Merge branch 'gsd_14.4.1' of ssh://vlab.ncep.noaa.gov:29418/AWIPS2_Dev_Baseline into master_14.4.1

Former-commit-id: ce42fe1d1c2ef5f664a522ec30fa91661b4aab3b
This commit is contained in:
Fay.Liang 2015-03-13 15:59:02 -04:00
commit 9353ac363a
3 changed files with 283 additions and 266 deletions

View file

@ -48,7 +48,7 @@ import com.raytheon.viz.ui.EditorUtil;
* ------------ ---------- ----------- --------------------------
* May 2009 # bsteffen Initial creation
* Nov 2013 # mccaslin Only one GUI dialog at a time
* Oct 2014 # mccaslin Improved error handeling
* Oct 2014 # mccaslin Improved error handeling
*
* </pre>
*
@ -56,7 +56,8 @@ import com.raytheon.viz.ui.EditorUtil;
* @version 1.0
*/
public class LapsToolsAction extends AbstractHandler {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(LapsToolsAction.class);
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(LapsToolsAction.class);
/**
* LAPS Tools dialog.
@ -65,50 +66,49 @@ public class LapsToolsAction extends AbstractHandler {
public static LAPSToolsDlg getLapsToolsDlg() {
return lapsToolsDlg;
}
}
public Object execute(ExecutionEvent arg0) throws ExecutionException {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
if (lapsToolsDlg == null) {
try {
lapsToolsDlg = new LAPSToolsDlg(shell);
lapsToolsDlg.addListener(SWT.Dispose, new Listener() {
@Override
public void handleEvent(Event event) {
lapsToolsDlg = null;
}
});
if (lapsToolsDlg.isLapsInstalled()) {
lapsToolsDlg.open();
} else {
String whatLapsIs ="LAPS data assimilation system, system requirements: " +
"\n\to LAPS v2.0 installed" +
"\n\to EDEX 'SITE' file containing LAPS domain, i.e. domain.xml" +
"\n\n\n(Sorry LAPS does not work in the ADAM implementation of AWIPS.)";
//Note: Go through the LAPS v2.0 Scripting Interface first, if you find that LAPS is not installed.
MessageBox mb = new MessageBox(EditorUtil.getActiveEditor().getSite().getShell(), SWT.ICON_WARNING | SWT.OK);
mb.setText("Cannot open LAPS V2.0 Tools GUI");
mb.setMessage(whatLapsIs);
mb.open();
lapsToolsDlg = null;
lapsToolsDlg = new LAPSToolsDlg(shell);
lapsToolsDlg.addListener(SWT.Dispose, new Listener() {
@Override
public void handleEvent(Event event) {
lapsToolsDlg = null;
}
});
//int val = mb.open();
//if (val == SWT.OK) {
// AlertViz Customization Update
//return false;
//}
if (lapsToolsDlg.isLapsInstalled()) {
lapsToolsDlg.open();
} else {
String whatLapsIs = "LAPS is not installed. ";
// Note: Go through the LAPS v2.0 Scripting Interface first,
// if you find that LAPS is not installed.
}
MessageBox mb = new MessageBox(EditorUtil.getActiveEditor()
.getSite().getShell(), SWT.ICON_ERROR | SWT.OK);
mb.setText("Cannot open the LAPS tool");
mb.setMessage(whatLapsIs);
mb.open();
lapsToolsDlg = null;
// int val = mb.open();
// if (val == SWT.OK) {
// AlertViz Customization Update
// return false;
// }
}
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error: Cannot open LAPS V2.0 Tools GUI", e);
}
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error: Cannot open LAPS V2.0 Tools GUI", e);
}
}
return null;

View file

@ -5,6 +5,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collection;
@ -27,6 +28,7 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.exception.LocalizationException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.SimulatedTime;
@ -36,8 +38,8 @@ import com.raytheon.viz.awipstools.ui.action.LapsToolsData.LapsDomain;
import com.vividsolutions.jts.geom.Envelope;
/**
* This class no longer performs all the file system, server input/output for laps.
* LAPS support scripts now conduct the localization process.
* This class no longer performs all the file system, server input/output for
* laps. LAPS support scripts now conduct the localization process.
*
* <pre>
*
@ -55,147 +57,150 @@ import com.vividsolutions.jts.geom.Envelope;
*/
public class LapsToolsIO {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(LapsToolsIO.class);
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(LapsToolsIO.class);
private static final String WHATGOTIN_FILE_FRMT = "%s/%s.wgi";
private static File fxaData;
private static File lapsLogs;
private static List<String> whatgotinFiles;
private static List<String> dataChoices;
static {
// TODO all this configuration should be customizable by the user.
// --- For what got in log files ---
// --- For what got in log files ---
if (System.getenv("FXA_DATA") == null) {
fxaData = new File("/data/fxa");
fxaData = new File("/data/fxa");
} else {
fxaData = new File(System.getenv("FXA_DATA"));
}
lapsLogs = new File(fxaData + "/laps/log/wgi");
whatgotinFiles = Arrays.asList("sfc", "wind", "lq3driver", "cloud", "temp");
dataChoices = Arrays.asList("Surface Analysis",
"Wind Analysis",
"Humidity Analysis",
"Cloud Analysis",
"Temperature Analysis");
whatgotinFiles = Arrays.asList("sfc", "wind", "lq3driver", "cloud",
"temp");
dataChoices = Arrays.asList("Surface Analysis", "Wind Analysis",
"Humidity Analysis", "Cloud Analysis", "Temperature Analysis");
}
public static Collection<String> getDataChoices() {
return dataChoices;
}
public static String getLogs(String type) throws IOException,
VizException {
public static String getLogs(String type) throws IOException, VizException {
String wgiFile = String.format(WHATGOTIN_FILE_FRMT, lapsLogs,
whatgotinFiles.get(dataChoices.indexOf(type)));
whatgotinFiles.get(dataChoices.indexOf(type)));
String resultIO = loadWhatGotInFile(wgiFile, type);
return (resultIO);
return (resultIO);
}
private static String loadWhatGotInFile(String wfile, String type)
throws IOException {
BufferedReader reader;
StringBuilder output = new StringBuilder();
File file = new File(wfile);
try {
reader = new BufferedReader(new FileReader(file));
} catch (FileNotFoundException e) {
String arg = String.format("*** Cannot find expected log file for %s." +
"\n*** File %s ....does not appear to exist.\n\n",
type, file.getAbsolutePath());
output.append(arg);
return output.toString();
}
private static String loadWhatGotInFile(String wfile, String type)
throws IOException {
BufferedReader reader;
StringBuilder output = new StringBuilder();
File file = new File(wfile);
try {
reader = new BufferedReader(new FileReader(file));
} catch (FileNotFoundException e) {
String arg = String
.format("*** Cannot find expected log file for %s."
+ "\n*** File %s ....does not appear to exist.\n\n",
type, file.getAbsolutePath());
output.append(arg);
return output.toString();
}
String line;
int lineNumber = 0;
while ((line = reader.readLine()) != null) {
String arg = String.format("%04d: %s%n", ++lineNumber, line);
output.append(arg);
output.append(arg);
}
reader.close();
return output.toString();
}
public static LapsToolsData loadData() throws IOException, VizException,
SpatialException {
LapsToolsData data = new LapsToolsData();
if(LapsToolsIO.readXmlFile(data)) {
LapsToolsIO.readCountyWarningArea(data);
if (LapsToolsIO.readXmlFile(data)) {
LapsToolsIO.readCountyWarningArea(data);
} else {
data = null;
data = null;
}
return data;
}
public static boolean readXmlFile(LapsToolsData data)
throws IOException, VizException {
public static boolean readXmlFile(LapsToolsData data) throws IOException,
VizException {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC,
LocalizationLevel.SITE);
LocalizationFile xmlLocalizationFile = pm.getLocalizationFile(lc, "LAPS/domain" +
".xml");
if(!xmlLocalizationFile.exists()) return false;
LapsDomain domain = new LapsDomain();
try {
JAXBContext jaxbContext = JAXBContext.newInstance(LapsDomain.class);
//unmarshal XML file to java object
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
domain = (LapsDomain) jaxbUnmarshaller.unmarshal(xmlLocalizationFile.getFile());
} catch (JAXBException e) {
throw new VizException("xml is unreadable: "+e.getLocalizedMessage());
}
LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC,
LocalizationLevel.SITE);
LocalizationFile xmlLocalizationFile = pm.getLocalizationFile(lc,
"LAPS/domain" + ".xml");
if (!xmlLocalizationFile.exists())
return false;
LapsDomain domain = new LapsDomain();
try {
JAXBContext jaxbContext = JAXBContext.newInstance(LapsDomain.class);
// unmarshal XML file to java object
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
domain = (LapsDomain) jaxbUnmarshaller
.unmarshal(xmlLocalizationFile.getFile());
} catch (JAXBException e) {
throw new VizException("xml is unreadable: "
+ e.getLocalizedMessage());
}
data.setNx(domain.getNx());
data.setNy(domain.getNy());
data.setNz(domain.getNz());
data.setGridSpacing(domain.getGridSpacing());
data.setGridCenterLon(domain.getGridCenLon());
data.setGridCenterLat(domain.getGridCenLat());
data.setGridCenterLat(domain.getGridCenLat());
return true;
}
public static void defaultDomain(LapsToolsData data)
throws IOException, VizException {
double distance = 111; //111 km per 1 degree
double gridSpacingDefault = 3500.;
public static void defaultDomain(LapsToolsData data) throws IOException,
VizException {
double distance = 111; // 111 km per 1 degree
double gridSpacingDefault = 3500.;
double dim = 200;
double N = dim * dim;
Envelope shapeArea = data.getValidAreaOrig();
double widthY = Math.abs(shapeArea.getHeight() * distance);
double widthX = Math.abs( (shapeArea.getWidth() * distance) * (Math.cos(shapeArea.centre().x) ) );
double widthX = Math.abs((shapeArea.getWidth() * distance)
* (Math.cos(shapeArea.centre().x)));
double aspectRatio = widthY / widthX;
double buffer = 0.5;
int nX = (int) (Math.sqrt(N/aspectRatio) + buffer);
int nX = (int) (Math.sqrt(N / aspectRatio) + buffer);
int nY = (int) ((aspectRatio * nX) + buffer);
System.out.print("LAPS Tools IO:\nheight = "+shapeArea.getHeight()+ " width = "+shapeArea.getWidth());
System.out.print("\naspect ratio = "+aspectRatio);
System.out.print("\nnX = "+nX+", nY = "+nY+"\n");
LapsDomain domain = new LapsDomain();
System.out.print("LAPS Tools IO:\nheight = " + shapeArea.getHeight()
+ " width = " + shapeArea.getWidth());
System.out.print("\naspect ratio = " + aspectRatio);
System.out.print("\nnX = " + nX + ", nY = " + nY + "\n");
LapsDomain domain = new LapsDomain();
domain.setNx(nX);
domain.setNy(nY);
domain.setNz(43);
domain.setGridSpacing(gridSpacingDefault);
domain.setGridCenLon(data.getCwaCenter().x);
domain.setGridCenLat(data.getCwaCenter().y);
domain.setGridCenLat(data.getCwaCenter().y);
data.setNx(domain.getNx());
data.setNy(domain.getNy());
data.setNz(domain.getNz());
data.setGridSpacing(domain.getGridSpacing());
data.setGridCenterLon(data.getCwaCenter().x);
data.setGridCenterLat(data.getCwaCenter().y);
data.setGridCenterLat(data.getCwaCenter().y);
}
private static void readCountyWarningArea(LapsToolsData data)
@ -209,23 +214,25 @@ public class LapsToolsIO {
return;
}
data.setCwaArea(result[0].geometry.getEnvelopeInternal());
}
}
public static String getWriteXmlQuestion() {
String date = new SimpleDateFormat("HH:mm").format(SimulatedTime
.getSystemTime().getTime());
return String.format("Are you sure you want write domain.xml?" +
"\nNote: Its %s and LAPS runs at ~20 minutes after the hour.",date);
return String
.format("Are you sure you want write domain.xml?"
+ "\nNote: Its %s and LAPS runs at ~20 minutes after the hour.",
date);
}
public static void writeXmlFile(LapsToolsData data) throws IOException,
InterruptedException, VizException {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC,
LocalizationLevel.SITE);
LocalizationFile xmlLocalizationFile = pm.getLocalizationFile(lc, "LAPS/domain-output" +
".xml");
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC,
LocalizationLevel.USER);
LocalizationFile xmlLocalizationFile = pm.getLocalizationFile(lc,
"LAPS" + IPathManager.SEPARATOR + "domain.xml");
LapsDomain lapsdomain = new LapsDomain();
lapsdomain.setNx(data.getNx());
lapsdomain.setNy(data.getNy());
@ -233,7 +240,15 @@ public class LapsToolsIO {
lapsdomain.setGridSpacing(data.getGridSpacing());
lapsdomain.setGridCenLat(data.getGridCenter().y);
lapsdomain.setGridCenLon(data.getGridCenter().x);
//marshal java object to XML file
JAXB.marshal(lapsdomain, xmlLocalizationFile.getFile());
// marshal java object to XML file
OutputStream stream;
try {
stream = xmlLocalizationFile.openOutputStream();
JAXB.marshal(lapsdomain, stream);
stream.close();
xmlLocalizationFile.save();
} catch (LocalizationException e) {
throw new VizException("Unable to save LapsDomain to xml.");
}
}
}

