diff options
author | Darin Wright | 2010-09-28 19:02:01 +0000 |
---|---|---|
committer | Darin Wright | 2010-09-28 19:02:01 +0000 |
commit | 31583d83a8c95d995d120de27b7d5cf5c10e249b (patch) | |
tree | 33ac6d6133c7c985b824f036d1c05d11ead4d23e | |
parent | 2be5716d7218e82b436c1057ff06a5b69f607126 (diff) | |
download | eclipse.platform.debug-R3_6_1_maintenance.tar.gz eclipse.platform.debug-R3_6_1_maintenance.tar.xz eclipse.platform.debug-R3_6_1_maintenance.zip |
[r3.6.1 maintenance] Bug 325797 - views automatically opened based on debug context are hidden/closed on perspective switchv20100928_r361mR3_6_1_maintenance
-rw-r--r-- | org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextService.java | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextService.java index 74ba6efe9..8a62fa86f 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextService.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. + * Copyright (c) 2006, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,9 +16,9 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.StringTokenizer; -import java.util.Map.Entry; import org.eclipse.core.commands.common.NotDefinedException; import org.eclipse.core.commands.contexts.Context; @@ -103,6 +103,12 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi private IDebugContextService fDebugContextService; + /** + * Perspective that is currently being de-activated. Used to determine + * when to ignore active context changes. + */ + private IPerspectiveDescriptor fActivePerspective; + // base debug context public static final String DEBUG_CONTEXT= "org.eclipse.debug.ui.debugging"; //$NON-NLS-1$ @@ -219,9 +225,9 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi * Activates the views in this context hierarchy. Views are activated top down, allowing * sub-contexts to override settings in a parent context. */ - public void activateChain(IWorkbenchPage page) { + public void activateChain(IWorkbenchPage page, IPerspectiveDescriptor perspective) { initializeChain(); - doActivation(page, fAllViewBindingIds, fAllConetxtIds); + doActivation(page, perspective, fAllViewBindingIds, fAllConetxtIds); } /** @@ -232,18 +238,18 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi * @param viewIds id's of views to activate * @param contextIds associated contexts that are activated */ - private void doActivation(IWorkbenchPage page, String[] viewIds, String[] contextIds) { + private void doActivation(IWorkbenchPage page, IPerspectiveDescriptor perspective, String[] viewIds, String[] contextIds) { // note activation of all the relevant contexts for (int i = 0; i < contextIds.length; i++) { addActivated(contextIds[i]); } // set the active context to be this - setActive(page.getPerspective(), getId()); + setActive(perspective, getId()); // activate the view bindings for (int i = 0; i < viewIds.length; i++) { String viewId = viewIds[i]; ViewBinding binding = (ViewBinding) fAllViewIdToBindings.get(viewId); - binding.activated(page); + binding.activated(page, perspective); } // bring most relevant views to top for (int i = 0; i < viewIds.length; i++) { @@ -293,7 +299,7 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi * * @param page workbench page */ - public void deactivate(IWorkbenchPage page) { + public void deactivate(IWorkbenchPage page, IPerspectiveDescriptor perspective) { removeActivated(getId()); if (isActiveContext(getId())) { setActive(page.getPerspective(), null); @@ -301,7 +307,7 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi for (int i = 0; i < fViewBindingIds.length; i++) { String viewId = fViewBindingIds[i]; ViewBinding binding = (ViewBinding) fAllViewIdToBindings.get(viewId); - binding.deactivated(page); + binding.deactivated(page, perspective); } } @@ -401,15 +407,15 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi * Returns whether this view was opened by the user in the active perspective. * @return */ - public boolean isUserOpened() { - return fUserOpened.contains(getActivePerspective().getId()); + public boolean isUserOpened(IPerspectiveDescriptor perspective) { + return fUserOpened.contains(perspective.getId()); } /** * Returns whether this view was closed by the user in the active perspective * @return */ - public boolean isUserClosed() { + public boolean isUserClosed(IPerspectiveDescriptor perspective) { return fUserClosed.contains(getActivePerspective().getId()); } @@ -421,8 +427,8 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi * * @return */ - public boolean isDefault() { - String id = getActivePerspective().getId(); + public boolean isDefault(IPerspectiveDescriptor perspective) { + String id = perspective.getId(); if (IDebugUIConstants.ID_DEBUG_PERSPECTIVE.equals(id)) { return fgBaseDebugViewIds.contains(getViewId()); } @@ -461,8 +467,8 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi * * @param page */ - public void activated(IWorkbenchPage page) { - if (!isUserClosed()) { + public void activated(IWorkbenchPage page, IPerspectiveDescriptor perspective) { + if (!isUserClosed(perspective)) { if (isAutoOpen()) { try { fIgnoreChanges = true; @@ -511,9 +517,9 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi * * @param page */ - public void deactivated(IWorkbenchPage page) { - if (!isUserOpened()) { - if (isAutoClose() && !isDefault()) { + public void deactivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) { + if (!isUserOpened(perspective)) { + if (isAutoClose() && !isDefault(perspective)) { IViewReference reference = page.findViewReference(getViewId()); if (reference != null) { try { @@ -598,6 +604,10 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi getDebugContextService().addDebugContextListener(this); DebugUIPlugin.getDefault().getPluginPreferences().addPropertyChangeListener(this); fContextService.addContextManagerListener(this); + IWorkbenchPage page = fWindow.getActivePage(); + if (page != null) { + fActivePerspective = page.getPerspective(); + } } public void dispose() { @@ -605,6 +615,7 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi getDebugContextService().removeDebugContextListener(this); DebugUIPlugin.getDefault().getPluginPreferences().removePropertyChangeListener(this); fContextService.removeContextManagerListener(this); + fActivePerspective = null; } /** @@ -715,11 +726,7 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi * @return active perspective or <code>null</code> */ private IPerspectiveDescriptor getActivePerspective() { - IWorkbenchPage activePage = fWindow.getActivePage(); - if (activePage != null) { - return activePage.getPerspective(); - } - return null; + return fActivePerspective; } /** @@ -788,12 +795,12 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi while (contexts.hasNext()) { String contextId = (String)contexts.next(); if (!isActivated(contextId)) { - activateChain(contextId); + activateChain(contextId, getActivePerspective()); } // ensure last context gets top priority if (!contexts.hasNext()) { if (!isActiveContext(contextId)) { - activateChain(contextId); + activateChain(contextId, getActivePerspective()); } } } @@ -901,7 +908,7 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi Iterator iterator = contexts.iterator(); while (iterator.hasNext()) { String id = (String) iterator.next(); - deactivate(id); + deactivate(id, perspective); } } } @@ -934,6 +941,7 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi */ public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) { if (page.getWorkbenchWindow().equals(fWindow)) { + fActivePerspective = perspective; ISelection activeContext = getDebugContextService().getActiveContext(); if (activeContext != null) { contextActivated(activeContext); @@ -952,12 +960,12 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi * * @param contextId */ - private void activateChain(String contextId) { + private void activateChain(String contextId, IPerspectiveDescriptor perspective) { IWorkbenchPage page = fWindow.getActivePage(); if (page != null) { DebugContextViewBindings bindings= (DebugContextViewBindings) fContextIdsToBindings.get(contextId); if (bindings != null) { - bindings.activateChain(page); + bindings.activateChain(page, perspective); } } } @@ -1001,7 +1009,7 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi * @see org.eclipse.core.commands.contexts.IContextManagerListener#contextManagerChanged(org.eclipse.core.commands.contexts.ContextManagerEvent) */ public void contextManagerChanged(ContextManagerEvent event) { - if (event.isActiveContextsChanged()) { + if (event.isActiveContextsChanged() && getActivePerspective() != null) { Set disabledContexts = getDisabledContexts(event); if (!disabledContexts.isEmpty()) { Iterator contexts = disabledContexts.iterator(); @@ -1009,7 +1017,7 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi String contextId = (String)contexts.next(); if (isViewConetxt(contextId)) { if (isActivated(contextId)) { - deactivate(contextId); + deactivate(contextId, getActivePerspective()); } } } @@ -1019,12 +1027,12 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi } } - private void deactivate(String contextId) { + private void deactivate(String contextId, IPerspectiveDescriptor perspective) { IWorkbenchPage page = fWindow.getActivePage(); if (page != null) { DebugContextViewBindings bindings = (DebugContextViewBindings) fContextIdsToBindings.get(contextId); if (bindings != null) { - bindings.deactivate(page); + bindings.deactivate(page, perspective); } } } @@ -1118,6 +1126,7 @@ public class ViewContextService implements IDebugContextListener, IPerspectiveLi */ public void perspectivePreDeactivate(IWorkbenchPage page, IPerspectiveDescriptor perspective) { if (page.getWorkbenchWindow().equals(fWindow)) { + fActivePerspective = null; clean(perspective); } } |