Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-01-17 09:38:32 +0000
committerUwe Stieber2012-01-18 07:51:19 +0000
commit82c1acd94d0b5836898ae5d37bff8f6a6f1e8bbd (patch)
treee48fc45e397a1d7506790f7c52958ff44c2ff671
parenta23c575879a07779e14c26d512ceeba6bc8d1027 (diff)
downloadorg.eclipse.tcf-82c1acd94d0b5836898ae5d37bff8f6a6f1e8bbd.tar.gz
org.eclipse.tcf-82c1acd94d0b5836898ae5d37bff8f6a6f1e8bbd.tar.xz
org.eclipse.tcf-82c1acd94d0b5836898ae5d37bff8f6a6f1e8bbd.zip
Target Explorer: Add a way to terminate (disconnect) a terminal without closing the tab
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/ITerminalService.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/manager/ConsoleManager.java26
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/services/TerminalService.java32
3 files changed, 60 insertions, 6 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/ITerminalService.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/ITerminalService.java
index 71285a516..5b5aaacf7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/ITerminalService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/ITerminalService.java
@@ -34,4 +34,12 @@ public interface ITerminalService extends IService {
* @param callback The target callback to invoke if finished or <code>null</code>.
*/
public void closeConsole(IPropertiesContainer properties, ICallback callback);
+
+ /**
+ * Terminate (disconnect) the terminal asynchronously and invokes the given callback if done.
+ *
+ * @param properties The terminal properties. Must be not <code>null</code>.
+ * @param callback The target callback to invoke if finished or <code>null</code>.
+ */
+ public void terminateConsole(IPropertiesContainer properties, ICallback callback);
}
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 a79a7197e..917f337c3 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
@@ -27,6 +27,7 @@ import org.eclipse.tcf.te.ui.terminals.interfaces.ITerminalsView;
import org.eclipse.tcf.te.ui.terminals.interfaces.IUIConstants;
import org.eclipse.tcf.te.ui.terminals.tabs.TabFolderManager;
import org.eclipse.tcf.te.ui.terminals.view.TerminalsView;
+import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
import org.eclipse.ui.IPerspectiveDescriptor;
import org.eclipse.ui.IPerspectiveListener;
@@ -523,4 +524,29 @@ public class ConsoleManager {
console.dispose();
}
}
+
+ /**
+ * Terminate (disconnect) the console with the given title and the given terminal connector.
+ * <p>
+ * <b>Note:</b> The method must be called within the UI thread.
+ * <b>Note:</b> The method will handle unified console titles itself.
+ *
+ * @param title The console title. Must not be <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>.
+ */
+ public void terminateConsole(String id, String title, ITerminalConnector connector, Object data) {
+ assert title != null && connector != null;
+ assert Display.findDisplay(Thread.currentThread()) != null;
+
+ // Lookup the console
+ CTabItem console = findConsoleForTerminalConnector(id, title, connector, data);
+ // If found, disconnect the console
+ if (console != null && !console.isDisposed()) {
+ ITerminalViewControl terminal = (ITerminalViewControl)console.getData();
+ if (terminal != null && !terminal.isDisposed()) {
+ terminal.disconnectTerminal();
+ }
+ }
+ }
}
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 0d83a9b6f..c6e9533f8 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
@@ -11,12 +11,6 @@ package org.eclipse.tcf.te.ui.terminals.services;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType;
-import org.eclipse.tcf.te.ui.terminals.interfaces.IUIConstants;
-import org.eclipse.tcf.te.ui.terminals.manager.ConsoleManager;
-import org.eclipse.tcf.te.ui.terminals.nls.Messages;
-import org.eclipse.tcf.te.ui.terminals.types.ConnectorManager;
-import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
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.AbstractService;
@@ -24,6 +18,12 @@ import org.eclipse.tcf.te.runtime.services.interfaces.ITerminalService;
import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants;
import org.eclipse.tcf.te.runtime.utils.StatusHelper;
import org.eclipse.tcf.te.ui.swt.DisplayUtil;
+import org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType;
+import org.eclipse.tcf.te.ui.terminals.interfaces.IUIConstants;
+import org.eclipse.tcf.te.ui.terminals.manager.ConsoleManager;
+import org.eclipse.tcf.te.ui.terminals.nls.Messages;
+import org.eclipse.tcf.te.ui.terminals.types.ConnectorManager;
+import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
/**
* Terminal service implementation.
@@ -202,4 +202,24 @@ public class TerminalService extends AbstractService implements ITerminalService
}
}, callback);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.services.interfaces.ITerminalService#terminateConsole(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
+ */
+ @Override
+ public void terminateConsole(IPropertiesContainer properties, ICallback callback) {
+ Assert.isNotNull(properties);
+
+ executeServiceOperation(properties, new TerminalServiceRunnable() {
+ @Override
+ public void run(String id, String title, ITerminalConnector connector, Object data, ICallback callback) {
+ // Close the console
+ ConsoleManager.getInstance().terminateConsole(id, title, connector, data);
+ // Invoke the callback
+ if (callback != null) {
+ callback.done(this, Status.OK_STATUS);
+ }
+ }
+ }, callback);
+ }
}

Back to the top