|
@@ -22,8 +22,8 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.ui.themes;
|
24
|
24
|
|
25
|
|
-import com.dmdirc.config.IdentityManager;
|
26
|
25
|
import com.dmdirc.config.InvalidIdentityFileException;
|
|
26
|
+import com.dmdirc.interfaces.IdentityController;
|
27
|
27
|
import com.dmdirc.logger.ErrorLevel;
|
28
|
28
|
import com.dmdirc.logger.Logger;
|
29
|
29
|
import com.dmdirc.util.io.ConfigFile;
|
|
@@ -34,11 +34,17 @@ import java.io.File;
|
34
|
34
|
import java.io.IOException;
|
35
|
35
|
import java.io.InputStream;
|
36
|
36
|
|
|
37
|
+import lombok.RequiredArgsConstructor;
|
|
38
|
+
|
37
|
39
|
/**
|
38
|
40
|
* Represents one theme file.
|
39
|
41
|
*/
|
|
42
|
+@RequiredArgsConstructor
|
40
|
43
|
public class Theme implements Comparable<Theme> {
|
41
|
44
|
|
|
45
|
+ /** The controller to add theme identities to. */
|
|
46
|
+ private final IdentityController identityController;
|
|
47
|
+
|
42
|
48
|
/** The file to load the theme from. */
|
43
|
49
|
private final File file;
|
44
|
50
|
|
|
@@ -54,15 +60,6 @@ public class Theme implements Comparable<Theme> {
|
54
|
60
|
/** The Identity we've registered. */
|
55
|
61
|
private ThemeIdentity identity;
|
56
|
62
|
|
57
|
|
- /**
|
58
|
|
- * Creates a new instance of Theme.
|
59
|
|
- *
|
60
|
|
- * @param file The file to load the theme from
|
61
|
|
- */
|
62
|
|
- public Theme(final File file) {
|
63
|
|
- this.file = file;
|
64
|
|
- }
|
65
|
|
-
|
66
|
63
|
/**
|
67
|
64
|
* Determines if this theme is valid or not (i.e., it is a valid zip file,
|
68
|
65
|
* and it contains one file).
|
|
@@ -85,9 +82,7 @@ public class Theme implements Comparable<Theme> {
|
85
|
82
|
|
86
|
83
|
try {
|
87
|
84
|
metadata.read();
|
88
|
|
- } catch (IOException ex) {
|
89
|
|
- metadata = null;
|
90
|
|
- } catch (InvalidConfigFileException ex) {
|
|
85
|
+ } catch (IOException | InvalidConfigFileException ex) {
|
91
|
86
|
metadata = null;
|
92
|
87
|
}
|
93
|
88
|
}
|
|
@@ -111,11 +106,8 @@ public class Theme implements Comparable<Theme> {
|
111
|
106
|
if (stream != null) {
|
112
|
107
|
try {
|
113
|
108
|
identity = new ThemeIdentity(stream, this);
|
114
|
|
- IdentityManager.getIdentityManager().registerIdentity(identity);
|
115
|
|
- } catch (InvalidIdentityFileException ex) {
|
116
|
|
- Logger.userError(ErrorLevel.MEDIUM, "Error loading theme identity file: "
|
117
|
|
- + ex.getMessage());
|
118
|
|
- } catch (IOException ex) {
|
|
109
|
+ identityController.registerIdentity(identity);
|
|
110
|
+ } catch (InvalidIdentityFileException | IOException ex) {
|
119
|
111
|
Logger.userError(ErrorLevel.MEDIUM, "Error loading theme identity file: "
|
120
|
112
|
+ ex.getMessage());
|
121
|
113
|
}
|
|
@@ -131,8 +123,7 @@ public class Theme implements Comparable<Theme> {
|
131
|
123
|
}
|
132
|
124
|
|
133
|
125
|
enabled = false;
|
134
|
|
-
|
135
|
|
- IdentityManager.getIdentityManager().unregisterIdentity(identity);
|
|
126
|
+ identityController.unregisterIdentity(identity);
|
136
|
127
|
}
|
137
|
128
|
|
138
|
129
|
/**
|