/** Creates a the pointbase menus for start/stop actions, dynamically * If we did that in the layer file, it would always be there. * Now the menu is optional... */ static void execute() { FileObject pbFolder = FileUtil.getConfigFile("Menu/Tools/PointbaseMenu"); //NOI18N if (pbFolder!=null){ return; } final FileObject ToolsFolder = FileUtil.getConfigFile("Menu/Tools");//NOI18N try { ToolsFolder.getFileSystem().runAtomicAction(new FileSystem.AtomicAction() { public void run() throws IOException { FileObject pointbaseFolder = ToolsFolder.createFolder("PointbaseMenu"); //NOI18N pointbaseFolder.setAttribute("SystemFileSystem.localizingBundle","org.netbeans.modules.j2ee.sun.ide.j2ee.db.Bundle");//NOI18N pointbaseFolder.createData("org.netbeans.modules.j2ee.sun.ide.j2ee.db.StartAction","instance");//NOI18N pointbaseFolder.createData("org.netbeans.modules.j2ee.sun.ide.j2ee.db.StopAction" ,"instance");//NOI18N ToolsFolder.setAttribute("OpenIDE-Folder-Order","org.netbeans.modules.j2ee.sun.ide.j2ee.db.StartAction.instance/org.netbeans.modules.j2ee.sun.ide.j2ee.db.StopAction.instance");//NOI18N } }); } catch (FileStateInvalidException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
private String classToSourceURL (FileObject fo, Log logger) { try { ClassPath cp = ClassPath.getClassPath (fo, ClassPath.EXECUTE); FileObject root = cp.findOwnerRoot (fo); String resourceName = cp.getResourceName (fo, '/', false); if (resourceName == null) { logger.info("Can not find classpath resource for "+fo+", skipping..."); return null; } int i = resourceName.indexOf ('$'); if (i > 0) resourceName = resourceName.substring (0, i); FileObject[] sRoots = SourceForBinaryQuery.findSourceRoots (root.getURL ()).getRoots (); ClassPath sourcePath = ClassPathSupport.createClassPath (sRoots); FileObject rfo = sourcePath.findResource (resourceName + ".java"); if (rfo == null) return null; return rfo.getURL ().toExternalForm (); } catch (FileStateInvalidException ex) { ex.printStackTrace (); return null; } }
imgResUrl = fo.getURL(); } catch (FileStateInvalidException e) { e.printStackTrace();