Home » Eclipse Projects » Remote Application Platform (RAP) » Outlookbar
Outlookbar [message #50644] |
Wed, 03 October 2007 16:18 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
No real name![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=toolang%40gmail.com) Messages: 9 Registered: July 2009 |
Junior Member |
|
|
Hi,
My SWT Control Outlookbar working fine in RCP, but it seems that controls
cannot be setVisible(false) in RAP, there is my outlookbar demo code:
public class HideInvisibleComposite extends Composite {
public HideInvisibleComposite(Composite parent, int style) {
super(parent, style);
}
@Override
public Control[] getChildren() {
Control[] children = super.getChildren();
ArrayList<Control> list = new ArrayList<Control>();
for (Control control : children) {
if (control.isVisible()) {
list.add(control);
}
}
return list.toArray(new Control[list.size()]);
}
}
.......
public class OutlookBarItem {
private Button button;
private HideInvisibleComposite composite;
public OutlookBarItem(Button button, HideInvisibleComposite composite) {
this.button = button;
this.composite = composite;
}
public Button getButton() {
return button;
}
public void setButton(Button button) {
this.button = button;
}
public Composite getComposite() {
return composite;
}
public void setComposite(HideInvisibleComposite composite) {
this.composite = composite;
}
}
.......
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FillLayout());
outlookbar_composite = new HideInvisibleComposite(container, SWT.NONE);
outlookbar_composite.setLayout(new GridLayout());
//
button = new Button(outlookbar_composite, SWT.NONE);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Button button = (Button) e.getSource();
for (OutlookBarItem item : itemList) {
Composite com = item.getComposite();
if (item.getButton() == button) {
com.setVisible(true);
} else {
com.setVisible(false);
}
}
outlookbar_composite.layout();
}
});
final GridData gd_button_1 = new GridData(SWT.FILL, SWT.CENTER, true,
false);
button.setLayoutData(gd_button_1);
button.setText("Button A");
composite = new HideInvisibleComposite(outlookbar_composite, SWT.NONE);
composite.setLayout(new FillLayout());
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
list = new List(composite, SWT.BORDER);
list.add("List A");
list.add("List B");
list.add("List C");
itemList.add(new OutlookBarItem(button, composite));
//
button = new Button(outlookbar_composite, SWT.NONE);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Button button = (Button) e.getSource();
for (OutlookBarItem item : itemList) {
Composite com = item.getComposite();
if (item.getButton() == button) {
com.setVisible(true);
} else {
com.setVisible(false);
}
}
outlookbar_composite.layout();
}
});
final GridData gd_button_2 = new GridData(SWT.FILL, SWT.CENTER, false,
false);
button.setLayoutData(gd_button_2);
button.setText("Button C");
composite = new HideInvisibleComposite(outlookbar_composite, SWT.NONE);
composite.setLayout(new FillLayout());
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
composite.setVisible(false);
list = new List(composite, SWT.BORDER);
list.add("List A");
list.add("List B");
list.add("List C");
itemList.add(new OutlookBarItem(button, composite));
//
button = new Button(outlookbar_composite, SWT.NONE);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Button button = (Button) e.getSource();
for (OutlookBarItem item : itemList) {
Composite com = item.getComposite();
if (item.getButton() == button) {
com.setVisible(true);
} else {
com.setVisible(false);
}
}
outlookbar_composite.layout();
}
});
final GridData gd_button_3 = new GridData(SWT.FILL, SWT.CENTER, false,
false);
button.setLayoutData(gd_button_3);
button.setText("Button C");
composite = new HideInvisibleComposite(outlookbar_composite, SWT.NONE);
composite.setLayout(new FillLayout());
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
composite.setVisible(false);
list = new List(composite, SWT.BORDER);
list.add("List A");
list.add("List B");
list.add("List C");
itemList.add(new OutlookBarItem(button, composite));
//
button = new Button(outlookbar_composite, SWT.NONE);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Button button = (Button) e.getSource();
for (OutlookBarItem item : itemList) {
Composite com = item.getComposite();
if (item.getButton() == button) {
com.setVisible(true);
} else {
com.setVisible(false);
}
}
outlookbar_composite.layout();
}
});
final GridData gd_button_4 = new GridData(SWT.FILL, SWT.CENTER, false,
false);
button.setLayoutData(gd_button_4);
button.setText("Button D");
composite = new HideInvisibleComposite(outlookbar_composite, SWT.NONE);
composite.setLayout(new FillLayout());
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
composite.setVisible(false);
list = new List(composite, SWT.BORDER);
list.add("List A");
list.add("List B");
list.add("List C");
itemList.add(new OutlookBarItem(button, composite));
.......
|
|
|
Re: Outlookbar [message #51788 is a reply to message #50644] |
Tue, 16 October 2007 11:02 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
I tested the code you sent us and indeed the outlookbar doesn't work as
expected. The visibility of controls can be set in RWT the same way like it
is done in SWT. I think that the problem might be the HideInvisibleComposite
implementation. You are overriding getChildren in a way that breaks the
semantic of the orignal method. This may work well with SWT but probably
have serious concequences in RWT. This is because a lot of lifecycle
operations make use of the composite structure of the component tree, which
is corrupted by the HideInvisibleComposite#getChildren implementation.
If my assumption is right, you should try to find another way to implement
the outlook bar, that runs in both environments. I did this once by myself,
which was quite straight forward, but unfortunately I have lost that piece
of code...
Ciao
Frank
"toolang" <toolang@gmail.com> schrieb im Newsbeitrag
news:fe0fc3$sdr$1@build.eclipse.org...
> Hi,
>
> My SWT Control Outlookbar working fine in RCP, but it seems that controls
> cannot be setVisible(false) in RAP, there is my outlookbar demo code:
>
> public class HideInvisibleComposite extends Composite {
> public HideInvisibleComposite(Composite parent, int style) {
> super(parent, style);
> }
>
> @Override
> public Control[] getChildren() {
> Control[] children = super.getChildren();
> ArrayList<Control> list = new ArrayList<Control>();
> for (Control control : children) {
> if (control.isVisible()) {
> list.add(control);
> }
> }
> return list.toArray(new Control[list.size()]);
> }
> }
>
> ......
>
> public class OutlookBarItem {
>
> private Button button;
> private HideInvisibleComposite composite;
>
> public OutlookBarItem(Button button, HideInvisibleComposite composite) {
> this.button = button;
> this.composite = composite;
> }
>
> public Button getButton() {
> return button;
> }
>
> public void setButton(Button button) {
> this.button = button;
> }
>
> public Composite getComposite() {
> return composite;
> }
>
> public void setComposite(HideInvisibleComposite composite) {
> this.composite = composite;
> }
>
> }
>
> ......
>
> Composite container = new Composite(parent, SWT.NONE);
> container.setLayout(new FillLayout());
>
> outlookbar_composite = new HideInvisibleComposite(container, SWT.NONE);
> outlookbar_composite.setLayout(new GridLayout());
>
> //
> button = new Button(outlookbar_composite, SWT.NONE);
> button.addSelectionListener(new SelectionAdapter() {
> public void widgetSelected(SelectionEvent e) {
> Button button = (Button) e.getSource();
> for (OutlookBarItem item : itemList) {
> Composite com = item.getComposite();
> if (item.getButton() == button) {
> com.setVisible(true);
> } else {
> com.setVisible(false);
> }
> }
> outlookbar_composite.layout();
> }
> });
> final GridData gd_button_1 = new GridData(SWT.FILL, SWT.CENTER, true,
> false);
> button.setLayoutData(gd_button_1);
> button.setText("Button A");
>
> composite = new HideInvisibleComposite(outlookbar_composite, SWT.NONE);
> composite.setLayout(new FillLayout());
> composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
>
> list = new List(composite, SWT.BORDER);
> list.add("List A");
> list.add("List B");
> list.add("List C");
>
> itemList.add(new OutlookBarItem(button, composite));
>
> //
> button = new Button(outlookbar_composite, SWT.NONE);
> button.addSelectionListener(new SelectionAdapter() {
> public void widgetSelected(SelectionEvent e) {
> Button button = (Button) e.getSource();
> for (OutlookBarItem item : itemList) {
> Composite com = item.getComposite();
> if (item.getButton() == button) {
> com.setVisible(true);
> } else {
> com.setVisible(false);
> }
> }
> outlookbar_composite.layout();
> }
> });
> final GridData gd_button_2 = new GridData(SWT.FILL, SWT.CENTER, false,
> false);
> button.setLayoutData(gd_button_2);
> button.setText("Button C");
>
> composite = new HideInvisibleComposite(outlookbar_composite, SWT.NONE);
> composite.setLayout(new FillLayout());
> composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
>
> composite.setVisible(false);
>
> list = new List(composite, SWT.BORDER);
> list.add("List A");
> list.add("List B");
> list.add("List C");
>
> itemList.add(new OutlookBarItem(button, composite));
>
> //
> button = new Button(outlookbar_composite, SWT.NONE);
> button.addSelectionListener(new SelectionAdapter() {
> public void widgetSelected(SelectionEvent e) {
> Button button = (Button) e.getSource();
> for (OutlookBarItem item : itemList) {
> Composite com = item.getComposite();
> if (item.getButton() == button) {
> com.setVisible(true);
> } else {
> com.setVisible(false);
> }
> }
> outlookbar_composite.layout();
> }
> });
> final GridData gd_button_3 = new GridData(SWT.FILL, SWT.CENTER, false,
> false);
> button.setLayoutData(gd_button_3);
> button.setText("Button C");
>
> composite = new HideInvisibleComposite(outlookbar_composite, SWT.NONE);
> composite.setLayout(new FillLayout());
> composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
>
> composite.setVisible(false);
>
> list = new List(composite, SWT.BORDER);
> list.add("List A");
> list.add("List B");
> list.add("List C");
>
> itemList.add(new OutlookBarItem(button, composite));
>
> //
> button = new Button(outlookbar_composite, SWT.NONE);
> button.addSelectionListener(new SelectionAdapter() {
> public void widgetSelected(SelectionEvent e) {
> Button button = (Button) e.getSource();
> for (OutlookBarItem item : itemList) {
> Composite com = item.getComposite();
> if (item.getButton() == button) {
> com.setVisible(true);
> } else {
> com.setVisible(false);
> }
> }
> outlookbar_composite.layout();
> }
> });
> final GridData gd_button_4 = new GridData(SWT.FILL, SWT.CENTER, false,
> false);
> button.setLayoutData(gd_button_4);
> button.setText("Button D");
>
> composite = new HideInvisibleComposite(outlookbar_composite, SWT.NONE);
> composite.setLayout(new FillLayout());
> composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
>
> composite.setVisible(false);
>
> list = new List(composite, SWT.BORDER);
> list.add("List A");
> list.add("List B");
> list.add("List C");
>
> itemList.add(new OutlookBarItem(button, composite));
>
> ......
>
>
>
>
|
|
|
Goto Forum:
Current Time: Fri Oct 18 02:48:04 GMT 2024
Powered by FUDForum. Page generated in 0.02964 seconds
|