Merge tag 'OB_14.4.1-50' into int_15.1.1
14.4.1-50 Conflicts: cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java Former-commit-id: a2a24493e5015323a22fbce1b2cb7b28f81b9f9c
This commit is contained in:
commit
0fa6593639
7 changed files with 149 additions and 25 deletions
|
@ -37,10 +37,11 @@ import com.raytheon.uf.common.localization.LocalizationContext;
|
|||
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.viz.core.localization.CAVELocalizationAdapter;
|
||||
import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* A {@link BooleanFieldEditor} which adds a button that can be used to
|
||||
* synchronize localization files with the server.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -48,7 +49,8 @@ import com.raytheon.uf.viz.core.localization.CAVELocalizationAdapter;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 22, 2011 bsteffen Initial creation
|
||||
* Nov 22, 2011 bsteffen Initial creation
|
||||
* May 29, 2015 4532 bsteffen Notify the preference store when sync is running.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -75,8 +77,9 @@ public class SyncLocalizationEditor extends BooleanFieldEditor {
|
|||
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
IPathManager pathManager = PathManagerFactory
|
||||
.getPathManager(new CAVELocalizationAdapter());
|
||||
getPreferenceStore().firePropertyChangeEvent(ThinClientPreferenceConstants.P_SYNC_REMOTE_LOCALIZATION,
|
||||
false, true);
|
||||
IPathManager pathManager = PathManagerFactory.getPathManager();
|
||||
LocalizationType[] types = { LocalizationType.CAVE_CONFIG,
|
||||
LocalizationType.CAVE_STATIC,
|
||||
LocalizationType.COMMON_STATIC };
|
||||
|
@ -105,6 +108,8 @@ public class SyncLocalizationEditor extends BooleanFieldEditor {
|
|||
System.out.println("Time to download " + type + ": "
|
||||
+ (endTime - startTime) + "ms");
|
||||
}
|
||||
getPreferenceStore().firePropertyChangeEvent(ThinClientPreferenceConstants.P_SYNC_REMOTE_LOCALIZATION,
|
||||
true, false);
|
||||
monitor.done();
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Date;
|
|||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
|
@ -53,6 +54,7 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
|
|||
* Aug 9, 2011 njensen Initial creation
|
||||
* Aug 13, 2013 2033 mschenke Changed to search all plugins when
|
||||
* CAVE_STATIC BASE context searched
|
||||
* May 29, 2015 4532 bsteffen Always use super when sync job is running.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -63,6 +65,12 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
|
|||
public class ThinClientLocalizationAdapter extends CAVELocalizationAdapter
|
||||
implements IPropertyChangeListener {
|
||||
|
||||
/**
|
||||
* Whenever there is a sync job running, always call super to allow it to go
|
||||
* to the server.
|
||||
*/
|
||||
private final AtomicInteger syncJobsRunning = new AtomicInteger(0);
|
||||
|
||||
private boolean useRemoteFiles = true;
|
||||
|
||||
public ThinClientLocalizationAdapter() {
|
||||
|
@ -83,6 +91,10 @@ public class ThinClientLocalizationAdapter extends CAVELocalizationAdapter
|
|||
@Override
|
||||
public void retrieve(LocalizationFile file)
|
||||
throws LocalizationOpFailedException {
|
||||
if (syncJobsRunning.get() > 0) {
|
||||
super.retrieve(file);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
File localFile = file.getFile(false);
|
||||
if (localFile.exists() == false || localFile.length() == 0) {
|
||||
|
@ -91,8 +103,15 @@ public class ThinClientLocalizationAdapter extends CAVELocalizationAdapter
|
|||
} catch (LocalizationOpFailedException e) {
|
||||
throw e;
|
||||
} catch (LocalizationException e) {
|
||||
// Ignore exception
|
||||
e.printStackTrace();
|
||||
/*
|
||||
* At the time of this writing, nothing will actually throw any
|
||||
* LocalizationException other than LocalizationOpFailedException.
|
||||
* However since LocalizationFile.getFile(boolean) has a method
|
||||
* signature indicating it could throw any LocalizationException
|
||||
* this code should be able to handle any LocalizationException in
|
||||
* case the implementation of getFile changes in the future.
|
||||
*/
|
||||
throw new LocalizationOpFailedException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +127,7 @@ public class ThinClientLocalizationAdapter extends CAVELocalizationAdapter
|
|||
public ListResponse[] listDirectory(LocalizationContext[] contexts,
|
||||
String path, boolean recursive, boolean filesOnly)
|
||||
throws LocalizationOpFailedException {
|
||||
if (useRemoteFiles) {
|
||||
if (shouldUseRemoteFiles()) {
|
||||
return super.listDirectory(contexts, path, recursive, filesOnly);
|
||||
} else {
|
||||
|
||||
|
@ -164,7 +183,7 @@ public class ThinClientLocalizationAdapter extends CAVELocalizationAdapter
|
|||
public ListResponse[] getLocalizationMetadata(
|
||||
LocalizationContext[] context, String fileName)
|
||||
throws LocalizationOpFailedException {
|
||||
if (useRemoteFiles) {
|
||||
if (shouldUseRemoteFiles()) {
|
||||
return super.getLocalizationMetadata(context, fileName);
|
||||
} else {
|
||||
List<ListResponse> responses = new ArrayList<ListResponse>(
|
||||
|
@ -193,19 +212,30 @@ public class ThinClientLocalizationAdapter extends CAVELocalizationAdapter
|
|||
|
||||
@Override
|
||||
public boolean exists(LocalizationFile file) {
|
||||
if (useRemoteFiles) {
|
||||
if (shouldUseRemoteFiles()) {
|
||||
return super.exists(file);
|
||||
} else {
|
||||
return file.getFile().exists();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldUseRemoteFiles() {
|
||||
return useRemoteFiles || syncJobsRunning.get() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent event) {
|
||||
if (ThinClientPreferenceConstants.P_DISABLE_REMOTE_LOCALIZATION
|
||||
.equals(event.getProperty())) {
|
||||
useRemoteFiles = !Boolean.valueOf(String.valueOf(event
|
||||
.getNewValue()));
|
||||
} else if (ThinClientPreferenceConstants.P_SYNC_REMOTE_LOCALIZATION.equals(event.getProperty())) {
|
||||
boolean sync = Boolean.valueOf(String.valueOf(event.getNewValue()));
|
||||
if (sync) {
|
||||
syncJobsRunning.incrementAndGet();
|
||||
} else {
|
||||
syncJobsRunning.decrementAndGet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.thinclient.preferences;
|
||||
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
|
||||
/**
|
||||
* Preference constants for the thin client mode
|
||||
*
|
||||
|
@ -32,6 +34,8 @@ package com.raytheon.uf.viz.thinclient.preferences;
|
|||
* Jan 14, 2013 1469 bkowal The hdf5 data directory is no longer a preference constant.
|
||||
* Feb 04, 2014 2704 njensen Consolidate services and pypies proxy addresses
|
||||
* Jun 24, 2014 3236 njensen Added proxy address options
|
||||
* May 29, 2015 4532 bsteffen Add sync localization option.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -61,6 +65,19 @@ public class ThinClientPreferenceConstants {
|
|||
|
||||
public static String P_DISABLE_REMOTE_LOCALIZATION = "disableRemoteLocalization";
|
||||
|
||||
/**
|
||||
* This preference is not stored but is used to send notification through
|
||||
* the preference store that the {@link #P_CACHE_LOCALIZATION} and
|
||||
* {@link #P_DISABLE_REMOTE_LOCALIZATION} should be temporarily ignored so
|
||||
* that the localization files can be synchronized with the server. Before
|
||||
* performing synchronization, an event should be fired using
|
||||
* {@link IPreferenceStore#firePropertyChangeEvent(String, Object, Object)}
|
||||
* with the preference name as {@link #P_SYNC_REMOTE_LOCALIZATION} and a
|
||||
* newValue of true. When synchronization has completed another event should
|
||||
* be fired with a newValue of false.
|
||||
*/
|
||||
public static String P_SYNC_REMOTE_LOCALIZATION = "syncRemoteFiles";
|
||||
|
||||
public static String P_DISABLE_MENU_TIMES = "disableMenuTimes";
|
||||
|
||||
public static String P_DISABLE_JMS = "disableJms";
|
||||
|
|
|
@ -17,6 +17,13 @@ then
|
|||
echo "CAVE and/or gfeclient not installed on this workstation ..exiting"
|
||||
exit 1
|
||||
else
|
||||
$_GFECLI $_MODULE "$@"
|
||||
CONFDIR=${HOME}/.runProc-$(hostname)-$$
|
||||
cleanup() {
|
||||
rm -rf "$CONFDIR"
|
||||
}
|
||||
mkdir -p "$CONFDIR" || exit 1
|
||||
trap cleanup EXIT
|
||||
|
||||
$_GFECLI -configuration $CONFDIR $_MODULE "$@"
|
||||
fi
|
||||
|
||||
|
|
|
@ -166,6 +166,7 @@ import com.vividsolutions.jts.geom.Polygon;
|
|||
* not be as expected if percentage/area is different between the two products. But the
|
||||
* chance for that to occur is trivial.
|
||||
* May 7, 2015 ASM #17438 D. Friedman Clean up debug and performance logging.
|
||||
* Jun 05, 2015 DR 17428 D. Friedman Fixed duration-related user interface issues. Added duration logging.
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
|
@ -1095,15 +1096,25 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
* @param durations
|
||||
*/
|
||||
public void setDurations(int[] durations) {
|
||||
String[] durList = new String[durations.length];
|
||||
ArrayList<String> durList = new ArrayList<String>(durations.length);
|
||||
boolean isDefaultDurationInList = false;
|
||||
durationList.removeAll();
|
||||
for (int i = 0; i < durations.length; i++) {
|
||||
if (defaultDuration != null
|
||||
&& defaultDuration.minutes == durations[i]) {
|
||||
isDefaultDurationInList = true;
|
||||
}
|
||||
DurationData data = new DurationData(durations[i]);
|
||||
durationList.setData(data.displayString, data);
|
||||
durList[i] = data.displayString;
|
||||
durList.add(data.displayString);
|
||||
}
|
||||
// Add the default duration to the list if what was missing
|
||||
if (! isDefaultDurationInList && defaultDuration != null) {
|
||||
durationList.setData(defaultDuration.displayString, defaultDuration);
|
||||
durList.add(0, defaultDuration.displayString);
|
||||
}
|
||||
|
||||
durationList.setItems(durList);
|
||||
durationList.setItems(durList.toArray(new String[durList.size()]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1179,6 +1190,8 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
long t0 = System.currentTimeMillis();
|
||||
try {
|
||||
monitor.beginTask("Generating product", 1);
|
||||
statusHandler.debug("using startTime " + startTime.getTime()
|
||||
+ " endTime " + endTime.getTime());
|
||||
String result = TemplateRunner.runTemplate(
|
||||
warngenLayer, startTime.getTime(),
|
||||
endTime.getTime(), selectedBullets,
|
||||
|
@ -1328,9 +1341,10 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
* Action for Reset button
|
||||
*/
|
||||
private void resetPressed() {
|
||||
statusHandler.debug("resetPressed");
|
||||
int durationToUse = getSelectedDuration();
|
||||
warngenLayer.resetState();
|
||||
warngenLayer.getStormTrackState().duration = ((DurationData) durationList
|
||||
.getData(durationList.getItem(durationList.getSelectionIndex()))).minutes;
|
||||
restoreDuration(durationToUse);
|
||||
durationList.setEnabled(warngenLayer.getConfiguration()
|
||||
.isEnableDuration());
|
||||
if (lineOfStorms.getSelection()) {
|
||||
|
@ -1366,6 +1380,7 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
warngenLayer.resetInitialFrame();
|
||||
warngenLayer.setWarningAction(null);
|
||||
instructionsLabel.setText("Instructions:");
|
||||
changeStartEndTimes();
|
||||
warngenLayer.issueRefresh();
|
||||
}
|
||||
|
||||
|
@ -1430,8 +1445,11 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
* Select one storm
|
||||
*/
|
||||
private void selectOneStorm() {
|
||||
statusHandler.debug("selectOneStorm");
|
||||
if (warngenLayer.state.followupData == null) {
|
||||
int savedDuration = warngenLayer.getStormTrackState().duration;
|
||||
warngenLayer.resetState();
|
||||
restoreDuration(savedDuration);
|
||||
warngenLayer.reset("oneStorm");
|
||||
warngenLayer.clearWarningGeometries();
|
||||
warngenLayer.getStormTrackState().dragMeLine = null;
|
||||
|
@ -1447,8 +1465,11 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
* Select line of storms
|
||||
*/
|
||||
private void selectLineOfStorms() {
|
||||
statusHandler.debug("selectLineOfStorms");
|
||||
if (warngenLayer.state.followupData == null) {
|
||||
int savedDuration = warngenLayer.getStormTrackState().duration;
|
||||
warngenLayer.resetState();
|
||||
restoreDuration(savedDuration);
|
||||
warngenLayer.reset("lineOfStorms");
|
||||
warngenLayer.clearWarningGeometries();
|
||||
warngenLayer.getStormTrackState().dragMeLine = null;
|
||||
|
@ -1596,6 +1617,7 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
* - The button that has been clicked
|
||||
*/
|
||||
private void changeTemplate(String templateName) {
|
||||
statusHandler.debug("changeTemplate: " + templateName);
|
||||
|
||||
String lastAreaSource = warngenLayer.getConfiguration()
|
||||
.getHatchedAreaSource().getAreaSource();
|
||||
|
@ -1689,11 +1711,11 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
}
|
||||
|
||||
protected void recreateDurations(Combo durList) {
|
||||
setDurations(warngenLayer.getConfiguration().getDurations());
|
||||
if (warngenLayer.getConfiguration().getDefaultDuration() != 0) {
|
||||
setDefaultDuration(warngenLayer.getConfiguration()
|
||||
.getDefaultDuration());
|
||||
}
|
||||
setDurations(warngenLayer.getConfiguration().getDurations());
|
||||
durList.setText(defaultDuration.displayString);
|
||||
endTime = DurationUtil.calcEndTime(startTime, defaultDuration.minutes);
|
||||
end.setText(df.format(endTime.getTime()));
|
||||
|
@ -1754,6 +1776,7 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
FollowupData data = (FollowupData) updateListCbo
|
||||
.getData(updateListCbo.getItem(updateListCbo
|
||||
.getSelectionIndex()));
|
||||
statusHandler.debug("updateListSelected: " + (data != null ? data.getDisplayString() : "(null)"));
|
||||
Mode currMode = warngenLayer.getStormTrackState().mode;
|
||||
if (data != null) {
|
||||
// does not refesh if user selected already highlighted option
|
||||
|
@ -1863,6 +1886,8 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
|| (action == WarningAction.EXT)) {
|
||||
recreateDurations(durationList);
|
||||
}
|
||||
} else {
|
||||
statusHandler.debug("updateListSelected");
|
||||
}
|
||||
updateListCbo.pack(true);
|
||||
productType.layout();
|
||||
|
@ -1895,6 +1920,7 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
}
|
||||
|
||||
private void changeSelected() {
|
||||
statusHandler.debug("changeSelected");
|
||||
if ((validPeriodDlg == null) || validPeriodDlg.isDisposed()) {
|
||||
validPeriodDlg = new ValidPeriodDialog(shell, startTime, endTime);
|
||||
validPeriodDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
@ -1902,6 +1928,7 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
int duration = (Integer) returnValue;
|
||||
statusHandler.debug("changeSelected.dialogClosed: " + duration);
|
||||
if (duration != -1) {
|
||||
durationList.setEnabled(false);
|
||||
endTime.add(Calendar.MINUTE, duration);
|
||||
|
@ -1926,6 +1953,7 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
private void durationSelected() {
|
||||
String selection = durationList.getItem(durationList
|
||||
.getSelectionIndex());
|
||||
statusHandler.debug("durationSelected: " + selection);
|
||||
endTime = DurationUtil.calcEndTime(extEndTime != null ? extEndTime
|
||||
: startTime,
|
||||
((DurationData) durationList.getData(selection)).minutes);
|
||||
|
@ -2292,8 +2320,7 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
updatePolygon(newWarn);
|
||||
|
||||
recreateDurations(durationList);
|
||||
int duration = ((DurationData) durationList.getData(durationList
|
||||
.getItem(durationList.getSelectionIndex()))).minutes;
|
||||
int duration = getSelectedDuration();
|
||||
warngenLayer.getStormTrackState().duration = duration;
|
||||
|
||||
startTime = TimeUtil.newCalendar();
|
||||
|
@ -2615,4 +2642,39 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
return defaultTemplate;
|
||||
}
|
||||
|
||||
private void restoreDuration(int duration) {
|
||||
warngenLayer.getStormTrackState().duration =
|
||||
warngenLayer.getStormTrackState().newDuration = duration;
|
||||
warngenLayer.getStormTrackState().geomChanged = true;
|
||||
}
|
||||
|
||||
private int getSelectedDuration() {
|
||||
Exception excToReport= null;
|
||||
DurationData data = null;
|
||||
try {
|
||||
data = (DurationData) durationList.getData(durationList
|
||||
.getItem(durationList.getSelectionIndex()));
|
||||
} catch (RuntimeException e) {
|
||||
excToReport = e;
|
||||
}
|
||||
int duration;
|
||||
if (data != null) {
|
||||
duration = data.minutes;
|
||||
} else {
|
||||
try {
|
||||
duration = warngenLayer.getConfiguration().getDefaultDuration();
|
||||
} catch (RuntimeException e) {
|
||||
if (excToReport == null) {
|
||||
excToReport = e;
|
||||
}
|
||||
duration = 30;
|
||||
}
|
||||
statusHandler.handle(Priority.WARN,
|
||||
"Unable to determine duration from selection in WarnGen dialog. Using default of "
|
||||
+ duration + " minutes.", excToReport);
|
||||
}
|
||||
statusHandler.debug("selected duration is " + duration);
|
||||
return duration;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1516,12 +1516,11 @@ class SectionCommon():
|
|||
pass
|
||||
|
||||
# If this is the "default" case
|
||||
if self._tr == "default" and len(statements) > 0:
|
||||
|
||||
if elementName in ["Wind", "Storm Surge"]:
|
||||
if statements[0].find("If realized, ") == -1:
|
||||
statements[0] = "If realized, " + statements[0] + \
|
||||
statements[0][1:]
|
||||
#if self._tr == "default" and len(statements) > 0:
|
||||
#
|
||||
# if elementName in ["Wind", "Storm Surge"]:
|
||||
# if statements[0].find("If realized, ") == -1:
|
||||
# statements[0] = "If realized, " + statements[0][0].lower() + statements[0][1:]
|
||||
|
||||
return statements
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue