Merge branch 'Dialog_Refactor' into development
Former-commit-id:0bd99c3637
[formerly0bd99c3637
[formerly bedeaaf67ed189fa84f3f5a8399aeae5c200d1cc]] Former-commit-id:702576bbac
Former-commit-id:7f9e89cc79
This commit is contained in:
commit
ede743f659
11 changed files with 662 additions and 448 deletions
|
@ -57,6 +57,7 @@ import com.raytheon.viz.texteditor.alarmalert.util.AAPACombined;
|
|||
import com.raytheon.viz.texteditor.alarmalert.util.AlarmAlertFunctions;
|
||||
import com.raytheon.viz.texteditor.alarmalert.util.AlarmAlertLists;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
import com.raytheon.viz.ui.dialogs.ModeListener;
|
||||
|
||||
/**
|
||||
|
@ -69,6 +70,7 @@ import com.raytheon.viz.ui.dialogs.ModeListener;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 9, 2009 mnash Initial creation
|
||||
* Oct 31,2011 8510 rferrel Cleaned up code made more robust
|
||||
* Sep 20,2011 1196 rferrel Change dialogs so they do not block.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -133,7 +135,8 @@ public class AlarmAlertDlg extends CaveSWTDialog {
|
|||
* @param parentShell
|
||||
*/
|
||||
protected AlarmAlertDlg(Shell parentShell) {
|
||||
super(parentShell, SWT.RESIZE, CAVE.PERSPECTIVE_INDEPENDENT);
|
||||
super(parentShell, SWT.RESIZE, CAVE.PERSPECTIVE_INDEPENDENT
|
||||
| CAVE.DO_NOT_BLOCK);
|
||||
setText("(init) Alarm/Alert and Proximity Alarm Products");
|
||||
}
|
||||
|
||||
|
@ -178,8 +181,6 @@ public class AlarmAlertDlg extends CaveSWTDialog {
|
|||
|
||||
preOpened();
|
||||
|
||||
// shell.open();
|
||||
|
||||
opened();
|
||||
}
|
||||
|
||||
|
@ -270,29 +271,14 @@ public class AlarmAlertDlg extends CaveSWTDialog {
|
|||
// open dialog
|
||||
AlarmAlertSaveLoadDlg dialog = new AlarmAlertSaveLoadDlg(shell,
|
||||
SaveOrLoad.SAVE);
|
||||
dialog.open();
|
||||
String fname = dialog.getFileName();
|
||||
fname = validateFileName(fname);
|
||||
// AlarmAlertFunctions.validateName(fname);
|
||||
dialog.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
if (fname != null && !fname.isEmpty()) {
|
||||
setShellText(fname);
|
||||
setLastFile(fname);
|
||||
// save alert products
|
||||
LocalizationFile lFile = AlarmAlertFunctions.getFile(
|
||||
AlarmAlertFunctions.initUserLocalization(), fname);
|
||||
if (lFile != null) {
|
||||
AlarmAlertFunctions.saveAlarms(
|
||||
aapList.subList(siteAdminNumberAA - 1,
|
||||
aapList.size()),
|
||||
papList.subList(siteAdminNumberPA - 1,
|
||||
papList.size()), lFile);
|
||||
} else {
|
||||
statusHandler.handle(Priority.SIGNIFICANT,
|
||||
"Null localization file", new VizException(
|
||||
"Null localization file"));
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
doSaveAs(returnValue.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
dialog.open();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -303,43 +289,72 @@ public class AlarmAlertDlg extends CaveSWTDialog {
|
|||
// open dialog
|
||||
AlarmAlertSaveLoadDlg dialog = new AlarmAlertSaveLoadDlg(shell,
|
||||
SaveOrLoad.LOAD);
|
||||
dialog.open();
|
||||
// load file
|
||||
String fname = dialog.getFileName();
|
||||
fname = validateFileName(fname);
|
||||
// AlarmAlertFunctions.validateName(fname);
|
||||
if (fname != null && !fname.isEmpty()) {
|
||||
dialog.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
// load alert products
|
||||
LocalizationFile lFile = AlarmAlertFunctions.getFile(
|
||||
AlarmAlertFunctions.initUserLocalization(), fname);
|
||||
if (lFile != null) {
|
||||
File file = lFile.getFile();
|
||||
setShellText(fname);
|
||||
setLastFile(fname);
|
||||
currentFile = file;
|
||||
AAPACombined combined = null;
|
||||
|
||||
try {
|
||||
combined = AlarmAlertFunctions.loadFile(file);
|
||||
} catch (FileNotFoundException e) {
|
||||
combined = AlarmAlertFunctions
|
||||
.createDefaultAAPACombined();
|
||||
}
|
||||
if (combined != null) {
|
||||
populateLists(combined.getAaList(),
|
||||
combined.getPaList());
|
||||
}
|
||||
} else {
|
||||
statusHandler.handle(Priority.SIGNIFICANT,
|
||||
"Null localization file", new VizException(
|
||||
"Null localization file"));
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
doLoad(returnValue.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
dialog.open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doSaveAs(String fname) {
|
||||
fname = validateFileName(fname);
|
||||
// AlarmAlertFunctions.validateName(fname);
|
||||
|
||||
if (fname != null && !fname.isEmpty()) {
|
||||
setShellText(fname);
|
||||
setLastFile(fname);
|
||||
// save alert products
|
||||
LocalizationFile lFile = AlarmAlertFunctions.getFile(
|
||||
AlarmAlertFunctions.initUserLocalization(), fname);
|
||||
if (lFile != null) {
|
||||
AlarmAlertFunctions.saveAlarms(
|
||||
aapList.subList(siteAdminNumberAA - 1, aapList.size()),
|
||||
papList.subList(siteAdminNumberPA - 1, papList.size()),
|
||||
lFile);
|
||||
} else {
|
||||
statusHandler.handle(Priority.SIGNIFICANT,
|
||||
"Null localization file", new VizException(
|
||||
"Null localization file"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doLoad(String fname) {
|
||||
fname = validateFileName(fname);
|
||||
// AlarmAlertFunctions.validateName(fname);
|
||||
if (fname != null && !fname.isEmpty()) {
|
||||
|
||||
// load alert products
|
||||
LocalizationFile lFile = AlarmAlertFunctions.getFile(
|
||||
AlarmAlertFunctions.initUserLocalization(), fname);
|
||||
if (lFile != null) {
|
||||
File file = lFile.getFile();
|
||||
setShellText(fname);
|
||||
setLastFile(fname);
|
||||
currentFile = file;
|
||||
AAPACombined combined = null;
|
||||
|
||||
try {
|
||||
combined = AlarmAlertFunctions.loadFile(file);
|
||||
} catch (FileNotFoundException e) {
|
||||
combined = AlarmAlertFunctions.createDefaultAAPACombined();
|
||||
}
|
||||
if (combined != null) {
|
||||
populateLists(combined.getAaList(), combined.getPaList());
|
||||
}
|
||||
} else {
|
||||
statusHandler.handle(Priority.SIGNIFICANT,
|
||||
"Null localization file", new VizException(
|
||||
"Null localization file"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the buttons right below the menu
|
||||
*/
|
||||
|
@ -359,21 +374,27 @@ public class AlarmAlertDlg extends CaveSWTDialog {
|
|||
}
|
||||
proximityAlarmDlg = new NewAlarmDlg(shell, "ALARM",
|
||||
new AlarmAlertProduct(isOperationalMode()));
|
||||
AlarmAlertProduct prod = (AlarmAlertProduct) proximityAlarmDlg
|
||||
.open();
|
||||
if (proximityAlarmDlg.haveOkEvent()) {
|
||||
aapList.add(prod);
|
||||
String string = "";
|
||||
if (prod.isAlarm()) {
|
||||
string += " (Alarm)";
|
||||
proximityAlarmDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
AlarmAlertProduct prod = (AlarmAlertProduct) returnValue;
|
||||
if (proximityAlarmDlg.haveOkEvent()) {
|
||||
aapList.add(prod);
|
||||
String string = "";
|
||||
if (prod.isAlarm()) {
|
||||
string += " (Alarm)";
|
||||
}
|
||||
if (!"".equals(prod.getSearchString())) {
|
||||
string += " containing \""
|
||||
+ prod.getSearchString() + "\"";
|
||||
}
|
||||
aaList.add(prod.getProductId() + string);
|
||||
changeSaveState(true);
|
||||
}
|
||||
}
|
||||
if (!"".equals(prod.getSearchString())) {
|
||||
string += " containing \"" + prod.getSearchString()
|
||||
+ "\"";
|
||||
}
|
||||
aaList.add(prod.getProductId() + string);
|
||||
changeSaveState(true);
|
||||
}
|
||||
});
|
||||
proximityAlarmDlg.open();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -389,16 +410,24 @@ public class AlarmAlertDlg extends CaveSWTDialog {
|
|||
|
||||
proximityAlarmDlg = new NewAlarmDlg(shell, "PROXIMITY",
|
||||
new AlarmAlertProduct(isOperationalMode()));
|
||||
AlarmAlertProduct prod = (AlarmAlertProduct) proximityAlarmDlg
|
||||
.open();
|
||||
if (proximityAlarmDlg.haveOkEvent()) {
|
||||
prod.setOperationalMode(isOperationalMode());
|
||||
papList.add(prod);
|
||||
paList.add(prod.getProductId() + " " + prod.getAlarmType()
|
||||
+ " " + prod.getActionCmd() + " "
|
||||
+ AlarmAlertFunctions.buildDistance(prod));
|
||||
changeSaveState(true);
|
||||
}
|
||||
proximityAlarmDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
AlarmAlertProduct prod = (AlarmAlertProduct) returnValue;
|
||||
if (proximityAlarmDlg.haveOkEvent()) {
|
||||
prod.setOperationalMode(isOperationalMode());
|
||||
papList.add(prod);
|
||||
paList.add(prod.getProductId() + " "
|
||||
+ prod.getAlarmType() + " "
|
||||
+ prod.getActionCmd() + " "
|
||||
+ AlarmAlertFunctions.buildDistance(prod));
|
||||
changeSaveState(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
proximityAlarmDlg.open();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -415,48 +444,64 @@ public class AlarmAlertDlg extends CaveSWTDialog {
|
|||
}
|
||||
if (aaList.getSelectionIndex() != -1) {
|
||||
// User might change selection while dialog is displayed.
|
||||
int index = aaList.getSelectionIndex();
|
||||
final int index = aaList.getSelectionIndex();
|
||||
proximityAlarmDlg = new NewAlarmDlg(shell, "ALARM", aapList
|
||||
.get(index - 1));
|
||||
AlarmAlertProduct prod = aapList.set(index - 1,
|
||||
(AlarmAlertProduct) proximityAlarmDlg.open());
|
||||
if (proximityAlarmDlg.haveOkEvent()) {
|
||||
String string = "";
|
||||
if (prod.isAlarm()) {
|
||||
string += " (Alarm)";
|
||||
proximityAlarmDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
AlarmAlertProduct prod = (AlarmAlertProduct) returnValue;
|
||||
prod = aapList.set(index - 1, prod);
|
||||
if (proximityAlarmDlg.haveOkEvent()) {
|
||||
String string = "";
|
||||
if (prod.isAlarm()) {
|
||||
string += " (Alarm)";
|
||||
}
|
||||
if (!"".equals(prod.getSearchString())) {
|
||||
string += " \"" + prod.getSearchString()
|
||||
+ "\"";
|
||||
}
|
||||
aaList.setItem(index, prod.getProductId()
|
||||
+ string);
|
||||
paList.deselectAll();
|
||||
aaList.select(index);
|
||||
aaList.showSelection();
|
||||
changeSaveState(true);
|
||||
}
|
||||
}
|
||||
if (!"".equals(prod.getSearchString())) {
|
||||
string += " \"" + prod.getSearchString() + "\"";
|
||||
}
|
||||
aaList.setItem(index, prod.getProductId() + string);
|
||||
paList.deselectAll();
|
||||
aaList.select(index);
|
||||
aaList.showSelection();
|
||||
changeSaveState(true);
|
||||
}
|
||||
});
|
||||
proximityAlarmDlg.open();
|
||||
} else if (paList.getSelectionIndex() != -1) {
|
||||
// User might change selection while dialog is displayed.
|
||||
int index = paList.getSelectionIndex();
|
||||
final int index = paList.getSelectionIndex();
|
||||
proximityAlarmDlg = new NewAlarmDlg(shell, "PROXIMITY",
|
||||
papList.get(index - 1));
|
||||
AlarmAlertProduct prod = papList.set(index - 1,
|
||||
(AlarmAlertProduct) proximityAlarmDlg.open());
|
||||
if (proximityAlarmDlg.haveOkEvent()) {
|
||||
paList.setItem(
|
||||
paList.getSelectionIndex(),
|
||||
prod.getProductId()
|
||||
+ " "
|
||||
+ prod.getAlarmType()
|
||||
+ " "
|
||||
+ prod.getActionCmd()
|
||||
+ " "
|
||||
+ AlarmAlertFunctions
|
||||
.buildDistance(prod));
|
||||
aaList.deselectAll();
|
||||
paList.select(index);
|
||||
paList.showSelection();
|
||||
changeSaveState(true);
|
||||
}
|
||||
proximityAlarmDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
AlarmAlertProduct prod = (AlarmAlertProduct) returnValue;
|
||||
prod = papList.set(index - 1, prod);
|
||||
if (proximityAlarmDlg.haveOkEvent()) {
|
||||
paList.setItem(
|
||||
paList.getSelectionIndex(),
|
||||
prod.getProductId()
|
||||
+ " "
|
||||
+ prod.getAlarmType()
|
||||
+ " "
|
||||
+ prod.getActionCmd()
|
||||
+ " "
|
||||
+ AlarmAlertFunctions
|
||||
.buildDistance(prod));
|
||||
aaList.deselectAll();
|
||||
paList.select(index);
|
||||
paList.showSelection();
|
||||
changeSaveState(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
proximityAlarmDlg.open();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -602,11 +647,11 @@ public class AlarmAlertDlg extends CaveSWTDialog {
|
|||
lists.getFilteredProducts().clear();
|
||||
lists.getFilteredProducts().addAll(aapList);
|
||||
lists.getFilteredProducts().addAll(papList);
|
||||
|
||||
|
||||
LocalizationFile lFile = AlarmAlertFunctions.getFile(
|
||||
AlarmAlertFunctions.initUserLocalization(),
|
||||
currentFile.getName());
|
||||
|
||||
|
||||
AlarmAlertFunctions.saveAlarms(
|
||||
aapList.subList(siteAdminNumberAA - 1, aapList.size()),
|
||||
papList.subList(siteAdminNumberPA - 1, papList.size()), lFile);
|
||||
|
|
|
@ -58,6 +58,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* AWIPS2 DR Work
|
||||
* 07/25/2012 953 jkorman Modified file "search" to return LocalizationFile
|
||||
* instead of File so references are deleted in all locations.
|
||||
* 09/20/2012 1196 rferrel Setup fileName now in return value for
|
||||
* use with close callback.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -74,8 +76,6 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
|
|||
|
||||
private Composite shellComp;
|
||||
|
||||
private static AlarmAlertSaveLoadDlg saveLoadDlg = null;
|
||||
|
||||
private static String fileName = "";
|
||||
|
||||
private SaveOrLoad saveLoad;
|
||||
|
@ -91,7 +91,7 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
|
|||
*/
|
||||
protected AlarmAlertSaveLoadDlg(Shell parentShell, SaveOrLoad saveLoad) {
|
||||
super(parentShell, SWT.APPLICATION_MODAL | SWT.CLOSE | SWT.TITLE,
|
||||
CAVE.PERSPECTIVE_INDEPENDENT);
|
||||
CAVE.PERSPECTIVE_INDEPENDENT | CAVE.DO_NOT_BLOCK);
|
||||
if (saveLoad == SaveOrLoad.SAVE) {
|
||||
setText("Save Lists As...");
|
||||
} else {
|
||||
|
@ -148,7 +148,7 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
|
|||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
lists.setLayoutData(gd);
|
||||
LocalizationContext lc = AlarmAlertFunctions.initUserLocalization();
|
||||
|
||||
|
||||
// Get a list of localization files!
|
||||
LocalizationFile[] fList = PathManagerFactory.getPathManager()
|
||||
.listFiles(lc, "alarms", new String[] { "xml" }, false, true);
|
||||
|
@ -191,7 +191,12 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
|
|||
loadButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
// Set the filename to be returned through getFileName()
|
||||
fileName = lists.getSelection()[0];
|
||||
if (lists.getSelectionCount() > 0) {
|
||||
fileName = lists.getSelection()[0];
|
||||
} else {
|
||||
fileName = "";
|
||||
}
|
||||
setReturnValue(fileName);
|
||||
shell.close();
|
||||
}
|
||||
});
|
||||
|
@ -285,6 +290,7 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
|
|||
public void widgetSelected(SelectionEvent event) {
|
||||
// Set the filename to be returned through getFileName()
|
||||
fileName = textBox.getText();
|
||||
setReturnValue(fileName);
|
||||
shell.close();
|
||||
}
|
||||
});
|
||||
|
@ -311,12 +317,4 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
|
|||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
saveLoadDlg = new AlarmAlertSaveLoadDlg(new Shell(), SaveOrLoad.LOAD);
|
||||
saveLoadDlg.open();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* Sep 10, 2009 mnash Initial creation
|
||||
* Jun 08, 2010 5851 cjeanbap Properly stop alarm/alert observer listener; shellComp is null.
|
||||
* Oct 31, 2011 8510 rferrel made PRIMARY_MODEL and add check for nonblank productID.
|
||||
* Sep 20, 2012 1196 rferrel No longer Blocks
|
||||
* </pre>
|
||||
*
|
||||
* @author mnash
|
||||
|
@ -71,8 +72,7 @@ public class NewAlarmDlg extends CaveSWTDialog {
|
|||
e.text = e.text.toUpperCase();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
private Combo alarmAlert;
|
||||
|
||||
private Combo actionCmd;
|
||||
|
@ -108,8 +108,8 @@ public class NewAlarmDlg extends CaveSWTDialog {
|
|||
*/
|
||||
protected NewAlarmDlg(Shell parentShell, String alarm_or_alert,
|
||||
AlarmAlertProduct product) {
|
||||
super(parentShell, CAVE.PERSPECTIVE_INDEPENDENT | SWT.PRIMARY_MODAL
|
||||
| SWT.RESIZE);
|
||||
super(parentShell, SWT.PRIMARY_MODAL | SWT.RESIZE,
|
||||
CAVE.PERSPECTIVE_INDEPENDENT | CAVE.DO_NOT_BLOCK);
|
||||
if ("PROXIMITY".equals(alarm_or_alert)) {
|
||||
productType = ProductType.Proximity_Alarm;
|
||||
setText("New Proximity Alarm Product");
|
||||
|
@ -187,13 +187,13 @@ public class NewAlarmDlg extends CaveSWTDialog {
|
|||
*/
|
||||
private Text createProductIdField(Composite prods, String initValue) {
|
||||
Text prodIdField = new Text(prods, SWT.SINGLE | SWT.BORDER);
|
||||
if(initValue != null) {
|
||||
if (initValue != null) {
|
||||
prodIdField.setText(initValue);
|
||||
}
|
||||
prodIdField.addVerifyListener(productIdVerifier);
|
||||
return prodIdField;
|
||||
}
|
||||
|
||||
|
||||
private void createAlarmDialog() {
|
||||
Composite prods = new Composite(shellComp, SWT.NONE);
|
||||
GridLayout prodLayout = new GridLayout(3, false);
|
||||
|
@ -208,8 +208,8 @@ public class NewAlarmDlg extends CaveSWTDialog {
|
|||
prodLabelData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
prodId.setLayoutData(prodLabelData);
|
||||
|
||||
productId = createProductIdField(prods,prod.getProductId());
|
||||
|
||||
productId = createProductIdField(prods, prod.getProductId());
|
||||
|
||||
prodLabelData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
prodLabelData.grabExcessHorizontalSpace = true;
|
||||
prodLabelData.widthHint = 150;
|
||||
|
@ -260,8 +260,8 @@ public class NewAlarmDlg extends CaveSWTDialog {
|
|||
prodId.setText("Product ID:");
|
||||
|
||||
prodLabelData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
|
||||
productId = createProductIdField(prods,prod.getProductId());
|
||||
|
||||
productId = createProductIdField(prods, prod.getProductId());
|
||||
productId.setLayoutData(prodLabelData);
|
||||
|
||||
// separator
|
||||
|
@ -468,7 +468,7 @@ public class NewAlarmDlg extends CaveSWTDialog {
|
|||
} else {
|
||||
prod.setSearchString(searchString.getText());
|
||||
prod.setAlarm(alarmCheck.getSelection());
|
||||
if(alarmCheck.getSelection()) {
|
||||
if (alarmCheck.getSelection()) {
|
||||
prod.setAlarmType("Alarm");
|
||||
} else {
|
||||
prod.setAlarmType("Alert");
|
||||
|
|
|
@ -23,6 +23,7 @@ package com.raytheon.viz.texteditor.dialogs;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.events.FocusEvent;
|
||||
|
@ -46,7 +47,6 @@ import org.eclipse.swt.widgets.Label;
|
|||
import org.eclipse.swt.widgets.Layout;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.text.AfosWmoIdDataContainer;
|
||||
import com.raytheon.uf.common.dataplugin.text.db.AfosToAwips;
|
||||
|
@ -64,6 +64,7 @@ import com.raytheon.viz.texteditor.msgs.IAfosIdSelectionCallback;
|
|||
import com.raytheon.viz.texteditor.msgs.IWmoIdSelectionCallback;
|
||||
import com.raytheon.viz.texteditor.util.TextEditorUtil;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
* Dialog that allows the user to edit the AWIPS header block.
|
||||
|
@ -72,8 +73,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 9/13/07 368 lvenable Initial creation.
|
||||
* 10/11/2007 482 grichard Reformatted file.
|
||||
* 10/18/2007 482 grichard Implemented build 9 features.
|
||||
|
@ -91,7 +92,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* 05/30/2012 15046 D.Friedman Always set addressee field to ALL.
|
||||
* 06/19/2012 14975 D.Friedman Run callback when dialog is dismissed.
|
||||
* 07/26/2012 15171 rferrel Disable editor's send and clear AFOS PIL fields when
|
||||
* invalid product Id and user want to edit it anyway,
|
||||
* invalid product Id and user want to edit it anyway.
|
||||
* 09/20/2012 1196 rferrel Changing dialogs being called to not block.
|
||||
* </pre>
|
||||
*
|
||||
* @author lvenable
|
||||
|
@ -104,12 +106,12 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
/**
|
||||
* WMO data type and area indicator text field.
|
||||
*/
|
||||
private Text wmoTtaaiiTF;
|
||||
private StyledText wmoTtaaiiTF;
|
||||
|
||||
/**
|
||||
* International location indicator text field.
|
||||
*/
|
||||
private Text ccccTF;
|
||||
private StyledText ccccTF;
|
||||
|
||||
/**
|
||||
* Combo box Type of message/indicator group.
|
||||
|
@ -124,23 +126,23 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
/**
|
||||
* AFOS site ID text field.
|
||||
*/
|
||||
private Text wsfoIdTF;
|
||||
private StyledText wsfoIdTF;
|
||||
|
||||
/**
|
||||
* Product category text field.
|
||||
*/
|
||||
private Text prodCatTF;
|
||||
private StyledText prodCatTF;
|
||||
|
||||
/**
|
||||
* Product designator text field.
|
||||
*/
|
||||
private Text prodDesignatorTF;
|
||||
private StyledText prodDesignatorTF;
|
||||
|
||||
/**
|
||||
* Address text field. Defines the site where a text product or message is
|
||||
* sent.
|
||||
*/
|
||||
private Text addresseeTF;
|
||||
private StyledText addresseeTF;
|
||||
|
||||
/**
|
||||
* Zeros button. Puts "000" into the addressee text field. Zeros indicates
|
||||
|
@ -247,7 +249,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
|
||||
// Create the WMO ID text field.
|
||||
GridData gd = new GridData(55, SWT.DEFAULT);
|
||||
wmoTtaaiiTF = new Text(wmoIdComp, SWT.BORDER);
|
||||
wmoTtaaiiTF = new StyledText(wmoIdComp, SWT.BORDER);
|
||||
wmoTtaaiiTF.setTextLimit(6);
|
||||
wmoTtaaiiTF.setLayoutData(gd);
|
||||
|
||||
|
@ -264,7 +266,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
|
||||
// Create the international location indicator text field.
|
||||
gd = new GridData(45, SWT.DEFAULT);
|
||||
ccccTF = new Text(wmoIdComp, SWT.BORDER);
|
||||
ccccTF = new StyledText(wmoIdComp, SWT.BORDER);
|
||||
ccccTF.setTextLimit(4);
|
||||
ccccTF.setLayoutData(gd);
|
||||
if (textProd != null && textProd.getSite() != null) {
|
||||
|
@ -377,7 +379,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
|
||||
// Create the WSFO ID text field.
|
||||
GridData gd = new GridData(45, SWT.DEFAULT);
|
||||
wsfoIdTF = new Text(afosIdComp, SWT.BORDER);
|
||||
wsfoIdTF = new StyledText(afosIdComp, SWT.BORDER);
|
||||
wsfoIdTF.setTextLimit(3);
|
||||
wsfoIdTF.setLayoutData(gd);
|
||||
|
||||
|
@ -386,7 +388,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
|
||||
// Create the Product category text field.
|
||||
gd = new GridData(45, SWT.DEFAULT);
|
||||
prodCatTF = new Text(afosIdComp, SWT.BORDER);
|
||||
prodCatTF = new StyledText(afosIdComp, SWT.BORDER);
|
||||
prodCatTF.setTextLimit(3);
|
||||
prodCatTF.setLayoutData(gd);
|
||||
|
||||
|
@ -395,7 +397,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
|
||||
// Create the product designator text field.
|
||||
gd = new GridData(45, SWT.DEFAULT);
|
||||
prodDesignatorTF = new Text(afosIdComp, SWT.BORDER);
|
||||
prodDesignatorTF = new StyledText(afosIdComp, SWT.BORDER);
|
||||
prodDesignatorTF.setTextLimit(3);
|
||||
prodDesignatorTF.setLayoutData(gd);
|
||||
prodDesignatorTF.addFocusListener(new FocusListener() {
|
||||
|
@ -409,7 +411,13 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
while (sb.length() < 3) {
|
||||
sb.append(' ');
|
||||
}
|
||||
prodDesignatorTF.setText(sb.toString());
|
||||
|
||||
// Only trigger the modification listener when there is a
|
||||
// real change.
|
||||
String value = sb.toString();
|
||||
if (!value.equals(prodDesignatorTF.getText())) {
|
||||
prodDesignatorTF.setText(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -460,7 +468,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
addresseeComp.setLayout(rowLayout);
|
||||
|
||||
RowData rd = new RowData(45, SWT.DEFAULT);
|
||||
addresseeTF = new Text(addresseeComp, SWT.BORDER);
|
||||
addresseeTF = new StyledText(addresseeComp, SWT.BORDER);
|
||||
addresseeTF.setTextLimit(4);
|
||||
addresseeTF.setLayoutData(rd);
|
||||
// Set the "default" addressee to "ALL".
|
||||
|
@ -471,8 +479,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
// text field.
|
||||
addresseeTF.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent event) {
|
||||
if (addresseeTF.getCaretPosition() == addresseeTF
|
||||
.getTextLimit()) {
|
||||
if (addresseeTF.getCaretOffset() == addresseeTF.getTextLimit()) {
|
||||
wmoTtaaiiTF.setFocus();
|
||||
}
|
||||
|
||||
|
@ -564,13 +571,17 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
} else {
|
||||
lookupWmoIDs();
|
||||
|
||||
if (prodDesignatorTF.getCaretPosition() == prodDesignatorTF
|
||||
.getTextLimit()) {
|
||||
addresseeTF.setFocus();
|
||||
if (!isDisposed()) {
|
||||
if (prodDesignatorTF.getCaretOffset() == prodDesignatorTF
|
||||
.getTextLimit()) {
|
||||
addresseeTF.setFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkEnableEnter();
|
||||
if (!isDisposed()) {
|
||||
checkEnableEnter();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -755,8 +766,16 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
|
||||
AfosIdSelectionDialog dlg = new AfosIdSelectionDialog(
|
||||
shell, this, afosIds);
|
||||
dlg.setBlockOnOpen(true);
|
||||
dlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
lookupAllowed = true;
|
||||
}
|
||||
});
|
||||
dlg.setBlockOnOpen(false);
|
||||
dlg.open();
|
||||
return;
|
||||
} else if (list.size() == 1) {
|
||||
setAfosId(list.get(0).getAfosid());
|
||||
} else {
|
||||
|
@ -820,8 +839,16 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
|
||||
WmoIdSelectionDialog dlg = new WmoIdSelectionDialog(
|
||||
shell, this, ttaaiiIds, ccccIds);
|
||||
dlg.setBlockOnOpen(true);
|
||||
dlg.setBlockOnOpen(false);
|
||||
dlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
lookupAllowed = true;
|
||||
}
|
||||
});
|
||||
dlg.open();
|
||||
return;
|
||||
} else if (list.size() == 1) {
|
||||
AfosToAwips id = list.get(0);
|
||||
setWmoId(id.getWmottaaii(), id.getWmocccc());
|
||||
|
@ -839,7 +866,6 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error occurred looking up WMO IDs", e);
|
||||
}
|
||||
|
||||
lookupAllowed = true;
|
||||
}
|
||||
}
|
||||
|
@ -889,8 +915,8 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
enterBtn.setEnabled(enable);
|
||||
}
|
||||
|
||||
private void textFieldKeyListener(final Text tf, final Text previousTF,
|
||||
final Text nextTF) {
|
||||
private void textFieldKeyListener(final StyledText tf,
|
||||
final StyledText previousTF, final StyledText nextTF) {
|
||||
tf.addKeyListener(new KeyAdapter() {
|
||||
|
||||
@Override
|
||||
|
@ -898,7 +924,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
char c = e.character;
|
||||
|
||||
if (Character.isLetterOrDigit(c) || Character.isSpaceChar(c)) {
|
||||
int pos = tf.getCaretPosition();
|
||||
int pos = tf.getCaretOffset();
|
||||
String text = tf.getText();
|
||||
|
||||
if (text.length() > pos) {
|
||||
|
@ -909,16 +935,16 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
}
|
||||
} else if (e.keyCode == SWT.ARROW_UP) {
|
||||
previousTF.setFocus();
|
||||
previousTF.setSelection(0);
|
||||
previousTF.selectAll();
|
||||
} else if (e.keyCode == SWT.ARROW_DOWN) {
|
||||
nextTF.setFocus();
|
||||
nextTF.setSelection(0);
|
||||
nextTF.selectAll();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void textFieldVerifyListener(final Text tf) {
|
||||
private void textFieldVerifyListener(final StyledText tf) {
|
||||
tf.addVerifyListener(new VerifyListener() {
|
||||
@Override
|
||||
public void verifyText(VerifyEvent e) {
|
||||
|
@ -944,8 +970,8 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
});
|
||||
}
|
||||
|
||||
private void textFieldModifyListener(final Text tf, final Text nextTF,
|
||||
final boolean callAfosLookup) {
|
||||
private void textFieldModifyListener(final StyledText tf,
|
||||
final StyledText nextTF, final boolean callAfosLookup) {
|
||||
tf.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent event) {
|
||||
if (tf.getCharCount() == tf.getTextLimit()) {
|
||||
|
@ -956,12 +982,14 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
|
|||
}
|
||||
}
|
||||
|
||||
if (tf.getCaretPosition() == tf.getTextLimit()) {
|
||||
nextTF.setFocus();
|
||||
nextTF.setSelection(0);
|
||||
}
|
||||
if (!isDisposed()) {
|
||||
if (tf.getCaretOffset() == tf.getTextLimit()) {
|
||||
nextTF.setFocus();
|
||||
nextTF.selectAll();
|
||||
}
|
||||
|
||||
checkEnableEnter();
|
||||
checkEnableEnter();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.jface.dialogs.IDialogConstants;
|
|||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
@ -43,6 +44,8 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 28, 2009 2924 rjpeter Initial creation.
|
||||
* Sep 20, 1010 1196 rferrel Scroll bar now displays and limit placed
|
||||
* on the height of the dialog.
|
||||
* </pre>
|
||||
*
|
||||
* @author rjpeter
|
||||
|
@ -120,7 +123,7 @@ public class AfosIdSelectionDialog extends CaveJFACEDialog {
|
|||
label.setLayoutData(data);
|
||||
|
||||
afosIdList = new List(top, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
|
||||
data = new GridData(SWT.BEGINNING, SWT.DEFAULT, true, false);
|
||||
data = new GridData(SWT.CENTER, SWT.FILL, false, true);
|
||||
afosIdList.setLayoutData(data);
|
||||
|
||||
for (String id : afosIds) {
|
||||
|
@ -158,4 +161,13 @@ public class AfosIdSelectionDialog extends CaveJFACEDialog {
|
|||
top.layout();
|
||||
return top;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Point getInitialSize() {
|
||||
Point point = super.getInitialSize();
|
||||
if (point.y > 500) {
|
||||
point.y = 500;
|
||||
}
|
||||
return point;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,12 +27,15 @@ import java.util.List;
|
|||
import java.util.TimeZone;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.FocusAdapter;
|
||||
import org.eclipse.swt.events.FocusEvent;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.events.KeyAdapter;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.VerifyEvent;
|
||||
import org.eclipse.swt.events.VerifyListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
|
@ -40,7 +43,6 @@ import org.eclipse.swt.widgets.Composite;
|
|||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Layout;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.text.AfosWmoIdDataContainer;
|
||||
import com.raytheon.uf.common.dataplugin.text.db.AfosToAwips;
|
||||
|
@ -58,6 +60,7 @@ import com.raytheon.viz.texteditor.command.CommandFailedException;
|
|||
import com.raytheon.viz.texteditor.msgs.IWmoIdSelectionCallback;
|
||||
import com.raytheon.viz.texteditor.util.TextEditorUtil;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
* The Remote Site Request dialog.
|
||||
|
@ -70,39 +73,50 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 9/13/07 368 lvenable Initial creation.
|
||||
* 10/11/2007 482 grichard Reformatted file.
|
||||
* 09/20/2012 1196 rferrel Changing dialogs being called to not block.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author lvenable
|
||||
*/
|
||||
public class RemoteSiteRequestDlg extends CaveSWTDialog {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(RemoteSiteRequestDlg.class);
|
||||
public class RemoteSiteRequestDlg extends CaveSWTDialog implements
|
||||
IWmoIdSelectionCallback {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(RemoteSiteRequestDlg.class);
|
||||
|
||||
private StyledText ttaaiiTF;
|
||||
|
||||
private StyledText ccccTF;
|
||||
|
||||
/**
|
||||
* AFOS site ID text field.
|
||||
*/
|
||||
private Text wsfoIdTF;
|
||||
private StyledText wsfoIdTF;
|
||||
|
||||
/**
|
||||
* Product category text field.
|
||||
*/
|
||||
private Text productCatTF;
|
||||
private StyledText productCatTF;
|
||||
|
||||
/**
|
||||
* Product designator text field.
|
||||
*/
|
||||
private Text prodDesignatorTF;
|
||||
private StyledText prodDesignatorTF;
|
||||
|
||||
/**
|
||||
* Address text field. Defines the site where a text product or message is
|
||||
* sent.
|
||||
*/
|
||||
private Text addresseeTF;
|
||||
|
||||
private StyledText addresseeTF;
|
||||
|
||||
private Button enterBtn;
|
||||
|
||||
|
||||
private String initialAfosID;
|
||||
|
||||
private WmoIdSelectionDialog wmoIdSelectionDialog;
|
||||
|
||||
boolean lookupAllowed = true;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -110,7 +124,8 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog {
|
|||
* Parent shell.
|
||||
*/
|
||||
public RemoteSiteRequestDlg(Shell parent) {
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.PERSPECTIVE_INDEPENDENT);
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.PERSPECTIVE_INDEPENDENT
|
||||
| CAVE.DO_NOT_BLOCK);
|
||||
setText("Send Request");
|
||||
}
|
||||
|
||||
|
@ -128,7 +143,7 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog {
|
|||
protected void initializeComponents(Shell shell) {
|
||||
createInputFields();
|
||||
createBottomButtons();
|
||||
validate();
|
||||
checkEnableEnter();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,137 +156,84 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog {
|
|||
gridLayout.marginTop = 1;
|
||||
gridLayout.horizontalSpacing = 20;
|
||||
topComp.setLayout(gridLayout);
|
||||
GridData gd = null;
|
||||
Label sepLbl = null;
|
||||
|
||||
gd = new GridData(70, SWT.DEFAULT);
|
||||
ttaaiiTF = new StyledText(topComp, SWT.BORDER | SWT.READ_ONLY);
|
||||
ttaaiiTF.setTextLimit(6);
|
||||
ttaaiiTF.setLayoutData(gd);
|
||||
ttaaiiTF.setEnabled(false);
|
||||
ttaaiiTF.setEditable(false);
|
||||
ttaaiiTF.setBackground(shell.getBackground());
|
||||
|
||||
Label ttaaiiLbl = new Label(topComp, SWT.NONE);
|
||||
ttaaiiLbl.setText("TTAAii");
|
||||
|
||||
gd = new GridData(45, SWT.DEFAULT);
|
||||
ccccTF = new StyledText(topComp, SWT.BORDER | SWT.READ_ONLY);
|
||||
ccccTF.setEnabled(false);
|
||||
ccccTF.setEditable(false);
|
||||
ccccTF.setLayoutData(gd);
|
||||
ccccTF.setBackground(shell.getBackground());
|
||||
Label ccccLbl = new Label(topComp, SWT.NONE);
|
||||
ccccLbl.setText("CCCC");
|
||||
|
||||
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
gd.horizontalSpan = 2;
|
||||
sepLbl = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL);
|
||||
sepLbl.setLayoutData(gd);
|
||||
|
||||
ModifyListener validator = new ModifyListener() {
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
validate();
|
||||
}
|
||||
};
|
||||
|
||||
// Create the WSFO ID text field.
|
||||
GridData gd = new GridData(45, SWT.DEFAULT);
|
||||
wsfoIdTF = new Text(topComp, SWT.BORDER);
|
||||
gd = new GridData(45, SWT.DEFAULT);
|
||||
wsfoIdTF = new StyledText(topComp, SWT.BORDER);
|
||||
wsfoIdTF.setTextLimit(3);
|
||||
wsfoIdTF.setLayoutData(gd);
|
||||
wsfoIdTF.addFocusListener(new FocusAdapter() {
|
||||
public void focusLost(FocusEvent event) {
|
||||
wsfoIdTF.setText(wsfoIdTF.getText().toUpperCase());
|
||||
}
|
||||
});
|
||||
|
||||
// When the number of characters enter reaches the max limit and
|
||||
// the caret position is at the end then switch focus to another
|
||||
// text field.
|
||||
wsfoIdTF.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent event) {
|
||||
if (wsfoIdTF.getCaretPosition() == wsfoIdTF.getTextLimit()) {
|
||||
productCatTF.setFocus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
wsfoIdTF.addModifyListener(validator);
|
||||
|
||||
Label wsfoIdLbl = new Label(topComp, SWT.NONE);
|
||||
wsfoIdLbl.setText("WSFO Identification");
|
||||
|
||||
// Create the product category text field.
|
||||
gd = new GridData(45, SWT.DEFAULT);
|
||||
productCatTF = new Text(topComp, SWT.BORDER);
|
||||
productCatTF = new StyledText(topComp, SWT.BORDER);
|
||||
productCatTF.setTextLimit(3);
|
||||
productCatTF.setLayoutData(gd);
|
||||
productCatTF.addFocusListener(new FocusAdapter() {
|
||||
public void focusLost(FocusEvent event) {
|
||||
productCatTF.setText(productCatTF.getText().toUpperCase());
|
||||
}
|
||||
});
|
||||
|
||||
// When the number of characters enter reaches the max limit and
|
||||
// the caret position is at the end then switch focus to another
|
||||
// text field.
|
||||
productCatTF.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent event) {
|
||||
if (productCatTF.getCaretPosition() == productCatTF
|
||||
.getTextLimit()) {
|
||||
prodDesignatorTF.setFocus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
productCatTF.addModifyListener(validator);
|
||||
|
||||
Label productCatLbl = new Label(topComp, SWT.NONE);
|
||||
productCatLbl.setText("Product Category");
|
||||
|
||||
// Create the product designator text field.
|
||||
gd = new GridData(45, SWT.DEFAULT);
|
||||
prodDesignatorTF = new Text(topComp, SWT.BORDER);
|
||||
prodDesignatorTF = new StyledText(topComp, SWT.BORDER);
|
||||
prodDesignatorTF.setTextLimit(3);
|
||||
prodDesignatorTF.setLayoutData(gd);
|
||||
prodDesignatorTF.addFocusListener(new FocusAdapter() {
|
||||
public void focusLost(FocusEvent event) {
|
||||
prodDesignatorTF.setText(prodDesignatorTF.getText()
|
||||
.toUpperCase());
|
||||
}
|
||||
});
|
||||
|
||||
// When the number of characters enter reaches the max limit and
|
||||
// the caret position is at the end then switch focus to another
|
||||
// text field.
|
||||
prodDesignatorTF.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent event) {
|
||||
if (prodDesignatorTF.getCaretPosition() == prodDesignatorTF
|
||||
.getTextLimit()) {
|
||||
addresseeTF.setFocus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
prodDesignatorTF.addModifyListener(validator);
|
||||
|
||||
Label prodDesignatorLbl = new Label(topComp, SWT.NONE);
|
||||
prodDesignatorLbl.setText("Product Designator");
|
||||
|
||||
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
gd.horizontalSpan = 2;
|
||||
Label sepLbl = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL);
|
||||
sepLbl = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL);
|
||||
sepLbl.setLayoutData(gd);
|
||||
|
||||
// Create the addressee text field.
|
||||
gd = new GridData(45, SWT.DEFAULT);
|
||||
addresseeTF = new Text(topComp, SWT.BORDER);
|
||||
addresseeTF = new StyledText(topComp, SWT.BORDER);
|
||||
addresseeTF.setTextLimit(4);
|
||||
addresseeTF.setText("DEF");
|
||||
addresseeTF.setLayoutData(gd);
|
||||
addresseeTF.addFocusListener(new FocusAdapter() {
|
||||
public void focusLost(FocusEvent event) {
|
||||
addresseeTF.setText(addresseeTF.getText().toUpperCase());
|
||||
}
|
||||
});
|
||||
|
||||
// When the number of characters enter reaches the max limit and
|
||||
// the caret position is at the end then switch focus to another
|
||||
// text field.
|
||||
addresseeTF.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent event) {
|
||||
if (addresseeTF.getCaretPosition() == addresseeTF
|
||||
.getTextLimit()) {
|
||||
wsfoIdTF.setFocus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
addresseeTF.addModifyListener(validator);
|
||||
|
||||
Label addresseeLbl = new Label(topComp, SWT.NONE);
|
||||
addresseeLbl.setText("Addressee");
|
||||
|
||||
setupTextFieldListeners();
|
||||
|
||||
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
gd.horizontalSpan = 2;
|
||||
sepLbl = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL);
|
||||
sepLbl.setLayoutData(gd);
|
||||
|
||||
|
||||
// TODO set fields should be moved to preOpen()
|
||||
String ccc = "";
|
||||
String nnn = "";
|
||||
String xxx = "";
|
||||
|
@ -287,6 +249,24 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog {
|
|||
prodDesignatorTF.setText(xxx);
|
||||
}
|
||||
|
||||
private void setupTextFieldListeners() {
|
||||
// forces all fields to uppercase and only allows numbers/digits
|
||||
textFieldVerifyListener(wsfoIdTF);
|
||||
textFieldVerifyListener(productCatTF);
|
||||
textFieldVerifyListener(prodDesignatorTF);
|
||||
textFieldVerifyListener(addresseeTF);
|
||||
|
||||
// forces overwrite and arrow key traversal
|
||||
textFieldKeyListener(wsfoIdTF, addresseeTF, productCatTF);
|
||||
textFieldKeyListener(productCatTF, wsfoIdTF, prodDesignatorTF);
|
||||
textFieldKeyListener(prodDesignatorTF, productCatTF, addresseeTF);
|
||||
textFieldKeyListener(addresseeTF, prodDesignatorTF, wsfoIdTF);
|
||||
|
||||
textFieldModifyListener(wsfoIdTF, productCatTF, true);
|
||||
textFieldModifyListener(productCatTF, prodDesignatorTF, true);
|
||||
textFieldModifyListener(prodDesignatorTF, addresseeTF, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the bottom Enter and Cancel buttons.
|
||||
*/
|
||||
|
@ -323,79 +303,9 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void validate() {
|
||||
if (enterBtn != null)
|
||||
enterBtn.setEnabled(createReturnValue(true));
|
||||
}
|
||||
|
||||
// Copied from AWIPSHeaderBlockDlg.lookupWmoIDs()
|
||||
private boolean lookupWmoId(final RemoteRetrievalRequest rrRequest) {
|
||||
GetWmoIdRequest request = new GetWmoIdRequest();
|
||||
request.setAfosId(rrRequest.getAfosID());
|
||||
|
||||
try {
|
||||
Object response = ThriftClient.sendRequest(request);
|
||||
if (response != null) {
|
||||
if (response instanceof AfosWmoIdDataContainer) {
|
||||
AfosWmoIdDataContainer container = (AfosWmoIdDataContainer) response;
|
||||
if (container.getErrorMessage() != null) {
|
||||
statusHandler.handle(
|
||||
Priority.PROBLEM,
|
||||
"Error occurred looking up WMO IDs\nMessage from server["
|
||||
+ container
|
||||
.getErrorMessage()
|
||||
+ "]");
|
||||
}
|
||||
|
||||
List<AfosToAwips> list = container.getIdList();
|
||||
|
||||
if (list.size() > 1) {
|
||||
ArrayList<String> ttaaiiIds = new ArrayList<String>(
|
||||
list.size());
|
||||
ArrayList<String> ccccIds = new ArrayList<String>(
|
||||
list.size());
|
||||
for (AfosToAwips id : list) {
|
||||
ttaaiiIds.add(id.getWmottaaii());
|
||||
ccccIds.add(id.getWmocccc());
|
||||
}
|
||||
|
||||
|
||||
IWmoIdSelectionCallback cb = new IWmoIdSelectionCallback() {
|
||||
@Override
|
||||
public void setWmoId(String ttaaii, String cccc) {
|
||||
rrRequest.setWmoHeader(ttaaii + ' ' + cccc);
|
||||
}
|
||||
};
|
||||
WmoIdSelectionDialog dlg = new WmoIdSelectionDialog(
|
||||
shell, cb, ttaaiiIds, ccccIds);
|
||||
dlg.setBlockOnOpen(true);
|
||||
dlg.open();
|
||||
return rrRequest.getWmoHeader() != null &&
|
||||
rrRequest.getWmoHeader().length() > 0;
|
||||
} else if (list.size() == 1) {
|
||||
AfosToAwips id = list.get(0);
|
||||
rrRequest.setWmoHeader(id.getWmottaaii() + ' ' + id.getWmocccc());
|
||||
} else {
|
||||
rrRequest.setWmoHeader("");
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Received unhandled WMO Id lookup response from server. Received obj of type ["
|
||||
+ response.getClass() + "], contents["
|
||||
+ response + "]");
|
||||
}
|
||||
}
|
||||
} catch (VizException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error occurred looking up WMO IDs", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Calendar createCalRelativeTo(Calendar relative, WMOHeader wmoHeader, int monthAdjustment) {
|
||||
private Calendar createCalRelativeTo(Calendar relative,
|
||||
WMOHeader wmoHeader, int monthAdjustment) {
|
||||
Calendar c = new GregorianCalendar(relative.getTimeZone());
|
||||
c.setTimeInMillis(relative.getTimeInMillis());
|
||||
c.add(GregorianCalendar.MONTH, monthAdjustment);
|
||||
|
@ -406,11 +316,11 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog {
|
|||
c.set(GregorianCalendar.MILLISECOND, 0);
|
||||
return c;
|
||||
}
|
||||
|
||||
private Calendar getCloserCalendar(Calendar reference, Calendar a, Calendar b) {
|
||||
return Math.abs(a.getTimeInMillis() - reference.getTimeInMillis()) <
|
||||
Math.abs(b.getTimeInMillis() - reference.getTimeInMillis()) ?
|
||||
a : b;
|
||||
|
||||
private Calendar getCloserCalendar(Calendar reference, Calendar a,
|
||||
Calendar b) {
|
||||
return Math.abs(a.getTimeInMillis() - reference.getTimeInMillis()) < Math
|
||||
.abs(b.getTimeInMillis() - reference.getTimeInMillis()) ? a : b;
|
||||
}
|
||||
|
||||
private boolean createReturnValue(boolean validateOnly) {
|
||||
|
@ -418,41 +328,41 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog {
|
|||
String nnn = productCatTF.getText();
|
||||
String xxx = prodDesignatorTF.getText();
|
||||
String addr = addresseeTF.getText();
|
||||
if (ccc.length() != 3 || nnn.length() != 3 ||
|
||||
xxx.length() < 1 || xxx.length() > 3 ||
|
||||
addr.length() < 1)
|
||||
if (ccc.length() != 3 || nnn.length() != 3 || xxx.length() < 1
|
||||
|| xxx.length() > 3 || addr.length() < 1)
|
||||
return false;
|
||||
|
||||
|
||||
if (validateOnly)
|
||||
return true;
|
||||
|
||||
|
||||
String afosID = ccc + nnn + xxx;
|
||||
GetWmoIdRequest request = new GetWmoIdRequest();
|
||||
request.setAfosId(afosID);
|
||||
|
||||
|
||||
RemoteRetrievalRequest req = new RemoteRetrievalRequest();
|
||||
// TODO: Translate addr via awipsSites.txt or siteDistLists.txt
|
||||
req.setAddressee(addr);
|
||||
req.setAfosID(afosID);
|
||||
|
||||
|
||||
List<StdTextProduct> latest = null;
|
||||
try {
|
||||
latest = CommandFactory.getAfosCommand(req.getAfosID()).executeCommand(TextEditorUtil
|
||||
.getTextDbsrvTransport());
|
||||
latest = CommandFactory.getAfosCommand(req.getAfosID())
|
||||
.executeCommand(TextEditorUtil.getTextDbsrvTransport());
|
||||
} catch (CommandFailedException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error retrieving metatdata", e);
|
||||
// but keep going...
|
||||
}
|
||||
|
||||
|
||||
if (latest != null && latest.size() > 0) {
|
||||
Calendar c = new GregorianCalendar(TimeZone
|
||||
.getTimeZone("GMT"));
|
||||
Calendar c = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
|
||||
c.setTimeInMillis(latest.get(0).getRefTime());
|
||||
req.setMostRecentTime(c.getTimeInMillis()); // default
|
||||
try {
|
||||
WMOHeader wmo = new WMOHeader(latest.get(0).getProduct().getBytes());
|
||||
Calendar t = getCloserCalendar(c, createCalRelativeTo(c, wmo, 0),
|
||||
WMOHeader wmo = new WMOHeader(latest.get(0).getProduct()
|
||||
.getBytes());
|
||||
Calendar t = getCloserCalendar(c,
|
||||
createCalRelativeTo(c, wmo, 0),
|
||||
createCalRelativeTo(c, wmo, 1));
|
||||
t = getCloserCalendar(c, t, createCalRelativeTo(c, wmo, -1));
|
||||
req.setMostRecentTime(t.getTimeInMillis());
|
||||
|
@ -463,18 +373,205 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog {
|
|||
} else
|
||||
req.setMostRecentTime(0);
|
||||
|
||||
if (! lookupWmoId(req))
|
||||
return false;
|
||||
|
||||
req.setValidTime(System.currentTimeMillis() + 600 * 1000); // Current time plus 10 minutes
|
||||
|
||||
String ttaaii = ttaaiiTF.getText();
|
||||
String cccc = ccccTF.getText();
|
||||
if (ttaaii.length() > 0 && cccc.length() > 0) {
|
||||
req.setWmoHeader(ttaaii + " " + cccc);
|
||||
} else {
|
||||
req.setWmoHeader("");
|
||||
}
|
||||
|
||||
req.setValidTime(System.currentTimeMillis() + 600 * 1000); // Current
|
||||
// time plus
|
||||
// 10 minutes
|
||||
|
||||
setReturnValue(req);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void textFieldKeyListener(final StyledText tf,
|
||||
final StyledText previousTF, final StyledText nextTF) {
|
||||
tf.addKeyListener(new KeyAdapter() {
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
char c = e.character;
|
||||
|
||||
if (Character.isLetterOrDigit(c) || Character.isSpaceChar(c)) {
|
||||
int pos = tf.getCaretOffset();
|
||||
String text = tf.getText();
|
||||
|
||||
if (text.length() > pos) {
|
||||
StringBuilder b = new StringBuilder(text);
|
||||
b.deleteCharAt(pos);
|
||||
tf.setText(b.toString());
|
||||
tf.setSelection(pos);
|
||||
}
|
||||
} else if (e.keyCode == SWT.ARROW_UP) {
|
||||
previousTF.setFocus();
|
||||
previousTF.selectAll();
|
||||
} else if (e.keyCode == SWT.ARROW_DOWN) {
|
||||
nextTF.setFocus();
|
||||
nextTF.selectAll();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void textFieldVerifyListener(final StyledText tf) {
|
||||
tf.addVerifyListener(new VerifyListener() {
|
||||
@Override
|
||||
public void verifyText(VerifyEvent e) {
|
||||
e.text = e.text.toUpperCase();
|
||||
StringBuilder b = null;
|
||||
int posMod = 0;
|
||||
char[] chars = e.text.toCharArray();
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
char c = chars[i];
|
||||
if (!Character.isLetterOrDigit(c)
|
||||
&& !Character.isSpaceChar(c)) {
|
||||
if (b == null) {
|
||||
b = new StringBuilder(e.text);
|
||||
}
|
||||
b.deleteCharAt(i - posMod++);
|
||||
}
|
||||
}
|
||||
|
||||
if (b != null) {
|
||||
e.text = b.toString();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void textFieldModifyListener(final StyledText tf,
|
||||
final StyledText nextTF, final boolean limitCheck) {
|
||||
tf.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent event) {
|
||||
if (!limitCheck || tf.getCharCount() == tf.getTextLimit()) {
|
||||
if (wmoIdSelectionDialog == null) {
|
||||
lookupWmoIDs();
|
||||
} else {
|
||||
wmoIdSelectionDialog.close();
|
||||
wmoIdSelectionDialog = null;
|
||||
lookupWmoIDs();
|
||||
}
|
||||
} else {
|
||||
if (wmoIdSelectionDialog != null) {
|
||||
wmoIdSelectionDialog.close();
|
||||
wmoIdSelectionDialog = null;
|
||||
}
|
||||
setWmoId("", "");
|
||||
checkEnableEnter();
|
||||
}
|
||||
|
||||
if (!isDisposed()) {
|
||||
if (tf.getCaretOffset() == tf.getTextLimit()) {
|
||||
nextTF.setFocus();
|
||||
nextTF.selectAll();
|
||||
}
|
||||
|
||||
checkEnableEnter();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void lookupWmoIDs() {
|
||||
if (lookupAllowed && wsfoIdTF.getCharCount() == wsfoIdTF.getTextLimit()
|
||||
&& productCatTF.getCharCount() == productCatTF.getTextLimit()
|
||||
&& prodDesignatorTF.getText().length() > 0) {
|
||||
GetWmoIdRequest request = new GetWmoIdRequest();
|
||||
request.setAfosId(wsfoIdTF.getText() + productCatTF.getText()
|
||||
+ prodDesignatorTF.getText());
|
||||
lookupAllowed = false;
|
||||
|
||||
try {
|
||||
Object response = ThriftClient.sendRequest(request);
|
||||
if (response != null) {
|
||||
if (response instanceof AfosWmoIdDataContainer) {
|
||||
AfosWmoIdDataContainer container = (AfosWmoIdDataContainer) response;
|
||||
if (container.getErrorMessage() != null) {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
"Error occurred looking up WMO IDs\nMessage from server["
|
||||
+ container
|
||||
.getErrorMessage()
|
||||
+ "]");
|
||||
}
|
||||
|
||||
java.util.List<AfosToAwips> list = container
|
||||
.getIdList();
|
||||
|
||||
if (list.size() > 1) {
|
||||
ArrayList<String> ttaaiiIds = new ArrayList<String>(
|
||||
list.size());
|
||||
ArrayList<String> ccccIds = new ArrayList<String>(
|
||||
list.size());
|
||||
for (AfosToAwips id : list) {
|
||||
ttaaiiIds.add(id.getWmottaaii());
|
||||
ccccIds.add(id.getWmocccc());
|
||||
}
|
||||
|
||||
wmoIdSelectionDialog = new WmoIdSelectionDialog(
|
||||
shell, this, ttaaiiIds, ccccIds);
|
||||
wmoIdSelectionDialog
|
||||
.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(
|
||||
Object returnValue) {
|
||||
lookupAllowed = true;
|
||||
wmoIdSelectionDialog = null;
|
||||
}
|
||||
});
|
||||
wmoIdSelectionDialog.setBlockOnOpen(false);
|
||||
wmoIdSelectionDialog.open();
|
||||
return;
|
||||
} else if (list.size() == 1) {
|
||||
AfosToAwips id = list.get(0);
|
||||
setWmoId(id.getWmottaaii(), id.getWmocccc());
|
||||
} else {
|
||||
setWmoId("", "");
|
||||
}
|
||||
checkEnableEnter();
|
||||
} else {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Received unhandled WMO Id lookup response from server. Received obj of type ["
|
||||
+ response.getClass() + "], contents["
|
||||
+ response + "]");
|
||||
}
|
||||
}
|
||||
} catch (VizException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error occurred looking up WMO IDs", e);
|
||||
}
|
||||
|
||||
lookupAllowed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void setRequest(RemoteRetrievalRequest lastRemoteRetrievalRequest) {
|
||||
initialAfosID = null;
|
||||
if (lastRemoteRetrievalRequest != null)
|
||||
initialAfosID = lastRemoteRetrievalRequest.getAfosID();
|
||||
}
|
||||
|
||||
private void checkEnableEnter() {
|
||||
boolean enabled = false;
|
||||
if (enterBtn != null && !isDisposed()) {
|
||||
if (ttaaiiTF.getCharCount() > 0 && ccccTF.getCharCount() > 0
|
||||
&& addresseeTF.getCharCount() > 0) {
|
||||
enabled = true;
|
||||
}
|
||||
enterBtn.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWmoId(String ttaaii, String cccc) {
|
||||
ttaaiiTF.setText(ttaaii);
|
||||
ccccTF.setText(cccc);
|
||||
checkEnableEnter();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,7 +158,6 @@ import com.raytheon.viz.texteditor.command.CommandFailedException;
|
|||
import com.raytheon.viz.texteditor.command.CommandHistory;
|
||||
import com.raytheon.viz.texteditor.command.CommandType;
|
||||
import com.raytheon.viz.texteditor.command.ICommand;
|
||||
import com.raytheon.viz.texteditor.dialogs.WarnGenConfirmationDlg.SessionDelegate;
|
||||
import com.raytheon.viz.texteditor.fax.dialogs.FaxMessageDlg;
|
||||
import com.raytheon.viz.texteditor.fax.dialogs.LdadFaxSitesDlg;
|
||||
import com.raytheon.viz.texteditor.msgs.IAfosBrowserCallback;
|
||||
|
@ -180,6 +179,7 @@ import com.raytheon.viz.texteditor.util.TextEditorUtil;
|
|||
import com.raytheon.viz.texteditor.util.VtecObject;
|
||||
import com.raytheon.viz.texteditor.util.VtecUtil;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
import com.raytheon.viz.ui.dialogs.SWTMessageBox;
|
||||
|
||||
/**
|
||||
|
@ -288,6 +288,7 @@ import com.raytheon.viz.ui.dialogs.SWTMessageBox;
|
|||
* 10Sep2012 15103 M.Gamazaychikov DR15103 -do not clear AFOS command from the text box
|
||||
* when obs are updated and refactored executeCommand
|
||||
* 10SEP2012 15401 D.Friedman Fix QC problem caused by DR 15340.
|
||||
* 20SEP2012 1196 rferrel Refactor dialogs to prevent blocking.
|
||||
* </pre>
|
||||
*
|
||||
* @author lvenable
|
||||
|
@ -1447,14 +1448,21 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
public void widgetSelected(SelectionEvent event) {
|
||||
RemoteSiteRequestDlg requestDlg = new RemoteSiteRequestDlg(
|
||||
shell);
|
||||
if (lastRemoteRetrievalRequest != null)
|
||||
if (lastRemoteRetrievalRequest != null) {
|
||||
requestDlg.setRequest(lastRemoteRetrievalRequest);
|
||||
RemoteRetrievalRequest req = (RemoteRetrievalRequest) requestDlg
|
||||
.open();
|
||||
if (req != null) {
|
||||
lastRemoteRetrievalRequest = req;
|
||||
sendRemoteRetrievalRequest(req);
|
||||
}
|
||||
requestDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
RemoteRetrievalRequest req = (RemoteRetrievalRequest) returnValue;
|
||||
if (req != null) {
|
||||
lastRemoteRetrievalRequest = req;
|
||||
sendRemoteRetrievalRequest(req);
|
||||
}
|
||||
}
|
||||
});
|
||||
requestDlg.open();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -4400,22 +4408,36 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell,
|
||||
"Problem Detected by QC", qcCheck.getErrorMessage(),
|
||||
"Do you really want to Send?\n", mode);
|
||||
wgcd.open(new SessionDelegate() {
|
||||
wgcd.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogDismissed(Object dialogResult) {
|
||||
if (Boolean.TRUE.equals(dialogResult))
|
||||
finishSendProduct1(resend, title, mode,
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (Boolean.TRUE.equals(returnValue))
|
||||
finishSendProduct(resend, title, mode,
|
||||
productMessage, modeMessage);
|
||||
|
||||
}
|
||||
});
|
||||
wgcd.open();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
finishSendProduct1(resend, title, mode, productMessage, modeMessage);
|
||||
finishSendProduct(resend, title, mode, productMessage, modeMessage);
|
||||
}
|
||||
|
||||
private void finishSendProduct1(final boolean resend, String title,
|
||||
/**
|
||||
* This finishes preparing to send a product as part of normal compleation
|
||||
* of sendProduct or as part of the call back when there is a problem with
|
||||
* the WarnGen being sent.
|
||||
*
|
||||
* @param resend
|
||||
* @param title
|
||||
* @param mode
|
||||
* @param productMessage
|
||||
* @param modeMessage
|
||||
*/
|
||||
private void finishSendProduct(final boolean resend, String title,
|
||||
CAVEMode mode, StringBuilder productMessage,
|
||||
StringBuilder modeMessage) {
|
||||
Pattern p = Pattern.compile(".\\%[s].");
|
||||
|
@ -4450,16 +4472,26 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
|
||||
WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell, title,
|
||||
productMessage.toString(), modeMessage.toString(), mode);
|
||||
wgcd.open(new SessionDelegate() {
|
||||
wgcd.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogDismissed(Object dialogResult) {
|
||||
if (Boolean.TRUE.equals(dialogResult))
|
||||
finishSendProduct2(resend, result);
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (Boolean.TRUE.equals(returnValue)) {
|
||||
warngenCloseCallback(resend, result);
|
||||
}
|
||||
}
|
||||
});
|
||||
wgcd.open();
|
||||
}
|
||||
|
||||
private void finishSendProduct2(boolean resend, boolean result) {
|
||||
/**
|
||||
* This is used by finishedSendProduct as the call back to the warnGen
|
||||
* confirmaiton Dialog.
|
||||
*
|
||||
* @param resend
|
||||
* @param result
|
||||
*/
|
||||
private void warngenCloseCallback(boolean resend, boolean result) {
|
||||
|
||||
// DR14553 (make upper case in product)
|
||||
String body = textEditor.getText().toUpperCase();
|
||||
|
@ -5245,9 +5277,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
public String getAddressee() {
|
||||
return addressee;
|
||||
}
|
||||
|
||||
|
||||
public void executeCommand(ICommand command) {
|
||||
executeCommand(command, false);
|
||||
executeCommand(command, false);
|
||||
}
|
||||
|
||||
public void executeCommand(ICommand command, boolean isObsUpdated) {
|
||||
|
@ -5355,11 +5387,11 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
w, siteNode);
|
||||
}
|
||||
/*
|
||||
* DR15103 - do not clear AFOS command from the text box
|
||||
* when obs are updated
|
||||
* DR15103 - do not clear AFOS command from the text box when
|
||||
* obs are updated
|
||||
*/
|
||||
if ( !isObsUpdated ) {
|
||||
clearAfosCmdTF();
|
||||
if (!isObsUpdated) {
|
||||
clearAfosCmdTF();
|
||||
}
|
||||
clearWmoTF();
|
||||
clearAwipsIdTF();
|
||||
|
@ -6469,11 +6501,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
/*
|
||||
* DR15103 - set the flag to 'true' before executing
|
||||
* AFOS command so the AFOS command box is not cleared
|
||||
* when obs are updated
|
||||
*/
|
||||
/*
|
||||
* DR15103 - set the flag to 'true' before executing AFOS command so
|
||||
* the AFOS command box is not cleared when obs are updated
|
||||
*/
|
||||
executeCommand(command, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@ package com.raytheon.viz.texteditor.dialogs;
|
|||
import java.io.InputStream;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
@ -51,6 +49,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* 10Aug2010 2187 cjeanbap Removed warnGenFlag.
|
||||
* 10Nov2011 11552 rferrel returnvalue no longer null
|
||||
* 08/20/2012 DR 15340 D. Friedman Use callbacks for closing
|
||||
* 09/24/2012 1196 rferrel Refactored to use close callback
|
||||
* added to CaveSWTDialog.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -69,17 +69,11 @@ public class WarnGenConfirmationDlg extends CaveSWTDialog {
|
|||
private String IMAGE_TEST = "res/images/twsTest.gif";
|
||||
|
||||
private String IMAGE_PRACTICE = "res/images/twsPractice.gif";
|
||||
|
||||
public static interface SessionDelegate {
|
||||
void dialogDismissed(Object result);
|
||||
}
|
||||
|
||||
private SessionDelegate sessionDelegate;
|
||||
|
||||
protected WarnGenConfirmationDlg(Shell parentShell, String title,
|
||||
String productMessage, String modeMessage, CAVEMode mode) {
|
||||
super(parentShell, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL,
|
||||
CAVE.NONE | CAVE.DO_NOT_BLOCK);
|
||||
super(parentShell, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL, CAVE.NONE
|
||||
| CAVE.DO_NOT_BLOCK);
|
||||
|
||||
setText(title);
|
||||
|
||||
|
@ -88,13 +82,6 @@ public class WarnGenConfirmationDlg extends CaveSWTDialog {
|
|||
this.mode = mode;
|
||||
setReturnValue(Boolean.FALSE);
|
||||
}
|
||||
|
||||
public void open(SessionDelegate sessionDelegate) {
|
||||
if (sessionDelegate != null && isOpen())
|
||||
throw new RuntimeException(String.format("Dialog \"%s\" already open", getText()));
|
||||
this.sessionDelegate = sessionDelegate;
|
||||
super.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
|
@ -103,13 +90,6 @@ public class WarnGenConfirmationDlg extends CaveSWTDialog {
|
|||
createImage(mainComposite);
|
||||
createMessageLabel(mainComposite);
|
||||
createButtonRow(mainComposite);
|
||||
shell.addDisposeListener(new DisposeListener() {
|
||||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
if (sessionDelegate != null)
|
||||
sessionDelegate.dialogDismissed(getReturnValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createImage(Composite mainComposite) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.jface.dialogs.IDialogConstants;
|
|||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
@ -43,6 +44,8 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 28, 2009 2924 rjpeter Initial creation.
|
||||
* Sep 19, 2012 1196 rferrel Scroll bar now displays and limit placed
|
||||
* on the height of the dialog.
|
||||
* </pre>
|
||||
*
|
||||
* @author rjpeter
|
||||
|
@ -124,7 +127,7 @@ public class WmoIdSelectionDialog extends CaveJFACEDialog {
|
|||
label.setLayoutData(data);
|
||||
|
||||
wmoIdList = new List(top, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
|
||||
data = new GridData(SWT.BEGINNING, SWT.DEFAULT, true, false);
|
||||
data = new GridData(SWT.CENTER, SWT.FILL, false, true);
|
||||
wmoIdList.setLayoutData(data);
|
||||
|
||||
for (int i = 0; i < ttaaiiIds.size(); i++) {
|
||||
|
@ -160,4 +163,13 @@ public class WmoIdSelectionDialog extends CaveJFACEDialog {
|
|||
top.layout();
|
||||
return top;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Point getInitialSize() {
|
||||
Point point = super.getInitialSize();
|
||||
if (point.y > 500) {
|
||||
point.y = 500;
|
||||
}
|
||||
return point;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,6 @@ 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.viz.core.status.StatusConstants;
|
||||
import com.raytheon.viz.texteditor.Activator;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
||||
/**
|
||||
|
@ -53,6 +51,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 30, 2009 mfegan Initial creation
|
||||
* Sep 20, 2012 1196 rferrel Added DO_NOT_BLOCK to constructor
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -61,7 +60,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
*/
|
||||
|
||||
public class HelpRequestDlg extends CaveSWTDialog implements SelectionListener {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(HelpRequestDlg.class);
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(HelpRequestDlg.class);
|
||||
|
||||
private static final String DLG_TITLE = "Command Help";
|
||||
|
||||
/** the selection list */
|
||||
|
@ -104,7 +105,7 @@ public class HelpRequestDlg extends CaveSWTDialog implements SelectionListener {
|
|||
*/
|
||||
public HelpRequestDlg(Shell parent, EnumHelpTypes type, String token) {
|
||||
super(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.FILL,
|
||||
CAVE.PERSPECTIVE_INDEPENDENT);
|
||||
CAVE.PERSPECTIVE_INDEPENDENT | CAVE.DO_NOT_BLOCK);
|
||||
setText(DLG_TITLE);
|
||||
|
||||
this.type = type;
|
||||
|
@ -126,6 +127,7 @@ public class HelpRequestDlg extends CaveSWTDialog implements SelectionListener {
|
|||
shell.setSize(size);
|
||||
|
||||
createClientArea();
|
||||
// TODO Move to preOpened and limit the height of the dialog.
|
||||
loadCommandList();
|
||||
}
|
||||
|
||||
|
@ -146,8 +148,9 @@ public class HelpRequestDlg extends CaveSWTDialog implements SelectionListener {
|
|||
selections.add(command);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Unable to load commands file "
|
||||
+ this.type.getFileName(), e);
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to load commands file " + this.type.getFileName(),
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
|
|||
* 04/22/08 1088 chammack Added dialog event propagation fix
|
||||
* 09/13/12 1165 lvenable Update for the initial process
|
||||
* of removing the dialog blocking capability.
|
||||
* 09/20/12 1196 rferrel Changes to setBlockOnOpen.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -93,6 +94,9 @@ public class CaveJFACEDialog extends Dialog implements
|
|||
mgr.addPerspectiveDialog(this);
|
||||
}
|
||||
}
|
||||
// Eventually this will be the default but for now do not know what this
|
||||
// will break.
|
||||
// setBlockOnOpen(false);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -234,17 +238,21 @@ public class CaveJFACEDialog extends Dialog implements
|
|||
* @param blockOnOpen
|
||||
* Flag indicating if the dialog should block when opened.
|
||||
*/
|
||||
@Override
|
||||
public void setBlockOnOpen(boolean blockOnOpen) {
|
||||
/*
|
||||
* If the dialog is already opened then just return because setting the
|
||||
* block won't work. In JFACE the setBlockOnOpen needs to be set before
|
||||
* the open() call, otherwise it is ignored.
|
||||
*/
|
||||
if (isOpen()) {
|
||||
return;
|
||||
}
|
||||
// TODO investigate eventually should never allow blocking?
|
||||
// /*
|
||||
// * If the dialog is already opened then just return because setting
|
||||
// the
|
||||
// * block won't work. In JFACE the setBlockOnOpen needs to be set
|
||||
// before
|
||||
// * the open() call, otherwise it is ignored.
|
||||
// */
|
||||
// if (isOpen()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
super.setBlockOnOpen(blockOnOpen);
|
||||
blockedOnOpen = blockOnOpen;
|
||||
// blockedOnOpen = blockOnOpen;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue