Skip to content

Commit

Permalink
Merge pull request #51 from Squareys/scripteditor-cleanup
Browse files Browse the repository at this point in the history
Overhaul the script editor with cleaned up style, javadoc, and better separation of concerns via decoupling the TextEditor and EditorPane.
  • Loading branch information
hinerm committed Aug 20, 2015
2 parents 1225999 + de83ff0 commit ff874bd
Show file tree
Hide file tree
Showing 15 changed files with 1,675 additions and 1,240 deletions.
3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
<dependency>
<groupId>org.scijava</groupId>
<artifactId>scijava-ui-swing</artifactId>
<version>0.6.0</version>
</dependency>
<dependency>
<groupId>org.scijava</groupId>
Expand All @@ -85,7 +84,7 @@
<dependency>
<groupId>com.fifesoft</groupId>
<artifactId>rsyntaxtextarea</artifactId>
<version>2.5.6</version>
<version>2.5.7</version>
</dependency>
<dependency>
<groupId>com.miglayout</groupId>
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/net/imagej/ui/swing/script/Bookmark.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

package net.imagej.ui.swing.script;

import javax.swing.text.BadLocationException;

import org.fife.ui.rtextarea.GutterIconInfo;

/**
* A "bookmark" is a stored location (line, file) in the text editor.
*
* @author Johannes Schindelin
* @author Jonathan Hale
*/
public class Bookmark {

TextEditorTab tab;
GutterIconInfo info;

public Bookmark(final TextEditorTab tab, final GutterIconInfo info) {
this.tab = tab;
this.info = info;
}

public int getLineNumber() {
try {
return tab.editorPane.getLineOfOffset(info.getMarkedOffset());
}
catch (final BadLocationException e) {
return -1;
}
}

public void setCaret() {
tab.requestFocus();
tab.editorPane.setCaretPosition(info.getMarkedOffset());
}

@Override
public String toString() {
return "Line " + (getLineNumber() + 1) + " (" + tab.editorPane.getFileName() + ")";
}
}
4 changes: 2 additions & 2 deletions src/main/java/net/imagej/ui/swing/script/BookmarkDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class BookmarkDialog extends JDialog implements ActionListener {
JList list;
JButton okay, cancel;

public BookmarkDialog(final Frame owner, final Vector<EditorPane.Bookmark> bookmarks) {
public BookmarkDialog(final Frame owner, final Vector<Bookmark> bookmarks) {
super(owner, "Bookmarks", true);

getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
Expand Down Expand Up @@ -105,7 +105,7 @@ else if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
}

public boolean jumpToSelectedBookmark() {
EditorPane.Bookmark bookmark = (EditorPane.Bookmark)list.getSelectedValue();
Bookmark bookmark = (Bookmark)list.getSelectedValue();
if (bookmark == null)
return false;
bookmark.setCaret();
Expand Down
Loading

0 comments on commit ff874bd

Please sign in to comment.