Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » problem with change the conotrol's position on a composite.
problem with change the conotrol's position on a composite. [message #466008] Thu, 12 April 2007 09:35 Go to next message
dl is currently offline dlFriend
Messages: 33
Registered: July 2009
Member
I have a problem with change the conotrol's position on a composite.


Problem description:

ViewPart create two contols on it's composite
via method createPartControl (Composite parent).

Controls are:
TreeViewer and Label

So, actual apperance is like:

------------------------
| label |
------------------------
| |
| |
| tree viewer |
| |
| |
-------------------------

Now, I have an action which can hide
label control via setVisible(boolean).

If that happens, then the tree viewer
must occupy all composite,
so I have written a method for change
the tree viewer location, and it works.

But, when I resize this View Part,
this previous method has no efect,
and the controls are positioned
like at the beginng (picture above).

Interesting, when I dispose the
Label via dispose() method,
the described problem doesn't exist.


Please, tell me where is a mistake,
and what should I do.

A lot of greetings.
Daniel.
Re: problem with change the conotrol's position on a composite. [message #466018 is a reply to message #466008] Thu, 12 April 2007 12:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: valere.fedronic.ext.streamezzo.com

hi,

I think you should use a form layout.

Composite wrapper;
createPartControl (Composite parent)
{

wrapper = new Composite(parent,SWT.default);
wrapper.setLayout(new Formlayout());

label = new Label(wrapper,SWT.default);
treeViewer = new TreeViewer(wrapper);

....

FormData data = new FormData();
data.top = new FormAttachement(0,0);
data.left = new FormAttachement(0,0);
data.right= new FormAttachement(100,0);
label.setLayoutData(data);

data = new FormData();
data.top = new FormAttachement(label);
data.left = new FormAttachement(0,0);
data.right= new FormAttachement(100,0);
data.bottom= new FormAttachement(100,0);
treeViewer.getControl().setLayoutData(data);

}

And then your action can use this :

public void setShowLabel(boolean visible)
{
if(visible)
{
FormData data = (FormData) treeViewer.getControl().getLayoutData();
data.top = new FormAttachement(label);
treeViewer.getControl().setLayoutData(data);
label.setVisible(true);
}
else
{
FormData data = (FormData) treeViewer.getControl().getLayoutData();
data.top = new FormAttachement(0,0);
treeViewer.getControl().setLayoutData(data);
label.setVisible(false);
}
wrapper.layout();

}

Create a wrapping composite with a form layout();
Daniel Ladavac wrote:
> I have a problem with change the conotrol's position on a composite.
>
>
> Problem description:
>
> ViewPart create two contols on it's composite
> via method createPartControl (Composite parent).
>
> Controls are:
> TreeViewer and Label
>
> So, actual apperance is like:
>
> ------------------------
> | label |
> ------------------------
> | |
> | |
> | tree viewer |
> | |
> | |
> -------------------------
>
> Now, I have an action which can hide
> label control via setVisible(boolean).
>
> If that happens, then the tree viewer
> must occupy all composite,
> so I have written a method for change
> the tree viewer location, and it works.
>
> But, when I resize this View Part,
> this previous method has no efect,
> and the controls are positioned
> like at the beginng (picture above).
>
> Interesting, when I dispose the
> Label via dispose() method,
> the described problem doesn't exist.
>
>
> Please, tell me where is a mistake,
> and what should I do.
>
> A lot of greetings.
> Daniel.
>
>
>
>
>
Re: problem with change the conotrol's position on a composite. [message #466032 is a reply to message #466008] Thu, 12 April 2007 17:12 Go to previous messageGo to next message
Chris Audley is currently offline Chris AudleyFriend
Messages: 41
Registered: July 2009
Member
You didn't indicate what layout manager you are using for the ViewPart.

When the layout manager is placing controls on the composite, it is
still leaving room for the controls you have set visible=false on. If
you manually reposition any of the control, your work will be undone as
soon as the layout manager is run again (as you have discovered). What
you need is to force the layout manager to leave the control out of the
layout.

