summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-09 10:04:20 (EDT)
committerEike Stepper2007-10-09 10:04:20 (EDT)
commite463ea9e7e8e8b4da1a257eb3e1a108c7e990370 (patch)
tree73c0d631d0aa3d8af7e102bd48c5378e56428632
parent22b32652d28f5b47609845aa3a1dd2c3da261346 (diff)
downloadcdo-e463ea9e7e8e8b4da1a257eb3e1a108c7e990370.zip
cdo-e463ea9e7e8e8b4da1a257eb3e1a108c7e990370.tar.gz
cdo-e463ea9e7e8e8b4da1a257eb3e1a108c7e990370.tar.bz2
[205668] Provide buddies example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205668
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java104
1 files changed, 43 insertions, 61 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java
index 848c795..0b0588b 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java
@@ -11,17 +11,23 @@ import org.eclipse.net4j.util.ui.views.ContainerView;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
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.graphics.Rectangle;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Sash;
import org.eclipse.swt.widgets.Tree;
public class CollaborationsView extends ContainerView implements IListener
{
+ private static final int LIMIT = 10;
+
+ private static final int PERCENT = 30;
+
private static CollaborationsView INSTANCE;
private Sash sash;
@@ -49,72 +55,48 @@ public class CollaborationsView extends ContainerView implements IListener
@Override
protected synchronized Control createUI(final Composite parent)
{
- GridLayout grid = new GridLayout(3, false);
- grid.marginWidth = 0;
- grid.marginHeight = 0;
- grid.horizontalSpacing = 0;
-
+ final FormLayout form = new FormLayout();
final Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(grid);
+ composite.setLayout(form);
leftControl = super.createUI(composite);
- leftControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
sash = new Sash(composite, SWT.VERTICAL);
- sash.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- sash.addSelectionListener(new SelectionAdapter()
+ rightControl = new Tree(composite, SWT.NONE);
+
+ FormData leftControlData = new FormData();
+ leftControlData.left = new FormAttachment(0, 0);
+ leftControlData.right = new FormAttachment(sash, 0);
+ leftControlData.top = new FormAttachment(0, 0);
+ leftControlData.bottom = new FormAttachment(100, 0);
+ leftControl.setLayoutData(leftControlData);
+
+ final FormData sashData = new FormData();
+ sashData.left = new FormAttachment(PERCENT, 0);
+ sashData.top = new FormAttachment(0, 0);
+ sashData.bottom = new FormAttachment(100, 0);
+ sash.setLayoutData(sashData);
+ sash.addListener(SWT.Selection, new Listener()
{
- @Override
- public void widgetSelected(SelectionEvent e)
+ public void handleEvent(Event e)
{
- sash.setBounds(e.x, e.y, e.width, e.height);
- composite.layout(true);
-
- // if (event.detail == SWT.DRAG)
- // {
- // return;
- // }
- //
- // int shift = event.x - sash.getBounds().x;
- // GridData data = (GridData)rightControl.getLayoutData();
- // int newWidthHint = data.widthHint + shift;
- // if (newWidthHint < 20)
- // {
- // return;
- // }
- //
- // Point computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
- // Point currentSize = getShell().getSize();
- //
- // // if the dialog wasn't of a custom size we know we can shrink
- // // it if necessary based on sash movement.
- // boolean customSize = !computedSize.equals(currentSize);
- // data.widthHint = newWidthHint;
- // composite.layout(true);
- //
- // // recompute based on new widget size
- // computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
- //
- // // if the dialog was of a custom size then increase it only if
- // // necessary.
- // if (customSize)
- // {
- // computedSize.x = Math.max(computedSize.x, currentSize.x);
- // }
- //
- // computedSize.y = Math.max(computedSize.y, currentSize.y);
- // if (computedSize.equals(currentSize))
- // {
- // return;
- // }
- //
- // compo(computedSize.x, computedSize.y);
- // lastShellSize = getShell().getSize();
+ Rectangle sashRect = sash.getBounds();
+ Rectangle shellRect = composite.getClientArea();
+ int right = shellRect.width - sashRect.width - LIMIT;
+ e.x = Math.max(Math.min(e.x, right), LIMIT);
+ if (e.x != sashRect.x)
+ {
+ sashData.left = new FormAttachment(0, e.x);
+ composite.layout();
+ }
}
});
- rightControl = new Tree(composite, SWT.NONE);
- rightControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ FormData rightControlData = new FormData();
+ rightControlData.left = new FormAttachment(sash, 0);
+ rightControlData.right = new FormAttachment(100, 0);
+ rightControlData.top = new FormAttachment(0, 0);
+ rightControlData.bottom = new FormAttachment(100, 0);
+ rightControl.setLayoutData(rightControlData);
INSTANCE = this;
return composite;