本文整理匯總了Java中org.openide.filesystems.FileObject.canRevert方法的典型用法代碼示例。如果您正苦於以下問題:Java FileObject.canRevert方法的具體用法?Java FileObject.canRevert怎麽用?Java FileObject.canRevert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.filesystems.FileObject
的用法示例。
在下文中一共展示了FileObject.canRevert方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isCustomProfile
import org.openide.filesystems.FileObject; //導入方法依賴的package包/類
/**
* 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;
}
示例2: delete
import org.openide.filesystems.FileObject; //導入方法依賴的package包/類
private static void delete(FileObject file) throws IOException { // cf. #162526
if (file.canRevert()) {
file.revert();
} else {
throw new IOException("Could not delete " + file);
}
}
示例3: createAction
import org.openide.filesystems.FileObject; //導入方法依賴的package包/類
/**
* 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;
}
}
示例4: canRevert
import org.openide.filesystems.FileObject; //導入方法依賴的package包/類
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;
}
示例5: isUserFile
import org.openide.filesystems.FileObject; //導入方法依賴的package包/類
/** 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();
}