warngen dialog cleanup

This commit is contained in:
Michael James 2017-06-26 09:04:58 -06:00 committed by mjames-upc
parent 01578bf341
commit 9a8ac09ac5
3 changed files with 37 additions and 279 deletions

View file

@ -103,6 +103,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Jan 26, 2016 5054 randerso Changed to use display as parent
* Feb 15, 2016 4860 njensen Removed references to IAviationObserver
* Mar 30, 2016 5513 randerso Fixed to display on same monitor as parent
* Jun 25, 2017 ---- mjames@ucar Simple dialog.
*
* </pre>
*
@ -213,9 +214,6 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
.getTimeZone(localTZName) : TimeZone.getDefault());
createMenus();
new Label(shell, SWT.NONE).setText("host: "
+ TextWorkstationConstants.getHostName());
createAwipsLabel();
createTimeLabels();
startTimeTimer();
createAlertAlarm();
@ -361,27 +359,14 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
});
}
private void createAwipsLabel() {
GridData gd = new GridData(300, 20);
Label awipsBlankLabel = new Label(shell, SWT.NONE);
awipsBlankLabel.setFont(fontAwipsLabel);
awipsBlankLabel.setText(" ");
awipsBlankLabel.setLayoutData(gd);
gd = new GridData(300, 80);
Label awipsLabel = new Label(shell, SWT.NONE);
awipsLabel.setFont(fontAwipsLabel);
awipsLabel.setText(" AWIPS II");
awipsLabel.setLayoutData(gd);
}
private void createTimeLabels() {
GridData gd = null;
gd = new GridData(300, SWT.DEFAULT);
gd = new GridData(200, SWT.DEFAULT);
utcTimeLabel = new Label(shell, SWT.CENTER);
utcTimeLabel.setLayoutData(gd);
gd = new GridData(300, SWT.DEFAULT);
gd = new GridData(200, SWT.DEFAULT);
localTimeLabel = new Label(shell, SWT.CENTER);
localTimeLabel.setLayoutData(gd);

View file

@ -188,6 +188,7 @@ import com.vividsolutions.jts.geom.Polygon;
* Feb 04, 2016 DR 14307 Daniel Huffman Added sorting to drop down items in recreateUpdates().
* Feb 16, 2016 DR 17531 Qinglu Lin Added overloaded setTrackLocked(boolean, boolean), updated expSelected().
* Jul 07, 2016 DR 5665 Jon Schmid Corrected WarngenLayer duration save and restore when selecting new TrackType.
* Jun 25, 2017 mjames@ucar Simple dialog.
* </pre>
*
* @author chammack
@ -235,13 +236,11 @@ public class WarngenDialog extends CaveSWTDialog implements
private static String UPDATELISTTEXT = "UPDATE LIST ";
public static String NO_BACKUP_SELECTED = "none";
/** "OK" button text */
private static final String OK_BTN_LABEL = "Create Text";
/** "Restart" button text */
private static final String RS_BTN_LABEL = "Restart";
private static final String RS_BTN_LABEL = "Reset";
/** "Cancel" button text */
private static final String CLOSE_BUTTON_LABEL = "Close";
@ -334,8 +333,6 @@ public class WarngenDialog extends CaveSWTDialog implements
private Text end;
private Combo backupSiteCbo;
private Text instructionsBox;
private Group productType;
@ -349,8 +346,8 @@ public class WarngenDialog extends CaveSWTDialog implements
public WarngenDialog(Shell parentShell, WarngenLayer layer) {
super(parentShell,
SWT.MIN | SWT.CLOSE | SWT.MODELESS | SWT.BORDER | SWT.TITLE,
CAVE.DO_NOT_BLOCK | CAVE.INDEPENDENT_SHELL);
SWT.MIN | SWT.CLOSE | SWT.MODELESS | SWT.BORDER | SWT.TITLE | SWT.ON_TOP,
CAVE.DO_NOT_BLOCK | CAVE.INDEPENDENT_SHELL );
setText("WarnGen");
bulletListManager = new BulletListManager();
warngenLayer = layer;
@ -370,10 +367,6 @@ public class WarngenDialog extends CaveSWTDialog implements
timer.cancel();
updateTimeTask.cancel();
CurrentWarnings.removeListener(this);
IDisplayPaneContainer container = warngenLayer.getResourceContainer();
if (container != null && ! (container instanceof SideView)) {
WarngenLayer.setLastSelectedBackupSite(warngenLayer.getBackupSite());
}
warngenLayer = null;
}
@ -421,7 +414,18 @@ public class WarngenDialog extends CaveSWTDialog implements
createTimeRangeGroup(mainComposite);
createBulletListAndLabel(mainComposite);
createBottomButtons(mainComposite);
setBackupSite();
createMainProductButtons(productType);
createOtherProductsList(productType);
productType.layout(true, true);
// Don't let errors prevent the new controls from being displayed!
try {
changeTemplate(getDefaultTemplate());
resetPressed();
} catch (Exception e) {
statusHandler
.error("Error occurred while switching to the default template.",
e);
}
setInstructions();
if (advanced) {
@ -766,63 +770,32 @@ public class WarngenDialog extends CaveSWTDialog implements
backupTrackEditComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
true, true, 1, 1));
createBackupGroup(backupTrackEditComp);
createReset(backupTrackEditComp);
createTrackGroup(backupTrackEditComp);
createEditGroup(backupTrackEditComp);
// Populate the control
populateBackupGroup();
}
/**
* Create the backup site
* Create the reset button
*
* @param backupTrackEditComp
*/
private void createBackupGroup(Composite backupTrackEditComp) {
Group backupGroup = new Group(backupTrackEditComp, SWT.NONE);
backupGroup.setLayoutData(new GridData(SWT.DEFAULT, SWT.FILL, false,
true));
backupGroup.setText("Backup");
backupGroup.setLayout(new GridLayout(2, false));
Label label2 = new Label(backupGroup, SWT.BOLD);
label2.setText("WFO:");
label2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
backupSiteCbo = new Combo(backupGroup, SWT.READ_ONLY | SWT.DROP_DOWN);
backupSiteCbo.addSelectionListener(new SelectionAdapter() {
private void createReset(Composite backupTrackEditComp) {
restartBtn = new Button(backupTrackEditComp, SWT.PUSH);
restartBtn.setText(RS_BTN_LABEL);
GridData gd = new GridData(SWT.CENTER, SWT.CENTER, true, true);
gd.widthHint = 100;
restartBtn.setLayoutData(gd);
restartBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
backupSiteSelected();
public void widgetSelected(SelectionEvent event) {
resetPressed();
}
});
}
/**
* Populate the backup site combo with data from preference store
*/
private void populateBackupGroup() {
backupSiteCbo.removeAll();
backupSiteCbo.add(NO_BACKUP_SELECTED);
String[] CWAs = warngenLayer.getDialogConfig().getBackupCWAs()
.split(",");
int index = 0, selectedIndex = 0;
for (String cwa : CWAs) {
if (cwa.length() > 0) {
index += 1;
BackupData data = new BackupData(cwa);
backupSiteCbo.setData(data.site, data);
backupSiteCbo.add(data.site);
if (data.site.equals(warngenLayer.getBackupSite())) {
selectedIndex = index;
warngenLayer.setBackupSite(data.site);
}
}
}
backupSiteCbo.select(selectedIndex);
setBackupCboColors();
}
private void createTrackGroup(Composite backupTrackEditComp) {
Group trackGroup = new Group(backupTrackEditComp, SWT.NONE);
@ -916,7 +889,7 @@ public class WarngenDialog extends CaveSWTDialog implements
*/
private void createBottomButtons(Composite parent) {
Composite buttonComp = new Composite(parent, SWT.NONE);
GridLayout gl = new GridLayout(3, true);
GridLayout gl = new GridLayout(2, true);
gl.marginHeight = 1;
buttonComp.setLayout(gl);
buttonComp.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true,
@ -936,22 +909,8 @@ public class WarngenDialog extends CaveSWTDialog implements
"Create WarnGen product");
return;
}
okPressed();
}
});
restartBtn = new Button(buttonComp, SWT.PUSH);
restartBtn.setText(RS_BTN_LABEL);
gd = new GridData(SWT.CENTER, SWT.CENTER, true, true);
gd.widthHint = 100;
restartBtn.setLayoutData(gd);
restartBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
resetPressed();
}
});
Button btn = new Button(buttonComp, SWT.PUSH);
@ -1221,9 +1180,6 @@ public class WarngenDialog extends CaveSWTDialog implements
final FollowupData followupData = (FollowupData) updateListCbo
.getData(updateListCbo.getItem(updateListCbo
.getSelectionIndex()));
final BackupData backupData = (BackupData) backupSiteCbo
.getData(backupSiteCbo.getItem(backupSiteCbo
.getSelectionIndex()));
if (checkFollowupSelection(followupData) == false) {
return;
@ -1272,7 +1228,7 @@ public class WarngenDialog extends CaveSWTDialog implements
String result = TemplateRunner.runTemplate(
warngenLayer, startTime.getTime(),
endTime.getTime(), selectedBullets,
followupData, backupData);
followupData, null);
resultContainer[0] = result;
Matcher m = FollowUpUtil.vtecPtrn.matcher(result);
totalSegments = 0;
@ -1468,69 +1424,6 @@ public class WarngenDialog extends CaveSWTDialog implements
hide();
}
private boolean setBackupSite() {
if ((backupSiteCbo.getSelectionIndex() >= 0)
&& (backupSiteCbo.getItemCount() > 0)) {
int index = backupSiteCbo.getSelectionIndex();
String backupSite = backupSiteCbo.getItem(index);
warngenLayer.setBackupSite(backupSite);
IDisplayPaneContainer container = warngenLayer.getResourceContainer();
if (container != null && ! (container instanceof SideView)) {
WarngenLayer.setLastSelectedBackupSite(backupSite);
}
if (backupSite.equalsIgnoreCase("none")) {
new TemplateRunnerInitJob().schedule();
} else {
new TemplateRunnerInitJob(backupSite).schedule();
}
/*
* When the product selection buttons are recreated below, the
* button for the default template will be selected and mainProducts
* will have been recreated. Then getDefaultTemplate() can be used
* here to change the state.
*/
createMainProductButtons(productType);
createOtherProductsList(productType);
// Don't let errors prevent the new controls from being displayed!
try {
changeTemplate(getDefaultTemplate());
resetPressed();
} catch (Exception e) {
statusHandler
.error("Error occurred while switching to the default template.",
e);
}
return true;
} else {
return false;
}
}
/**
* Action for when something is selected from the backup site combo
*/
private void backupSiteSelected() {
if (setBackupSite()) {
productType.layout(true, true);
getShell().pack(true);
}
setBackupCboColors();
}
private void setBackupCboColors() {
if (backupSiteCbo.getSelectionIndex() == 0) {
backupSiteCbo.setBackground(null);
backupSiteCbo.setForeground(null);
} else {
backupSiteCbo.setBackground(shell.getDisplay().getSystemColor(
SWT.COLOR_YELLOW));
backupSiteCbo.setForeground(shell.getDisplay().getSystemColor(
SWT.COLOR_BLACK));
}
}
/**
* Select one storm
*/

