Browse Source

Remove stupid textlabel classes, work around introduced bugs

Update miglayout

Fixes issue 4254

Change-Id: I942553c146edfc4b078433bf2ddc6e93fc41a193
Reviewed-on: http://gerrit.dmdirc.com/1463
Automatic-Compile: Chris Smith <chris@dmdirc.com>
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.5
Greg Holmes 14 years ago
parent
commit
821dafdfdf

BIN
lib/miglayout-3.7.2-swing.jar → lib/miglayout-3.7.3.1-swing.jar View File


+ 0
- 80
src/com/dmdirc/addons/ui_swing/components/text/HTMLLabel.java View File

@@ -1,80 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_swing.components.text;
24
-
25
-import java.awt.Color;
26
-import java.awt.Font;
27
-
28
-import javax.swing.JEditorPane;
29
-import javax.swing.UIManager;
30
-import javax.swing.plaf.basic.BasicTextPaneUI;
31
-import javax.swing.text.html.HTMLDocument;
32
-import javax.swing.text.html.StyleSheet;
33
-
34
-/**
35
- * Dyamnic text label with hyperlink support.
36
- */
37
-public class HTMLLabel extends JEditorPane {
38
-
39
-    /**
40
-     * A version number for this class. It should be changed whenever the
41
-     * class structure is changed (or anything else that would prevent
42
-     * serialized objects being unserialized with the new class).
43
-     */
44
-    private static final long serialVersionUID = 1;
45
-
46
-    /**
47
-     * Creates a new instance of TextLabel.
48
-     */
49
-    public HTMLLabel() {
50
-        this(null);
51
-    }
52
-
53
-    /**
54
-     * Creates a new instance of TextLabel.
55
-     *
56
-     * @param text Text to display
57
-     */
58
-    public HTMLLabel(final String text) {
59
-        super("text/html", text);
60
-
61
-        final StyleSheet styleSheet = ((HTMLDocument) getDocument()).getStyleSheet();
62
-        final Font font = UIManager.getFont("Label.font");
63
-        final Color colour = UIManager.getColor("Label.foreground");
64
-        styleSheet.addRule("body { font-family: " + font.getFamily()
65
-                + "; " + "font-size: " + font.getSize() + "pt; color: rgb("
66
-                + colour.getRed() + ", " + colour.getGreen() + ", "
67
-                + colour.getBlue()+"); }");
68
-
69
-        init();
70
-    }
71
-
72
-    /** Initialiases the component. */
73
-    private void init() {
74
-        setUI(new BasicTextPaneUI());
75
-        setOpaque(false);
76
-        setEditable(false);
77
-        setHighlighter(null);
78
-        setFont(UIManager.getFont("TextField.font"));
79
-    }
80
-}

+ 0
- 108
src/com/dmdirc/addons/ui_swing/components/text/OldTextLabel.java View File

