1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
private void compute() {
progressBar = new Barre();
flag = true;
File tmpFile = null;
if (!((JEditArea)tabbedPane.getSelectedComponent()).isSaved()){
int n = JOptionPane.showOptionDialog(this,
"<html> Your file is unsaved. <br> Would you want to save it ?</html>",
"Warning",
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
options,
options[0]);
if (n==JOptionPane.YES_OPTION){
saveAsFile();
currentFile = ((JEditArea)tabbedPane.getSelectedComponent()).getFile();
} else { // creation du fichier temp
currentFile = ((JEditArea)tabbedPane.getSelectedComponent()).createTempfile();
}
} else {
try {
currentFile = ((JEditArea)tabbedPane.getSelectedComponent()).getFile();
} catch (NullPointerException npe) {
System.out.println("Null Pointer Exception");
}
}
(new Thread() {
public void run() {
while (flag) {
try {
File file = getCurrentFile();
TestParser testParser = new TestParser();
if (file.canRead()){
try {
testParser.process(file);
stopBar();
displayInfo("ICAr generate with sucess");
} catch (cdi.amparser.HandlerException he) {
System.out.println(he.getMessage());
he.printStackTrace();
stopBar();
displayInfo("Compilation Error");
}
catch (Exception e) {
System.out.println(e.getMessage());
stopBar();
displayInfo("Compilation Error");
}
}
} catch (NullPointerException npe) {
stopBar();
}
}
}
}).start();
try {
tmpFile.delete();
} catch (NullPointerException npe) {}
} |
Partager