View file

@ -77,8 +77,9 @@ import com.raytheon.viz.ui.editor.IMultiPaneEditor;
* @version 1.0
*/
public class LAPSToolsDlg extends CaveSWTDialog {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(LAPSToolsDlg.class);
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(LAPSToolsDlg.class);
private final LapsToolsData data;
@ -109,7 +110,7 @@ public class LAPSToolsDlg extends CaveSWTDialog {
*/
private boolean isLapsInstalled = false;
/**
/**
* Flag indicating which tool is active.
*/
private boolean isDataUsedByAnalysis = true;
@ -175,9 +176,9 @@ public class LAPSToolsDlg extends CaveSWTDialog {
*/
private StackLayout stackLayout;
private MessageBox areaDialog;
private MessageBox areaDialog;
private Label areaStrLbl;
private Label areaStrLbl;
/**
* Constructor.
@ -192,16 +193,15 @@ public class LAPSToolsDlg extends CaveSWTDialog {
try {
this.data = LapsToolsIO.loadData();
if(data==null){
isLapsInstalled = false;
if (data == null) {
isLapsInstalled = false;
} else {
isLapsInstalled = true;
isLapsInstalled = true;
}
} catch (VizException e) {
MessageDialog
.openInformation(shell, "LAPS Tools GUI cannot run.",
e.getLocalizedMessage());
MessageDialog.openInformation(shell, "LAPS Tools GUI cannot run.",
e.getLocalizedMessage());
throw e;
} catch (Exception e) {
throw new VizException("Laps Dialog Failed to open", e);
@ -242,8 +242,7 @@ public class LAPSToolsDlg extends CaveSWTDialog {
createMainControls();
// create dialog with OK and cancel button and info icon
areaDialog =
new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
areaDialog = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
areaDialog.setText("Size of LAPS Domain");
}
@ -352,27 +351,27 @@ public class LAPSToolsDlg extends CaveSWTDialog {
// Create the Help menu item with a Help "dropdown" menu
Menu helpMenu = new Menu(menuBar);
helpMenuItem.setMenu(helpMenu);
// create dialog with OK and cancel button and info icon
final MessageBox dialog =
new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
final MessageBox dialog = new MessageBox(shell, SWT.ICON_INFORMATION
| SWT.OK);
dialog.setText("About LAPS details");
dialog.setMessage("For additional detailed information about LAPS Tools go to the URL" +
"\n\t http://laps.noaa.gov/awipsii/");
dialog.setMessage("For additional detailed information about LAPS Tools go to the URL"
+ "\n\t http://laps.noaa.gov/awipsii/");
// ------------------------------------------------------
// Create all the items in the Help dropdown menu
// ------------------------------------------------------
// Administration menu item
// Administration menu item
MenuItem aboutMI = new MenuItem(helpMenu, SWT.NONE);
aboutMI.setText("About LAPS...");
aboutMI.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
dialog.open();
dialog.open();
}
});
}
/**
@ -430,22 +429,24 @@ public class LAPSToolsDlg extends CaveSWTDialog {
@Override
public void widgetSelected(SelectionEvent e) {
Combo c = (Combo) e.widget;
if(c.getSelectionIndex() == 0 && c.getItem(0) == "-- Select a Type --") {
//no action
} else if(c.getSelectionIndex() != 0 && c.getItem(0) == "-- Select a Type --") {
c.remove(0);
typeAction((c.getItem(c.getSelectionIndex())));
if (c.getSelectionIndex() == 0
&& c.getItem(0) == "-- Select a Type --") {
// no action
} else if (c.getSelectionIndex() != 0
&& c.getItem(0) == "-- Select a Type --") {
c.remove(0);
typeAction((c.getItem(c.getSelectionIndex())));
} else {
typeAction((c.getItem(c.getSelectionIndex())));
typeAction((c.getItem(c.getSelectionIndex())));
}
}
});
typeCbo.select(0);
typeCbo.setToolTipText("Select one of the options to see what got into this LAPS product." );
typeCbo.setToolTipText("Select one of the options to see what got into this LAPS product.");
Label blank = new Label(controlComp, SWT.NONE);
blank.setText(" ");
Button clearBtn = new Button(controlComp, SWT.PUSH);
clearBtn.setText(" Clear ");
clearBtn.addSelectionListener(new SelectionAdapter() {
@ -455,7 +456,7 @@ public class LAPSToolsDlg extends CaveSWTDialog {
}
});
clearBtn.setToolTipText("Clear screen.");
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.widthHint = 500;
gd.heightHint = 300;
@ -491,12 +492,13 @@ public class LAPSToolsDlg extends CaveSWTDialog {
writeDomainBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
writeXmlfileAction();
writeXmlfileAction();
}
});
writeDomainBtn.setToolTipText("Write LAPS domain.xml file AND Exit.\n" +
"This step will cause scripts to run that redefine the LAPS domain.\n" +
"Next cycle of the analysis will show the change in domain made here." );
writeDomainBtn
.setToolTipText("Write LAPS domain.xml file AND Exit.\n"
+ "This step will cause scripts to run that redefine the LAPS domain.\n"
+ "Next cycle of the analysis will show the change in domain made here.");
}
/**
@ -606,36 +608,31 @@ public class LAPSToolsDlg extends CaveSWTDialog {
nxSpnr.setEnabled(true);
nxSpnr.setLayoutData(gd);
nxSpnr.addListener(SWT.Verify, new Listener() {
@Override
public void handleEvent(Event event) {
data.setNx(nxSpnr.getSelection());
areaStrLbl.setText(data.getAreaCoverageString());
}
@Override
public void handleEvent(Event event) {
data.setNx(nxSpnr.getSelection());
areaStrLbl.setText(data.getAreaCoverageString());
}
});
/*nxSpnr.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
data.setNx(nxSpnr.getSelection());
//areaStrLbl.setText(data.getAreaCoverageString());
}
@Override
public void focusLost(FocusEvent e) {
data.setNx(nxSpnr.getSelection());
areaStrLbl.setText(data.getAreaCoverageString());
}
});
nxSpnr.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
data.setNx(nxSpnr.getSelection());
areaStrLbl.setText(data.getAreaCoverageString());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
*/
/*
* nxSpnr.addFocusListener(new FocusListener() {
*
* @Override public void focusGained(FocusEvent e) {
* data.setNx(nxSpnr.getSelection());
* //areaStrLbl.setText(data.getAreaCoverageString()); }
*
* @Override public void focusLost(FocusEvent e) {
* data.setNx(nxSpnr.getSelection());
* areaStrLbl.setText(data.getAreaCoverageString()); } });
* nxSpnr.addSelectionListener(new SelectionListener() {
*
* @Override public void widgetSelected(SelectionEvent e) {
* data.setNx(nxSpnr.getSelection());
* areaStrLbl.setText(data.getAreaCoverageString()); }
*
* @Override public void widgetDefaultSelected(SelectionEvent e) { } });
*/
/*
* Ny
*/
@ -655,23 +652,21 @@ public class LAPSToolsDlg extends CaveSWTDialog {
nySpnr.setEnabled(true);
nySpnr.setLayoutData(gd);
nySpnr.addListener(SWT.Verify, new Listener() {
@Override
public void handleEvent(Event event) {
data.setNy(nySpnr.getSelection());
areaStrLbl.setText(data.getAreaCoverageString());
}
@Override
public void handleEvent(Event event) {
data.setNy(nySpnr.getSelection());
areaStrLbl.setText(data.getAreaCoverageString());
}
});
/*nySpnr.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
data.setNy(nySpnr.getSelection());
areaStrLbl.setText(data.getAreaCoverageString());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
*/
/*
* nySpnr.addSelectionListener(new SelectionListener() {
*
* @Override public void widgetSelected(SelectionEvent e) {
* data.setNy(nySpnr.getSelection());
* areaStrLbl.setText(data.getAreaCoverageString()); }
*
* @Override public void widgetDefaultSelected(SelectionEvent e) { } });
*/
/*
* Dx(m)
*/
@ -691,23 +686,21 @@ public class LAPSToolsDlg extends CaveSWTDialog {
dxmSpnr.setLayoutData(gd);
dxmSpnr.setMinimum(1000);
dxmSpnr.addListener(SWT.Verify, new Listener() {
@Override
public void handleEvent(Event event) {
data.setGridSpacing((double) dxmSpnr.getSelection());
areaStrLbl.setText(data.getAreaCoverageString());
}
@Override
public void handleEvent(Event event) {
data.setGridSpacing((double) dxmSpnr.getSelection());
areaStrLbl.setText(data.getAreaCoverageString());
}
});
/*dxmSpnr.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
data.setGridSpacing((double) dxmSpnr.getSelection());
areaStrLbl.setText(data.getAreaCoverageString());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
*/
/*
* dxmSpnr.addSelectionListener(new SelectionListener() {
*
* @Override public void widgetSelected(SelectionEvent e) {
* data.setGridSpacing((double) dxmSpnr.getSelection());
* areaStrLbl.setText(data.getAreaCoverageString()); }
*
* @Override public void widgetDefaultSelected(SelectionEvent e) { } });
*/
/*
* Vertical label
*/
@ -744,7 +737,6 @@ public class LAPSToolsDlg extends CaveSWTDialog {
gridGroup.setLayout(new GridLayout(1, false));
gridGroup.setLayoutData(gd);
gridGroup.setText(" Area of Coverage ");
/*
* Calculated Area label
@ -768,7 +760,8 @@ public class LAPSToolsDlg extends CaveSWTDialog {
Composite groupComp = new Composite(configureAnalysisComp, SWT.NONE);
groupComp.setLayout(gl);
groupComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
groupComp
.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
/*
* Settings
@ -790,8 +783,9 @@ public class LAPSToolsDlg extends CaveSWTDialog {
setDefaultDomain();
}
});
//defaultBtn.setToolTipText("Set to the default");
defaultBtn.setToolTipText("Reset all variables to values so that the LAPS domain will fully include the CWA area");
// defaultBtn.setToolTipText("Set to the default");
defaultBtn
.setToolTipText("Reset all variables to values so that the LAPS domain will fully include the CWA area");
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.widthHint = buttonWidth;
@ -804,8 +798,8 @@ public class LAPSToolsDlg extends CaveSWTDialog {
resetDomain();
}
});
resetBtn.setToolTipText("Set to the values that you started with" );
resetBtn.setToolTipText("Set to the values that you started with");
/*
* LAPS Relocator
*/
@ -826,8 +820,8 @@ public class LAPSToolsDlg extends CaveSWTDialog {
loadAction();
}
});
loadBtn.setToolTipText("Load the grid info into the display." +
"\nRelocate the domain by selecting and moving the grid center.");
loadBtn.setToolTipText("Load the grid info into the display."
+ "\nRelocate the domain by selecting and moving the grid center.");
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.widthHint = buttonWidth;
@ -841,8 +835,8 @@ public class LAPSToolsDlg extends CaveSWTDialog {
applyAction();
}
});
applyBtn.setToolTipText("Fill the selectors with new values, if you" +
"\nmoved the domain by relocating the center point." );
applyBtn.setToolTipText("Fill the selectors with new values, if you"
+ "\nmoved the domain by relocating the center point.");
}
/**
@ -880,29 +874,29 @@ public class LAPSToolsDlg extends CaveSWTDialog {
private void populateTypeCombo(Combo combo) {
combo.add("-- Select a Type --");
for (String choice : LapsToolsIO.getDataChoices()) {
for (String choice : LapsToolsIO.getDataChoices()) {
combo.add(choice);
}
}
private void typeAction(String type) {
try {
stText.append("Begin "+type+"\n");
stText.append("Begin " + type + "\n");
stText.append(LapsToolsIO.getLogs(type));
stText.append("End of "+type);
stText.append("End of " + type);
stText.append("\n__________________________________________\n\n");
stText.setTopIndex(stText.getLineCount());
} catch (Exception ex) {
statusHandler.handle(Priority.PROBLEM,
ex.getLocalizedMessage(), ex);
statusHandler
.handle(Priority.PROBLEM, ex.getLocalizedMessage(), ex);
}
}
private void populateSpinners() {
configureSpinner(cenLatSpnr, data.getGridCenter().y,
data.getValidArea().getMinY(), data.getValidArea().getMaxY());
configureSpinner(cenLonSpnr, data.getGridCenter().x,
data.getValidArea().getMinX(), data.getValidArea().getMaxX());
configureSpinner(cenLatSpnr, data.getGridCenter().y, data
.getValidArea().getMinY(), data.getValidArea().getMaxY());
configureSpinner(cenLonSpnr, data.getGridCenter().x, data
.getValidArea().getMinX(), data.getValidArea().getMaxX());
configureSpinner(nxSpnr, data.getNx());
configureSpinner(nySpnr, data.getNy());
configureSpinner(dxmSpnr, data.getGridSpacing());
@ -945,14 +939,16 @@ public class LAPSToolsDlg extends CaveSWTDialog {
private void setDefaultDomain() {
boolean ok = MessageDialog
.openConfirm(getShell(), "Confirm Exit",
.openConfirm(
getShell(),
"Confirm Exit",
"This will reset all variables to values so that the LAPS domain will fully includes the CWA area.");
if (ok) {
try {
LapsToolsIO.defaultDomain(data);
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
e.printStackTrace();
}
populateSpinners();
@ -967,23 +963,28 @@ public class LAPSToolsDlg extends CaveSWTDialog {
try {
LapsToolsIO.readXmlFile(data);
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
populateSpinners();
}
}
private void applyAction() {
if(data.getLimits()) {
System.out.print("LAPS Tools Dlg: problem with domain not covering CWA");
if (data.getLimits()) {
System.out
.print("LAPS Tools Dlg: problem with domain not covering CWA");
boolean yes = MessageDialog
.openQuestion(getShell(), "Domain Size Error",
"The size of the LAPS domain does not cover the entire CWA." +
"\nWould you like to move and recenter domain?" +
"\n\n(Answering 'No' will allow you to reedit text values, instead.)");
if(yes){ return; }
}
.openQuestion(
getShell(),
"Domain Size Error",
"The size of the LAPS domain does not cover the entire CWA."
+ "\nWould you like to move and recenter domain?"
+ "\n\n(Answering 'No' will allow you to reedit text values, instead.)");
if (yes) {
return;
}
}
cenLatSpnr.setEnabled(true);
cenLonSpnr.setEnabled(true);
nxSpnr.setEnabled(true);
@ -1011,7 +1012,7 @@ public class LAPSToolsDlg extends CaveSWTDialog {
}
}
private void loadAction() {
private void loadAction() {
cenLatSpnr.setEnabled(false);
cenLonSpnr.setEnabled(false);
nxSpnr.setEnabled(false);
@ -1023,7 +1024,7 @@ public class LAPSToolsDlg extends CaveSWTDialog {
defaultBtn.setEnabled(false);
writeDomainBtn.setEnabled(false);
readSpinners();
GenericToolsResourceData<LapsToolLayer> rd = new GenericToolsResourceData<LapsToolLayer>(
LapsToolLayer.DEFAULT_NAME, LapsToolLayer.class);
@ -1047,29 +1048,30 @@ public class LAPSToolsDlg extends CaveSWTDialog {
desc.getResourceList().add(rsc);
rsc.getCapability(EditableCapability.class).setEditable(true);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
}
private void writeXmlfileAction() {
private void writeXmlfileAction() {
if (MessageDialog.openQuestion(getShell(), "Confirmation",
LapsToolsIO.getWriteXmlQuestion())) {
try {
LapsToolsIO.writeXmlFile(data);
statusHandler.handle(Priority.INFO, //SIGNIFICANT
"Write EDEX domain.xml file. This action will initiated a LAPS Localization process.");
statusHandler
.handle(Priority.INFO, // SIGNIFICANT
"Write EDEX domain.xml file. This action will initiate a LAPS Localization process.");
close();
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
}
public boolean isLapsInstalled() {
return isLapsInstalled;
}
return isLapsInstalled;
}
}