@@ -1,108 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.ui_swing.components.text;
24
-
25
-import java.awt.Insets;
26
-
27
-import javax.swing.JTextPane;
28
-import javax.swing.UIManager;
29
-import javax.swing.plaf.basic.BasicTextPaneUI;
30
-import javax.swing.text.DefaultStyledDocument;
31
-import javax.swing.text.SimpleAttributeSet;
32
-import javax.swing.text.StyleConstants;
33
-import javax.swing.text.StyledDocument;
34
-
35
-/**
36
- * Dyamnic text label.
37
- */
38
-public class OldTextLabel extends JTextPane {
39
-
40
-    /**
41
-     * A version number for this class. It should be changed whenever the
42
-     * class structure is changed (or anything else that would prevent
43
-     * serialized objects being unserialized with the new class).
44
-     */
45
-    private static final long serialVersionUID = 1;
46
-    /** Simple attribute set. */
47
-    private SimpleAttributeSet sas;
48
-
49
-    /**
50
-     * Creates a new instance of TextLabel.
51
-     */
52
-    public OldTextLabel() {
53
-        this(null, true);
54
-    }
55
-
56
-    /**
57
-     * Creates a new instance of TextLabel.
58
-     *
59
-     * @param text Text to display
60
-     */
61
-    public OldTextLabel(final String text) {
62
-        this(text, true);
63
-    }
64
-
65
-    /**
66
-     * Creates a new instance of TextLabel.
67
-     *
68
-     * @param text Text to display
69
-     * @param justified Justify the text?
70
-     */
71
-    public OldTextLabel(final String text, final boolean justified) {
72
-        super(new DefaultStyledDocument());
73
-        setUI(new BasicTextPaneUI());
74
-
75
-        setOpaque(false);
76
-        setEditable(false);
77
-        setHighlighter(null);
78
-        setMargin(new Insets(0, 0, 0, 0));
79
-
80
-        sas = new SimpleAttributeSet();
81
-        if (justified) {
82
-            StyleConstants.setAlignment(sas, StyleConstants.ALIGN_JUSTIFIED);
83
-        }
84
-
85
-        StyleConstants.setForeground(sas, UIManager.getColor("Label.foreground"));
86
-        StyleConstants.setFontFamily(sas, getFont().getFamily());
87
-        StyleConstants.setFontSize(sas, getFont().getSize());
88
-        StyleConstants.setBold(sas, getFont().isBold());
89
-        StyleConstants.setItalic(sas, getFont().isItalic());
90
-
91
-        setText(text);
92
-    }
93
-
94
-    /** {@inheritDoc} */
95
-    @Override
96
-    public StyledDocument getDocument() {
97
-        return (StyledDocument) super.getDocument();
98
-    }
99
-
100
-    /** {@inheritDoc} */
101
-    @Override
102
-    public void setText(final String t) {
103
-        super.setText(t);
104
-        if (t != null && !t.isEmpty()) {
105
-            getDocument().setParagraphAttributes(0, t.length(), sas, true);
106
-        }
107
-    }
108
-}

+ 1
- 2
src/com/dmdirc/addons/ui_swing/components/text/TextLabel.java View File

@@ -37,7 +37,7 @@ import javax.swing.text.html.HTMLDocument;
37 37
 import javax.swing.text.html.StyleSheet;
38 38
 
39 39
 /**
40
- * Dyamnic text label.
40
+ * Dynamic text label.
41 41
  */
