diff options
Diffstat (limited to 'src/cuchaz/enigma/gui/Gui.java')
| -rw-r--r-- | src/cuchaz/enigma/gui/Gui.java | 50 |
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; | |||
| 16 | import java.awt.Dimension; | 16 | import java.awt.Dimension; |
| 17 | import java.awt.FlowLayout; | 17 | import java.awt.FlowLayout; |
| 18 | import java.awt.GridLayout; | 18 | import java.awt.GridLayout; |
| 19 | import java.awt.Rectangle; | ||
| 20 | import java.awt.event.ActionEvent; | 19 | import java.awt.event.ActionEvent; |
| 21 | import java.awt.event.ActionListener; | 20 | import java.awt.event.ActionListener; |
| 22 | import java.awt.event.InputEvent; | 21 | import java.awt.event.InputEvent; |
| @@ -54,8 +53,6 @@ import javax.swing.JTextField; | |||
| 54 | import javax.swing.JTree; | 53 | import javax.swing.JTree; |
| 55 | import javax.swing.KeyStroke; | 54 | import javax.swing.KeyStroke; |
| 56 | import javax.swing.ListSelectionModel; | 55 | import javax.swing.ListSelectionModel; |
| 57 | import javax.swing.SwingUtilities; | ||
| 58 | import javax.swing.Timer; | ||
| 59 | import javax.swing.WindowConstants; | 56 | import javax.swing.WindowConstants; |
| 60 | import javax.swing.event.CaretEvent; | 57 | import javax.swing.event.CaretEvent; |
| 61 | import javax.swing.event.CaretListener; | 58 | import 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 | ||