Skip to content

Commit

Permalink
show code after loading a script #510
Browse files Browse the repository at this point in the history
  • Loading branch information
walterxie committed Jul 29, 2024
1 parent 1d452d2 commit 9778bf1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class CanonicalModelPanel extends JComponent {
JTextPane pane = new JTextPane();
JScrollPane scrollPane;

CanonicalCodeBuilder codeBuilder = new CanonicalCodeBuilder();

public CanonicalModelPanel(GraphicalModelParserDictionary parserDictionary) {
this.parserDictionary = parserDictionary;

Expand Down Expand Up @@ -46,7 +48,6 @@ private void setText() {
e.printStackTrace();
}

CanonicalCodeBuilder codeBuilder = new CanonicalCodeBuilder();
String text = codeBuilder.getCode(parserDictionary);

System.out.println(text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,9 @@ public void interpretInput(String input, LPhyParserDictionary.Context context) {
}
}

try {
LineCodeColorizer codeColorizer = new LineCodeColorizer(parserDictionary, context, textPane);
// if no data{}, input is empty
codeColorizer.parse(input);
} catch (Exception e) {
LoggerUtils.log.severe("CodeColorizer failed with exception: " + e.getMessage());
e.printStackTrace(System.err);
}
addInputToPane(input, context);

//TODO below it will handle err messages for user
//TODO below it will handle err messages for user
} catch (SimulatorParsingException spe) {
LoggerUtils.log.severe("Parsing of " + context + " block failed: " + spe.getMessage());
} catch (IllegalArgumentException ex) {
Expand All @@ -311,6 +304,17 @@ public void interpretInput(String input, LPhyParserDictionary.Context context) {
}
}

public void addInputToPane(String input, LPhyParserDictionary.Context context) {
try {
LineCodeColorizer codeColorizer = new LineCodeColorizer(parserDictionary, context, textPane);
// if no data{}, input is empty
codeColorizer.parse(input);
} catch (Exception e) {
LoggerUtils.log.severe("CodeColorizer failed with exception: " + e.getMessage());
e.printStackTrace(System.err);
}
}

public void clear() {
textPane.setText("");
}
Expand Down

0 comments on commit 9778bf1

Please sign in to comment.