Merge "Issue #2864 - Change how saved subset files are stored." into development
Former-commit-id:8a682a5e23
[formerly 05fed9ffbd4c61601d6a42b2ef3dadefde7e1a3c] Former-commit-id:695878c6aa
This commit is contained in:
commit
0fa4180959
6 changed files with 406 additions and 73 deletions
|
@ -19,8 +19,6 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.viz.datadelivery.actions;
|
package com.raytheon.uf.viz.datadelivery.actions;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.eclipse.core.commands.AbstractHandler;
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
@ -30,20 +28,20 @@ import org.eclipse.ui.PlatformUI;
|
||||||
import com.raytheon.uf.common.auth.AuthException;
|
import com.raytheon.uf.common.auth.AuthException;
|
||||||
import com.raytheon.uf.common.auth.user.IUser;
|
import com.raytheon.uf.common.auth.user.IUser;
|
||||||
import com.raytheon.uf.common.datadelivery.registry.DataSet;
|
import com.raytheon.uf.common.datadelivery.registry.DataSet;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
||||||
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
|
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
|
||||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||||
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;
|
||||||
import com.raytheon.uf.viz.core.auth.UserController;
|
import com.raytheon.uf.viz.core.auth.UserController;
|
||||||
import com.raytheon.uf.viz.datadelivery.common.ui.LoadSaveConfigDlg;
|
|
||||||
import com.raytheon.uf.viz.datadelivery.common.ui.LoadSaveConfigDlg.DialogType;
|
|
||||||
import com.raytheon.uf.viz.datadelivery.filter.MetaDataManager;
|
import com.raytheon.uf.viz.datadelivery.filter.MetaDataManager;
|
||||||
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
|
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
|
||||||
import com.raytheon.uf.viz.datadelivery.subscription.subset.SubsetFileManager;
|
import com.raytheon.uf.viz.datadelivery.subscription.subset.SubsetFileManager;
|
||||||
import com.raytheon.uf.viz.datadelivery.subscription.subset.SubsetManagerDlg;
|
import com.raytheon.uf.viz.datadelivery.subscription.subset.SubsetManagerDlg;
|
||||||
import com.raytheon.uf.viz.datadelivery.subscription.subset.xml.SubsetXML;
|
import com.raytheon.uf.viz.datadelivery.subscription.subset.xml.SubsetXML;
|
||||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
|
import com.raytheon.viz.ui.dialogs.ListSelectionDlg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for launching the Subset Manager Dialog.
|
* Handler for launching the Subset Manager Dialog.
|
||||||
|
@ -56,12 +54,13 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Apr 02, 2012 mpduff Initial creation
|
* Apr 02, 2012 mpduff Initial creation
|
||||||
* Aug 06, 2012 955 djohnson Change to accept {@link DataSet}.
|
* Aug 06, 2012 955 djohnson Change to accept {@link DataSet}.
|
||||||
* Aug 10, 2012 1022 djohnson Store provider name in {@link SubsetXml}, use GriddedDataSet.
|
* Aug 10, 2012 1022 djohnson Store provider name in {@link SubsetXML}, use GriddedDataSet.
|
||||||
* Aug 21, 2012 0743 djohnson Change getMetaData to getDataSet.
|
* Aug 21, 2012 0743 djohnson Change getMetaData to getDataSet.
|
||||||
* Oct 03, 2012 1241 djohnson Use {@link DataDeliveryPermission}.
|
* Oct 03, 2012 1241 djohnson Use {@link DataDeliveryPermission}.
|
||||||
* Jul 26, 2013 2232 mpduff Refactored Data Delivery permissions.
|
* Jul 26, 2013 2232 mpduff Refactored Data Delivery permissions.
|
||||||
* Sep 04, 2013 2314 mpduff LoadSave dialog now non-blocking.
|
* Sep 04, 2013 2314 mpduff LoadSave dialog now non-blocking.
|
||||||
* Oct 11, 2013 2386 mpduff Refactor DD Front end.
|
* Oct 11, 2013 2386 mpduff Refactor DD Front end.
|
||||||
|
* Apr 10, 2014 2864 mpduff Changed how saved subset files are stored.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -74,15 +73,11 @@ public class SubsetAction extends AbstractHandler {
|
||||||
private final IUFStatusHandler statusHandler = UFStatus
|
private final IUFStatusHandler statusHandler = UFStatus
|
||||||
.getHandler(SubsetAction.class);
|
.getHandler(SubsetAction.class);
|
||||||
|
|
||||||
/** Saved subset path */
|
|
||||||
private final String SUBSET_PATH = "dataDelivery" + File.separator
|
|
||||||
+ "subset" + File.separator;
|
|
||||||
|
|
||||||
/** Dialog instance */
|
/** Dialog instance */
|
||||||
private SubsetManagerDlg dlg = null;
|
private SubsetManagerDlg dlg = null;
|
||||||
|
|
||||||
/** Dialog instance */
|
/** Dialog instance */
|
||||||
private LoadSaveConfigDlg loadDlg = null;
|
private ListSelectionDlg selectionDlg = null;
|
||||||
|
|
||||||
private final String permission = DataDeliveryPermission.SUBSCRIPTION_EDIT
|
private final String permission = DataDeliveryPermission.SUBSCRIPTION_EDIT
|
||||||
.toString();
|
.toString();
|
||||||
|
@ -97,37 +92,55 @@ public class SubsetAction extends AbstractHandler {
|
||||||
+ permission;
|
+ permission;
|
||||||
if (DataDeliveryServices.getPermissionsService()
|
if (DataDeliveryServices.getPermissionsService()
|
||||||
.checkPermissions(user, msg, permission).isAuthorized()) {
|
.checkPermissions(user, msg, permission).isAuthorized()) {
|
||||||
|
String[] choices = SubsetFileManager.getInstance()
|
||||||
|
.getAllLocalizationFileNames();
|
||||||
final Shell shell = PlatformUI.getWorkbench()
|
final Shell shell = PlatformUI.getWorkbench()
|
||||||
.getActiveWorkbenchWindow().getShell();
|
.getActiveWorkbenchWindow().getShell();
|
||||||
if (loadDlg == null || loadDlg.isDisposed()) {
|
if (selectionDlg == null || selectionDlg.isDisposed()) {
|
||||||
loadDlg = new LoadSaveConfigDlg(shell, DialogType.OPEN,
|
selectionDlg = new ListSelectionDlg(shell, choices);
|
||||||
SUBSET_PATH, "", true);
|
selectionDlg.setCloseCallback(new ICloseCallback() {
|
||||||
loadDlg.setCloseCallback(new ICloseCallback() {
|
|
||||||
@Override
|
@Override
|
||||||
public void dialogClosed(Object returnValue) {
|
public void dialogClosed(Object returnValue) {
|
||||||
if (returnValue instanceof LocalizationFile) {
|
if (returnValue instanceof String[]) {
|
||||||
LocalizationFile locFile = (LocalizationFile) returnValue;
|
String[] selection = (String[]) returnValue;
|
||||||
SubsetXML subset = SubsetFileManager
|
if (selection.length == 1) {
|
||||||
.getInstance().loadSubset(
|
String[] parts = selection[0].split(":");
|
||||||
locFile.getFile().getName());
|
|
||||||
|
|
||||||
DataSet data = MetaDataManager.getInstance()
|
SubsetFileManager sfm = SubsetFileManager
|
||||||
.getDataSet(subset.getDatasetName(),
|
.getInstance();
|
||||||
subset.getProviderName());
|
LocalizationFile locFile = sfm.getFile(
|
||||||
|
parts[1],
|
||||||
|
DataType.valueOf(parts[0]));
|
||||||
|
SubsetXML subset = SubsetFileManager
|
||||||
|
.getInstance().loadSubset(locFile);
|
||||||
|
|
||||||
if (dlg == null || dlg.isDisposed()) {
|
DataSet data = MetaDataManager
|
||||||
dlg = SubsetManagerDlg.fromSubsetXML(shell,
|
.getInstance().getDataSet(
|
||||||
data, true, subset);
|
subset.getDatasetName(),
|
||||||
dlg.open();
|
subset.getProviderName());
|
||||||
|
|
||||||
|
if (dlg == null || dlg.isDisposed()) {
|
||||||
|
dlg = SubsetManagerDlg.fromSubsetXML(
|
||||||
|
shell, data, true, subset);
|
||||||
|
dlg.open();
|
||||||
|
} else {
|
||||||
|
dlg.bringToTop();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dlg.bringToTop();
|
throw new IllegalArgumentException(
|
||||||
|
"Expected 1 item, received "
|
||||||
|
+ selection.length
|
||||||
|
+ " items.");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Invalid return type from ListSelectionDlg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
loadDlg.open();
|
selectionDlg.open();
|
||||||
} else {
|
} else {
|
||||||
loadDlg.bringToTop();
|
selectionDlg.bringToTop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.List;
|
import org.eclipse.swt.widgets.List;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
||||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||||
import com.raytheon.uf.viz.datadelivery.subscription.subset.xml.SubsetXML;
|
import com.raytheon.uf.viz.datadelivery.subscription.subset.xml.SubsetXML;
|
||||||
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
|
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
|
||||||
|
@ -45,6 +46,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
|
||||||
* Mar 30, 2012 mpduff Initial creation.
|
* Mar 30, 2012 mpduff Initial creation.
|
||||||
* Jun 4, 2012 645 jpiatt Added tooltips.
|
* Jun 4, 2012 645 jpiatt Added tooltips.
|
||||||
* Nov 1, 2012 1278 mpduff Formatted to meet coding standard.
|
* Nov 1, 2012 1278 mpduff Formatted to meet coding standard.
|
||||||
|
* Apr 10, 2014 2864 mpduff Changed how saved subset files are stored.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -72,17 +74,23 @@ public class SavedSubsetTab extends SubsetTab {
|
||||||
/** File extension */
|
/** File extension */
|
||||||
String extension = ".xml";
|
String extension = ".xml";
|
||||||
|
|
||||||
|
/** The type of data loaded in the dialog */
|
||||||
|
private final DataType dataType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param comp
|
* @param comp
|
||||||
* Composite holding these controls
|
* Composite holding these controls
|
||||||
|
* @param dataType
|
||||||
|
* The datatype of the loaded data
|
||||||
* @param callback
|
* @param callback
|
||||||
* The class for callbacks
|
* The class for callbacks
|
||||||
*/
|
*/
|
||||||
public SavedSubsetTab(Composite comp, ITabAction callback) {
|
public SavedSubsetTab(Composite comp, DataType dataType, ITabAction callback) {
|
||||||
this.comp = comp;
|
this.comp = comp;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
|
this.dataType = dataType;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -155,7 +163,7 @@ public class SavedSubsetTab extends SubsetTab {
|
||||||
subsetList.removeAll();
|
subsetList.removeAll();
|
||||||
// Get the subset data
|
// Get the subset data
|
||||||
for (LocalizationFile locFile : SubsetFileManager.getInstance()
|
for (LocalizationFile locFile : SubsetFileManager.getInstance()
|
||||||
.getSubsets()) {
|
.getLocalizationFiles(this.dataType)) {
|
||||||
String locFileName = locFile.getFile().getName();
|
String locFileName = locFile.getFile().getName();
|
||||||
subsetList.add(SubsetXML.getBaseSubsetName(locFileName));
|
subsetList.add(SubsetXML.getBaseSubsetName(locFileName));
|
||||||
}
|
}
|
||||||
|
@ -170,7 +178,8 @@ public class SavedSubsetTab extends SubsetTab {
|
||||||
.getSelectionIndex());
|
.getSelectionIndex());
|
||||||
subsetName = subsetName + extension;
|
subsetName = subsetName + extension;
|
||||||
if (response == SWT.YES) {
|
if (response == SWT.YES) {
|
||||||
SubsetFileManager.getInstance().deleteSubset(subsetName);
|
SubsetFileManager.getInstance().deleteSubset(subsetName,
|
||||||
|
this.dataType);
|
||||||
loadList();
|
loadList();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -20,6 +20,12 @@
|
||||||
package com.raytheon.uf.viz.datadelivery.subscription.subset;
|
package com.raytheon.uf.viz.datadelivery.subscription.subset;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
@ -29,6 +35,7 @@ import javax.xml.bind.Unmarshaller;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
||||||
import com.raytheon.uf.common.localization.IPathManager;
|
import com.raytheon.uf.common.localization.IPathManager;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||||
|
@ -65,6 +72,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
|
||||||
* Nov 19, 2012 1289 bgonzale Added deleteArea(String) method.
|
* Nov 19, 2012 1289 bgonzale Added deleteArea(String) method.
|
||||||
* Jun 04, 2013 223 mpduff Added PointTimeXML to JaxB context.
|
* Jun 04, 2013 223 mpduff Added PointTimeXML to JaxB context.
|
||||||
* Oct 11, 2013 2386 mpduff Refactor DD Front end.
|
* Oct 11, 2013 2386 mpduff Refactor DD Front end.
|
||||||
|
* Apr 10, 2014 2864 mpduff Changed how saved subset files are stored.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -97,14 +105,15 @@ public class SubsetFileManager {
|
||||||
/** Unmarshaller object */
|
/** Unmarshaller object */
|
||||||
private Unmarshaller unmarshaller;
|
private Unmarshaller unmarshaller;
|
||||||
|
|
||||||
/** Array of subset files */
|
private final Map<DataType, Set<LocalizationFile>> subsetFiles = new HashMap<DataType, Set<LocalizationFile>>();
|
||||||
private LocalizationFile[] subsetFiles;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
private SubsetFileManager() {
|
private SubsetFileManager() {
|
||||||
createContext();
|
createContext();
|
||||||
|
|
||||||
|
populate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,7 +181,6 @@ public class SubsetFileManager {
|
||||||
return true;
|
return true;
|
||||||
} catch (JAXBException e) {
|
} catch (JAXBException e) {
|
||||||
statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e);
|
statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e);
|
||||||
e.printStackTrace();
|
|
||||||
} catch (LocalizationOpFailedException e) {
|
} catch (LocalizationOpFailedException e) {
|
||||||
statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e);
|
statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -241,18 +249,40 @@ public class SubsetFileManager {
|
||||||
/**
|
/**
|
||||||
* Get all the saved subset files
|
* Get all the saved subset files
|
||||||
*
|
*
|
||||||
* @return LocalizationFile[]
|
* @param type
|
||||||
|
* Data type of files to retrieve
|
||||||
|
*
|
||||||
|
* @return LocalizationFile[] Array of files of DataType type
|
||||||
*/
|
*/
|
||||||
public LocalizationFile[] getSubsets() {
|
private Set<LocalizationFile> getSubsetFiles(DataType type) {
|
||||||
IPathManager pm = PathManagerFactory.getPathManager();
|
IPathManager pm = PathManagerFactory.getPathManager();
|
||||||
|
|
||||||
LocalizationContext context = pm.getContext(
|
LocalizationContext context = pm.getContext(
|
||||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||||
String[] extensions = new String[] { "xml" };
|
String[] extensions = new String[] { "xml" };
|
||||||
this.subsetFiles = pm.listFiles(context, SUBSET_PATH, extensions,
|
String path = null;
|
||||||
false, true);
|
|
||||||
|
|
||||||
return subsetFiles;
|
path = SUBSET_PATH + type.toString() + File.separator;
|
||||||
|
|
||||||
|
LocalizationFile[] fileArr = pm.listFiles(context, path, extensions,
|
||||||
|
false, true);
|
||||||
|
Set<LocalizationFile> files = new TreeSet<LocalizationFile>();
|
||||||
|
for (LocalizationFile file : fileArr) {
|
||||||
|
files.add(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populate() {
|
||||||
|
subsetFiles.clear();
|
||||||
|
for (DataType type : DataType.values()) {
|
||||||
|
subsetFiles.put(type, getSubsetFiles(type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<LocalizationFile> getLocalizationFiles(DataType type) {
|
||||||
|
return subsetFiles.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -260,17 +290,20 @@ public class SubsetFileManager {
|
||||||
*
|
*
|
||||||
* @param subset
|
* @param subset
|
||||||
* the object to save
|
* the object to save
|
||||||
|
* @param type
|
||||||
|
* DataType
|
||||||
* @param shell
|
* @param shell
|
||||||
* The calling dialog's shell
|
* The calling dialog's shell
|
||||||
* @return true if successfully saved
|
* @return true if successfully saved
|
||||||
*/
|
*/
|
||||||
public boolean saveSubset(SubsetXML subset, Shell shell) {
|
public boolean saveSubset(SubsetXML subset, DataType type, Shell shell) {
|
||||||
IPathManager pm = PathManagerFactory.getPathManager();
|
IPathManager pm = PathManagerFactory.getPathManager();
|
||||||
|
|
||||||
LocalizationContext context = pm.getContext(
|
LocalizationContext context = pm.getContext(
|
||||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||||
LocalizationFile subsetLocFile = pm.getLocalizationFile(context,
|
LocalizationFile subsetLocFile = pm.getLocalizationFile(context,
|
||||||
SUBSET_PATH + subset.getSubsetName());
|
SUBSET_PATH + File.separator + type.toString() + File.separator
|
||||||
|
+ subset.getSubsetName());
|
||||||
|
|
||||||
if (subsetLocFile.getFile().exists()) {
|
if (subsetLocFile.getFile().exists()) {
|
||||||
String msg = "The file "
|
String msg = "The file "
|
||||||
|
@ -286,7 +319,7 @@ public class SubsetFileManager {
|
||||||
try {
|
try {
|
||||||
marshaller.marshal(subset, subsetLocFile.getFile());
|
marshaller.marshal(subset, subsetLocFile.getFile());
|
||||||
subsetLocFile.save();
|
subsetLocFile.save();
|
||||||
|
subsetFiles.get(type).add(subsetLocFile);
|
||||||
return true;
|
return true;
|
||||||
} catch (JAXBException e) {
|
} catch (JAXBException e) {
|
||||||
statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e);
|
statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e);
|
||||||
|
@ -302,16 +335,13 @@ public class SubsetFileManager {
|
||||||
*
|
*
|
||||||
* @param subsetName
|
* @param subsetName
|
||||||
* The subset name
|
* The subset name
|
||||||
|
* @param type
|
||||||
|
* The data type
|
||||||
*
|
*
|
||||||
* @return The SubsetXML object
|
* @return The SubsetXML object or null if none exist
|
||||||
*/
|
*/
|
||||||
public SubsetXML loadSubset(String subsetName) {
|
public SubsetXML loadSubset(String subsetName, DataType type) {
|
||||||
// Load the subset files if not already loaded
|
for (LocalizationFile lf : subsetFiles.get(type)) {
|
||||||
if (subsetFiles == null || subsetFiles.length == 0) {
|
|
||||||
getSubsets();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (LocalizationFile lf : subsetFiles) {
|
|
||||||
if (lf.getFile().getName().equals(subsetName)) {
|
if (lf.getFile().getName().equals(subsetName)) {
|
||||||
try {
|
try {
|
||||||
return (SubsetXML) unmarshaller.unmarshal(lf.getFile());
|
return (SubsetXML) unmarshaller.unmarshal(lf.getFile());
|
||||||
|
@ -325,27 +355,77 @@ public class SubsetFileManager {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a saved subset into memory
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* The subset name
|
||||||
|
*
|
||||||
|
* @return The SubsetXML object or null if none exist
|
||||||
|
*/
|
||||||
|
public SubsetXML loadSubset(LocalizationFile file) {
|
||||||
|
|
||||||
|
if (file.exists()) {
|
||||||
|
try {
|
||||||
|
return (SubsetXML) unmarshaller.unmarshal(file.getFile());
|
||||||
|
} catch (JAXBException e) {
|
||||||
|
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
|
||||||
|
e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the subset
|
* Delete the subset
|
||||||
*
|
*
|
||||||
* @param subsetName
|
* @param subsetName
|
||||||
* The name of the subset to delete
|
* The name of the subset to delete
|
||||||
|
* @param type
|
||||||
|
* The data type
|
||||||
*/
|
*/
|
||||||
public void deleteSubset(String subsetName) {
|
public void deleteSubset(String subsetName, DataType type) {
|
||||||
// Load the subset files if not already loaded
|
LocalizationFile file = null;
|
||||||
if (subsetFiles == null || subsetFiles.length == 0) {
|
for (LocalizationFile lf : subsetFiles.get(type)) {
|
||||||
getSubsets();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (LocalizationFile lf : subsetFiles) {
|
|
||||||
if (lf.getFile().getName().equals(subsetName)) {
|
if (lf.getFile().getName().equals(subsetName)) {
|
||||||
try {
|
try {
|
||||||
lf.delete();
|
lf.delete();
|
||||||
|
file = lf;
|
||||||
|
break;
|
||||||
} catch (LocalizationOpFailedException e) {
|
} catch (LocalizationOpFailedException e) {
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
e.getLocalizedMessage(), e);
|
e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file != null) {
|
||||||
|
subsetFiles.get(type).remove(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getAllLocalizationFileNames() {
|
||||||
|
List<String> fileList = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (DataType type : DataType.values()) {
|
||||||
|
Set<LocalizationFile> files = getLocalizationFiles(type);
|
||||||
|
for (LocalizationFile file : files) {
|
||||||
|
fileList.add(type.toString() + ":" + file.getFile().getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileList.toArray(new String[fileList.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalizationFile getFile(String fileName, DataType dataType) {
|
||||||
|
Set<LocalizationFile> files = subsetFiles.get(dataType);
|
||||||
|
for (LocalizationFile file : files) {
|
||||||
|
if (file.getFile().getName().equals(fileName)) {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,9 @@ import com.raytheon.viz.ui.presenter.IDisplay;
|
||||||
* Feb 26, 2014 #2833 lvenable Added code to prevent the Subset (this) dialog from
|
* Feb 26, 2014 #2833 lvenable Added code to prevent the Subset (this) dialog from
|
||||||
* disappearing when the Subscription button is double clicked.
|
* disappearing when the Subscription button is double clicked.
|
||||||
* Added dispose check for subscription button.
|
* Added dispose check for subscription button.
|
||||||
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
* Mar 31, 2014 2889 dhladky Added username for notification center tracking.
|
||||||
|
* Apr 10, 2014 2864 mpduff Changed how saved subset files are stored.
|
||||||
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author mpduff
|
* @author mpduff
|
||||||
|
@ -382,7 +384,8 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements
|
||||||
savedSetsTab.setText("Saved Subsets");
|
savedSetsTab.setText("Saved Subsets");
|
||||||
Composite savedSetsComp = new Composite(tabFolder, SWT.NONE);
|
Composite savedSetsComp = new Composite(tabFolder, SWT.NONE);
|
||||||
savedSetsTab.setControl(savedSetsComp);
|
savedSetsTab.setControl(savedSetsComp);
|
||||||
subsetTab = new SavedSubsetTab(savedSetsComp, this);
|
subsetTab = new SavedSubsetTab(savedSetsComp, dataSet.getDataSetType(),
|
||||||
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create the information composite */
|
/** Create the information composite */
|
||||||
|
@ -553,9 +556,9 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
as.setSubscriptionType(SubscriptionType.QUERY);
|
as.setSubscriptionType(SubscriptionType.QUERY);
|
||||||
SubscriptionServiceResult result = subscriptionService.store(LocalizationManager.getInstance()
|
SubscriptionServiceResult result = subscriptionService.store(
|
||||||
.getCurrentUser(),
|
LocalizationManager.getInstance().getCurrentUser(), as,
|
||||||
as, this);
|
this);
|
||||||
|
|
||||||
if (result.hasMessageToDisplay()) {
|
if (result.hasMessageToDisplay()) {
|
||||||
DataDeliveryUtils.showMessage(getShell(), SWT.OK,
|
DataDeliveryUtils.showMessage(getShell(), SWT.OK,
|
||||||
|
@ -746,7 +749,8 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements
|
||||||
populateSubsetXML(subset);
|
populateSubsetXML(subset);
|
||||||
|
|
||||||
// Have all the info, now save the file
|
// Have all the info, now save the file
|
||||||
SubsetFileManager.getInstance().saveSubset(subset, this.shell);
|
SubsetFileManager.getInstance().saveSubset(subset,
|
||||||
|
this.dataSet.getDataSetType(), this.shell);
|
||||||
setClean();
|
setClean();
|
||||||
subsetTab.enableButtons(nameText);
|
subsetTab.enableButtons(nameText);
|
||||||
}
|
}
|
||||||
|
@ -835,7 +839,7 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements
|
||||||
@Override
|
@Override
|
||||||
public void handleLoadSubset(String subsetName) {
|
public void handleLoadSubset(String subsetName) {
|
||||||
SubsetXML loadedSubsetXml = SubsetFileManager.getInstance().loadSubset(
|
SubsetXML loadedSubsetXml = SubsetFileManager.getInstance().loadSubset(
|
||||||
subsetName);
|
subsetName, dataSet.getDataSetType());
|
||||||
|
|
||||||
loadFromSubsetXML(loadedSubsetXml);
|
loadFromSubsetXML(loadedSubsetXml);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,184 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.viz.ui.dialogs;
|
||||||
|
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.MouseEvent;
|
||||||
|
import org.eclipse.swt.events.MouseListener;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Layout;
|
||||||
|
import org.eclipse.swt.widgets.List;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialog allowing the user to select one or more items from the provided list.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Apr 09, 2014 2864 mpduff Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author mpduff
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ListSelectionDlg extends CaveSWTDialog {
|
||||||
|
/** Stings to populate the list */
|
||||||
|
private final String[] textChoices;
|
||||||
|
|
||||||
|
/** Single/Multiple select flag */
|
||||||
|
private final boolean singleSelect;
|
||||||
|
|
||||||
|
/** The list widget */
|
||||||
|
private List selectList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param parent
|
||||||
|
* Parent shell
|
||||||
|
* @param textChoices
|
||||||
|
* Items for the list
|
||||||
|
* @param singleSelect
|
||||||
|
* true if only a single selection allowed
|
||||||
|
*/
|
||||||
|
public ListSelectionDlg(Shell parent, String[] textChoices,
|
||||||
|
boolean singleSelect) {
|
||||||
|
super(parent, SWT.TITLE | SWT.RESIZE | SWT.APPLICATION_MODAL,
|
||||||
|
CAVE.DO_NOT_BLOCK);
|
||||||
|
this.textChoices = textChoices;
|
||||||
|
this.singleSelect = singleSelect;
|
||||||
|
|
||||||
|
if (singleSelect) {
|
||||||
|
setText("Select One");
|
||||||
|
} else {
|
||||||
|
setText("Select Items");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Single select list.
|
||||||
|
*
|
||||||
|
* @param parent
|
||||||
|
* Parent shell
|
||||||
|
* @param textChoices
|
||||||
|
* Items for the list
|
||||||
|
*/
|
||||||
|
public ListSelectionDlg(Shell parent, String[] textChoices) {
|
||||||
|
this(parent, textChoices, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Layout constructShellLayout() {
|
||||||
|
// Create the main layout for the shell.
|
||||||
|
GridLayout mainLayout = new GridLayout(1, false);
|
||||||
|
mainLayout.marginHeight = 2;
|
||||||
|
mainLayout.marginWidth = 2;
|
||||||
|
mainLayout.verticalSpacing = 2;
|
||||||
|
return mainLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Object constructShellLayoutData() {
|
||||||
|
return new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initializeComponents(Shell shell) {
|
||||||
|
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
|
Composite mainComp = new Composite(shell, SWT.NONE);
|
||||||
|
mainComp.setLayout(new GridLayout(1, false));
|
||||||
|
mainComp.setLayoutData(gd);
|
||||||
|
|
||||||
|
int style = SWT.SINGLE;
|
||||||
|
if (!this.singleSelect) {
|
||||||
|
style = SWT.MULTI;
|
||||||
|
}
|
||||||
|
|
||||||
|
style |= SWT.V_SCROLL | SWT.H_SCROLL;
|
||||||
|
|
||||||
|
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
|
selectList = new List(mainComp, SWT.BORDER | style);
|
||||||
|
selectList.setLayoutData(gd);
|
||||||
|
selectList.addMouseListener(new MouseListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseUp(MouseEvent e) {
|
||||||
|
// No op
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseDown(MouseEvent e) {
|
||||||
|
// No op
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseDoubleClick(MouseEvent e) {
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
|
||||||
|
Composite btnComp = new Composite(shell, SWT.NONE);
|
||||||
|
btnComp.setLayout(new GridLayout(2, false));
|
||||||
|
btnComp.setLayoutData(gd);
|
||||||
|
|
||||||
|
Button selectBtn = new Button(btnComp, SWT.PUSH);
|
||||||
|
selectBtn.setLayoutData(new GridData(75, SWT.DEFAULT));
|
||||||
|
selectBtn.setText("Select");
|
||||||
|
selectBtn.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Button cancelBtn = new Button(btnComp, SWT.PUSH);
|
||||||
|
cancelBtn.setLayoutData(new GridData(75, SWT.DEFAULT));
|
||||||
|
cancelBtn.setText("Cancel");
|
||||||
|
cancelBtn.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
selectList.setItems(textChoices);
|
||||||
|
this.shell.setMinimumSize(225, 275);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action handler.
|
||||||
|
*/
|
||||||
|
private void action() {
|
||||||
|
setReturnValue(selectList.getSelection());
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
43
deltaScripts/14.3.1/subsetRelocator.sh
Normal file
43
deltaScripts/14.3.1/subsetRelocator.sh
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# DR 2864 - update the location of saved subset files
|
||||||
|
|
||||||
|
echo "Updating saved subset file locations"
|
||||||
|
|
||||||
|
startDir=/awips2/edex/data/utility/cave_static/user
|
||||||
|
cd $startDir
|
||||||
|
users=$(ls -1)
|
||||||
|
|
||||||
|
for i in $users
|
||||||
|
do
|
||||||
|
cd $i
|
||||||
|
if [ -e dataDelivery/subset ]
|
||||||
|
then
|
||||||
|
cd dataDelivery/subset
|
||||||
|
|
||||||
|
if [ ! -e GRID ]
|
||||||
|
then
|
||||||
|
mkdir GRID
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e POINT ]
|
||||||
|
then
|
||||||
|
mkdir POINT
|
||||||
|
fi
|
||||||
|
|
||||||
|
gridFiles=$(grep providerName *.xml | grep NOMADS | cut -d: -f1)
|
||||||
|
pointFiles=$(grep providerName *.xml | grep MADIS | cut -d: -f1)
|
||||||
|
for j in $gridFiles
|
||||||
|
do
|
||||||
|
mv $j* GRID
|
||||||
|
done
|
||||||
|
for j in $pointFiles
|
||||||
|
do
|
||||||
|
mv $j* POINT
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $startDir
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Update complete"
|
Loading…
Add table
Reference in a new issue