Browse Source

jump to error when not autoparsing

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@816 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Mark Kattenbelt 17 years ago
parent
commit
6be8adf130
  1. 2
      prism/src/userinterface/model/GUIModelEditor.java
  2. 6
      prism/src/userinterface/model/GUIMultiModelHandler.java
  3. 40
      prism/src/userinterface/model/GUITextModelEditor.java
  4. 2
      prism/src/userinterface/model/computation/BuildModelThread.java
  5. 2
      prism/src/userinterface/model/computation/ParseModelThread.java

2
prism/src/userinterface/model/GUIModelEditor.java

@ -50,7 +50,7 @@ public abstract class GUIModelEditor extends JPanel
public abstract void selectAll(); public abstract void selectAll();
public void modelParseFailed(PrismLangException parserError) {}
public void modelParseFailed(PrismLangException parserError, boolean background) {}
public void modelParseSuccessful() {} public void modelParseSuccessful() {}
} }

6
prism/src/userinterface/model/GUIMultiModelHandler.java

@ -795,11 +795,11 @@ public class GUIMultiModelHandler extends JPanel
theModel.notifyEventListeners(new GUIModelEvent(GUIModelEvent.MODEL_PARSED, parsedModel)); theModel.notifyEventListeners(new GUIModelEvent(GUIModelEvent.MODEL_PARSED, parsedModel));
} }
public synchronized void modelParseFailed(PrismLangException parserError)
public synchronized void modelParseFailed(PrismLangException parserError, boolean background)
{ {
lastError = parserError.getMessage(); lastError = parserError.getMessage();
editor.modelParseFailed(parserError);
editor.modelParseFailed(parserError, background);
tree.stopParsing(); tree.stopParsing();
parsing = false; parsing = false;
@ -903,7 +903,7 @@ public class GUIMultiModelHandler extends JPanel
public synchronized void modelBuildFailed(PrismException e) public synchronized void modelBuildFailed(PrismException e)
{ {
if (e != null && e instanceof PrismLangException) editor.modelParseFailed((PrismLangException)e);
if (e != null && e instanceof PrismLangException) editor.modelParseFailed((PrismLangException)e, false);
if(exportAfterReceiveBuildNotification) if(exportAfterReceiveBuildNotification)
{ {

40
prism/src/userinterface/model/GUITextModelEditor.java

@ -297,9 +297,9 @@ public class GUITextModelEditor extends GUIModelEditor implements DocumentListen
// search and replace action // search and replace action
actionSearch = new AbstractAction() { actionSearch = new AbstractAction() {
public void actionPerformed(ActionEvent ae) { public void actionPerformed(ActionEvent ae) {
/*
// System.out.println("search button pressed"); // System.out.println("search button pressed");
/* if (GUIMultiModelHandler.isDoingSearch()) {
if (GUIMultiModelHandler.isDoingSearch()) {
} else { } else {
try { try {
@ -309,13 +309,14 @@ public class GUITextModelEditor extends GUIModelEditor implements DocumentListen
GUIPrism.getGUI().getMultiLogger().logMessage(prism.log.PrismLogLevel.PRISM_ERROR, GUIPrism.getGUI().getMultiLogger().logMessage(prism.log.PrismLogLevel.PRISM_ERROR,
pnfe.getMessage()); pnfe.getMessage());
} }
}*/
}
*/
} }
}; };
actionSearch.putValue(Action.LONG_DESCRIPTION, "Opens a find and replace dialog."); actionSearch.putValue(Action.LONG_DESCRIPTION, "Opens a find and replace dialog.");
//actionSearch.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("find.png")); //actionSearch.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("find.png"));
actionSearch.putValue(Action.NAME, "Find/Replace"); actionSearch.putValue(Action.NAME, "Find/Replace");
//actionSearch.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK));
//actionSearch.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_MASK));
insertDTMC = new AbstractAction() { insertDTMC = new AbstractAction() {
public void actionPerformed(ActionEvent ae) { public void actionPerformed(ActionEvent ae) {
@ -664,6 +665,21 @@ public class GUITextModelEditor extends GUIModelEditor implements DocumentListen
} }
public void jumpToError()
{
if (parseError != null && parseError.hasLineNumbers() )
{
try
{
editor.setCaretPosition(computeDocumentOffset(parseError.getBeginLine(), parseError.getBeginColumn()));
}
catch (BadLocationException e)
{
}
}
}
public void refreshErrorDisplay() public void refreshErrorDisplay()
{ {
if (parseErrorHighlightKey != null) if (parseErrorHighlightKey != null)
@ -676,12 +692,17 @@ public class GUITextModelEditor extends GUIModelEditor implements DocumentListen
{ {
String error = parseError.getMessage(); String error = parseError.getMessage();
for (int line = parseError.getBeginLine();
// Just the first line.
errorLines.put(parseError.getBeginLine(), error);
// If error spans multiple lines, this code will put
// an error in every line of the gutter.
/*for (int line = parseError.getBeginLine();
line <= parseError.getEndLine(); line <= parseError.getEndLine();
line++) line++)
{ {
errorLines.put(line, error); errorLines.put(line, error);
}
}*/
} }
gutter.setParseErrors(errorLines); gutter.setParseErrors(errorLines);
@ -700,9 +721,7 @@ public class GUITextModelEditor extends GUIModelEditor implements DocumentListen
{ {
} }
} }
} }
public int computeDocumentOffset(int line, int column) throws BadLocationException public int computeDocumentOffset(int line, int column) throws BadLocationException
@ -737,16 +756,19 @@ public class GUITextModelEditor extends GUIModelEditor implements DocumentListen
return beginLineOffset+documentChar; return beginLineOffset+documentChar;
} }
public void modelParseFailed(PrismLangException parserError)
public void modelParseFailed(PrismLangException parserError, boolean background)
{ {
this.parseError = parserError; this.parseError = parserError;
refreshErrorDisplay(); refreshErrorDisplay();
if (!background)
jumpToError();
} }
@Override @Override
public void modelParseSuccessful() public void modelParseSuccessful()
{ {
this.parseError = null; this.parseError = null;
// get rid of any error highlighting
refreshErrorDisplay(); refreshErrorDisplay();
} }

2
prism/src/userinterface/model/computation/BuildModelThread.java

@ -109,7 +109,7 @@ public class BuildModelThread extends GUIComputationThread
plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_ERROR, plug)); plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_ERROR, plug));
plug.setTaskBarText("Parsing model... error."); plug.setTaskBarText("Parsing model... error.");
error(parseError.getMessage()); error(parseError.getMessage());
handler.modelParseFailed(parseError);
handler.modelParseFailed(parseError, false);
handler.modelBuildFailed(null); handler.modelBuildFailed(null);
}}); }});
return; return;

2
prism/src/userinterface/model/computation/ParseModelThread.java

@ -97,7 +97,7 @@ public class ParseModelThread extends GUIComputationThread
plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_ERROR, plug)); plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_ERROR, plug));
if(!background) plug.setTaskBarText("Parsing model... error."); if(!background) plug.setTaskBarText("Parsing model... error.");
if(!background) error(errMsg); if(!background) error(errMsg);
handler.modelParseFailed(parseError);
handler.modelParseFailed(parseError, background);
} }
}); });
return; return;

Loading…
Cancel
Save