diff options
author | Anton Leherbauer | 2014-07-18 13:56:12 +0000 |
---|---|---|
committer | Anton Leherbauer | 2014-07-18 13:58:53 +0000 |
commit | ad0688e73e390d8f33863ada0841fee04586a08a (patch) | |
tree | 3f67d80cd43efdc7a3422214e9a12bbe5525f44e | |
parent | 0750e5747ab70cdf106b0a8f7e7001b4ef73af12 (diff) | |
download | org.eclipse.tcf-ad0688e73e390d8f33863ada0841fee04586a08a.tar.gz org.eclipse.tcf-ad0688e73e390d8f33863ada0841fee04586a08a.tar.xz org.eclipse.tcf-ad0688e73e390d8f33863ada0841fee04586a08a.zip |
Terminals: Fix lookup of primary Terminals view
Added an internal constant to make it possible to differentiate
between "accept any secondary view" and "accept only the primary view".
2 files changed, 15 insertions, 4 deletions
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 2ce42b44d..59dacea65 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 @@ -48,6 +48,9 @@ import org.eclipse.ui.PlatformUI; @SuppressWarnings("restriction") 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; @@ -234,7 +237,9 @@ public class ConsoleManager { for (int i = 0; i < refs.length; i++) { IViewReference ref = refs[i]; if (ref.getId().equals(id)) { - if (secondaryId == null || secondaryId.equals(ref.getSecondaryId())) { + if (secondaryId == ANY_SECONDARY_ID + || secondaryId == null && ref.getSecondaryId() == null + || secondaryId != null && secondaryId.equals(ref.getSecondaryId())) { IViewPart part = ref.getView(true); if (useActive) { if (page.isPartVisible(part)) { @@ -289,6 +294,8 @@ public class ConsoleManager { String secondaryIdStr = Integer.toString(i); if (!terminalViews.keySet().contains(secondaryIdStr)) { // found a free slot + if (i == 0) + return null; return Integer.toString(i); } } @@ -360,7 +367,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() && secondaryId == null) { + if (((ITerminalsView) activePart).isPinned() && secondaryId == ANY_SECONDARY_ID) { // we found one so use it IViewPart notPinnedPart = getFirstNotPinnedTerminalsView(id != null ? id : IUIConstants.ID); if (notPinnedPart != null) { @@ -401,7 +408,7 @@ public class ConsoleManager { * @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, Map<String, Boolean> flags) { - return openConsole(id, null, title, encoding, connector, data, flags); + return openConsole(id, ANY_SECONDARY_ID, title, encoding, connector, data, flags); } /** 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 6a08bb5b6..f6e1568db 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 @@ -188,7 +188,11 @@ public class TerminalService extends AbstractService implements ITerminalService 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, flags); + 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); // 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$ |