ASM #15007 AvnFPS: TAF Editor 'Restore From' function not working properly
Change-Id: I6cd12030643a1bbc68b6be8cfb70961e4aac7234 Former-commit-id:50f4e9a7fc
[formerlyb2260aa614
] [formerly1e0ffe6a38
[formerly 96e179b48217dab20e8e657ed8e2a74410cf56ae]] Former-commit-id:1e0ffe6a38
Former-commit-id:2c427924b8
This commit is contained in:
parent
a336ce07d3
commit
fc31ec7438
1 changed files with 88 additions and 1 deletions
|
@ -240,6 +240,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|||
* 07/23/2014 15645 zhao modified checkBasicSyntaxError()
|
||||
* May 15, 2014 3002 bgonzale Moved common taf code to com.raytheon.uf.common.dataplugin.taf.
|
||||
* 08/13/2014 3497 njensen Refactored syntax checking to prevent potential infinite loop
|
||||
* 12/02/2014 #15007 zhao Added restoreFrom() for the "Restore From..." menu option
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -1163,7 +1164,7 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
|
|||
restoreFromMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
restoreFile(null);
|
||||
restoreFrom();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2502,6 +2503,92 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* restore from a file a user selects
|
||||
*/
|
||||
private void restoreFrom() {
|
||||
|
||||
if ( tabFolder.getSelectionIndex() == VIEWER_TAB_SELECTED ) {
|
||||
tabFolder.setSelection(editorTab);
|
||||
}
|
||||
|
||||
String tempTafPath = "aviation/tmp/";
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext context = pm.getContext(LocalizationType.CAVE_STATIC, LocalizationLevel.SITE);
|
||||
String path = pm.getFile(context, tempTafPath).getAbsolutePath();
|
||||
FileDialog dlg = new FileDialog(shell, SWT.OPEN);
|
||||
dlg.setFilterPath(path);
|
||||
String filepath = dlg.open();
|
||||
|
||||
String errorMsg = null;
|
||||
|
||||
try {
|
||||
setWaitCursor(true);
|
||||
File file = new File(filepath);
|
||||
FileReader reader = new FileReader(file);
|
||||
BufferedReader input = new BufferedReader(reader);
|
||||
StringBuilder contents = new StringBuilder();
|
||||
String line = null;
|
||||
line = input.readLine();
|
||||
|
||||
if (line == null) {
|
||||
errorMsg = "empty file";
|
||||
} else {
|
||||
String[] values = line.split("\t");
|
||||
// Assume first line contains wmo, wmo site and issue time.
|
||||
if (values.length != 3) {
|
||||
errorMsg = "parse error";
|
||||
contents.append(line);
|
||||
contents.append(System.getProperty("line.separator"));
|
||||
} else {
|
||||
editorTafTabComp.setWmoIdLbl(values[0].trim());
|
||||
editorTafTabComp.setWmoSiteLbl(values[1].trim());
|
||||
editorTafTabComp.setLargeTF(values[2].trim());
|
||||
}
|
||||
}
|
||||
|
||||
while ((line = input.readLine()) != null) {
|
||||
contents.append(line);
|
||||
contents.append(System.getProperty("line.separator"));
|
||||
}
|
||||
|
||||
input.close();
|
||||
|
||||
String tafText = contents.toString();
|
||||
List<String> sitesInTaf = getSitesInTaf(tafText);
|
||||
String icao = "----";
|
||||
String bbb = "---";
|
||||
|
||||
if (errorMsg == null) {
|
||||
bbb = editorTafTabComp.getBBB();
|
||||
}
|
||||
|
||||
if (sitesInTaf.size() > 0) {
|
||||
icao = sitesInTaf.get(0);
|
||||
} else if (errorMsg == null) {
|
||||
errorMsg = "uable to determine station";
|
||||
}
|
||||
|
||||
ti.setText(icao + " " + bbb);
|
||||
editorTafTabComp.getTextEditorControl().setText(tafText);
|
||||
|
||||
if (editorTafTabComp.isTafSent()) {
|
||||
editorTafTabComp.updateTafSent(false);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
setMessageStatusError("File " + filepath + " not found.");
|
||||
} catch (IOException e) {
|
||||
setMessageStatusError("An IOException occured while opening file " + filepath);
|
||||
} finally {
|
||||
if (errorMsg != null) {
|
||||
setMessageStatusError("File " + filepath + ": " + errorMsg);
|
||||
} else {
|
||||
setMessageStatusOK("File " + filepath + " opened successfully.");
|
||||
}
|
||||
setWaitCursor(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore a TAF bulletin from a tmp file.
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue