Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2014-05-19 07:48:10 -0400
committerUwe Stieber2014-05-19 09:11:49 -0400
commitc6a05a2acede6170ff7e6fadf80b934019e82d3d (patch)
treec3a7c8a85842593804f1b1cbbe2c6d234d4daa1d
parent21b0a1822191f77693846c0f6210f97c54858111 (diff)
downloadorg.eclipse.tcf-c6a05a2acede6170ff7e6fadf80b934019e82d3d.tar.gz
org.eclipse.tcf-c6a05a2acede6170ff7e6fadf80b934019e82d3d.tar.xz
org.eclipse.tcf-c6a05a2acede6170ff7e6fadf80b934019e82d3d.zip
Target Explorer: Fix Bug 434940 - [TERMINALS] Cannot open multiple local
terminals - Part 3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherDelegate.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherDelegate.java
index aaa1e404d..5f31aaeb4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherDelegate.java
@@ -9,8 +9,15 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.terminals.local.launcher;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.services.ServiceManager;
@@ -22,6 +29,8 @@ import org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanel;
import org.eclipse.tcf.te.ui.terminals.interfaces.IMementoHandler;
import org.eclipse.tcf.te.ui.terminals.launcher.AbstractLauncherDelegate;
import org.eclipse.tcf.te.ui.terminals.local.controls.LocalWizardConfigurationPanel;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.WorkbenchEncoding;
/**
@@ -85,6 +94,35 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate {
properties.setProperty(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR, home);
}
+ // If the current selection resolved to an folder, default the working directory
+ // to that folder and update the terminal title
+ ISelectionService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
+ if (service != null && service.getSelection() != null) {
+ ISelection selection = service.getSelection();
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ String dir = null;
+ Iterator<?> iter = ((IStructuredSelection)selection).iterator();
+ while (iter.hasNext()) {
+ Object element = iter.next();
+ if (element instanceof IResource && ((IResource)element).exists()) {
+ IPath location = ((IResource)element).getLocation();
+ if (location == null) continue;
+ if (location.toFile().isFile()) location = location.removeLastSegments(1);
+ if (location.toFile().isDirectory() && location.toFile().canRead()) {
+ dir = location.toFile().getAbsolutePath();
+ break;
+ }
+ }
+ }
+ if (dir != null) {
+ properties.setProperty(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR, dir);
+
+ String basename = new Path(dir).lastSegment();
+ properties.setProperty(ITerminalsConnectorConstants.PROP_TITLE, basename + " (" + terminalTitle + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+
// Get the terminal service
ITerminalService terminal = ServiceManager.getInstance().getService(ITerminalService.class);
// If not available, we cannot fulfill this request

Back to the top