Issue #1996 remove tear offs from GFE by adding a field to enable by perspective

Change-Id: I92d0138637b95c86a8326878756c720a97586fb1

Former-commit-id: cb59b82add [formerly 7895dfa2e4 [formerly 7666c93bd833f935c6b1635adeb385c2fa4e04cc]]
Former-commit-id: 7895dfa2e4
Former-commit-id: 7d61737d79
This commit is contained in:
Matt Nash 2013-05-31 11:16:56 -05:00
parent 5d4ecc6328
commit aa13a1ed3a
7 changed files with 169 additions and 6 deletions

View file

@ -2170,4 +2170,11 @@
value="purge"> value="purge">
</path> </path>
</extension> </extension>
<extension
point="com.raytheon.uf.viz.ui.menus.tearoffperspective">
<tearoffperspective
enabled="true"
perspectiveId="com.raytheon.uf.viz.d2d.ui.perspectives.D2D5Pane">
</tearoffperspective>
</extension>
</plugin> </plugin>

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?> <?eclipse version="3.4"?>
<plugin> <plugin>
<extension-point id="tearoffperspective" name="tearoffperspective" schema="schema/tearoffperspective.exsd"/>
<extension <extension
point="com.raytheon.uf.viz.localization.localizationpath"> point="com.raytheon.uf.viz.localization.localizationpath">
<path <path

View file

@ -0,0 +1,106 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="com.raytheon.uf.viz.ui.menus" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="com.raytheon.uf.viz.ui.menus" id="com.raytheon.uf.viz.ui.menus.tearoff" name="tearoffperspective"/>
</appinfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<sequence>
<element ref="tearoffperspective"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="tearoffperspective">
<complexType>
<attribute name="perspectiveId" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="enabled" type="boolean" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>

View file

@ -23,6 +23,11 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; 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.Action;
import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.ContributionItem; 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;
import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.viz.ui.VizWorkbenchManager; 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 * 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"; 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 private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(TearOffMenuListener.class); .getHandler(TearOffMenuListener.class);
private static boolean enabled; private static boolean enabled;
private static List<String> enabledPerspectives;
static { static {
final IPreferenceStore store = com.raytheon.uf.viz.core.Activator final IPreferenceStore store = com.raytheon.uf.viz.core.Activator
.getDefault().getPreferenceStore(); .getDefault().getPreferenceStore();
enabled = store.getBoolean(TEAROFF_PREFERENCE_ID); enabled = store.getBoolean(TEAROFF_PREFERENCE_ID);
enabledPerspectives = new ArrayList<String>();
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() { store.addPropertyChangeListener(new IPropertyChangeListener() {
@Override @Override
public void propertyChange(PropertyChangeEvent event) { public void propertyChange(PropertyChangeEvent event) {
@ -149,9 +176,12 @@ public class TearOffMenuListener implements IMenuListener2 {
private Object getPerspectiveKey(IMenuManager manager) { private Object getPerspectiveKey(IMenuManager manager) {
String perspectiveId = ""; String perspectiveId = "";
try { try {
perspectiveId = VizWorkbenchManager.getInstance().getCurrentWindow().getActivePage().getPerspective().getId(); perspectiveId = VizWorkbenchManager.getInstance()
.getCurrentWindow().getActivePage().getPerspective()
.getId();
} catch (Exception e) { } 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); return perspectiveId + "::" + getKey(manager);
} }
@ -210,7 +240,13 @@ public class TearOffMenuListener implements IMenuListener2 {
*/ */
@Override @Override
public boolean isVisible() { 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;
} }
} }

View file

@ -30,7 +30,6 @@ import org.eclipse.ui.actions.CompoundContributionItem;
import org.eclipse.ui.menus.CommandContributionItem; import org.eclipse.ui.menus.CommandContributionItem;
import org.eclipse.ui.menus.CommandContributionItemParameter; 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.GFEPreference;
import com.raytheon.viz.gfe.core.DataManager; import com.raytheon.viz.gfe.core.DataManager;
import com.raytheon.viz.gfe.core.IReferenceSetManager; import com.raytheon.viz.gfe.core.IReferenceSetManager;
@ -81,7 +80,7 @@ public class GFEEditAreaMenu extends CompoundContributionItem {
MenuManager mm = new MenuManager(group); MenuManager mm = new MenuManager(group);
menuMgr.add(mm); menuMgr.add(mm);
mm.addMenuListener(new TearOffMenuListener(mm)); // mm.addMenuListener(new TearOffMenuListener(mm));
int count = 0; int count = 0;
for (String ref : refMgr.getGroupData(group)) { for (String ref : refMgr.getGroupData(group)) {
Map<String, String> parms = new HashMap<String, String>(); Map<String, String> parms = new HashMap<String, String>();

View file

@ -990,4 +990,11 @@
key="hydroTimeSeries"> key="hydroTimeSeries">
</component> </component>
</extension> </extension>
<extension
point="com.raytheon.uf.viz.ui.menus.tearoffperspective">
<tearoffperspective
enabled="true"
perspectiveId="com.raytheon.viz.hydro.HydroPerspective">
</tearoffperspective>
</extension>
</plugin> </plugin>

View file

@ -1916,4 +1916,11 @@
key="autodqc"> key="autodqc">
</component> </component>
</extension> </extension>
<extension
point="com.raytheon.uf.viz.ui.menus.tearoffperspective">
<tearoffperspective
enabled="true"
perspectiveId="com.raytheon.viz.mpe.ui.MPEPerspective">
</tearoffperspective>
</extension>
</plugin> </plugin>