1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

Terminals: Bug 460065 - The SSH Terminal "disconnect" icon disappears

when a selection is made
This commit is contained in:
Uwe Stieber 2015-02-17 17:17:17 +01:00
parent cf87ee533b
commit 5d84a80a39
8 changed files with 14 additions and 57 deletions

View file

@ -67,13 +67,6 @@ public interface ITerminalsConnectorConstants {
*/ */
public static final String PROP_FORCE_NEW = "terminal.forceNew"; //$NON-NLS-1$ public static final String PROP_FORCE_NEW = "terminal.forceNew"; //$NON-NLS-1$
/**
* Property: Flag to signal if the terminal tab shall have a disconnect button or not.
* <p>
* Property Type: {@link Boolean}
*/
public static final String PROP_HAS_DISCONNECT_BUTTON = "hasDisconnectButton"; //$NON-NLS-1$
/** /**
* Property: Terminals launcher delegate id. * Property: Terminals launcher delegate id.
* <p> * <p>

View file

@ -68,11 +68,6 @@ public class SerialLauncherDelegate extends AbstractLauncherDelegate {
properties.put(ITerminalsConnectorConstants.PROP_TITLE, terminalTitle); properties.put(ITerminalsConnectorConstants.PROP_TITLE, terminalTitle);
} }
// Serial terminals do have a disconnect button
if (!properties.containsKey(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON)) {
properties.put(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON, Boolean.TRUE);
}
// Get the terminal service // Get the terminal service
ITerminalService terminal = TerminalServiceFactory.getService(); ITerminalService terminal = TerminalServiceFactory.getService();
// If not available, we cannot fulfill this request // If not available, we cannot fulfill this request

View file

@ -75,11 +75,6 @@ public class SshLauncherDelegate extends AbstractLauncherDelegate {
properties.put(ITerminalsConnectorConstants.PROP_FORCE_NEW, Boolean.TRUE); properties.put(ITerminalsConnectorConstants.PROP_FORCE_NEW, Boolean.TRUE);
} }
// SSH terminals do have a disconnect button
if (!properties.containsKey(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON)) {
properties.put(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON, Boolean.TRUE);
}
// Get the terminal service // Get the terminal service
ITerminalService terminal = TerminalServiceFactory.getService(); ITerminalService terminal = TerminalServiceFactory.getService();
// If not available, we cannot fulfill this request // If not available, we cannot fulfill this request

View file

@ -75,11 +75,6 @@ public class TelnetLauncherDelegate extends AbstractLauncherDelegate {
properties.put(ITerminalsConnectorConstants.PROP_FORCE_NEW, Boolean.TRUE); properties.put(ITerminalsConnectorConstants.PROP_FORCE_NEW, Boolean.TRUE);
} }
// Telnet terminals do have a disconnect button
if (!properties.containsKey(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON)) {
properties.put(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON, Boolean.TRUE);
}
// Get the terminal service // Get the terminal service
ITerminalService terminal = TerminalServiceFactory.getService(); ITerminalService terminal = TerminalServiceFactory.getService();
// If not available, we cannot fulfill this request // If not available, we cannot fulfill this request

View file

@ -128,7 +128,7 @@
class="org.eclipse.tcf.te.ui.terminals.internal.PropertyTester" class="org.eclipse.tcf.te.ui.terminals.internal.PropertyTester"
id="org.eclipse.tcf.te.ui.terminals.PropertyTester" id="org.eclipse.tcf.te.ui.terminals.PropertyTester"
namespace="org.eclipse.tcf.te.ui.terminals" namespace="org.eclipse.tcf.te.ui.terminals"
properties="hasApplicableLauncherDelegates,hasDisconnectButton,canDisconnect" properties="hasApplicableLauncherDelegates,canDisconnect"
type="java.lang.Object"> type="java.lang.Object">
</propertyTester> </propertyTester>
</extension> </extension>
@ -175,16 +175,6 @@
label="%command.disconnect.label" label="%command.disconnect.label"
style="push" style="push"
tooltip="%command.disconnect.tooltip"> 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> </command>
</menuContribution> </menuContribution>
<menuContribution locationURI="popup:org.eclipse.tcf.te.ui.terminals.TerminalsView?after=additions"> <menuContribution locationURI="popup:org.eclipse.tcf.te.ui.terminals.TerminalsView?after=additions">
@ -263,13 +253,9 @@
class="org.eclipse.tcf.te.ui.terminals.internal.handler.DisconnectTerminalCommandHandler" class="org.eclipse.tcf.te.ui.terminals.internal.handler.DisconnectTerminalCommandHandler"
commandId="org.eclipse.tcf.te.ui.terminals.command.disconnect"> commandId="org.eclipse.tcf.te.ui.terminals.command.disconnect">
<enabledWhen> <enabledWhen>
<with variable="selection"> <with variable="activePart">
<count value="1"/> <instanceof value="org.eclipse.tcf.te.ui.terminals.interfaces.ITerminalsView"/>
<iterate operator="and" ifEmpty="false">
<adapt type="org.eclipse.swt.custom.CTabItem">
<test property="org.eclipse.tcf.te.ui.terminals.canDisconnect" value="true"/> <test property="org.eclipse.tcf.te.ui.terminals.canDisconnect" value="true"/>
</adapt>
</iterate>
</with> </with>
</enabledWhen> </enabledWhen>
</handler> </handler>

View file

@ -12,8 +12,9 @@ package org.eclipse.tcf.te.ui.terminals.internal;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.custom.CTabItem;
import org.eclipse.tcf.te.core.terminals.interfaces.constants.ITerminalsConnectorConstants; import org.eclipse.tcf.te.ui.terminals.interfaces.ITerminalsView;
import org.eclipse.tcf.te.ui.terminals.launcher.LauncherDelegateManager; import org.eclipse.tcf.te.ui.terminals.launcher.LauncherDelegateManager;
import org.eclipse.tcf.te.ui.terminals.tabs.TabFolderManager;
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
@ -34,18 +35,15 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester
return expectedValue.equals(Boolean.valueOf(LauncherDelegateManager.getInstance().getApplicableLauncherDelegates(selection).length > 0)); return expectedValue.equals(Boolean.valueOf(LauncherDelegateManager.getInstance().getApplicableLauncherDelegates(selection).length > 0));
} }
if ("hasDisconnectButton".equals(property) && receiver instanceof CTabItem) { //$NON-NLS-1$ if ("canDisconnect".equals(property) && receiver instanceof ITerminalsView) { //$NON-NLS-1$
CTabItem tabItem = (CTabItem)receiver; CTabItem tabItem = null;
if (!tabItem.isDisposed()) {
Boolean hasDisconnectButton = (Boolean) tabItem.getData(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON); TabFolderManager manager = (TabFolderManager) ((ITerminalsView)receiver).getAdapter(TabFolderManager.class);
return expectedValue.equals(hasDisconnectButton); if (manager != null) {
} tabItem = manager.getActiveTabItem();
return false;
} }
if ("canDisconnect".equals(property) && receiver instanceof CTabItem) { //$NON-NLS-1$ if (tabItem != null && !tabItem.isDisposed() && tabItem.getData() instanceof ITerminalViewControl) {
CTabItem tabItem = (CTabItem)receiver;
if (!tabItem.isDisposed() && tabItem.getData() instanceof ITerminalViewControl) {
ITerminalViewControl terminal = (ITerminalViewControl)tabItem.getData(); ITerminalViewControl terminal = (ITerminalViewControl)tabItem.getData();
TerminalState state = terminal.getState(); TerminalState state = terminal.getState();
return expectedValue.equals(Boolean.valueOf(state != TerminalState.CLOSED)); return expectedValue.equals(Boolean.valueOf(state != TerminalState.CLOSED));

View file

@ -302,9 +302,6 @@ public class TerminalService implements ITerminalService {
if (properties.get(ITerminalsConnectorConstants.PROP_FORCE_NEW) instanceof Boolean) { if (properties.get(ITerminalsConnectorConstants.PROP_FORCE_NEW) instanceof Boolean) {
flags.put(ITerminalsConnectorConstants.PROP_FORCE_NEW, (Boolean)properties.get(ITerminalsConnectorConstants.PROP_FORCE_NEW)); flags.put(ITerminalsConnectorConstants.PROP_FORCE_NEW, (Boolean)properties.get(ITerminalsConnectorConstants.PROP_FORCE_NEW));
} }
if (properties.get(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON) instanceof Boolean) {
flags.put(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON, (Boolean)properties.get(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON));
}
// Open the new console // Open the new console
CTabItem item; CTabItem item;
if (secondaryId != null) if (secondaryId != null)

View file

@ -283,8 +283,6 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid
item.setData(terminal); item.setData(terminal);
// Associated the custom data node with the tab item (if any) // Associated the custom data node with the tab item (if any)
if (data != null) item.setData("customData", data); //$NON-NLS-1$ 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 // Overwrite the text canvas help id
String contextHelpId = getParentView().getContextHelpId(); String contextHelpId = getParentView().getContextHelpId();