diff --git a/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/KmlExportDialog.java b/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/KmlExportDialog.java index 137860d4f7..96d1ecc296 100644 --- a/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/KmlExportDialog.java +++ b/cave/com.raytheon.uf.viz.kml.export/src/com/raytheon/uf/viz/kml/export/KmlExportDialog.java @@ -59,6 +59,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Jun 05, 2012 bsteffen Initial creation * Jan 23, 2014 2703 bsteffen Enable subclasses to add custom frame * selection options. + * Apr 03, 2014 2847 dgilling Add some additional methods for + * use by sub-classes. * * * @@ -169,6 +171,7 @@ public class KmlExportDialog extends CaveSWTDialog { Button button = new Button(group, SWT.PUSH); button.setText("Browse ..."); button.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { selectDestinationFile(); } @@ -383,7 +386,7 @@ public class KmlExportDialog extends CaveSWTDialog { } } - private void populateProductSubTree(List rscList, + protected void populateProductSubTree(List rscList, final TreeItem parent) { TreeItem[] items = parent != null ? parent.getItems() : productTree .getItems(); @@ -605,4 +608,11 @@ public class KmlExportDialog extends CaveSWTDialog { return true; } + public boolean isExportHiddenSelected() { + return exportHiddenButton.getSelection(); + } + + public boolean isExportMapsSelected() { + return exportMapsButton.getSelection(); + } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/export/kml/GfeKmlExportDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/export/kml/GfeKmlExportDialog.java index 40f636bdd7..ff3f3fa731 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/export/kml/GfeKmlExportDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/export/kml/GfeKmlExportDialog.java @@ -19,17 +19,27 @@ **/ package com.raytheon.viz.gfe.export.kml; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.viz.core.drawables.IRenderableDisplay; +import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.kml.export.KmlExportDialog; import com.raytheon.uf.viz.kml.export.KmlExportOptions; import com.raytheon.uf.viz.kml.export.KmlPane; +import com.raytheon.viz.gfe.core.IParmManager; +import com.raytheon.viz.gfe.core.parm.Parm; import com.raytheon.viz.gfe.export.image.GfeImageExportDialog; +import com.raytheon.viz.gfe.rsc.GFEResource; /** * A custom {@link KmlExportDialog} for GFE which adds on option to use the Grid @@ -42,6 +52,7 @@ import com.raytheon.viz.gfe.export.image.GfeImageExportDialog; * Date Ticket# Engineer Description * ------------- -------- ----------- -------------------------- * Jan 23, 2014 2702 bsteffen Initial creation + * Apr 03, 2014 2847 dgilling Add "Export Selected" option. * * * @@ -53,8 +64,14 @@ public class GfeKmlExportDialog extends KmlExportDialog { protected Button selectedFrameRangeButton; - public GfeKmlExportDialog(Shell shell, KmlExportOptions options) { + protected Button exportSelectParmsButton; + + private final IParmManager parmMgr; + + public GfeKmlExportDialog(Shell shell, KmlExportOptions options, + IParmManager parmMgr) { super(shell, options); + this.parmMgr = parmMgr; } @Override @@ -72,10 +89,10 @@ public class GfeKmlExportDialog extends KmlExportDialog { if (selectedFrameRangeButton.getSelection()) { KmlPane pane = options.getSinglPane(); IRenderableDisplay renderableDispaly = pane.getDisplay(); - - int[] frameRange = GfeImageExportDialog.getSelectedFrameRange(getShell(), - renderableDispaly); - if(frameRange == null){ + + int[] frameRange = GfeImageExportDialog.getSelectedFrameRange( + getShell(), renderableDispaly); + if (frameRange == null) { return; } options.setFirstFrameIndex(frameRange[0]); @@ -84,4 +101,50 @@ public class GfeKmlExportDialog extends KmlExportDialog { super.okPressed(); } + @Override + protected void initializeOptionsGroup(Group group) { + if (parmMgr != null) { + exportSelectParmsButton = new Button(group, SWT.CHECK); + exportSelectParmsButton.setText("Export Selected"); + exportSelectParmsButton.setSelection(true); + exportSelectParmsButton + .setToolTipText("Include only selected weather elements in the selection of products to export."); + exportSelectParmsButton + .addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + populateProductTree(); + } + }); + } + super.initializeOptionsGroup(group); + } + + @Override + protected void populateProductTree() { + boolean exportMaps = isExportMapsSelected(); + boolean exportHidden = isExportHiddenSelected(); + boolean exportSelected = exportSelectParmsButton.getSelection(); + List prelimRscList = options.getSinglPane().getResources( + exportMaps, exportHidden); + + List rscList; + if (exportSelected) { + rscList = new ArrayList(); + List selectedParms = Arrays + .asList(parmMgr.getSelectedParms()); + for (ResourcePair rp : prelimRscList) { + GFEResource gfeRsc = (GFEResource) rp.getResource(); + if (selectedParms.contains(gfeRsc.getParm())) { + rscList.add(rp); + } + } + } else { + rscList = prelimRscList; + } + + populateProductSubTree(rscList, null); + } + } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/export/kml/GfeKmlExportHandler.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/export/kml/GfeKmlExportHandler.java index c0e3b5d842..6d963c8cda 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/export/kml/GfeKmlExportHandler.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/export/kml/GfeKmlExportHandler.java @@ -24,6 +24,9 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.ui.handlers.HandlerUtil; import com.raytheon.uf.viz.kml.export.KmlExportHandler; +import com.raytheon.viz.gfe.core.DataManager; +import com.raytheon.viz.gfe.core.DataManagerUIFactory; +import com.raytheon.viz.gfe.core.IParmManager; /** * A custom {@link KmlExportHandler} for GFE which allows adds options to the @@ -36,6 +39,7 @@ import com.raytheon.uf.viz.kml.export.KmlExportHandler; * Date Ticket# Engineer Description * ------------- -------- ----------- -------------------------- * Jan 23, 2014 2702 bsteffen Initial creation + * Apr 03, 2014 2847 dgilling Pass ParmManager instance to dialog. * * * @@ -47,8 +51,13 @@ public class GfeKmlExportHandler extends KmlExportHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { + DataManager dataMgr = DataManagerUIFactory.getCurrentInstance(); + IParmManager parmMgr = null; + if (dataMgr != null) { + parmMgr = dataMgr.getParmManager(); + } new GfeKmlExportDialog(HandlerUtil.getActiveShell(event), - getDefaultOptions()).open(); + getDefaultOptions(), parmMgr).open(); return null; }