Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'terminals/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherHandler.java')
-rw-r--r--terminals/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherHandler.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherHandler.java b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherHandler.java
index 00525774d..aa51e1646 100644
--- a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherHandler.java
+++ b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherHandler.java
@@ -15,10 +15,15 @@ import java.util.Map;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.tcf.te.core.terminals.interfaces.constants.ITerminalsConnectorConstants;
import org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate;
import org.eclipse.tcf.te.ui.terminals.launcher.LauncherDelegateManager;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPathEditorInput;
import org.eclipse.ui.handlers.HandlerUtil;
/**
@@ -34,6 +39,19 @@ public class LocalLauncherHandler extends AbstractHandler {
// Get the current selection
ISelection selection = HandlerUtil.getCurrentSelection(event);
+ // If the selection is not a structured selection, check if there is an active
+ // editor and get the path from the editor input
+ if (!(selection instanceof IStructuredSelection)) {
+ IEditorInput input = HandlerUtil.getActiveEditorInput(event);
+ if (input instanceof IPathEditorInput) {
+ IPath path = ((IPathEditorInput)input).getPath();
+ if (path != null) {
+ if (path.toFile().isFile()) path = path.removeLastSegments(1);
+ if (path.toFile().isDirectory() && path.toFile().canRead()) selection = new StructuredSelection(path);
+ }
+ }
+ }
+
// Get all applicable launcher delegates for the current selection
ILauncherDelegate[] delegates = LauncherDelegateManager.getInstance().getApplicableLauncherDelegates(selection);
// Find the local terminal launcher delegate

Back to the top