Skip to content

Commit

Permalink
Fix UnsupportedOperationException in GUI. #1718
Browse files Browse the repository at this point in the history
  • Loading branch information
mkordas authored and romani committed Aug 17, 2015
1 parent 7e1d5d0 commit f0c7433
Showing 1 changed file with 11 additions and 8 deletions.
Expand Up @@ -27,7 +27,6 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.TooManyListenersException;

Expand Down Expand Up @@ -112,9 +111,9 @@ public void openAst(DetailAST parseTree, final Component parent) {
reloadAction.setEnabled(true);

// clear for each new file
getLinesToPosition().clear();
clearLinesToPosition();
// starts line counting at 1
getLinesToPosition().add(0);
addLineToPosition(0);
// insert the contents of the file to the text area

// clean the text area before inserting the lines of the new file
Expand All @@ -141,12 +140,12 @@ public void openFile(File file, final Component parent) {
final String[] sourceLines = text.toLinesArray();

// clear for each new file
getLinesToPosition().clear();
clearLinesToPosition();
// starts line counting at 1
getLinesToPosition().add(0);
addLineToPosition(0);
// insert the contents of the file to the text area
for (String element : sourceLines) {
getLinesToPosition().add(textArea.getText().length());
addLineToPosition(textArea.getText().length());
textArea.append(element + "\n");
}

Expand Down Expand Up @@ -199,8 +198,12 @@ private static void showErrorDialog(final Component parent, final String msg) {
SwingUtilities.invokeLater(showError);
}

public List<Integer> getLinesToPosition() {
return Collections.unmodifiableList(linesToPosition);
void addLineToPosition(int value) {
linesToPosition.add(value);
}

void clearLinesToPosition() {
linesToPosition.clear();
}

/**
Expand Down

0 comments on commit f0c7433

Please sign in to comment.