Refine search
private void createIndexJSP(FileObject targetFolder, String name ) throws IOException { final FileObject jspTemplate = FileUtil.getConfigFile( "Templates/JSP_Servlet/JSP.jsp" ); // NOI18N if (jspTemplate == null) { return; // Don't know the template } final DataObject mt = DataObject.find(jspTemplate); final DataFolder webDf = DataFolder.findFolder(targetFolder); mt.createFromTemplate(webDf, name); // NOI18N } }
private static FileObject getFileObjectFromNode(Node node) { DataObject dobj = node.getLookup().lookup(DataObject.class); return dobj != null ? dobj.getPrimaryFile() : null; }
private static EditorCookie getEditorCookie(FileObject fo) throws IOException { DataObject dataObject = DataObject.find(fo); EditorCookie result = dataObject.getCookie(EditorCookie.class); if (result == null) { throw new IllegalStateException("File " + fo + " does not have an EditorCookie."); } return result; }
public Icon getIcon() { try { return new ImageIcon(DataObject.find(fo).getNodeDelegate().getIcon(BeanInfo.ICON_COLOR_16x16)); } catch (DataObjectNotFoundException ex) { return null; } }
protected void performAction(Node[] activatedNodes) { final GrailsPlatform runtime = GrailsPlatform.getDefault(); if (!runtime.isConfigured()) { ConfigurationSupport.showConfigurationWarning(runtime); return; } DataObject dataObject = activatedNodes[0].getLookup().lookup(DataObject.class); GrailsProject prj = (GrailsProject) FileOwnerQuery.getOwner(dataObject.getFolder().getPrimaryFile()); FileObject domainDir = prj.getProjectDirectory().getFileObject(DOMAIN_DIR); if (domainDir == null) { return; } String relativePath = FileUtil.getRelativePath(domainDir, dataObject.getPrimaryFile()); if (relativePath == null) { return; } // replace slashes and cut off the extension StringBuilder builder = new StringBuilder(relativePath.replace('/', '.')); // NOI18N builder.setLength(builder.length() - dataObject.getPrimaryFile().getNameExt().length()); builder.append(dataObject.getPrimaryFile().getName()); ProjectInformation inf = prj.getLookup().lookup(ProjectInformation.class); String displayName = inf.getDisplayName() + " (" + command + ")"; // NOI18N Callable<Process> callable = ExecutionSupport.getInstance().createSimpleCommand( command, GrailsProjectConfig.forProject(prj), builder.toString()); // NOI18N ExecutionDescriptor descriptor = prj.getCommandSupport().getDescriptor(command); ExecutionService service = ExecutionService.newService(callable, descriptor, displayName); service.run(); }
protected Node[] createNodes(Node n) { DataObject dobj = (DataObject) n.getLookup().lookup(DataObject.class); if (dobj != null) { FileObject fobj = dobj.getPrimaryFile(); if (fobj.isFolder() && fobj.getNameExt().equals("nbproject") && fobj.getFileObject("project.xml") != null) { // It is the NetBeans project folder, ignore it. return new Node[0]; } ModelCookie cookie = (ModelCookie) dobj.getCookie(ModelCookie.class); String fname = fobj.getNameExt(); String ext = decorator.getDocumentType().toString(); if (fobj.isFolder() || cookie != null && fname.endsWith(ext)) { return super.createNodes(n); } } return new Node[0]; }
public java.lang.String[] getTags () { ArrayList<String> list = new ArrayList<String> (6); Lookup.Result<org.openide.awt.HtmlBrowser.Factory> r = Lookup.getDefault().lookupResult(org.openide.awt.HtmlBrowser.Factory.class); for (Lookup.Item<org.openide.awt.HtmlBrowser.Factory> i: r.allItems()) { list.add(i.getDisplayName()); FileObject fo = FileUtil.getConfigFile (BROWSER_FOLDER); if (fo != null) { DataFolder folder = DataFolder.findFolder (fo); DataObject [] dobjs = folder.getChildren (); for (int i = 0; i<dobjs.length; i++) { if (Boolean.TRUE.equals(dobjs[i].getPrimaryFile().getAttribute(EA_HIDDEN)) || dobjs[i].getCookie(InstanceCookie.class) == null) { FileObject fo2 = dobjs[i].getPrimaryFile(); String n = fo2.getName(); try { n = fo2.getFileSystem().getStatus().annotateName(n, dobjs[i].files()); } catch (FileStateInvalidException e) {
/** * This finally produces the java platform's XML that represents the basic * platform's properties. The XML is returned in the resulting Set. * @return singleton Set with java platform's instance DO inside. */ public java.util.Set instantiate() throws IOException { //Workaround #44444 this.detectPanel.storeSettings (this.wizard); CDCPlatform newPlatform = getPlatform(); final String systemName = platform.getAntName(); FileObject platformsFolder = FileUtil.getConfigFile( "Services/Platforms/org-netbeans-api-java-Platform"); //NOI18N if (platformsFolder.getFileObject(systemName,"xml")!=null) { //NOI18N String msg = NbBundle.getMessage(CDCWizardIterator.class,"ERROR_InvalidName"); throw (IllegalStateException)ErrorManager.getDefault().annotate( new IllegalStateException(msg), ErrorManager.USER, null, msg,null, null); } DataObject dobj = PlatformConvertor.create(newPlatform, DataFolder.findFolder(platformsFolder),systemName); JavaPlatform platform = (JavaPlatform) dobj.getNodeDelegate().getLookup().lookup(JavaPlatform.class); return Collections.singleton(platform); }
@Override protected boolean enable(Node[] activatedNodes) { if (activatedNodes.length == 0) { return false; } DataObject dataObject = activatedNodes[0].getLookup().lookup(DataObject.class); if (dataObject == null || dataObject.getFolder() == null) { return false; } Project prj = FileOwnerQuery.getOwner(dataObject.getFolder().getPrimaryFile()); if (prj == null) { return false; } FileObject domainDir = prj.getProjectDirectory().getFileObject(DOMAIN_DIR); if (domainDir == null) { return false; } return FileUtil.isParentOf(domainDir, dataObject.getPrimaryFile()); } }
@Override protected Pane createPane() { // if there is a CndPaneProvider, us it CndPaneProvider paneProvider = Lookup.getDefault().lookup(CndPaneProvider.class); if (paneProvider != null) { Pane pane = paneProvider.createPane(this); if (pane != null) { return pane; } } return (CloneableEditorSupport.Pane) MultiViews.createCloneableMultiView(getDataObject().getPrimaryFile().getMIMEType(), getDataObject()); }
public void actionPerformed( ActionEvent e ) { String command = e.getActionCommand(); if ( COMMAND_SELECT.equals( command ) ) { Node selection[] = browsePanel.getExplorerManager().getSelectedNodes(); if ( selection != null && selection.length > 0 ) { DataObject dobj = (DataObject)selection[0].getLookup().lookup( DataObject.class ); if ( dobj != null ) { FileObject fo = dobj.getPrimaryFile(); if ( fo.isFolder() ) { result = fo; } } } } }
private EditorCookie getEditorCookie(TmpLocalFile tmpFile) throws IOException { FileObject fileObject = FileUtil.toFileObject(new File(tmpFile.getAbsolutePath())); assert fileObject != null : "Fileobject for tmp local file not found: " + tmpFile; DataObject dataObject = DataObject.find(fileObject); return dataObject.getLookup().lookup(EditorCookie.class); }
public ContextAction(Lookup context) { super(NbBundle.getMessage(BowerInstallAction.class, "CTL_BowerInstallAction")); Project p = context.lookup(Project.class); if (p!=null) { bower_json = p.getProjectDirectory().getFileObject("bower.json");//NOI18N } else { DataObject dob = context.lookup(DataObject.class); bower_json = dob.getPrimaryFile(); } setEnabled(bower_json!=null); putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true); }
private static boolean isDuplicateEnabled(Node[] nodes) { // It has not much sense to duplicate non-editable templates. // Thus using the same condition: if (nodes != null && nodes.length == 1 && nodes [0].isLeaf ()) { Node n = nodes[0]; DataObject dobj = n.getLookup().lookup(DataObject.class); assert dobj != null : "DataObject for node " + n; FileObject fo = dobj.getPrimaryFile (); return fo.canRevert() || fo.getSize () > 0; } else { return false; } }
@Override public String getDisplayName() { if (isTopLevelNode) { String s = NbBundle.getMessage(SiteDocsNode.class, "LBL_Site_Pages"); DataObject dob = getOriginal().getLookup().lookup(DataObject.class); FileObject file = dob.getPrimaryFile(); try { s = file.getFileSystem().getStatus().annotateName(s, Collections.singleton(file)); } catch (FileStateInvalidException e) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); } return s; } return getOriginal().getDisplayName(); }
private static FileObject getFileObjectFromNode(Node node) { DataObject dO; DataFolder df; dO = node.getLookup().lookup(DataObject.class); if (null != dO) { return dO.getPrimaryFile(); } df = node.getLookup().lookup(DataFolder.class); if (null != df) { return df.getPrimaryFile(); } return null; }
public void doRefactoringBypass() throws IOException { DataObject dob = null; if (byPassFolder != null) { dob = DataFolder.findFolder(byPassFolder); } else { dob = DataObject.find(refactoring.getRefactoringSource().lookup(FileObject.class)); } dob.rename(getPanelName()); } }
@Override public void destroy() throws IOException { if (parent != null) { for (DataObject d = getLookup().lookup(DataObject.class); d != null && FileUtil.isParentOf(parent.getPrimaryFile(), d.getPrimaryFile()); d = d.getFolder()) { d.delete(); } } else { super.destroy(); } }