View file

@ -270,6 +270,7 @@ import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier;
* 03/11/2016 ASM #18720 D. Friedman Improve warning message when extension area is not available.
* 03/22/2016 DCS 18719 D. Friedman Add dynamic extension area option.
* 07/21/2016 DR 18159 Qinglu Lin Added third filterArea().
* 06/25/2017 mjames@ucar Simple dialog.
* </pre>
*
* @author mschenke
@ -288,14 +289,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
private static final String EXTENSION_AREA_MAP_NAME = "WarnGen Extension Area";
static String lastSelectedBackupSite;
String uniqueFip = null;
String backupOfficeShort = null;
String backupOfficeLoc = null;
Map<String, Double> geomArea = new HashMap<String, Double>();
Map<String, Point> geomCentroid = new HashMap<String, Point>();
@ -1375,8 +1370,6 @@ public class WarngenLayer extends AbstractStormTrackResource {
private String templateName;
private String backupSite;
private boolean boxEditable = true;
private final CustomMaps customMaps;
@ -1437,8 +1430,6 @@ public class WarngenLayer extends AbstractStormTrackResource {
"Error loading config.xml", e);
}
setBackupSite(WarngenLayer.getLastSelectedBackupSite());
// Load default template
String defaultTemplate = dialogConfig.getDefaultTemplate();
if (defaultTemplate.equals("")) {
@ -1930,7 +1921,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
public void realizeExtensionAreaVisibility() {
VizApp.runAsync(new Runnable() {
VizApp.runSync(new Runnable() {
@Override
public void run() {
boolean actuallyVisible = isExtensionAreaActuallyVisible();
@ -1953,7 +1944,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
try {
config = WarngenConfiguration.loadConfig(templateName,
LocalizationManager.getInstance().getCurrentSite(),
backupSite);
null);
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred loading template " + templateName, e);
@ -2278,99 +2269,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
return state.getWarningPolygon();
}
public void setBackupSite(String site) {
if (site == null || site.equalsIgnoreCase("none")) {
backupSite = null;
} else {
backupSite = site;
}
DialogConfiguration dc = null;
if (backupSite != null) {
boolean haveBackupConfig = DialogConfiguration
.isSiteDialogConfigExtant(backupSite);
if (haveBackupConfig) {
try {
dc = DialogConfiguration.loadDialogConfigNoUser(backupSite);
} catch (Exception e) {
statusHandler
.error(String
.format("Unable to load WarnGen configuration for site %s. Falling back to local configuration.",
getLocalizedSite()), e);
}
} else {
statusHandler
.warn(String
.format("WarnGen configuration for site %s does not exist. Falling back to local configuration.",
backupSite));
}
if (dc == null) {
try {
dc = DialogConfiguration
.loadDialogConfigNoUser(LocalizationManager
.getInstance().getCurrentSite());
} catch (Exception e) {
dc = new DialogConfiguration();
statusHandler
.error(String
.format("Unable to load WarnGen configuration for site %s.",
getLocalizedSite()), e);
}
}
} else {
try {
dc = DialogConfiguration.loadDialogConfig(LocalizationManager
.getInstance().getCurrentSite());
} catch (Exception e) {
dc = new DialogConfiguration();
statusHandler.error(
"Unable to load local WarnGen configuration.", e);
}
}
if ((dc != null) && (dialogConfig != null)) {
dialogConfig.setDefaultTemplate(dc.getDefaultTemplate());
dialogConfig.setMainWarngenProducts(dc.getMainWarngenProducts());
dialogConfig.setOtherWarngenProducts(dc.getOtherWarngenProducts());
backupOfficeShort = dc.getWarngenOfficeShort();
backupOfficeLoc = dc.getWarngenOfficeLoc();
if (backupSite != null) {
boolean shortTag = false;
boolean locTag = false;
String infoType = null;
if ((backupOfficeShort == null)
|| (backupOfficeShort.trim().isEmpty())) {
shortTag = true;
}
if ((backupOfficeLoc == null)
|| (backupOfficeLoc.trim().isEmpty())) {
locTag = true;
}
if (shortTag && locTag) {
infoType = "warngenOfficeShort and warngenOfficeLoc";
} else {
if (shortTag) {
infoType = "warngenOfficeShort";
} else if (locTag) {
infoType = "warngenOfficeLoc";
}
}
if (infoType != null) {
statusHandler.handle(Priority.CRITICAL, "Info for "
+ infoType + " in " + backupSite
+ "'s config.xml is missing.");
}
}
}
}
public String getLocalizedSite() {
String site = "";
if (backupSite == null) {
site = LocalizationManager.getInstance().getCurrentSite();
} else {
site = backupSite;
}
return site;
return LocalizationManager.getInstance().getCurrentSite();
}
/**
@ -4591,26 +4491,6 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
}
public String getBackupOfficeShort() {
return backupOfficeShort;
}
public String getBackupOfficeLoc() {
return backupOfficeLoc;
}
public String getBackupSite() {
return backupSite;
}
public static String getLastSelectedBackupSite() {
return lastSelectedBackupSite;
}
public static void setLastSelectedBackupSite(String backupSite) {
lastSelectedBackupSite = backupSite;
}
private GeospatialData[] getActiveFeatures() {
return geoData.getFeatures(isCwaStretch());
}