Java Code Examples for org.openide.filesystems.FileObject#getPath()
The following examples show how to use
org.openide.filesystems.FileObject#getPath() .
These examples are extracted from open source projects.
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 Project: minifierbeans File: Base64Decode.java License: Apache License 2.0 | 6 votes |
void decode() { InputOutput io = IOProvider.getDefault().getIO(Bundle.CTL_Base64Encode(), false); ImageUtil imageUtil = new ImageUtil(); try { FileObject file = context.getPrimaryFile(); if (file.getExt().equalsIgnoreCase("ENCODE")) { File newFile = new File(file.getPath()); String fileType = file.getName().substring(file.getName().lastIndexOf('.') + 1); imageUtil.decodeToImage(FileUtils.readFileToString(newFile), file.getParent().getPath() + File.separator + file.getName(), fileType); NotificationDisplayer.getDefault().notify("Image decoded successfully", NotificationDisplayer.Priority.NORMAL.getIcon(), "The decoding of the image was successful.", null); } else { NotificationDisplayer.getDefault().notify("Invalid file to decode", NotificationDisplayer.Priority.HIGH.getIcon(), String.format("The file '%s' is invalid. File must have an '.encode' extension.", file.getParent().getPath() + File.separator + file.getNameExt()), null); } } catch (IOException ex) { io.getOut().println("Exception: " + ex.toString()); } }
Example 2
Source Project: cakephp3-netbeans File: CakePHP3ModuleImpl.java License: Apache License 2.0 | 6 votes |
/** * Get a category for a file. * * @param fileObject a file * @return Category */ public Category getCategory(FileObject fileObject) { if (fileObject == null) { return Category.UNKNOWN; } Base base = getBase(fileObject); if (base == Base.UNKNOWN || base == Base.VENDOR) { return Category.UNKNOWN; } String path = fileObject.getPath(); // plugin String pluginName = ""; // NOI18N if (base == Base.PLUGIN) { pluginName = getPluginName(fileObject); } for (Category category : CATEGORIES) { Category c = getCategory(path, base, category, pluginName); if (c != Category.UNKNOWN) { return c; } } return Category.UNKNOWN; }
Example 3
Source Project: netbeans File: EntityResourcesGenerator.java License: Apache License 2.0 | 6 votes |
private FileObject getSourceRootFolder(FileObject packageFolder, String packageName) { String[] segments = packageName.split("\\."); // NOI18N FileObject ret = packageFolder; for (int i = segments.length - 1; i >= 0; i--) { String segment = segments[i]; if (segment.length() == 0) { return ret; } if (ret == null || !segments[i].equals(ret.getNameExt())) { throw new IllegalArgumentException("Unmatched folder: " + packageFolder.getPath() + " and package name: " + packageName); // NOI18N } ret = ret.getParent(); } return ret; }
Example 4
Source Project: netbeans File: SourcePathProviderImpl.java License: Apache License 2.0 | 6 votes |
/** * Returns source root for given ClassPath root as String, or <code>null</code>. */ public static String getRoot(FileObject fileObject) { File f = null; String path = ""; try { if (fileObject.getFileSystem () instanceof JarFileSystem) { f = ((JarFileSystem) fileObject.getFileSystem ()).getJarFile (); if (!fileObject.isRoot()) { path = "!/"+fileObject.getPath(); } } else { f = FileUtil.toFile (fileObject); } } catch (FileStateInvalidException ex) { } if (f != null) { return f.getAbsolutePath () + path; } else { return null; } }
Example 5
Source Project: netbeans File: FileStateManager.java License: Apache License 2.0 | 6 votes |
public void fileDataCreated (FileEvent fe) { FileObject mfo = file.get (); if (mfo != null && mfo.isValid ()) { String created = fe.getFile ().getPath(); String mfoname = mfo.getPath(); if (created.equals (mfoname)) { int layer; if (-1 != (layer = layerOfFile (fe.getFile ()))) attachNotifier (mfo, layer); rescan (mfo); } } else detachAllNotifiers (); }
Example 6
Source Project: netbeans File: BaseFileObjectTestHid.java License: Apache License 2.0 | 6 votes |
private static void deep(FileObject fo, int depth, StringBuilder sb, boolean path, Set<String> skipChildren) { if (depth-- == 0) { return; } sb.append(" "); String n; if (path) { n = fo.getPath(); } else { n = fo.getNameExt(); } if (n.length() > 1) { sb.append(n); } sb.append("\n"); for (FileObject ch : fo.getChildren()) { if (!skipChildren.contains(ch.getNameExt()) && !isRemoteFS(ch)) { deep(ch, depth, sb, path, Collections.<String>emptySet()); } } }
Example 7
Source Project: cakephp3-netbeans File: CakePHP3ModuleImpl.java License: Apache License 2.0 | 5 votes |
/** * Get a Base for a file. * * @param fileObject a file * @return a Base */ public Base getBase(FileObject fileObject) { if (fileObject == null) { return Base.UNKNOWN; } String path = fileObject.getPath(); for (Base base : Arrays.asList(Base.CORE, Base.VENDOR, Base.PLUGIN, Base.APP)) { List<FileObject> directories = getDirectories(base); for (FileObject directory : directories) { if (ModuleUtils.isChild(directory, path)) { if (base != Base.VENDOR) { return base; } // vendor plugin List<Pair<String, FileObject>> vendorPlugins = getVendorPlugins(); for (Pair<String, FileObject> vendorPlugin : vendorPlugins) { FileObject pluginDirectory = vendorPlugin.second(); if (ModuleUtils.isChild(pluginDirectory, path)) { return Base.PLUGIN; } } return base; } } } return Base.UNKNOWN; }
Example 8
Source Project: netbeans File: Env.java License: Apache License 2.0 | 5 votes |
/** find an entity registration according to passed provider * @param provider provider file object * @return entity file object */ public static FileObject findEntityRegistration(FileObject provider) { String filename = provider.getPath(); int i = filename.lastIndexOf('.'); if (i != -1 && i > filename.lastIndexOf('/')) { filename = filename.substring(0, i); } String resource = xmlEntitiesPrefix + filename.substring(xmlLookupsPrefix.length(), filename.length()); return FileUtil.getConfigFile(resource); }
Example 9
Source Project: netbeans File: ELDeclarationFinder.java License: Apache License 2.0 | 5 votes |
private static String getComparableString(AlternativeLocation loc) { DeclarationLocation location = loc.getLocation(); FileObject fileObject = location.getFileObject(); if (fileObject != null) { return String.valueOf(location.getOffset()) + fileObject.getPath(); } else { return String.valueOf(location.getOffset()); } }
Example 10
Source Project: MikuMikuStudio File: ConvertOgreBinaryMeshesAction.java License: BSD 2-Clause "Simplified" License | 5 votes |
public void scanDir(String dir2scan, boolean delete) { ProgressHandle handle = ProgressHandleFactory.createHandle("Convert Ogre Binary Files"); handle.start(); try { File zipDir = new File(dir2scan); String[] dirList = zipDir.list(); for (int i = 0; i < dirList.length; i++) { File f = new File(zipDir, dirList[i]); if (f.isDirectory()) { String filePath = f.getPath(); scanDir(filePath, delete); continue; } FileObject fobj = FileUtil.toFileObject(f); if (fobj.getExt().equalsIgnoreCase("mesh")||fobj.getExt().equalsIgnoreCase("skeleton")) { OgreXMLConvertOptions options = new OgreXMLConvertOptions(fobj.getPath()); options.setBinaryFile(true); OgreXMLConvert conv = new OgreXMLConvert(); conv.doConvert(options, handle); if (delete) { fobj.delete(); } } } } catch (Exception e) { Logger.getLogger(ConvertOgreBinaryMeshesAction.class.getName()).log(Level.SEVERE, "Error scanning directory", e); } finally { handle.finish(); } }
Example 11
Source Project: minifierbeans File: XMLMinify.java License: Apache License 2.0 | 5 votes |
private static void xmlMinify(DataObject context, String content, boolean notify) { MinifyProperty minifyProperty = MinifyProperty.getInstance(); MinifyUtil util = new MinifyUtil(); try { FileObject file = context.getPrimaryFile(); if (!util.isMinifiedFile(file.getName(), minifyProperty.getPreExtensionXML())) { String inputFilePath = file.getPath(); String outputFilePath; if (minifyProperty.isNewXMLFile() && minifyProperty.getPreExtensionXML() != null && !minifyProperty.getPreExtensionXML().trim().isEmpty()) { outputFilePath = file.getParent().getPath() + File.separator + file.getName() + minifyProperty.getPreExtensionXML() + "." + file.getExt(); } else { outputFilePath = inputFilePath; } MinifyFileResult minifyFileResult; if (content != null) { minifyFileResult = util.compressContent(inputFilePath, content, "text/xml-mime", outputFilePath, minifyProperty); } else { minifyFileResult = util.compress(inputFilePath, "text/xml-mime", outputFilePath, minifyProperty); } if (minifyProperty.isEnableOutputLogAlert() && notify) { NotificationDisplayer.getDefault().notify("Successful XML minification", NotificationDisplayer.Priority.NORMAL.getIcon(), String.format("Input XML Files Size: %s Bytes \n" + "After Minifying XML Files Size: %s Bytes \n" + "XML Space Saved %s%%", minifyFileResult.getInputFileSize(), minifyFileResult.getOutputFileSize(), minifyFileResult.getSavedPercentage()), null); } } } catch (HeadlessException | IOException ex) { Exceptions.printStackTrace(ex); } }
Example 12
Source Project: netbeans File: SnippetFileSystem.java License: Apache License 2.0 | 5 votes |
public SnippetFileSystem(FileObject projectRoot, FileObject configRoot, String projectFSPathPrefix, String configFSPathPrefix) throws IOException { super(new FileSystem[] { projectRoot.getFileSystem(), configRoot.getFileSystem() }); this.projectRoot = projectRoot; this.projectFileSystem = projectRoot.getFileSystem(); this.configFileSystem = configRoot.getFileSystem(); this.configRoot = configRoot; this.projectRootPath = projectRoot.getPath(); this.projectFSPrefix = projectFSPathPrefix; this.configFSPathPrefix = configFSPathPrefix; }
Example 13
Source Project: netbeans File: Accessor.java License: Apache License 2.0 | 5 votes |
public static String getPath( Task t ) { URL url = getURL(t); if( null != url ) { return url.toString(); } FileObject fo = getFile(t); return fo.getPath(); }
Example 14
Source Project: MikuMikuStudio File: ProjectAssetManager.java License: BSD 2-Clause "Simplified" License | 5 votes |
public String getAbsoluteAssetPath(String path) { if (folderNames.isEmpty()) { } else { for (Iterator<String> it = folderNames.iterator(); it.hasNext();) { FileObject string = project.getProjectDirectory().getFileObject(it.next() + "/" + path); if (string != null) { return string.getPath(); } } } return null; }
Example 15
Source Project: minifierbeans File: JSMinify.java License: Apache License 2.0 | 5 votes |
private static void jsMinify(DataObject context, String content, boolean notify) { MinifyProperty minifyProperty = MinifyProperty.getInstance(); MinifyUtil util = new MinifyUtil(); try { FileObject file = context.getPrimaryFile(); if (!util.isMinifiedFile(file.getName(), minifyProperty.getPreExtensionJS())) { String inputFilePath = file.getPath(); String outputFilePath; if (minifyProperty.isNewJSFile() && minifyProperty.getPreExtensionJS() != null && !minifyProperty.getPreExtensionJS().trim().isEmpty()) { outputFilePath = file.getParent().getPath() + File.separator + file.getName() + minifyProperty.getPreExtensionJS() + "." + file.getExt(); } else { outputFilePath = inputFilePath; } MinifyFileResult minifyFileResult; if (content != null) { minifyFileResult = util.compressContent(inputFilePath, content, "text/javascript", outputFilePath, minifyProperty); } else { minifyFileResult = util.compress(inputFilePath, "text/javascript", outputFilePath, minifyProperty); } if (minifyProperty.isEnableOutputLogAlert() && notify) { NotificationDisplayer.getDefault().notify("Successful JS minification", NotificationDisplayer.Priority.NORMAL.getIcon(), String.format("Input JS Files Size: %s Bytes \n" + "After Minifying JS Files Size: %s Bytes \n" + "JS Space Saved %s%%", minifyFileResult.getInputFileSize(), minifyFileResult.getOutputFileSize(), minifyFileResult.getSavedPercentage()), null); } } } catch (HeadlessException | IOException ex) { Exceptions.printStackTrace(ex); } }
Example 16
Source Project: cakephp3-netbeans File: CakePHP3ModuleImpl.java License: Apache License 2.0 | 5 votes |
/** * Get a category for a file. * * @param path a path * @param base Base * @param category Category * @param pluginName a plugin name * @return Category */ private Category getCategory(String path, Base base, Category category, String pluginName) { List<FileObject> directories = getDirectories(base, category, pluginName); for (FileObject directory : directories) { String categoryPath = directory.getPath(); if (path.startsWith(categoryPath + "/")) { // NOI18N return category; } } return Category.UNKNOWN; }
Example 17
Source Project: netbeans File: MimeTypesTracker.java License: Apache License 2.0 | 5 votes |
private void notifyRebuild(FileObject f) { String path = f.getPath(); if (path.startsWith(basePath)) { if (synchronous) rebuild(); else task.schedule(1000); } }
Example 18
Source Project: netbeans File: ModelElementImpl.java License: Apache License 2.0 | 5 votes |
public String getNormalizedName() { String filePath = ""; //NOI18N final FileObject fileObject = getFileObject(); if (fileObject != null) { filePath = fileObject.getPath(); } return getNamespaceName().append(QualifiedName.create(getName())).toString().toLowerCase() + String.valueOf(offsetRange.getStart()) + filePath; }
Example 19
Source Project: netbeans File: Page.java License: Apache License 2.0 | 4 votes |
public static String getFolderDisplayName(FileObject webFolder, String path, String fileNameExt) { String folderpath = webFolder.getPath(); return path.replaceFirst(folderpath + "/", "") + fileNameExt; }
Example 20
Source Project: netbeans File: MultiModuleNodeFactory.java License: Apache License 2.0 | 4 votes |
@Override public String id(FileObject obj) { return obj.getPath(); }