Pārlūkot izejas kodu

Fixes issue 3841

Add support for channels and nicknames to the URL handling capabilities
of the topic bar.

Change-Id: I1137418de6d23d369a0719589ed6e3b809549a03
Reviewed-on: http://gerrit.dmdirc.com/955
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.4
Greboid 14 gadus atpakaļ
vecāks
revīzija
62d8629b43

+ 16
- 1
src/com/dmdirc/addons/ui_swing/components/TopicBar.java Parādīt failu

@@ -280,7 +280,22 @@ public class TopicBar extends JComponent implements ActionListener,
280 280
     @Override
281 281
     public void hyperlinkUpdate(final HyperlinkEvent e) {
282 282
         if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
283
-            URLHandler.getURLHander().launchApp(e.getDescription());
283
+            final String url = e.getDescription();
284
+            if (url == null) {
285
+                return;
286
+            }
287
+            if (url.startsWith("#")) {
288
+                channel.getServer().join(url);
289
+            } else if (url.contains("://")) {
290
+                URLHandler.getURLHander().launchApp(e.getDescription());
291
+            } else {
292
+                if (channel.getServer().hasQuery(url)) {
293
+                    channel.getServer().getQuery(url).activateFrame();
294
+                } else {
295
+                    channel.getServer().addQuery(url);
296
+                    channel.getServer().getQuery(url).show();
297
+                }
298
+            }
284 299
         }
285 300
     }
286 301
 

+ 20
- 3
src/com/dmdirc/addons/ui_swing/components/text/WrapEditorKit.java Parādīt failu

@@ -74,9 +74,12 @@ public class WrapEditorKit extends StyledEditorKit implements MouseListener,
74 74
             return;
75 75
         }
76 76
         if (!editorPane.isEditable()) {
77
-            Object target = characterElementAt(e).getAttributes().getAttribute(
78
-                    IRCTextAttribute.HYPERLINK);
79
-            if (target != null) {
77
+            if (characterElementAt(e).getAttributes().getAttribute(
78
+                    IRCTextAttribute.HYPERLINK) != null
79
+                    || characterElementAt(e).getAttributes().getAttribute(
80
+                    IRCTextAttribute.CHANNEL) != null
81
+                    || characterElementAt(e).getAttributes().getAttribute(
82
+                    IRCTextAttribute.NICKNAME) != null) {
80 83
                 editorPane.setCursor(HAND_CURSOR);
81 84
                 return;
82 85
             }
@@ -102,6 +105,20 @@ public class WrapEditorKit extends StyledEditorKit implements MouseListener,
102 105
                     HyperlinkEvent.EventType.ACTIVATED, null,
103 106
                     (String) target));
104 107
             }
108
+            target = characterElementAt(e).getAttributes().getAttribute(
109
+                    IRCTextAttribute.CHANNEL);
110
+            if (target != null) {
111
+                editorPane.fireHyperlinkUpdate(new HyperlinkEvent(editorPane,
112
+                    HyperlinkEvent.EventType.ACTIVATED, null,
113
+                    (String) target));
114
+            }
115
+            target = characterElementAt(e).getAttributes().getAttribute(
116
+                    IRCTextAttribute.NICKNAME);
117
+            if (target != null) {
118
+                editorPane.fireHyperlinkUpdate(new HyperlinkEvent(editorPane,
119
+                    HyperlinkEvent.EventType.ACTIVATED, null,
120
+                    (String) target));
121
+            }
105 122
         }
106 123
     }
107 124
 

Notiek ielāde…
Atcelt
Saglabāt