本文整理汇总了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();
}