Merge "Issue #1216 Added Point Change Listeners to update the Volume Browser menus. Clean up code to properly dispose of menus." into development
Former-commit-id:dcf6d77966
[formerly56b84c6546
] [formerlydcf6d77966
[formerly56b84c6546
] [formerly2446629c9f
[formerly 9eca9ad17e3e9f4705c20562e4260c3f5ced6f2d]]] Former-commit-id:2446629c9f
Former-commit-id:26c85e7b4f
[formerlyb54f1d8184
] Former-commit-id:9a3005a433
This commit is contained in:
commit
74cb9e8817
3 changed files with 80 additions and 90 deletions
|
@ -22,7 +22,6 @@ package com.raytheon.viz.volumebrowser.vbui;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -51,11 +50,6 @@ import org.eclipse.swt.widgets.Label;
|
|||
|
||||
import com.raytheon.uf.common.dataplugin.grib.util.GribModelLookup;
|
||||
import com.raytheon.uf.common.dataplugin.grib.util.GridModel;
|
||||
import com.raytheon.uf.common.menus.xml.CommonAbstractMenuContribution;
|
||||
import com.raytheon.uf.common.menus.xml.CommonMenuContribution;
|
||||
import com.raytheon.uf.common.menus.xml.CommonSubmenuContribution;
|
||||
import com.raytheon.uf.common.menus.xml.CommonTitleContribution;
|
||||
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;
|
||||
|
@ -63,8 +57,6 @@ import com.raytheon.uf.viz.core.VizApp;
|
|||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.points.IPointChangedListener;
|
||||
import com.raytheon.uf.viz.points.PointsDataManager;
|
||||
import com.raytheon.uf.viz.points.data.IPointNode;
|
||||
import com.raytheon.uf.viz.ui.menus.widgets.SubmenuContributionItem;
|
||||
import com.raytheon.viz.awipstools.IToolChangedListener;
|
||||
import com.raytheon.viz.awipstools.ToolsDataManager;
|
||||
import com.raytheon.viz.volumebrowser.datacatalog.DataCatalogManager;
|
||||
|
@ -90,6 +82,8 @@ import com.raytheon.viz.volumebrowser.xml.VbSourceList;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* May 12, 2009 #2161 lvenable Initial creation
|
||||
* Jul 31, 2012 #875 rferrel Now uses markers.
|
||||
* Sep 26, 2012 #1216 rferrel Change listener added to update
|
||||
* points menu.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -101,6 +95,8 @@ public class DataListsProdTableComp extends Composite implements
|
|||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(DataListsProdTableComp.class);
|
||||
|
||||
private IPointChangedListener pointChangeListener;
|
||||
|
||||
/**
|
||||
* Perform a regular expression find instead of simply completing the input
|
||||
*/
|
||||
|
@ -782,7 +778,7 @@ public class DataListsProdTableComp extends Composite implements
|
|||
}
|
||||
|
||||
/**
|
||||
* Create the Planes tollbar menus.
|
||||
* Create the Planes toolbar menus.
|
||||
*
|
||||
* @param setting
|
||||
* The selected "setting".
|
||||
|
@ -799,6 +795,11 @@ public class DataListsProdTableComp extends Composite implements
|
|||
currentDataSelection = DataSelection.PLANES;
|
||||
|
||||
planeControl.toolbar.disposeToolbars();
|
||||
if (pointChangeListener != null) {
|
||||
PointsDataManager.getInstance().removePointsChangedListener(
|
||||
pointChangeListener);
|
||||
pointChangeListener = null;
|
||||
}
|
||||
|
||||
String pointDisplayString = null;
|
||||
switch (setting) {
|
||||
|
@ -835,27 +836,21 @@ public class DataListsProdTableComp extends Composite implements
|
|||
ToolBarContribution tbContrib = new ToolBarContribution();
|
||||
tbContrib.xml.toolItemText = "Points";
|
||||
tbContrib.xml.id = "SoundingPointsButton";
|
||||
List<IContributionItem> items = new ArrayList<IContributionItem>();
|
||||
|
||||
List<IPointNode> children = PointsDataManager.getInstance()
|
||||
.getChildren(null);
|
||||
final PointToolAction pta = new PointToolAction("Points",
|
||||
pointDisplayString);
|
||||
planeControl.toolbar.add(pta);
|
||||
|
||||
for (IPointNode child : children) {
|
||||
if (child.isGroup()) {
|
||||
IContributionItem item = createSubmenuContributionItem(
|
||||
child, pointDisplayString);
|
||||
items.add(item);
|
||||
} else {
|
||||
MenuContribution mContrib = new MenuContribution();
|
||||
mContrib.xml.key = "Point" + child.getName();
|
||||
mContrib.xml.menuText = pointDisplayString + " "
|
||||
+ child.getName();
|
||||
items.add(new MenuContributionItem(mContrib));
|
||||
pointChangeListener = new IPointChangedListener() {
|
||||
|
||||
@Override
|
||||
public void pointChanged() {
|
||||
MenuItemManager.getInstance().clearPlanesMap();
|
||||
pta.resetMenu();
|
||||
}
|
||||
}
|
||||
planeControl.toolbar.add(new PointToolAction("Points",
|
||||
pointDisplayString));
|
||||
|
||||
};
|
||||
PointsDataManager.getInstance().addPointsChangedListener(
|
||||
pointChangeListener);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -865,68 +860,6 @@ public class DataListsProdTableComp extends Composite implements
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param pointDisplayString
|
||||
* @return
|
||||
*/
|
||||
private SubmenuContributionItem createSubmenuContributionItem(
|
||||
IPointNode parent, String pointDisplayString) {
|
||||
List<CommonAbstractMenuContribution> items = new ArrayList<CommonAbstractMenuContribution>();
|
||||
List<IPointNode> children = PointsDataManager.getInstance()
|
||||
.getChildren(parent);
|
||||
for (IPointNode child : children) {
|
||||
if (child.isGroup()) {
|
||||
CommonSubmenuContribution submenu = new CommonSubmenuContribution();
|
||||
submenu.menuText = child.getName();
|
||||
submenu.id = child.getName();
|
||||
submenu.contributions = createContributions(child,
|
||||
pointDisplayString);
|
||||
items.add(submenu);
|
||||
} else {
|
||||
CommonMenuContribution menuCont = new CommonMenuContribution();
|
||||
menuCont.key = "Point" + child.getName();
|
||||
menuCont.menuText = pointDisplayString + " " + child.getName();
|
||||
menuCont.id = child.getName();
|
||||
items.add(menuCont);
|
||||
}
|
||||
}
|
||||
SubmenuContributionItem item = new SubmenuContributionItem(
|
||||
new VariableSubstitution[0], parent.getName(),
|
||||
items.toArray(new CommonAbstractMenuContribution[0]),
|
||||
new HashSet<String>());
|
||||
return item;
|
||||
}
|
||||
|
||||
private CommonAbstractMenuContribution[] createContributions(
|
||||
IPointNode parent, String pointDisplayString) {
|
||||
List<IPointNode> children = PointsDataManager.getInstance()
|
||||
.getChildren(parent);
|
||||
|
||||
CommonAbstractMenuContribution[] contributions = new CommonAbstractMenuContribution[children
|
||||
.size()];
|
||||
|
||||
int index = 0;
|
||||
for (IPointNode child : children) {
|
||||
CommonTitleContribution contribution = new CommonTitleContribution();
|
||||
if (child.isGroup()) {
|
||||
CommonSubmenuContribution submenu = new CommonSubmenuContribution();
|
||||
submenu.menuText = child.getName();
|
||||
submenu.id = child.getName();
|
||||
submenu.contributions = createContributions(child,
|
||||
pointDisplayString);
|
||||
} else {
|
||||
contribution.titleText = pointDisplayString + " "
|
||||
+ child.getName();
|
||||
contribution.id = child.getName();
|
||||
CommonMenuContribution menuCont = new CommonMenuContribution();
|
||||
}
|
||||
contributions[index] = contribution;
|
||||
++index;
|
||||
}
|
||||
return contributions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Sources, Fields, and Planes toolbar items.
|
||||
*
|
||||
|
|
|
@ -26,11 +26,14 @@ import org.eclipse.jface.action.ActionContributionItem;
|
|||
import org.eclipse.jface.action.ContributionItem;
|
||||
import org.eclipse.jface.action.IMenuCreator;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.ToolItem;
|
||||
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.points.PointsDataManager;
|
||||
import com.raytheon.uf.viz.points.data.IPointNode;
|
||||
import com.raytheon.viz.volumebrowser.widget.MenuContributionItem;
|
||||
|
@ -48,6 +51,7 @@ import com.raytheon.viz.volumebrowser.xml.MenuContribution;
|
|||
* Jul 29, 2012 rferrel Initial creation
|
||||
* Sep 25, 2012 1215 rferrel Clicking anywhere on the Point button
|
||||
* now opens the menu.
|
||||
* Sep 26, 2012 1216 rferrel resetMenu method added.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -137,6 +141,24 @@ public class PointToolAction extends Action implements IMenuCreator {
|
|||
return menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* This forces the drop down menu to to be recreated the next time the menu
|
||||
* is needed.
|
||||
*/
|
||||
public void resetMenu() {
|
||||
if (menu != null) {
|
||||
final Menu oldMenu = menu;
|
||||
menu = null;
|
||||
VizApp.runAsync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
oldMenu.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void fillMenu(final Menu menu) {
|
||||
List<IPointNode> nodes = dataManager.getChildren(parentNode);
|
||||
|
||||
|
@ -144,9 +166,16 @@ public class PointToolAction extends Action implements IMenuCreator {
|
|||
for (IPointNode node : nodes) {
|
||||
if (node.isGroup()) {
|
||||
if (dataManager.getChildren(node).size() > 0) {
|
||||
PointToolAction submenu = new PointToolAction(""
|
||||
final PointToolAction submenu = new PointToolAction(""
|
||||
+ node.getName(), pointNames, node);
|
||||
submenu.menu = new Menu(menu);
|
||||
menu.addDisposeListener(new DisposeListener() {
|
||||
|
||||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
submenu.menu.dispose();
|
||||
}
|
||||
});
|
||||
submenu.fillMenu(submenu.menu);
|
||||
ActionContributionItem item = new ActionContributionItem(
|
||||
submenu);
|
||||
|
|
|
@ -44,10 +44,12 @@ import org.eclipse.ui.IWorkbenchWindow;
|
|||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.commands.ICommandService;
|
||||
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.core.VizConstants;
|
||||
import com.raytheon.uf.viz.core.globals.IGlobalChangedListener;
|
||||
import com.raytheon.uf.viz.core.globals.VizGlobalsManager;
|
||||
import com.raytheon.uf.viz.d2d.core.time.LoadMode;
|
||||
import com.raytheon.uf.viz.points.IPointChangedListener;
|
||||
import com.raytheon.uf.viz.points.PointsDataManager;
|
||||
import com.raytheon.uf.viz.points.data.IPointNode;
|
||||
import com.raytheon.uf.viz.points.data.Point;
|
||||
|
@ -68,6 +70,8 @@ import com.raytheon.viz.volumebrowser.vbui.VBMenuBarItemsMgr.ViewMenu;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* May 12, 2009 #2161 lvenable Initial creation
|
||||
* Jul 21, 2012 #875 rferrel Now uses points.
|
||||
* Sep 26, 2012 #1216 rferrel Point Change listener added to update
|
||||
* the Time Series Point menu.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -121,6 +125,8 @@ public class VolumeBrowserDlg extends CaveSWTDialog implements
|
|||
|
||||
private boolean initialized = false;
|
||||
|
||||
private IPointChangedListener pointChangeListener;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -645,6 +651,12 @@ public class VolumeBrowserDlg extends CaveSWTDialog implements
|
|||
settingsMI.setText(mi.getText());
|
||||
settingsMI.setData(mi.getData());
|
||||
|
||||
if (pointChangeListener != null) {
|
||||
PointsDataManager.getInstance().removePointsChangedListener(
|
||||
pointChangeListener);
|
||||
pointChangeListener = null;
|
||||
}
|
||||
|
||||
if (spaceTimeMI != null) {
|
||||
previousSpaceTimeMenu = (SpaceTimeMenu) spaceTimeMI.getData();
|
||||
spaceTimeMI.dispose();
|
||||
|
@ -685,6 +697,22 @@ public class VolumeBrowserDlg extends CaveSWTDialog implements
|
|||
// Do nothing. No extra menus need to be created.
|
||||
} else if (currentSetting == ViewMenu.TIMESERIES) {
|
||||
createPointsMenu();
|
||||
pointChangeListener = new IPointChangedListener() {
|
||||
|
||||
@Override
|
||||
public void pointChanged() {
|
||||
VizApp.runAsync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
pointsMI.dispose();
|
||||
createPointsMenu();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
PointsDataManager.getInstance().addPointsChangedListener(
|
||||
pointChangeListener);
|
||||
}
|
||||
|
||||
dialogSettings.setViewSelection(currentSetting);
|
||||
|
|
Loading…
Add table
Reference in a new issue