diff --git a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/DataListsProdTableComp.java b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/DataListsProdTableComp.java index 9377500140..521b0076a5 100644 --- a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/DataListsProdTableComp.java +++ b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/DataListsProdTableComp.java @@ -84,6 +84,8 @@ import com.raytheon.viz.volumebrowser.xml.VbSourceList; * Jul 31, 2012 #875 rferrel Now uses markers. * Sep 26, 2012 #1216 rferrel Change listener added to update * points menu. + * Jan 14, 2013 #1516 rferrel Remove listeners on dispose and specify + * Data Selection in Points Tool Action. * * * @@ -95,8 +97,22 @@ public class DataListsProdTableComp extends Composite implements private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(DataListsProdTableComp.class); + /** + * Listener to update planes current point menu. + */ private IPointChangedListener pointChangeListener; + /** + * Listener to trigger reset. + */ + private IPointChangedListener resetPointChangeListener; + + /** + * Listener to trigger reset. + */ + + private IToolChangedListener resetToolChangeListener; + /** * Perform a regular expression find instead of simply completing the input */ @@ -112,6 +128,13 @@ public class DataListsProdTableComp extends Composite implements super(proposals); } + /* + * (non-Javadoc) + * + * @see + * net.sf.swtaddons.autocomplete.AutocompleteContentProposalProvider + * #getMatchingProposals(java.lang.String[], java.lang.String) + */ @Override protected List getMatchingProposals(String[] proposals, String contents) { @@ -381,10 +404,19 @@ public class DataListsProdTableComp extends Composite implements } + /** + * Dynamic controls for populating the sources' list. + */ private SelectionControl sourceControl; + /** + * Dynamic controls for populating the fields' list. + */ private SelectionControl fieldControl; + /** + * Dynamic controls for populating the planes' list. + */ private SelectionControl planeControl; /** @@ -437,28 +469,33 @@ public class DataListsProdTableComp extends Composite implements initializeComponents(); + resetToolChangeListener = new IToolChangedListener() { + @Override + public void toolChanged() { + VizApp.runAsync(new Runnable() { + public void run() { + updateMenuInventory(); + } + }); + } + }; + ToolsDataManager.getInstance().addBaselinesChangedListener( - new IToolChangedListener() { - @Override - public void toolChanged() { - VizApp.runAsync(new Runnable() { - public void run() { - updateMenuInventory(); - } - }); + resetToolChangeListener); + + resetPointChangeListener = new IPointChangedListener() { + @Override + public void pointChanged() { + VizApp.runAsync(new Runnable() { + public void run() { + updateMenuInventory(); } }); + } + }; + PointsDataManager.getInstance().addPointsChangedListener( - new IPointChangedListener() { - @Override - public void pointChanged() { - VizApp.runAsync(new Runnable() { - public void run() { - updateMenuInventory(); - } - }); - } - }); + resetPointChangeListener); } /** @@ -838,7 +875,7 @@ public class DataListsProdTableComp extends Composite implements tbContrib.xml.id = "SoundingPointsButton"; final PointToolAction pta = new PointToolAction("Points", - pointDisplayString); + pointDisplayString, currentDataSelection); planeControl.toolbar.add(pta); pointChangeListener = new IPointChangedListener() { @@ -926,6 +963,18 @@ public class DataListsProdTableComp extends Composite implements return currentDataSelection; } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.volumebrowser.vbui.IDataMenuAction#setActiveDataSelection + * ( + * com.raytheon.viz.volumebrowser.vbui.DataListsProdTableComp.DataSelection) + */ + public void setActiveDataSelection(DataSelection dataSelection) { + currentDataSelection = dataSelection; + } + /** * Add product to the products table. */ @@ -1063,7 +1112,6 @@ public class DataListsProdTableComp extends Composite implements String[] selectedPlanes = planeControl.list.getSelectedKeys(); DataCatalogManager.getDataCatalogManager().updateAvailableData( selectedSources, selectedFields, selectedPlanes); - } /** @@ -1166,8 +1214,28 @@ public class DataListsProdTableComp extends Composite implements markAvailableData(plane, planeControl); } + /** + * Obtain the product table. + * + * @return prodTable + */ public ProductTableComp getProductTable() { return prodTable; } + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.widgets.Widget#dispose() + */ + @Override + public void dispose() { + ToolsDataManager.getInstance().removeBaselinesChangedListener( + resetToolChangeListener); + + PointsDataManager.getInstance().removePointsChangedListener( + resetPointChangeListener); + + super.dispose(); + } } diff --git a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/IDataMenuAction.java b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/IDataMenuAction.java index 1fbfe68c1c..ac3325853e 100644 --- a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/IDataMenuAction.java +++ b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/IDataMenuAction.java @@ -33,7 +33,7 @@ import com.raytheon.viz.volumebrowser.xml.MenuContribution; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * May 27, 2009 #2161 lvenable Initial creation - * + * Jan 24, 2013 #1516 rferrel Added setActiveDataSelection * * * @author lvenable @@ -57,4 +57,11 @@ public interface IDataMenuAction { * @return The active data selection. */ DataSelection getActiveDataSelection(); + + /** + * Set the active data selection. + * + * @param dataSelection + */ + void setActiveDataSelection(DataSelection dataSelection); } diff --git a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/MenuItemManager.java b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/MenuItemManager.java index b2d15b0a90..6e2fa3bbf1 100644 --- a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/MenuItemManager.java +++ b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/MenuItemManager.java @@ -41,6 +41,8 @@ import com.raytheon.viz.volumebrowser.xml.MenuContribution; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * May 27, 2009 #2161 lvenable Initial creation + * Jan 24, 2013 #1516 rferrel Methods to change/get + * Active Data Selection. * * * @@ -462,8 +464,7 @@ public class MenuItemManager { } } - /* - * + /** * * Convenience methods to print all of the data. * @@ -480,6 +481,11 @@ public class MenuItemManager { printMenu(planesMenuItemMap); } + /** + * Print out the entries of the desired map. + * + * @param map + */ private void printMenu(HashMap> map) { Set keys = map.keySet(); @@ -533,7 +539,9 @@ public class MenuItemManager { } /** - * @return + * Obtain all the keys for lat/lon entries of the Planes Menu Item map. + * + * @return latLonKeys * */ public List getLatLonKeys() { @@ -557,7 +565,23 @@ public class MenuItemManager { latLonKeys.add("LONS"); return latLonKeys; - } + /** + * Obtain the Active Data Selection. + * + * @return dataSelection + */ + public DataSelection getActiveDataSelection() { + return menuActionCB.getActiveDataSelection(); + } + + /** + * Set the Active Data Selection. + * + * @param dataSelection + */ + public void setActiveDataSelection(DataSelection dataSelection) { + menuActionCB.setActiveDataSelection(dataSelection); + } } diff --git a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/PointToolAction.java b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/PointToolAction.java index 385a6c9b11..e88f410df8 100644 --- a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/PointToolAction.java +++ b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/vbui/PointToolAction.java @@ -36,6 +36,7 @@ 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.vbui.DataListsProdTableComp.DataSelection; import com.raytheon.viz.volumebrowser.widget.MenuContributionItem; import com.raytheon.viz.volumebrowser.xml.MenuContribution; @@ -52,6 +53,7 @@ import com.raytheon.viz.volumebrowser.xml.MenuContribution; * Sep 25, 2012 1215 rferrel Clicking anywhere on the Point button * now opens the menu. * Sep 26, 2012 1216 rferrel resetMenu method added. + * Jan 24, 2013 1516 rferrel Change Active Data Selection prior to filling menus. * * * @@ -60,21 +62,57 @@ import com.raytheon.viz.volumebrowser.xml.MenuContribution; */ public class PointToolAction extends Action implements IMenuCreator { + + /** + * Menu to display the parentNode's children. + */ private Menu menu; - private String pointNames; + /** + * Type of name to prepend to a point's name. + */ + private final String pointNames; - private IPointNode parentNode; + /** + * The Data Selection type that requested the menu. + */ + private final DataSelection dataSelection; - private PointsDataManager dataManager; + /** + * The group node associated with this action. + */ + private final IPointNode parentNode; - public PointToolAction(String text, String pointNames) { - this(text, pointNames, null); + /** + * Manager to get point information. + */ + private final PointsDataManager dataManager; + + /** + * Constructor. + * + * @param text + * @param pointNames + * @param dataSelection + */ + public PointToolAction(String text, String pointNames, + DataSelection dataSelection) { + this(text, pointNames, dataSelection, null); } - public PointToolAction(String text, String pointNames, IPointNode parentNode) { + /** + * Private constructor used recursively to generate menus for groups. + * + * @param text + * @param pointNames + * @param dataSelecion + * @param parentNode + */ + private PointToolAction(String text, String pointNames, + DataSelection dataSelecion, IPointNode parentNode) { super(text, SWT.DROP_DOWN); this.pointNames = pointNames; + this.dataSelection = dataSelecion; this.parentNode = parentNode; this.dataManager = PointsDataManager.getInstance(); } @@ -93,7 +131,6 @@ public class PointToolAction extends Action implements IMenuCreator { getMenu(item.getParent()); } menu.setVisible(true); - super.runWithEvent(event); } /* @@ -118,6 +155,7 @@ public class PointToolAction extends Action implements IMenuCreator { @Override public Menu getMenu(Control parent) { if (menu == null) { + MenuItemManager.getInstance().setActiveDataSelection(dataSelection); menu = new Menu(parent); fillMenu(menu); } @@ -134,7 +172,8 @@ public class PointToolAction extends Action implements IMenuCreator { */ @Override public Menu getMenu(Menu parent) { - if (menu != null) { + if (menu == null) { + MenuItemManager.getInstance().setActiveDataSelection(dataSelection); menu = new Menu(parent); fillMenu(menu); } @@ -159,6 +198,11 @@ public class PointToolAction extends Action implements IMenuCreator { } } + /** + * Populates the menu with the children of the parentNode. + * + * @param menu + */ private void fillMenu(final Menu menu) { List nodes = dataManager.getChildren(parentNode); @@ -166,8 +210,8 @@ public class PointToolAction extends Action implements IMenuCreator { for (IPointNode node : nodes) { if (node.isGroup()) { if (dataManager.getChildren(node).size() > 0) { - final PointToolAction submenu = new PointToolAction("" - + node.getName(), pointNames, node); + final PointToolAction submenu = new PointToolAction( + node.getName(), pointNames, dataSelection, node); submenu.menu = new Menu(menu); menu.addDisposeListener(new DisposeListener() { @@ -199,6 +243,9 @@ public class PointToolAction extends Action implements IMenuCreator { return this; } + /** + * This class the details for placing a point in the desired menu. + */ private class TitleContributionItem extends ContributionItem { private String text; @@ -218,13 +265,6 @@ public class PointToolAction extends Action implements IMenuCreator { this.text = text; } - /** - * @return the text - */ - public String getText() { - return text; - } - /* * (non-Javadoc) *