42 42
 public class TextLabel extends JTextPane {
43 43
 
@@ -86,7 +86,6 @@ public class TextLabel extends JTextPane {
86 86
                 + "font-size: " + font.getSize() + "pt; "
87 87
                 + "color: rgb(" + colour.getRed() + ", " + colour.getGreen()
88 88
                 + ", " + colour.getBlue() + "); }");
89
-        styleSheet.addRule("p { margin: 0; }");
90 89
 
91 90
         setOpaque(false);
92 91
         setEditable(false);

+ 3
- 3
src/com/dmdirc/addons/ui_swing/dialogs/about/AboutPanel.java View File

@@ -23,7 +23,7 @@
23 23
 package com.dmdirc.addons.ui_swing.dialogs.about;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26
-import com.dmdirc.addons.ui_swing.components.text.HTMLLabel;
26
+import com.dmdirc.addons.ui_swing.components.text.TextLabel;
27 27
 import com.dmdirc.ui.core.util.URLHandler;
28 28
 
29 29
 import javax.swing.JPanel;
@@ -55,12 +55,12 @@ public final class AboutPanel extends JPanel implements HyperlinkListener {
55 55
     
56 56
     /** Initialises the components. */
57 57
     private void initComponents() {
58
-        final HTMLLabel about = new HTMLLabel("<html><center>"
58
+        final TextLabel about = new TextLabel("<html><center>"
59 59
                 + "<h1 style=\"margin-bottom: 0px;\">DMDirc</h1>"
60 60
                 + "<span style=\"font-style: italic;\">The intelligent IRC client.</span>"
61 61
                 + "<p>Easy to use, cross-platform IRC client.</p>"
62 62
                 + "<p><a href=\"http://www.dmdirc.com\">www.dmdirc.com</a></p>"
63
-                + "</center></html>");
63
+                + "</center></html>", false);
64 64
         about.addHyperlinkListener(this);
65 65
         
66 66
         setLayout(new MigLayout("ins rel, fill"));

+ 3
- 3
src/com/dmdirc/addons/ui_swing/dialogs/about/CreditsPanel.java View File

@@ -23,7 +23,7 @@
23 23
 package com.dmdirc.addons.ui_swing.dialogs.about;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26
-import com.dmdirc.addons.ui_swing.components.text.HTMLLabel;
26
+import com.dmdirc.addons.ui_swing.components.text.TextLabel;
27 27
 import com.dmdirc.ui.core.util.URLHandler;
28 28
 
29 29
 import javax.swing.JPanel;
@@ -47,7 +47,7 @@ public final class CreditsPanel extends JPanel implements HyperlinkListener {
47 47
     private static final long serialVersionUID = 2;
48 48
 
49 49
     /** HTML label we're using. */
50
-    private HTMLLabel about;
50
+    private TextLabel about;
51 51
     
52 52
     /** Creates a new instance of CreditsPanel. */
53 53
     public CreditsPanel() {
@@ -65,7 +65,7 @@ public final class CreditsPanel extends JPanel implements HyperlinkListener {
65 65
     
66 66
     /** Initialises the components. */
67 67
     private void initComponents() {
68
-        about = new HTMLLabel("<html>"
68
+        about = new TextLabel("<html>"
69 69
                 + "<h3 style='margin: 3px; padding: 0px 0px 5px 0px;'>Main developers:</h3>"
70 70
                 + "<ul style='list-style-type: circle; margin-top: 0px;'>"
71 71
                 + "<li><a href=\"http://www.md87.co.uk\">Chris 'MD87' Smith</a></li>"

+ 11
- 7
src/com/dmdirc/addons/ui_swing/dialogs/actionsmanager/ActionGroupInformationPanel.java View File

@@ -23,7 +23,8 @@ package com.dmdirc.addons.ui_swing.dialogs.actionsmanager;
23 23
 
24 24
 import com.dmdirc.actions.ActionGroup;
25 25
 
26
-import com.dmdirc.addons.ui_swing.components.text.OldTextLabel;
26
+import com.dmdirc.addons.ui_swing.components.text.TextLabel;
27
+import javax.swing.Box;
27 28
 import javax.swing.JLabel;
28 29
 import javax.swing.JPanel;
29 30
 
@@ -43,7 +44,7 @@ public final class ActionGroupInformationPanel extends JPanel {
43 44
     /** Action group. */
44 45
     private ActionGroup group;
45 46
     /** Description field. */
46
-    private OldTextLabel infoLabel;
47
+    private TextLabel infoLabel;
47 48
     /** Version label label. */
48 49
     private JLabel versionLabel;
49 50
     /** Version label. */
@@ -72,7 +73,7 @@ public final class ActionGroupInformationPanel extends JPanel {
72 73
      * Initialises the components.
73 74
      */
74 75
     private void initComponents() {
75
-        infoLabel = new OldTextLabel();
76
+        infoLabel = new TextLabel("");
76 77
         versionLabel = new JLabel("Version: ");
77 78
         version = new JLabel();
78 79
         authorLabel = new JLabel("Author: ");
@@ -92,9 +93,9 @@ public final class ActionGroupInformationPanel extends JPanel {
92 93
      * Lays out the components.
93 94
      */
94 95
     private void layoutComponents() {
95
-        setLayout(new MigLayout("fill, wrap 2, hidemode 3"));
96
+        setLayout(new MigLayout("fill, wrap 2, hidemode 2"));
96 97
 
97
-        add(infoLabel, "span 2, growx, pushx");
98
+        add(infoLabel, "spanx 2, grow, push");
98 99
         add(authorLabel, "");
99 100
         add(author, "growx, pushx");
100 101
         add(versionLabel, "");
@@ -110,7 +111,9 @@ public final class ActionGroupInformationPanel extends JPanel {
110 111
         this.group = group;
111 112
 
112 113
         if (shouldDisplay()) {
113
-            infoLabel.setText(group.getDescription());
114
+            //Prevent HTML text displaying, replace newlines with <br>
115
+            infoLabel.setText(group.getDescription().replace("<", "&lt;")
116
+                    .replace("\n", "<br>"));
114 117
             author.setText(group.getAuthor());
115 118
             version.setText(group.getVersion() == null ? "" : group.getVersion().toString());
116 119
 
@@ -119,7 +122,8 @@ public final class ActionGroupInformationPanel extends JPanel {
119 122
             authorLabel.setVisible(group.getAuthor() != null);
120 123
             versionLabel.setVisible(group.getVersion() != null);
121 124
         } else {
122
-            infoLabel.setText("");
125
+            //Value require for mig/swing layouting bug
126
+            infoLabel.setText("Non empty string");
123 127
             author.setText("");
124 128
             version.setText("");
125 129
         }

+ 5
- 5
src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/TopicLabel.java View File

@@ -25,7 +25,7 @@ package com.dmdirc.addons.ui_swing.dialogs.channelsetting;
25 25
 
26 26
 import com.dmdirc.Channel;
27 27
 import com.dmdirc.Topic;
28
-import com.dmdirc.addons.ui_swing.components.text.OldTextLabel;
28
+import com.dmdirc.addons.ui_swing.components.text.TextLabel;
29 29
 
30 30
 import java.awt.Color;
31 31
 import java.util.Date;
@@ -122,15 +122,15 @@ public class TopicLabel extends JPanel {
122 122
             add(pane, "wmax 450, grow, push, wrap, gapleft 5, gapleft 5");
123 123
         }
124 124
 
125
-        OldTextLabel label;
125
+        TextLabel label;
126 126
         if (topic.getTopic().isEmpty()) {
127
-            label = new OldTextLabel("Topic unset by " + topic.getClient());
127
+            label = new TextLabel("Topic unset by " + topic.getClient());
128 128
         } else {
129
-            label = new OldTextLabel("Topic set by " + topic.getClient());
129
+            label = new TextLabel("Topic set by " + topic.getClient());
130 130
         }
131 131
         add(label, "wmax 450, grow, push, wrap, gapleft 5, pad 0");
132 132
 
133
-        label = new OldTextLabel("on " + new Date(topic.getTime() * 1000).
133
+        label = new TextLabel("on " + new Date(topic.getTime() * 1000).
134 134
                 toString());
135 135
         add(label, "wmax 450, grow, push, wrap, gapleft 5, pad 0");
136 136
 

+ 5
- 5
src/com/dmdirc/addons/ui_swing/dialogs/serverlist/Info.java View File

@@ -23,8 +23,8 @@
23 23
 package com.dmdirc.addons.ui_swing.dialogs.serverlist;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26
-import com.dmdirc.addons.ui_swing.components.text.HTMLLabel;
27 26
 import com.dmdirc.addons.serverlists.ServerGroupItem;
27
+import com.dmdirc.addons.ui_swing.components.text.TextLabel;
28 28
 import com.dmdirc.ui.core.util.URLHandler;
29 29
 
30 30
 import java.net.URI;
@@ -51,9 +51,9 @@ public class Info extends JPanel implements HyperlinkListener,
51 51
      */
52 52
     private static final long serialVersionUID = 2;
53 53
     /** Info pane. */
54
-    private final HTMLLabel infoLabel;
54
+    private final TextLabel infoLabel;
55 55
     /** Link label. */
56
-    private final HTMLLabel linkLabel;
56
+    private final TextLabel linkLabel;
57 57
     /** Server list model. */
58 58
     private final ServerListModel model;
59 59
     /** Info scroll panel. */
@@ -69,8 +69,8 @@ public class Info extends JPanel implements HyperlinkListener,
69 69
 
70 70
         this.model = model;
71 71
 
72
-        infoLabel = new HTMLLabel();
73
-        linkLabel = new HTMLLabel();
72
+        infoLabel = new TextLabel();
73
+        linkLabel = new TextLabel();
74 74
         sp = new JScrollPane(infoLabel);
75 75
 
76 76
         setLayout(new MigLayout("fill, ins 0"));

Loading…
Cancel
Save