Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 61932 Details for
Bug 173213
[Commands] Show View cannot be executed from the Command Composer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Work in progress - v01
dialogWithWorkbench-v01.txt (text/plain), 16.88 KB, created by
Paul Webster
on 2007-03-25 15:14:43 EDT
(
hide
)
Description:
Work in progress - v01
Filename:
MIME Type:
Creator:
Paul Webster
Created:
2007-03-25 15:14:43 EDT
Size:
16.88 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/contexts/IContextService.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/contexts/IContextService.java,v >retrieving revision 1.19 >diff -u -r1.19 IContextService.java >--- Eclipse UI/org/eclipse/ui/contexts/IContextService.java 8 May 2006 20:55:53 -0000 1.19 >+++ Eclipse UI/org/eclipse/ui/contexts/IContextService.java 25 Mar 2007 19:14:22 -0000 >@@ -71,6 +71,19 @@ > * context should also be active. > */ > public static final int TYPE_WINDOW = 2; >+ >+ /** >+ * The type used for registration indicating that the shell should be >+ * treated as a dialog. When the given shell is active, the "In Dialogs" >+ * context should also be active. The active workbench window should also be >+ * available. >+ * <p> >+ * The return value from getShellType(Shell) will be TYPE_DIALOG. >+ * </p> >+ * >+ * @since 3.3 >+ */ >+ public static final int TYPE_DIALOG_WITH_WORKBENCH = TYPE_DIALOG | 4; > > /** > * <p> >Index: Eclipse UI/org/eclipse/ui/internal/services/ActiveShellSourceProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/ActiveShellSourceProvider.java,v >retrieving revision 1.8 >diff -u -r1.8 ActiveShellSourceProvider.java >--- Eclipse UI/org/eclipse/ui/internal/services/ActiveShellSourceProvider.java 16 Mar 2007 18:00:35 -0000 1.8 >+++ Eclipse UI/org/eclipse/ui/internal/services/ActiveShellSourceProvider.java 25 Mar 2007 19:14:22 -0000 >@@ -27,6 +27,7 @@ > import org.eclipse.ui.contexts.IContextService; > import org.eclipse.ui.internal.Workbench; > import org.eclipse.ui.internal.WorkbenchWindow; >+import org.eclipse.ui.internal.contexts.ContextService; > > /** > * A provider of notifications for when the active shell changes. >@@ -63,7 +64,7 @@ > * <code>null</code>. > */ > private Shell lastActiveWorkbenchWindowShell = null; >- >+ > /** > * The last workbench window seen as active by this provider. This value may > * be null if the last call to >@@ -81,7 +82,7 @@ > * @since 3.3 > */ > private Boolean lastCoolbarVisibility = Boolean.FALSE; >- >+ > /** > * The result of the last visibility check on the perspective bar of the > * last active workbench window. >@@ -89,7 +90,7 @@ > * @since 3.3 > */ > private Boolean lastPerspectiveBarVisibility = Boolean.FALSE; >- >+ > /** > * The listener to individual window properties. > * >@@ -110,8 +111,7 @@ > newValue); > lastCoolbarVisibility = (Boolean) newValue; > } >- } >- else if (WorkbenchWindow.PROP_PERSPECTIVEBAR_VISIBLE.equals(event >+ } else if (WorkbenchWindow.PROP_PERSPECTIVEBAR_VISIBLE.equals(event > .getProperty())) { > Object newValue = event.getNewValue(); > if (newValue == null || !(newValue instanceof Boolean)) >@@ -125,9 +125,9 @@ > } > } > } >- >+ > }; >- >+ > /** > * The listener to shell activations on the display. > */ >@@ -142,7 +142,7 @@ > } > return; > } >- >+ > if (DEBUG) { > logDebuggingInfo("\tASSP:lastActiveShell: " + lastActiveShell); //$NON-NLS-1$ > logDebuggingInfo("\tASSP:lastActiveWorkbenchWindowShell" + lastActiveWorkbenchWindowShell); //$NON-NLS-1$ >@@ -155,7 +155,7 @@ > .get(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); > final Shell newActiveWorkbenchWindowShell = (Shell) currentState > .get(ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME); >- >+ > // dont update the coolbar/perspective bar visibility unless we're > // processing a workbench window change > final Boolean newCoolbarVisibility = newActiveWorkbenchWindow == null ? lastCoolbarVisibility >@@ -180,16 +180,21 @@ > sourceValuesByName.put( > ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME, > newActiveWorkbenchWindowShell); >- int sourceFlags = ISources.ACTIVE_SHELL | ISources.ACTIVE_WORKBENCH_WINDOW; >- >+ int sourceFlags = ISources.ACTIVE_SHELL >+ | ISources.ACTIVE_WORKBENCH_WINDOW; >+ > if (coolbarChanged) { >- sourceValuesByName.put(ISources.ACTIVE_WORKBENCH_WINDOW_IS_COOLBAR_VISIBLE_NAME, >- newCoolbarVisibility); >+ sourceValuesByName >+ .put( >+ ISources.ACTIVE_WORKBENCH_WINDOW_IS_COOLBAR_VISIBLE_NAME, >+ newCoolbarVisibility); > sourceFlags |= ISources.ACTIVE_WORKBENCH_WINDOW_SUBORDINATE; > } > if (perspectiveBarChanged) { >- sourceValuesByName.put(ISources.ACTIVE_WORKBENCH_WINDOW_IS_PERSPECTIVEBAR_VISIBLE_NAME, >- newPerspectiveBarVisibility); >+ sourceValuesByName >+ .put( >+ ISources.ACTIVE_WORKBENCH_WINDOW_IS_PERSPECTIVEBAR_VISIBLE_NAME, >+ newPerspectiveBarVisibility); > sourceFlags |= ISources.ACTIVE_WORKBENCH_WINDOW_SUBORDINATE; > } > >@@ -205,9 +210,10 @@ > logDebuggingInfo("Active workbench window perspective bar visibility " //$NON-NLS-1$ > + newPerspectiveBarVisibility); > } >- >+ > fireSourceChanged(sourceFlags, sourceValuesByName); >- hookListener(lastActiveWorkbenchWindow, newActiveWorkbenchWindow); >+ hookListener(lastActiveWorkbenchWindow, >+ newActiveWorkbenchWindow); > > } else if (shellChanged) { > if (DEBUG) { >@@ -224,20 +230,25 @@ > sourceValuesByName.put( > ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME, > newActiveWorkbenchWindowShell); >- >- int sourceFlags = ISources.ACTIVE_SHELL | ISources.ACTIVE_WORKBENCH_WINDOW; >- >+ >+ int sourceFlags = ISources.ACTIVE_SHELL >+ | ISources.ACTIVE_WORKBENCH_WINDOW; >+ > if (coolbarChanged) { >- sourceValuesByName.put(ISources.ACTIVE_WORKBENCH_WINDOW_IS_COOLBAR_VISIBLE_NAME, >- newCoolbarVisibility); >+ sourceValuesByName >+ .put( >+ ISources.ACTIVE_WORKBENCH_WINDOW_IS_COOLBAR_VISIBLE_NAME, >+ newCoolbarVisibility); > sourceFlags |= ISources.ACTIVE_WORKBENCH_WINDOW_SUBORDINATE; > } > if (perspectiveBarChanged) { >- sourceValuesByName.put(ISources.ACTIVE_WORKBENCH_WINDOW_IS_PERSPECTIVEBAR_VISIBLE_NAME, >- newPerspectiveBarVisibility); >+ sourceValuesByName >+ .put( >+ ISources.ACTIVE_WORKBENCH_WINDOW_IS_PERSPECTIVEBAR_VISIBLE_NAME, >+ newPerspectiveBarVisibility); > sourceFlags |= ISources.ACTIVE_WORKBENCH_WINDOW_SUBORDINATE; > } >- >+ > if (DEBUG) { > logDebuggingInfo("Active workbench window changed to " //$NON-NLS-1$ > + newActiveWorkbenchWindow); >@@ -249,9 +260,9 @@ > + newPerspectiveBarVisibility); > } > >- fireSourceChanged(sourceFlags, >- sourceValuesByName); >- hookListener(lastActiveWorkbenchWindow, newActiveWorkbenchWindow); >+ fireSourceChanged(sourceFlags, sourceValuesByName); >+ hookListener(lastActiveWorkbenchWindow, >+ newActiveWorkbenchWindow); > } > > // Update the member variables. >@@ -297,12 +308,17 @@ > > /* > * We will fallback to the workbench window, but only if a dialog is not >- * open. >+ * open or it's not a specially registered TYPE_DIALOG_WITH_WORKBENCH. > */ > final IContextService contextService = (IContextService) workbench >- .getService(IContextService.class); >+ .getService(IContextService.class); >+ boolean dialogSupportsWorkbench = false; >+ if (contextService instanceof ContextService) { >+ dialogSupportsWorkbench = ((ContextService) contextService) >+ .dialogSupportsWorkbench(newActiveShell); >+ } > final int shellType = contextService.getShellType(newActiveShell); >- if (shellType != IContextService.TYPE_DIALOG) { >+ if (shellType != IContextService.TYPE_DIALOG || dialogSupportsWorkbench) { > final IWorkbenchWindow newActiveWorkbenchWindow = workbench > .getActiveWorkbenchWindow(); > final Shell newActiveWorkbenchWindowShell; >@@ -324,13 +340,15 @@ > public final String[] getProvidedSourceNames() { > return PROVIDED_SOURCE_NAMES; > } >- >+ > private void hookListener(WorkbenchWindow lastActiveWorkbenchWindow, > WorkbenchWindow newActiveWorkbenchWindow) { > if (lastActiveWorkbenchWindow != null) >- lastActiveWorkbenchWindow.removePropertyChangeListener(propertyListener); >- >+ lastActiveWorkbenchWindow >+ .removePropertyChangeListener(propertyListener); >+ > if (newActiveWorkbenchWindow != null) >- newActiveWorkbenchWindow.addPropertyChangeListener(propertyListener); >+ newActiveWorkbenchWindow >+ .addPropertyChangeListener(propertyListener); > } > } >Index: Eclipse UI/org/eclipse/ui/internal/contexts/ContextAuthority.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/contexts/ContextAuthority.java,v >retrieving revision 1.21 >diff -u -r1.21 ContextAuthority.java >--- Eclipse UI/org/eclipse/ui/internal/contexts/ContextAuthority.java 16 Mar 2007 18:00:37 -0000 1.21 >+++ Eclipse UI/org/eclipse/ui/internal/contexts/ContextAuthority.java 25 Mar 2007 19:14:22 -0000 >@@ -46,6 +46,8 @@ > */ > final class ContextAuthority extends ExpressionAuthority { > >+ private static final String DIALOG_WITH_WORKBENCH = "org.eclipse.ui.contexts.dialog_with_workbench"; //$NON-NLS-1$ >+ > /** > * The default size of the set containing the activations to recompute. This > * is more than enough to cover the average case. >@@ -177,7 +179,7 @@ > for (int i = 1; i <= 32; i++) { > if ((sourcePriority & (1 << i)) != 0) { > Set activations = activationsBySourcePriority[i]; >- if (activations == null) { >+ if (activations == null) { > activations = new HashSet(1); > activationsBySourcePriority[i] = activations; > } >@@ -378,6 +380,33 @@ > return (Shell) getVariable(ISources.ACTIVE_SHELL_NAME); > } > >+ public final boolean dialogSupportsWorkbench(final Shell shell) { >+ if (shell != null) { >+ final Collection activations = (Collection) registeredWindows >+ .get(shell); >+ if (activations != null) { >+ // The shell is registered, so check what type it was registered >+ // as. >+ if (activations.isEmpty()) { >+ // It was registered as none. >+ return false; >+ } >+ >+ // Look for the right type of context id. >+ final Iterator activationItr = activations.iterator(); >+ while (activationItr.hasNext()) { >+ final IContextActivation activation = (IContextActivation) activationItr >+ .next(); >+ final String contextId = activation.getContextId(); >+ if (contextId == DIALOG_WITH_WORKBENCH) { >+ return true; >+ } >+ } >+ } >+ } >+ return false; >+ } >+ > /** > * Returns the shell type for the given shell. > * >@@ -418,9 +447,10 @@ > } > > // This shouldn't be possible. >- Assert.isTrue( >- false, >- "A registered shell should have at least one submission matching TYPE_WINDOW or TYPE_DIALOG"); //$NON-NLS-1$ >+ Assert >+ .isTrue( >+ false, >+ "A registered shell should have at least one submission matching TYPE_WINDOW or TYPE_DIALOG"); //$NON-NLS-1$ > return IContextService.TYPE_NONE; // not reachable > > } else if (shell.getParent() != null) { >@@ -504,6 +534,9 @@ > Expression expression; > IContextActivation dialogWindowActivation; > switch (type) { >+ case IContextService.TYPE_DIALOG_WITH_WORKBENCH: >+ activations.add(new ContextActivation(DIALOG_WITH_WORKBENCH, null, >+ contextService)); > case IContextService.TYPE_DIALOG: > expression = new ActiveShellExpression(shell); > dialogWindowActivation = new ContextActivation( >@@ -568,7 +601,9 @@ > */ > public void widgetDisposed(DisposeEvent e) { > registeredWindows.remove(shell); >- shell.removeDisposeListener(this); >+ if (!shell.isDisposed()) { >+ shell.removeDisposeListener(this); >+ } > > /* > * In the case where a dispose has happened, we are expecting an >@@ -605,7 +640,7 @@ > if (DEBUG_PERFORMANCE) { > startTime = System.currentTimeMillis(); > } >- >+ > /* > * In this first phase, we cycle through all of the activations that > * could have potentially changed. Each such activation is added to a >@@ -662,7 +697,7 @@ > updateContext(contextId, false); > } > } >- >+ > // If tracing performance, then print the results. > if (DEBUG_PERFORMANCE) { > final long elapsedTime = System.currentTimeMillis() - startTime; >Index: Eclipse UI/org/eclipse/ui/internal/contexts/ContextService.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/contexts/ContextService.java,v >retrieving revision 1.18 >diff -u -r1.18 ContextService.java >--- Eclipse UI/org/eclipse/ui/internal/contexts/ContextService.java 8 May 2006 20:55:32 -0000 1.18 >+++ Eclipse UI/org/eclipse/ui/internal/contexts/ContextService.java 25 Mar 2007 19:14:22 -0000 >@@ -209,6 +209,10 @@ > public final int getShellType(final Shell shell) { > return contextAuthority.getShellType(shell); > } >+ >+ public final boolean dialogSupportsWorkbench(final Shell shell) { >+ return contextAuthority.dialogSupportsWorkbench(shell); >+ } > > /* > * (non-Javadoc) >#P org.eclipse.ui.tests >Index: Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandsTestSuite.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandsTestSuite.java,v >retrieving revision 1.21 >diff -u -r1.21 CommandsTestSuite.java >--- Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandsTestSuite.java 16 Mar 2007 18:00:01 -0000 1.21 >+++ Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandsTestSuite.java 25 Mar 2007 19:14:23 -0000 >@@ -45,5 +45,6 @@ > addTest(new TestSuite(CommandCallbackTest.class)); > addTest(new TestSuite(CommandEnablementTest.class)); > addTest(new TestSuite(CommandActionTest.class)); >+ addTest(new TestSuite(WindowDialogTest.class)); > } > } >Index: Eclipse UI Tests/org/eclipse/ui/tests/commands/WindowDialogTest.java >=================================================================== >RCS file: Eclipse UI Tests/org/eclipse/ui/tests/commands/WindowDialogTest.java >diff -N Eclipse UI Tests/org/eclipse/ui/tests/commands/WindowDialogTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI Tests/org/eclipse/ui/tests/commands/WindowDialogTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,90 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.tests.commands; >+ >+import org.eclipse.core.expressions.IEvaluationContext; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.ui.ISources; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.contexts.IContextService; >+import org.eclipse.ui.handlers.IHandlerService; >+import org.eclipse.ui.tests.harness.util.UITestCase; >+ >+/** >+ * @since 3.3 >+ * >+ */ >+public class WindowDialogTest extends UITestCase { >+ >+ /** >+ * @param testName >+ */ >+ public WindowDialogTest(String testName) { >+ super(testName); >+ } >+ >+ public void testBasicApplicationContext() throws Exception { >+ IWorkbenchWindow win = openTestWindow(); >+ IHandlerService handlerService = (IHandlerService) win >+ .getService(IHandlerService.class); >+ IEvaluationContext appContext = handlerService.getCurrentState(); >+ Object obj = appContext >+ .getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); >+ assertEquals(win, obj); >+ Dialog d = new Dialog(win.getShell()) { >+ }; >+ try { >+ d.setBlockOnOpen(false); >+ d.open(); >+ processEvents(); >+ appContext = handlerService.getCurrentState(); >+ obj = appContext.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); >+ } finally { >+ d.close(); >+ } >+ processEvents(); >+ assertNull(obj); >+ appContext = handlerService.getCurrentState(); >+ obj = appContext.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); >+ assertEquals(win, obj); >+ } >+ >+ public void testDialogWithWindowRef() throws Exception { >+ IWorkbenchWindow win = openTestWindow(); >+ IHandlerService handlerService = (IHandlerService) win >+ .getService(IHandlerService.class); >+ IContextService contextService = (IContextService) win >+ .getService(IContextService.class); >+ IEvaluationContext appContext = handlerService.getCurrentState(); >+ Object obj = appContext >+ .getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); >+ assertEquals(win, obj); >+ Dialog d = new Dialog(win.getShell()) { >+ }; >+ try { >+ d.setBlockOnOpen(false); >+ d.open(); >+ contextService.registerShell(d.getShell(), >+ IContextService.TYPE_DIALOG_WITH_WORKBENCH); >+ processEvents(); >+ appContext = handlerService.getCurrentState(); >+ obj = appContext.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); >+ } finally { >+ d.close(); >+ } >+ processEvents(); >+ assertEquals(win, obj); >+ appContext = handlerService.getCurrentState(); >+ obj = appContext.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); >+ assertEquals(win, obj); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 173213
:
61932
|
62000
|
62012
|
64257
|
64547