improved error message if hdl code parsing failed, closes #293

This commit is contained in:
hneemann 2019-07-29 10:02:18 +02:00
parent bde8a3bc8f
commit 0a3dac09cf
3 changed files with 17 additions and 4 deletions

View File

@ -797,7 +797,8 @@ public final class EditorFactory {
if (app != null) {
try {
getAttributeDialog().storeEditedValues();
if (app.ensureConsistency(elementAttributes))
final boolean consistent = app.ensureConsistency(elementAttributes);
if (consistent)
getAttributeDialog().updateEditedValues();
PortDefinition ins = new PortDefinition(elementAttributes.get(Keys.EXTERNAL_INPUTS));
@ -807,10 +808,11 @@ public final class EditorFactory {
try {
String message = app.checkCode(label, code, ins, outs);
if (message != null && !message.isEmpty())
new ErrorMessage(Lang.get("msg_checkResult") + "\n\n" + message).show(getAttributeDialog());
if (message != null && !message.isEmpty()) {
createError(consistent, Lang.get("msg_checkResult") + "\n\n" + message).show(getAttributeDialog());
}
} catch (IOException e) {
new ErrorMessage(Lang.get("msg_checkResult")).addCause(e).show(getAttributeDialog());
createError(consistent, Lang.get("msg_checkResult")).addCause(e).show(getAttributeDialog());
}
} catch (EditorParseException e) {
e.printStackTrace();
@ -818,6 +820,13 @@ public final class EditorFactory {
}
}
}
private ErrorMessage createError(boolean consistent, String message) {
if (!consistent)
message = Lang.get("msg_codeNotConsistent") + "\n\n" + message;
return new ErrorMessage(message);
}
}.setToolTip(Lang.get("btn_checkCode_tt")).createJButton();
combo.addActionListener(new AbstractAction() {
@Override

View File

@ -1689,6 +1689,8 @@ Soll dennoch exportiert werden?</string>
<string name="btn_checkCode_tt">Startet die Anwendung um zu prüfen, ob der eingegebene Code korrekt ist. Falls das
nicht der Fall ist, wird die Fehlermeldung der externen Anwendung angezeigt. Wenn es möglich ist, werden zudem
die Eingangs- und Ausgangsdefinitionen an den aktuellen Code angepasst.</string>
<string name="msg_codeNotConsistent">Ein- und Ausgängsdefinitionen konnten nicht automatisch erzeugt werden.
Bitte prüfen Sie die Einstellungen!</string>
<string name="msg_applicationFileNotFound">Ausführbare Datei "{0}" nicht gefunden!</string>
<string name="msg_enterText">Text eingeben!</string>
<string name="btn_startATMISP">Starte ATMISP</string>

View File

@ -1669,6 +1669,8 @@
<string name="btn_checkCode_tt">Starts the application to check if the entered code is correct.
If this is not the case, the error message of the external application is displayed.
If possible, the input and output definitions are also adapted to the current code.</string>
<string name="msg_codeNotConsistent">Input and output definitions could not be created automatically.
Please check the settings!</string>
<string name="msg_applicationFileNotFound">Executable file "{0}" not found!</string>
<string name="msg_enterText">Enter Text!</string>