Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2018-02-18 04:37:59 -0500
committerAndrey Loskutov2018-02-18 08:22:39 -0500
commitd1f97f64e7962451e851095d52726adbbc861cf4 (patch)
treed15ba271da41793f977f2ddb908e1ef60be56131 /org.eclipse.ui.console
parent9e580523e2e39e00b1ed554274af916a9f15605f (diff)
downloadeclipse.platform.debug-d1f97f64e7962451e851095d52726adbbc861cf4.tar.gz
eclipse.platform.debug-d1f97f64e7962451e851095d52726adbbc861cf4.tar.xz
eclipse.platform.debug-d1f97f64e7962451e851095d52726adbbc861cf4.zip
Bug 531241 - ConsoleDropDownAction and OpenConsoleAction disposed onI20180218-2000
perspective reset Change-Id: I4c4d6f1741ee58e34977465226e127590dcc932c Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.ui.console')
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDropDownAction.java25
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java4
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java7
3 files changed, 32 insertions, 4 deletions
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDropDownAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDropDownAction.java
index 3d34f1a73..f3b3d9359 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDropDownAction.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDropDownAction.java
@@ -18,8 +18,13 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
@@ -44,12 +49,11 @@ class ConsoleDropDownAction extends Action implements IMenuCreator, IConsoleList
}
public ConsoleDropDownAction(IConsoleView view) {
+ super(ConsoleMessages.ConsoleDropDownAction_0, AS_DROP_DOWN_MENU);
fView= view;
- setText(ConsoleMessages.ConsoleDropDownAction_0);
setToolTipText(ConsoleMessages.ConsoleDropDownAction_1);
setImageDescriptor(ConsolePluginImages.getImageDescriptor(IConsoleConstants.IMG_VIEW_CONSOLE));
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CONSOLE_DISPLAY_CONSOLE_ACTION);
- setMenuCreator(this);
ConsolePlugin.getDefault().getConsoleManager().addConsoleListener(this);
update();
}
@@ -132,6 +136,23 @@ class ConsoleDropDownAction extends Action implements IMenuCreator, IConsoleList
}
@Override
+ public void runWithEvent(Event event) {
+ // Show menu on drop-down button, run action otherwise
+ if (event.detail == SWT.ARROW && event.widget instanceof ToolItem) {
+ ToolItem toolItem = (ToolItem) event.widget;
+ Control control = toolItem.getParent();
+ Menu menu = getMenu(control);
+
+ Rectangle bounds = toolItem.getBounds();
+ Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
+ menu.setLocation(control.toDisplay(topLeft));
+ menu.setVisible(true);
+ } else {
+ run();
+ }
+ }
+
+ @Override
public void consolesAdded(IConsole[] consoles) {
UIJob job = new UIJob(ConsoleMessages.UpdatingConsoleState) {
@Override
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java
index 02fac9708..ff7c5f18e 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java
@@ -359,6 +359,10 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL
fDisplayConsoleAction.dispose();
fDisplayConsoleAction = null;
}
+ if (fOpenConsoleAction != null) {
+ fOpenConsoleAction.dispose();
+ fOpenConsoleAction = null;
+ }
}
/**
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java
index 0927e14a2..ad9a8fb7f 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java
@@ -39,12 +39,11 @@ public class OpenConsoleAction extends Action implements IMenuCreator {
private Menu fMenu;
public OpenConsoleAction() {
+ super(ConsoleMessages.OpenConsoleAction_0, AS_DROP_DOWN_MENU);
fFactoryExtensions = getSortedFactories();
- setText(ConsoleMessages.OpenConsoleAction_0);
setToolTipText(ConsoleMessages.OpenConsoleAction_1);
setImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_NEW_CON));
setDisabledImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_DLCL_NEW_CON));
- setMenuCreator(this);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CONSOLE_OPEN_CONSOLE_ACTION);
}
@@ -71,6 +70,10 @@ public class OpenConsoleAction extends Action implements IMenuCreator {
@Override
public void dispose() {
fFactoryExtensions = null;
+ if (fMenu != null) {
+ fMenu.dispose();
+ fMenu = null;
+ }
}
@Override

Back to the top