Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/ITerminalsConnectorConstants.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/activator/UIPlugin.java73
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/manager/ConsoleManager.java46
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/services/TerminalService.java17
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/tabs/TabFolderManager.java9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/view/TerminalsViewMementoHandler.java13
6 files changed, 105 insertions, 58 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 a7ccdde83..20c140b65 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
@@ -21,6 +21,11 @@ public interface ITerminalsConnectorConstants {
public static final String PROP_ID = "id"; //$NON-NLS-1$
/**
+ * Property: The unique secondary id of the terminals view to open.
+ */
+ public static final String PROP_SECONDARY_ID = "secondaryId"; //$NON-NLS-1$
+
+ /**
* Property: The title of the terminal tab to open.
*/
public static final String PROP_TITLE = "title"; //$NON-NLS-1$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/activator/UIPlugin.java
index bf4368185..cf8dfa63f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/activator/UIPlugin.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/activator/UIPlugin.java
@@ -22,7 +22,6 @@ import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.graphics.Image;
import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
import org.eclipse.tcf.te.runtime.tracing.TraceHandler;
-import org.eclipse.tcf.te.ui.terminals.interfaces.IUIConstants;
import org.eclipse.tcf.te.ui.terminals.interfaces.ImageConsts;
import org.eclipse.tcf.te.ui.terminals.view.TerminalsView;
import org.eclipse.tcf.te.ui.terminals.view.TerminalsViewMementoHandler;
@@ -111,44 +110,46 @@ public class UIPlugin extends AbstractUIPlugin {
@Override
public boolean preShutdown(IWorkbench workbench, boolean forced) {
- /*
- * The terminal tabs to save to the views memento on shutdown can
- * be determined only _before_ the saveState(memento) method of the
- * view is called. Within saveState, it is already to late and the
- * terminals might be in CLOSED state already. This depends on the
- * terminal type and the corresponding connector implementation.
- *
- * To be safe, we determine the still opened terminals on shutdown
- * separately here in the preShutdown.
- */
- final List<CTabItem> saveables = new ArrayList<CTabItem>();
-
- // Get the "Terminals" view
- IViewReference ref = workbench.getActiveWorkbenchWindow().getActivePage().findViewReference(IUIConstants.ID);
- IViewPart part = ref != null ? ref.getView(false) : null;
- if (part instanceof TerminalsView) {
- // Get the tab folder
- CTabFolder tabFolder = (CTabFolder)((TerminalsView)part).getAdapter(CTabFolder.class);
- if (tabFolder != null && !tabFolder.isDisposed()) {
- // Get the list of tab items
- CTabItem[] items = tabFolder.getItems();
- // Loop the tab items and find the still connected ones
- for (CTabItem item : items) {
- // Ignore disposed items
- if (item.isDisposed()) continue;
- // Get the terminal view control
- ITerminalViewControl terminal = (ITerminalViewControl)item.getData();
- if (terminal == null || terminal.getState() != TerminalState.CONNECTED) {
- continue;
+ // Find all "Terminals" views
+ IViewReference[] refs = workbench.getActiveWorkbenchWindow().getActivePage().getViewReferences();
+ for (IViewReference ref : refs) {
+ IViewPart part = ref.getView(false);
+ if (part instanceof TerminalsView) {
+ /*
+ * The terminal tabs to save to the views memento on shutdown can
+ * be determined only _before_ the saveState(memento) method of the
+ * view is called. Within saveState, it is already to late and the
+ * terminals might be in CLOSED state already. This depends on the
+ * terminal type and the corresponding connector implementation.
+ *
+ * To be safe, we determine the still opened terminals on shutdown
+ * separately here in the preShutdown.
+ */
+ final List<CTabItem> saveables = new ArrayList<CTabItem>();
+
+ // Get the tab folder
+ CTabFolder tabFolder = (CTabFolder)((TerminalsView)part).getAdapter(CTabFolder.class);
+ if (tabFolder != null && !tabFolder.isDisposed()) {
+ // Get the list of tab items
+ CTabItem[] items = tabFolder.getItems();
+ // Loop the tab items and find the still connected ones
+ for (CTabItem item : items) {
+ // Ignore disposed items
+ if (item.isDisposed()) continue;
+ // Get the terminal view control
+ ITerminalViewControl terminal = (ITerminalViewControl)item.getData();
+ if (terminal == null || terminal.getState() != TerminalState.CONNECTED) {
+ continue;
+ }
+ // Still connected -> Add to the list
+ saveables.add(item);
}
- // Still connected -> Add to the list
- saveables.add(item);
}
- }
- // Push the determined saveable items to the memento handler
- TerminalsViewMementoHandler mementoHandler = (TerminalsViewMementoHandler)((TerminalsView)part).getAdapter(TerminalsViewMementoHandler.class);
- if (mementoHandler != null) mementoHandler.setSaveables(saveables);
+ // Push the determined saveable items to the memento handler
+ TerminalsViewMementoHandler mementoHandler = (TerminalsViewMementoHandler)((TerminalsView)part).getAdapter(TerminalsViewMementoHandler.class);
+ if (mementoHandler != null) mementoHandler.setSaveables(saveables);
+ }
}
return true;
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 601b1093b..2082cfd5f 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
@@ -217,11 +217,12 @@ public class ConsoleManager {
* Search and return the first available terminal view.
*
* @param id The terminals console view id. Must not be <code>null</code>.
+ * @param secondaryId The terminals console view secondary id or <code>null</code>.
* @param useActive - return only an active terminal view.
*
* @return The terminals console view instance or <code>null</code> if not found.
*/
- private IViewPart getFirstTerminalsView(String id, boolean useActive) {
+ private IViewPart getFirstTerminalsView(String id, String secondaryId, boolean useActive) {
Assert.isNotNull(id);
IWorkbenchPage page = getActiveWorkbenchPage();
@@ -230,15 +231,17 @@ public class ConsoleManager {
for (int i = 0; i < refs.length; i++) {
IViewReference ref = refs[i];
if (ref.getId().equals(id)) {
- IViewPart part = ref.getView(true);
- if (useActive) {
- if (page.isPartVisible(part)) {
+ if (secondaryId == null || secondaryId.equals(ref.getSecondaryId())) {
+ IViewPart part = ref.getView(true);
+ if (useActive) {
+ if (page.isPartVisible(part)) {
+ return part;
+ }
+ }
+ else {
return part;
}
}
- else {
- return part;
- }
}
}
return null;
@@ -322,18 +325,19 @@ public class ConsoleManager {
* Bring the terminals console view, specified by the given id, to the top of the view stack.
*
* @param id The terminals console view id or <code>null</code> to show the default terminals console view.
+ * @param secondaryId The terminals console view secondary id or <code>null</code>.
* @param activate If <code>true</code> activate the console view.
*/
- private IViewPart bringToTop(String id, boolean activate) {
+ private IViewPart bringToTop(String id, String secondaryId, boolean activate) {
// Get the active workbench page
IWorkbenchPage page = getActiveWorkbenchPage();
if (page != null) {
// Look for any terminal view
- IViewPart anyTerminal = getFirstTerminalsView(id != null ? id : IUIConstants.ID, false);
+ IViewPart anyTerminal = getFirstTerminalsView(id != null ? id : IUIConstants.ID, secondaryId, false);
// there is at least one terminal available
if (anyTerminal != null) {
// is there an active terminal view
- IViewPart activePart = getFirstTerminalsView(id != null ? id : IUIConstants.ID, true);
+ IViewPart activePart = getFirstTerminalsView(id != null ? id : IUIConstants.ID, secondaryId, true);
// no terminal view active
if (activePart == null) {
// use the first not pinned
@@ -353,7 +357,7 @@ public class ConsoleManager {
}
// we found a active terminal page
// if it is pinned search for a non pinned (not active)
- if (((ITerminalsView) activePart).isPinned()) {
+ if (((ITerminalsView) activePart).isPinned() && secondaryId == null) {
// we found one so use it
IViewPart notPinnedPart = getFirstNotPinnedTerminalsView(id != null ? id : IUIConstants.ID);
if (notPinnedPart != null) {
@@ -395,12 +399,30 @@ public class ConsoleManager {
* @param forceNew If <code>true</code> a new console tab is created even if another one matches the criteria.
*/
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);
+ }
+
+ /**
+ * Opens the console with the given title and connector.
+ * <p>
+ * <b>Note:</b> The method must be called within the UI thread.
+ *
+ * @param id The terminals console view id or <code>null</code> to show the default terminals console view.
+ * @param secondaryId The terminals console view secondary id or <code>null</code>.
+ * @param title The console title. Must not be <code>null</code>.
+ * @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.
+ */
+ public CTabItem openConsole(String id, String secondaryId, String title, String encoding, ITerminalConnector connector, Object data, boolean activate, boolean forceNew) {
Assert.isNotNull(title);
Assert.isNotNull(connector);
Assert.isNotNull(Display.findDisplay(Thread.currentThread()));
// Make the consoles view visible
- IViewPart part = bringToTop(id, activate);
+ IViewPart part = bringToTop(id, secondaryId, activate);
if (!(part instanceof ITerminalsView)) return null;
// Cast to the correct type
ITerminalsView view = (ITerminalsView)part;
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 b91d11c6a..96cdb7230 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
@@ -41,12 +41,13 @@ public class TerminalService extends AbstractService implements ITerminalService
* Invoked to execute the terminal service runnable.
*
* @param id The terminals view id or <code>null</code>.
+ * @param secondaryId The terminals view secondary id or <code>null</code>.
* @param title The terminal tab 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>.
* @param callback The target callback to invoke if the operation finished or <code>null</code>.
*/
- public abstract void run(String id, String title, ITerminalConnector connector, Object data, ICallback callback);
+ public abstract void run(String id, String secondaryId, String title, ITerminalConnector connector, Object data, ICallback callback);
/**
* Returns if or if not to execute the runnable asynchronously.
@@ -73,6 +74,7 @@ public class TerminalService extends AbstractService implements ITerminalService
// Extract the properties
String id = properties.getStringProperty(ITerminalsConnectorConstants.PROP_ID);
+ String secondaryId = properties.getStringProperty(ITerminalsConnectorConstants.PROP_SECONDARY_ID);
String title = properties.getStringProperty(ITerminalsConnectorConstants.PROP_TITLE);
Object data = properties.getProperty(ITerminalsConnectorConstants.PROP_DATA);
@@ -93,18 +95,19 @@ public class TerminalService extends AbstractService implements ITerminalService
// Finalize the used variables
final String finId = id;
+ final String finSecondaryId = secondaryId;
final String finTitle = title;
final Object finData = data;
// Execute the operation
if (!runnable.isExecuteAsync()) {
- runnable.run(finId, finTitle, connector, finData, callback);
+ runnable.run(finId, finSecondaryId, finTitle, connector, finData, callback);
}
else {
DisplayUtil.safeAsyncExec(new Runnable() {
@Override
public void run() {
- runnable.run(finId, finTitle, connector, finData, callback);
+ runnable.run(finId, finSecondaryId, finTitle, connector, finData, callback);
}
});
}
@@ -173,13 +176,13 @@ public class TerminalService extends AbstractService implements ITerminalService
executeServiceOperation(properties, new TerminalServiceRunnable() {
@Override
- public void run(String id, String title, ITerminalConnector connector, Object data, ICallback callback) {
+ 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);
// Open the new console
- CTabItem item = ConsoleManager.getInstance().openConsole(id, title, encoding, connector, data, true, forceNew);
+ CTabItem item = ConsoleManager.getInstance().openConsole(id, secondaryId, title, encoding, connector, data, true, forceNew);
// 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.setData("properties", properties); //$NON-NLS-1$
@@ -198,7 +201,7 @@ public class TerminalService extends AbstractService implements ITerminalService
executeServiceOperation(properties, new TerminalServiceRunnable() {
@Override
- public void run(String id, String title, ITerminalConnector connector, Object data, ICallback callback) {
+ public void run(String id, String secondaryId, String title, ITerminalConnector connector, Object data, ICallback callback) {
// Close the console
ConsoleManager.getInstance().closeConsole(id, title, connector, data);
// Invoke the callback
@@ -216,7 +219,7 @@ public class TerminalService extends AbstractService implements ITerminalService
executeServiceOperation(properties, new TerminalServiceRunnable() {
@Override
- public void run(String id, String title, ITerminalConnector connector, Object data, ICallback callback) {
+ public void run(String id, String secondaryId, String title, ITerminalConnector connector, Object data, ICallback callback) {
// Close the console
ConsoleManager.getInstance().terminateConsole(id, title, connector, data);
// Invoke the callback
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 1f8df8be8..440973df8 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
@@ -406,8 +406,9 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid
ITerminalViewControl terminal = (ITerminalViewControl)oldItem.getData();
ITerminalConnector connector = terminal.getTerminalConnector();
- Object data=oldItem.getData("customData"); //$NON-NLS-1$
- String title=oldItem.getText();
+ Object data = oldItem.getData("customData"); //$NON-NLS-1$
+ IPropertiesContainer properties = (IPropertiesContainer)oldItem.getData("properties"); //$NON-NLS-1$
+ String title = oldItem.getText();
// The result tab item
CTabItem item = null;
@@ -446,8 +447,10 @@ public class TabFolderManager extends PlatformObject implements ISelectionProvid
item.setData(terminal);
- // Associated the custom data node with the tab item (if any)
+ // Associate the custom data node with the tab item (if any)
if (data != null) item.setData("customData", data); //$NON-NLS-1$
+ // Associate the properties with the tab item (if any)
+ if (properties != null) item.setData("properties", properties); //$NON-NLS-1$
// Overwrite the text canvas help id
String contextHelpId = getParentView().getContextHelpId();
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/view/TerminalsViewMementoHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/view/TerminalsViewMementoHandler.java
index a1963c0d5..64ea8724b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/view/TerminalsViewMementoHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/view/TerminalsViewMementoHandler.java
@@ -63,6 +63,10 @@ public class TerminalsViewMementoHandler {
memento = memento.createChild("terminalConnections"); //$NON-NLS-1$
Assert.isNotNull(memento);
+ // Write the view id and secondary id
+ memento.putString("id", view.getViewSite().getId()); //$NON-NLS-1$
+ memento.putString("secondaryId", view.getViewSite().getSecondaryId()); //$NON-NLS-1$
+
// Save the pinned state
memento.putBoolean("pinned", view.isPinned()); //$NON-NLS-1$
@@ -120,6 +124,11 @@ public class TerminalsViewMementoHandler {
// Get the "terminalConnections" memento
memento = memento.getChild("terminalConnections"); //$NON-NLS-1$
if (memento != null) {
+ // Read view id and secondary id
+ String id = memento.getString("id"); //$NON-NLS-1$
+ String secondaryId = memento.getString("secondaryId"); //$NON-NLS-1$
+ if ("null".equals(secondaryId)) secondaryId = null; //$NON-NLS-1$
+
final IMemento finMemento = memento;
// Restore the pinned state of the after all connections completed
AsyncCallbackCollector collector = new AsyncCallbackCollector(new Callback() {
@@ -148,6 +157,10 @@ public class TerminalsViewMementoHandler {
// Create the properties container that holds the terminal properties
IPropertiesContainer properties = new PropertiesContainer();
+ // Set the view id attributes
+ properties.setProperty(ITerminalsConnectorConstants.PROP_ID, id);
+ properties.setProperty(ITerminalsConnectorConstants.PROP_SECONDARY_ID, secondaryId);
+
// Restore the common attributes
properties.setProperty(ITerminalsConnectorConstants.PROP_DELEGATE_ID, connection.getString(ITerminalsConnectorConstants.PROP_DELEGATE_ID));
properties.setProperty(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, connection.getString(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID));

Back to the top