The GridLayout and RowLayout provide a means for doing this. In the
layout data for the control, there is a field called "exclude" which
will force the layout manager to leave the control out of the layout if
set to true.

In the code where you have control.setVisible(false)
try ((GridData)control.getLayoutData()).exclude = true

Cheers
Chris

Daniel Ladavac wrote:
> I have a problem with change the conotrol's position on a composite.
>
>
> Problem description:
>
> ViewPart create two contols on it's composite
> via method createPartControl (Composite parent).
>
> Controls are:
> TreeViewer and Label
>
> So, actual apperance is like:
>
> ------------------------
> | label |
> ------------------------
> | |
> | |
> | tree viewer |
> | |
> | |
> -------------------------
>
> Now, I have an action which can hide
> label control via setVisible(boolean).
>
> If that happens, then the tree viewer
> must occupy all composite,
> so I have written a method for change
> the tree viewer location, and it works.
>
> But, when I resize this View Part,
> this previous method has no efect,
> and the controls are positioned
> like at the beginng (picture above).
>
> Interesting, when I dispose the
> Label via dispose() method,
> the described problem doesn't exist.
>
>
> Please, tell me where is a mistake,
> and what should I do.
>
> A lot of greetings.
> Daniel.
>
>
>
>
>
Re: problem with change the conotrol's position on a composite. [message #466034 is a reply to message #466032] Thu, 12 April 2007 17:14 Go to previous messageGo to next message
Chris Audley is currently offline Chris AudleyFriend
Messages: 41
Registered: July 2009
Member
I failed to mention, when you change the settings on the layout data for
a control, you must re-run layout on the composite. After setting the
exclude flag on your label's layout data, call layout() on the composite.

Chris Audley wrote:
> You didn't indicate what layout manager you are using for the ViewPart.
>
> When the layout manager is placing controls on the composite, it is
> still leaving room for the controls you have set visible=false on. If
> you manually reposition any of the control, your work will be undone as
> soon as the layout manager is run again (as you have discovered). What
> you need is to force the layout manager to leave the control out of the
> layout.
>
> The GridLayout and RowLayout provide a means for doing this. In the
> layout data for the control, there is a field called "exclude" which
> will force the layout manager to leave the control out of the layout if
> set to true.
>
> In the code where you have control.setVisible(false)
> try ((GridData)control.getLayoutData()).exclude = true
>
> Cheers
> Chris
>
> Daniel Ladavac wrote:
>> I have a problem with change the conotrol's position on a composite.
>>
>>
>> Problem description:
>>
>> ViewPart create two contols on it's composite
>> via method createPartControl (Composite parent).
>>
>> Controls are:
>> TreeViewer and Label
>>
>> So, actual apperance is like:
>>
>> ------------------------
>> | label |
>> ------------------------
>> | |
>> | |
>> | tree viewer |
>> | |
>> | |
>> -------------------------
>>
>> Now, I have an action which can hide
>> label control via setVisible(boolean).
>>
>> If that happens, then the tree viewer
>> must occupy all composite,
>> so I have written a method for change
>> the tree viewer location, and it works.
>>
>> But, when I resize this View Part,
>> this previous method has no efect,
>> and the controls are positioned
>> like at the beginng (picture above).
>>
>> Interesting, when I dispose the
>> Label via dispose() method,
>> the described problem doesn't exist.
>>
>>
>> Please, tell me where is a mistake,
>> and what should I do.
>>
>> A lot of greetings.
>> Daniel.
>>
>>
>>
>>
>>
Re: problem with change the conotrol's position on a composite. [message #466210 is a reply to message #466008] Mon, 16 April 2007 13:41 Go to previous message
dl is currently offline dlFriend
Messages: 33
Registered: July 2009
Member
Thank you all for your time and suggestions... I didn't try yet because I
was doing sth else, but when I try to solve this problem I will post here
about results. Have a nice day Fedronic & Audley ;)
Previous Topic:Re: Opening editors without specifying extensions or file names
Next Topic:Strange Problem about rcp quit unexpectedly.
Goto Forum:
  


Current Time: Thu Apr 25 22:58:51 GMT 2024

Powered by FUDForum. Page generated in 0.03933 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top