Merge "Issue #1444 - Fix updating subsets by loading a saved subset from the saved subset tab. Change-Id: Ibc6b93fd8a9d7a9fdf07b28d77f4f32e706ae05a" into development

Former-commit-id: 31c1c5e71b [formerly 130e9151d2] [formerly 31c1c5e71b [formerly 130e9151d2] [formerly a3429f5ca1 [formerly 3afdc1e33555448ab7863858cc1d6496b545b5c8]]]
Former-commit-id: a3429f5ca1
Former-commit-id: d01c8c70b4 [formerly c0655734e7]
Former-commit-id: 9eee7d176e
This commit is contained in:
Richard Peter 2013-01-11 12:25:20 -06:00 committed by Gerrit Code Review
commit c695421365
6 changed files with 128 additions and 44 deletions

View file

@ -20,6 +20,8 @@
package com.raytheon.uf.viz.datadelivery.subscription.subset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.eclipse.swt.SWT;
@ -48,6 +50,7 @@ import com.raytheon.viz.ui.widgets.duallist.DualListConfig;
* Aug 29, 2012 0223 mpduff Removed cycle times.
* Sep 07, 2012 0684 mpduff Clear fcstHour selection before setting new selection.
* Sep 24, 2012 1209 djohnson Display text when there are no available cycles, move validation to presenter.
* Jan 10, 2013 1444 mpduff Add updateSelectedForecastHours method.
*
* </pre>
*
@ -55,8 +58,8 @@ import com.raytheon.viz.ui.widgets.duallist.DualListConfig;
* @version 1.0
*/
public class GriddedTimingSubsetTab extends DataTimingSubsetTab
implements IGriddedDataTimingSubsetView {
public class GriddedTimingSubsetTab extends DataTimingSubsetTab implements
IGriddedDataTimingSubsetView {
/** Forecast dual list */
private DualList fcstDualList;
@ -74,8 +77,8 @@ public class GriddedTimingSubsetTab extends DataTimingSubsetTab
* @param callback
* @param shell
*/
public GriddedTimingSubsetTab(Composite parentComp,
IDataSize callback, Shell shell) {
public GriddedTimingSubsetTab(Composite parentComp, IDataSize callback,
Shell shell) {
super(parentComp, callback, shell);
}
@ -132,8 +135,45 @@ public class GriddedTimingSubsetTab extends DataTimingSubsetTab
}
}
/**
* {@inheritDoc}
*/
@Override
public void setAvailableForecastHours(List<String> forecastHours) {
fcstDualList.setFullList(new ArrayList<String>(forecastHours));
}
/**
* {@inheritDoc}
*/
@Override
public void updateSelectedForecastHours(List<String> fcstHours) {
List<String> selectedHrs = new ArrayList<String>();
String[] selectedItems = fcstDualList.getSelectedSelection();
// Add the saved hours
for (String fcstHr : fcstDualList.getAvailableListItems()) {
if (fcstHours.contains(fcstHr)) {
selectedHrs.add(fcstHr);
}
}
// Add in the previously selected hours
selectedHrs.addAll(Arrays.asList(selectedItems));
// Sort the hours
List<Integer> intList = new ArrayList<Integer>();
for (String hr : selectedHrs) {
intList.add(Integer.parseInt(hr));
}
Collections.sort(intList);
selectedHrs.clear();
for (int i : intList) {
selectedHrs.add(String.valueOf(i));
}
fcstDualList.selectItems(selectedHrs.toArray(new String[selectedHrs
.size()]));
}
}

View file

