/** Methods that tells {@link Repository} subclasses to refresh list of * URLs provided by {@link LayerProvider}s. * @since 7.59 */ protected void refreshAdditionalLayers() { if (getDefaultFileSystem() instanceof MainFS) { ((MainFS)getDefaultFileSystem()).refreshLayers(); } }
/** * Executes atomic action. For more info see {@link FileSystem#runAtomicAction}. * <p> * All events about filesystem changes (related to events on all affected instances of <code>FileSystem</code>) * are postponed after the whole <code>atomicCode</code> * is executed. * </p> * @param atomicCode code that is supposed to be run as atomic action. See {@link FileSystem#runAtomicAction} * @throws java.io.IOException * @since 7.5 */ @SuppressWarnings("deprecation") public static final void runAtomicAction(final AtomicAction atomicCode) throws IOException { Repository.getDefault().getDefaultFileSystem().runAtomicAction(atomicCode); }
/** * Returns {@code FileObject} from the NetBeans default (system, configuration) * filesystem or {@code null} if does not exist. * If you wish to create the file/folder when it does not already exist, * start with {@link #getConfigRoot} and use {@link #createData(FileObject, String)} * or {@link #createFolder(FileObject, String)} methods. * @param path the path from the root of the NetBeans default (system, configuration) * filesystem delimited by '/' or empty string to get root folder. * @throws NullPointerException if the path is {@code null} * @return a {@code FileObject} for given path in the NetBeans default (system, configuration) * filesystem or {@code null} if does not exist * @since org.openide.filesystems 7.19 */ @SuppressWarnings("deprecation") public static FileObject getConfigFile(String path) { Parameters.notNull("path", path); //NOI18N return Repository.getDefault().getDefaultFileSystem().findResource(path); }
/** * Gets FileObject for passed url. * @param url * @return appropriate FileObject. Can return null for other protocol than nbfs or * if such FileObject isn't reachable via Repository. */ static FileObject getFileObject(URL url) { if (!url.getProtocol().equals(FileURL.PROTOCOL)) { return null; } if (isOldEncoding(url)) { return oldDecode(url); } String[] urlParts = split(url); String fsName = decodeFsPart(urlParts[0]); String foName = decodeFoPart(urlParts[1]); FileSystem fsys = fsName.equals(SYSTEM_FILE_SYSTEM_NAME) ? Repository.getDefault().getDefaultFileSystem() : Repository.getDefault().findFileSystem(fsName); return (fsys == null) ? null : fsys.findResource(foName); }
/** Returns <code>true</code> if the filesystem is default one of the IDE. * @see Repository#getDefaultFileSystem */ public final boolean isDefault () { return this == ExternalUtil.getRepository ().getDefaultFileSystem (); }
/** Returns <code>true</code> if the filesystem is default one of the IDE. * @see Repository#getDefaultFileSystem */ public final boolean isDefault () { return this == ExternalUtil.getRepository ().getDefaultFileSystem (); }
private void initCacheStore() { String userDir = System.getProperty("netbeans.user"); // NOI18N if (userDir != null) { cacheStore = new File(new File(new File (userDir, "var"), "cache"), DATA_DIRECTORY); // NOI18N } else { File cachedir = FileUtil.toFile(org.openide.filesystems.Repository.getDefault().getDefaultFileSystem().getRoot()); cacheStore = new File(cachedir, DATA_DIRECTORY); } cacheStore.mkdirs(); } }
private static URL recreateURL(String fileName, String fileSystem, FileSystem fs) throws IOException { if (fileSystem == null) { return createURL(fs, fileName); } else if (fileSystem.equals("SystemFileSystem")) { return createURL(Repository.getDefault().getDefaultFileSystem(), fileName); } else { // Does not work. No FS is mounted anymore. throw new java.io.FileNotFoundException (fileName+" "+fileSystem); //NOI18N } } private static URL createURL(FileSystem fs, String fileName) throws IOException {
public boolean isSupported (String mimeType) { FileSystem fs = Repository.getDefault ().getDefaultFileSystem (); return fs.findResource ("Editors/" + mimeType + "/language.nbs") != null; }
private DataFolder getRecentFolder () { if (recentListFolder == null) { FileObject fo = Repository.getDefault ().getDefaultFileSystem (). findResource ("Templates/Recent"); // NOI18N if (fo != null) { recentListFolder = DataFolder.findFolder(fo); } } return recentListFolder; }
public boolean createDataObjectFor (String mimeType) { if(!isSupported(mimeType)) { return false; } FileSystem fs = Repository.getDefault ().getDefaultFileSystem (); FileObject fo = fs.findResource ("Editors/" + mimeType); if (fo == null) return false; Boolean b = (Boolean) fo.getAttribute ("createDataObject"); if (b == null) return true; return b.booleanValue (); }
protected FileObject findPrimaryFile (FileObject fo) { FileSystem fs = null; try { fs = fo.getFileSystem (); } catch (FileStateInvalidException e) { return null; } if (fs != Repository.getDefault ().getDefaultFileSystem ()) { return null; } return super.findPrimaryFile (fo); }
private void bEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bEditActionPerformed String mimeType = (String) lFiles.getSelectedValue (); if (mimeType == null) return; FileObject fileObject = Repository.getDefault ().getDefaultFileSystem ().findResource ("Editors/" + mimeType + "/language.nbs"); try { DataObject dataObject = DataObject.find (fileObject); OpenCookie openCookie = dataObject.getCookie (OpenCookie.class); openCookie.open (); } catch (DataObjectNotFoundException ex) { Exceptions.printStackTrace (ex); } }//GEN-LAST:event_bEditActionPerformed
private static int findPositionOfDefaultPopupAction(String name, int fallback) { FileObject f = Repository.getDefault().getDefaultFileSystem().findResource("Editors/Popup/" + name); if (f != null) { Object pos = f.getAttribute("position"); if (pos instanceof Integer) { return (Integer) pos; } } return fallback; }
@Override protected boolean reloadStream() { FileObject fo = Repository.getDefault().getDefaultFileSystem().getRoot().getFileObject(FILENAME); boolean prevExists = lastTimeExists; lastTimeExists = fo != null; return ((fo == null && prevExists) || (fo != null && fo.lastModified().after(lastModified))); } }
private static DataFolder getDataFolder(String folderPath) { FileObject fileObject = Repository.getDefault().getDefaultFileSystem().findResource(folderPath); if (fileObject == null) { return null; } return DataFolder.findFolder(fileObject); }
private static String getBundleName(Language l) { FileSystem fs = Repository.getDefault().getDefaultFileSystem(); FileObject root = fs.findResource("Editors/" + l.getMimeType()); // NOI18N Object attrValue = root.getAttribute("SystemFileSystem.localizingBundle"); //NOI18N // [PENDING] if (bundleName == null) ... check for bundle name in nbs file return (String) attrValue; }
/** Getter for the folder with templates. * @return the folder with templates that should be used as root */ public DataFolder getTemplatesFolder () { DataFolder df = templatesFolder; if (df == null) { FileObject fo = Repository.getDefault ().getDefaultFileSystem ().findResource ("/Templates"); // NOI18N if (fo != null && fo.isFolder ()) { return DataFolder.findFolder (fo); } } return df; }
public LanguagesDataNode(LanguagesDataObject obj) { super(obj, Children.LEAF); String mimeType = obj.getPrimaryFile ().getMIMEType (); FileObject fo = Repository.getDefault ().getDefaultFileSystem (). findResource ("Editors/" + mimeType + "/language.nbs"); String icon = (String) fo.getAttribute ("icon"); if (icon == null) icon = "org/netbeans/modules/languages/resources/defaultIcon.png"; setIconBaseWithExtension (icon); }
public Node.Cookie getCookie (Class clazz) { if (clazz == org.openide.nodes.Index.class || clazz == Index.class) { //#33130 - enable IndexCookie only on SystemFileSystem try { if (DataFolder.this.getPrimaryFile().getFileSystem() == Repository.getDefault().getDefaultFileSystem()) { return new Index (DataFolder.this, this); } } catch (FileStateInvalidException ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } } return super.getCookie (clazz); }