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 62000 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]
Dialog supports Workbench v02
dialogWithWorkbench-v02.txt (text/plain), 11.72 KB, created by
Paul Webster
on 2007-03-26 14:09:47 EDT
(
hide
)
Description:
Dialog supports Workbench v02
Filename:
MIME Type:
Creator:
Paul Webster
Created:
2007-03-26 14:09:47 EDT
Size:
11.72 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 26 Mar 2007 18:08:36 -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_SUPPORTS_WORKBENCH = TYPE_DIALOG | 4; > > /** > * <p> >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 26 Mar 2007 18:08:36 -0000 >@@ -46,6 +46,8 @@ > */ > final class ContextAuthority extends ExpressionAuthority { > >+ private static final String DIALOG_WITH_WORKBENCH = "org.eclipse.ui.contexts.internal.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) { >@@ -486,6 +516,9 @@ > case IContextService.TYPE_DIALOG: > buffer.append("dialog"); //$NON-NLS-1$ > break; >+ case IContextService.TYPE_DIALOG_SUPPORTS_WORKBENCH: >+ buffer.append("dialog-workbench"); //$NON-NLS-1$ >+ break; > case IContextService.TYPE_WINDOW: > buffer.append("window"); //$NON-NLS-1$ > break; >@@ -504,6 +537,10 @@ > Expression expression; > IContextActivation dialogWindowActivation; > switch (type) { >+ case IContextService.TYPE_DIALOG_SUPPORTS_WORKBENCH: >+ // add the bogus activation for reference purposes >+ activations.add(new ContextActivation(DIALOG_WITH_WORKBENCH, null, >+ contextService)); > case IContextService.TYPE_DIALOG: > expression = new ActiveShellExpression(shell); > dialogWindowActivation = new ContextActivation( >@@ -568,7 +605,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 +644,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 +701,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 26 Mar 2007 18:08:36 -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) >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 26 Mar 2007 18:08:36 -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. >@@ -300,9 +301,14 @@ > * open. > */ > 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; >#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 26 Mar 2007 18:08:37 -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,91 @@ >+/******************************************************************************* >+ * 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.create(); >+ contextService.registerShell(d.getShell(), >+ IContextService.TYPE_DIALOG_SUPPORTS_WORKBENCH); >+ d.open(); >+ 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