@ -53,7 +53,6 @@ import com.raytheon.uf.common.datadelivery.registry.GriddedDataSet;
import com.raytheon.uf.common.datadelivery.registry.Parameter;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
import com.raytheon.uf.common.datadelivery.retrieval.util.DataSizeUtils;
import com.raytheon.uf.common.geospatial.MapUtil;
@ -122,6 +121,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
* Dec 18, 2012 1439 mpduff Redo subscription name validation.
* Jan 02, 2012 1345 djohnson Use gui thread task executor.
* Jan 04, 2012 1420 mpduff Pass the subscription in to the GriddedTimingSelectionDlg.
* Jan 10, 2013 1444 mpduff Fix the loading of saved subsets from the saved subset tab.
* </pre>
*
* @author mpduff
@ -830,7 +830,8 @@ public abstract class SubsetManagerDlg<DATASET extends DataSet, PRESENTER extend
}
/**
* Load saved subset button action handler.
* Load saved subset button action handler. This action takes the settings
* from the saved subset and applies them to the current data set.
*
* @param subsetName
* Name of the subset to load
@ -840,27 +841,10 @@ public abstract class SubsetManagerDlg<DATASET extends DataSet, PRESENTER extend
public void handleLoadSubset(String subsetName) {
// TODO: How else to do this other than casting?
this.subsetXml = (SubsetXML<TIMEXML>) SubsetFileManager.getInstance()
.loadSubset(subsetName);
SubsetXML<TIMEXML> loadedSubsetXml = (SubsetXML<TIMEXML>) SubsetFileManager
.getInstance().loadSubset(subsetName);
if (!spatialTabControls.getRegionSaveText().isEmpty()) {
spatialTabControls.resetRegionSaveText();
}
try {
// TODO: How else other can casting?
this.dataSet = (DATASET) DataDeliveryHandlers.getDataSetHandler()
.getByNameAndProvider(subsetXml.getDatasetName(),
subsetXml.getProviderName());
setText(DD_SUBSET_MANAGER + dataSet.getDataSetName());
populate();
getShell().layout();
getShell().pack();
} catch (RegistryHandlerException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
updateSelections(loadedSubsetXml);
}
/**
@ -884,7 +868,17 @@ public abstract class SubsetManagerDlg<DATASET extends DataSet, PRESENTER extend
TIMEXML time = subsetXml.getTime();
this.timingTabControls.populate(time, dataSet);
this.nameText.setText(subsetXml.getBaseSubsetName());
}
/**
* Update selections with from the loadedSubsetXML object.
*/
private void updateSelections(SubsetXML<TIMEXML> loadedSubsetXml) {
ArrayList<VerticalXML> vertList = loadedSubsetXml.getVerticalList();
vTab.updateSettings(vertList);
TIMEXML time = loadedSubsetXml.getTime();
timingTabControls.updateSettings(time);
}
/**

View file

@ -65,6 +65,7 @@ import com.raytheon.uf.viz.datadelivery.subscription.subset.xml.VerticalXML;
* Oct 4, 2012 1245 jpiatt Correct isValid method & code clean up.
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
* Dec 10, 2012 1259 bsteffen Switch Data Delivery from LatLon to referenced envelopes.
* Jan 10, 2013 1444 mpduff Add updateSettings method.
*
* </pre>
*
@ -575,4 +576,27 @@ public class VerticalSubsetTab extends SubsetTab implements
}
}
}
/**
* Update the selected parameters and levels.
*
* @param vertList
*/
public void updateSettings(ArrayList<VerticalXML> vertList) {
for (VerticalXML vert : vertList) {
for (ExpandItem item : expandBar.getItems()) {
LevelParameterSelection lps = (LevelParameterSelection) item
.getControl();
if (vert.getLayerType().equalsIgnoreCase(item.getText())) {
if (vert.getLevels() != null && !vert.getLevels().isEmpty()) {
lps.selectLevels(vert.getLevels());
}
if (vert.getParameterList() != null
&& !vert.getParameterList().isEmpty()) {
lps.selectParameters(vert.getParameterList());
}
}
}
}
}
}

View file

@ -42,6 +42,7 @@ import com.raytheon.uf.viz.datadelivery.subscription.subset.xml.TimeXML;
* Aug 15, 2012 0743 djohnson Initial creation
* Aug 29, 2012 0223 mpduff Changed as result of renamed objects.
* Sep 24, 2012 1209 djohnson Sub-classes provide isValid() implementations.
* Jan 10, 2013 1444 mpduff Add updateSettings method.
*
* </pre>
*
@ -120,4 +121,12 @@ public abstract class DataTimingSubsetPresenter<DATASET extends DataSet, DATASET
* the saved time information
*/
public abstract void populate(TIMEXML time, DataSet dataSet);
/**
* Update the data timing presenter from the save information.
*
* @param time
* the saved time information
*/
public abstract void updateSettings(TIMEXML time);
}

View file

@ -43,6 +43,7 @@ import com.raytheon.uf.viz.datadelivery.subscription.subset.xml.SpecificDateTime
* Aug 22, 2012 0743 djohnson Initial creation
* Aug 29, 2012 0223 mpduff Removed cycles.
* Sep 24, 2012 1209 djohnson Move isValid() in from view.
* Jan 10, 2013 1444 mpduff Add updateSettings method.
*
* </pre>
*
@ -50,7 +51,8 @@ import com.raytheon.uf.viz.datadelivery.subscription.subset.xml.SpecificDateTime
* @version 1.0
*/
public class GriddedTimingSubsetPresenter extends
public class GriddedTimingSubsetPresenter
extends
DataTimingSubsetPresenter<GriddedDataSet, GriddedDataSetMetaData, IGriddedDataTimingSubsetView, SpecificDateTimeXML, GriddedDataSetMetaDataQuery> {
/**
@ -121,4 +123,12 @@ public class GriddedTimingSubsetPresenter extends
return !CollectionUtil.isNullOrEmpty(forecastHours);
}
/**
* {@inheritDoc}
*/
@Override
public void updateSettings(SpecificDateTimeXML time) {
view.updateSelectedForecastHours(time.getFcstHours());
}
}

View file

@ -20,7 +20,6 @@
package com.raytheon.uf.viz.datadelivery.subscription.subset.presenter;
import java.util.List;
import java.util.Set;
import com.raytheon.uf.common.datadelivery.registry.GriddedDataSet;
@ -35,6 +34,7 @@ import com.raytheon.uf.common.datadelivery.registry.GriddedDataSet;
* ------------ ---------- ----------- --------------------------
* Aug 22, 2012 0743 djohnson Initial creation
* Aug 29, 2012 0223 mpduff Removed cycles.
* Jan 10, 2012 1444 mpduff Add updateSelectedForecastHours method.
* </pre>
*
* @author djohnson
@ -59,4 +59,11 @@ public interface IGriddedDataTimingSubsetView extends IDataTimingSubsetView {
* @param fcstHours
*/
void setAvailableForecastHours(List<String> fcstHours);
/**
* Update the selected forecast hours.
*
* @param fcstHours
*/
void updateSelectedForecastHours(List<String> fcstHours);
}