use of org.antlr.xjlib.appkit.utils.XJAlert in project antlrworks by antlr.
the class CodeGenerate method generateInThreadDidTerminate.
public void generateInThreadDidTerminate() {
progress.close();
if (generateError != null) {
XJAlert.display(window.getJavaContainer(), "Error", "Cannot generate the grammar because:\n" + generateError);
if (delegate != null) {
delegate.codeGenerateDidCompleteWithError(generateError);
}
} else {
if (delegate == null || delegate.codeGenerateDisplaySuccess()) {
if (AWPrefs.isAlertGenerateCodeSuccess()) {
XJAlert alert = XJAlert.createInstance();
alert.setDisplayDoNotShowAgainButton(true);
alert.showSimple(window.getJavaContainer(), "Success", "The grammar has been successfully generated in path:\n" + getOutputPath());
AWPrefs.setAlertGenerateCodeSuccess(!alert.isDoNotShowAgain());
}
}
if (delegate != null) {
delegate.codeGenerateDidComplete();
}
}
}
use of org.antlr.xjlib.appkit.utils.XJAlert in project antlrworks by antlr.
the class InterpreterTab method createRunButton.
public JButton createRunButton() {
JButton button = XJRollOverButton.createMediumButton(IconManager.shared().getIconRun());
button.setToolTipText("Run");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (AWPrefs.isAlertInterpreterLimitation()) {
XJAlert alert = XJAlert.createInstance();
alert.setDisplayDoNotShowAgainButton(true);
alert.showSimple(getContainer(), "Warning", "The interpreterTab does not run actions nor evaluate syntactic predicates." + "\nUse the debugger if you want to use these ANTLR features.");
AWPrefs.setAlertInterpreterLimitation(!alert.isDoNotShowAgain());
}
StatisticsAW.shared().recordEvent(StatisticsAW.EVENT_INTERPRETER_BUTTON);
interpret();
}
});
return button;
}
use of org.antlr.xjlib.appkit.utils.XJAlert in project antlrworks by antlr.
the class GrammarWindow method componentDocumentContentChanged.
public void componentDocumentContentChanged() {
// Called when the document associated file has changed on the disk
if (!isFileExists()) {
XJAlert.display(getJavaContainer(), "Warning", "The document cannot be found on the disk anymore.");
return;
}
if (AWPrefs.isAlertFileChangesDetected()) {
XJAlert alert = XJAlert.createInstance();
alert.setDisplayDoNotShowAgainButton(true);
int result = alert.showCustom(getJavaContainer(), "File Changes", "The file \"" + getFileName() + "\" changed on the disk. Do you want to reload it?", "Cancel", "Reload", 1, 0);
AWPrefs.setAlertFileChangesDetected(!alert.isDoNotShowAgain());
if (result == 0) {
return;
}
}
int oldCursorPosition = getCaretPosition();
try {
getDocument().reload();
} catch (Exception e) {
e.printStackTrace();
XJAlert.display(getJavaContainer(), "Error Reloading Document", "An error occurred when reloading the document:\n" + e.toString());
}
grammarChanged();
setCaretPosition(Math.min(oldCursorPosition, getText().length()));
}
use of org.antlr.xjlib.appkit.utils.XJAlert in project antlrworks by antlr.
the class STWindow method componentDocumentContentChanged.
public void componentDocumentContentChanged() {
// Called when the document associated file has changed on the disk
if (!isFileExists()) {
XJAlert.display(getJavaContainer(), "Warning", "The document cannot be found on the disk anymore.");
return;
}
if (AWPrefs.isAlertFileChangesDetected()) {
XJAlert alert = XJAlert.createInstance();
alert.setDisplayDoNotShowAgainButton(true);
int result = alert.showCustom(getJavaContainer(), "File Changes", "The file \"" + getFileName() + "\" changed on the disk. Do you want to reload it?", "Cancel", "Reload", 1, 0);
AWPrefs.setAlertFileChangesDetected(!alert.isDoNotShowAgain());
if (result == 0) {
return;
}
}
int oldCursorPosition = textEditor.getCaretPosition();
try {
getDocument().reload();
} catch (Exception e) {
e.printStackTrace();
XJAlert.display(getJavaContainer(), "Error Reloading Document", "An error occurred when reloading the document:\n" + e.toString());
}
textEditor.setCaretPosition(Math.min(oldCursorPosition, getText().length()), true, AWPrefs.getSmoothScrolling());
}
use of org.antlr.xjlib.appkit.utils.XJAlert in project antlrworks by antlr.
the class GrammarMenu method checkGrammarDidEnd.
public void checkGrammarDidEnd(CheckGrammar source, GrammarResult result) {
checkGrammar.close();
checkGrammar = null;
checkingGrammar = false;
window.hideProgress();
if (result.isSuccess()) {
if (AWPrefs.isAlertCheckGrammarSuccess()) {
XJAlert alert = XJAlert.createInstance();
alert.setDisplayDoNotShowAgainButton(true);
alert.showSimple(window.getJavaContainer(), "Success", "Check Grammar succeeded.");
AWPrefs.setAlertCheckGrammarSuccess(!alert.isDoNotShowAgain());
}
} else {
if (result.getErrorCount() > 0) {
XJAlert.display(window.getJavaContainer(), "Error", "Check Grammar reported some errors:\n" + result.getFirstErrorMessage() + "\nConsult the console for more information.");
} else if (result.getWarningCount() > 0) {
XJAlert.display(window.getJavaContainer(), "Warning", "Check Grammar reported some warnings:\n" + result.getFirstWarningMessage() + "\nConsult the console for more information.");
} else {
XJAlert.display(window.getJavaContainer(), "Error", "Check Grammar reported some errors.\nConsult the console for more information.");
}
}
}
Aggregations