diff options
author | Sami Wagiaalla | 2012-12-14 15:21:32 +0000 |
---|---|---|
committer | Camilo Bernal | 2012-12-17 19:01:59 +0000 |
commit | a27b20c009899e41fe83c07292384825c4b5160d (patch) | |
tree | d224232ef9826fdfba075e803f0c8e6ca682d5b6 | |
parent | ac0ad05a39f462676564834a425e5ed74e8dc015 (diff) | |
download | org.eclipse.linuxtools-a27b20c009899e41fe83c07292384825c4b5160d.tar.gz org.eclipse.linuxtools-a27b20c009899e41fe83c07292384825c4b5160d.tar.xz org.eclipse.linuxtools-a27b20c009899e41fe83c07292384825c4b5160d.zip |
Move stop button to the console
Change-Id: I0597de10ad8d5b8900289a1cb385fcdfeb55866f
Reviewed-on: https://git.eclipse.org/r/9243
Reviewed-by: Camilo Bernal <cabernal@redhat.com>
IP-Clean: Camilo Bernal <cabernal@redhat.com>
Tested-by: Camilo Bernal <cabernal@redhat.com>
6 files changed, 58 insertions, 13 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/icons/actions/stop_script.gif b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/icons/actions/stop_script.gif Binary files differnew file mode 100644 index 0000000000..dc47edf069 --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/icons/actions/stop_script.gif diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/plugin.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/plugin.properties index 225f0ee3d1..ac605519b1 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/plugin.properties +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/plugin.properties @@ -6,3 +6,6 @@ action.saveLog.name=Save &Log action.saveLog.desc=Save console log to file preference.consoleLog.name=Remote Server + +action.stopScript.name=Stop Script +action.stopScript.desc=Stop the script currently running in this console. diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/plugin.xml b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/plugin.xml index 132cca1217..4cb4274d1a 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/plugin.xml +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/plugin.xml @@ -27,6 +27,16 @@ toolbarPath="launchGroup" state="false" style="push"/> + <action + class="org.eclipse.linuxtools.systemtap.ui.consolelog.actions.StopScriptAction" + icon="icons/actions/stop_script.gif" + id="org.eclipse.linuxtools.systemtap.ui.consolelog.stopScriptAction" + label="%action.stopScript.name" + state="true" + style="push" + toolbarPath="launchGroup" + tooltip="%action.stopScript.desc"> + </action> </viewContribution> </extension> diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/actions/StopScriptAction.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/actions/StopScriptAction.java index 0d8b75225e..cbf5514b1d 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/actions/StopScriptAction.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/actions/StopScriptAction.java @@ -14,6 +14,8 @@ package org.eclipse.linuxtools.systemtap.ui.consolelog.actions; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.linuxtools.systemtap.ui.consolelog.structures.ScriptConsole; +import org.eclipse.ui.IPropertyListener; +import org.eclipse.ui.IViewPart; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.IConsole; @@ -25,6 +27,9 @@ import org.eclipse.ui.console.IConsole; * @author Ryan Morse */ public class StopScriptAction extends ConsoleAction { + + private IAction action; + /** * This is the main method of the class. It handles stopping the * currently active <code>ScriptConsole</code>. @@ -42,9 +47,25 @@ public class StopScriptAction extends ConsoleAction { } @Override - public void selectionChanged(IAction a, ISelection s) { - a.setEnabled(anyRunning()); + public void init(IViewPart view) { + updateEnablement(); + view.addPropertyListener(new IPropertyListener() { + public void propertyChanged(Object source, int propId) { + updateEnablement(); } + }); + } + + private void updateEnablement(){ + if (this.action != null) + this.action.setEnabled(ScriptConsole.isActiveConsoleRunning()); + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + this.action = action; + updateEnablement(); + } /** diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/ScriptConsole.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/ScriptConsole.java index 18d81b2b80..69b389f3b4 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/ScriptConsole.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/ScriptConsole.java @@ -28,6 +28,8 @@ import org.eclipse.ui.IViewPart; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.IConsole; +import org.eclipse.ui.console.IConsoleConstants; +import org.eclipse.ui.console.IConsoleView; import org.eclipse.ui.console.IOConsole; @@ -91,6 +93,25 @@ public class ScriptConsole extends IOConsole { return console; } + public static boolean isActiveConsoleRunning(){ + ScriptConsole active = getActive(); + return (active != null && getActive().isRunning()); + } + + /** + * Finds and returns the active console. + * @return The active <code>ScriptConsole<code> in the ConsoleView + */ + public static ScriptConsole getActive() { + IViewPart ivp = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IConsoleConstants.ID_CONSOLE_VIEW); + IConsole activeConsole = ((IConsoleView)ivp).getConsole(); + if (activeConsole instanceof ScriptConsole){ + return (ScriptConsole)activeConsole; + }else{ + return null; + } + } + private ScriptConsole(String name, ImageDescriptor imageDescriptor) { super(name, imageDescriptor); cmd = null; @@ -183,7 +204,7 @@ public class ScriptConsole extends IOConsole { /** * Check to see if this class has already been disposed. - * @return boolean represneting whether or not the class has been disposed. + * @return boolean representing whether or not the class has been disposed. */ public boolean isDisposed() { // If there is no command it can be considered disposed diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml index 15cdc63339..e0b7cfcfb9 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml @@ -209,16 +209,6 @@ definitionId="org.eclipse.linuxtools.systemtap.ui.ide.commands.RunScript" style="push" state="false"/> - <action - label="%action.stop.name" - tooltip="%action.stop.desc" - id="org.eclipse.linuxtools.systemtap.ui.consolelog.actions.StopScript" - icon="icons/actions/terminate_co.gif" - toolbarPath="org.eclipse.ui.workbench.file/stop.ext" - class="org.eclipse.linuxtools.systemtap.ui.consolelog.actions.StopScriptAction" - definitionId="org.eclipse.linuxtools.systemtap.ui.consolelog.commands.StopScript" - style="push" - state="false"/> </actionSet> </extension> |