Quellcode durchsuchen

Remove the licenseloader.

pull/412/head
Greg Holmes vor 9 Jahren
Ursprung
Commit
05c911e6da

+ 2
- 6
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/about/AboutDialog.java Datei anzeigen

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.addons.ui_swing.dialogs.about;
24 24
 
25 25
 import com.dmdirc.ClientModule.GlobalConfig;
26
-import com.dmdirc.DMDircMBassador;
27 26
 import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
28 27
 import com.dmdirc.addons.ui_swing.injection.MainWindow;
29 28
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
@@ -47,7 +46,6 @@ public class AboutDialog extends StandardDialog {
47 46
     private static final long serialVersionUID = 5;
48 47
     private final URLHandler urlHandler;
49 48
     private final AboutDialogModel model;
50
-    private final DMDircMBassador eventBus;
51 49
     private final AggregateConfigProvider config;
52 50
 
53 51
     @Inject
@@ -55,12 +53,10 @@ public class AboutDialog extends StandardDialog {
55 53
             @GlobalConfig final AggregateConfigProvider config,
56 54
             @MainWindow final Window parentWindow,
57 55
             final AboutDialogModel model,
58
-            final URLHandler urlHandler,
59
-            final DMDircMBassador eventBus) {
56
+            final URLHandler urlHandler) {
60 57
         super(parentWindow, ModalityType.MODELESS);
61 58
         this.urlHandler = urlHandler;
62 59
         this.model = model;
63
-        this.eventBus = eventBus;
64 60
         this.config = config;
65 61
         model.load();
66 62
         initComponents();
@@ -81,7 +77,7 @@ public class AboutDialog extends StandardDialog {
81 77
 
82 78
         tabbedPane.add("About", new AboutPanel(urlHandler, model));
83 79
         tabbedPane.add("Credits", new CreditsPanel(urlHandler, model));
84
-        tabbedPane.add("Licences", new LicencesPanel(model, config, eventBus));
80
+        tabbedPane.add("Licences", new LicencesPanel(model, config));
85 81
         tabbedPane.add("Information", new InfoPanel(model));
86 82
 
87 83
         getContentPane().setLayout(new MigLayout("ins rel, wrap 1, fill, "

+ 0
- 88
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/about/LicenceLoader.java Datei anzeigen

@@ -1,88 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
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.dialogs.about;
24
-
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
27
-import com.dmdirc.interfaces.ui.AboutDialogModel;
28
-import com.dmdirc.ui.core.about.LicensedComponent;
29
-
30
-import java.io.IOException;
31
-
32
-import javax.swing.JTree;
33
-import javax.swing.tree.DefaultMutableTreeNode;
34
-import javax.swing.tree.DefaultTreeModel;
35
-import javax.swing.tree.MutableTreeNode;
36
-import javax.swing.tree.TreeNode;
37
-
38
-/**
39
- * Background loader of licences into a list.
40
- */
41
-public class LicenceLoader extends LoggingSwingWorker<Void, Void> {
42
-
43
-    /** Tree to add licenses to. */
44
-    private final JTree tree;
45
-    private final AboutDialogModel model;
46
-    /** Model to load licences into. */
47
-    private final DefaultTreeModel treeModel;
48
-
49
-    /**
50
-     * Instantiates a new licence loader.
51
-     *
52
-     * @param tree     Tree to add licenses to
53
-     * @param model    Model to load licences into
54
-     * @param eventBus The event bus to post errors to
55
-     */
56
-    public LicenceLoader(final AboutDialogModel model, final JTree tree,
57
-            final DefaultTreeModel treeModel, final DMDircMBassador eventBus) {
58
-        super(eventBus);
59
-        this.tree = tree;
60
-        this.model = model;
61
-        this.treeModel = treeModel;
62
-    }
63
-
64
-    @Override
65
-    protected Void doInBackground() throws IOException {
66
-        model.getLicensedComponents().forEach(this::addLicensedComponent);
67
-        return null;
68
-    }
69
-
70
-    private void addLicensedComponent(final LicensedComponent component) {
71
-        final MutableTreeNode componentNode = new DefaultMutableTreeNode(component);
72
-        treeModel.insertNodeInto(componentNode, (MutableTreeNode) treeModel.getRoot(),
73
-                treeModel.getChildCount(treeModel.getRoot()));
74
-        component.getLicences().forEach(l -> treeModel.insertNodeInto(
75
-                new DefaultMutableTreeNode(l), componentNode,
76
-                treeModel.getChildCount(componentNode)));
77
-    }
78
-
79
-    @Override
80
-    protected void done() {
81
-        treeModel.nodeStructureChanged((TreeNode) treeModel.getRoot());
82
-        for (int i = 0; i < tree.getRowCount(); i++) {
83
-            tree.expandRow(i);
84
-        }
85
-        tree.setSelectionRow(0);
86
-        super.done();
87
-    }
88
-}

+ 26
- 4
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/about/LicencesPanel.java Datei anzeigen

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs.about;
24 24
 
25
-import com.dmdirc.DMDircMBassador;
26 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
27 26
 import com.dmdirc.addons.ui_swing.components.TreeScroller;
28 27
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
@@ -45,6 +44,8 @@ import javax.swing.text.html.HTMLDocument;
45 44
 import javax.swing.text.html.HTMLEditorKit;
46 45
 import javax.swing.tree.DefaultMutableTreeNode;
47 46
 import javax.swing.tree.DefaultTreeModel;
47
+import javax.swing.tree.MutableTreeNode;
48
+import javax.swing.tree.TreeNode;
48 49
 import javax.swing.tree.TreeSelectionModel;
49 50
 
50 51
 import net.miginfocom.layout.PlatformDefaults;
@@ -57,6 +58,7 @@ public class LicencesPanel extends JPanel implements TreeSelectionListener {
57 58
 
58 59
     /** Serial version UID. */
59 60
     private static final long serialVersionUID = 3;
61
+    private final AboutDialogModel model;
60 62
     /** Config manager. */
61 63
     private final AggregateConfigProvider config;
62 64
     /** Licence scroll pane. */
@@ -69,12 +71,12 @@ public class LicencesPanel extends JPanel implements TreeSelectionListener {
69 71
     private JTree list;
70 72
 
71 73
     public LicencesPanel(final AboutDialogModel model,
72
-            final AggregateConfigProvider globalConfig,
73
-            final DMDircMBassador eventBus) {
74
+            final AggregateConfigProvider globalConfig) {
75
+        this.model = model;
74 76
         config = globalConfig;
75 77
         initComponents();
76
-        new LicenceLoader(model, list, listModel, eventBus).execute();
77 78
         addListeners();
79
+        initLicenses();
78 80
         layoutComponents();
79 81
     }
80 82
 
@@ -156,4 +158,24 @@ public class LicencesPanel extends JPanel implements TreeSelectionListener {
156 158
         UIUtilities.resetScrollPane(scrollPane);
157 159
     }
158 160
 
161
+    private void initLicenses() {
162
+        model.getLicensedComponents().forEach(this::addLicensedComponent);
163
+        listModel.nodeStructureChanged((TreeNode) listModel.getRoot());
164
+        for (int i = 0; i < list.getRowCount(); i++) {
165
+            list.expandRow(i);
166
+        }
167
+        list.setSelectionRow(0);
168
+    }
169
+
170
+
171
+
172
+    private void addLicensedComponent(final LicensedComponent component) {
173
+        final MutableTreeNode componentNode = new DefaultMutableTreeNode(component);
174
+        listModel.insertNodeInto(componentNode, (MutableTreeNode) listModel.getRoot(),
175
+                listModel.getChildCount(listModel.getRoot()));
176
+        component.getLicences().forEach(l -> listModel.insertNodeInto(
177
+                new DefaultMutableTreeNode(l), componentNode,
178
+                listModel.getChildCount(componentNode)));
179
+    }
180
+
159 181
 }

Laden…
Abbrechen
Speichern