Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Change control's position on a composite ???
Change control's position on a composite ??? [message #204458] Thu, 12 April 2007 09:12 Go to next message
dl is currently offline dlFriend
Messages: 33
Registered: July 2009
Member
Hi to all!
I have a problem with change the control'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 effect,
and the controls are positioned
like at the beginning (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: Change control's position on a composite ??? [message #204995 is a reply to message #204458] Sun, 15 April 2007 15:04 Go to previous message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

how about something like this. Instead of writing my own routine to
place the controls, I just use the grid layout and let it do the work.
I basically merged snippet 15 and snippet 175
(http://www.eclipse.org/swt/snippets/)


/*
* Tree example snippet: create a tree
*
* For a list of all SWT example snippets see
* http://www.eclipse.org/swt/snippets/
*/
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;

public class Snippet15 {

public static void main(String[] args) {
Display display = new Display();
final Shell shell = new Shell(display);
GridData gd = null;

gd = new GridData(SWT.FILL, SWT.FILL, true, false);

final Label label = new Label(shell, SWT.NONE);
label.setLayoutData(gd);

label.setText("This is some label:");
shell.setLayout(new GridLayout());
final Tree tree = new Tree(shell, SWT.BORDER);
for (int i = 0; i < 4; i++) {
TreeItem iItem = new TreeItem(tree, 0);
iItem.setText("TreeItem (0) -" + i);
for (int j = 0; j < 4; j++) {
TreeItem jItem = new TreeItem(iItem, 0);
jItem.setText("TreeItem (1) -" + j);
for (int k = 0; k < 4; k++) {
TreeItem kItem = new TreeItem(jItem, 0);
kItem.setText("TreeItem (2) -" + k);
for (int l = 0; l < 4; l++) {
TreeItem lItem = new TreeItem(kItem, 0);
lItem.setText("TreeItem (3) -" + l);
}
}
}
}
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
tree.setLayoutData(gd);

Button button = new Button(shell, SWT.PUSH);
button.setText("Hide Label");
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
button.setLayoutData(gd);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
GridData data = (GridData) label.getLayoutData();
data.exclude = !data.exclude;
label.setVisible(!data.exclude);
shell.layout();
}
});
shell.setSize(200, 200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}

Daddo wrote:
> Hi to all!
> I have a problem with change the control'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 effect,
> and the controls are positioned
> like at the beginning (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.
>
Previous Topic:Where Is The Missing Source of SWT Examples?
Next Topic:creating customized table in swt
Goto Forum:
  


Current Time: Thu Apr 25 03:56:47 GMT 2024

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

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

Back to the top