@@ -63,41 +63,6 @@ public String getTitle() {
63
63
}
64
64
65
65
66
- /*
67
- public String getPluralTitle() {
68
- switch (this) {
69
- case LIBRARY:
70
- return "Libraries";
71
- case MODE:
72
- return "Modes";
73
- case TOOL:
74
- return "Tools";
75
- case EXAMPLES:
76
- return "Examples";
77
- }
78
- return null; // should be unreachable
79
- }
80
- */
81
-
82
-
83
- // public String getFolderName() {
84
- // return toString();
85
- // /*
86
- // switch (this) {
87
- // case LIBRARY:
88
- // return "libraries";
89
- // case TOOL:
90
- // return "tools";
91
- // case MODE:
92
- // return "modes";
93
- // case EXAMPLES:
94
- // return "examples";
95
- // }
96
- // return null; // should be unreachable
97
- // */
98
- // }
99
-
100
-
101
66
/** Get the name of the properties file for this type of contribution. */
102
67
public String getPropertiesName () {
103
68
return this + ".properties" ;
@@ -109,42 +74,11 @@ public File createTempFolder() throws IOException {
109
74
}
110
75
111
76
112
- /*
113
- // removed for 4.0a6, doesn't appear to be in use
114
- public File[] listTempFolders() throws IOException {
115
- File base = getSketchbookFolder();
116
- return base.listFiles(new FileFilter() {
117
- @Override
118
- public boolean accept(File file) {
119
- String name = file.getName();
120
- return (file.isDirectory() &&
121
- name.startsWith(toString()) && name.endsWith("tmp"));
122
- }
123
- });
124
- }
125
- */
126
-
127
-
128
77
public boolean isTempFolderName (String name ) {
129
78
return name .startsWith (toString ()) && name .endsWith ("tmp" );
130
79
}
131
80
132
81
133
- // public String getTempPrefix() {
134
- // return toString();
135
- // }
136
- //
137
- //
138
- // public String getTempSuffix() {
139
- // return "tmp";
140
- // }
141
-
142
-
143
- // public String getPropertiesName() {
144
- // return toString() + ".properties";
145
- // }
146
-
147
-
148
82
static public ContributionType fromName (String s ) {
149
83
if (s != null ) {
150
84
if ("library" .equalsIgnoreCase (s )) {
@@ -239,20 +173,22 @@ LocalContribution load(Base base, File folder) {
239
173
}
240
174
241
175
242
- List <LocalContribution > listContributions (Editor editor ) {
176
+ List <LocalContribution > listContributions (Base base , Editor editor ) {
243
177
List <LocalContribution > contribs = new ArrayList <>();
244
178
switch (this ) {
245
179
case LIBRARY :
246
- contribs .addAll (editor .getMode ().contribLibraries );
180
+ if (editor != null ) {
181
+ contribs .addAll (editor .getMode ().contribLibraries );
182
+ }
247
183
break ;
248
184
case TOOL :
249
- contribs .addAll (editor . getBase () .getToolContribs ());
185
+ contribs .addAll (base .getToolContribs ());
250
186
break ;
251
187
case MODE :
252
- contribs .addAll (editor . getBase () .getModeContribs ());
188
+ contribs .addAll (base .getModeContribs ());
253
189
break ;
254
190
case EXAMPLES :
255
- contribs .addAll (editor . getBase () .getExampleContribs ());
191
+ contribs .addAll (base .getExampleContribs ());
256
192
break ;
257
193
}
258
194
return contribs ;
@@ -266,41 +202,11 @@ File getBackupFolder() {
266
202
267
203
File createBackupFolder (StatusPanel status ) {
268
204
File backupFolder = getBackupFolder ();
269
- // if (backupFolder.isDirectory()) {
270
- // status.setErrorMessage("First remove the folder named \"old\" from the " +
271
- // getFolderName() + " folder in the sketchbook.");
272
- // return null;
273
- // }
274
205
if (!backupFolder .exists () && !backupFolder .mkdirs ()) {
275
206
status .setErrorMessage ("Could not create a backup folder in the " +
276
207
"sketchbook " + this + " folder." );
277
208
return null ;
278
209
}
279
210
return backupFolder ;
280
211
}
281
-
282
-
283
- // /**
284
- // * Create a filter for a specific contribution type.
285
- // * @param type The type, or null for a generic update checker.
286
- // */
287
- // Contribution.Filter createFilter2() {
288
- // return new Contribution.Filter() {
289
- // public boolean matches(Contribution contrib) {
290
- // return contrib.getType() == ContributionType.this;
291
- // }
292
- // };
293
- // }
294
-
295
-
296
- // static Contribution.Filter createUpdateFilter() {
297
- // return new Contribution.Filter() {
298
- // public boolean matches(Contribution contrib) {
299
- // if (contrib instanceof LocalContribution) {
300
- // return ContributionListing.getInstance().hasUpdates(contrib);
301
- // }
302
- // return false;
303
- // }
304
- // };
305
- // }
306
212
}
0 commit comments