Merge "Omaha #5242: Remove calls to deprecated Localization APIs from GFE viz code." into omaha_16.2.2
Former-commit-id: 4c46d7724b3b6801e68cbf334a779d87ffd55f25
This commit is contained in:
commit
ce63ab22e6
17 changed files with 235 additions and 663 deletions
|
@ -19,7 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.viz.gfe.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
@ -29,6 +28,8 @@ import java.util.Set;
|
|||
import jep.JepException;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
|
@ -50,6 +51,7 @@ import com.raytheon.uf.common.util.FileUtil;
|
|||
* Jan 21, 2010 randerso Initial creation
|
||||
* Jul 08, 2014 3361 njensen Consolidated code
|
||||
* Sep 29, 2014 2975 njensen Only look up files in CAVE_STATIC
|
||||
* Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -82,22 +84,20 @@ public class ConfigCatalog {
|
|||
* @return true if config file is hidden
|
||||
*/
|
||||
public boolean isHidden(String name) {
|
||||
LocalizationFile lf = getFile(name);
|
||||
File file = lf.getFile();
|
||||
boolean rtnVal = false;
|
||||
if (file == null || !file.exists()) {
|
||||
|
||||
LocalizationFile lf = getFile(name);
|
||||
if (lf == null || !lf.exists()) {
|
||||
throw new IllegalArgumentException("No such GFE config file: "
|
||||
+ name);
|
||||
} else {
|
||||
// Look for HideConfigFile = True in the file
|
||||
PythonScript pscript = null;
|
||||
try {
|
||||
String configPath = GfePyIncludeUtil.getConfigIncludePath();
|
||||
String vtecPath = GfePyIncludeUtil.getVtecIncludePath();
|
||||
String configPath = GfePyIncludeUtil.getConfigIncludePath();
|
||||
String vtecPath = GfePyIncludeUtil.getVtecIncludePath();
|
||||
|
||||
pscript = new PythonScript(file.getAbsolutePath(),
|
||||
PyUtil.buildJepIncludePath(configPath, vtecPath),
|
||||
getClass().getClassLoader(), preEvals);
|
||||
// Look for HideConfigFile = True in the file
|
||||
try (PythonScript pscript = new PythonScript(lf.getFile()
|
||||
.getAbsolutePath(), PyUtil.buildJepIncludePath(configPath,
|
||||
vtecPath), getClass().getClassLoader(), preEvals)) {
|
||||
Boolean scriptValue = (Boolean) pscript.execute(
|
||||
"checkHideConfigFile", null);
|
||||
rtnVal = scriptValue.booleanValue();
|
||||
|
@ -108,10 +108,6 @@ public class ConfigCatalog {
|
|||
Priority.PROBLEM,
|
||||
"Error loading GFE config file: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
} finally {
|
||||
if (pscript != null) {
|
||||
pscript.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
return rtnVal;
|
||||
|
@ -122,8 +118,8 @@ public class ConfigCatalog {
|
|||
*
|
||||
* @return the localization files for the procedures.
|
||||
*/
|
||||
public LocalizationFile[] getFiles() {
|
||||
LocalizationFile[] procFiles = PathManagerFactory.getPathManager()
|
||||
public ILocalizationFile[] getFiles() {
|
||||
ILocalizationFile[] procFiles = PathManagerFactory.getPathManager()
|
||||
.listStaticFiles(LocalizationType.CAVE_STATIC,
|
||||
GfePyIncludeUtil.CONFIG, new String[] { EXTENSION },
|
||||
false, true);
|
||||
|
@ -136,9 +132,8 @@ public class ConfigCatalog {
|
|||
* @return the simple names of the procedures.
|
||||
*/
|
||||
public Collection<String> getNames() {
|
||||
Collection<String> result = new HashSet<String>();
|
||||
LocalizationFile[] procFiles = getFiles();
|
||||
result = scriptNames(procFiles);
|
||||
ILocalizationFile[] procFiles = getFiles();
|
||||
Collection<String> result = scriptNames(procFiles);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -148,8 +143,8 @@ public class ConfigCatalog {
|
|||
* @return The localization file for the script
|
||||
*/
|
||||
public LocalizationFile getFile(String scriptName) {
|
||||
String fname = GfePyIncludeUtil.CONFIG + File.separator + scriptName
|
||||
+ EXTENSION;
|
||||
String fname = GfePyIncludeUtil.CONFIG + IPathManager.SEPARATOR
|
||||
+ scriptName + EXTENSION;
|
||||
LocalizationFile file = PathManagerFactory.getPathManager()
|
||||
.getStaticLocalizationFile(LocalizationType.CAVE_STATIC, fname);
|
||||
return file;
|
||||
|
@ -163,16 +158,14 @@ public class ConfigCatalog {
|
|||
* the array of LocalizationFiles.
|
||||
* @return a Collection of simple script names with no duplicates.
|
||||
*/
|
||||
protected Collection<String> scriptNames(LocalizationFile[] scriptFiles) {
|
||||
protected Collection<String> scriptNames(ILocalizationFile[] scriptFiles) {
|
||||
Set<String> procs = new HashSet<String>();
|
||||
String fname = null;
|
||||
String[] fsplit = null;
|
||||
String script = null;
|
||||
if (scriptFiles != null) {
|
||||
for (LocalizationFile file : scriptFiles) {
|
||||
fname = file.getName();
|
||||
fsplit = fname.split(FileUtil.fileSeparatorRegex);
|
||||
script = fsplit[fsplit.length - 1].replaceAll("\\.py$", "");
|
||||
for (ILocalizationFile file : scriptFiles) {
|
||||
String fname = file.getPath();
|
||||
String[] fsplit = fname.split(FileUtil.fileSeparatorRegex);
|
||||
String script = fsplit[fsplit.length - 1].replaceAll("\\.py$",
|
||||
"");
|
||||
procs.add(script);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ import com.raytheon.uf.common.localization.LocalizationContext;
|
|||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.LocalizationUtil;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.site.notify.SiteActivationNotification;
|
||||
|
@ -149,7 +150,8 @@ import com.raytheon.viz.gfe.types.MutableInteger;
|
|||
* 10/30/2014 #3775 randerso Changed to createMutableDb before getting initial database inventory
|
||||
* 01/13/2015 #3955 randerso Changed getProductDatabase() to return mutableDb for EditTopo
|
||||
* 03/12/2015 #4246 randerso Changes to support VCModules at base, site, and user levels
|
||||
* 11/17/2015 #5129 dgilling Changes to support new IFPClienbt
|
||||
* 11/17/2015 #5129 dgilling Changes to support new IFPClient
|
||||
* 02/05/2016 #5242 dgilling Remove calls to deprecated Localization APIs.
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
|
@ -3129,15 +3131,9 @@ public class ParmManager implements IParmManager, IMessageClient {
|
|||
FileUtil.join("gfe", "vcmodule"), new String[] { "py" },
|
||||
false, true);
|
||||
for (LocalizationFile lf : files) {
|
||||
try {
|
||||
String modName = lf.getFile(false).getName()
|
||||
.split("\\.(?=[^\\.]+$)")[0];
|
||||
modMap.put(modName, lf);
|
||||
} catch (LocalizationException e) {
|
||||
statusHandler.error(
|
||||
"Error getting local file name for VCModule " + lf,
|
||||
e);
|
||||
}
|
||||
String modName = LocalizationUtil.extractName(lf.getPath())
|
||||
.replace(".py", "");
|
||||
modMap.put(modName, lf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.io.IOException;
|
|||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -60,12 +59,13 @@ import com.raytheon.uf.common.localization.LocalizationContext;
|
|||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.LocalizationUtil;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.SaveableOutputStream;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.python.concurrent.IPythonExecutor;
|
||||
import com.raytheon.uf.common.python.concurrent.PythonInterpreterFactory;
|
||||
import com.raytheon.uf.common.python.concurrent.IPythonJobListener;
|
||||
import com.raytheon.uf.common.python.concurrent.PythonInterpreterFactory;
|
||||
import com.raytheon.uf.common.python.concurrent.PythonJobCoordinator;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
@ -285,8 +285,8 @@ public class ReferenceSetManager implements IReferenceSetManager,
|
|||
* @param lf
|
||||
*/
|
||||
private void loadGroup(LocalizationFile lf) {
|
||||
String groupName = Paths.get(lf.getName()).getFileName().toString()
|
||||
.replace(".txt", "");
|
||||
String groupName = LocalizationUtil.extractName(lf.getPath()).replace(
|
||||
".txt", "");
|
||||
GroupID group = new GroupID(groupName, lf.isProtected(), lf
|
||||
.getContext().getLocalizationLevel());
|
||||
if (group.equals("Misc")) {
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.viz.gfe.core.internal;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -39,6 +40,7 @@ import com.raytheon.uf.common.dataplugin.gfe.sample.SampleId;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
|
||||
import com.raytheon.uf.common.gfe.ifpclient.IFPClient;
|
||||
import com.raytheon.uf.common.localization.FileUpdatedMessage;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFileObserver;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
|
@ -47,6 +49,7 @@ import com.raytheon.uf.common.localization.LocalizationFile;
|
|||
import com.raytheon.uf.common.localization.LocalizationUtil;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
|
@ -74,6 +77,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* files at multiple localization levels
|
||||
* Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException
|
||||
* Nov 19, 2015 5129 dgilling Support new IFPClient.
|
||||
* Feb 10, 2016 5242 dgilling Remove calls to deprecated Localization APIs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -158,23 +162,11 @@ public class SampleSetManager implements ISampleSetManager,
|
|||
getMarkerPoints();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
this.sampleSetDir.removeFileUpdatedObserver(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.ISampleSetManager#sampleSetLocations(java.lang
|
||||
* .String)
|
||||
*/
|
||||
@Override
|
||||
public List<Coordinate> sampleSetLocations(final String setName) {
|
||||
// verify set in inventory
|
||||
|
@ -190,41 +182,22 @@ public class SampleSetManager implements ISampleSetManager,
|
|||
String fileName = FileUtil.join(SAMPLE_SETS_DIR, sampleId.getName()
|
||||
+ ".xml");
|
||||
|
||||
LocalizationFile lf = this.pathManager.getLocalizationFile(
|
||||
this.pathManager.getContext(LocalizationType.COMMON_STATIC,
|
||||
ILocalizationFile lf = pathManager.getLocalizationFile(
|
||||
pathManager.getContext(LocalizationType.COMMON_STATIC,
|
||||
sampleId.getAccess()), fileName);
|
||||
|
||||
File file = null;
|
||||
try {
|
||||
file = lf.getFile(true);
|
||||
} catch (LocalizationException e) {
|
||||
if (file == null) {
|
||||
statusHandler.error("An error occurred retrieving SampleSet: "
|
||||
+ fileName, e);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Coordinate> points = Collections.emptyList();
|
||||
try (InputStream inStream = lf.openInputStream()) {
|
||||
SampleData sampleData = SampleData.getJAXBManager()
|
||||
.unmarshalFromInputStream(inStream);
|
||||
points = sampleData.getPoints();
|
||||
} catch (IOException | LocalizationException | SerializationException e) {
|
||||
statusHandler.error("Unable to load sampledata: " + lf, e);
|
||||
}
|
||||
|
||||
SampleData sampleData = null;
|
||||
try {
|
||||
sampleData = SampleData.getJAXBManager().unmarshalFromXmlFile(
|
||||
file.getAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
statusHandler.error("Unable to load sampledata: " + file, e);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return sampleData.getPoints();
|
||||
return points;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.ISampleSetManager#loadSampleSet(com.raytheon
|
||||
* .edex.plugin.gfe.sample.SampleId,
|
||||
* com.raytheon.viz.gfe.core.internal.SampleSetManager.SampleSetLoadMode)
|
||||
*/
|
||||
@Override
|
||||
public void loadSampleSet(final SampleId sampleId,
|
||||
SampleSetLoadMode loadMode) {
|
||||
|
@ -255,11 +228,6 @@ public class SampleSetManager implements ISampleSetManager,
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#clearSamples()
|
||||
*/
|
||||
@Override
|
||||
public void clearSamples() {
|
||||
mergeSamples(new ArrayList<Coordinate>(), SampleSetLoadMode.REPLACE);
|
||||
|
@ -268,12 +236,6 @@ public class SampleSetManager implements ISampleSetManager,
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seecom.raytheon.viz.gfe.core.ISampleSetManager#addAnchoredSample(com.
|
||||
* vividsolutions.jts.geom.Coordinate)
|
||||
*/
|
||||
@Override
|
||||
public void addAnchoredSample(final Coordinate sampleLocation) {
|
||||
mergeSamples(Arrays.asList(sampleLocation), SampleSetLoadMode.ADD);
|
||||
|
@ -282,26 +244,12 @@ public class SampleSetManager implements ISampleSetManager,
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredSample(com.
|
||||
* vividsolutions.jts.geom.Coordinate)
|
||||
*/
|
||||
@Override
|
||||
public void removeAnchoredSample(final Coordinate sampleLocation) {
|
||||
removeAnchoredSample(sampleLocation,
|
||||
ISampleSetManager.DEFAULT_THRESHOLD);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredSample(com.
|
||||
* vividsolutions.jts.geom.Coordinate, float)
|
||||
*/
|
||||
@Override
|
||||
public void removeAnchoredSample(final Coordinate sampleLocation,
|
||||
float threshold) {
|
||||
|
@ -312,12 +260,6 @@ public class SampleSetManager implements ISampleSetManager,
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seecom.raytheon.viz.gfe.core.ISampleSetManager#addAnchoredMarker(com.
|
||||
* vividsolutions.jts.geom.Coordinate)
|
||||
*/
|
||||
@Override
|
||||
public void addAnchoredMarker(final Coordinate location, final GridID gid) {
|
||||
String set = activeMarkerSet(gid);
|
||||
|
@ -330,25 +272,11 @@ public class SampleSetManager implements ISampleSetManager,
|
|||
saveSampleSet(locations, new SampleId(set));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredMarker(com.
|
||||
* vividsolutions.jts.geom.Coordinate)
|
||||
*/
|
||||
@Override
|
||||
public void removeAnchoredMarker(final Coordinate location, final GridID gid) {
|
||||
removeAnchoredMarker(location, gid, ISampleSetManager.DEFAULT_THRESHOLD);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.ISampleSetManager#removeAnchoredMarker(com.
|
||||
* vividsolutions.jts.geom.Coordinate, float)
|
||||
*/
|
||||
@Override
|
||||
public void removeAnchoredMarker(final Coordinate location,
|
||||
final GridID gid, float threshold) {
|
||||
|
@ -374,13 +302,6 @@ public class SampleSetManager implements ISampleSetManager,
|
|||
fireSampleSetChangedListeners();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.ISampleSetManager#anchoredMarkerAtLocation(
|
||||
* com.vividsolutions.jts.geom.Coordinate, float)
|
||||
*/
|
||||
@Override
|
||||
public boolean anchoredMarkerAtLocation(final Coordinate location,
|
||||
final GridID gid, float threshold) {
|
||||
|
@ -402,13 +323,6 @@ public class SampleSetManager implements ISampleSetManager,
|
|||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.ISampleSetManager#saveSampleSet(com.vividsolutions
|
||||
* .jts.geom.Coordinate[], com.raytheon.edex.plugin.gfe.sample.SampleId)
|
||||
*/
|
||||
@Override
|
||||
public boolean saveSampleSet(final List<Coordinate> sampleLocations,
|
||||
final SampleId sampleId) {
|
||||
|
@ -424,26 +338,12 @@ public class SampleSetManager implements ISampleSetManager,
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.ISampleSetManager#saveActiveSampleSet(com.raytheon
|
||||
* .edex.plugin.gfe.sample.SampleId)
|
||||
*/
|
||||
@Override
|
||||
public boolean saveActiveSampleSet(final SampleId sampleId) {
|
||||
this.loadedSet = sampleId;
|
||||
return saveSampleSet(this.locations, sampleId);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.ISampleSetManager#deleteSampleSet(com.raytheon
|
||||
* .edex.plugin.gfe.sample.SampleId)
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteSampleSet(final SampleId sampleId) {
|
||||
ServerResponse<?> sr = ifpClient.deleteSampleData(Arrays
|
||||
|
@ -459,13 +359,6 @@ public class SampleSetManager implements ISampleSetManager,
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.localization.ILocalizationFileObserver#fileUpdated
|
||||
* (com.raytheon.uf.common.localization.FileUpdatedMessage)
|
||||
*/
|
||||
@Override
|
||||
public void fileUpdated(FileUpdatedMessage message) {
|
||||
|
||||
|
@ -522,12 +415,6 @@ public class SampleSetManager implements ISampleSetManager,
|
|||
fireSampleSetChangedListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* mergeSamples(...) with default threshold
|
||||
*
|
||||
* @param mergeSet
|
||||
* @param mergeMode
|
||||
*/
|
||||
private void mergeSamples(final List<Coordinate> mergeSet,
|
||||
SampleSetLoadMode mergeMode) {
|
||||
mergeSamples(mergeSet, mergeMode, ISampleSetManager.DEFAULT_THRESHOLD);
|
||||
|
@ -599,32 +486,17 @@ public class SampleSetManager implements ISampleSetManager,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getLoadedSet()
|
||||
*/
|
||||
@Override
|
||||
public SampleId getLoadedSet() {
|
||||
return this.loadedSet;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getInventory()
|
||||
*/
|
||||
@Override
|
||||
public SampleId[] getInventory() {
|
||||
return this.inventory.values().toArray(
|
||||
new SampleId[this.inventory.size()]);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getInventoryAsStrings()
|
||||
*/
|
||||
@Override
|
||||
public String[] getInventoryAsStrings() {
|
||||
String[] retVal = new String[this.inventory.size()];
|
||||
|
@ -647,41 +519,21 @@ public class SampleSetManager implements ISampleSetManager,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getLocations()
|
||||
*/
|
||||
@Override
|
||||
public List<Coordinate> getLocations() {
|
||||
return new ArrayList<Coordinate>(this.locations);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#getMarkerLocations()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, List<Coordinate>> getMarkerLocations() {
|
||||
return this.markerLocations;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#isShowLatLon()
|
||||
*/
|
||||
@Override
|
||||
public boolean isShowLatLon() {
|
||||
return showLatLon;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.ISampleSetManager#setShowLatLon(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setShowLatLon(boolean showLatLon) {
|
||||
this.showLatLon = showLatLon;
|
||||
|
|
|
@ -22,7 +22,6 @@ package com.raytheon.viz.gfe.core.internal;
|
|||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.ArrayList;
|
||||
|
@ -35,12 +34,15 @@ import java.util.TreeMap;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange.Mode;
|
||||
import com.raytheon.uf.common.localization.FileUpdatedMessage;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFileObserver;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.SaveableOutputStream;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -62,6 +64,7 @@ import com.raytheon.viz.gfe.core.msgs.SelectTimeRangesChangedMsg;
|
|||
* Aug 06, 2013 #1561 njensen Use pm.listFiles() instead of pm.listStaticFiles()
|
||||
* Sep 08, 2014 #3592 randerso Changed to use new pm listStaticFiles()
|
||||
* Nov 18, 2015 #5129 dgilling Support new IFPClient.
|
||||
* Feb 05, 2016 #5242 dgilling Remove calls to deprecated Localization APIs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -115,12 +118,11 @@ public class SelectTimeRangeManager implements ISelectTimeRangeManager,
|
|||
return inventory;
|
||||
}
|
||||
|
||||
private SelectTimeRange loadTimeRange(LocalizationFile lf) {
|
||||
String rangeName = rangeNameFromFileName(lf.getName());
|
||||
private SelectTimeRange loadTimeRange(ILocalizationFile lf) {
|
||||
String rangeName = rangeNameFromFileName(lf.getPath());
|
||||
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
in = new BufferedReader(new InputStreamReader(lf.openInputStream()));
|
||||
try (BufferedReader in = new BufferedReader(new InputStreamReader(
|
||||
lf.openInputStream()))) {
|
||||
String[] s = in.readLine().split("\\s+");
|
||||
int start = Integer.parseInt(s[0]);
|
||||
int end = Integer.parseInt(s[1]);
|
||||
|
@ -135,19 +137,9 @@ public class SelectTimeRangeManager implements ISelectTimeRangeManager,
|
|||
return range;
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error reading SELECTTR file "
|
||||
+ lf.getFile().getAbsolutePath(), e);
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error closing file "
|
||||
+ lf.getFile().getAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
"Error reading SELECTTR file " + lf.toString(), e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -158,47 +150,34 @@ public class SelectTimeRangeManager implements ISelectTimeRangeManager,
|
|||
|
||||
@Override
|
||||
public void save(String name, int start, int end, Mode mode) {
|
||||
LocalizationFile lf = pathManager.getLocalizationFile(pathManager
|
||||
ILocalizationFile lf = pathManager.getLocalizationFile(pathManager
|
||||
.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.USER), FileUtil.join(FILE_PATH,
|
||||
FileUtil.mangle(name) + FILE_EXT));
|
||||
|
||||
BufferedWriter out = null;
|
||||
try {
|
||||
out = new BufferedWriter(new OutputStreamWriter(
|
||||
lf.openOutputStream()));
|
||||
try (SaveableOutputStream lfStream = lf.openOutputStream();
|
||||
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
|
||||
lfStream))) {
|
||||
out.write(String.format("%d %d %d", start, end, mode.ordinal()));
|
||||
out.close();
|
||||
out = null;
|
||||
lf.save();
|
||||
lfStream.save();
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error writing SELECTTR file "
|
||||
+ lf.getFile().getAbsolutePath(), e);
|
||||
} finally {
|
||||
try {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Error closing file "
|
||||
+ lf.getFile().getAbsolutePath(), e);
|
||||
}
|
||||
"Error writing SELECTTR file " + lf.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(String name) {
|
||||
LocalizationFile lf = pathManager.getLocalizationFile(pathManager
|
||||
ILocalizationFile lf = pathManager.getLocalizationFile(pathManager
|
||||
.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.USER), FileUtil.join(FILE_PATH,
|
||||
FileUtil.mangle(name) + FILE_EXT));
|
||||
try {
|
||||
lf.delete();
|
||||
} catch (Exception e) {
|
||||
} catch (LocalizationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error deleting SELECTTR file "
|
||||
+ lf.getFile().getAbsolutePath(), e);
|
||||
"Error deleting SELECTTR file " + lf.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.viz.gfe.core.internal;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -36,13 +37,16 @@ import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.weatherelement.WEGroup;
|
||||
import com.raytheon.uf.common.localization.FileUpdatedMessage;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFileObserver;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.LocalizationUtil;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.SaveableOutputStream;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
|
||||
|
@ -67,6 +71,7 @@ import com.raytheon.viz.gfe.core.IWEGroupManager;
|
|||
* Sep 30, 2013 2361 njensen Use JAXBManager for XML
|
||||
* Aug 13, 2015 4749 njensen Implemented dispose()
|
||||
* Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException
|
||||
* Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -145,32 +150,25 @@ public class WEGroupManager implements IWEGroupManager,
|
|||
|
||||
private void loadGroups() {
|
||||
IPathManager pathManager = PathManagerFactory.getPathManager();
|
||||
|
||||
LocalizationContext[] contexts = pathManager
|
||||
.getLocalSearchHierarchy(LocalizationType.CAVE_STATIC);
|
||||
LocalizationFile[] files = pathManager.listFiles(contexts, WEGROUP_DIR,
|
||||
new String[] { ".xml" }, false, true);
|
||||
ILocalizationFile[] files = pathManager.listFiles(contexts,
|
||||
WEGROUP_DIR, new String[] { ".xml" }, false, true);
|
||||
|
||||
this.inventory = new LinkedHashMap<LocalizationLevel, Set<String>>();
|
||||
for (LocalizationFile lf : files) {
|
||||
try {
|
||||
File file = lf.getFile(false);
|
||||
String fn = file.getName();
|
||||
LocalizationLevel levelType = lf.getContext()
|
||||
.getLocalizationLevel();
|
||||
inventory = new LinkedHashMap<LocalizationLevel, Set<String>>();
|
||||
for (ILocalizationFile lf : files) {
|
||||
String fn = LocalizationUtil.extractName(lf.getPath());
|
||||
LocalizationLevel levelType = lf.getContext()
|
||||
.getLocalizationLevel();
|
||||
|
||||
Set<String> inventoryList = this.inventory.get(levelType);
|
||||
if (inventoryList == null) {
|
||||
inventoryList = new HashSet<String>();
|
||||
this.inventory.put(levelType, inventoryList);
|
||||
}
|
||||
String s = construct(fn);
|
||||
if (s != null) {
|
||||
inventoryList.add(s);
|
||||
}
|
||||
} catch (LocalizationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error retrieving WE Group inventory", e);
|
||||
Set<String> inventoryList = inventory.get(levelType);
|
||||
if (inventoryList == null) {
|
||||
inventoryList = new HashSet<String>();
|
||||
inventory.put(levelType, inventoryList);
|
||||
}
|
||||
String s = construct(fn);
|
||||
if (s != null) {
|
||||
inventoryList.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -195,41 +193,20 @@ public class WEGroupManager implements IWEGroupManager,
|
|||
return displayName + SUFFIX;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.IWEGroupManager#save(java.lang.String,
|
||||
* com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID[],
|
||||
* com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID[])
|
||||
*/
|
||||
@Override
|
||||
public void save(String name, ParmID[] parmIDs, ParmID[] availableParmIDs) {
|
||||
WEGroup group = new WEGroup(name, parmIDs, availableParmIDs);
|
||||
this.save(name, group);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.internal.IWEGroupManager#remove(java.lang.String
|
||||
* )
|
||||
*/
|
||||
@Override
|
||||
public boolean remove(String name) {
|
||||
return this.delete(name);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.internal.IWEGroupManager#getParmIDs(java.lang
|
||||
* .String, com.raytheon.edex.plugin.gfe.db.objects.ParmID[])
|
||||
*/
|
||||
@Override
|
||||
public ParmID[] getParmIDs(String name, ParmID[] availableParmIDs) {
|
||||
LocalizationFile file = this.getLocalizationFile(name);
|
||||
ILocalizationFile file = getLocalizationFile(name);
|
||||
if (file == null || !file.exists()) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error loading weather element group \"" + name
|
||||
|
@ -238,25 +215,17 @@ public class WEGroupManager implements IWEGroupManager,
|
|||
}
|
||||
|
||||
WEGroup weGroup = null;
|
||||
try {
|
||||
weGroup = jaxb.unmarshalFromXmlFile(file.getFile().getPath());
|
||||
try (InputStream inStream = file.openInputStream()) {
|
||||
weGroup = jaxb.unmarshalFromInputStream(inStream);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error getting weather element group", e);
|
||||
return new ParmID[0];
|
||||
}
|
||||
|
||||
return getParmIDs(weGroup, availableParmIDs);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.internal.IWEGroupManager#getParmIDs(com.raytheon
|
||||
* .edex.plugin.gfe.weatherElement.WEGroup,
|
||||
* com.raytheon.edex.plugin.gfe.db.objects.ParmID[])
|
||||
*/
|
||||
@Override
|
||||
public ParmID[] getParmIDs(final WEGroup bundle,
|
||||
final ParmID[] availableParmIDs) {
|
||||
|
@ -288,13 +257,6 @@ public class WEGroupManager implements IWEGroupManager,
|
|||
return parmIDs.toArray(new ParmID[parmIDs.size()]);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.internal.AbstractFileBasedManager#getInventory
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
public List<String> getInventory() {
|
||||
List<String> completeList = new ArrayList<String>();
|
||||
|
@ -317,11 +279,6 @@ public class WEGroupManager implements IWEGroupManager,
|
|||
return Collections.unmodifiableList(completeList);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.gfe.core.IWEGroupManager#getDefaultGroup()
|
||||
*/
|
||||
@Override
|
||||
public String getDefaultGroup() {
|
||||
String defaultGroup = Activator.getDefault().getPreferenceStore()
|
||||
|
@ -332,12 +289,6 @@ public class WEGroupManager implements IWEGroupManager,
|
|||
return defaultGroup;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.gfe.core.IWEGroupManager#isProtected(java.lang.String )
|
||||
*/
|
||||
@Override
|
||||
public boolean isProtected(String name) {
|
||||
LocalizationFile file = getLocalizationFile(name);
|
||||
|
@ -375,17 +326,18 @@ public class WEGroupManager implements IWEGroupManager,
|
|||
}
|
||||
|
||||
private void save(String key, WEGroup objectToSave) {
|
||||
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
|
||||
LocalizationContext lc = pm.getContext(LocalizationType.CAVE_STATIC,
|
||||
LocalizationLevel.USER);
|
||||
|
||||
LocalizationFile file = pm.getLocalizationFile(lc,
|
||||
ILocalizationFile file = pm.getLocalizationFile(lc,
|
||||
FileUtil.join(WEGROUP_DIR, getName(key)));
|
||||
try {
|
||||
jaxb.marshalToXmlFile(objectToSave, file.getFile().getPath());
|
||||
file.save();
|
||||
try (SaveableOutputStream out = file.openOutputStream()) {
|
||||
jaxb.marshalToStream(objectToSave, out);
|
||||
out.save();
|
||||
} catch (IOException e) {
|
||||
String msg = String.format("Error writing to WEGroup file %s: %s",
|
||||
file, e.getLocalizedMessage());
|
||||
statusHandler.error(msg);
|
||||
} catch (LocalizationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error saving to localization server", e);
|
||||
|
@ -394,10 +346,10 @@ public class WEGroupManager implements IWEGroupManager,
|
|||
e);
|
||||
}
|
||||
|
||||
Set<String> list = this.inventory.get(LocalizationLevel.USER);
|
||||
Set<String> list = inventory.get(LocalizationLevel.USER);
|
||||
if (list == null) {
|
||||
list = new HashSet<String>();
|
||||
this.inventory.put(LocalizationLevel.USER, list);
|
||||
inventory.put(LocalizationLevel.USER, list);
|
||||
}
|
||||
list.add(key);
|
||||
}
|
||||
|
@ -426,13 +378,6 @@ public class WEGroupManager implements IWEGroupManager,
|
|||
return Collections.unmodifiableList(completeList);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.localization.ILocalizationFileObserver#fileUpdated
|
||||
* (com.raytheon.uf.common.localization.FileUpdatedMessage)
|
||||
*/
|
||||
@Override
|
||||
public void fileUpdated(FileUpdatedMessage message) {
|
||||
loadGroups();
|
||||
|
|
|
@ -21,10 +21,11 @@ package com.raytheon.viz.gfe.dialogs;
|
|||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
|
@ -62,16 +63,16 @@ import org.eclipse.swt.widgets.Shell;
|
|||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.SaveableOutputStream;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.time.SimulatedTime;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
import com.raytheon.viz.gfe.Activator;
|
||||
|
@ -91,6 +92,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
|||
* Oct 28, 2015 5054 randerso Place GfeConfigDialog on current monitor if
|
||||
* parent shell is not visible.
|
||||
* Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException
|
||||
* Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -411,60 +413,38 @@ public class GFEConfigDialog extends CaveJFACEDialog {
|
|||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext context = pathMgr.getContext(
|
||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||
LocalizationFile lf = pathMgr.getLocalizationFile(context, LAST_CONFIG);
|
||||
File file = lf.getFile();
|
||||
ILocalizationFile lf = pathMgr
|
||||
.getLocalizationFile(context, LAST_CONFIG);
|
||||
|
||||
BufferedWriter out = null;
|
||||
try {
|
||||
out = new BufferedWriter(new FileWriter(file));
|
||||
try (SaveableOutputStream outStream = lf.openOutputStream();
|
||||
Writer out = new BufferedWriter(new OutputStreamWriter(
|
||||
outStream))) {
|
||||
out.write(config);
|
||||
out.close();
|
||||
outStream.save();
|
||||
} catch (IOException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error saving config file selection", e);
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
lf.save();
|
||||
statusHandler.error("Error writing config file selection", e);
|
||||
} catch (LocalizationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error saving config file selection", e);
|
||||
statusHandler.error("Error saving config file selection", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadLastConfig() {
|
||||
config = null;
|
||||
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext context = pathMgr.getContext(
|
||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||
LocalizationFile lf = pathMgr.getLocalizationFile(context, LAST_CONFIG);
|
||||
File file = lf.getFile();
|
||||
ILocalizationFile lf = pathMgr
|
||||
.getLocalizationFile(context, LAST_CONFIG);
|
||||
|
||||
if (file.exists()) {
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
in = new BufferedReader(new FileReader(file));
|
||||
config = null;
|
||||
if (lf.exists()) {
|
||||
try (InputStream inStream = lf.openInputStream();
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(inStream))) {
|
||||
config = in.readLine();
|
||||
} catch (IOException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error loading config file selection", e);
|
||||
} catch (IOException | LocalizationException e) {
|
||||
statusHandler.error("Error loading config file selection", e);
|
||||
config = null;
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,11 +40,11 @@ import org.eclipse.swt.widgets.Text;
|
|||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.reference.GroupID;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
@ -63,9 +63,10 @@ import com.raytheon.viz.ui.widgets.ToggleSelectList;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 11, 2008 Eric Babin Initial Creation
|
||||
* Mar 11, 2008 Eric Babin Initial Creation
|
||||
* Oct 24, 2012 1287 rferrel Code clean part of non-blocking dialog.
|
||||
* Nov 18, 2015 5129 dgilling Code cleanup to support ReferenceSetManager changes.
|
||||
* Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -363,11 +364,11 @@ public class SaveDeleteEditAreaGroupDialog extends CaveJFACEDialog {
|
|||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext ctx = pm.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.USER);
|
||||
LocalizationFile lf = pm.getLocalizationFile(ctx,
|
||||
ILocalizationFile lf = pm.getLocalizationFile(ctx,
|
||||
ReferenceSetManager.EDIT_AREAS_DIR
|
||||
+ IPathManager.SEPARATOR + id.getName()
|
||||
+ ".xml");
|
||||
boolean verify = AccessMgr.verifyDelete(lf.getName(), lf
|
||||
boolean verify = AccessMgr.verifyDelete(lf.getPath(), lf
|
||||
.getContext().getLocalizationType(), false);
|
||||
if (!verify) {
|
||||
return;
|
||||
|
|
|
@ -44,11 +44,11 @@ import org.eclipse.swt.widgets.Text;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData.RefType;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceID;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
@ -71,6 +71,7 @@ import com.raytheon.viz.ui.widgets.ToggleSelectList;
|
|||
* Sep 10, 2010 randerso Initial creation
|
||||
* Oct 24, 2012 1287 rferrel Code clean up part of non-blocking dialog.
|
||||
* Nov 18, 2015 5129 dgilling Code cleanup to support ReferenceSetManager changes.
|
||||
* Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -349,10 +350,10 @@ public class SaveDeleteRefDialog extends CaveJFACEDialog {
|
|||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext ctx = pm.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.USER);
|
||||
LocalizationFile lf = pm.getLocalizationFile(ctx,
|
||||
ILocalizationFile lf = pm.getLocalizationFile(ctx,
|
||||
ReferenceSetManager.EDIT_AREAS_DIR + IPathManager.SEPARATOR
|
||||
+ id.getName() + ".xml");
|
||||
boolean verify = AccessMgr.verifyDelete(lf.getName(), lf
|
||||
boolean verify = AccessMgr.verifyDelete(lf.getPath(), lf
|
||||
.getContext().getLocalizationType(), false);
|
||||
if (!verify) {
|
||||
return false;
|
||||
|
|
|
@ -39,11 +39,11 @@ import org.eclipse.swt.widgets.Shell;
|
|||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.sample.SampleId;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
@ -64,6 +64,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
|||
* Oct 24, 2012 1287 rferrel Code clean up for non-blocking dialog.
|
||||
* Sep 15, 2014 3592 randerso Re-implemented to match A1
|
||||
* Nov 19, 2014 5129 dgilling Support SampleSetManager changes.
|
||||
* Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -237,9 +238,9 @@ public class SaveDeleteSampleSetDialog extends CaveJFACEDialog {
|
|||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext ctx = pm.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.USER);
|
||||
LocalizationFile lf = pm.getLocalizationFile(ctx,
|
||||
ILocalizationFile lf = pm.getLocalizationFile(ctx,
|
||||
SampleSetManager.SAMPLE_SETS_DIR + id.getName() + ".xml");
|
||||
boolean verify = AccessMgr.verifyDelete(lf.getName(), lf
|
||||
boolean verify = AccessMgr.verifyDelete(lf.getPath(), lf
|
||||
.getContext().getLocalizationType(), false);
|
||||
if (!verify) {
|
||||
return;
|
||||
|
|
|
@ -100,6 +100,7 @@ import com.raytheon.uf.common.jms.notification.INotificationObserver;
|
|||
import com.raytheon.uf.common.jms.notification.NotificationException;
|
||||
import com.raytheon.uf.common.jms.notification.NotificationMessage;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -182,6 +183,7 @@ import com.raytheon.viz.ui.simulatedtime.SimulatedTimeOperations;
|
|||
* match the current time
|
||||
* 01/21/2016 18505 lshi Resent product should have same WMO, MND, and segment times
|
||||
* as original product.
|
||||
* 02/05/2016 5242 dgilling Remove calls to deprecated Localization APIs.
|
||||
* </pre>
|
||||
*
|
||||
* @author lvenable
|
||||
|
@ -2425,7 +2427,7 @@ public class ProductEditorComp extends Composite implements
|
|||
String product = null;
|
||||
try {
|
||||
product = readFile(file);
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException | LocalizationException ex) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Failed to load product "
|
||||
+ pil, ex);
|
||||
return;
|
||||
|
|
|
@ -22,10 +22,14 @@ package com.raytheon.viz.gfe.product;
|
|||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -35,7 +39,9 @@ import com.raytheon.uf.common.localization.LocalizationContext;
|
|||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.LocalizationUtil;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.SaveableOutputStream;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.time.SimulatedTime;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
|
@ -50,6 +56,7 @@ import com.raytheon.viz.core.mode.CAVEMode;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 11 Feb 2010 4132 ryu Initial creation
|
||||
* Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException
|
||||
* Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -102,7 +109,7 @@ public class ProductFileUtil {
|
|||
ArrayList<String> names = new ArrayList<String>();
|
||||
String regex = "2\\d{7}_\\d{6}_" + pil;
|
||||
for (LocalizationFile f : files) {
|
||||
String fname = f.getFile().getName();
|
||||
String fname = LocalizationUtil.extractName(f.getPath());
|
||||
if (fname.matches(regex)) {
|
||||
names.add(fname);
|
||||
}
|
||||
|
@ -133,54 +140,56 @@ public class ProductFileUtil {
|
|||
}
|
||||
|
||||
static public void writeFile(String text, File file) throws IOException {
|
||||
if (!file.exists()) {
|
||||
if (file.getParentFile() != null) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
}
|
||||
Path filePath = file.toPath();
|
||||
Files.createDirectories(filePath);
|
||||
|
||||
Writer out = null;
|
||||
try {
|
||||
out = new BufferedWriter(new FileWriter(file));
|
||||
out.write(text);
|
||||
} finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
try (Writer out = Files.newBufferedWriter(filePath,
|
||||
StandardCharsets.UTF_8)) {
|
||||
writeFile(text, out);
|
||||
}
|
||||
}
|
||||
|
||||
static public String readFile(File file) throws IOException {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
in = new BufferedReader(new FileReader(file));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
builder.append(line);
|
||||
builder.append(System.getProperty("line.separator"));
|
||||
}
|
||||
} finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
try (BufferedReader in = Files.newBufferedReader(file.toPath(),
|
||||
StandardCharsets.UTF_8)) {
|
||||
return readFile(in);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
static public void writeFile(String text, LocalizationFile localizationFile)
|
||||
throws IOException, LocalizationException {
|
||||
File file = localizationFile.getFile();
|
||||
writeFile(text, file);
|
||||
|
||||
localizationFile.save();
|
||||
try (SaveableOutputStream outStream = localizationFile
|
||||
.openOutputStream();
|
||||
Writer out = new BufferedWriter(new OutputStreamWriter(
|
||||
outStream))) {
|
||||
writeFile(text, out);
|
||||
out.close();
|
||||
outStream.save();
|
||||
}
|
||||
}
|
||||
|
||||
static public String readFile(LocalizationFile localizationFile)
|
||||
throws IOException {
|
||||
File file = localizationFile.getFile();
|
||||
return readFile(file);
|
||||
throws IOException, LocalizationException {
|
||||
try (InputStream inStream = localizationFile.openInputStream();
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(
|
||||
inStream))) {
|
||||
return readFile(in);
|
||||
}
|
||||
}
|
||||
|
||||
private static String readFile(BufferedReader reader) throws IOException {
|
||||
StringBuilder contents = new StringBuilder();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
contents.append(line);
|
||||
contents.append(System.getProperty("line.separator"));
|
||||
}
|
||||
|
||||
return contents.toString();
|
||||
}
|
||||
|
||||
private static void writeFile(String text, Writer writer)
|
||||
throws IOException {
|
||||
writer.write(text);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ package com.raytheon.viz.gfe.smarttool;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
|
@ -33,6 +32,7 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel
|
|||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.SaveableOutputStream;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.python.PythonFileFilter;
|
||||
import com.raytheon.viz.gfe.GFEOperationFailedException;
|
||||
|
@ -48,6 +48,7 @@ import com.raytheon.viz.gfe.GFEOperationFailedException;
|
|||
* Apr 28, 2009 njensen Initial creation
|
||||
* Apr 20, 2015 4027 randerso Changes to support GFE formatter auto tests
|
||||
* Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException
|
||||
* Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -93,7 +94,7 @@ public class TextFileUtil {
|
|||
LocalizationContext ctx = PATH_MGR.getContext(source.getContext()
|
||||
.getLocalizationType(), LocalizationLevel.USER);
|
||||
|
||||
LocalizationFile destLf = getTextFile(ctx, source.getName());
|
||||
LocalizationFile destLf = getTextFile(ctx, source.getPath());
|
||||
return destLf;
|
||||
}
|
||||
|
||||
|
@ -138,7 +139,6 @@ public class TextFileUtil {
|
|||
getPathFromType(dest, fileType));
|
||||
try {
|
||||
copy(srcLf, destLf);
|
||||
destLf.save();
|
||||
} catch (Exception e) {
|
||||
throw new GFEOperationFailedException(
|
||||
"Unable to save localization file", e);
|
||||
|
@ -168,7 +168,7 @@ public class TextFileUtil {
|
|||
Files.createDirectories(dir.toPath());
|
||||
|
||||
try (InputStream in = srcLf.openInputStream();
|
||||
OutputStream out = destLf.openOutputStream()) {
|
||||
SaveableOutputStream out = destLf.openOutputStream()) {
|
||||
|
||||
// Transfer bytes from in to out
|
||||
byte[] buf = new byte[1024];
|
||||
|
@ -176,6 +176,7 @@ public class TextFileUtil {
|
|||
while ((len = in.read(buf)) > 0) {
|
||||
out.write(buf, 0, len);
|
||||
}
|
||||
out.save();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ import com.raytheon.uf.common.localization.LocalizationContext;
|
|||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.LocalizationUtil;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.SaveableOutputStream;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
|
@ -82,6 +83,7 @@ import com.raytheon.viz.gfe.textformatter.CombinationsFileUtil.ComboData.Entry;
|
|||
* Oct 07, 2015 #4695 dgilling Code cleanup to remove compile warnings.
|
||||
* Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException
|
||||
* Nov 18, 2015 #5129 dgilling Support new IFPClient.
|
||||
* Feb 05, 2016 5242 dgilling Remove calls to deprecated Localization APIs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -156,8 +158,8 @@ public class CombinationsFileUtil {
|
|||
}
|
||||
|
||||
public static String fileToId(LocalizationFile file) {
|
||||
File f = new File(file.getName());
|
||||
String id = f.getName().replace(".xml", "");
|
||||
String id = LocalizationUtil.extractName(file.getPath()).replace(
|
||||
".xml", "");
|
||||
id = FileUtil.unmangle(id);
|
||||
|
||||
return id;
|
||||
|
@ -215,7 +217,7 @@ public class CombinationsFileUtil {
|
|||
throws SerializationException, IOException, LocalizationException {
|
||||
LocalizationFile lf = idToFile(id);
|
||||
try (InputStream in = lf.openInputStream()) {
|
||||
ComboData comboData = (ComboData) jaxb.unmarshalFromInputStream(in);
|
||||
ComboData comboData = jaxb.unmarshalFromInputStream(in);
|
||||
|
||||
Map<String, Integer> comboDict = new HashMap<String, Integer>(
|
||||
comboData.combos.size());
|
||||
|
|
|
@ -21,31 +21,16 @@ package com.raytheon.viz.gfe.textproduct;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
/**
|
||||
* Utilities for text products
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sept 23, 2008 askripsky Initial creation
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sept 23, 2008 askripsky Initial creation
|
||||
* Sept 09, 2013 #2033 dgilling Remove dead code.
|
||||
* Feb 05, 2016 #5242 dgilling Remove dead code.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -54,8 +39,6 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
|||
*/
|
||||
|
||||
public class TextProductUtils {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(TextProductUtils.class);
|
||||
|
||||
// Extension of text products
|
||||
public static final String EXTENSION = ".py";
|
||||
|
@ -83,181 +66,4 @@ public class TextProductUtils {
|
|||
// Root path for Utilities
|
||||
public final static String UTILITIES_PATH = TEXT_PRODUCTS_ROOT_PATH
|
||||
+ File.separator + "utilities";
|
||||
|
||||
/**
|
||||
* Copies the source file
|
||||
*
|
||||
* @param oldFileName
|
||||
* The file to be copied
|
||||
* @param newFileName
|
||||
* The destination file
|
||||
* @param type
|
||||
* Designates whether the file is a product or a utility
|
||||
* @throws VizException
|
||||
* Exception if the file doesn't get copied correctly
|
||||
*/
|
||||
public static void copyFile(String oldFileName, String newFileName,
|
||||
String type) throws VizException {
|
||||
// Make sure the new name has the correct extension
|
||||
if (!newFileName.endsWith(EXTENSION)) {
|
||||
newFileName += EXTENSION;
|
||||
}
|
||||
|
||||
// Get file from catalogue
|
||||
LocalizationFile oldFile = TextProductCatalogue.getInstance().getEntry(
|
||||
oldFileName, type);
|
||||
|
||||
// Get new file for the Site
|
||||
LocalizationFile newFile = newTextProductFile(newFileName, type);
|
||||
|
||||
// Make a copy to the Site location
|
||||
try {
|
||||
// Copy file
|
||||
FileUtil.copyFile(oldFile.getFile(), newFile.getFile());
|
||||
|
||||
newFile.save();
|
||||
|
||||
// Add entry to catalogue
|
||||
TextProductCatalogue.getInstance().addEntry(newFileName, newFile,
|
||||
type);
|
||||
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error copying text product", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a text product or utility.
|
||||
*
|
||||
* @param toolToDelete
|
||||
* the name of the tool
|
||||
* @throws VizException
|
||||
*/
|
||||
public static void deleteTextProduct(String textProductToDelete,
|
||||
String textProductType) throws VizException {
|
||||
// Retrieve a handle to the actual file
|
||||
LocalizationFile file = TextProductCatalogue.getInstance().getEntry(
|
||||
textProductToDelete, textProductType);
|
||||
|
||||
if (file.getContext().getLocalizationLevel() != LocalizationLevel.BASE) {
|
||||
if ((file != null) && file.getFile().exists()) {
|
||||
try {
|
||||
file.delete();
|
||||
|
||||
TextProductCatalogue.getInstance().removeEntry(
|
||||
textProductToDelete, textProductType);
|
||||
} catch (Exception e) {
|
||||
throw new VizException(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new VizException("Can't delete base text product "
|
||||
+ textProductToDelete);
|
||||
}
|
||||
}
|
||||
|
||||
private static LocalizationFile newTextProductFile(String newName,
|
||||
String type) throws VizException {
|
||||
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
|
||||
// Get context for the Site
|
||||
LocalizationContext cx = pathMgr.getContext(
|
||||
LocalizationType.CAVE_STATIC, LocalizationLevel.SITE);
|
||||
|
||||
// Build the path to the new file
|
||||
String path = (type.equals(PRODUCT) ? PRODUCTS_PATH : UTILITIES_PATH)
|
||||
+ File.separator + newName;
|
||||
|
||||
// Verify the extension is correct
|
||||
if (!path.endsWith(EXTENSION)) {
|
||||
path += EXTENSION;
|
||||
}
|
||||
|
||||
// the created file
|
||||
LocalizationFile rval = PathManagerFactory.getPathManager()
|
||||
.getLocalizationFile(cx, path);
|
||||
|
||||
// Check to see if the file exists
|
||||
// If not, create it
|
||||
File file = rval.getFile();
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
// Check to see if the directory exists
|
||||
File dir = file.getParentFile();
|
||||
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
file.createNewFile();
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new VizException(e);
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
public static LocalizationLevel getLocalizationLevel(String entryName,
|
||||
String entryType) {
|
||||
return TextProductCatalogue.getInstance()
|
||||
.getEntry(entryName, entryType).getContext()
|
||||
.getLocalizationLevel();
|
||||
}
|
||||
|
||||
public static void renameFile(String oldName, String newName, String type)
|
||||
throws VizException {
|
||||
|
||||
// Verify the extension is correct
|
||||
if (!newName.endsWith(EXTENSION)) {
|
||||
newName += EXTENSION;
|
||||
}
|
||||
|
||||
// Rename the localization file and entry
|
||||
try {
|
||||
copyFile(oldName, newName, type);
|
||||
deleteTextProduct(oldName, type);
|
||||
} catch (Exception e) {
|
||||
throw new VizException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean promptForOverwrite(String name, String type) {
|
||||
boolean okToOverwrite = true;
|
||||
|
||||
if (!name.endsWith(EXTENSION)) {
|
||||
name += EXTENSION;
|
||||
}
|
||||
|
||||
LocalizationFile preexistingFile = TextProductCatalogue.getInstance()
|
||||
.getEntry(name, type);
|
||||
|
||||
if (preexistingFile != null) {
|
||||
// Initialize the confirmation prompt
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
|
||||
if (preexistingFile.getContext().getLocalizationLevel() == LocalizationLevel.BASE) {
|
||||
// Do you want to create a site copy?
|
||||
String prompt = name
|
||||
+ " exists at the BASE Level and cannot be modified.\nDo you"
|
||||
+ " want to make a copy that can be modified at the SITE Level?";
|
||||
|
||||
okToOverwrite = MessageDialog.openConfirm(shell,
|
||||
"Item Overwrite", prompt);
|
||||
} else {
|
||||
// A Site file
|
||||
String prompt = name
|
||||
+ " already exists.\nDo you want to overwrite it?";
|
||||
|
||||
okToOverwrite = MessageDialog.openConfirm(shell,
|
||||
"Item Overwrite", prompt);
|
||||
}
|
||||
}
|
||||
|
||||
return okToOverwrite;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.viz.ghg.monitor.data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -31,7 +32,6 @@ import java.util.Set;
|
|||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import jep.JepException;
|
||||
|
@ -44,15 +44,18 @@ import org.eclipse.swt.widgets.Display;
|
|||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.SaveableOutputStream;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.python.PyUtil;
|
||||
import com.raytheon.uf.common.python.PythonScript;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
|
||||
import com.raytheon.uf.common.site.SiteMap;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
@ -89,6 +92,7 @@ import com.raytheon.viz.ui.statusline.StatusStore;
|
|||
* Nov 12, 2015 4834 njensen Changed LocalizationOpFailedException to LocalizationException
|
||||
* Dec 16, 2015 5184 dgilling Remove viz.gfe dependencies.
|
||||
* Feb 05, 2016 5316 randerso Moved notification of filter change into this class
|
||||
* Feb 05, 2016 #5242 dgilling Remove calls to deprecated Localization APIs.
|
||||
* </pre>
|
||||
*
|
||||
* @author lvenable
|
||||
|
@ -783,21 +787,19 @@ public final class GhgConfigData {
|
|||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext locCtx = pathMgr.getContext(
|
||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||
LocalizationFile localizationFile = pathMgr.getLocalizationFile(locCtx,
|
||||
CONFIG_PATH);
|
||||
File configFile = localizationFile.getFile();
|
||||
ILocalizationFile localizationFile = pathMgr.getLocalizationFile(
|
||||
locCtx, CONFIG_PATH);
|
||||
|
||||
try {
|
||||
JAXBContext ctx = JAXBContext.newInstance(GhgConfigXml.class);
|
||||
Marshaller marshaller = ctx.createMarshaller();
|
||||
marshaller.marshal(config, configFile);
|
||||
localizationFile.save();
|
||||
try (SaveableOutputStream outStream = localizationFile
|
||||
.openOutputStream()) {
|
||||
SingleTypeJAXBManager<GhgConfigXml> jaxb = SingleTypeJAXBManager
|
||||
.createWithoutException(GhgConfigXml.class);
|
||||
jaxb.marshalToStream(config, outStream);
|
||||
outStream.save();
|
||||
StatusStore.updateStatus(StatusConstants.CATEGORY_GHG,
|
||||
"Saved configuration", StatusMessage.Importance.REGULAR);
|
||||
|
||||
} catch (JAXBException | LocalizationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error saving GHG Monitor configuration", e);
|
||||
} catch (IOException | LocalizationException | SerializationException e) {
|
||||
statusHandler.error("Error saving GHG Monitor configuration", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.weather.WeatherSubKey;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.weather.WxDefinition;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
|
@ -117,6 +118,7 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 13, 2015 #5129 dgilling Initial creation
|
||||
* Feb 05, 2016 #5242 dgilling Replace calls to deprecated Localization APIs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -572,7 +574,7 @@ public class IFPClient {
|
|||
LocalizationType.COMMON_STATIC, SAMPLE_SETS_DIR,
|
||||
new String[] { ".xml" }, false, true);
|
||||
for (LocalizationFile lf : files) {
|
||||
String name = LocalizationUtil.extractName(lf.getName()).replace(
|
||||
String name = LocalizationUtil.extractName(lf.getPath()).replace(
|
||||
".xml", "");
|
||||
inv.add(new SampleId(name, false, lf.getContext()
|
||||
.getLocalizationLevel()));
|
||||
|
@ -599,7 +601,7 @@ public class IFPClient {
|
|||
new String[] { ".xml" }, false, true);
|
||||
if (contents != null) {
|
||||
for (LocalizationFile lf : contents) {
|
||||
String area = LocalizationUtil.extractName(lf.getName())
|
||||
String area = LocalizationUtil.extractName(lf.getPath())
|
||||
.replace(".xml", "");
|
||||
refIDs.add(new ReferenceID(area, false, lf.getContext()
|
||||
.getLocalizationLevel()));
|
||||
|
@ -625,7 +627,7 @@ public class IFPClient {
|
|||
LocalizationContext ctx = pm.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.USER);
|
||||
for (SampleData sample : sampleData) {
|
||||
LocalizationFile lf = pm.getLocalizationFile(ctx, SAMPLE_SETS_DIR
|
||||
ILocalizationFile lf = pm.getLocalizationFile(ctx, SAMPLE_SETS_DIR
|
||||
+ IPathManager.SEPARATOR + sample.getSampleId().getName()
|
||||
+ ".xml");
|
||||
try (SaveableOutputStream out = lf.openOutputStream()) {
|
||||
|
@ -660,7 +662,7 @@ public class IFPClient {
|
|||
LocalizationContext ctx = pm.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.USER);
|
||||
for (ReferenceData refData : referenceData) {
|
||||
LocalizationFile lf = pm.getLocalizationFile(ctx, EDIT_AREAS_DIR
|
||||
ILocalizationFile lf = pm.getLocalizationFile(ctx, EDIT_AREAS_DIR
|
||||
+ IPathManager.SEPARATOR + refData.getId().getName()
|
||||
+ ".xml");
|
||||
try (SaveableOutputStream out = lf.openOutputStream()) {
|
||||
|
@ -694,7 +696,7 @@ public class IFPClient {
|
|||
LocalizationLevel.USER);
|
||||
for (SampleId id : ids) {
|
||||
try {
|
||||
LocalizationFile lf = pm.getLocalizationFile(ctx,
|
||||
ILocalizationFile lf = pm.getLocalizationFile(ctx,
|
||||
SAMPLE_SETS_DIR + IPathManager.SEPARATOR + id.getName()
|
||||
+ ".xml");
|
||||
lf.delete();
|
||||
|
@ -722,7 +724,7 @@ public class IFPClient {
|
|||
LocalizationLevel.USER);
|
||||
for (ReferenceID id : ids) {
|
||||
try {
|
||||
LocalizationFile lf = pm.getLocalizationFile(ctx,
|
||||
ILocalizationFile lf = pm.getLocalizationFile(ctx,
|
||||
EDIT_AREAS_DIR + IPathManager.SEPARATOR + id.getName()
|
||||
+ ".xml");
|
||||
lf.delete();
|
||||
|
@ -773,14 +775,14 @@ public class IFPClient {
|
|||
for (SampleId id : ids) {
|
||||
String filePath = SAMPLE_SETS_DIR + IPathManager.SEPARATOR
|
||||
+ id.getName() + ".xml";
|
||||
LocalizationFile lf = PathManagerFactory.getPathManager()
|
||||
ILocalizationFile lf = PathManagerFactory.getPathManager()
|
||||
.getStaticLocalizationFile(LocalizationType.COMMON_STATIC,
|
||||
filePath);
|
||||
|
||||
if (lf != null) {
|
||||
try (InputStream in = lf.openInputStream()) {
|
||||
SampleData sampleData = (SampleData) SampleData
|
||||
.getJAXBManager().unmarshalFromInputStream(in);
|
||||
SampleData sampleData = SampleData.getJAXBManager()
|
||||
.unmarshalFromInputStream(in);
|
||||
sampleData.setSampleId(id);
|
||||
data.add(sampleData);
|
||||
} catch (Exception e) {
|
||||
|
@ -844,13 +846,13 @@ public class IFPClient {
|
|||
for (ReferenceID id : ids) {
|
||||
String filePath = EDIT_AREAS_DIR + IPathManager.SEPARATOR
|
||||
+ id.getName() + ".xml";
|
||||
LocalizationFile lf = PathManagerFactory.getPathManager()
|
||||
ILocalizationFile lf = PathManagerFactory.getPathManager()
|
||||
.getStaticLocalizationFile(LocalizationType.COMMON_STATIC,
|
||||
filePath);
|
||||
if (lf != null) {
|
||||
try (InputStream in = lf.openInputStream()) {
|
||||
ReferenceData refData = (ReferenceData) ReferenceData
|
||||
.getJAXBManager().unmarshalFromInputStream(in);
|
||||
ReferenceData refData = ReferenceData.getJAXBManager()
|
||||
.unmarshalFromInputStream(in);
|
||||
refData.setId(new ReferenceID(id.getName(), false, lf
|
||||
.getContext().getLocalizationLevel()));
|
||||
refData.setGloc(gridLocation);
|
||||
|
|
Loading…
Add table
Reference in a new issue