当前位置: 首页>>代码示例>>Java>>正文


Java FileObject.canWrite方法代码示例

本文整理汇总了Java中org.openide.filesystems.FileObject.canWrite方法的典型用法代码示例。如果您正苦于以下问题:Java FileObject.canWrite方法的具体用法?Java FileObject.canWrite怎么用?Java FileObject.canWrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.filesystems.FileObject的用法示例。


在下文中一共展示了FileObject.canWrite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: searchFile

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 */
@Override
public boolean searchFile(FileObject file)
        throws IllegalArgumentException {
    if (file.isFolder()) {
        throw new java.lang.IllegalArgumentException(
                "file (not folder) expected");                      //NOI18N
    }
    File f = FileUtil.toFile(file);
    if (f == null && !file.canWrite()) {
        // non-standard file objects, e.g. ZIP archive items.
        return true;
    } else {
        return SharabilityQuery.getSharability(file)
                != Sharability.NOT_SHARABLE;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SharabilityFilter.java

示例2: traverseFolder

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 */
@Override
public FolderResult traverseFolder(FileObject folder)
        throws IllegalArgumentException {
    if (!folder.isFolder()) {
        throw new java.lang.IllegalArgumentException(
                "folder expected");                                 //NOI18N
    }
    File f = FileUtil.toFile(folder);
    if (f == null && !folder.canWrite()) {
        // non-standard file objects, e.g. ZIP archive items.
        return FolderResult.TRAVERSE;
    } else {
        Sharability sharability = SharabilityQuery.getSharability(folder);
        switch (sharability) {
            case NOT_SHARABLE:
                return FolderResult.DO_NOT_TRAVERSE;
            case SHARABLE:
                return FolderResult.TRAVERSE_ALL_SUBFOLDERS;
            default:
                return FolderResult.TRAVERSE;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:SharabilityFilter.java

示例3: traverseFolder

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 */
@Override
public int traverseFolder(FileObject folder)
        throws IllegalArgumentException {
    if (!folder.isFolder()) {
        throw new java.lang.IllegalArgumentException(
                "folder expected");                                 //NOI18N
    }
    File f = FileUtil.toFile(folder);
    if (f == null && !folder.canWrite()) {
        // non-standard file objects, e.g. ZIP archive items.
        return TRAVERSE;
    } else {
        final int sharability = SharabilityQuery.getSharability(f);
        switch (sharability) {
            case SharabilityQuery.NOT_SHARABLE:
                return DO_NOT_TRAVERSE;
            case SharabilityQuery.SHARABLE:
                return TRAVERSE_ALL_SUBFOLDERS;
            default:
                return TRAVERSE;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:SharabilityFilter.java

示例4: isFolderWritable

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 * Checks whether the folder identified by the given <code>packageName</code> is
 * writable or is in a writable parent directory but does not exist yet.
 * 
 * @param sourceGroup the source group of the folder; must not be null.
 * @param packageName the package to check; must not be null.
 * @return true if the folder is writable or can be created (i.e. the parent 
 * folder, or the root folder of the given <code>sourceGroup</code> if there is no other 
 * parent for the folder, is writable), false otherwise.
 */ 
public static boolean isFolderWritable(SourceGroup sourceGroup, String packageName) {
    Parameters.notNull("sourceGroup", sourceGroup); //NOI18N
    Parameters.notNull("packageName", packageName); //NOI18N
    try {
        FileObject fo = getFolderForPackage(sourceGroup, packageName, false);

        while ((fo == null) && (packageName.lastIndexOf('.') != -1)) {
            packageName = packageName.substring(0, packageName.lastIndexOf('.'));
            fo = getFolderForPackage(sourceGroup, packageName, false);
        }
        return fo == null ? sourceGroup.getRootFolder().canWrite() : fo.canWrite();
    } catch (IOException ex) {
        LOGGER.log(Level.INFO, null, ex);
        return false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:SourceGroups.java

示例5: searchFile

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 */
@Override
public boolean searchFile(FileObject file)
        throws IllegalArgumentException {
    if (file.isFolder()) {
        throw new java.lang.IllegalArgumentException(
                "file (not folder) expected");                      //NOI18N
    }
    File f = FileUtil.toFile(file);
    if (f == null && !file.canWrite()) {
        // non-standard file objects, e.g. ZIP archive items.
        return true;
    } else {
        return SharabilityQuery.getSharability(FileUtil.toFile(file))
                != SharabilityQuery.NOT_SHARABLE;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SharabilityFilter.java

示例6: checkFileStatus

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void checkFileStatus(FileObject fo) {
    boolean update = false;
    synchronized (this) {
        if (lastFile == null || lastFile.get() != fo) {
            lastFile = new WeakReference<FileObject>(fo);
            update = true;
        }
    }
    if (update) {
        fo.addFileChangeListener(WeakListeners.create(FileChangeListener.class, this, fo));
        boolean readOnly = !fo.canWrite(); // Access without monitor on this class and document's lock
        updateFileReadOnly(readOnly);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ReadOnlyFilesHighlighting.java

示例7: isReadOnly

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 * Returns true if the underlying document is read-only, false otherwise.
 */
public boolean isReadOnly() {
    ModelSource ms = getModelSource();
    assert(ms != null);
    if (ms.isEditable()) {
        FileObject fo = (FileObject) ms.getLookup().lookup(FileObject.class);
        assert(fo != null);
        return !fo.canWrite();
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:AXIModel.java

示例8: isBaseFileWritable

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private boolean isBaseFileWritable () {
    if (canWriteBaseFile == null) {
        FileObject fo = FileUtil.toFileObject(baseFile);
        canWriteBaseFile = fo != null && fo.canWrite();
    }
    return canWriteBaseFile;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:DiffStreamSource.java

示例9: disableErrors

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static Set<Severity> disableErrors(FileObject file) {
    if (file.getAttribute(DISABLE_ERRORS) != null) {
        return EnumSet.allOf(Severity.class);
    }
    if (!file.canWrite() && FileUtil.getArchiveFile(file) != null) {
        return EnumSet.allOf(Severity.class);
    }

    return EnumSet.noneOf(Severity.class);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:Utilities.java

示例10: testImplsCanWrite

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testImplsCanWrite() throws IOException {
    FileObject fo = FileUtil.toFileObject(getWorkDir());
    assertNotNull(fo);
    assertNotNull(iListener);
    assertNotNull(iListenerNoCanWrite);
    int nCalls = iListener.implsCanWriteCalls;
    FileObject toChange = fo.createData("cw");
    assertNotNull(toChange);
    boolean cw = toChange.canWrite();
    assertEquals(nCalls + 1, iListener.implsCanWriteCalls);
    assertEquals(0, iListenerNoCanWrite.implsCanWriteCalls);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ProvidedExtensionsTest.java

示例11: implement

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void implement() throws Exception {
    final FileObject file = err.getFile();
    if (!file.canWrite()) {
        NotifyDescriptor d = new NotifyDescriptor.Message(
                NbBundle.getMessage(FixDescription.class, "CTL_File_Not_Writable", file.getNameExt()), //NOI18N
                NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notify(d);
        return ;
    }

    fix.implement();
    fixed.set(true);
    cs.fireChange();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:FixDescription.java

示例12: isTargetWritable

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
    * Detects if targets file is non-null and writable
    * @return true if target's file is writable
    */
   public static boolean isTargetWritable(@NonNull TypeElement target, @NonNull CompilationInfo info) {
       TypeElement outermostType = info.getElementUtilities().outermostTypeElement(target);
       FileObject fo = SourceUtils.getFile(ElementHandle.create(outermostType), info.getClasspathInfo());
if(fo != null && fo.canWrite())
    return true;
else
    return false;
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:Utilities.java

示例13: canCloseElement

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Messages({
     "MSG_SaveModified=File {0} is modified. Save?"
 })
 @Override
 public CloseOperationState canCloseElement() {
     if (sqlEditorSupport().isConsole()) {
         return CloseOperationState.STATE_OK;
     } else {
         DataObject sqlDO = sqlEditorSupport().getDataObject();
         FileObject sqlFO = sqlEditorSupport().getDataObject().getPrimaryFile();
         if (sqlDO.isModified()) {
             if (sqlFO.canWrite()) {
                 Savable sav = sqlDO.getLookup().lookup(Savable.class);
                 if (sav != null) {
                     AbstractAction save = new AbstractAction() {
                         @Override
                         public void actionPerformed(ActionEvent e) {
                             try {
                                 sqlEditorSupport().saveDocument();
                             } catch (IOException ex) {
                                 Exceptions.printStackTrace(ex);
                             }
                         }
                     };
                     save.putValue(Action.LONG_DESCRIPTION, Bundle.MSG_SaveModified(sqlFO.getNameExt()));
                     return MultiViewFactory.createUnsafeCloseState("editor", save, null);
                 }
             }
         }
     }
     return CloseOperationState.STATE_OK;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:SQLCloneableEditor.java

示例14: isReadOnly

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public boolean isReadOnly() {
    FileObject javaFO = getPrimaryFile();
    FileObject formFO = formEntry.getFile();
    return !javaFO.canWrite() || !formFO.canWrite();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:FormDataObject.java

示例15: performAction

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
protected void performAction(Node[] nodes) {
    Node node = nodes[ 0 ];
    FileObject fo = node.getLookup().lookup( FileObject.class );
    Project proj = node.getLookup().lookup(Project.class);
    String origLoc = (String) node.getValue(
            JAXBWizModuleConstants.ORIG_LOCATION);
    Boolean origLocIsURL = (Boolean) node.getValue(
            JAXBWizModuleConstants.ORIG_LOCATION_TYPE);
    FileObject locSchemaRoot = (FileObject) node.getValue(
            JAXBWizModuleConstants.LOC_SCHEMA_ROOT);
    
    if ( ( fo != null ) && ( origLoc != null ) ) {
        // XXX TODO run in separate non-awt thread.
         try {
             if (fo.canWrite()){
                 if (origLocIsURL){
                    URL url = new URL(origLoc);
                     ProjectHelper.retrieveResource(locSchemaRoot, 
                             url.toURI());                        
                 } else {
                     File projDir = FileUtil.toFile(
                             proj.getProjectDirectory());
                     //File srcFile = new File(origLoc);
                     File srcFile = FileSysUtil.Relative2AbsolutePath(
                             projDir, origLoc);
                     ProjectHelper.retrieveResource(fo.getParent(), 
                             srcFile.toURI());
                 }
             } else {
                 String msg = NbBundle.getMessage(this.getClass(),
                         "MSG_CanNotRefreshFile"); //NOI18N
                 NotifyDescriptor d = new NotifyDescriptor.Message(
                         msg, NotifyDescriptor.INFORMATION_MESSAGE);
                 d.setTitle(NbBundle.getMessage(this.getClass(), 
                         "LBL_RefreshFile")); //NOI18N
                 DialogDisplayer.getDefault().notify(d);
             }
         } catch (Exception ex){
             log(ex);
         } 
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:JAXBRefreshAction.java


注:本文中的org.openide.filesystems.FileObject.canWrite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。