From e25c78d251f799ced7345954c4b509a6c8651637 Mon Sep 17 00:00:00 2001 From: Dirk Fauth Date: Wed, 10 Feb 2016 16:42:06 +0100 Subject: [PATCH] Bug 460496 - [TERMINALS] Make it easier to run Git Bash Added external executables to the terminal combobox on the Open Terminal Dialog (Ctrl+Alt+Shift+T) Change-Id: Ia9d9a3959fd95b666c4a1ad4474b519103297920 Signed-off-by: Dirk Fauth --- .../dialogs/LaunchTerminalSettingsDialog.java | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/internal/dialogs/LaunchTerminalSettingsDialog.java b/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/internal/dialogs/LaunchTerminalSettingsDialog.java index 14d8c1bcea1..af52d93e7e2 100644 --- a/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/internal/dialogs/LaunchTerminalSettingsDialog.java +++ b/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/internal/dialogs/LaunchTerminalSettingsDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 - 2015 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2011, 2016 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -7,6 +7,7 @@ * Contributors: * Wind River Systems - initial API and implementation * Max Weninger (Wind River) - [361352] [TERMINALS][SSH] Add SSH terminal support + * Dirk Fauth - Bug 460496 *******************************************************************************/ package org.eclipse.tm.terminal.view.ui.internal.dialogs; @@ -41,10 +42,13 @@ import org.eclipse.tm.terminal.view.ui.activator.UIPlugin; import org.eclipse.tm.terminal.view.ui.controls.ConfigurationPanelControl; import org.eclipse.tm.terminal.view.ui.help.IContextHelpIds; import org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanel; +import org.eclipse.tm.terminal.view.ui.interfaces.IExternalExecutablesProperties; import org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate; import org.eclipse.tm.terminal.view.ui.interfaces.tracing.ITraceIds; import org.eclipse.tm.terminal.view.ui.launcher.LauncherDelegateManager; +import org.eclipse.tm.terminal.view.ui.local.showin.ExternalExecutablesManager; import org.eclipse.tm.terminal.view.ui.nls.Messages; +import org.eclipse.ui.ISelectionService; import org.eclipse.ui.PlatformUI; /** @@ -63,6 +67,9 @@ public class LaunchTerminalSettingsDialog extends TrayDialog { // Map the label added to the combo box to the corresponding launcher delegate. /* default */ final Map label2delegate = new HashMap(); + // Map the label added to the combo box to the corresponding launcher properties for external executables. + /* default */ final Map> label2properties = new HashMap>(); + // The data object containing the currently selected settings private Map data = null; @@ -402,6 +409,8 @@ public class LaunchTerminalSettingsDialog extends TrayDialog { protected List getTerminals() { List items = new ArrayList(); + ILauncherDelegate localLauncher = null; + if(selection==null || selection.isEmpty()){ if (UIPlugin.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_LAUNCH_TERMINAL_COMMAND_HANDLER)) { UIPlugin.getTraceHandler().trace("Getting launcher delegates after " + (System.currentTimeMillis() - start) + " ms.", //$NON-NLS-1$ //$NON-NLS-2$ @@ -421,6 +430,10 @@ public class LaunchTerminalSettingsDialog extends TrayDialog { if (label == null || "".equals(label.trim())) label = delegate.getId(); //$NON-NLS-1$ label2delegate.put(label, delegate); items.add(label); + + if ("org.eclipse.tm.terminal.connector.local.launcher.local".equals(delegate.getId())) { //$NON-NLS-1$ + localLauncher = delegate; + } } } else { if (UIPlugin.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_LAUNCH_TERMINAL_COMMAND_HANDLER)) { @@ -441,9 +454,45 @@ public class LaunchTerminalSettingsDialog extends TrayDialog { if (label == null || "".equals(label.trim())) label = delegate.getId(); //$NON-NLS-1$ label2delegate.put(label, delegate); items.add(label); + + if ("org.eclipse.tm.terminal.connector.local.launcher.local".equals(delegate.getId())) { //$NON-NLS-1$ + localLauncher = delegate; + } } } + // if the local launcher was found, check for configured external executables + if (localLauncher != null) { + List> l = ExternalExecutablesManager.load(); + if (l != null && !l.isEmpty()) { + for (Map executableData : l) { + String name = executableData.get(IExternalExecutablesProperties.PROP_NAME); + String path = executableData.get(IExternalExecutablesProperties.PROP_PATH); + String args = executableData.get(IExternalExecutablesProperties.PROP_ARGS); + + String strTranslate = executableData.get(IExternalExecutablesProperties.PROP_TRANSLATE); + boolean translate = strTranslate != null ? Boolean.parseBoolean(strTranslate) : false; + + if (name != null && !"".equals(name) && path != null && !"".equals(path)) { //$NON-NLS-1$ //$NON-NLS-2$ + ISelectionService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService(); + ISelection selection = service != null ? service.getSelection() : null; + if (selection != null && selection.isEmpty()) selection = null; + + Map properties = new HashMap(); + properties.put(ITerminalsConnectorConstants.PROP_PROCESS_PATH, path); + properties.put(ITerminalsConnectorConstants.PROP_PROCESS_ARGS, args); + properties.put(ITerminalsConnectorConstants.PROP_TRANSLATE_BACKSLASHES_ON_PASTE, Boolean.valueOf(translate)); + + // store external executable and properties + label2delegate.put(name, localLauncher); + label2properties.put(name, properties); + items.add(name); + } + } + } + + } + return items; } @@ -534,6 +583,11 @@ public class LaunchTerminalSettingsDialog extends TrayDialog { // Store the selection data.put(ITerminalsConnectorConstants.PROP_SELECTION, selection); + // Add the properties for external executables if there are any + if (label2properties.containsKey(terminalLabel)) { + data.putAll(label2properties.get(terminalLabel)); + } + // Store the delegate specific settings panel.extractData(data);