Lines 43-52
package org.netbeans.modules.apisupport.
Link Here
|
43 |
|
43 |
|
44 |
import java.io.File; |
44 |
import java.io.File; |
45 |
import java.io.IOException; |
45 |
import java.io.IOException; |
|
|
46 |
import java.net.MalformedURLException; |
47 |
import java.net.URL; |
46 |
import java.util.Collections; |
48 |
import java.util.Collections; |
47 |
import java.util.HashMap; |
49 |
import java.util.HashMap; |
48 |
import java.util.Map; |
50 |
import java.util.Map; |
49 |
import java.util.Set; |
51 |
import java.util.Set; |
|
|
52 |
import java.util.logging.Level; |
53 |
import java.util.logging.Logger; |
50 |
import org.netbeans.api.project.Project; |
54 |
import org.netbeans.api.project.Project; |
51 |
import org.netbeans.modules.apisupport.project.CreatedModifiedFiles; |
55 |
import org.netbeans.modules.apisupport.project.CreatedModifiedFiles; |
52 |
import org.netbeans.modules.apisupport.project.Util; |
56 |
import org.netbeans.modules.apisupport.project.Util; |
Lines 56-61
import org.openide.filesystems.FileObjec
Link Here
|
56 |
import org.openide.filesystems.FileObject; |
60 |
import org.openide.filesystems.FileObject; |
57 |
import org.openide.filesystems.FileSystem; |
61 |
import org.openide.filesystems.FileSystem; |
58 |
import org.openide.filesystems.FileUtil; |
62 |
import org.openide.filesystems.FileUtil; |
|
|
63 |
import org.openide.modules.SpecificationVersion; |
64 |
import org.openide.util.Exceptions; |
59 |
import org.openide.util.NbBundle; |
65 |
import org.openide.util.NbBundle; |
60 |
|
66 |
|
61 |
/** |
67 |
/** |
Lines 170-175
final class NewTCIterator extends BasicW
Link Here
|
170 |
final String name = model.getName(); |
176 |
final String name = model.getName(); |
171 |
final String packageName = model.getPackageName(); |
177 |
final String packageName = model.getPackageName(); |
172 |
final String mode = model.getMode(); |
178 |
final String mode = model.getMode(); |
|
|
179 |
|
180 |
boolean actionLessTC; |
181 |
try { |
182 |
SpecificationVersion current = model.getModuleInfo().getDependencyVersion("org.openide.windows"); |
183 |
actionLessTC = current.compareTo(new SpecificationVersion("6.24")) >= 0; // NOI18N |
184 |
} catch (IOException ex) { |
185 |
Logger.getLogger(NewTCIterator.class.getName()).log(Level.INFO, null, ex); |
186 |
actionLessTC = false; |
187 |
} |
188 |
|
173 |
|
189 |
|
174 |
Map<String,String> replaceTokens = new HashMap<String,String>(); |
190 |
Map<String,String> replaceTokens = new HashMap<String,String>(); |
175 |
replaceTokens.put("TEMPLATENAME", name);//NOI18N |
191 |
replaceTokens.put("TEMPLATENAME", name);//NOI18N |
Lines 189-197
final class NewTCIterator extends BasicW
Link Here
|
189 |
fil = null; |
205 |
fil = null; |
190 |
} |
206 |
} |
191 |
} |
207 |
} |
|
|
208 |
String relativeIconPath = null; |
192 |
if (fil != null) { |
209 |
if (fil != null) { |
193 |
FileObject fo = FileUtil.toFileObject(fil); |
210 |
FileObject fo = FileUtil.toFileObject(fil); |
194 |
String relativeIconPath = null; |
|
|
195 |
if (!FileUtil.isParentOf(Util.getResourceDirectory(project), fo)) { |
211 |
if (!FileUtil.isParentOf(Util.getResourceDirectory(project), fo)) { |
196 |
String iconPath = getRelativePath(moduleInfo.getResourceDirectoryPath(false), packageName, |
212 |
String iconPath = getRelativePath(moduleInfo.getResourceDirectoryPath(false), packageName, |
197 |
"", fo.getNameExt()); //NOI18N |
213 |
"", fo.getNameExt()); //NOI18N |
Lines 228-238
final class NewTCIterator extends BasicW
Link Here
|
228 |
name, "TopComponent.form"); //NOI18N |
244 |
name, "TopComponent.form"); //NOI18N |
229 |
template = CreatedModifiedFiles.getTemplate("templateTopComponent.form");//NOI18N |
245 |
template = CreatedModifiedFiles.getTemplate("templateTopComponent.form");//NOI18N |
230 |
fileChanges.add(fileChanges.createFileWithSubstitutions(tcFormName, template, replaceTokens)); |
246 |
fileChanges.add(fileChanges.createFileWithSubstitutions(tcFormName, template, replaceTokens)); |
231 |
|
247 |
|
232 |
final String actionName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, |
248 |
if (!actionLessTC) { |
233 |
name, "Action.java"); //NOI18N |
249 |
final String actionName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, |
234 |
template = CreatedModifiedFiles.getTemplate("templateAction.java");//NOI18N |
250 |
name, "Action.java"); //NOI18N |
235 |
fileChanges.add(fileChanges.createFileWithSubstitutions(actionName, template, replaceTokens)); |
251 |
template = CreatedModifiedFiles.getTemplate("templateAction.java");//NOI18N |
|
|
252 |
fileChanges.add(fileChanges.createFileWithSubstitutions(actionName, template, replaceTokens)); |
253 |
} |
236 |
|
254 |
|
237 |
final String settingsName = name + "TopComponent.settings"; //NOI18N |
255 |
final String settingsName = name + "TopComponent.settings"; //NOI18N |
238 |
template = CreatedModifiedFiles.getTemplate("templateSettings.xml");//NOI18N |
256 |
template = CreatedModifiedFiles.getTemplate("templateSettings.xml");//NOI18N |
Lines 242-251
final class NewTCIterator extends BasicW
Link Here
|
242 |
template = CreatedModifiedFiles.getTemplate("templateWstcref.xml");//NOI18N |
260 |
template = CreatedModifiedFiles.getTemplate("templateWstcref.xml");//NOI18N |
243 |
fileChanges.add(fileChanges.createLayerEntry("Windows2/Modes/" + mode + "/" + wstcrefName, // NOI18N |
261 |
fileChanges.add(fileChanges.createLayerEntry("Windows2/Modes/" + mode + "/" + wstcrefName, // NOI18N |
244 |
template, replaceTokens, null, null)); |
262 |
template, replaceTokens, null, null)); |
245 |
|
263 |
|
246 |
fileChanges.add(fileChanges.layerModifications(new CreateActionEntryOperation(name + "Action", packageName), // NOI18N |
264 |
String bundlePath = getRelativePath(moduleInfo.getResourceDirectoryPath(false), packageName, "", "Bundle.properties"); //NOI18N |
|
|
265 |
if (actionLessTC) { |
266 |
String path = "Actions/Window/" + packageName.replace('.','-') + "-" + name + "Action.instance"; // NOI18N |
267 |
{ |
268 |
Map<String,Object> attrs = new HashMap<String,Object>(); |
269 |
attrs.put("instanceCreate", "methodvalue:org.openide.windows.TopComponent.openAction"); // NOI18N |
270 |
attrs.put("component", "methodvalue:" + packageName + '.' + name + "TopComponent.findInstance"); // NOI18N |
271 |
if (relativeIconPath != null) { |
272 |
try { |
273 |
attrs.put("SystemFileSystem.icon", new URL("nbresloc://" + relativeIconPath)); // NOI18N |
274 |
} catch (MalformedURLException ex) { |
275 |
Exceptions.printStackTrace(ex); |
276 |
} |
277 |
} |
278 |
fileChanges.add( |
279 |
fileChanges.createLayerEntry( |
280 |
path, |
281 |
null, |
282 |
null, |
283 |
NbBundle.getMessage(NewTCIterator.class, "LBL_TemplateActionName", name), // NOI18N |
284 |
attrs |
285 |
) |
286 |
); |
287 |
} |
288 |
|
289 |
{ |
290 |
Map<String,Object> attrs = new HashMap<String,Object>(); |
291 |
attrs.put("originalFile", path); // NOI18N |
292 |
fileChanges.add( |
293 |
fileChanges.createLayerEntry( |
294 |
"Menu/Window/" + name + "Action.shadow", // NOI18N |
295 |
null, |
296 |
null, |
297 |
null, |
298 |
attrs |
299 |
) |
300 |
); |
301 |
} |
302 |
} else { |
303 |
fileChanges.add(fileChanges.layerModifications(new CreateActionEntryOperation(name + "Action", packageName), // NOI18N |
247 |
Collections.<String>emptySet())); |
304 |
Collections.<String>emptySet())); |
248 |
String bundlePath = getRelativePath(moduleInfo.getResourceDirectoryPath(false), packageName, "", "Bundle.properties"); //NOI18N |
305 |
} |
249 |
fileChanges.add(fileChanges.bundleKey(bundlePath, "CTL_" + name + "Action", // NOI18N |
306 |
fileChanges.add(fileChanges.bundleKey(bundlePath, "CTL_" + name + "Action", // NOI18N |
250 |
NbBundle.getMessage(NewTCIterator.class, "LBL_TemplateActionName", name))); //NOI18N |
307 |
NbBundle.getMessage(NewTCIterator.class, "LBL_TemplateActionName", name))); //NOI18N |
251 |
|
308 |
|