From 22b32652d28f5b47609845aa3a1dd2c3da261346 Mon Sep 17 00:00:00 2001 From: Eike Stepper Date: Tue, 9 Oct 2007 13:56:18 +0000 Subject: [205668] Provide buddies example https://bugs.eclipse.org/bugs/show_bug.cgi?id=205668 --- .../internal/ui/views/CollaborationsView.java | 70 +++++++++++++++++++--- .../eclipse/net4j/util/ui/views/ContainerView.java | 9 +++ 2 files changed, 72 insertions(+), 7 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 935ae94f67..848c79595e 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,6 +11,8 @@ 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.widgets.Composite; @@ -24,6 +26,10 @@ public class CollaborationsView extends ContainerView implements IListener private Sash sash; + private Control leftControl; + + private Tree rightControl; + public CollaborationsView() { } @@ -41,24 +47,74 @@ public class CollaborationsView extends ContainerView implements IListener } @Override - protected synchronized Control createUI(Composite parent) + protected synchronized Control createUI(final Composite parent) { GridLayout grid = new GridLayout(3, false); grid.marginWidth = 0; grid.marginHeight = 0; grid.horizontalSpacing = 0; - Composite composite = new Composite(parent, SWT.NONE); + final Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(grid); - Control control = super.createUI(composite); - control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + 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)); - - Tree pane = new Tree(composite, SWT.NONE); - pane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + sash.addSelectionListener(new SelectionAdapter() + { + @Override + public void widgetSelected(SelectionEvent 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(); + } + }); + + rightControl = new Tree(composite, SWT.NONE); + rightControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); INSTANCE = this; return composite; diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java index 916369517f..a0cc10b00c 100644 --- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java +++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java @@ -28,6 +28,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.part.ISetSelectionTarget; @@ -35,6 +36,8 @@ import org.eclipse.ui.part.ViewPart; public abstract class ContainerView extends ViewPart implements ISetSelectionTarget { + private Shell shell; + private ContainerItemProvider> itemProvider; private TreeViewer viewer; @@ -55,6 +58,11 @@ public abstract class ContainerView extends ViewPart implements ISetSelectionTar { } + public Shell getShell() + { + return shell; + } + @Override public void setFocus() { @@ -92,6 +100,7 @@ public abstract class ContainerView extends ViewPart implements ISetSelectionTar @Override public final void createPartControl(Composite parent) { + shell = parent.getShell(); GridLayout grid = new GridLayout(1, false); grid.marginWidth = 0; grid.marginHeight = 0; -- cgit v1.2.3