From cb59b82add15d804fb5b58caf49fbb7d2ccb74dd Mon Sep 17 00:00:00 2001 From: Matt Nash Date: Fri, 31 May 2013 11:16:56 -0500 Subject: [PATCH] Issue #1996 remove tear offs from GFE by adding a field to enable by perspective Change-Id: I92d0138637b95c86a8326878756c720a97586fb1 Former-commit-id: 7666c93bd833f935c6b1635adeb385c2fa4e04cc --- cave/com.raytheon.uf.viz.d2d.ui/plugin.xml | 7 ++ cave/com.raytheon.uf.viz.ui.menus/plugin.xml | 1 + .../schema/tearoffperspective.exsd | 106 ++++++++++++++++++ .../widgets/tearoff/TearOffMenuListener.java | 44 +++++++- .../raytheon/viz/gfe/ui/GFEEditAreaMenu.java | 3 +- cave/com.raytheon.viz.hydro/plugin.xml | 7 ++ cave/com.raytheon.viz.mpe.ui/plugin.xml | 7 ++ 7 files changed, 169 insertions(+), 6 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.ui.menus/schema/tearoffperspective.exsd diff --git a/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml b/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml index 5dd403a1b2..2d363f2a90 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml +++ b/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml @@ -2170,4 +2170,11 @@ value="purge"> + + + + diff --git a/cave/com.raytheon.uf.viz.ui.menus/plugin.xml b/cave/com.raytheon.uf.viz.ui.menus/plugin.xml index 21f28a2f0d..a9cb64e917 100644 --- a/cave/com.raytheon.uf.viz.ui.menus/plugin.xml +++ b/cave/com.raytheon.uf.viz.ui.menus/plugin.xml @@ -1,6 +1,7 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/tearoff/TearOffMenuListener.java b/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/tearoff/TearOffMenuListener.java index f486955279..45b0814f5c 100644 --- a/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/tearoff/TearOffMenuListener.java +++ b/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/tearoff/TearOffMenuListener.java @@ -23,6 +23,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.ContributionItem; @@ -43,6 +48,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.viz.ui.VizWorkbenchManager; +import com.raytheon.viz.ui.perspectives.VizPerspectiveListener; /** * Menu listener that adds item to menu which will open dialog which is the menu @@ -72,14 +78,35 @@ public class TearOffMenuListener implements IMenuListener2 { public static final String TEAROFF_PREFERENCE_ID = "tearoffmenus"; + private static final String TEAROFF_DISABLED_PERSPECTIVES = "com.raytheon.uf.viz.ui.menus.tearoffperspective"; + private static final IUFStatusHandler statusHandler = UFStatus - .getHandler(TearOffMenuListener.class); + .getHandler(TearOffMenuListener.class); private static boolean enabled; + + private static List enabledPerspectives; static { final IPreferenceStore store = com.raytheon.uf.viz.core.Activator .getDefault().getPreferenceStore(); enabled = store.getBoolean(TEAROFF_PREFERENCE_ID); + enabledPerspectives = new ArrayList(); + + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint point = registry + .getExtensionPoint(TEAROFF_DISABLED_PERSPECTIVES); + if (point != null) { + IExtension[] extensions = point.getExtensions(); + for (IExtension extension : extensions) { + for (IConfigurationElement element : extension + .getConfigurationElements()) { + if (Boolean.valueOf(element.getAttribute("enabled"))) { + enabledPerspectives.add(element + .getAttribute("perspectiveId")); + } + } + } + } store.addPropertyChangeListener(new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { @@ -149,9 +176,12 @@ public class TearOffMenuListener implements IMenuListener2 { private Object getPerspectiveKey(IMenuManager manager) { String perspectiveId = ""; try { - perspectiveId = VizWorkbenchManager.getInstance().getCurrentWindow().getActivePage().getPerspective().getId(); + perspectiveId = VizWorkbenchManager.getInstance() + .getCurrentWindow().getActivePage().getPerspective() + .getId(); } catch (Exception e) { - statusHandler.handle(Priority.EVENTA, "Failed to get current perspective ID", e); + statusHandler.handle(Priority.EVENTA, + "Failed to get current perspective ID", e); } return perspectiveId + "::" + getKey(manager); } @@ -210,7 +240,13 @@ public class TearOffMenuListener implements IMenuListener2 { */ @Override public boolean isVisible() { - return super.isVisible() && enabled; + String currPerspective = VizPerspectiveListener + .getCurrentPerspectiveManager().getPerspectiveId(); + boolean currPerspectiveEnabled = false; + if (enabledPerspectives.contains(currPerspective)) { + currPerspectiveEnabled = true; + } + return super.isVisible() && enabled && currPerspectiveEnabled; } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/GFEEditAreaMenu.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/GFEEditAreaMenu.java index f4169f07b0..eae4785929 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/GFEEditAreaMenu.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/GFEEditAreaMenu.java @@ -30,7 +30,6 @@ import org.eclipse.ui.actions.CompoundContributionItem; import org.eclipse.ui.menus.CommandContributionItem; import org.eclipse.ui.menus.CommandContributionItemParameter; -import com.raytheon.uf.viz.ui.menus.widgets.tearoff.TearOffMenuListener; import com.raytheon.viz.gfe.GFEPreference; import com.raytheon.viz.gfe.core.DataManager; import com.raytheon.viz.gfe.core.IReferenceSetManager; @@ -81,7 +80,7 @@ public class GFEEditAreaMenu extends CompoundContributionItem { MenuManager mm = new MenuManager(group); menuMgr.add(mm); - mm.addMenuListener(new TearOffMenuListener(mm)); + // mm.addMenuListener(new TearOffMenuListener(mm)); int count = 0; for (String ref : refMgr.getGroupData(group)) { Map parms = new HashMap(); diff --git a/cave/com.raytheon.viz.hydro/plugin.xml b/cave/com.raytheon.viz.hydro/plugin.xml index df50a8766f..85be1165d6 100644 --- a/cave/com.raytheon.viz.hydro/plugin.xml +++ b/cave/com.raytheon.viz.hydro/plugin.xml @@ -990,4 +990,11 @@ key="hydroTimeSeries"> + + + + diff --git a/cave/com.raytheon.viz.mpe.ui/plugin.xml b/cave/com.raytheon.viz.mpe.ui/plugin.xml index cee551b58d..e894623e47 100644 --- a/cave/com.raytheon.viz.mpe.ui/plugin.xml +++ b/cave/com.raytheon.viz.mpe.ui/plugin.xml @@ -1916,4 +1916,11 @@ key="autodqc"> + + + +