Przeglądaj źródła

Tab completion works in topic bar and topic tab in CSD

Change-Id: Ia8a8173f67a7d9f423407f82b2a3c776e87b077e
Reviewed-on: http://gerrit.dmdirc.com/323
Reviewed-by: Gregory Holmes <greboid@dmdirc.com>
Tested-by: Gregory Holmes <greboid@dmdirc.com>
tags/0.6.3
Gregory Holmes 14 lat temu
rodzic
commit
4666264e6b

+ 7
- 5
src/com/dmdirc/addons/ui_swing/components/SwingInputHandler.java Wyświetl plik

@@ -128,13 +128,15 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
128 128
     /** {@inheritDoc} */
129 129
     @Override
130 130
     protected void addTabHandler() {
131
-        JTextComponent localTarget = null;
131
+        final JTextComponent localTarget;
132 132
         if (target instanceof JTextComponent) {
133 133
             localTarget = (JTextComponent) target;
134 134
         } else if (target instanceof SwingInputField) {
135 135
             localTarget = ((SwingInputField) target).getTextField();
136
+        } else {
137
+            throw new IllegalArgumentException("Unknown target");
136 138
         }
137
-        localTarget.getActionMap().put("tabPressed", new AbstractAction() {
139
+        localTarget.getActionMap().put("insert-tab", new AbstractAction() {
138 140
 
139 141
             /**
140 142
              * A version number for this class. It should be changed whenever the class
@@ -151,7 +153,7 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
151 153
                     /** {@inheritDoc} */
152 154
                     @Override
153 155
                     protected Object doInBackground() throws Exception {
154
-                        ((JTextField) e.getSource()).setEditable(false);
156
+                        localTarget.setEditable(false);
155 157
                         doTabCompletion();
156 158
                         return null;
157 159
                     }
@@ -159,13 +161,13 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
159 161
                     /** {@inheritDoc} */
160 162
                     @Override
161 163
                     protected void done() {
162
-                        ((JTextField) e.getSource()).setEditable(true);
164
+                        localTarget.setEditable(true);
163 165
                     }
164 166
                 }.execute();
165 167
             }
166 168
         });
167 169
         localTarget.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
168
-                put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "tabPressed");
170
+                put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "insert-tab");
169 171
     }
170 172
 
171 173
     /** {@inheritDoc} */

+ 4
- 0
src/com/dmdirc/addons/ui_swing/components/TextPaneInputField.java Wyświetl plik

@@ -47,6 +47,7 @@ public class TextPaneInputField extends JEditorPane implements InputField {
47 47
     /** Colour picker. */
48 48
     protected ColourPickerDialog colourPicker;
49 49
 
50
+    /** {@inheritDoc} */
50 51
     @Override
51 52
     public void showColourPicker(boolean irc, boolean hex) {
52 53
         if (IdentityManager.getGlobalConfig().getOptionBool("general",
@@ -73,6 +74,7 @@ public class TextPaneInputField extends JEditorPane implements InputField {
73 74
         }
74 75
     }
75 76
 
77
+    /** {@inheritDoc} */
76 78
     @Override
77 79
     public void hideColourPicker() {
78 80
         if (colourPicker != null) {
@@ -81,11 +83,13 @@ public class TextPaneInputField extends JEditorPane implements InputField {
81 83
         }
82 84
     }
83 85
 
86
+    /** {@inheritDoc} */
84 87
     @Override
85 88
     public void addActionListener(ActionListener listener) {
86 89
         //Ignore
87 90
     }
88 91
 
92
+    /** {@inheritDoc} */
89 93
     @Override
90 94
     public void removeActionListener(ActionListener listener) {
91 95
         //Ignore

+ 4
- 2
src/com/dmdirc/addons/ui_swing/components/TopicBar.java Wyświetl plik

@@ -139,8 +139,10 @@ public class TopicBar extends JComponent implements ActionListener,
139 139
                 getIcon("close"), IconManager.getIconManager().
140 140
                 getIcon("close-active"));
141 141
 
142
-        new SwingInputHandler(topicText, channelFrame.getCommandParser(),
143
-                channelFrame).setTypes(false, false, true, false);
142
+        final SwingInputHandler handler = new SwingInputHandler(topicText,
143
+                channelFrame.getCommandParser(), channelFrame);
144
+        handler.setTypes(true, false, true, false);
145
+        handler.setTabCompleter(channel.getTabCompleter());
144 146
 
145 147
         final JScrollPane sp = new JScrollPane(topicText);
146 148
         sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

+ 5
- 3
src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/TopicDisplayPane.java Wyświetl plik

@@ -101,10 +101,12 @@ public class TopicDisplayPane extends JPanel implements DocumentListener {
101 101
         topicText.setWrapStyleWord(true);
102 102
         topicText.setRows(5);
103 103
         topicText.setColumns(30);
104
-        new SwingInputHandler(topicText, channel.getFrame().getCommandParser(),
105
-                channel.getFrame()).setTypes(false, false, true, false);
104
+        final SwingInputHandler handler = new SwingInputHandler(topicText,
105
+                channel.getFrame().getCommandParser(), channel.getFrame());
106
+        handler.setTypes(true, false, true, false);
107
+        handler.setTabCompleter(channel.getTabCompleter());
106 108
 
107
-        topicText.getActionMap().put("paste-from-clipboard",
109
+        topicText.getActionMap().put("paste-from-clipboard",    
108 110
                     new NoNewlinesPasteAction());
109 111
         topicText.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 
110 112
                 0), new TopicEnterAction(parent));

Ładowanie…
Anuluj
Zapisz