Merge "Issue #206 Made tear off menu dialog activate contexts for perspective" into 10-Tech_Blocked
Former-commit-id:b1eca1ae8f
[formerly 1ca26738cc10a37119b939a405987198245a4d65] Former-commit-id:54d27a840f
This commit is contained in:
commit
9893d3b246
4 changed files with 47 additions and 8 deletions
|
@ -29,9 +29,9 @@ import org.eclipse.core.runtime.IExtension;
|
||||||
import org.eclipse.core.runtime.IExtensionPoint;
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
|
||||||
import org.eclipse.ui.contexts.IContextActivation;
|
import org.eclipse.ui.contexts.IContextActivation;
|
||||||
import org.eclipse.ui.contexts.IContextService;
|
import org.eclipse.ui.contexts.IContextService;
|
||||||
|
import org.eclipse.ui.services.IServiceLocator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses extension point to look up contexts for editors
|
* Uses extension point to look up contexts for editors
|
||||||
|
@ -61,7 +61,7 @@ public class ContextManager {
|
||||||
|
|
||||||
private static final String EXTENSION_POINT = "com.raytheon.uf.viz.core.classContext";
|
private static final String EXTENSION_POINT = "com.raytheon.uf.viz.core.classContext";
|
||||||
|
|
||||||
private static Map<IWorkbenchWindow, ContextManager> instanceMap = new HashMap<IWorkbenchWindow, ContextManager>();
|
private static Map<IServiceLocator, ContextManager> instanceMap = new HashMap<IServiceLocator, ContextManager>();
|
||||||
|
|
||||||
private static synchronized String[] getContextsForClass(String name) {
|
private static synchronized String[] getContextsForClass(String name) {
|
||||||
if (contexts == null) {
|
if (contexts == null) {
|
||||||
|
@ -126,11 +126,11 @@ public class ContextManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized ContextManager getInstance(
|
public static synchronized ContextManager getInstance(
|
||||||
IWorkbenchWindow window) {
|
IServiceLocator locator) {
|
||||||
ContextManager manager = instanceMap.get(window);
|
ContextManager manager = instanceMap.get(locator);
|
||||||
if (manager == null) {
|
if (manager == null) {
|
||||||
manager = new ContextManager(window);
|
manager = new ContextManager(locator);
|
||||||
instanceMap.put(window, manager);
|
instanceMap.put(locator, manager);
|
||||||
}
|
}
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
@ -141,8 +141,8 @@ public class ContextManager {
|
||||||
|
|
||||||
private IContextService service;
|
private IContextService service;
|
||||||
|
|
||||||
private ContextManager(IWorkbenchWindow window) {
|
private ContextManager(IServiceLocator locator) {
|
||||||
service = (IContextService) window.getService(IContextService.class);
|
service = (IContextService) locator.getService(IContextService.class);
|
||||||
activeObjects = new HashSet<Object>();
|
activeObjects = new HashSet<Object>();
|
||||||
activeMap = new HashMap<String, ContextManager.Context>();
|
activeMap = new HashMap<String, ContextManager.Context>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,10 @@ import org.eclipse.swt.widgets.Menu;
|
||||||
import org.eclipse.swt.widgets.MenuItem;
|
import org.eclipse.swt.widgets.MenuItem;
|
||||||
import org.eclipse.swt.widgets.Monitor;
|
import org.eclipse.swt.widgets.Monitor;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
import org.eclipse.ui.services.IServiceLocator;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.core.ContextManager;
|
||||||
import com.raytheon.viz.ui.VizWorkbenchManager;
|
import com.raytheon.viz.ui.VizWorkbenchManager;
|
||||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
|
|
||||||
|
@ -159,6 +162,37 @@ public class TearOffMenuDialog extends CaveSWTDialog {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#opened()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void opened() {
|
||||||
|
final IServiceLocator locator = PlatformUI.getWorkbench();
|
||||||
|
|
||||||
|
Listener activate = new Listener() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(Event event) {
|
||||||
|
ContextManager.getInstance(locator).activateContexts(
|
||||||
|
perspectiveManager);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Listener deactivate = new Listener() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(Event event) {
|
||||||
|
ContextManager.getInstance(locator).deactivateContexts(
|
||||||
|
perspectiveManager);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
addListener(SWT.Activate, activate);
|
||||||
|
addListener(SWT.Deactivate, deactivate);
|
||||||
|
addListener(SWT.Close, deactivate);
|
||||||
|
|
||||||
|
activate.handleEvent(new Event());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void disposed() {
|
protected void disposed() {
|
||||||
for (Control control : fullComp.getChildren()) {
|
for (Control control : fullComp.getChildren()) {
|
||||||
|
|
|
@ -2042,6 +2042,9 @@
|
||||||
point="com.raytheon.uf.viz.core.classContext">
|
point="com.raytheon.uf.viz.core.classContext">
|
||||||
<classContext
|
<classContext
|
||||||
class="com.raytheon.viz.gfe.perspective.GFEPerspectiveManager">
|
class="com.raytheon.viz.gfe.perspective.GFEPerspectiveManager">
|
||||||
|
<contextId
|
||||||
|
id="com.raytheon.viz.gfe.GFEActionSet">
|
||||||
|
</contextId>
|
||||||
<contextId
|
<contextId
|
||||||
id="com.raytheon.viz.gfe.GFEContext">
|
id="com.raytheon.viz.gfe.GFEContext">
|
||||||
</contextId>
|
</contextId>
|
||||||
|
|
|
@ -1610,6 +1610,8 @@
|
||||||
point="com.raytheon.uf.viz.core.classContext">
|
point="com.raytheon.uf.viz.core.classContext">
|
||||||
<classContext
|
<classContext
|
||||||
class="com.raytheon.viz.mpe.ui.perspective.MPEPerspectiveManager">
|
class="com.raytheon.viz.mpe.ui.perspective.MPEPerspectiveManager">
|
||||||
|
<contextId id="com.raytheon.viz.MPEActionSet">
|
||||||
|
</contextId>
|
||||||
<contextId id="com.raytheon.viz.mpe.ui.MPE">
|
<contextId id="com.raytheon.viz.mpe.ui.MPE">
|
||||||
</contextId>
|
</contextId>
|
||||||
<contextId id="com.raytheon.viz.ui.tools.nav.zoom">
|
<contextId id="com.raytheon.viz.ui.tools.nav.zoom">
|
||||||
|
|
Loading…
Add table
Reference in a new issue