diff options
author | Uwe Stieber | 2014-04-21 16:52:25 +0000 |
---|---|---|
committer | Uwe Stieber | 2014-04-21 16:52:25 +0000 |
commit | 94d23125c09d4f3125c9a2b5623baf54771fbdae (patch) | |
tree | 13c2ddc97cee44b8bce47aca0a299a4910d85f89 | |
parent | 3808db440066f984fc368d74985e8055a8082507 (diff) | |
download | org.eclipse.tcf-94d23125c09d4f3125c9a2b5623baf54771fbdae.tar.gz org.eclipse.tcf-94d23125c09d4f3125c9a2b5623baf54771fbdae.tar.xz org.eclipse.tcf-94d23125c09d4f3125c9a2b5623baf54771fbdae.zip |
Terminal: Support a disconnect button for terminal tabs which are "disconnectable"
12 files changed, 172 insertions, 17 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/ITerminalsConnectorConstants.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/ITerminalsConnectorConstants.java index c210b66b3..dd804d6e5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/ITerminalsConnectorConstants.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/ITerminalsConnectorConstants.java @@ -51,6 +51,11 @@ public interface ITerminalsConnectorConstants { public static final String PROP_FORCE_NEW = "forceNew"; //$NON-NLS-1$ /** + * Property: Flag to signal if the terminal tab shall have a disconnect button or not. + */ + public static final String PROP_HAS_DISCONNECT_BUTTON = "hasDisconnectButton"; //$NON-NLS-1$ + + /** * Property: Terminals launcher delegate id. */ public static final String PROP_DELEGATE_ID = "delegateId"; //$NON-NLS-1$ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.core/src/org/eclipse/tcf/te/tcf/terminals/core/launcher/TerminalsLauncher.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.core/src/org/eclipse/tcf/te/tcf/terminals/core/launcher/TerminalsLauncher.java index 80d5d77df..39f5f8b9f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.core/src/org/eclipse/tcf/te/tcf/terminals/core/launcher/TerminalsLauncher.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.core/src/org/eclipse/tcf/te/tcf/terminals/core/launcher/TerminalsLauncher.java @@ -411,6 +411,8 @@ public class TerminalsLauncher extends PlatformObject implements ITerminalsLaunc props.setProperty(ITerminalsConnectorConstants.PROP_SELECTION, properties.getProperty(ITerminalsConnectorConstants.PROP_SELECTION)); // Force creation of new terminal tabs if connecting to the same agent again props.setProperty(ITerminalsConnectorConstants.PROP_FORCE_NEW, true); + // Show the disconnect button + props.setProperty(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON, true); // Set the terminal tab title String terminalTitle = getTerminalTitle(); if (terminalTitle != null) { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/launcher/SerialLauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/launcher/SerialLauncherDelegate.java index 890c12674..bb42a3990 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/launcher/SerialLauncherDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/launcher/SerialLauncherDelegate.java @@ -62,6 +62,11 @@ public class SerialLauncherDelegate extends AbstractLauncherDelegate { properties.setProperty(ITerminalsConnectorConstants.PROP_TITLE, terminalTitle); } + // Serial terminals do have a disconnect button + if (!properties.containsKey(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON)) { + properties.setProperty(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON, true); + } + // Get the terminal service ITerminalService terminal = ServiceManager.getInstance().getService(ITerminalService.class); // If not available, we cannot fulfill this request diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/launcher/SshLauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/launcher/SshLauncherDelegate.java index 5da0c8b9b..5f7d09f60 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/launcher/SshLauncherDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/launcher/SshLauncherDelegate.java @@ -65,10 +65,15 @@ public class SshLauncherDelegate extends AbstractLauncherDelegate { // For SSH terminals, force a new terminal tab each time it is launched, // if not set otherwise from outside - if (properties.getProperty(ITerminalsConnectorConstants.PROP_FORCE_NEW) == null) { + if (!properties.containsKey(ITerminalsConnectorConstants.PROP_FORCE_NEW)) { properties.setProperty(ITerminalsConnectorConstants.PROP_FORCE_NEW, true); } + // SSH terminals do have a disconnect button + if (!properties.containsKey(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON)) { + properties.setProperty(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON, true); + } + // Get the terminal service ITerminalService terminal = ServiceManager.getInstance().getService(ITerminalService.class); // If not available, we cannot fulfill this request diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java index 295bfb865..639534791 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java @@ -65,10 +65,15 @@ public class TelnetLauncherDelegate extends AbstractLauncherDelegate { // For Telnet terminals, force a new terminal tab each time it is launched, // if not set otherwise from outside - if (properties.getProperty(ITerminalsConnectorConstants.PROP_FORCE_NEW) == null) { + if (!properties.containsKey(ITerminalsConnectorConstants.PROP_FORCE_NEW)) { properties.setProperty(ITerminalsConnectorConstants.PROP_FORCE_NEW, true); } + // Telnet terminals do have a disconnect button + if (!properties.containsKey(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON)) { + properties.setProperty(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON, true); + } + // Get the terminal service ITerminalService terminal = ServiceManager.getInstance().getService(ITerminalService.class); // If not available, we cannot fulfill this request diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.properties index 5a491fc43..f185b15d8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.properties @@ -29,8 +29,13 @@ toolbar.terminal.label=Terminals command.launch.name=Launch Terminal Command command.launch.label=Launch Terminal... + command.launchWithoutSelection.tooltip=Opens a terminal +command.disconnect.name=Disconnect Terminal Command +command.disconnect.label=Disconnect +command.disconnect.tooltip=Disconnect Terminal Connection + # ***** Extension Points ***** ExtensionPoint.connectorTypes.name=Terminal Connector Types diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.xml index 6b594b566..ea5effa3f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.xml @@ -93,7 +93,7 @@ class="org.eclipse.tcf.te.ui.terminals.internal.PropertyTester" id="org.eclipse.tcf.te.ui.terminals.PropertyTester" namespace="org.eclipse.tcf.te.ui.terminals" - properties="hasApplicableLauncherDelegates" + properties="hasApplicableLauncherDelegates,hasDisconnectButton,canDisconnect" type="java.lang.Object"> </propertyTester> </extension> @@ -124,7 +124,6 @@ label="%toolbar.terminal.label"> <command commandId="org.eclipse.tcf.te.ui.terminals.command.launchToolbar" - helpContextId="org.eclipse.tcf.te.ui.terminals.command_Launch" icon="platform:/plugin/org.eclipse.ui.console/icons/full/eview16/console_view.gif" id="org.eclipse.tcf.te.ui.terminals.commands.launchToolbar" label="%command.launch.label" @@ -136,13 +135,30 @@ <menuContribution locationURI="toolbar:org.eclipse.tcf.te.ui.terminals.TerminalsView"> <command commandId="org.eclipse.tcf.te.ui.terminals.command.launchToolbar" - helpContextId="org.eclipse.tcf.te.ui.terminals.command_Launch" icon="platform:/plugin/org.eclipse.ui.console/icons/full/eview16/console_view.gif" id="org.eclipse.tcf.te.ui.terminals.commands.launchToolbarTerminalsView" label="%command.launch.label" style="push" tooltip="%command.launchWithoutSelection.tooltip"> </command> + <command + commandId="org.eclipse.tcf.te.ui.terminals.command.disconnect" + icon="platform:/plugin/org.eclipse.tcf.te.ui/icons/elcl16/disconnect.gif" + id="org.eclipse.tcf.te.ui.terminals.commands.disconnect" + label="%command.disconnect.label" + style="push" + tooltip="%command.disconnect.tooltip"> + <visibleWhen checkEnabled="false"> + <with variable="selection"> + <count value="1"/> + <iterate operator="and" ifEmpty="false"> + <adapt type="org.eclipse.swt.custom.CTabItem"> + <test property="org.eclipse.tcf.te.ui.terminals.hasDisconnectButton" value="true"/> + </adapt> + </iterate> + </with> + </visibleWhen> + </command> </menuContribution> </extension> @@ -161,6 +177,12 @@ id="org.eclipse.tcf.te.ui.terminals.command.launchToolbar" name="%command.launch.name"> </command> + <command + categoryId="org.eclipse.tcf.te.ui.commands.category" + helpContextId="org.eclipse.tcf.te.ui.terminals.command_Disconnect" + id="org.eclipse.tcf.te.ui.terminals.command.disconnect" + name="%command.disconnect.name"> + </command> </extension> <!-- Handler contributions --> @@ -173,6 +195,20 @@ class="org.eclipse.tcf.te.ui.terminals.internal.handler.LaunchTerminalCommandHandler" commandId="org.eclipse.tcf.te.ui.terminals.command.launchToolbar"> </handler> + <handler + class="org.eclipse.tcf.te.ui.terminals.internal.handler.DisconnectTerminalCommandHandler" + commandId="org.eclipse.tcf.te.ui.terminals.command.disconnect"> + <enabledWhen> + <with variable="selection"> + <count value="1"/> + <iterate operator="and" ifEmpty="false"> + <adapt type="org.eclipse.swt.custom.CTabItem"> + <test property="org.eclipse.tcf.te.ui.terminals.canDisconnect" value="true"/> + </adapt> + </iterate> + </with> + </enabledWhen> + </handler> </extension> <!-- Help Context contributions --> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/PropertyTester.java index dfe166721..ea30847c5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/PropertyTester.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/PropertyTester.java @@ -11,12 +11,17 @@ package org.eclipse.tcf.te.ui.terminals.internal; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants; import org.eclipse.tcf.te.ui.terminals.launcher.LauncherDelegateManager; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; /** * Terminals property tester implementation. */ +@SuppressWarnings("restriction") public class PropertyTester extends org.eclipse.core.expressions.PropertyTester { /* (non-Javadoc) @@ -28,6 +33,18 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester ISelection selection = receiver instanceof ISelection ? (ISelection)receiver : new StructuredSelection(receiver); return expectedValue.equals(Boolean.valueOf(LauncherDelegateManager.getInstance().getApplicableLauncherDelegates(selection).length > 0)); } + + if ("hasDisconnectButton".equals(property) && receiver instanceof CTabItem) { //$NON-NLS-1$ + Boolean hasDisconnectButton = (Boolean)((CTabItem)receiver).getData(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON); + return expectedValue.equals(hasDisconnectButton); + } + + if ("canDisconnect".equals(property) && receiver instanceof CTabItem && ((CTabItem)receiver).getData() instanceof ITerminalViewControl) { //$NON-NLS-1$ + ITerminalViewControl terminal = (ITerminalViewControl)((CTabItem)receiver).getData(); + TerminalState state = terminal.getState(); + return expectedValue.equals(Boolean.valueOf(state != TerminalState.CLOSED)); + } + return false; } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/handler/DisconnectTerminalCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/handler/DisconnectTerminalCommandHandler.java new file mode 100644 index 000000000..7858bf9a7 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/handler/DisconnectTerminalCommandHandler.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2014 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 + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.internal.handler; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.tcf.te.ui.terminals.interfaces.ITerminalsView; +import org.eclipse.tcf.te.ui.terminals.tabs.TabFolderManager; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * Disconnect terminal connection command handler implementation. + */ +@SuppressWarnings("restriction") +public class DisconnectTerminalCommandHandler extends AbstractHandler { + + /* (non-Javadoc) + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + CTabItem item = null; + + ISelection selection = HandlerUtil.getCurrentSelection(event); + if (selection instanceof IStructuredSelection && !selection.isEmpty()) { + Object element = ((IStructuredSelection)selection).getFirstElement(); + if (element instanceof CTabItem && ((CTabItem)element).getData() instanceof ITerminalViewControl) { + item = (CTabItem)element; + } + } + + if (item == null && HandlerUtil.getActivePart(event) instanceof ITerminalsView) { + ITerminalsView view = (ITerminalsView)HandlerUtil.getActivePart(event); + TabFolderManager mgr = (TabFolderManager)view.getAdapter(TabFolderManager.class); + if (mgr != null && mgr.getActiveTabItem() != null) { + item = mgr.getActiveTabItem(); + } + } + + if (item != null && item.getData() instanceof ITerminalViewControl) { + ITerminalViewControl terminal = (ITerminalViewControl)item.getData(); + if (terminal != null && !terminal.isDisposed()) { + terminal.disconnectTerminal(); + } + } + + return null; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/manager/ConsoleManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/manager/ConsoleManager.java index 4305b84bc..2ce42b44d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/manager/ConsoleManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/manager/ConsoleManager.java @@ -22,6 +22,7 @@ import org.eclipse.core.runtime.Status; import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.widgets.Display; +import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants; import org.eclipse.tcf.te.ui.terminals.activator.UIPlugin; import org.eclipse.tcf.te.ui.terminals.interfaces.IPreferenceKeys; import org.eclipse.tcf.te.ui.terminals.interfaces.ITerminalsView; @@ -397,11 +398,10 @@ public class ConsoleManager { * @param encoding The terminal encoding or <code>null</code>. * @param connector The terminal connector. Must not be <code>null</code>. * @param data The custom terminal data node or <code>null</code>. - * @param activate If <code>true</code> activate the console view. - * @param forceNew If <code>true</code> a new console tab is created even if another one matches the criteria. + * @param flags The flags controlling how the console is opened or <code>null</code> to use defaults. */ - public CTabItem openConsole(String id, String title, String encoding, ITerminalConnector connector, Object data, boolean activate, boolean forceNew) { - return openConsole(id, null, title, encoding, connector, data, activate, forceNew); + public CTabItem openConsole(String id, String title, String encoding, ITerminalConnector connector, Object data, Map<String, Boolean> flags) { + return openConsole(id, null, title, encoding, connector, data, flags); } /** @@ -415,14 +415,17 @@ public class ConsoleManager { * @param encoding The terminal encoding or <code>null</code>. * @param connector The terminal connector. Must not be <code>null</code>. * @param data The custom terminal data node or <code>null</code>. - * @param activate If <code>true</code> activate the console view. - * @param forceNew If <code>true</code> a new console tab is created even if another one matches the criteria. + * @param flags The flags controlling how the console is opened or <code>null</code> to use defaults. */ - public CTabItem openConsole(String id, String secondaryId, String title, String encoding, ITerminalConnector connector, Object data, boolean activate, boolean forceNew) { + public CTabItem openConsole(String id, String secondaryId, String title, String encoding, ITerminalConnector connector, Object data, Map<String, Boolean> flags) { Assert.isNotNull(title); Assert.isNotNull(connector); Assert.isNotNull(Display.findDisplay(Thread.currentThread())); + // Get the flags handled by the openConsole method itself + boolean activate = flags != null && flags.containsKey("activate") ? flags.get("activate").booleanValue() : false; //$NON-NLS-1$ //$NON-NLS-2$ + boolean forceNew = flags != null && flags.containsKey(ITerminalsConnectorConstants.PROP_FORCE_NEW) ? flags.get(ITerminalsConnectorConstants.PROP_FORCE_NEW).booleanValue() : false; + // Make the consoles view visible IViewPart part = bringToTop(id, secondaryId, activate); if (!(part instanceof ITerminalsView)) return null; @@ -457,7 +460,7 @@ public class ConsoleManager { } // Create a new tab item - item = manager.createTabItem(title, encoding, connector, data); + item = manager.createTabItem(title, encoding, connector, data, flags); } // If still null, something went wrong if (item == null) return null; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/services/TerminalService.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/services/TerminalService.java index 7563eae75..625cac78d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/services/TerminalService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/services/TerminalService.java @@ -9,6 +9,9 @@ *******************************************************************************/ package org.eclipse.tcf.te.ui.terminals.services; +import java.util.HashMap; +import java.util.Map; + import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.Status; import org.eclipse.swt.custom.CTabItem; @@ -177,15 +180,19 @@ public class TerminalService extends AbstractService implements ITerminalService executeServiceOperation(properties, new TerminalServiceRunnable() { @Override public void run(String id, String secondaryId, String title, ITerminalConnector connector, Object data, ICallback callback) { - // Determine if a new terminal tab shall be enforced - boolean forceNew = properties.getBooleanProperty(ITerminalsConnectorConstants.PROP_FORCE_NEW); // Determine the terminal encoding String encoding = properties.getStringProperty(ITerminalsConnectorConstants.PROP_ENCODING); + // Create the flags to pass on to openConsole + Map<String, Boolean> flags = new HashMap<String, Boolean>(); + flags.put("activate", Boolean.TRUE); //$NON-NLS-1$ + flags.put(ITerminalsConnectorConstants.PROP_FORCE_NEW, Boolean.valueOf(properties.getBooleanProperty(ITerminalsConnectorConstants.PROP_FORCE_NEW))); + flags.put(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON, Boolean.valueOf(properties.getBooleanProperty(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON))); // Open the new console - CTabItem item = ConsoleManager.getInstance().openConsole(id, secondaryId, title, encoding, connector, data, true, forceNew); + CTabItem item = ConsoleManager.getInstance().openConsole(id, secondaryId, title, encoding, connector, data, flags); // Associate the original terminal properties with the tab item. // This makes it easier to persist the connection data within the memento handler if (item != null && !item.isDisposed()) item.setData("properties", properties); //$NON-NLS-1$ + // Invoke the callback if (callback != null) callback.done(this, Status.OK_STATUS); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java index 0a073507e..78a6fe5c2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java @@ -303,11 +303,12 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid * @param encoding The terminal encoding or <code>null</code>. * @param connector The terminal connector. Must not be <code>null</code>. * @param data The custom terminal data node or <code>null</code>. + * @param flags The flags controlling how the console is opened or <code>null</code> to use defaults. * * @return The created tab item or <code>null</code> if failed. */ @SuppressWarnings("unused") - public CTabItem createTabItem(String title, String encoding, ITerminalConnector connector, Object data) { + public CTabItem createTabItem(String title, String encoding, ITerminalConnector connector, Object data, Map<String, Boolean> flags) { Assert.isNotNull(title); Assert.isNotNull(connector); @@ -354,6 +355,8 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid item.setData(terminal); // Associated the custom data node with the tab item (if any) if (data != null) item.setData("customData", data); //$NON-NLS-1$ + // Set the property that marks the item has a disconnect button or not if selected + item.setData(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON, flags != null && flags.containsKey(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON) ? flags.get(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON) : Boolean.FALSE); // Overwrite the text canvas help id String contextHelpId = getParentView().getContextHelpId(); |