summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/gui/Gui.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuchaz/enigma/gui/Gui.java')
-rw-r--r--src/cuchaz/enigma/gui/Gui.java50
1 files changed, 1 insertions, 49 deletions
diff --git a/src/cuchaz/enigma/gui/Gui.java b/src/cuchaz/enigma/gui/Gui.java
index a214243..38a6ee9 100644
--- a/src/cuchaz/enigma/gui/Gui.java
+++ b/src/cuchaz/enigma/gui/Gui.java
@@ -16,7 +16,6 @@ import java.awt.Container;
16import java.awt.Dimension; 16import java.awt.Dimension;
17import java.awt.FlowLayout; 17import java.awt.FlowLayout;
18import java.awt.GridLayout; 18import java.awt.GridLayout;
19import java.awt.Rectangle;
20import java.awt.event.ActionEvent; 19import java.awt.event.ActionEvent;
21import java.awt.event.ActionListener; 20import java.awt.event.ActionListener;
22import java.awt.event.InputEvent; 21import java.awt.event.InputEvent;
@@ -54,8 +53,6 @@ import javax.swing.JTextField;
54import javax.swing.JTree; 53import javax.swing.JTree;
55import javax.swing.KeyStroke; 54import javax.swing.KeyStroke;
56import javax.swing.ListSelectionModel; 55import javax.swing.ListSelectionModel;
57import javax.swing.SwingUtilities;
58import javax.swing.Timer;
59import javax.swing.WindowConstants; 56import javax.swing.WindowConstants;
60import javax.swing.event.CaretEvent; 57import javax.swing.event.CaretEvent;
61import javax.swing.event.CaretListener; 58import javax.swing.event.CaretListener;
@@ -740,52 +737,7 @@ public class Gui {
740 if (token == null) { 737 if (token == null) {
741 throw new IllegalArgumentException("Token cannot be null!"); 738 throw new IllegalArgumentException("Token cannot be null!");
742 } 739 }
743 740 GuiTricks.navigateToToken(m_editor, token, m_selectionHighlightPainter);
744 // set the caret position to the token
745 m_editor.setCaretPosition(token.start);
746 m_editor.grabFocus();
747
748 try {
749 // make sure the token is visible in the scroll window
750 Rectangle start = m_editor.modelToView(token.start);
751 Rectangle end = m_editor.modelToView(token.end);
752 final Rectangle show = start.union(end);
753 show.grow(start.width * 10, start.height * 6);
754 SwingUtilities.invokeLater(new Runnable() {
755 @Override
756 public void run() {
757 m_editor.scrollRectToVisible(show);
758 }
759 });
760 } catch (BadLocationException ex) {
761 throw new Error(ex);
762 }
763
764 // highlight the token momentarily
765 final Timer timer = new Timer(200, new ActionListener() {
766 private int m_counter = 0;
767 private Object m_highlight = null;
768
769 @Override
770 public void actionPerformed(ActionEvent event) {
771 if (m_counter % 2 == 0) {
772 try {
773 m_highlight = m_editor.getHighlighter().addHighlight(token.start, token.end, m_selectionHighlightPainter);
774 } catch (BadLocationException ex) {
775 // don't care
776 }
777 } else if (m_highlight != null) {
778 m_editor.getHighlighter().removeHighlight(m_highlight);
779 }
780
781 if (m_counter++ > 6) {
782 Timer timer = (Timer)event.getSource();
783 timer.stop();
784 }
785 }
786 });
787 timer.start();
788
789 redraw(); 741 redraw();
790 } 742 }
791 743