diff --git a/terminal/plugins/org.eclipse.tm.terminal.view.core/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.view.core/META-INF/MANIFEST.MF index 19c8c7373fd..9f15d97d265 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.view.core/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.view.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal.view.core;singleton:=true -Bundle-Version: 4.7.100.qualifier +Bundle-Version: 4.8.0.qualifier Bundle-Activator: org.eclipse.tm.terminal.view.core.activator.CoreBundleActivator Bundle-Vendor: %providerName Require-Bundle: org.eclipse.core.expressions;bundle-version="3.4.400", diff --git a/terminal/plugins/org.eclipse.tm.terminal.view.core/src/org/eclipse/tm/terminal/view/core/interfaces/constants/ITerminalsConnectorConstants.java b/terminal/plugins/org.eclipse.tm.terminal.view.core/src/org/eclipse/tm/terminal/view/core/interfaces/constants/ITerminalsConnectorConstants.java index ed14256fce1..c94d0262618 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.view.core/src/org/eclipse/tm/terminal/view/core/interfaces/constants/ITerminalsConnectorConstants.java +++ b/terminal/plugins/org.eclipse.tm.terminal.view.core/src/org/eclipse/tm/terminal/view/core/interfaces/constants/ITerminalsConnectorConstants.java @@ -32,10 +32,35 @@ public interface ITerminalsConnectorConstants { /** * Property: The unique secondary id of the terminals view to open. *
+ * Special values: + *
null
means open on the first primary terminal (the one with no secondary id)
+ * * Property Type: {@link String} */ public static final String PROP_SECONDARY_ID = "secondaryId"; //$NON-NLS-1$ + /** + * Special value for {@link #PROP_SECONDARY_ID} to indicate reuse of the most recent terminal view + * @since 4.8 + */ + public static final String LAST_ACTIVE_SECONDARY_ID = "last"; //$NON-NLS-1$ + + /** + * Special value for {@link #PROP_SECONDARY_ID} to indicate reuse of any terminal view + * @since 4.8 + */ + public static final String ANY_ACTIVE_SECONDARY_ID = "*"; //$NON-NLS-1$ + /** * Property: The title of the terminal tab to open. *
diff --git a/terminal/plugins/org.eclipse.tm.terminal.view.ui/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.view.ui/META-INF/MANIFEST.MF
index 0d4a0192d6b..d5a95f4f69f 100644
--- a/terminal/plugins/org.eclipse.tm.terminal.view.ui/META-INF/MANIFEST.MF
+++ b/terminal/plugins/org.eclipse.tm.terminal.view.ui/META-INF/MANIFEST.MF
@@ -11,8 +11,8 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="3.4.400",
org.eclipse.core.variables;bundle-version="3.2.600",
org.eclipse.debug.ui;bundle-version="3.8.1";resolution:=optional,
org.eclipse.egit.ui;bundle-version="2.0.0";resolution:=optional,
- org.eclipse.tm.terminal.view.core;bundle-version="4.5.0",
- org.eclipse.tm.terminal.control;bundle-version="4.5.0",
+ org.eclipse.tm.terminal.view.core;bundle-version="[4.8.0,5.0.0)",
+ org.eclipse.tm.terminal.control;bundle-version="[5.2.0,6.0.0)",
org.eclipse.ui;bundle-version="3.8.0",
org.eclipse.ui.ide;bundle-version="3.18.0";resolution:=optional,
org.eclipse.ui.editors;bundle-version="3.14.0";resolution:=optional,
diff --git a/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/manager/ConsoleManager.java b/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/manager/ConsoleManager.java
index 072b4673582..428ebf5a5f2 100644
--- a/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/manager/ConsoleManager.java
+++ b/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/manager/ConsoleManager.java
@@ -17,6 +17,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
@@ -53,9 +54,6 @@ import org.eclipse.ui.PlatformUI;
*/
public class ConsoleManager {
- // Constant to indicate any secondary id is acceptable
- private final static String ANY_SECONDARY_ID = new String("*"); //$NON-NLS-1$
-
// Reference to the perspective listener instance
private final IPerspectiveListener perspectiveListener;
@@ -198,7 +196,9 @@ public class ConsoleManager {
* Note: The method must be called within the UI thread.
*
* @param id The terminals console view id or null
to show the default terminals console view.
- * @param secondaryId The terminals console view secondary id or null
.
+ * @param secondaryId The terminal console secondary id, which may be null
which is the secondary id of
+ * the first terminal view opened. To specify reuse of most recent terminal view use special value of
+ * {@link ITerminalsConnectorConstants#LAST_ACTIVE_SECONDARY_ID}.
*
* @return The console view instance if available or null
otherwise.
*/
@@ -225,7 +225,9 @@ public class ConsoleManager {
* Search and return a terminal view with a specific secondary id
*
* @param id The terminals console view id. Must not be null
.
- * @param secondaryId The terminals console view secondary id or null
.
+ * @param secondaryId The terminal console secondary id, which may be null
which is the secondary id of
+ * the first terminal view opened. To specify reuse of any active terminal view use special value of
+ * {@link ITerminalsConnectorConstants#ANY_ACTIVE_SECONDARY_ID}.
* @param restore True
if to try to restore the view, false
otherwise.
*
* @return The terminals console view instance or null
if not found.
@@ -235,8 +237,8 @@ public class ConsoleManager {
for (IViewReference ref : getActiveWorkbenchPage().getViewReferences()) {
if (ref.getId().equals(id)) {
- if (ANY_SECONDARY_ID.equals(secondaryId) || secondaryId == null && ref.getSecondaryId() == null
- || secondaryId != null && secondaryId.equals(ref.getSecondaryId())) {
+ if (ITerminalsConnectorConstants.ANY_ACTIVE_SECONDARY_ID.equals(secondaryId)
+ || Objects.equals(secondaryId, ref.getSecondaryId())) {
return ref.getView(restore);
}
}
@@ -248,7 +250,9 @@ public class ConsoleManager {
* Search and return the active terminals view.
*
* @param id The terminals console view id. Must not be null
.
- * @param secondaryId The terminals console view secondary id or null
.
+ * @param secondaryId The terminal console secondary id, which may be null
which is the secondary id of
+ * the first terminal view opened. To specify reuse of most recent terminal view use special value of
+ * {@link ITerminalsConnectorConstants#LAST_ACTIVE_SECONDARY_ID}.
* @return The terminals console view instance or null
if not found.
*/
private IViewPart getActiveTerminalsView(String id, String secondaryId) {
@@ -257,8 +261,8 @@ public class ConsoleManager {
IViewPart part = null;
if (id.equals(lastActiveViewId)) {
- if (secondaryId == null || ANY_SECONDARY_ID.equals(secondaryId)
- || secondaryId.equals(lastActiveSecondaryViewId)) {
+ if (ITerminalsConnectorConstants.LAST_ACTIVE_SECONDARY_ID.equals(secondaryId)
+ || Objects.equals(secondaryId, lastActiveSecondaryViewId)) {
part = getTerminalsViewWithSecondaryId(lastActiveViewId, lastActiveSecondaryViewId, false);
}
}
@@ -363,7 +367,8 @@ public class ConsoleManager {
IViewPart activePart = getActiveTerminalsView(id != null ? id : IUIConstants.ID, secondaryId);
if (activePart == null) {
// Create a new one
- IViewPart newPart = showConsoleView(id != null ? id : IUIConstants.ID, getSecondaryId(secondaryId, id));
+ IViewPart newPart = showConsoleView(id != null ? id : IUIConstants.ID,
+ getNextTerminalSecondaryId(IUIConstants.ID));
return newPart;
}
@@ -377,20 +382,6 @@ public class ConsoleManager {
return null;
}
- /**
- * Return the secondary id to use.
- * @param secondaryId
- * @param id
- * @return the secondaryId argument is not null, or *, otherwise use the auto generated secondary id.
- */
- private String getSecondaryId(String secondaryId, String id) {
- if (secondaryId == null || ANY_SECONDARY_ID.equals(secondaryId)) {
- return getNextTerminalSecondaryId(id != null ? id : IUIConstants.ID);
- }
-
- return secondaryId;
- }
-
/**
* Opens the console with the given title and connector.
*
@@ -402,10 +393,14 @@ public class ConsoleManager {
* @param connector The terminal connector. Must not be null
.
* @param data The custom terminal data node or null
.
* @param flags The flags controlling how the console is opened or null
to use defaults.
+ * @deprecated Use {@link #openConsole(String, String, String, String, ITerminalConnector, Object, Map)}
+ * and explicitly specify an ID {@link ITerminalsConnectorConstants#LAST_ACTIVE_SECONDARY_ID}
*/
+ @Deprecated
public CTabItem openConsole(String id, String title, String encoding, ITerminalConnector connector, Object data,
Mapnull
to show the default terminals console view.
- * @param secondaryId The terminals console view secondary id or null
.
+ * @param secondaryId The terminal console secondary id, which may be null
which is the secondary id of
+ * the first terminal view opened. To specify reuse of most recent terminal view use special value of
+ * {@link ITerminalsConnectorConstants#LAST_ACTIVE_SECONDARY_ID}.
* @param title The console title. Must not be null
.
* @param encoding The terminal encoding or null
.
* @param connector The terminal connector. Must not be null
.
diff --git a/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/services/TerminalService.java b/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/services/TerminalService.java
index a6ee782d4ec..c5b8bf263b5 100644
--- a/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/services/TerminalService.java
+++ b/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/services/TerminalService.java
@@ -153,6 +153,9 @@ public class TerminalService implements ITerminalService {
// Extract the properties
String id = (String) properties.get(ITerminalsConnectorConstants.PROP_ID);
String secondaryId = (String) properties.get(ITerminalsConnectorConstants.PROP_SECONDARY_ID);
+ if (!properties.containsKey(ITerminalsConnectorConstants.PROP_SECONDARY_ID)) {
+ secondaryId = ITerminalsConnectorConstants.LAST_ACTIVE_SECONDARY_ID;
+ }
String title = (String) properties.get(ITerminalsConnectorConstants.PROP_TITLE);
Object data = properties.get(ITerminalsConnectorConstants.PROP_DATA);
@@ -292,11 +295,8 @@ public class TerminalService implements ITerminalService {
}
// Open the new console
CTabItem item;
- if (secondaryId != null)
- item = ConsoleManager.getInstance().openConsole(id, secondaryId, title, encoding, connector, data,
- flags);
- else
- item = ConsoleManager.getInstance().openConsole(id, title, encoding, connector, data, flags);
+ 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())