ソースを参照

Mostly use new core about model.

pull/150/head
Greg Holmes 9年前
コミット
70308c945c

+ 38
- 66
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/about/AboutDialog.java ファイルの表示

@@ -22,64 +22,58 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs.about;
24 24
 
25
+import com.dmdirc.DMDircMBassador;
26
+import com.dmdirc.addons.ui_swing.SwingController;
25 27
 import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
26 28
 import com.dmdirc.addons.ui_swing.injection.MainWindow;
29
+import com.dmdirc.events.ClientInfoRequestEvent;
30
+import com.dmdirc.interfaces.ui.AboutDialogModel;
31
+import com.dmdirc.ui.core.about.InfoItem;
32
+import com.dmdirc.ui.core.util.URLHandler;
27 33
 
28 34
 import java.awt.Window;
29
-import java.awt.event.ActionEvent;
30
-import java.awt.event.ActionListener;
31 35
 
32 36
 import javax.inject.Inject;
33 37
 import javax.swing.JButton;
34 38
 import javax.swing.JTabbedPane;
35 39
 import javax.swing.WindowConstants;
36
-import javax.swing.event.ChangeEvent;
37
-import javax.swing.event.ChangeListener;
38 40
 
41
+import net.miginfocom.layout.LayoutUtil;
39 42
 import net.miginfocom.swing.MigLayout;
40 43
 
44
+import net.engio.mbassy.listener.Handler;
45
+
41 46
 /**
42 47
  * About dialog.
43 48
  */
