Fix for bug 55201: clicking on an empty editor area should close the active fast view
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewPane.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewPane.java
index 7648dc2..4e70bef 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewPane.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/FastViewPane.java
@@ -25,11 +25,13 @@
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Sash;
+import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.internal.dnd.DragUtil;
import org.eclipse.ui.internal.presentations.SystemMenuClose;
import org.eclipse.ui.internal.presentations.SystemMenuMaximize;
@@ -76,7 +78,7 @@
ViewPane pane = currentPane;
switch(newState) {
case IStackPresentationSite.STATE_MINIMIZED:
- currentPane.getPage().toggleFastView(currentPane.getViewReference());
+ currentPane.getPage().toggleFastView(null);//currentPane.getViewReference());
break;
case IStackPresentationSite.STATE_MAXIMIZED:
sash.setVisible(false);
@@ -169,6 +171,35 @@
}
}
+ private Listener mouseDownListener = new Listener() {
+ public void handleEvent(Event event) {
+ if (event.widget instanceof Control) {
+ Control control = (Control)event.widget;
+
+ if (control.getShell() != clientComposite.getShell()) {
+ return;
+ }
+
+ if (event.widget instanceof ToolBar) {
+ // Ignore mouse down on actual tool bar buttons
+ Point pt = new Point(event.x, event.y);
+ ToolBar toolBar = (ToolBar) event.widget;
+ if (toolBar.getItem(pt) != null)
+ return;
+ }
+
+ Point loc = DragUtil.getEventLoc(event);
+
+ Rectangle bounds = DragUtil.getDisplayBounds(clientComposite);
+ bounds = Geometry.getExtrudedEdge(bounds, size + SASH_SIZE, side);
+
+ if (!bounds.contains(loc)) {
+ site.setState(IStackPresentationSite.STATE_MINIMIZED);
+ }
+ }
+ }
+ };
+
private IContributionItem systemMenuContribution;
public void moveSash() {
@@ -357,6 +388,9 @@
setSize((int)(Geometry.getDimension(clientArea, !horizontal) * sizeRatio));
+ Display display = sash.getDisplay();
+
+ display.addFilter(SWT.MouseDown, mouseDownListener);
}
/**
@@ -382,6 +416,12 @@
* of the view itself.
*/
public void dispose() {
+ if (clientComposite != null) {
+ Display display = clientComposite.getDisplay();
+
+ display.removeFilter(SWT.MouseDown, mouseDownListener);
+ }
+
if (sash != null) {
sash.dispose();
}
@@ -440,6 +480,12 @@
*/
public void hideView() {
+ if (clientComposite != null) {
+ Display display = clientComposite.getDisplay();
+
+ display.removeFilter(SWT.MouseDown, mouseDownListener);
+ }
+
if (currentPane == null) {
return;
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutPartSash.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutPartSash.java
index 50359bd..e7f489c 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutPartSash.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/LayoutPartSash.java
@@ -100,7 +100,6 @@
public void createControl(Composite parent) {
if (sash == null) {
sash = new Sash(parent, style);
- sash.addListener(SWT.MouseDown, rootContainer.getMouseDownListener());
sash.addSelectionListener(selectionListener);
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java
index a80e2de..1c29075 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSashContainer.java
@@ -25,8 +25,6 @@
import org.eclipse.swt.graphics.Rectangle;
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.ui.IPageLayout;
import org.eclipse.ui.internal.dnd.AbstractDropTarget;
import org.eclipse.ui.internal.dnd.CompatibilityDragTarget;
@@ -47,7 +45,6 @@
protected ControlListener resizeListener;
protected LayoutTree root;
protected LayoutTree unzoomRoot;
- protected Listener mouseDownListener;
protected WorkbenchPage page;
boolean active = false;
@@ -112,14 +109,6 @@
resizeSashes(parent.getClientArea());
}
};
- // Mouse down listener to hide fast view when
- // user clicks on empty editor area or sashes.
- mouseDownListener = new Listener() {
- public void handleEvent(Event event) {
- if (event.type == SWT.MouseDown)
- page.toggleFastView(null);
- }
- };
}
/**
* Find the sashs around the specified part.
@@ -205,18 +194,9 @@
info.relative = relative;
addChild(info);
}
-private void addChild(RelationshipInfo info) {
+protected void addChild(RelationshipInfo info) {
LayoutPart child = info.part;
- // Nasty hack: ensure that all views end up inside a tab folder.
- // Since the view title is provided by the tab folder, this ensures
- // that views don't get created without a title tab.
- if (child instanceof ViewPane) {
- PartTabFolder folder = new PartTabFolder(page);
- folder.add(child);
- child = folder;
- }
-
children.add(child);
if(root == null) {
@@ -436,19 +416,13 @@
return page;
}
/**
- * Return the interested listener of mouse down events.
- */
-protected Listener getMouseDownListener() {
- return mouseDownListener;
-}
-/**
* Returns the composite used to parent all the
* layout parts contained within.
*/
public Composite getParent() {
return parent;
}
-private boolean isChild(LayoutPart part) {
+protected boolean isChild(LayoutPart part) {
return children.indexOf(part) >= 0;
}
private boolean isRelationshipCompatible(int relationship,boolean isVertical) {
@@ -524,16 +498,7 @@
zoomOut();
if (!isChild(oldChild))return;
-
- // Nasty hack: ensure that all views end up inside a tab folder.
- // Since the view title is provided by the tab folder, this ensures
- // that views don't get created without a title tab.
- if (newChild instanceof ViewPane) {
- PartTabFolder folder = new PartTabFolder(page);
- folder.add(newChild);
- newChild = folder;
- }
-
+
children.remove(oldChild);
children.add(newChild);
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/RootLayoutContainer.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/RootLayoutContainer.java
index d7f1876..895999d 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/RootLayoutContainer.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/RootLayoutContainer.java
@@ -253,4 +253,41 @@
page.getActivePerspective().getPresentation().derefPart(sourcePart);
}
+/* (non-Javadoc)
+ * @see org.eclipse.ui.internal.PartSashContainer#addChild(org.eclipse.ui.internal.PartSashContainer.RelationshipInfo)
+ */
+protected void addChild(RelationshipInfo info) {
+ LayoutPart child = info.part;
+
+ // Nasty hack: ensure that all views end up inside a tab folder.
+ // Since the view title is provided by the tab folder, this ensures
+ // that views don't get created without a title tab.
+ if (child instanceof ViewPane) {
+ PartTabFolder folder = new PartTabFolder(page);
+ folder.add(child);
+ info.part = folder;
+ }
+
+ super.addChild(info);
+}
+
+/* (non-Javadoc)
+ * @see org.eclipse.ui.internal.ILayoutContainer#replace(org.eclipse.ui.internal.LayoutPart, org.eclipse.ui.internal.LayoutPart)
+ */
+public void replace(LayoutPart oldChild, LayoutPart newChild) {
+ if (!isChild(oldChild)) {
+ return;
+ }
+
+ // Nasty hack: ensure that all views end up inside a tab folder.
+ // Since the view title is provided by the tab folder, this ensures
+ // that views don't get created without a title tab.
+ if (newChild instanceof ViewPane) {
+ PartTabFolder folder = new PartTabFolder(page);
+ folder.add(newChild);
+ newChild = folder;
+ }
+
+ super.replace(oldChild, newChild);
+}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewPane.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewPane.java
index ffa14cc..40192d3 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewPane.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewPane.java
@@ -27,7 +27,6 @@
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
@@ -39,7 +38,6 @@
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.internal.dnd.AbstractDragSource;
import org.eclipse.ui.internal.dnd.DragUtil;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.part.WorkbenchPart;
@@ -130,22 +128,6 @@
return;
super.createControl(parent);
-
- DragUtil.addDragSource(control, new AbstractDragSource() {
-
- public Object getDraggedItem(Point position) {
- return ViewPane.this;
- }
-
- public void dragStarted(Object draggedItem) {
- getPage().getActivePerspective().setActiveFastView(null, 0);
- }
-
- public Rectangle getDragRectangle(Object draggedItem) {
- return DragUtil.getDisplayBounds(control);
- }
-
- });
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java
index b306068..4bb9cc1 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java
@@ -674,37 +674,6 @@
trimDropTarget = new TrimDropTarget(shell, this);
DragUtil.addDragTarget(shell, trimDropTarget);
- // If the user clicks on toolbar, status bar, or shortcut bar
- // hide the fast view.
- Listener listener = new Listener() {
- public void handleEvent(Event event) {
- WorkbenchPage currentPage = getActiveWorkbenchPage();
- if (currentPage != null) {
- if (event.type == SWT.MouseDown) {
- if (event.widget instanceof ToolBar) {
- // Ignore mouse down on actual tool bar buttons
- Point pt = new Point(event.x, event.y);
- ToolBar toolBar = (ToolBar) event.widget;
- if (toolBar.getItem(pt) != null)
- return;
- }
- currentPage.toggleFastView(null);
- }
- }
- }
- };
- topBar.addListener(SWT.MouseDown, listener);
- getCoolBarControl().addListener(SWT.MouseDown, listener);
- Control[] children = ((Composite) getStatusLineManager().getControl()).getChildren();
- for (int i = 0; i < children.length; i++) {
- if (children[i] != null)
- children[i].addListener(SWT.MouseDown, listener);
- }
- //fastViewBar.getControl().addListener(SWT.MouseDown, listener);
- if (perspectiveBar.getControl() != null) {
- perspectiveBar.getControl().addListener(SWT.MouseDown, listener);
- }
-
// Create the client composite area (where page content goes).
createPageComposite(shell);
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dnd/DragUtil.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dnd/DragUtil.java
index 20766f9..cdf58ae 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dnd/DragUtil.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dnd/DragUtil.java
@@ -298,5 +298,14 @@
// No controls could handle this event -- check for default targets
return getDropTarget(defaultTargets, toSearch, draggedObject, position, dragRectangle);
}
+
+ /**
+ * Returns the location of the given event, in display coordinates
+ * @return
+ */
+ public static Point getEventLoc(Event event) {
+ Control ctrl = (Control)event.widget;
+ return ctrl.toDisplay(new Point(event.x, event.y));
+ }
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/presentations/PresentationUtil.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/presentations/PresentationUtil.java
index f422c19..0e2ce5f 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/presentations/PresentationUtil.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/presentations/PresentationUtil.java
@@ -16,6 +16,7 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.internal.dnd.DragUtil;
/**
* Contains various utility methods for Presentation authors
@@ -40,19 +41,10 @@
* opening a tracker.
*/
private static boolean hasMovedEnough(Event event) {
- return Geometry.distanceSquared(getEventLoc(event), anchor)
+ return Geometry.distanceSquared(DragUtil.getEventLoc(event), anchor)
>= HYSTERESIS * HYSTERESIS;
}
- /**
- * Returns the location of the given event, in display coordinates
- * @return
- */
- private static Point getEventLoc(Event event) {
- Control ctrl = (Control)event.widget;
- return ctrl.toDisplay(new Point(event.x, event.y));
- }
-
private static Listener moveListener = new Listener() {
public void handleEvent(Event event) {
handleMouseMove(event);
@@ -70,7 +62,7 @@
if (event.widget instanceof Control) {
Control dragControl = (Control)event.widget;
currentListener = (Listener)dragControl.getData(LISTENER_ID);
- anchor = getEventLoc(event);
+ anchor = DragUtil.getEventLoc(event);
}
}
};