Merge branch '10-Tech_Blocked' into 104-integration
Former-commit-id: d31ccf5832bf2b2ccfe29126deb4da80806c6739
This commit is contained in:
commit
f693b6d0a7
37 changed files with 1683 additions and 368 deletions
|
@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.ui,
|
||||||
org.apache.commons.lang;bundle-version="2.3.0",
|
org.apache.commons.lang;bundle-version="2.3.0",
|
||||||
com.raytheon.uf.common.pointdata;bundle-version="1.12.1174",
|
com.raytheon.uf.common.pointdata;bundle-version="1.12.1174",
|
||||||
com.raytheon.uf.viz.productbrowser;bundle-version="1.12.1152",
|
com.raytheon.uf.viz.productbrowser;bundle-version="1.12.1152",
|
||||||
com.raytheon.uf.viz.core.rsc;bundle-version="1.0.0"
|
com.raytheon.uf.viz.core.rsc;bundle-version="1.0.0",
|
||||||
|
com.raytheon.uf.viz.ui.menus;bundle-version="1.12.1174"
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Eclipse-RegisterBuddy: com.raytheon.uf.viz.core
|
Eclipse-RegisterBuddy: com.raytheon.uf.viz.core
|
||||||
|
|
|
@ -22,15 +22,15 @@ package com.raytheon.uf.viz.core.maps.menus;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.jface.action.IContributionItem;
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
import org.eclipse.jface.action.MenuManager;
|
import org.eclipse.jface.action.MenuManager;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
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.core.maps.MapStore;
|
import com.raytheon.uf.viz.core.maps.MapStore;
|
||||||
import com.raytheon.uf.viz.core.maps.MapStore.MapNode;
|
import com.raytheon.uf.viz.core.maps.MapStore.MapNode;
|
||||||
|
import com.raytheon.uf.viz.ui.menus.widgets.AbstractTearOffableCompoundContributionItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* TODO Add Description
|
||||||
|
@ -48,22 +48,32 @@ import com.raytheon.uf.viz.core.maps.MapStore.MapNode;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MapsMenu extends CompoundContributionItem {
|
public class MapsMenu extends AbstractTearOffableCompoundContributionItem {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param text
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
public MapsMenu() {
|
||||||
|
super("Maps", MapsMenu.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean addTear = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see
|
* @see com.raytheon.uf.viz.ui.menus.widgets.
|
||||||
* org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
|
* AbstractTearOffableCompoundContributionItem
|
||||||
|
* #addContributionItems(org.eclipse.jface.action.IMenuManager)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected IContributionItem[] getContributionItems() {
|
protected void addContributionItems(IMenuManager manager) {
|
||||||
MapNode node = MapStore.getMapTree();
|
MapNode node = MapStore.getMapTree();
|
||||||
return createMenu(node).getItems();
|
createMenu(manager, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MenuManager createMenu(MapNode root) {
|
private void createMenu(IMenuManager manager, MapNode root) {
|
||||||
MenuManager menuMgr = new MenuManager(root.getName());
|
|
||||||
for (MapNode node : root.getSubTree()) {
|
for (MapNode node : root.getSubTree()) {
|
||||||
if (node.getSubTree() == null) {
|
if (node.getSubTree() == null) {
|
||||||
Map<String, String> parms = new HashMap<String, String>();
|
Map<String, String> parms = new HashMap<String, String>();
|
||||||
|
@ -78,11 +88,13 @@ public class MapsMenu extends CompoundContributionItem {
|
||||||
parms, null, null, null, node.getName(), null,
|
parms, null, null, null, node.getName(), null,
|
||||||
null, CommandContributionItem.STYLE_CHECK,
|
null, CommandContributionItem.STYLE_CHECK,
|
||||||
null, true));
|
null, true));
|
||||||
menuMgr.add(item);
|
manager.add(item);
|
||||||
} else {
|
} else {
|
||||||
menuMgr.add(createMenu(node));
|
IMenuManager subMenu = new MenuManager(node.getName(),
|
||||||
|
manager.getId() + "." + node.getName());
|
||||||
|
createMenu(subMenu, node);
|
||||||
|
manager.add(subMenu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return menuMgr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
<httpServerAddress>http://localhost:9581/services</httpServerAddress>
|
<httpServerAddress>http://localhost:9581/services</httpServerAddress>
|
||||||
<dataDirectory>/awips2/edex/data/share</dataDirectory>
|
<dataDirectory>/awips2/edex/data/share</dataDirectory>
|
||||||
<textureCardPreference>512</textureCardPreference>
|
<textureCardPreference>512</textureCardPreference>
|
||||||
|
<tearoffmenus>true</tearoffmenus>
|
||||||
<framesPerSecondPreference>25</framesPerSecondPreference>
|
<framesPerSecondPreference>25</framesPerSecondPreference>
|
||||||
<tileBoundaries>false</tileBoundaries>
|
<tileBoundaries>false</tileBoundaries>
|
||||||
<fontMagnification>1.0</fontMagnification>
|
<fontMagnification>1.0</fontMagnification>
|
||||||
|
|
|
@ -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>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,12 @@ import org.eclipse.core.commands.AbstractHandler;
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.handlers.HandlerUtil;
|
|
||||||
|
|
||||||
import com.raytheon.uf.viz.core.IDisplayPane;
|
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||||
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||||
import com.raytheon.uf.viz.d2d.core.legend.D2DLegendResource;
|
import com.raytheon.uf.viz.d2d.core.legend.D2DLegendResource;
|
||||||
import com.raytheon.uf.viz.d2d.core.legend.D2DLegendResource.LegendMode;
|
import com.raytheon.uf.viz.d2d.core.legend.D2DLegendResource.LegendMode;
|
||||||
|
import com.raytheon.viz.ui.EditorUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* TODO Add Description
|
||||||
|
@ -68,8 +68,9 @@ public class ChangeLegendModeHandler extends AbstractHandler {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
IEditorPart part = HandlerUtil.getActiveEditor(event);
|
IEditorPart part = (IEditorPart) EditorUtil
|
||||||
if (part instanceof IDisplayPaneContainer) {
|
.getActiveEditorAs(IDisplayPaneContainer.class);
|
||||||
|
if (part != null) {
|
||||||
IDisplayPane[] panes = ((IDisplayPaneContainer) part)
|
IDisplayPane[] panes = ((IDisplayPaneContainer) part)
|
||||||
.getDisplayPanes();
|
.getDisplayPanes();
|
||||||
for (IDisplayPane pane : panes) {
|
for (IDisplayPane pane : panes) {
|
||||||
|
|
|
@ -34,4 +34,5 @@ Import-Package: com.raytheon.edex.scriptfactory,
|
||||||
com.raytheon.uf.viz.core.status
|
com.raytheon.uf.viz.core.status
|
||||||
Export-Package: com.raytheon.uf.viz.ui.menus,
|
Export-Package: com.raytheon.uf.viz.ui.menus,
|
||||||
com.raytheon.uf.viz.ui.menus.widgets,
|
com.raytheon.uf.viz.ui.menus.widgets,
|
||||||
|
com.raytheon.uf.viz.ui.menus.widgets.tearoff,
|
||||||
com.raytheon.uf.viz.ui.menus.xml
|
com.raytheon.uf.viz.ui.menus.xml
|
||||||
|
|
|
@ -12,4 +12,11 @@
|
||||||
extensionFilter=".xml">
|
extensionFilter=".xml">
|
||||||
</path>
|
</path>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.preferencePages">
|
||||||
|
<page
|
||||||
|
class="com.raytheon.uf.viz.ui.menus.widgets.tearoff.TearOffPreferencePage"
|
||||||
|
id="com.raytheon.uf.viz.ui.menus.tearoffpreferencepage"
|
||||||
|
name="Tear-Off Menus"/>
|
||||||
|
</extension>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.viz.ui.menus.widgets;
|
||||||
|
|
||||||
|
import org.eclipse.jface.action.IContributionItem;
|
||||||
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
|
import org.eclipse.jface.action.MenuManager;
|
||||||
|
import org.eclipse.ui.actions.CompoundContributionItem;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.ui.menus.widgets.tearoff.TearOffMenuListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO Add Description
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Feb 6, 2012 mschenke Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author mschenke
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public abstract class AbstractTearOffableCompoundContributionItem extends
|
||||||
|
CompoundContributionItem {
|
||||||
|
|
||||||
|
private String text;
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private TearOffMenuListener listener;
|
||||||
|
|
||||||
|
protected AbstractTearOffableCompoundContributionItem(String text, String id) {
|
||||||
|
this.text = text;
|
||||||
|
this.id = id;
|
||||||
|
listener = new TearOffMenuListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected final IContributionItem[] getContributionItems() {
|
||||||
|
IMenuManager manager = new MenuManager(text, id);
|
||||||
|
addContributionItems(manager);
|
||||||
|
IContributionItem[] items = manager.getItems();
|
||||||
|
TearOffMenuListener.register(items, listener);
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal method for retrieving contribution items to add to the menu.
|
||||||
|
*
|
||||||
|
* @param manager
|
||||||
|
*/
|
||||||
|
protected abstract void addContributionItems(IMenuManager manager);
|
||||||
|
}
|
|
@ -215,6 +215,12 @@ public class BundleContributionItem extends ContributionItem {
|
||||||
|
|
||||||
if (!performQuery) {
|
if (!performQuery) {
|
||||||
widget.setText(menuText);
|
widget.setText(menuText);
|
||||||
|
|
||||||
|
// notify things of menu update times
|
||||||
|
Event event = new Event();
|
||||||
|
event.data = widget;
|
||||||
|
event.widget = widget;
|
||||||
|
widget.notifyListeners(SWT.Modify, event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,6 +249,12 @@ public class BundleContributionItem extends ContributionItem {
|
||||||
String labelStr = this.menuText + " \t" + dateStr;
|
String labelStr = this.menuText + " \t" + dateStr;
|
||||||
|
|
||||||
widget.setText(labelStr);
|
widget.setText(labelStr);
|
||||||
|
|
||||||
|
// notify things of menu update times
|
||||||
|
Event event = new Event();
|
||||||
|
event.data = widget;
|
||||||
|
event.widget = widget;
|
||||||
|
widget.notifyListeners(SWT.Modify, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateTime(DataTime time, BinOffset offset) {
|
protected void updateTime(DataTime time, BinOffset offset) {
|
||||||
|
@ -282,6 +294,7 @@ public class BundleContributionItem extends ContributionItem {
|
||||||
private Listener getItemListener() {
|
private Listener getItemListener() {
|
||||||
if (menuItemListener == null) {
|
if (menuItemListener == null) {
|
||||||
menuItemListener = new Listener() {
|
menuItemListener = new Listener() {
|
||||||
|
@Override
|
||||||
public void handleEvent(Event event) {
|
public void handleEvent(Event event) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SWT.Dispose:
|
case SWT.Dispose:
|
||||||
|
@ -405,6 +418,7 @@ public class BundleContributionItem extends ContributionItem {
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void updateTime(DataTime time) {
|
public void updateTime(DataTime time) {
|
||||||
BundleContributionItem.this.updateTime(time, offset);
|
BundleContributionItem.this.updateTime(time, offset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,142 +0,0 @@
|
||||||
/**
|
|
||||||
* This software was developed and / or modified by Raytheon Company,
|
|
||||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
|
||||||
*
|
|
||||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
|
||||||
* This software product contains export-restricted data whose
|
|
||||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
|
||||||
* to non-U.S. persons whether in the United States or abroad requires
|
|
||||||
* an export license or other authorization.
|
|
||||||
*
|
|
||||||
* Contractor Name: Raytheon Company
|
|
||||||
* Contractor Address: 6825 Pine Street, Suite 340
|
|
||||||
* Mail Stop B8
|
|
||||||
* Omaha, NE 68106
|
|
||||||
* 402.291.0100
|
|
||||||
*
|
|
||||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
|
||||||
* further licensing information.
|
|
||||||
**/
|
|
||||||
package com.raytheon.uf.viz.ui.menus.widgets;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.eclipse.jface.action.ContributionItem;
|
|
||||||
import org.eclipse.jface.action.IContributionItem;
|
|
||||||
import org.eclipse.swt.widgets.Menu;
|
|
||||||
import org.eclipse.swt.widgets.ToolBar;
|
|
||||||
|
|
||||||
import com.raytheon.uf.common.menus.xml.CommonAbstractMenuContribution;
|
|
||||||
import com.raytheon.uf.common.menus.xml.VariableSubstitution;
|
|
||||||
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.uf.viz.core.exception.VizException;
|
|
||||||
import com.raytheon.uf.viz.ui.menus.xml.IncludeMenuItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Waits to load included files until the menu is filled.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
*
|
|
||||||
* SOFTWARE HISTORY
|
|
||||||
*
|
|
||||||
* Date Ticket# Engineer Description
|
|
||||||
* ------------ ---------- ----------- --------------------------
|
|
||||||
* Sep 13, 2011 bsteffen Initial creation
|
|
||||||
*
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author bsteffen
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
public class IncludeContributionItem extends ContributionItem {
|
|
||||||
static final transient IUFStatusHandler statusHandler = UFStatus
|
|
||||||
.getHandler(IncludeContributionItem.class);
|
|
||||||
|
|
||||||
private final IncludeMenuItem imc;
|
|
||||||
|
|
||||||
private final CommonAbstractMenuContribution contribs;
|
|
||||||
|
|
||||||
private final VariableSubstitution[] incomingSubs;
|
|
||||||
|
|
||||||
private final Set<String> removalsIn;
|
|
||||||
|
|
||||||
private IContributionItem[] items = null;
|
|
||||||
|
|
||||||
public IncludeContributionItem(IncludeMenuItem imc,
|
|
||||||
CommonAbstractMenuContribution contribs,
|
|
||||||
VariableSubstitution[] incomingSubs, Set<String> removalsIn) {
|
|
||||||
super();
|
|
||||||
this.imc = imc;
|
|
||||||
this.contribs = contribs;
|
|
||||||
this.incomingSubs = incomingSubs;
|
|
||||||
this.removalsIn = removalsIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized IContributionItem[] getContributionItems() {
|
|
||||||
if (items == null) {
|
|
||||||
try {
|
|
||||||
items = imc.getAllContributionItems(contribs, incomingSubs,
|
|
||||||
removalsIn);
|
|
||||||
} catch (VizException e) {
|
|
||||||
statusHandler.handle(Priority.SIGNIFICANT,
|
|
||||||
"Error setting up menus", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void fill(Menu menu, int index) {
|
|
||||||
getContributionItems();
|
|
||||||
if (index == -1) {
|
|
||||||
index = menu.getItemCount();
|
|
||||||
}
|
|
||||||
IContributionItem[] items = getContributionItems();
|
|
||||||
for (int i = 0; i < items.length; i++) {
|
|
||||||
IContributionItem item = items[i];
|
|
||||||
int oldItemCount = menu.getItemCount();
|
|
||||||
if (item.isVisible()) {
|
|
||||||
item.fill(menu, index);
|
|
||||||
}
|
|
||||||
int newItemCount = menu.getItemCount();
|
|
||||||
int numAdded = newItemCount - oldItemCount;
|
|
||||||
index += numAdded;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void fill(ToolBar toolbar, int index) {
|
|
||||||
getContributionItems();
|
|
||||||
if (index == -1) {
|
|
||||||
index = toolbar.getItemCount();
|
|
||||||
}
|
|
||||||
IContributionItem[] items = getContributionItems();
|
|
||||||
for (int i = 0; i < items.length; i++) {
|
|
||||||
IContributionItem item = items[i];
|
|
||||||
int oldItemCount = toolbar.getItemCount();
|
|
||||||
if (item.isVisible()) {
|
|
||||||
item.fill(toolbar, index);
|
|
||||||
}
|
|
||||||
int newItemCount = toolbar.getItemCount();
|
|
||||||
int numAdded = newItemCount - oldItemCount;
|
|
||||||
index += numAdded;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isDynamic() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
if (items != null) {
|
|
||||||
for (IContributionItem item : items) {
|
|
||||||
item.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -22,13 +22,9 @@ package com.raytheon.uf.viz.ui.menus.widgets;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.jface.action.ContributionItem;
|
|
||||||
import org.eclipse.jface.action.IContributionItem;
|
import org.eclipse.jface.action.IContributionItem;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.jface.action.MenuManager;
|
||||||
import org.eclipse.swt.events.MenuEvent;
|
|
||||||
import org.eclipse.swt.events.MenuListener;
|
|
||||||
import org.eclipse.swt.widgets.Menu;
|
import org.eclipse.swt.widgets.Menu;
|
||||||
import org.eclipse.swt.widgets.MenuItem;
|
|
||||||
|
|
||||||
import com.raytheon.uf.common.menus.xml.CommonAbstractMenuContribution;
|
import com.raytheon.uf.common.menus.xml.CommonAbstractMenuContribution;
|
||||||
import com.raytheon.uf.common.menus.xml.VariableSubstitution;
|
import com.raytheon.uf.common.menus.xml.VariableSubstitution;
|
||||||
|
@ -57,7 +53,7 @@ import com.raytheon.uf.viz.ui.menus.xml.MenuXMLMap;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SubmenuContributionItem extends ContributionItem {
|
public class SubmenuContributionItem extends MenuManager {
|
||||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
.getHandler(SubmenuContributionItem.class);
|
.getHandler(SubmenuContributionItem.class);
|
||||||
|
|
||||||
|
@ -66,88 +62,48 @@ public class SubmenuContributionItem extends ContributionItem {
|
||||||
|
|
||||||
private CommonAbstractMenuContribution[] contribs;
|
private CommonAbstractMenuContribution[] contribs;
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
private MenuItem widget;
|
|
||||||
|
|
||||||
protected Menu menu;
|
|
||||||
|
|
||||||
protected VariableSubstitution[] subs;
|
protected VariableSubstitution[] subs;
|
||||||
|
|
||||||
protected IContributionItem[][] contributionItems;
|
protected IContributionItem[][] contributionItems;
|
||||||
|
|
||||||
protected Set<String> removals;
|
protected Set<String> removals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param includeSubstitutions
|
||||||
|
* @param name
|
||||||
|
* @param ci
|
||||||
|
* @param removals
|
||||||
|
* @param mListener
|
||||||
|
*/
|
||||||
public SubmenuContributionItem(VariableSubstitution[] includeSubstitutions,
|
public SubmenuContributionItem(VariableSubstitution[] includeSubstitutions,
|
||||||
String name, CommonAbstractMenuContribution[] ci,
|
String name, CommonAbstractMenuContribution[] ci,
|
||||||
Set<String> removals) {
|
Set<String> removals) {
|
||||||
super();
|
super(processNameSubstitution(includeSubstitutions, name));
|
||||||
this.subs = includeSubstitutions;
|
this.subs = includeSubstitutions;
|
||||||
this.contribs = ci;
|
this.contribs = ci;
|
||||||
this.removals = removals;
|
this.removals = removals;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String processNameSubstitution(
|
||||||
|
VariableSubstitution[] includeSubstitutions, String name) {
|
||||||
if (includeSubstitutions != null && includeSubstitutions.length > 0) {
|
if (includeSubstitutions != null && includeSubstitutions.length > 0) {
|
||||||
Map<String, String> map = VariableSubstitution
|
Map<String, String> map = VariableSubstitution
|
||||||
.toMap(includeSubstitutions);
|
.toMap(includeSubstitutions);
|
||||||
try {
|
try {
|
||||||
this.name = VariableSubstitutionUtil
|
name = VariableSubstitutionUtil.processVariables(name, map);
|
||||||
.processVariables(name, map);
|
|
||||||
} catch (VizException e) {
|
} catch (VizException e) {
|
||||||
this.name = name;
|
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
"Error during menu substitution", e);
|
"Error during menu substitution", e);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.name = name;
|
|
||||||
}
|
}
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fill(Menu parent, int index) {
|
public void fill(Menu parent, int index) {
|
||||||
|
removeAll();
|
||||||
if (widget != null && widget.isDisposed()) {
|
super.fill(parent, index);
|
||||||
widget = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (widget != null || parent == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MenuItem item = null;
|
|
||||||
if (index >= 0) {
|
|
||||||
item = new MenuItem(parent, SWT.CASCADE, index);
|
|
||||||
} else {
|
|
||||||
item = new MenuItem(parent, SWT.CASCADE);
|
|
||||||
}
|
|
||||||
|
|
||||||
item.setData(this);
|
|
||||||
|
|
||||||
item.setText(this.name);
|
|
||||||
|
|
||||||
widget = item;
|
|
||||||
|
|
||||||
createMenu();
|
|
||||||
|
|
||||||
update(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createMenu() {
|
|
||||||
menu = new Menu(widget.getParent().getShell(), SWT.DROP_DOWN);
|
|
||||||
menu.addMenuListener(new MenuListener() {
|
|
||||||
@Override
|
|
||||||
public void menuHidden(MenuEvent e) {
|
|
||||||
// should Menu Items be disposed here?
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void menuShown(MenuEvent e) {
|
|
||||||
fillMenu();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
widget.setMenu(menu);
|
|
||||||
|
|
||||||
getContributionItemsJob.schedule(new GetContributionItemsRunnable());
|
getContributionItemsJob.schedule(new GetContributionItemsRunnable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,30 +128,9 @@ public class SubmenuContributionItem extends ContributionItem {
|
||||||
return this.contributionItems;
|
return this.contributionItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillMenu() {
|
|
||||||
getContributionItems();
|
|
||||||
if (this.menu.getItemCount() == 0) {
|
|
||||||
for (int i = 0; i < this.contributionItems.length; i++) {
|
|
||||||
for (IContributionItem item : this.contributionItems[i]) {
|
|
||||||
if (item.isVisible()) {
|
|
||||||
item.fill(this.menu, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.jface.action.ContributionItem#dispose()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public boolean isVisible() {
|
||||||
super.dispose();
|
return visible;
|
||||||
if (this.menu != null && !this.menu.isDisposed()) {
|
|
||||||
this.menu.dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// call getContributionItems using the getContributionItems JobPool.
|
// call getContributionItems using the getContributionItems JobPool.
|
||||||
|
@ -204,7 +139,11 @@ public class SubmenuContributionItem extends ContributionItem {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
getContributionItems();
|
getContributionItems();
|
||||||
|
for (int i = 0; i < contributionItems.length; i++) {
|
||||||
|
for (IContributionItem item : contributionItems[i]) {
|
||||||
|
add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,555 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.viz.ui.menus.widgets.tearoff;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.MenuEvent;
|
||||||
|
import org.eclipse.swt.events.MenuListener;
|
||||||
|
import org.eclipse.swt.events.MouseAdapter;
|
||||||
|
import org.eclipse.swt.events.MouseEvent;
|
||||||
|
import org.eclipse.swt.events.MouseTrackAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.events.SelectionListener;
|
||||||
|
import org.eclipse.swt.graphics.Color;
|
||||||
|
import org.eclipse.swt.graphics.GC;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.Event;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Listener;
|
||||||
|
import org.eclipse.swt.widgets.Menu;
|
||||||
|
import org.eclipse.swt.widgets.MenuItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds the information for all the menu items in the dialog
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Sep 15, 2011 mnash Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author mnash
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class MenuItemComposite extends Composite implements MenuListener {
|
||||||
|
|
||||||
|
private boolean separator = false;
|
||||||
|
|
||||||
|
private Control firstItem;
|
||||||
|
|
||||||
|
private Control secondItem;
|
||||||
|
|
||||||
|
// backing data for executing listeners
|
||||||
|
private MenuItem item;
|
||||||
|
|
||||||
|
private Image arrow = null;
|
||||||
|
|
||||||
|
private Image highlightedArrow = null;
|
||||||
|
|
||||||
|
private Listener updateListener = null;
|
||||||
|
|
||||||
|
private SelectionListener radioListener = null;
|
||||||
|
|
||||||
|
private List<String> myPath;
|
||||||
|
|
||||||
|
private Menu topMostParent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param parent
|
||||||
|
* @param style
|
||||||
|
*/
|
||||||
|
public MenuItemComposite(Composite parent, int style) {
|
||||||
|
super(parent, style);
|
||||||
|
}
|
||||||
|
|
||||||
|
// creates both labels and ties them together
|
||||||
|
public void addLabels(MenuItem it, int labelStyle) {
|
||||||
|
if (it.isDisposed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
myPath = new ArrayList<String>();
|
||||||
|
|
||||||
|
// Build the menu path to the MenuItem from highest menu level
|
||||||
|
Menu parent = it.getParent();
|
||||||
|
MenuItem toAdd = it;
|
||||||
|
do {
|
||||||
|
myPath.add(toAdd.getText());
|
||||||
|
toAdd = parent.getParentItem();
|
||||||
|
topMostParent = parent;
|
||||||
|
parent = parent.getParentMenu();
|
||||||
|
} while (parent.getParentMenu() != null);
|
||||||
|
|
||||||
|
Collections.reverse(myPath);
|
||||||
|
|
||||||
|
topMostParent.addMenuListener(this);
|
||||||
|
item = it;
|
||||||
|
|
||||||
|
String[] labels = item.getText().split("\t");
|
||||||
|
// handle for a separator menu item
|
||||||
|
if (item.getStyle() == SWT.SEPARATOR) {
|
||||||
|
separator = true;
|
||||||
|
firstItem = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
|
||||||
|
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
gd.horizontalSpan = 2;
|
||||||
|
firstItem.setLayoutData(gd);
|
||||||
|
} else {
|
||||||
|
// radio items
|
||||||
|
if (item.getStyle() == SWT.RADIO) {
|
||||||
|
firstItem = new Button(this, SWT.RADIO);
|
||||||
|
((Button) firstItem).setSelection(item.getSelection());
|
||||||
|
GridData gd = new GridData(18, 18);
|
||||||
|
firstItem.setLayoutData(gd);
|
||||||
|
|
||||||
|
secondItem = new Label(this, labelStyle);
|
||||||
|
((Label) secondItem).setText(labels[0]);
|
||||||
|
gd = new GridData(SWT.LEFT, SWT.CENTER, true, true);
|
||||||
|
secondItem.setLayoutData(gd);
|
||||||
|
createRadioListener();
|
||||||
|
} else if (item.getStyle() == SWT.CASCADE) {
|
||||||
|
firstItem = new Label(this, SWT.PUSH);
|
||||||
|
firstItem.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT,
|
||||||
|
true, false));
|
||||||
|
((Label) firstItem).setText(labels[0]);
|
||||||
|
secondItem = new Label(this, labelStyle);
|
||||||
|
createArrow();
|
||||||
|
((Label) secondItem).setImage(arrow);
|
||||||
|
}
|
||||||
|
// regular selectable menu items
|
||||||
|
else {
|
||||||
|
firstItem = new Label(this, labelStyle);
|
||||||
|
firstItem.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT,
|
||||||
|
true, false));
|
||||||
|
((Label) firstItem).setText(labels[0]);
|
||||||
|
|
||||||
|
secondItem = new Label(this, labelStyle);
|
||||||
|
if (labels.length > 1) {
|
||||||
|
((Label) secondItem).setText(labels[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create and add text update listener
|
||||||
|
createUpdateListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.isEnabled()) {
|
||||||
|
// add the listeners to both the first and the second
|
||||||
|
// control, so the same thing happens if you scroll over either,
|
||||||
|
// or the MenuItemComposite
|
||||||
|
MouseTrackAdapter mouseTrackAdapter = getMouseTrackAdapter();
|
||||||
|
firstItem.addMouseTrackListener(mouseTrackAdapter);
|
||||||
|
secondItem.addMouseTrackListener(mouseTrackAdapter);
|
||||||
|
this.addMouseTrackListener(mouseTrackAdapter);
|
||||||
|
|
||||||
|
MouseAdapter mouseAdapter = getMouseAdapter();
|
||||||
|
firstItem.addMouseListener(mouseAdapter);
|
||||||
|
secondItem.addMouseListener(mouseAdapter);
|
||||||
|
this.addMouseListener(mouseAdapter);
|
||||||
|
} else {
|
||||||
|
setForeground(Display.getCurrent().getSystemColor(
|
||||||
|
SWT.COLOR_DARK_GRAY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addItemListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void addItemListeners() {
|
||||||
|
if (updateListener != null) {
|
||||||
|
item.addListener(SWT.Modify, updateListener);
|
||||||
|
}
|
||||||
|
if (radioListener != null) {
|
||||||
|
item.addSelectionListener(radioListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void createRadioListener() {
|
||||||
|
radioListener = new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
if (e.widget instanceof MenuItem) {
|
||||||
|
// check that the radio groups match
|
||||||
|
for (Control comp : firstItem.getParent().getParent()
|
||||||
|
.getChildren()) {
|
||||||
|
MenuItemComposite composite = (MenuItemComposite) comp;
|
||||||
|
if (composite.item.getText().equals(
|
||||||
|
((MenuItem) e.widget).getText())) {
|
||||||
|
if (composite.firstItem instanceof Button) {
|
||||||
|
((Button) composite.firstItem)
|
||||||
|
.setSelection(composite.item
|
||||||
|
.getSelection());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (composite.firstItem instanceof Button) {
|
||||||
|
((Button) composite.firstItem)
|
||||||
|
.setSelection(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void createUpdateListener() {
|
||||||
|
updateListener = new Listener() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(Event event) {
|
||||||
|
if (secondItem != null && !secondItem.isDisposed()) {
|
||||||
|
if (item == event.data) {
|
||||||
|
if (((MenuItem) event.data).getText().split("\t").length > 1) {
|
||||||
|
((Label) secondItem)
|
||||||
|
.setText(((MenuItem) event.data).getText()
|
||||||
|
.split("\t")[1]);
|
||||||
|
// don't want to make the times go off the
|
||||||
|
// screen
|
||||||
|
layout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the background on all the visible items
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setBackground(Color color) {
|
||||||
|
firstItem.setBackground(color);
|
||||||
|
secondItem.setBackground(color);
|
||||||
|
super.setBackground(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the foreground on all the visible items to the necessary color
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setForeground(Color color) {
|
||||||
|
firstItem.setForeground(color);
|
||||||
|
secondItem.setForeground(color);
|
||||||
|
super.setForeground(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the arrows for submenus
|
||||||
|
*/
|
||||||
|
private void createArrow() {
|
||||||
|
int imgWidth = 11;
|
||||||
|
int imgHeight = 11;
|
||||||
|
|
||||||
|
arrow = new Image(Display.getCurrent(), imgWidth, imgHeight);
|
||||||
|
highlightedArrow = new Image(Display.getCurrent(), imgWidth, imgHeight);
|
||||||
|
|
||||||
|
// the normal arrow
|
||||||
|
GC gc = new GC(arrow);
|
||||||
|
drawArrowImage(gc, imgWidth, imgHeight, SWT.COLOR_WIDGET_BACKGROUND,
|
||||||
|
SWT.COLOR_BLACK);
|
||||||
|
|
||||||
|
// the highlighted arrow
|
||||||
|
gc = new GC(highlightedArrow);
|
||||||
|
drawArrowImage(gc, imgWidth, imgHeight, SWT.COLOR_LIST_SELECTION,
|
||||||
|
SWT.COLOR_WHITE);
|
||||||
|
|
||||||
|
gc.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the arrow image.
|
||||||
|
*
|
||||||
|
* @param gc
|
||||||
|
* Graphic context.
|
||||||
|
* @param imgWidth
|
||||||
|
* Image width.
|
||||||
|
* @param imgHeight
|
||||||
|
* Image height.
|
||||||
|
*/
|
||||||
|
private void drawArrowImage(GC gc, int imgWidth, int imgHeight,
|
||||||
|
int highlightColor, int arrowColor) {
|
||||||
|
gc.setAntialias(SWT.ON);
|
||||||
|
|
||||||
|
// "Erase" the canvas by filling it in with a white rectangle.
|
||||||
|
gc.setBackground(Display.getCurrent().getSystemColor(highlightColor));
|
||||||
|
|
||||||
|
gc.fillRectangle(0, 0, imgWidth, imgHeight);
|
||||||
|
|
||||||
|
gc.setBackground(Display.getCurrent().getSystemColor(arrowColor));
|
||||||
|
|
||||||
|
int[] polyArray = new int[] { 2, 0, 8, 4, 2, 8 };
|
||||||
|
|
||||||
|
gc.fillPolygon(polyArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createSubMenu(MenuItem item, int y) {
|
||||||
|
PopupMenu men = new PopupMenu();
|
||||||
|
men.addSubmenus(item, this.getShell(), y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Highlight the areas of the composite so that we get the "look" of the
|
||||||
|
* whole thing being highlighted
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private MouseTrackAdapter getMouseTrackAdapter() {
|
||||||
|
MouseTrackAdapter trackAdapter = new MouseTrackAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseEnter(MouseEvent e) {
|
||||||
|
// we want all the colors to be the same for background
|
||||||
|
// and foreground, so we set that here, this is to tell
|
||||||
|
// the whole thing to be highlighted
|
||||||
|
setBackground(Display.getCurrent().getSystemColor(
|
||||||
|
SWT.COLOR_LIST_SELECTION));
|
||||||
|
setForeground(Display.getCurrent().getSystemColor(
|
||||||
|
SWT.COLOR_LIST_SELECTION_TEXT));
|
||||||
|
// changes the arrow image to the highlighted version
|
||||||
|
if (secondItem instanceof Label) {
|
||||||
|
if (((Label) secondItem).getImage() != null) {
|
||||||
|
((Label) secondItem).setImage(highlightedArrow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseExit(MouseEvent e) {
|
||||||
|
// we want all the colors to be the same for background
|
||||||
|
// and foreground, so we set that here, this is to
|
||||||
|
// unhighlight the whole thing
|
||||||
|
setBackground(Display.getCurrent().getSystemColor(
|
||||||
|
SWT.COLOR_WIDGET_BACKGROUND));
|
||||||
|
setForeground(Display.getCurrent().getSystemColor(
|
||||||
|
SWT.COLOR_WIDGET_FOREGROUND));
|
||||||
|
// changes the arrow image to the unhighlighted version
|
||||||
|
if (secondItem instanceof Label) {
|
||||||
|
if (((Label) secondItem).getImage() != null) {
|
||||||
|
((Label) secondItem).setImage(arrow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return trackAdapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select on either item being selected, so that we get the same action for
|
||||||
|
* both being selected
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private MouseAdapter getMouseAdapter() {
|
||||||
|
MouseAdapter mouseAdapter = new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseDown(MouseEvent e) {
|
||||||
|
if (item.getMenu() != null) {
|
||||||
|
// This is item opens a submenu, get the y offset based on
|
||||||
|
// the location of the click
|
||||||
|
int y = 0;
|
||||||
|
if (e.widget instanceof MenuItemComposite) {
|
||||||
|
y = ((Control) e.widget).getLocation().y;
|
||||||
|
} else {
|
||||||
|
y = ((Control) e.widget).getParent().getLocation().y;
|
||||||
|
}
|
||||||
|
createSubMenu(item, y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle the selection event, so if it is able to load
|
||||||
|
// something, do it (by looping over ALL the selection
|
||||||
|
// listeners assigned to the item)
|
||||||
|
for (Listener list : item.getListeners(SWT.Selection)) {
|
||||||
|
Event event = new Event();
|
||||||
|
event.type = SWT.Selection;
|
||||||
|
event.widget = item;
|
||||||
|
list.handleEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDisposed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// handles the check boxes, if clicking the check box
|
||||||
|
// need to not do this (because SWT does it already)
|
||||||
|
// otherwise do it
|
||||||
|
if (firstItem instanceof Button
|
||||||
|
&& firstItem.getStyle() == SWT.CHECK) {
|
||||||
|
if (e.widget != firstItem) {
|
||||||
|
((Button) firstItem).setSelection(!((Button) firstItem)
|
||||||
|
.getSelection());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle radio selection changing...
|
||||||
|
Control[] siblings = getParent().getChildren();
|
||||||
|
for (int i = 0; i < siblings.length; i++) {
|
||||||
|
final MenuItemComposite mic = (MenuItemComposite) siblings[i];
|
||||||
|
if (mic.separator == false
|
||||||
|
&& mic.item.getStyle() == SWT.RADIO) {
|
||||||
|
try {
|
||||||
|
MenuItemComposite parent = null;
|
||||||
|
// check whether a Label is clicked or a
|
||||||
|
// MenuItemComposite
|
||||||
|
if (e.widget instanceof MenuItemComposite) {
|
||||||
|
parent = (MenuItemComposite) e.widget;
|
||||||
|
} else {
|
||||||
|
parent = (MenuItemComposite) ((Control) e.widget)
|
||||||
|
.getParent();
|
||||||
|
}
|
||||||
|
// check that the radio groups match
|
||||||
|
if (mic.getData("radioGroup").equals(
|
||||||
|
parent.getData("radioGroup"))) {
|
||||||
|
if (!parent.item
|
||||||
|
.getText()
|
||||||
|
.replaceAll("&", "")
|
||||||
|
.equals(mic.item.getText().replaceAll(
|
||||||
|
"&", ""))) {
|
||||||
|
mic.item.setSelection(false);
|
||||||
|
((Button) mic.firstItem)
|
||||||
|
.setSelection(false);
|
||||||
|
} else {
|
||||||
|
mic.item.setSelection(true);
|
||||||
|
((Button) mic.firstItem).setSelection(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (NullPointerException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return mouseAdapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
if (arrow != null) {
|
||||||
|
arrow.dispose();
|
||||||
|
}
|
||||||
|
if (highlightedArrow != null) {
|
||||||
|
highlightedArrow.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item != null) {
|
||||||
|
if (updateListener != null && !item.isDisposed()) {
|
||||||
|
item.removeListener(SWT.Modify, updateListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (radioListener != null && !item.isDisposed()) {
|
||||||
|
item.removeSelectionListener(radioListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (topMostParent != null) {
|
||||||
|
topMostParent.removeMenuListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelection(boolean selection) {
|
||||||
|
if (firstItem instanceof Button) {
|
||||||
|
((Button) firstItem).setSelection(selection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* org.eclipse.swt.events.MenuListener#menuHidden(org.eclipse.swt.events
|
||||||
|
* .MenuEvent)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void menuHidden(MenuEvent e) {
|
||||||
|
if (item.isDisposed() == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// At some point we may need to check against the index as well but that
|
||||||
|
// is difficult because we don't know if the tear off menu item will/was
|
||||||
|
// in the menu when we were created/now so our index could be off by one
|
||||||
|
// very easily making it unreliable
|
||||||
|
Menu menu = topMostParent;
|
||||||
|
MenuItem myItem = null;
|
||||||
|
String last = myPath.get(myPath.size() - 1);
|
||||||
|
for (String path : myPath) {
|
||||||
|
if (menu != null) {
|
||||||
|
MenuItem[] items = menu.getItems();
|
||||||
|
for (int i = 0; i < items.length; ++i) {
|
||||||
|
MenuItem item = items[i];
|
||||||
|
if (path.equals(item.getText())) {
|
||||||
|
if (path == last) {
|
||||||
|
myItem = item;
|
||||||
|
} else {
|
||||||
|
menu = item.getMenu();
|
||||||
|
|
||||||
|
if (menu != null && menu.getItemCount() == 0) {
|
||||||
|
// Have to manually fill menu
|
||||||
|
for (Listener listener : menu
|
||||||
|
.getListeners(SWT.Show)) {
|
||||||
|
Event event = new Event();
|
||||||
|
event.type = SWT.Show;
|
||||||
|
event.widget = menu;
|
||||||
|
listener.handleEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (myItem != null && myItem.isDisposed() == false) {
|
||||||
|
item = myItem;
|
||||||
|
addItemListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* org.eclipse.swt.events.MenuListener#menuShown(org.eclipse.swt.events.
|
||||||
|
* MenuEvent)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void menuShown(MenuEvent e) {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,230 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.viz.ui.menus.widgets.tearoff;
|
||||||
|
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.MenuAdapter;
|
||||||
|
import org.eclipse.swt.events.MenuEvent;
|
||||||
|
import org.eclipse.swt.widgets.Event;
|
||||||
|
import org.eclipse.swt.widgets.Listener;
|
||||||
|
import org.eclipse.swt.widgets.Menu;
|
||||||
|
import org.eclipse.swt.widgets.MenuItem;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import com.raytheon.viz.ui.EditorUtil;
|
||||||
|
import com.raytheon.viz.ui.editor.AbstractEditor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The popup menu for when items are populated out of the TearOffMenuDialog
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Dec 5, 2011 mnash Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author mnash
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class PopupMenu {
|
||||||
|
|
||||||
|
Listener selectionListener = null;
|
||||||
|
|
||||||
|
Listener updateListener = null;
|
||||||
|
|
||||||
|
Listener showListener = null;
|
||||||
|
|
||||||
|
public PopupMenu() {
|
||||||
|
// default constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void buildMenu(final MenuItem item, final Shell shell,
|
||||||
|
final Menu menu) {
|
||||||
|
String longest = "";
|
||||||
|
for (final MenuItem menItem : item.getMenu().getItems()) {
|
||||||
|
// building a new menu item that does what we want it to do, but
|
||||||
|
// very similar to the original item in the menu
|
||||||
|
final MenuItem mItem = new MenuItem(menu, menItem.getStyle());
|
||||||
|
mItem.setText(menItem.getText());
|
||||||
|
|
||||||
|
// check for length
|
||||||
|
if (mItem.getText().length() > longest.length()) {
|
||||||
|
longest = mItem.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
mItem.setEnabled(menItem.getEnabled());
|
||||||
|
mItem.setSelection(menItem.getSelection());
|
||||||
|
// still going to have the menItem TODO need to update if the
|
||||||
|
// MenuItems are disposed
|
||||||
|
mItem.setData(menItem);
|
||||||
|
|
||||||
|
// adding all the selection listeners from the menu
|
||||||
|
for (Listener list : menItem.getListeners(SWT.Selection)) {
|
||||||
|
mItem.addListener(SWT.Selection, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
mItem.addListener(SWT.Selection, new Listener() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(Event event) {
|
||||||
|
((AbstractEditor) EditorUtil.getActiveEditor()).refresh();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// a show listener, so when the menu is shown (in cave) it updates
|
||||||
|
// the time in the tear off submenu
|
||||||
|
// this tries to update all the times when the menu is opened
|
||||||
|
showListener = new Listener() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(Event event) {
|
||||||
|
if (!mItem.isDisposed()) {
|
||||||
|
if (mItem.getData() == event.data) {
|
||||||
|
mItem.setText(((MenuItem) event.data).getText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
menItem.getParent().addListener(SWT.Show, showListener);
|
||||||
|
|
||||||
|
// modify listener gets fired from BundleContributionItem if the
|
||||||
|
// times are updated, so we listen for that here so that item times
|
||||||
|
// can get updated, in the submenus
|
||||||
|
// this does the periodic updating of the menus through the
|
||||||
|
// SWT.Modify event which is fired from BundleContributionItem
|
||||||
|
updateListener = new Listener() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(Event event) {
|
||||||
|
if (!mItem.isDisposed()) {
|
||||||
|
if (mItem.getData() == event.data) {
|
||||||
|
mItem.setText(((MenuItem) event.data).getText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
menItem.addListener(SWT.Modify, updateListener);
|
||||||
|
|
||||||
|
// if it has a submenu, do the following
|
||||||
|
if (mItem.getStyle() == SWT.CASCADE) {
|
||||||
|
final Menu subMenu = new Menu(shell, SWT.DROP_DOWN);
|
||||||
|
mItem.setMenu(subMenu);
|
||||||
|
subMenu.addMenuListener(new MenuAdapter() {
|
||||||
|
@Override
|
||||||
|
public void menuShown(MenuEvent e) {
|
||||||
|
// if not empty
|
||||||
|
if (subMenu.getItemCount() == 0) {
|
||||||
|
// execute the show listeners on the menu of the
|
||||||
|
// stored off MenuItem, which will populate the Menu
|
||||||
|
// with the items and then we are able to get those
|
||||||
|
// items to populate our submenu
|
||||||
|
for (Listener list : ((MenuItem) mItem.getData())
|
||||||
|
.getMenu().getListeners(SWT.Show)) {
|
||||||
|
Event event = new Event();
|
||||||
|
event.widget = (Menu) e.getSource();
|
||||||
|
event.type = SWT.Show;
|
||||||
|
list.handleEvent(event);
|
||||||
|
}
|
||||||
|
// now that we have the items, we build the menu
|
||||||
|
buildMenu((MenuItem) mItem.getData(), shell,
|
||||||
|
subMenu);
|
||||||
|
subMenu.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// add toggle button functionality
|
||||||
|
if (mItem.getStyle() == SWT.CHECK) {
|
||||||
|
selectionListener = new Listener() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(Event event) {
|
||||||
|
// set it to the actual menu item, so that next time it
|
||||||
|
// pops up it will hold the correct selection
|
||||||
|
menItem.setSelection(((MenuItem) event.widget)
|
||||||
|
.getSelection());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mItem.addListener(SWT.Selection, selectionListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
menu.addMenuListener(new MenuAdapter() {
|
||||||
|
@Override
|
||||||
|
public void menuHidden(MenuEvent e) {
|
||||||
|
if (selectionListener != null) {
|
||||||
|
mItem.removeListener(SWT.Selection, selectionListener);
|
||||||
|
}
|
||||||
|
menItem.removeListener(SWT.Modify, updateListener);
|
||||||
|
menItem.getParent().removeListener(SWT.Show, showListener);
|
||||||
|
|
||||||
|
// execute the hide listener on the menu so that the
|
||||||
|
// TearOffMenuListener gets removed from the menu and you
|
||||||
|
// don't get duplicate tear off items
|
||||||
|
for (Listener list : menItem.getParent().getListeners(
|
||||||
|
SWT.Hide)) {
|
||||||
|
Event event = new Event();
|
||||||
|
event.type = SWT.Hide;
|
||||||
|
event.widget = menItem.getParent();
|
||||||
|
list.handleEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the popup menu that pops up off the main TearOffMenuDialog
|
||||||
|
*
|
||||||
|
* @param item
|
||||||
|
* @param shell
|
||||||
|
* @param y
|
||||||
|
* y - used for the y location
|
||||||
|
*/
|
||||||
|
private void addPopupMenu(MenuItem item, Shell shell, int y) {
|
||||||
|
Menu menu = new Menu(shell, SWT.POP_UP);
|
||||||
|
buildMenu(item, shell, menu);
|
||||||
|
// get the location for the popup menu
|
||||||
|
// TODO XXX need to figure out bounds and such so that we dont put the
|
||||||
|
// pop up over the menu item selected
|
||||||
|
int xOffset = shell.getLocation().x;
|
||||||
|
int yOffset = shell.getLocation().y;
|
||||||
|
menu.setLocation(xOffset + shell.getSize().x, yOffset + y);
|
||||||
|
menu.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addSubmenus(MenuItem item, Shell shell, int y) {
|
||||||
|
// showing the menu in cave (won't actually show), but executes all the
|
||||||
|
// listeners to build the menus (since they are built on-demand)
|
||||||
|
for (Listener list : item.getMenu().getListeners(SWT.Show)) {
|
||||||
|
try {
|
||||||
|
Event event = new Event();
|
||||||
|
event.widget = item;
|
||||||
|
event.type = SWT.Show;
|
||||||
|
list.handleEvent(event);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addPopupMenu(item, shell, y);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,183 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.viz.ui.menus.widgets.tearoff;
|
||||||
|
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.custom.ScrolledComposite;
|
||||||
|
import org.eclipse.swt.graphics.Point;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.Event;
|
||||||
|
import org.eclipse.swt.widgets.Listener;
|
||||||
|
import org.eclipse.swt.widgets.Menu;
|
||||||
|
import org.eclipse.swt.widgets.MenuItem;
|
||||||
|
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.dialogs.CaveSWTDialog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "Tear-off" menus to emulate A1 behavior
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Sep 14, 2011 mnash Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author mnash
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TearOffMenuDialog extends CaveSWTDialog {
|
||||||
|
|
||||||
|
private MenuItem[] items;
|
||||||
|
|
||||||
|
private ScrolledComposite scrolledComp;
|
||||||
|
|
||||||
|
private Composite fullComp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param parentShell
|
||||||
|
*/
|
||||||
|
public TearOffMenuDialog(Menu menu) {
|
||||||
|
super(VizWorkbenchManager.getInstance().getCurrentWindow().getShell(),
|
||||||
|
SWT.DIALOG_TRIM | SWT.RESIZE, CAVE.DO_NOT_BLOCK);
|
||||||
|
String text = menu.getParentItem().getText();
|
||||||
|
this.items = menu.getItems();
|
||||||
|
|
||||||
|
// handle for the & that makes key bindings
|
||||||
|
setText(text.replace("&", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initializeComponents(final Shell shell) {
|
||||||
|
// allow for scrolling if necessary
|
||||||
|
scrolledComp = new ScrolledComposite(shell, SWT.V_SCROLL);
|
||||||
|
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
|
scrolledComp.setLayoutData(gd);
|
||||||
|
fullComp = new Composite(scrolledComp, SWT.NONE);
|
||||||
|
GridLayout fullLayout = new GridLayout();
|
||||||
|
fullLayout.marginHeight = 0;
|
||||||
|
fullLayout.marginWidth = 0;
|
||||||
|
// don't want any space between the two controls
|
||||||
|
fullLayout.horizontalSpacing = 0;
|
||||||
|
fullComp.setLayout(fullLayout);
|
||||||
|
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
|
fullComp.setLayoutData(gd);
|
||||||
|
|
||||||
|
// go through menu items and build MenuItemComposite for each item,
|
||||||
|
// which handles all the selection and color of the "MenuItem" in the
|
||||||
|
// dialog
|
||||||
|
int radioGroup = 0;
|
||||||
|
for (int i = 1; i < items.length; i++) {
|
||||||
|
MenuItem item = items[i];
|
||||||
|
MenuItemComposite comp = new MenuItemComposite(fullComp, SWT.NONE);
|
||||||
|
|
||||||
|
if (item.getStyle() == SWT.RADIO) {
|
||||||
|
comp.setData("radioGroup", radioGroup);
|
||||||
|
} else {
|
||||||
|
radioGroup++;
|
||||||
|
}
|
||||||
|
|
||||||
|
GridLayout layout = new GridLayout(2, false);
|
||||||
|
layout.marginHeight = 0;
|
||||||
|
layout.marginWidth = 0;
|
||||||
|
comp.setLayout(layout);
|
||||||
|
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
comp.setLayoutData(gd);
|
||||||
|
|
||||||
|
// add the labels to the dialog with each of the MenuItems
|
||||||
|
comp.addLabels(item, SWT.NONE);
|
||||||
|
}
|
||||||
|
scrolledComp.setContent(fullComp);
|
||||||
|
scrolledComp.setExpandHorizontal(true);
|
||||||
|
scrolledComp.setExpandVertical(true);
|
||||||
|
scrolledComp.setMinSize(fullComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
||||||
|
|
||||||
|
shell.setMinimumSize(150, fullComp.getSize().y);
|
||||||
|
shell.pack();
|
||||||
|
Point point = Display.getCurrent().getCursorLocation();
|
||||||
|
int offset = shell.getBounds().width / 2;
|
||||||
|
int x = point.x - offset;
|
||||||
|
int y = point.y;
|
||||||
|
shell.setLocation(x, y);
|
||||||
|
|
||||||
|
// close the dialog on perspective change
|
||||||
|
shell.addListener(SWT.Hide, new Listener() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(Event event) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (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) {
|
||||||
|
if (Display.getCurrent().getActiveShell() == getShell()) {
|
||||||
|
ContextManager.getInstance(locator).deactivateContexts(
|
||||||
|
perspectiveManager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
addListener(SWT.Activate, activate);
|
||||||
|
addListener(SWT.Deactivate, deactivate);
|
||||||
|
addListener(SWT.Close, deactivate);
|
||||||
|
|
||||||
|
activate.handleEvent(new Event());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void disposed() {
|
||||||
|
for (Control control : fullComp.getChildren()) {
|
||||||
|
control.dispose();
|
||||||
|
}
|
||||||
|
super.disposed();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,243 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.viz.ui.menus.widgets.tearoff;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.jface.action.Action;
|
||||||
|
import org.eclipse.jface.action.ActionContributionItem;
|
||||||
|
import org.eclipse.jface.action.ContributionItem;
|
||||||
|
import org.eclipse.jface.action.IContributionItem;
|
||||||
|
import org.eclipse.jface.action.IMenuListener;
|
||||||
|
import org.eclipse.jface.action.IMenuListener2;
|
||||||
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.widgets.Event;
|
||||||
|
import org.eclipse.swt.widgets.Listener;
|
||||||
|
import org.eclipse.swt.widgets.Menu;
|
||||||
|
import org.eclipse.swt.widgets.MenuItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menu listener that adds item to menu which will open dialog which is the menu
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Sep 14, 2011 mschenke Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author mschenke
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TearOffMenuListener implements IMenuListener2 {
|
||||||
|
|
||||||
|
private List<Object> openDialogs = new ArrayList<Object>();
|
||||||
|
|
||||||
|
private static final String ID = "tearOffMenuContributionItem";
|
||||||
|
|
||||||
|
private static final String ACTION_ID = "tearOffMenuAction";
|
||||||
|
|
||||||
|
public static final String TEAROFF_PREFERENCE_ID = "tearoffmenus";
|
||||||
|
|
||||||
|
private static boolean enabled;
|
||||||
|
static {
|
||||||
|
final IPreferenceStore store = com.raytheon.uf.viz.core.Activator
|
||||||
|
.getDefault().getPreferenceStore();
|
||||||
|
enabled = store.getBoolean(TEAROFF_PREFERENCE_ID);
|
||||||
|
store.addPropertyChangeListener(new IPropertyChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void propertyChange(PropertyChangeEvent event) {
|
||||||
|
enabled = store.getBoolean(TEAROFF_PREFERENCE_ID);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public TearOffMenuListener() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public TearOffMenuListener(IMenuManager mgr) {
|
||||||
|
register(mgr.getItems(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the menu is about to show, check if the list contains that menu
|
||||||
|
* manager and if it doesn't add a TearOffContributionItem
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void menuAboutToShow(final IMenuManager manager) {
|
||||||
|
register(manager.getItems(), this);
|
||||||
|
if (openDialogs.contains(getKey(manager)) == false) {
|
||||||
|
// We need to add our item to be first so we need to remove others
|
||||||
|
// then add ourself
|
||||||
|
IContributionItem[] items = manager.getItems();
|
||||||
|
manager.removeAll();
|
||||||
|
manager.add(new TearOffContributionItem(manager));
|
||||||
|
for (IContributionItem item : items) {
|
||||||
|
manager.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the menu manager from the list, so that the menu item will show
|
||||||
|
* back up
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void menuAboutToHide(IMenuManager manager) {
|
||||||
|
if (openDialogs.contains(getKey(manager)) == false) {
|
||||||
|
manager.remove(ID);
|
||||||
|
manager.remove(ACTION_ID);
|
||||||
|
unregister(manager.getItems(), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void register(IContributionItem[] items,
|
||||||
|
IMenuListener listener) {
|
||||||
|
for (IContributionItem item : items) {
|
||||||
|
if (item instanceof IMenuManager) {
|
||||||
|
((IMenuManager) item).addMenuListener(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unregister(IContributionItem[] items,
|
||||||
|
IMenuListener listener) {
|
||||||
|
for (IContributionItem item : items) {
|
||||||
|
if (item instanceof IMenuManager) {
|
||||||
|
((IMenuManager) item).removeMenuListener(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Object getKey(IMenuManager manager) {
|
||||||
|
Object key = manager;
|
||||||
|
if (manager.getId() != null) {
|
||||||
|
key = manager.getId();
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TearOffContributionItem extends ContributionItem {
|
||||||
|
|
||||||
|
private IMenuManager manager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param action
|
||||||
|
*/
|
||||||
|
public TearOffContributionItem(IMenuManager manager) {
|
||||||
|
super(ID);
|
||||||
|
this.manager = manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* org.eclipse.jface.action.ActionContributionItem#fill(org.eclipse.
|
||||||
|
* swt.widgets.Menu, int)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void fill(Menu menu, int index) {
|
||||||
|
String longest = "";
|
||||||
|
for (MenuItem item : menu.getItems()) {
|
||||||
|
String check = item.getText();
|
||||||
|
if (check.length() > longest.length()) {
|
||||||
|
longest = check;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
byte[] bytes = new byte[longest.length() * 2];
|
||||||
|
Arrays.fill(bytes, (byte) '|');
|
||||||
|
// String filled = new String(bytes);
|
||||||
|
String filled = "- - - - - - TEAR-OFF : "
|
||||||
|
+ menu.getParentItem().getText() + " - - - - - -";
|
||||||
|
// String filled = "-" * bytes.length
|
||||||
|
|
||||||
|
new ActionContributionItem(new TearOffAction(filled, manager, menu))
|
||||||
|
.fill(menu, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.jface.action.ContributionItem#isVisible()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isVisible() {
|
||||||
|
return super.isVisible() && enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TearOffAction extends Action {
|
||||||
|
|
||||||
|
private IMenuManager manager;
|
||||||
|
|
||||||
|
private Menu menu;
|
||||||
|
|
||||||
|
private TearOffAction(String text, final IMenuManager manager, Menu menu) {
|
||||||
|
super(text);
|
||||||
|
this.manager = manager;
|
||||||
|
this.menu = menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.jface.action.Action#run()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
TearOffMenuDialog dialog = new TearOffMenuDialog(menu);
|
||||||
|
dialog.addListener(SWT.Dispose, new Listener() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(Event event) {
|
||||||
|
openDialogs.remove(getKey(manager));
|
||||||
|
manager.remove(ID);
|
||||||
|
manager.remove(ACTION_ID);
|
||||||
|
unregister(manager.getItems(), TearOffMenuListener.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
openDialogs.add(getKey(manager));
|
||||||
|
register(manager.getItems(), TearOffMenuListener.this);
|
||||||
|
dialog.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.jface.action.Action#getId()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return ACTION_ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.viz.ui.menus.widgets.tearoff;
|
||||||
|
|
||||||
|
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||||
|
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||||
|
import org.eclipse.ui.IWorkbench;
|
||||||
|
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.core.Activator;
|
||||||
|
import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preference page for tear off menus
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Nov 23, 2011 mnash Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author mnash
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TearOffPreferencePage extends FieldEditorPreferencePage implements
|
||||||
|
IWorkbenchPreferencePage {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init(IWorkbench workbench) {
|
||||||
|
HierarchicalPreferenceStore store = Activator.getDefault()
|
||||||
|
.getPreferenceStore();
|
||||||
|
setPreferenceStore(store);
|
||||||
|
setDescription("CAVE UI Preferences");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
|
||||||
|
* ()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void createFieldEditors() {
|
||||||
|
BooleanFieldEditor editor = new BooleanFieldEditor(
|
||||||
|
TearOffMenuListener.TEAROFF_PREFERENCE_ID,
|
||||||
|
"Enable Tear-Off Menus (requires restart)",
|
||||||
|
getFieldEditorParent());
|
||||||
|
addField(editor);
|
||||||
|
}
|
||||||
|
}
|
|
@ -119,5 +119,4 @@ public class IncludeMenuContribution extends
|
||||||
|
|
||||||
return contribList.toArray(new IContributionItem[contribList.size()]);
|
return contribList.toArray(new IContributionItem[contribList.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@ 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.uf.viz.core.exception.VizException;
|
import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
import com.raytheon.uf.viz.ui.menus.DiscoverMenuContributions;
|
import com.raytheon.uf.viz.ui.menus.DiscoverMenuContributions;
|
||||||
import com.raytheon.uf.viz.ui.menus.widgets.IncludeContributionItem;
|
|
||||||
import com.raytheon.uf.viz.ui.menus.widgets.SubmenuContributionItem;
|
import com.raytheon.uf.viz.ui.menus.widgets.SubmenuContributionItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,6 +67,8 @@ public class IncludeMenuItem extends CommonIncludeMenuItem implements
|
||||||
static final transient IUFStatusHandler statusHandler = UFStatus
|
static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
.getHandler(IncludeMenuItem.class);
|
.getHandler(IncludeMenuItem.class);
|
||||||
|
|
||||||
|
private SubmenuContributionItem submenuCont = null;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -81,8 +82,8 @@ public class IncludeMenuItem extends CommonIncludeMenuItem implements
|
||||||
VariableSubstitution[] incomingSubs, Set<String> removalsIn)
|
VariableSubstitution[] incomingSubs, Set<String> removalsIn)
|
||||||
throws VizException {
|
throws VizException {
|
||||||
if (subMenuName != null) {
|
if (subMenuName != null) {
|
||||||
return new IContributionItem[] { new SubmenuContributionItem(
|
submenuCont = new SubmenuContributionItem(incomingSubs,
|
||||||
incomingSubs, subMenuName, null, removalsIn) {
|
subMenuName, null, removalsIn) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected synchronized IContributionItem[][] getContributionItems() {
|
protected synchronized IContributionItem[][] getContributionItems() {
|
||||||
|
@ -97,11 +98,20 @@ public class IncludeMenuItem extends CommonIncludeMenuItem implements
|
||||||
}
|
}
|
||||||
return this.contributionItems;
|
return this.contributionItems;
|
||||||
}
|
}
|
||||||
} };
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.jface.action.MenuManager#getId()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return subMenuName;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return new IContributionItem[] { submenuCont };
|
||||||
}
|
}
|
||||||
// return getAllContributionItems(items, incomingSubs, removalsIn);
|
return getAllContributionItems(items, incomingSubs, removalsIn);
|
||||||
return new IContributionItem[] { new IncludeContributionItem(this,
|
|
||||||
items, incomingSubs, removalsIn) };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IContributionItem[] getAllContributionItems(
|
public IContributionItem[] getAllContributionItems(
|
||||||
|
@ -141,7 +151,8 @@ public class IncludeMenuItem extends CommonIncludeMenuItem implements
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (amc == null) {
|
if (amc == null) {
|
||||||
System.out.println(c.getClass());
|
System.out.println("There is no xml mapping for "
|
||||||
|
+ c.getClass());
|
||||||
}
|
}
|
||||||
IContributionItem[] contribItems = amc
|
IContributionItem[] contribItems = amc
|
||||||
.getContributionItems(c, combinedSub, removalsSet);
|
.getContributionItems(c, combinedSub, removalsSet);
|
||||||
|
@ -162,5 +173,4 @@ public class IncludeMenuItem extends CommonIncludeMenuItem implements
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,8 @@ public class SubmenuContribution extends
|
||||||
if (removals.contains(item.id))
|
if (removals.contains(item.id))
|
||||||
return new IContributionItem[0];
|
return new IContributionItem[0];
|
||||||
|
|
||||||
final SubmenuContributionItem smci = new SubmenuContributionItem(subs,
|
return new IContributionItem[] { new SubmenuContributionItem(subs,
|
||||||
item.menuText, item.contributions, new HashSet<String>());
|
item.menuText, item.contributions, new HashSet<String>()) };
|
||||||
return new IContributionItem[] { smci };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ Import-Package: com.raytheon.edex.meteoLib,
|
||||||
com.raytheon.uf.common.serialization.comm,
|
com.raytheon.uf.common.serialization.comm,
|
||||||
com.raytheon.uf.viz.python.swt,
|
com.raytheon.uf.viz.python.swt,
|
||||||
com.raytheon.uf.viz.python.swt.widgets,
|
com.raytheon.uf.viz.python.swt.widgets,
|
||||||
|
com.raytheon.uf.viz.ui.menus.widgets.tearoff,
|
||||||
com.raytheon.viz.core.gl,
|
com.raytheon.viz.core.gl,
|
||||||
com.raytheon.viz.pointdata,
|
com.raytheon.viz.pointdata,
|
||||||
com.raytheon.viz.ui.tools.map,
|
com.raytheon.viz.ui.tools.map,
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -30,6 +30,7 @@ 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;
|
||||||
|
@ -53,57 +54,81 @@ import com.raytheon.viz.gfe.core.IReferenceSetManager;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class GFEEditAreaMenu extends CompoundContributionItem {
|
public class GFEEditAreaMenu extends CompoundContributionItem {
|
||||||
private static final String COMMAND_ID = "com.raytheon.viz.gfe.actions.EditArea";
|
private static final String COMMAND_ID = "com.raytheon.viz.gfe.actions.EditArea";
|
||||||
|
|
||||||
private static final String NULL_COMMAND_ID = "com.raytheon.viz.ui.actions.nullAction";
|
private static final String NULL_COMMAND_ID = "com.raytheon.viz.ui.actions.nullAction";
|
||||||
|
|
||||||
/*
|
// private boolean addTear = true;
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected IContributionItem[] getContributionItems() {
|
|
||||||
MenuManager menuMgr = new MenuManager("Edit Areas");
|
|
||||||
DataManager dm = DataManager.getCurrentInstance();
|
|
||||||
if (dm != null) {
|
|
||||||
IReferenceSetManager refMgr = dm.getRefManager();
|
|
||||||
List<String> groupList = refMgr.getGroupInventory();
|
|
||||||
groupList.add("Misc");
|
|
||||||
int menuLength = GFEPreference
|
|
||||||
.getIntPreference("MaxMenuItemsBeforeCascade");
|
|
||||||
menuLength = (menuLength > 1) ? menuLength : 30;
|
|
||||||
for (String group : groupList) {
|
|
||||||
MenuManager mm = new MenuManager(group);
|
|
||||||
menuMgr.add(mm);
|
|
||||||
int count = 0;
|
|
||||||
for (String ref : refMgr.getGroupData(group)) {
|
|
||||||
Map<String, String> parms = new HashMap<String, String>();
|
|
||||||
parms.put("name", ref);
|
|
||||||
mm.add(new CommandContributionItem(
|
|
||||||
new CommandContributionItemParameter(PlatformUI
|
|
||||||
.getWorkbench(), null, COMMAND_ID, parms,
|
|
||||||
null, null, null, ref, null, null,
|
|
||||||
CommandContributionItem.STYLE_PUSH, null,
|
|
||||||
true)));
|
|
||||||
if (++count % menuLength == 0) {
|
|
||||||
MenuManager mm1 = new MenuManager("More");
|
|
||||||
mm.add(mm1);
|
|
||||||
mm = mm1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count == 0) {
|
/*
|
||||||
mm.add(new CommandContributionItem(
|
* (non-Javadoc)
|
||||||
new CommandContributionItemParameter(PlatformUI
|
*
|
||||||
.getWorkbench(), null, NULL_COMMAND_ID,
|
* @see
|
||||||
null, null, null, null, "<Empty>", null,
|
* org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
|
||||||
null, CommandContributionItem.STYLE_PUSH,
|
*/
|
||||||
null, true)));
|
@Override
|
||||||
}
|
protected IContributionItem[] getContributionItems() {
|
||||||
}
|
// TODO, fix this code to not show extra items
|
||||||
}
|
// boolean needTear = com.raytheon.uf.viz.core.Activator.getDefault()
|
||||||
return menuMgr.getItems();
|
// .getPreferenceStore().getBoolean("tearoffmenus");
|
||||||
}
|
|
||||||
|
MenuManager menuMgr = new MenuManager("Edit Areas");
|
||||||
|
DataManager dm = DataManager.getCurrentInstance();
|
||||||
|
if (dm != null) {
|
||||||
|
IReferenceSetManager refMgr = dm.getRefManager();
|
||||||
|
List<String> groupList = refMgr.getGroupInventory();
|
||||||
|
groupList.add("Misc");
|
||||||
|
int menuLength = GFEPreference
|
||||||
|
.getIntPreference("MaxMenuItemsBeforeCascade");
|
||||||
|
menuLength = (menuLength > 1) ? menuLength : 30;
|
||||||
|
// if (addTear && needTear) {
|
||||||
|
// menuMgr.addMenuListener(new TearOffMenuListener(menuMgr));
|
||||||
|
// addTear = false;
|
||||||
|
// }
|
||||||
|
for (String group : groupList) {
|
||||||
|
MenuManager mm = new MenuManager(group);
|
||||||
|
menuMgr.add(mm);
|
||||||
|
|
||||||
|
// if (needTear) {
|
||||||
|
// menuMgr.addMenuListener(new TearOffMenuListener(mm));
|
||||||
|
// addTear = true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (String ref : refMgr.getGroupData(group)) {
|
||||||
|
// if (needTear && addTear) {
|
||||||
|
// mm.addMenuListener(new TearOffMenuListener(mm));
|
||||||
|
// addTear = false;
|
||||||
|
// }
|
||||||
|
Map<String, String> parms = new HashMap<String, String>();
|
||||||
|
parms.put("name", ref);
|
||||||
|
mm.add(new CommandContributionItem(
|
||||||
|
new CommandContributionItemParameter(PlatformUI
|
||||||
|
.getWorkbench(), null, COMMAND_ID, parms,
|
||||||
|
null, null, null, ref, null, null,
|
||||||
|
CommandContributionItem.STYLE_PUSH, null,
|
||||||
|
true)));
|
||||||
|
if (++count % menuLength == 0) {
|
||||||
|
MenuManager mm1 = new MenuManager("More");
|
||||||
|
mm.add(mm1);
|
||||||
|
mm = mm1;
|
||||||
|
// if (needTear && addTear) {
|
||||||
|
// mm.addMenuListener(new TearOffMenuListener(mm));
|
||||||
|
// addTear = false;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
|
mm.add(new CommandContributionItem(
|
||||||
|
new CommandContributionItemParameter(PlatformUI
|
||||||
|
.getWorkbench(), null, NULL_COMMAND_ID,
|
||||||
|
null, null, null, null, "<Empty>", null,
|
||||||
|
null, CommandContributionItem.STYLE_PUSH,
|
||||||
|
null, true)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return menuMgr.getItems();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,6 +392,10 @@
|
||||||
name="size"
|
name="size"
|
||||||
value="7">
|
value="7">
|
||||||
</parameter>
|
</parameter>
|
||||||
|
<parameter
|
||||||
|
name="org.eclipse.ui.commands.radioStateParameter"
|
||||||
|
value="miniscule">
|
||||||
|
</parameter>
|
||||||
</command>
|
</command>
|
||||||
<command
|
<command
|
||||||
commandId="com.raytheon.viz.hydro.actions.setfont"
|
commandId="com.raytheon.viz.hydro.actions.setfont"
|
||||||
|
@ -402,6 +406,10 @@
|
||||||
name="size"
|
name="size"
|
||||||
value="8">
|
value="8">
|
||||||
</parameter>
|
</parameter>
|
||||||
|
<parameter
|
||||||
|
name="org.eclipse.ui.commands.radioStateParameter"
|
||||||
|
value="verysmall">
|
||||||
|
</parameter>
|
||||||
</command>
|
</command>
|
||||||
<command
|
<command
|
||||||
commandId="com.raytheon.viz.hydro.actions.setfont"
|
commandId="com.raytheon.viz.hydro.actions.setfont"
|
||||||
|
@ -412,6 +420,10 @@
|
||||||
name="size"
|
name="size"
|
||||||
value="9">
|
value="9">
|
||||||
</parameter>
|
</parameter>
|
||||||
|
<parameter
|
||||||
|
name="org.eclipse.ui.commands.radioStateParameter"
|
||||||
|
value="small">
|
||||||
|
</parameter>
|
||||||
</command>
|
</command>
|
||||||
<command
|
<command
|
||||||
commandId="com.raytheon.viz.hydro.actions.setfont"
|
commandId="com.raytheon.viz.hydro.actions.setfont"
|
||||||
|
@ -422,6 +434,10 @@
|
||||||
name="size"
|
name="size"
|
||||||
value="10">
|
value="10">
|
||||||
</parameter>
|
</parameter>
|
||||||
|
<parameter
|
||||||
|
name="org.eclipse.ui.commands.radioStateParameter"
|
||||||
|
value="normal">
|
||||||
|
</parameter>
|
||||||
</command>
|
</command>
|
||||||
<command
|
<command
|
||||||
commandId="com.raytheon.viz.hydro.actions.setfont"
|
commandId="com.raytheon.viz.hydro.actions.setfont"
|
||||||
|
@ -432,6 +448,10 @@
|
||||||
name="size"
|
name="size"
|
||||||
value="12">
|
value="12">
|
||||||
</parameter>
|
</parameter>
|
||||||
|
<parameter
|
||||||
|
name="org.eclipse.ui.commands.radioStateParameter"
|
||||||
|
value="large">
|
||||||
|
</parameter>
|
||||||
</command>
|
</command>
|
||||||
<command
|
<command
|
||||||
commandId="com.raytheon.viz.hydro.actions.setfont"
|
commandId="com.raytheon.viz.hydro.actions.setfont"
|
||||||
|
@ -442,6 +462,10 @@
|
||||||
name="size"
|
name="size"
|
||||||
value="16">
|
value="16">
|
||||||
</parameter>
|
</parameter>
|
||||||
|
<parameter
|
||||||
|
name="org.eclipse.ui.commands.radioStateParameter"
|
||||||
|
value="verylarge">
|
||||||
|
</parameter>
|
||||||
</command>
|
</command>
|
||||||
</menu>
|
</menu>
|
||||||
</menuContribution>
|
</menuContribution>
|
||||||
|
@ -625,8 +649,17 @@
|
||||||
<commandParameter
|
<commandParameter
|
||||||
id="size"
|
id="size"
|
||||||
name="size"
|
name="size"
|
||||||
optional="true">
|
optional="false">
|
||||||
</commandParameter>
|
</commandParameter>
|
||||||
|
<commandParameter
|
||||||
|
id="org.eclipse.ui.commands.radioStateParameter"
|
||||||
|
name="State"
|
||||||
|
optional="false">
|
||||||
|
</commandParameter>
|
||||||
|
<state
|
||||||
|
class="org.eclipse.ui.handlers.RadioState:normal"
|
||||||
|
id="org.eclipse.ui.commands.radioState">
|
||||||
|
</state>
|
||||||
</command>
|
</command>
|
||||||
<command
|
<command
|
||||||
id="com.raytheon.viz.hydro.actions.EditLocationShiftAction"
|
id="com.raytheon.viz.hydro.actions.EditLocationShiftAction"
|
||||||
|
|
|
@ -22,8 +22,12 @@ package com.raytheon.viz.hydrocommon.actions;
|
||||||
import org.eclipse.core.commands.AbstractHandler;
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
import org.eclipse.ui.handlers.HandlerUtil;
|
||||||
|
import org.eclipse.ui.handlers.RadioState;
|
||||||
|
|
||||||
import com.raytheon.viz.hydrocommon.HydroDisplayManager;
|
import com.raytheon.viz.hydrocommon.HydroDisplayManager;
|
||||||
|
import com.raytheon.viz.ui.EditorUtil;
|
||||||
|
import com.raytheon.viz.ui.editor.AbstractEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* TODO Add Description
|
||||||
|
@ -48,6 +52,12 @@ public class FontAction extends AbstractHandler {
|
||||||
HydroDisplayManager manager = HydroDisplayManager.getInstance();
|
HydroDisplayManager manager = HydroDisplayManager.getInstance();
|
||||||
manager.setFontSize(Integer.parseInt(event.getParameter("size")));
|
manager.setFontSize(Integer.parseInt(event.getParameter("size")));
|
||||||
|
|
||||||
|
String newVal = event.getParameter(RadioState.PARAMETER_ID);
|
||||||
|
HandlerUtil.updateRadioState(event.getCommand(), newVal);
|
||||||
|
if (EditorUtil.getActiveEditor() != null) {
|
||||||
|
((AbstractEditor) EditorUtil.getActiveEditor()).refresh();
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<!--
|
||||||
This_software_was_developed_and_/_or_modified_by_Raytheon_Company,
|
This_software_was_developed_and_/_or_modified_by_Raytheon_Company,
|
||||||
pursuant_to_Contract_DG133W-05-CQ-1067_with_the_US_Government.
|
pursuant_to_Contract_DG133W-05-CQ-1067_with_the_US_Government.
|
||||||
|
|
||||||
U.S._EXPORT_CONTROLLED_TECHNICAL_DATA
|
U.S._EXPORT_CONTROLLED_TECHNICAL_DATA
|
||||||
This_software_product_contains_export-restricted_data_whose
|
This_software_product_contains_export-restricted_data_whose
|
||||||
export/transfer/disclosure_is_restricted_by_U.S._law._Dissemination
|
export/transfer/disclosure_is_restricted_by_U.S._law._Dissemination
|
||||||
to_non-U.S._persons_whether_in_the_United_States_or_abroad_requires
|
to_non-U.S._persons_whether_in_the_United_States_or_abroad_requires
|
||||||
an_export_license_or_other_authorization.
|
an_export_license_or_other_authorization.
|
||||||
|
|
||||||
Contractor_Name:________Raytheon_Company
|
Contractor_Name:________Raytheon_Company
|
||||||
Contractor_Address:_____6825_Pine_Street,_Suite_340
|
Contractor_Address:_____6825_Pine_Street,_Suite_340
|
||||||
________________________Mail_Stop_B8
|
________________________Mail_Stop_B8
|
||||||
________________________Omaha,_NE_68106
|
________________________Omaha,_NE_68106
|
||||||
________________________402.291.0100
|
________________________402.291.0100
|
||||||
|
|
||||||
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for
|
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for
|
||||||
further_licensing_information.
|
further_licensing_information.
|
||||||
-->
|
-->
|
||||||
|
@ -937,10 +937,12 @@
|
||||||
name="State"
|
name="State"
|
||||||
optional="false">
|
optional="false">
|
||||||
</commandParameter>
|
</commandParameter>
|
||||||
|
<!--
|
||||||
<state
|
<state
|
||||||
class="org.eclipse.ui.handlers.RadioState:Contrast"
|
class="org.eclipse.ui.handlers.RadioState:Contrast"
|
||||||
id="org.eclipse.ui.commands.radioState">
|
id="org.eclipse.ui.commands.radioState">
|
||||||
</state>
|
</state>
|
||||||
|
-->
|
||||||
</command>
|
</command>
|
||||||
<command
|
<command
|
||||||
id="com.raytheon.viz.mpe.ui.actions.saveBestEstimate"
|
id="com.raytheon.viz.mpe.ui.actions.saveBestEstimate"
|
||||||
|
@ -1608,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">
|
||||||
|
|
|
@ -312,7 +312,7 @@ public class MPEDisplayManager {
|
||||||
public static MPEDisplayManager getCurrent() {
|
public static MPEDisplayManager getCurrent() {
|
||||||
MPEDisplayManager instance = null;
|
MPEDisplayManager instance = null;
|
||||||
IEditorPart editor = EditorUtil.getActiveEditor();
|
IEditorPart editor = EditorUtil.getActiveEditor();
|
||||||
if (editor != null && editor instanceof IDisplayPaneContainer) {
|
if ((editor != null) && (editor instanceof IDisplayPaneContainer)) {
|
||||||
IDisplayPane pane = null;
|
IDisplayPane pane = null;
|
||||||
if (editor instanceof IMultiPaneEditor) {
|
if (editor instanceof IMultiPaneEditor) {
|
||||||
IMultiPaneEditor multiPane = (IMultiPaneEditor) editor;
|
IMultiPaneEditor multiPane = (IMultiPaneEditor) editor;
|
||||||
|
@ -420,8 +420,7 @@ public class MPEDisplayManager {
|
||||||
displayMode = EnumSet.noneOf(DisplayMode.class);
|
displayMode = EnumSet.noneOf(DisplayMode.class);
|
||||||
gageDisplay = EnumSet.noneOf(GageDisplay.class);
|
gageDisplay = EnumSet.noneOf(GageDisplay.class);
|
||||||
gageMissing = GageMissingOptions.MissingNone;
|
gageMissing = GageMissingOptions.MissingNone;
|
||||||
gageColor = GageColor.valueOf(String.valueOf(colorCommand.getState(
|
gageColor = GageColor.Solid;
|
||||||
RadioState.STATE_ID).getValue()));
|
|
||||||
|
|
||||||
VizApp.runAsync(new Runnable() {
|
VizApp.runAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -891,6 +890,12 @@ public class MPEDisplayManager {
|
||||||
*/
|
*/
|
||||||
public void setGageColor(GageColor gc) {
|
public void setGageColor(GageColor gc) {
|
||||||
gageColor = gc;
|
gageColor = gc;
|
||||||
|
|
||||||
|
final ICommandService service = (ICommandService) PlatformUI
|
||||||
|
.getWorkbench().getService(ICommandService.class);
|
||||||
|
|
||||||
|
service.refreshElements(
|
||||||
|
"com.raytheon.viz.mpe.ui.actions.toggleGageColor", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,11 +25,11 @@ import org.eclipse.core.commands.AbstractHandler;
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.handlers.HandlerUtil;
|
|
||||||
|
|
||||||
import com.raytheon.uf.viz.core.IDisplayPane;
|
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||||
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||||
import com.raytheon.viz.mpe.ui.rsc.MPEPolygonResource;
|
import com.raytheon.viz.mpe.ui.rsc.MPEPolygonResource;
|
||||||
|
import com.raytheon.viz.ui.EditorUtil;
|
||||||
import com.raytheon.viz.ui.input.EditableManager;
|
import com.raytheon.viz.ui.input.EditableManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,8 +51,9 @@ public class DrawPolygonAction extends AbstractHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
|
IEditorPart activeEditor = (IEditorPart) EditorUtil
|
||||||
if (activeEditor instanceof IDisplayPaneContainer) {
|
.getActiveEditorAs(IDisplayPaneContainer.class);
|
||||||
|
if (activeEditor != null) {
|
||||||
IDisplayPane first = ((IDisplayPaneContainer) activeEditor)
|
IDisplayPane first = ((IDisplayPaneContainer) activeEditor)
|
||||||
.getDisplayPanes()[0];
|
.getDisplayPanes()[0];
|
||||||
List<MPEPolygonResource> rscs = first.getDescriptor()
|
List<MPEPolygonResource> rscs = first.getDescriptor()
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
|
||||||
import org.eclipse.ui.handlers.RadioState;
|
import org.eclipse.ui.handlers.RadioState;
|
||||||
|
|
||||||
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||||
|
import com.raytheon.viz.ui.EditorUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the font size on the display managers for an editor. Updates radio state
|
* Sets the font size on the display managers for an editor. Updates radio state
|
||||||
|
@ -55,8 +56,9 @@ public class FontAction extends AbstractHandler {
|
||||||
String newVal = event.getParameter(RadioState.PARAMETER_ID);
|
String newVal = event.getParameter(RadioState.PARAMETER_ID);
|
||||||
HandlerUtil.updateRadioState(event.getCommand(), newVal);
|
HandlerUtil.updateRadioState(event.getCommand(), newVal);
|
||||||
|
|
||||||
IEditorPart part = HandlerUtil.getActiveEditor(event);
|
IEditorPart part = (IEditorPart) EditorUtil
|
||||||
if (part instanceof IDisplayPaneContainer) {
|
.getActiveEditorAs(IDisplayPaneContainer.class);
|
||||||
|
if (part != null) {
|
||||||
((IDisplayPaneContainer) part).refresh();
|
((IDisplayPaneContainer) part).refresh();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -23,13 +23,13 @@ import org.eclipse.core.commands.AbstractHandler;
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.handlers.HandlerUtil;
|
|
||||||
|
|
||||||
import com.raytheon.uf.viz.core.IDisplayPane;
|
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||||
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||||
import com.raytheon.viz.mpe.ui.DisplayFieldData;
|
import com.raytheon.viz.mpe.ui.DisplayFieldData;
|
||||||
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
|
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
|
||||||
import com.raytheon.viz.mpe.ui.rsc.XmrgResource;
|
import com.raytheon.viz.mpe.ui.rsc.XmrgResource;
|
||||||
|
import com.raytheon.viz.ui.EditorUtil;
|
||||||
import com.raytheon.viz.ui.editor.IMultiPaneEditor;
|
import com.raytheon.viz.ui.editor.IMultiPaneEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,8 +61,9 @@ public class SetDisplayField extends AbstractHandler {
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
String f = event.getParameter("Field");
|
String f = event.getParameter("Field");
|
||||||
|
|
||||||
IEditorPart editor = HandlerUtil.getActiveEditor(event);
|
IEditorPart editor = (IEditorPart) EditorUtil
|
||||||
if (editor instanceof IDisplayPaneContainer) {
|
.getActiveEditorAs(IDisplayPaneContainer.class);
|
||||||
|
if (editor != null) {
|
||||||
return setDisplayField((IDisplayPaneContainer) editor, f);
|
return setDisplayField((IDisplayPaneContainer) editor, f);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.eclipse.core.commands.ExecutionEvent;
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.commands.IElementUpdater;
|
import org.eclipse.ui.commands.IElementUpdater;
|
||||||
import org.eclipse.ui.handlers.HandlerUtil;
|
|
||||||
import org.eclipse.ui.menus.UIElement;
|
import org.eclipse.ui.menus.UIElement;
|
||||||
|
|
||||||
import com.raytheon.uf.viz.core.IDisplayPane;
|
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||||
|
@ -56,8 +55,9 @@ public class ShowAddPseudoGage extends AbstractHandler implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
|
IEditorPart activeEditor = (IEditorPart) EditorUtil
|
||||||
if (activeEditor instanceof IDisplayPaneContainer) {
|
.getActiveEditorAs(IDisplayPaneContainer.class);
|
||||||
|
if (activeEditor != null) {
|
||||||
IDisplayPane first = ((IDisplayPaneContainer) activeEditor)
|
IDisplayPane first = ((IDisplayPaneContainer) activeEditor)
|
||||||
.getDisplayPanes()[0];
|
.getDisplayPanes()[0];
|
||||||
List<AddPseudoGageResource> rscs = first.getDescriptor()
|
List<AddPseudoGageResource> rscs = first.getDescriptor()
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.eclipse.core.commands.ExecutionEvent;
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.commands.IElementUpdater;
|
import org.eclipse.ui.commands.IElementUpdater;
|
||||||
import org.eclipse.ui.handlers.HandlerUtil;
|
|
||||||
import org.eclipse.ui.menus.UIElement;
|
import org.eclipse.ui.menus.UIElement;
|
||||||
|
|
||||||
import com.raytheon.uf.viz.core.IDisplayPane;
|
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||||
|
@ -55,8 +54,9 @@ public class ShowDisplay7x7 extends AbstractHandler implements IElementUpdater {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
|
IEditorPart activeEditor = (IEditorPart) EditorUtil
|
||||||
if (activeEditor instanceof IDisplayPaneContainer) {
|
.getActiveEditorAs(IDisplayPaneContainer.class);
|
||||||
|
if (activeEditor != null) {
|
||||||
IDisplayPane first = ((IDisplayPaneContainer) activeEditor)
|
IDisplayPane first = ((IDisplayPaneContainer) activeEditor)
|
||||||
.getDisplayPanes()[0];
|
.getDisplayPanes()[0];
|
||||||
List<MPEGageResource> rscs = first.getDescriptor()
|
List<MPEGageResource> rscs = first.getDescriptor()
|
||||||
|
|
|
@ -19,13 +19,19 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.viz.mpe.ui.actions;
|
package com.raytheon.viz.mpe.ui.actions;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.core.commands.AbstractHandler;
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
import org.eclipse.ui.commands.IElementUpdater;
|
||||||
import org.eclipse.ui.handlers.RadioState;
|
import org.eclipse.ui.handlers.RadioState;
|
||||||
|
import org.eclipse.ui.menus.UIElement;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||||
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
|
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
|
||||||
import com.raytheon.viz.mpe.ui.MPEDisplayManager.GageColor;
|
import com.raytheon.viz.mpe.ui.MPEDisplayManager.GageColor;
|
||||||
|
import com.raytheon.viz.ui.EditorUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* TODO Add Description
|
||||||
|
@ -43,7 +49,7 @@ import com.raytheon.viz.mpe.ui.MPEDisplayManager.GageColor;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ToggleGageColor extends AbstractHandler {
|
public class ToggleGageColor extends AbstractHandler implements IElementUpdater {
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -59,4 +65,23 @@ public class ToggleGageColor extends AbstractHandler {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void updateElement(UIElement element, Map parameters) {
|
||||||
|
MPEDisplayManager dm = MPEDisplayManager.getCurrent();
|
||||||
|
if (dm == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GageColor color = dm.getGageColor();
|
||||||
|
String g = (String) parameters.get(RadioState.PARAMETER_ID);
|
||||||
|
GageColor val = GageColor.valueOf(g);
|
||||||
|
element.setChecked(color.equals(val));
|
||||||
|
|
||||||
|
IDisplayPaneContainer container = EditorUtil
|
||||||
|
.getActiveEditorAs(IDisplayPaneContainer.class);
|
||||||
|
if (container != null) {
|
||||||
|
container.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,11 @@ import org.eclipse.core.commands.AbstractHandler;
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.handlers.HandlerUtil;
|
|
||||||
|
|
||||||
import com.raytheon.uf.viz.core.IDisplayPane;
|
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||||
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||||
import com.raytheon.viz.mpe.ui.rsc.MPELegendResource;
|
import com.raytheon.viz.mpe.ui.rsc.MPELegendResource;
|
||||||
|
import com.raytheon.viz.ui.EditorUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* TODO Add Description
|
||||||
|
@ -58,8 +58,9 @@ public class ToggleMpeInfo extends AbstractHandler {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
IEditorPart part = HandlerUtil.getActiveEditor(event);
|
IEditorPart part = (IEditorPart) EditorUtil
|
||||||
if (part instanceof IDisplayPaneContainer) {
|
.getActiveEditorAs(IDisplayPaneContainer.class);
|
||||||
|
if (part != null) {
|
||||||
IDisplayPane activePane = ((IDisplayPaneContainer) part)
|
IDisplayPane activePane = ((IDisplayPaneContainer) part)
|
||||||
.getActiveDisplayPane();
|
.getActiveDisplayPane();
|
||||||
List<MPELegendResource> rscs = activePane.getDescriptor()
|
List<MPELegendResource> rscs = activePane.getDescriptor()
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
|
||||||
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
|
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
|
||||||
|
|
||||||
import com.raytheon.uf.viz.ui.menus.DiscoverMenuContributions;
|
import com.raytheon.uf.viz.ui.menus.DiscoverMenuContributions;
|
||||||
|
import com.raytheon.uf.viz.ui.menus.widgets.tearoff.TearOffMenuListener;
|
||||||
import com.raytheon.viz.ui.dialogs.ModeListener;
|
import com.raytheon.viz.ui.dialogs.ModeListener;
|
||||||
import com.raytheon.viz.ui.perspectives.AbstractVizPerspectiveManager;
|
import com.raytheon.viz.ui.perspectives.AbstractVizPerspectiveManager;
|
||||||
import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
|
import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
|
||||||
|
@ -135,6 +136,9 @@ public class VizWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
|
||||||
if (perspective != null) {
|
if (perspective != null) {
|
||||||
listener.perspectiveActivated(page, perspective);
|
listener.perspectiveActivated(page, perspective);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new TearOffMenuListener(VizActionBarAdvisor.getInstance(window)
|
||||||
|
.getMenuManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
import org.eclipse.jface.action.ContributionItem;
|
import org.eclipse.jface.action.ContributionItem;
|
||||||
import org.eclipse.jface.action.IContributionItem;
|
import org.eclipse.jface.action.IContributionItem;
|
||||||
|
@ -206,7 +207,7 @@ public abstract class AbstractVizPerspectiveManager implements
|
||||||
public AbstractVizPerspectiveManager() {
|
public AbstractVizPerspectiveManager() {
|
||||||
// new up a tool manager for the perspective
|
// new up a tool manager for the perspective
|
||||||
toolManager = new ModalToolManager();
|
toolManager = new ModalToolManager();
|
||||||
perspectiveDialogs = new ArrayList<IPerspectiveSpecificDialog>();
|
perspectiveDialogs = new CopyOnWriteArrayList<IPerspectiveSpecificDialog>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -95,8 +95,9 @@ public abstract class AbstractTool extends AbstractHandler implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEditorPart eventEditor = HandlerUtil.getActiveEditor(event);
|
IEditorPart eventEditor = (IEditorPart) EditorUtil
|
||||||
if (eventEditor != null && eventEditor instanceof IDisplayPaneContainer) {
|
.getActiveEditorAs(IDisplayPaneContainer.class);
|
||||||
|
if (eventEditor != null) {
|
||||||
this.editor = (IDisplayPaneContainer) eventEditor;
|
this.editor = (IDisplayPaneContainer) eventEditor;
|
||||||
} else {
|
} else {
|
||||||
IWorkbenchWindow window = HandlerUtil
|
IWorkbenchWindow window = HandlerUtil
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package com.raytheon.viz.volumebrowser.vbui;
|
package com.raytheon.viz.volumebrowser.vbui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.jface.action.IContributionItem;
|
import org.eclipse.jface.action.IContributionItem;
|
||||||
|
@ -33,8 +34,6 @@ import org.eclipse.swt.widgets.ToolItem;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.menus.IMenuService;
|
import org.eclipse.ui.menus.IMenuService;
|
||||||
|
|
||||||
import com.raytheon.uf.viz.ui.menus.widgets.IncludeContributionItem;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Implementation of multiline toolbars. Use add and populate to build a toolbar
|
* Implementation of multiline toolbars. Use add and populate to build a toolbar
|
||||||
|
@ -149,21 +148,6 @@ public class MultiToolbar extends Composite {
|
||||||
ms.populateContributionManager(tbm, location);
|
ms.populateContributionManager(tbm, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<IContributionItem> getContributionItems(
|
|
||||||
IContributionItem[] items) {
|
|
||||||
List<IContributionItem> list = new ArrayList<IContributionItem>();
|
|
||||||
for (IContributionItem item : items) {
|
|
||||||
if (item instanceof IncludeContributionItem) {
|
|
||||||
IncludeContributionItem includeItem = (IncludeContributionItem) item;
|
|
||||||
list.addAll(getContributionItems(includeItem
|
|
||||||
.getContributionItems()));
|
|
||||||
} else {
|
|
||||||
list.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* split into multiple bars, this is probably why you are using this class.
|
* split into multiple bars, this is probably why you are using this class.
|
||||||
*
|
*
|
||||||
|
@ -173,7 +157,7 @@ public class MultiToolbar extends Composite {
|
||||||
this.numBars = numBars;
|
this.numBars = numBars;
|
||||||
List<IContributionItem> items = new ArrayList<IContributionItem>();
|
List<IContributionItem> items = new ArrayList<IContributionItem>();
|
||||||
for (ToolBarManager tbm : tbms) {
|
for (ToolBarManager tbm : tbms) {
|
||||||
items.addAll(getContributionItems(tbm.getItems()));
|
items.addAll(Arrays.asList(tbm.getItems()));
|
||||||
}
|
}
|
||||||
disposeToolbars();
|
disposeToolbars();
|
||||||
splitContruibutionItems(items, numBars);
|
splitContruibutionItems(items, numBars);
|
||||||
|
|
Loading…
Add table
Reference in a new issue