Java Code Examples for org.openide.filesystems.FileObject#isFolder()
The following examples show how to use
org.openide.filesystems.FileObject#isFolder() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GsfTaskProvider.java From netbeans with Apache License 2.0 | 6 votes |
private synchronized void refreshImpl (FileObject file) { LOG.log(Level.FINE, "refresh: {0}", file); //NOI18N if (scope == null || callback == null) return ; //nothing to refresh if (!scope.isInScope(file)) { if (!file.isFolder()) return; //the given file may be a parent of some file that is in the scope: for (FileObject inScope : scope.getLookup().lookupAll(FileObject.class)) { if (FileUtil.isParentOf(file, inScope)) { enqueue(new Work(inScope, callback)); } } return ; } LOG.log(Level.FINE, "enqueing work for: {0}", file); //NOI18N enqueue(new Work(file, callback)); }
Example 2
Source File: Watcher.java From netbeans with Apache License 2.0 | 6 votes |
final void register(final FileObject fo) { if (fo.isValid() && !fo.isFolder()) { LOG.log(Level.INFO, "Should be a folder: {0} data: {1} folder: {2} valid: {3}", new Object[]{fo, fo.isData(), fo.isFolder(), fo.isValid()}); } try { clearQueue(); } catch (IOException ex) { LOG.log(Level.INFO, "Exception while clearing the queue", ex); } FileChangedManager.waitNowAndRun(new Runnable() { @Override public void run() { registerSynchronized(fo); } }); }
Example 3
Source File: RenameRefactoringUI.java From netbeans with Apache License 2.0 | 6 votes |
private RenameRefactoringUI(FileObject fileObject, String newName, TreePathHandle handle, CompilationInfo info) { if (handle!=null) { this.refactoring = new RenameRefactoring(Lookups.fixed(fileObject, handle)); Element element = handle.resolveElement(info); if (UIUtilities.allowedElementKinds.contains(element.getKind())) { this.elementHandle = ElementHandle.create(element); } } else { this.refactoring = new RenameRefactoring(Lookups.fixed(fileObject)); } this.newName = newName; this.oldName = fileObject.isFolder()? fileObject.getNameExt() : fileObject.getName(); ClasspathInfo cpInfo = handle==null?JavaRefactoringUtils.getClasspathInfoFor(fileObject):RefactoringUtils.getClasspathInfoFor(handle); this.refactoring.getContext().add(cpInfo); this.fromListener = true; }
Example 4
Source File: LicenseHeaderPanelProvider.java From netbeans with Apache License 2.0 | 6 votes |
@Override public FileObject resolveProjectLocation(String path) { if ("".equals(path)) { return null; } try { String eval = PluginPropertyUtils.createEvaluator(project).evaluate(path).toString(); FileObject toRet = FileUtil.toFileObject(FileUtilities.resolveFilePath(handle.getProject().getBasedir(), eval)); if (toRet != null && toRet.isFolder()) { toRet = null; } return toRet; } catch (ExpressionEvaluationException ex) { Exceptions.printStackTrace(ex); } return null; }
Example 5
Source File: PackageDisplayUtils.java From netbeans with Apache License 2.0 | 6 votes |
/** * Check whether a package should be displayed. * It should be displayed if {@link VisibilityQuery} says it should be, * and it is either completely empty, or contains files (as opposed to * containing some subpackages but no files). */ public static boolean isSignificant(FileObject pkg) throws IllegalArgumentException { if (!pkg.isFolder()) { throw new IllegalArgumentException("Not a folder"); // NOI18N } // XXX consider using group.contains() here if (!VisibilityQuery.getDefault().isVisible(pkg)) { return false; } FileObject[] kids = pkg.getChildren(); boolean subpackages = false; for (int i = 0; i < kids.length; i++) { if (!VisibilityQuery.getDefault().isVisible(kids[i])) { continue; } if (kids[i].isData()) { return true; } else { subpackages = true; } } return !subpackages; }
Example 6
Source File: Nodes.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected Node copyNode(final Node originalNode) { FileObject file = originalNode.getLookup().lookup(FileObject.class); if (file.isFolder()) { return new DummyNode(originalNode, new DummyChildren(originalNode, filter)); } return new DummyNode(originalNode); }
Example 7
Source File: TreeRootNode.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected Node copyNode(final Node originalNode) { final FileObject fo = originalNode.getLookup().lookup(FileObject.class); if (fo.isFolder()) { return new PackageFilterNode(originalNode); } else { return super.copyNode(originalNode); } }
Example 8
Source File: RunSeleniumAction.java From netbeans with Apache License 2.0 | 5 votes |
private RunSeleniumAction(Lookup actionContext) { activatedFOs = lookupSeleniumTestOnly(actionContext); if(activatedFOs != null) { if(activatedFOs.length == 1) { if(activatedFOs[0].isData()) { putValue(Action.NAME, Bundle.SeleniumTestFileAction_name()); } else if(activatedFOs[0].isFolder()) { putValue(Action.NAME, Bundle.RunSeleniumTestsAction_name()); } } else { boolean onlyFiles = true; for (int i = 0; i < activatedFOs.length; i++) { FileObject activatedFO = activatedFOs[i]; if (activatedFO.isFolder()) { onlyFiles = false; break; } } if (onlyFiles) { putValue(Action.NAME, Bundle.SeleniumTestFilesAction_name()); } else { putValue(Action.NAME, Bundle.RunSeleniumTestsAction_name()); } } } putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true); setEnabled(activatedFOs != null); }
Example 9
Source File: FileChangeListener.java From editorconfig-netbeans with MIT License | 5 votes |
private boolean isCandidateForProcessing(FileEvent event) { FileObject file = event.getFile(); boolean applyRules = false; boolean isntFolder = !file.isFolder(); boolean isUnexpected = !event.isExpected(); boolean isntSkipped = !SmartSkip.skipDirectory(file); if (isUnexpected && isntFolder && isntSkipped) { applyRules = true; } return applyRules; }
Example 10
Source File: CommonTestsCfgOfCreate.java From netbeans with Apache License 2.0 | 5 votes |
@NbBundle.Messages({ "# {0} - folder", "MSG_NoTestTarget_Fo=Unable to locate test package folders for folder {0}. The project must contain a test package folder to create tests. You can designate test package folders for your project in the Sources pane of the project Properties dialog.", "# {0} - file", "MSG_NoTestTarget_Fi=Unable to locate test package folder for file {0}. The project must contain a test package folder to create tests. You can designate test package folders for your project in the Sources pane of the project Properties dialog." }) private void setupLocationChooser(FileObject refFileObject) { Object[] targetFolders = null; if (testCreatorConfiguration != null) { targetFolders = testCreatorConfiguration.getTestSourceRoots(createdSourceRoots, refFileObject); } if (targetFolders != null && targetFolders.length != 0) { hasTargetFolders = true; cboxLocation.setModel(new DefaultComboBoxModel(targetFolders)); cboxLocation.setRenderer(new LocationChooserRenderer()); setMessage(null, MSG_TYPE_NO_TARGET_FOLDERS); } else { hasTargetFolders = false; if(testingFrameworks != null) { //PENDING - message text: String msgNoTargetsFound = refFileObject.isFolder()? Bundle.MSG_NoTestTarget_Fo(refFileObject.getNameExt()) : Bundle.MSG_NoTestTarget_Fi(refFileObject.getNameExt()); setMessage(msgNoTargetsFound, MSG_TYPE_NO_TARGET_FOLDERS); // do not disable all components as user might want to select a different testing provider // disableComponents(); } } }
Example 11
Source File: BaseEEModuleImpl.java From netbeans with Apache License 2.0 | 5 votes |
@Override public J2eeModule.RootedEntry next() { FileObject f = ch.get(0); ch.remove(0); if (f.isFolder()) { f.refresh(); for (FileObject fo : f.getChildren()) { ch.add(fo); } } return new FSRootRE(root, f); }
Example 12
Source File: FSCompletionUtils.java From netbeans with Apache License 2.0 | 5 votes |
@Override public boolean accept(FileObject file) { if (file.equals(currentFile) || isNbProjectMetadata(file)) { return false; //do not include self in the cc result } if (file.isFolder()) { return true; } String mimeType = FileUtil.getMIMEType(file); return mimeType != null && mimeType.startsWith("text/"); //NOI18N }
Example 13
Source File: TestUtil.java From netbeans with Apache License 2.0 | 5 votes |
static void copyFolder(FileObject source, FileObject dest) throws IOException { for (FileObject child : source.getChildren()) { if (child.isFolder()) { FileObject created = FileUtil.createFolder(dest, child.getNameExt()); copyFolder(child, created); } else { FileUtil.copyFile(child, dest, child.getName(), child.getExt()); } } }
Example 14
Source File: DataEditorSupportMoveTest.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected FileObject findPrimaryFile(FileObject fo) { if (!fo.isFolder()) { // here is the common code for the worse behaviour if (fo.hasExt("prima")) { return FileUtil.findBrother(fo, "seconda") != null ? fo : null; } if (fo.hasExt("seconda")) { return FileUtil.findBrother(fo, "prima"); } } return null; }
Example 15
Source File: NodeJsElement.java From netbeans with Apache License 2.0 | 4 votes |
@Override public String getName() { FileObject fo = getFileObject(); return fo.isFolder() ? fo.getNameExt() : fo.getName(); }
Example 16
Source File: J2SEPlatformDefaultJavadocImpl.java From netbeans with Apache License 2.0 | 4 votes |
@NonNull Collection<? extends URI> accept(@NonNull FileObject fo) { if (fo.canRead()) { if (fo.isFolder()) { if ("docs".equals(fo.getName())) { //NOI18N return Collections.singleton(fo.toURI()); } } else if (fo.isData()) { final String nameExt = fo.getNameExt(); final String vendorPath = VENDOR_DOCS.get(nameExt); if (vendorPath != null) { if (FileUtil.isArchiveFile(fo)) { try { return Collections.singleton( new URL (FileUtil.getArchiveRoot(fo.toURL()).toExternalForm() + vendorPath).toURI()); } catch (MalformedURLException | URISyntaxException e) { LOG.log( Level.INFO, "Invalid Javadoc URI for file : {0}, reason: {1}", new Object[]{ FileUtil.getFileDisplayName(fo), e.getMessage() }); //pass } } } else if (DOCS_FILE_PATTERN.matcher(nameExt).matches() && !JAVAFX_FILE_PATTERN.matcher(nameExt).matches()) { final FileObject root = FileUtil.getArchiveRoot(fo); if (root != null) { final List<URI> roots = new ArrayList<>(DOCS_PATHS.size()); for (String path : DOCS_PATHS) { final FileObject docRoot = root.getFileObject(path); if (docRoot != null) { roots.add(docRoot.toURI()); } } return Collections.unmodifiableCollection(roots); } } } } return Collections.emptySet(); }
Example 17
Source File: CakePHP3ModuleDefault.java From cakephp3-netbeans with Apache License 2.0 | 4 votes |
private FileObject getControllerOrViewCell(FileObject template, boolean isController, boolean forceApp) { if (template == null || template.isFolder()) { return null; } Category category = getCategory(template); if (isController) { if (category != Category.TEMPLATE) { return null; } } else { if (category != Category.TEMPLATE_CELL) { return null; } } Base base = getBase(template); // plugin String pluginName = ""; // NOI18N if (base == Base.PLUGIN) { pluginName = getPluginName(template); } List<FileObject> directories = getDirectories(base, category, pluginName); for (FileObject directory : directories) { String relativeFilePath = FileUtil.getRelativePath(directory, template); if (StringUtils.isEmpty(relativeFilePath)) { continue; } String relativeSubpath = relativeFilePath.replace(template.getNameExt(), ""); // NOI18N if (relativeSubpath.endsWith("/")) { // NOI18N relativeSubpath = relativeSubpath.substring(0, relativeSubpath.length() - 1); } Category c = category == Category.TEMPLATE ? Category.CONTROLLER : Category.VIEW_CELL; String controllerFilePath = toPhpFileName(c, relativeSubpath); if (forceApp) { base = Base.APP; pluginName = null; } FileObject controllerOrViewCell = getFile(base, c, controllerFilePath, pluginName); if (controllerOrViewCell != null) { return controllerOrViewCell; } } return null; }
Example 18
Source File: DefaultPlugin.java From netbeans with Apache License 2.0 | 3 votes |
/** * Determines whether annotations should be used in test classes in the * given folder when generating the given type of TestNG tests. * If annotations are supported, adds this information to the map of * template parameters. * * @param testFolder target folder for generated test classes * @param templateParams map of template params to store * the information to * @return {@code true} if it was detected that annotations are supported; * {@code false} otherwise */ private static boolean setAnnotationsSupport( FileObject testFolder, Map<String, Boolean> templateParams) { if (!testFolder.isFolder()) { throw new IllegalArgumentException("not a folder"); //NOI18N } templateParams.put(templatePropUseAnnotations, true); return true; }
Example 19
Source File: ImportantFilesNode.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 3 votes |
public Lookup createAdditionalLookup(Lookup lookup) { Project prj = lookup.lookup(Project.class); //create node if lookup has important files node FileObject folder = prj.getProjectDirectory().getFileObject("mobile"); if (folder != null && folder.isFolder()) { return Lookups.fixed(new ImportantFilesLookupItem(prj)); } return Lookups.fixed(); }
Example 20
Source File: JspCompileUtil.java From netbeans with Apache License 2.0 | 2 votes |
/** Finds a relative context path between rootFolder and relativeObject. * Similar to <code>FileUtil.getRelativePath(FileObject, FileObject)</code>, only * different slash '/' conventions. * @return relative context path between rootFolder and relativeObject. The returned path * always starts with a '/'. It ends with a '/' if the relative object is a directory. * @exception IllegalArgumentException if relativeObject is not in rootFolder's tree. */ public static String findRelativeContextPath(FileObject rootFolder, FileObject relativeObject) { String result = "/" + FileUtil.getRelativePath(rootFolder, relativeObject); // NOI18N return relativeObject.isFolder() ? (result + "/") : result; // NOI18N }