Java Code Examples for org.openide.filesystems.FileObject#canRevert()
The following examples show how to use
org.openide.filesystems.FileObject#canRevert() .
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: LayersBridge.java From netbeans with Apache License 2.0 | 6 votes |
/** * Custom profile is present if: * a/ the profile's folder can be reverted (=> was materialized on writable layer) * b/ there's no "reveal" entry for it in its parent => was not present * @param profileName * @return C */ public boolean isCustomProfile(String profileName) { DataFolder profileFolder = getExistingProfile(profileName); if (profileFolder == null) { return true; } FileObject f = profileFolder.getPrimaryFile(); if (!f.canRevert()) { return false; } FileObject parentF = profileFolder.getPrimaryFile().getParent(); if (parentF == null) { // very very unlikely return true; } Collection<FileObject> col = (Collection<FileObject>)parentF.getAttribute("revealEntries"); if (col == null) { return true; } for (FileObject f2 : col) { if (f2.getNameExt().equals(profileName)) { return false; } } return true; }
Example 2
Source File: ShortcutWizard.java From netbeans with Apache License 2.0 | 5 votes |
private static void delete(FileObject file) throws IOException { // cf. #162526 if (file.canRevert()) { file.revert(); } else { throw new IOException("Could not delete " + file); } }
Example 3
Source File: LayersBridge.java From netbeans with Apache License 2.0 | 5 votes |
/** * Returns instance of GlobalAction encapsulating action, or null. */ private GlobalAction createAction (DataObject dataObject, String prefix, String name, boolean ignoreUserRemoves) { InstanceCookie ic = dataObject.getCookie(InstanceCookie.class); // handle any non-IC file as instruction to remove the action FileObject pf = dataObject.getPrimaryFile(); if (ignoreUserRemoves && pf.canRevert()) { return null; } if (ic == null) { if (!EXT_REMOVED.equals(pf.getExt())) { LOG.log(Level.WARNING, "Invalid shortcut: {0}", dataObject); return null; } // ignore the 'remove' file, if there's a shadow (= real action) present if (FileUtil.findBrother(pf, "shadow") != null) { // handle redefinition + removal: ignore the removal. return null; } return REMOVED; } try { Object action = ic.instanceCreate (); if (action == null) return null; if (!(action instanceof Action)) return null; return createAction((Action) action, prefix, name); } catch (Exception ex) { ex.printStackTrace (); return null; } }
Example 4
Source File: TemplatesPanel.java From netbeans with Apache License 2.0 | 5 votes |
private static boolean canRevert(Node[] nodes) { if (nodes == null) { return false; } boolean can = false; for (Node node : nodes) { FileObject fo = node.getLookup().lookup(FileObject.class); if (fo != null && fo.canRevert()) { can = true; } else { return false; } } return can; }
Example 5
Source File: TemplatesPanel.java From netbeans with Apache License 2.0 | 5 votes |
/** Test if the file physically exists on disk and thus was created by user and can be renamed. */ private static boolean isUserFile(FileObject fo) { // A layer-defined folder with a user-added file (or subfolder) should not be renamable: for (FileObject child : fo.getChildren()) { if (!isUserFile(child)) { return false; } } return fo.canRevert(); }