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.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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.GribModelLookup;
|
||||||
import com.raytheon.uf.common.dataplugin.grib.util.GridModel;
|
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.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
|
@ -63,8 +57,6 @@ import com.raytheon.uf.viz.core.VizApp;
|
||||||
import com.raytheon.uf.viz.core.exception.VizException;
|
import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
import com.raytheon.uf.viz.points.IPointChangedListener;
|
import com.raytheon.uf.viz.points.IPointChangedListener;
|
||||||
import com.raytheon.uf.viz.points.PointsDataManager;
|
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.IToolChangedListener;
|
||||||
import com.raytheon.viz.awipstools.ToolsDataManager;
|
import com.raytheon.viz.awipstools.ToolsDataManager;
|
||||||
import com.raytheon.viz.volumebrowser.datacatalog.DataCatalogManager;
|
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
|
* May 12, 2009 #2161 lvenable Initial creation
|
||||||
* Jul 31, 2012 #875 rferrel Now uses markers.
|
* Jul 31, 2012 #875 rferrel Now uses markers.
|
||||||
|
* Sep 26, 2012 #1216 rferrel Change listener added to update
|
||||||
|
* points menu.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -101,6 +95,8 @@ public class DataListsProdTableComp extends Composite implements
|
||||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
.getHandler(DataListsProdTableComp.class);
|
.getHandler(DataListsProdTableComp.class);
|
||||||
|
|
||||||
|
private IPointChangedListener pointChangeListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a regular expression find instead of simply completing the input
|
* 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
|
* @param setting
|
||||||
* The selected "setting".
|
* The selected "setting".
|
||||||
|
@ -799,6 +795,11 @@ public class DataListsProdTableComp extends Composite implements
|
||||||
currentDataSelection = DataSelection.PLANES;
|
currentDataSelection = DataSelection.PLANES;
|
||||||
|
|
||||||
planeControl.toolbar.disposeToolbars();
|
planeControl.toolbar.disposeToolbars();
|
||||||
|
if (pointChangeListener != null) {
|
||||||
|
PointsDataManager.getInstance().removePointsChangedListener(
|
||||||
|
pointChangeListener);
|
||||||
|
pointChangeListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
String pointDisplayString = null;
|
String pointDisplayString = null;
|
||||||
switch (setting) {
|
switch (setting) {
|
||||||
|
@ -835,27 +836,21 @@ public class DataListsProdTableComp extends Composite implements
|
||||||
ToolBarContribution tbContrib = new ToolBarContribution();
|
ToolBarContribution tbContrib = new ToolBarContribution();
|
||||||
tbContrib.xml.toolItemText = "Points";
|
tbContrib.xml.toolItemText = "Points";
|
||||||
tbContrib.xml.id = "SoundingPointsButton";
|
tbContrib.xml.id = "SoundingPointsButton";
|
||||||
List<IContributionItem> items = new ArrayList<IContributionItem>();
|
|
||||||
|
|
||||||
List<IPointNode> children = PointsDataManager.getInstance()
|
final PointToolAction pta = new PointToolAction("Points",
|
||||||
.getChildren(null);
|
pointDisplayString);
|
||||||
|
planeControl.toolbar.add(pta);
|
||||||
|
|
||||||
for (IPointNode child : children) {
|
pointChangeListener = new IPointChangedListener() {
|
||||||
if (child.isGroup()) {
|
|
||||||
IContributionItem item = createSubmenuContributionItem(
|
@Override
|
||||||
child, pointDisplayString);
|
public void pointChanged() {
|
||||||
items.add(item);
|
MenuItemManager.getInstance().clearPlanesMap();
|
||||||
} else {
|
pta.resetMenu();
|
||||||
MenuContribution mContrib = new MenuContribution();
|
|
||||||
mContrib.xml.key = "Point" + child.getName();
|
|
||||||
mContrib.xml.menuText = pointDisplayString + " "
|
|
||||||
+ child.getName();
|
|
||||||
items.add(new MenuContributionItem(mContrib));
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
planeControl.toolbar.add(new PointToolAction("Points",
|
PointsDataManager.getInstance().addPointsChangedListener(
|
||||||
pointDisplayString));
|
pointChangeListener);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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.
|
* 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.ContributionItem;
|
||||||
import org.eclipse.jface.action.IMenuCreator;
|
import org.eclipse.jface.action.IMenuCreator;
|
||||||
import org.eclipse.swt.SWT;
|
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.Control;
|
||||||
import org.eclipse.swt.widgets.Event;
|
import org.eclipse.swt.widgets.Event;
|
||||||
import org.eclipse.swt.widgets.Menu;
|
import org.eclipse.swt.widgets.Menu;
|
||||||
import org.eclipse.swt.widgets.ToolItem;
|
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.PointsDataManager;
|
||||||
import com.raytheon.uf.viz.points.data.IPointNode;
|
import com.raytheon.uf.viz.points.data.IPointNode;
|
||||||
import com.raytheon.viz.volumebrowser.widget.MenuContributionItem;
|
import com.raytheon.viz.volumebrowser.widget.MenuContributionItem;
|
||||||
|
@ -48,6 +51,7 @@ import com.raytheon.viz.volumebrowser.xml.MenuContribution;
|
||||||
* Jul 29, 2012 rferrel Initial creation
|
* Jul 29, 2012 rferrel Initial creation
|
||||||
* Sep 25, 2012 1215 rferrel Clicking anywhere on the Point button
|
* Sep 25, 2012 1215 rferrel Clicking anywhere on the Point button
|
||||||
* now opens the menu.
|
* now opens the menu.
|
||||||
|
* Sep 26, 2012 1216 rferrel resetMenu method added.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -137,6 +141,24 @@ public class PointToolAction extends Action implements IMenuCreator {
|
||||||
return menu;
|
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) {
|
private void fillMenu(final Menu menu) {
|
||||||
List<IPointNode> nodes = dataManager.getChildren(parentNode);
|
List<IPointNode> nodes = dataManager.getChildren(parentNode);
|
||||||
|
|
||||||
|
@ -144,9 +166,16 @@ public class PointToolAction extends Action implements IMenuCreator {
|
||||||
for (IPointNode node : nodes) {
|
for (IPointNode node : nodes) {
|
||||||
if (node.isGroup()) {
|
if (node.isGroup()) {
|
||||||
if (dataManager.getChildren(node).size() > 0) {
|
if (dataManager.getChildren(node).size() > 0) {
|
||||||
PointToolAction submenu = new PointToolAction(""
|
final PointToolAction submenu = new PointToolAction(""
|
||||||
+ node.getName(), pointNames, node);
|
+ node.getName(), pointNames, node);
|
||||||
submenu.menu = new Menu(menu);
|
submenu.menu = new Menu(menu);
|
||||||
|
menu.addDisposeListener(new DisposeListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetDisposed(DisposeEvent e) {
|
||||||
|
submenu.menu.dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
submenu.fillMenu(submenu.menu);
|
submenu.fillMenu(submenu.menu);
|
||||||
ActionContributionItem item = new ActionContributionItem(
|
ActionContributionItem item = new ActionContributionItem(
|
||||||
submenu);
|
submenu);
|
||||||
|
|
|
@ -44,10 +44,12 @@ import org.eclipse.ui.IWorkbenchWindow;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.commands.ICommandService;
|
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.VizConstants;
|
||||||
import com.raytheon.uf.viz.core.globals.IGlobalChangedListener;
|
import com.raytheon.uf.viz.core.globals.IGlobalChangedListener;
|
||||||
import com.raytheon.uf.viz.core.globals.VizGlobalsManager;
|
import com.raytheon.uf.viz.core.globals.VizGlobalsManager;
|
||||||
import com.raytheon.uf.viz.d2d.core.time.LoadMode;
|
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.PointsDataManager;
|
||||||
import com.raytheon.uf.viz.points.data.IPointNode;
|
import com.raytheon.uf.viz.points.data.IPointNode;
|
||||||
import com.raytheon.uf.viz.points.data.Point;
|
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
|
* May 12, 2009 #2161 lvenable Initial creation
|
||||||
* Jul 21, 2012 #875 rferrel Now uses points.
|
* 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>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -121,6 +125,8 @@ public class VolumeBrowserDlg extends CaveSWTDialog implements
|
||||||
|
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
|
|
||||||
|
private IPointChangedListener pointChangeListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
@ -645,6 +651,12 @@ public class VolumeBrowserDlg extends CaveSWTDialog implements
|
||||||
settingsMI.setText(mi.getText());
|
settingsMI.setText(mi.getText());
|
||||||
settingsMI.setData(mi.getData());
|
settingsMI.setData(mi.getData());
|
||||||
|
|
||||||
|
if (pointChangeListener != null) {
|
||||||
|
PointsDataManager.getInstance().removePointsChangedListener(
|
||||||
|
pointChangeListener);
|
||||||
|
pointChangeListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (spaceTimeMI != null) {
|
if (spaceTimeMI != null) {
|
||||||
previousSpaceTimeMenu = (SpaceTimeMenu) spaceTimeMI.getData();
|
previousSpaceTimeMenu = (SpaceTimeMenu) spaceTimeMI.getData();
|
||||||
spaceTimeMI.dispose();
|
spaceTimeMI.dispose();
|
||||||
|
@ -685,6 +697,22 @@ public class VolumeBrowserDlg extends CaveSWTDialog implements
|
||||||
// Do nothing. No extra menus need to be created.
|
// Do nothing. No extra menus need to be created.
|
||||||
} else if (currentSetting == ViewMenu.TIMESERIES) {
|
} else if (currentSetting == ViewMenu.TIMESERIES) {
|
||||||
createPointsMenu();
|
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);
|
dialogSettings.setViewSelection(currentSetting);
|
||||||
|
|
Loading…
Add table
Reference in a new issue