Просмотр исходного кода

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 лет назад
Родитель
Сommit
4666264e6b

+ 7
- 5
src/com/dmdirc/addons/ui_swing/components/SwingInputHandler.java Просмотреть файл

128
     /** {@inheritDoc} */
128
     /** {@inheritDoc} */
129
     @Override
129
     @Override
130
     protected void addTabHandler() {
130
     protected void addTabHandler() {
131
-        JTextComponent localTarget = null;
131
+        final JTextComponent localTarget;
132
         if (target instanceof JTextComponent) {
132
         if (target instanceof JTextComponent) {
133
             localTarget = (JTextComponent) target;
133
             localTarget = (JTextComponent) target;
134
         } else if (target instanceof SwingInputField) {
134
         } else if (target instanceof SwingInputField) {
135
             localTarget = ((SwingInputField) target).getTextField();
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
              * A version number for this class. It should be changed whenever the class
142
              * A version number for this class. It should be changed whenever the class
151
                     /** {@inheritDoc} */
153
                     /** {@inheritDoc} */
152
                     @Override
154
                     @Override
153
                     protected Object doInBackground() throws Exception {
155
                     protected Object doInBackground() throws Exception {
154
-                        ((JTextField) e.getSource()).setEditable(false);
156
+                        localTarget.setEditable(false);
155
                         doTabCompletion();
157
                         doTabCompletion();
156
                         return null;
158
                         return null;
157
                     }
159
                     }
159
                     /** {@inheritDoc} */
161
                     /** {@inheritDoc} */
160
                     @Override
162
                     @Override
161
                     protected void done() {
163
                     protected void done() {
162
-                        ((JTextField) e.getSource()).setEditable(true);
164
+                        localTarget.setEditable(true);
163
                     }
165
                     }
164
                 }.execute();
166
                 }.execute();
165
             }
167
             }
166
         });
168
         });
167
         localTarget.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
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
     /** {@inheritDoc} */
173
     /** {@inheritDoc} */

+ 4
- 0
src/com/dmdirc/addons/ui_swing/components/TextPaneInputField.java Просмотреть файл

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

+ 4
- 2
src/com/dmdirc/addons/ui_swing/components/TopicBar.java Просмотреть файл

139
                 getIcon("close"), IconManager.getIconManager().
139
                 getIcon("close"), IconManager.getIconManager().
140
                 getIcon("close-active"));
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
         final JScrollPane sp = new JScrollPane(topicText);
147
         final JScrollPane sp = new JScrollPane(topicText);
146
         sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
148
         sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

+ 5
- 3
src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/TopicDisplayPane.java Просмотреть файл

101
         topicText.setWrapStyleWord(true);
101
         topicText.setWrapStyleWord(true);
102
         topicText.setRows(5);
102
         topicText.setRows(5);
103
         topicText.setColumns(30);
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
                     new NoNewlinesPasteAction());
110
                     new NoNewlinesPasteAction());
109
         topicText.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 
111
         topicText.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 
110
                 0), new TopicEnterAction(parent));
112
                 0), new TopicEnterAction(parent));

Загрузка…
Отмена
Сохранить