44
-public class AboutDialog extends StandardDialog implements ActionListener, ChangeListener {
49
+public class AboutDialog extends StandardDialog {
45 50
 
46
-    /** Serial version UID. */
47 51
     private static final long serialVersionUID = 5;
48
-    /** Tabbed pane to use. */
49
-    private JTabbedPane tabbedPane;
50
-    /** Credits panel. */
51
-    private CreditsPanel cp;
52
-    /** Tab history. */
53
-    private int history;
54
-
55
-    /**
56
-     * Creates a new instance of AboutDialog.
57
-     *
58
-     * @param parentWindow  Parent window
59
-     * @param infoPanel     The info panel to display.
60
-     * @param creditsPanel  The credits panel to display.
61
-     * @param licensesPanel The licenses panel to display.
62
-     * @param aboutPanel    The about panel to display.
63
-     */
52
+    private final URLHandler urlHandler;
53
+    private final AboutDialogModel model;
54
+    private final SwingController controller;
55
+
64 56
     @Inject
65 57
     public AboutDialog(
66 58
             @MainWindow final Window parentWindow,
67
-            final InfoPanel infoPanel,
68
-            final CreditsPanel creditsPanel,
69
-            final LicencesPanel licensesPanel,
70
-            final AboutPanel aboutPanel) {
59
+            final AboutDialogModel model,
60
+            final URLHandler urlHandler,
61
+            final DMDircMBassador eventBus,
62
+            final SwingController controller,
63
+            final LicencesPanel licensesPanel) {
71 64
         super(parentWindow, ModalityType.MODELESS);
65
+        this.urlHandler = urlHandler;
66
+        this.model = model;
67
+        this.controller = controller;
72 68
 
73
-        initComponents(infoPanel, creditsPanel, licensesPanel, aboutPanel);
69
+        eventBus.subscribe(this);
70
+        model.load();
71
+        initComponents(licensesPanel);
74 72
     }
75 73
 
76 74
     /** Initialises the main UI components. */
77
-    private void initComponents(
78
-            final InfoPanel infoPanel,
79
-            final CreditsPanel creditsPanel,
80
-            final LicencesPanel licensesPanel,
81
-            final AboutPanel aboutPanel) {
82
-        tabbedPane = new JTabbedPane();
75
+    private void initComponents(final LicencesPanel licensesPanel) {
76
+        final JTabbedPane tabbedPane = new JTabbedPane();
83 77
 
84 78
         setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
85 79
         setTitle("About");
@@ -87,16 +81,13 @@ public class AboutDialog extends StandardDialog implements ActionListener, Chang
87 81
 
88 82
         orderButtons(new JButton(), new JButton());
89 83
 
90
-        getOkButton().addActionListener(this);
91
-        getCancelButton().addActionListener(this);
92
-
93
-        cp = creditsPanel;
84
+        getOkButton().addActionListener(e -> dispose());
85
+        getCancelButton().addActionListener(e -> dispose());
94 86
 
95
-        tabbedPane.add("About", aboutPanel);
96
-        tabbedPane.add("Credits", cp);
87
+        tabbedPane.add("About", new AboutPanel(urlHandler, model));
88
+        tabbedPane.add("Credits", new CreditsPanel(urlHandler, model));
97 89
         tabbedPane.add("Licences", licensesPanel);
98
-        tabbedPane.add("Information", infoPanel);
99
-        tabbedPane.addChangeListener(this);
90
+        tabbedPane.add("Information", new InfoPanel(model));
100 91
 
101 92
         getContentPane().setLayout(new MigLayout("ins rel, wrap 1, fill, "
102 93
                 + "wmin 600, wmax 600, hmin 400, hmax 400"));
@@ -104,30 +95,11 @@ public class AboutDialog extends StandardDialog implements ActionListener, Chang
104 95
         getContentPane().add(getOkButton(), "right");
105 96
     }
106 97
 
107
-    /**
108
-     * {@inheritDoc}.
109
-     *
110
-     * @param e Action event
111
-     */
112
-    @Override
113
-    public void actionPerformed(final ActionEvent e) {
114
-        dispose();
115
-    }
116
-
117
-    @Override
118
-    public boolean enterPressed() {
119
-        executeAction(getOkButton());
120
-        return true;
98
+    @Handler
99
+    public void handleInfoRequest(final ClientInfoRequestEvent event) {
100
+        event.addInfoItem(InfoItem.create("Swing UI Version", controller.getVersion().toString()),
101
+                InfoItem.create("Look and Feel", SwingController.getLookAndFeel()),
102
+                InfoItem.create("MiG Layout Version", LayoutUtil.getVersion())
103
+        );
121 104
     }
122
-
123
-    @Override
124
-    public void stateChanged(final ChangeEvent e) {
125
-        history = 10 * (history % 10000) + tabbedPane.getSelectedIndex();
126
-
127
-        if (history / 10 % 100 == 32 && (history & 1) == 1
128
-                && history >> 8 == 118) {
129
-            cp.showEE();
130
-        }
131
-    }
132
-
133 105
 }

+ 11
- 31
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/about/AboutPanel.java ファイルの表示

@@ -24,58 +24,38 @@ package com.dmdirc.addons.ui_swing.dialogs.about;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26 26
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
27
+import com.dmdirc.interfaces.ui.AboutDialogModel;
27 28
 import com.dmdirc.ui.core.util.URLHandler;
28 29
 
29
-import javax.inject.Inject;
30 30
 import javax.swing.JPanel;
31 31
 import javax.swing.event.HyperlinkEvent;
32
-import javax.swing.event.HyperlinkEvent.EventType;
33
-import javax.swing.event.HyperlinkListener;
34 32
 
35 33
 import net.miginfocom.swing.MigLayout;
36 34
 
37 35
 /**
38 36
  * About DMDirc panel.
39 37
  */
40
-public final class AboutPanel extends JPanel implements HyperlinkListener {
38
+public final class AboutPanel extends JPanel {
41 39
 
42
-    /** A version number for this class. */
43 40
     private static final long serialVersionUID = 1;
44
-    /** The URL Handler to use to handle clicked links. */
45 41
     private final URLHandler urlHandler;
42
+    private final AboutDialogModel model;
46 43
 
47
-    /**
48
-     * Creates a new instance of AboutPanel.
49
-     *
50
-     * @param urlHandler The URL Handler to use to handle clicked links
51
-     */
52
-    @Inject
53
-    public AboutPanel(final URLHandler urlHandler) {
44
+    public AboutPanel(final URLHandler urlHandler, final AboutDialogModel model) {
54 45
         this.urlHandler = urlHandler;
46
+        this.model = model;
55 47
         setOpaque(UIUtilities.getTabbedPaneOpaque());
56 48
         initComponents();
57 49
     }
58 50
 
59
-    /** Initialises the components. */
60 51
     private void initComponents() {
61
-        final TextLabel about = new TextLabel("<html><center>"
62
-                + "<h1 style=\"margin-bottom: 0px;\">DMDirc</h1>"
63
-                + "<span style=\"font-style: italic;\">The intelligent IRC client.</span>"
64
-                + "<p>Easy to use, cross-platform IRC client.</p>"
65
-                + "<p><a href=\"http://www.dmdirc.com\">www.dmdirc.com</a></p>"
66
-                + "</center></html>", false);
67
-        about.addHyperlinkListener(this);
68
-
52
+        final TextLabel about = new TextLabel(model.getAbout(), false);
53
+        about.addHyperlinkListener(e -> {
54
+            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
55
+                urlHandler.launchApp(e.getURL());
56
+            }
57
+        });
69 58
         setLayout(new MigLayout("ins rel, fill"));
70
-
71 59
         add(about, "align center");
72 60
     }
73
-
74
-    @Override
75
-    public void hyperlinkUpdate(final HyperlinkEvent e) {
76
-        if (e.getEventType() == EventType.ACTIVATED) {
77
-            urlHandler.launchApp(e.getURL());
78
-        }
79
-    }
80
-
81 61
 }

+ 28
- 41
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/about/CreditsPanel.java ファイルの表示

@@ -24,63 +24,57 @@ package com.dmdirc.addons.ui_swing.dialogs.about;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26 26
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
27
+import com.dmdirc.interfaces.ui.AboutDialogModel;
28
+import com.dmdirc.ui.core.about.Developer;
27 29
 import com.dmdirc.ui.core.util.URLHandler;
28 30
 
29
-import javax.inject.Inject;
31
+import java.util.function.Consumer;
32
+
30 33
 import javax.swing.JPanel;
31 34
 import javax.swing.JScrollPane;
32
-import javax.swing.event.HyperlinkEvent;
33 35
 import javax.swing.event.HyperlinkEvent.EventType;
34
-import javax.swing.event.HyperlinkListener;
35 36
 
36 37
 import net.miginfocom.swing.MigLayout;
37 38
 
38 39
 /**
39 40
  * Authors Panel.
40 41
  */
41
-public final class CreditsPanel extends JPanel implements HyperlinkListener {
42
+public final class CreditsPanel extends JPanel {
42 43
 
43
-    /** A version number for this class. */
44 44
     private static final long serialVersionUID = 2;
45
-    /** HTML label we're using. */
46
-    private TextLabel about;
47
-    /** URL Handler to use to open clicked links. */
48 45
     private final URLHandler urlHandler;
46
+    private final AboutDialogModel model;
49 47
 
50
-    /**
51
-     * Creates a new instance of CreditsPanel.
52
-     *
53
-     * @param urlHandler The URL handler to use to open clicked links
54
-     */
55
-    @Inject
56
-    public CreditsPanel(final URLHandler urlHandler) {
48
+    public CreditsPanel(final URLHandler urlHandler, final AboutDialogModel model) {
57 49
         this.urlHandler = urlHandler;
50
+        this.model = model;
58 51
 
59 52
         setOpaque(UIUtilities.getTabbedPaneOpaque());
60 53
         initComponents();
61 54
     }
62 55
 
63
-    /** Shows some alternate content. */
64
-    public void showEE() {
65
-        about.setText("<html><center><br><br><br>"
66
-                + "<img src=\"https://www.dmdirc.com/res/about.png\"></html>");
67
-    }
68
-
69 56
     /** Initialises the components. */
70 57
     private void initComponents() {
71
-        about = new TextLabel("<html>"
72
-                + "<h3 style='margin: 3px; padding: 0px 0px 5px 0px;'>Main developers:</h3>"
73
-                + "<ul style='list-style-type: circle; margin-top: 0px;'>"
74
-                + "<li><a href=\"https://www.md87.co.uk\">Chris 'MD87' Smith</a></li>"
75
-                + "<li><a href=\"https://www.greboid.com\">Gregory 'Greboid' Holmes</a></li>"
76
-                + "<li><a href=\"http://home.dataforce.org.uk\">Shane 'Dataforce' Mc Cormack</a></li>"
77
-                + "</ul>"
78
-                + "<h3 style='margin: 3px; padding: 0px 0px 5px 0px;'>Additional developers:</h3>"
79
-                + "<ul style='list-style-type: circle; margin-top: 0px;'>"
80
-                + "<li><a href=\"http://simonmott.co.uk/\">Simon 'Demented-Idiot' Mott</a></li>"
81
-                + "</ul>"
82
-                + "</html>");
83
-        about.addHyperlinkListener(this);
58
+        final StringBuilder sb = new StringBuilder();
59
+        sb.append("<html>");
60
+        sb.append("<h3 style='margin: 3px; padding: 0px 0px 5px 0px;'>Main Developers:</h3>");
61
+        sb.append("<ul style='margin-top: 0px;'>");
62
+        final Consumer<Developer> developerConsumer = i -> {
63
+                sb.append("<li><a href=\"").append(i.getWebsite()).append("\">");
64
+                sb.append(i.getName()).append("</a>").append("</li>");
65
+        };
66
+        model.getMainDevelopers().forEach(developerConsumer);
67
+        sb.append("</ul>");
68
+        sb.append("<h3 style='margin: 3px; padding: 0px 0px 5px 0px;'>Other Developers: </h3>");
69
+        sb.append("<ul style='margin-top: 0px;'>");
70
+        model.getOtherDevelopers().forEach(developerConsumer);
71
+        sb.append("</ul></html>");
72
+        final TextLabel about = new TextLabel(sb.toString());
73
+        about.addHyperlinkListener(e -> {
74
+            if (e.getEventType() == EventType.ACTIVATED) {
75
+                urlHandler.launchApp(e.getURL());
76
+            }
77
+        });
84 78
 
85 79
         setLayout(new MigLayout("ins rel, fill"));
86 80
         final JScrollPane scrollPane = new JScrollPane(about);
@@ -89,11 +83,4 @@ public final class CreditsPanel extends JPanel implements HyperlinkListener {
89 83
         add(scrollPane, "grow, push");
90 84
     }
91 85
 
92
-    @Override
93
-    public void hyperlinkUpdate(final HyperlinkEvent e) {
94
-        if (e.getEventType() == EventType.ACTIVATED) {
95
-            urlHandler.launchApp(e.getURL());
96
-        }
97
-    }
98
-
99 86
 }

+ 12
- 47
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/about/InfoPanel.java ファイルの表示

@@ -22,19 +22,11 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs.about;
24 24
 
25
-import com.dmdirc.ClientModule.GlobalConfig;
26
-import com.dmdirc.addons.ui_swing.SwingController;
27 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
28
-import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
29
-import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
30
-import com.dmdirc.interfaces.config.AggregateConfigProvider;
31
-import com.dmdirc.util.ClientInfo;
32
-import com.dmdirc.util.DateUtils;
26
+import com.dmdirc.interfaces.ui.AboutDialogModel;
33 27
 
34 28
 import java.awt.Font;
35
-import java.nio.charset.Charset;
36 29
 
37
-import javax.inject.Inject;
38 30
 import javax.swing.JEditorPane;
39 31
 import javax.swing.JPanel;
40 32
 import javax.swing.JScrollPane;
@@ -42,38 +34,20 @@ import javax.swing.UIManager;
42 34
 import javax.swing.text.html.HTMLDocument;
43 35
 import javax.swing.text.html.HTMLEditorKit;
44 36
 
45
-import net.miginfocom.layout.LayoutUtil;
46 37
 import net.miginfocom.swing.MigLayout;
47 38
 
48 39
 /** Info panel. */
49 40
 public final class InfoPanel extends JPanel {
50 41
 
51
-    /** Serial version UID. */
52 42
     private static final long serialVersionUID = 1;
53
-    /** Parent controller. */
54
-    private final SwingController controller;
55
-    /** The config to read settings from. */
56
-    private final AggregateConfigProvider globalConfig;
57
-    /** The base directory used for settings. */
58
-    private final String baseDirectory;
59
-    /** Used to get information about the client. */
60
-    private final ClientInfo clientInfo;
43
+    private final AboutDialogModel model;
61 44
 
62
-    @Inject
63
-    public InfoPanel(
64
-            final SwingController controller,
65
-            @GlobalConfig final AggregateConfigProvider globalConfig,
66
-            @Directory(DirectoryType.BASE) final String baseDirectory,
67
-            final ClientInfo clientInfo) {
68
-        this.controller = controller;
69
-        this.globalConfig = globalConfig;
70
-        this.baseDirectory = baseDirectory;
71
-        this.clientInfo = clientInfo;
45
+    public InfoPanel(final AboutDialogModel model) {
46
+        this.model = model;
72 47
         setOpaque(UIUtilities.getTabbedPaneOpaque());
73 48
         initComponents();
74 49
     }
75 50
 
76
-    /** Initialises the components. */
77 51
     private void initComponents() {
78 52
         final JScrollPane scrollPane = new JScrollPane();
79 53
         final JEditorPane infoPane = new JEditorPane();
@@ -83,23 +57,14 @@ public final class InfoPanel extends JPanel {
83 57
                 + "{ font-family: " + font.getFamily() + "; " + "font-size: "
84 58
                 + font.getSize() + "pt; }");
85 59
 
86
-        infoPane.setText("<html>"
87
-                + "<b>DMDirc version: </b>" + clientInfo.getVersionInformation() + "<br>"
88
-                + "<b>Mode Aliases version: </b>"
89
-                + globalConfig.getOption("identity", "modealiasversion")
90
-                + "<br>"
91
-                + "<b>Swing UI version: </b>" + controller.getVersion() + "<br>"
92
-                + "<b>OS Version: </b>" + clientInfo.getOperatingSystemInformation() + "<br>"
93
-                + "<b>Profile directory: </b>" + baseDirectory + "<br>"
94
-                + "<b>Java version: </b>" + clientInfo.getJavaInformation() + "<br>"
95
-                + "<b>Look and Feel: </b>" + SwingController.getLookAndFeel()
96
-                + "<br>"
97
-                + "<b>MiG Layout version: </b>" + LayoutUtil.getVersion()
98
-                + "<br>"
99
-                + "<b>Java Default charset: </b>" + Charset.defaultCharset().displayName() + "<br>"
100
-                + "<b>Client Uptime: </b>"
101
-                + DateUtils.formatDuration((int) clientInfo.getUptime() / 1000) + "<br>"
102
-                + "</html>");
60
+        final StringBuilder sb = new StringBuilder();
61
+        sb.append("<html>");
62
+        model.getInfo().forEach(i -> {
63
+            sb.append("<b>").append(i.getDescription()).append(": ").append("</b>");
64
+            sb.append(i.getInformation()).append("<br>");
65
+        });
66
+        sb.append("</html>");
67
+        infoPane.setText(sb.toString());
103 68
         infoPane.setEditable(false);
104 69
         scrollPane.setViewportView(infoPane);
105 70
 

+ 7
- 0
ui_swing/src/com/dmdirc/addons/ui_swing/injection/DialogModule.java ファイルの表示

@@ -48,11 +48,13 @@ import com.dmdirc.interfaces.Connection;
48 48
 import com.dmdirc.interfaces.LifecycleController;
49 49
 import com.dmdirc.interfaces.config.ConfigProvider;
50 50
 import com.dmdirc.interfaces.config.IdentityFactory;
51
+import com.dmdirc.interfaces.ui.AboutDialogModel;
51 52
 import com.dmdirc.interfaces.ui.AliasDialogModel;
52 53
 import com.dmdirc.interfaces.ui.FeedbackDialogModel;
53 54
 import com.dmdirc.interfaces.ui.NewServerDialogModel;
54 55
 import com.dmdirc.interfaces.ui.ProfilesDialogModel;
55 56
 import com.dmdirc.plugins.ServiceManager;
57
+import com.dmdirc.ui.core.about.CoreAboutDialogModel;
56 58
 import com.dmdirc.ui.core.aliases.CoreAliasDialogModel;
57 59
 import com.dmdirc.ui.core.feedback.CoreFeedbackDialogModel;
58 60
 import com.dmdirc.ui.core.newserver.CoreNewServerDialogModel;
@@ -110,6 +112,11 @@ public class DialogModule {
110 112
         return model;
111 113
     }
112 114
 
115
+    @Provides
116
+    public AboutDialogModel getAboutDialogModel(final CoreAboutDialogModel model) {
117
+        return model;
118
+    }
119
+
113 120
     @Provides
114 121
     @Singleton
115 122
     public DialogProvider<NewServerDialog> getNewServerDialogProvider(

読み込み中…
キャンセル
保存