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


Java FileChangeListener类代码示例

本文整理汇总了Java中org.openide.filesystems.FileChangeListener的典型用法代码示例。如果您正苦于以下问题:Java FileChangeListener类的具体用法?Java FileChangeListener怎么用?Java FileChangeListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: addCfgFileChangeListener

import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
public static void addCfgFileChangeListener(Project prj, 
        FileChangeListener l){
    
    FileObject fo = getFOForBindingConfigFile(prj);
    FileChangeListener fcl = null;
    if (fo != null) {
        fcl = FileUtil.weakFileChangeListener(l, fo);
        fo.addFileChangeListener(fcl);
    } else {
        fo = getFOForNBProjectDir(prj);
        if (fo != null) {
            fcl = FileUtil.weakFileChangeListener(l, fo);                
            fo.addFileChangeListener(fcl);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ProjectHelper.java

示例2: testDeadlockWhileRefesh

import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
public void testDeadlockWhileRefesh() throws IOException {
    clearWorkDir();
    
    MockServices.setServices(Watcher.class, AnnotationProviderImpl.class);
    final File root = new File(getWorkDir(), "root");
    
    File f = new File(new File(new File(root, "x"), "y"), "z");
    f.mkdirs();
    final FileObject r = FileUtil.toFileObject(root);
    r.refresh(true);
    
    Set<FileObject> all = new HashSet<FileObject>();
    Enumeration<? extends FileObject> en = r.getChildren(true);
    while (en.hasMoreElements()) {
        FileObject fileObject = en.nextElement();
        all.add(fileObject);
    }
    assertEquals("Some files: " + all, 3, all.size());
    
    FileChangeListener l = new FileChangeAdapter();
    FileUtil.addRecursiveListener(l, root);
    
    FileChangeListener l2 = new FileChangeAdapter();
    FileUtil.addRecursiveListener(l2, root);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:WatcherDeadlockTest.java

示例3: testRefresh69744

import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
public void testRefresh69744() throws Exception {
    File thisTest = new File(getWorkDir(),"thisTest");
    thisTest.createNewFile();
    FileObject testf = FileBasedFileSystem.getFileObject(thisTest);
    assertNotNull(testf);
    assertGC("",new WeakReference<FileObject>(testf.getParent()));
    modifyFileObject(testf, "abc");
    FileSystem fs = testf.getFileSystem();
    final List<FileEvent> l = new ArrayList<FileEvent>();
    FileChangeListener fcl = new FileChangeAdapter() {
        @Override
        public void fileChanged(FileEvent fe) {
            l.add(fe);
        }
    };
    Thread.sleep(1500);
    fs.addFileChangeListener(fcl);
    try {
        modifyFileObject(testf, "def");
        assertFalse(l.isEmpty());
    } finally {
        fs.removeFileChangeListener(fcl);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:FolderObjTest.java

示例4: ChangeSupport

import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
ChangeSupport(
        @NonNull final FileObject file,
        @NonNull final Runnable resetAction) {
    Parameters.notNull("file", file);   //NOI18N
    Parameters.notNull("resetAction", resetAction); //NOI18N
    this.resetAction = resetAction;
    this.file = file;
    this.file.addFileChangeListener(WeakListeners.create(FileChangeListener.class, this, this.file));
    EditorCookie.Observable cookie = null;
    try {
        final DataObject dobj = DataObject.find(file);
        cookie = dobj.getLookup().lookup(EditorCookie.Observable.class);
    } catch (DataObjectNotFoundException e) {
        //pass
    }
    this.ec = cookie;
    if (this.ec != null) {
        this.ec.addPropertyChangeListener(WeakListeners.propertyChange(this, this.ec));
        assignDocListener(this.ec);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:GraphTopComponent.java

示例5: acceptTemplate

import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
private boolean acceptTemplate (FileObject fo) {
    if (fo.isFolder() &&
        (TEMPLATES_FOLDER+"/Properties").equals(fo.getPath())) {
        
        return false;
    }
    boolean attachListener;
    synchronized (filesWeListenOn) {
        attachListener = filesWeListenOn.add(fo);
    }
    if (attachListener) {
        FileChangeListener fileChangeListener = FileUtil.weakFileChangeListener(this, fo);
        fo.addFileChangeListener(fileChangeListener);
    }
    if (isTemplate (fo) || fo.isFolder()) {
        Object o = fo.getAttribute ("simple"); // NOI18N
        return o == null || Boolean.TRUE.equals (o);
    } else {
        return false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:TemplatesPanel.java

示例6: safeAddRecursiveListener

import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
private void safeAddRecursiveListener(
        @NonNull final FileChangeListener listener,
        @NonNull final File path,
        @NullAllowed final ClassPath.Entry entry) {
    if (USE_RECURSIVE_LISTENERS) {
        final FileFilter filter = entry == null?
            null:
            (pathname) -> {
                try {
                    return entry.includes(BaseUtilities.toURI(pathname).toURL());
                } catch (MalformedURLException ex) {
                    Exceptions.printStackTrace(ex);
                    return true;
                }
            };
        performAsync(() -> {
                FileUtil.addRecursiveListener(
                    listener,
                    path,
                    filter,
                    () -> !listens);
                return null;
            });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:RootsListener.java

示例7: rebuild

import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
/**
 * Create a new tracker for tracking mime types under the <code>basePath</code>
 * folder.
 * 
 * @param settingsType The type of settings to track mime types for. If not
 *   <code>null</code> the tracker will only list mime types that declare
 *   settings of this type.
 * @param basePath The path on the system <code>FileSystem</code> where the
 *   mime types should be tracked.
 */
/* package */ MimeTypesTracker(SettingsType.Locator locator, String basePath) {
    this.locator = locator;
    this.basePath = basePath;
    this.basePathElements = basePath.split("/"); //NOI18N
    
    rebuild();
    
    // Start listening
    this.listener = new Listener();
    FileSystem sfs = null;
    try {
        sfs = FileUtil.getConfigRoot().getFileSystem();
    } catch (FileStateInvalidException ex) {
        Exceptions.printStackTrace(ex);
    }
    sfs.addFileChangeListener(WeakListeners.create(FileChangeListener.class,listener, sfs));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:MimeTypesTracker.java

示例8: rebuild

import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
/**
 * Creates a new instance of ProfilesTracker.
 * 
 * @param type 
 * @param mimeTypes 
 * @param strict 
 */
/* package */ProfilesTracker(Locator locator, MimeTypesTracker mimeTypes) {
    this.locator = locator;
    this.mimeTypes = mimeTypes;

    rebuild();

    // Start listening
    this.listener = new Listener();
    FileSystem sfs = null;
    try {
        sfs = FileUtil.getConfigRoot().getFileSystem();
    } catch (FileStateInvalidException ex) {
        Exceptions.printStackTrace(ex);
    }
    this.systemFileSystem = sfs;
    this.systemFileSystem.addFileChangeListener(WeakListeners.create(FileChangeListener.class, listener, this.systemFileSystem));
    this.mimeTypes.addPropertyChangeListener(listener);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ProfilesTracker.java

示例9: addFileSystemsListener

import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
/**
 * Adds given listener to all FileSystems
 * @param l listener to add
 */    
public static void addFileSystemsListener(FileChangeListener l) {
    FileSystem[] fileSystems = getFileSystems();
    for (int i=0; i<fileSystems.length; i++) {
        fileSystems[i].addFileChangeListener(l);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:Util.java

示例10: removeFileSystemsListener

import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
/**
 * Removes given listener to all FileSystems
 * @param l listener to remove
 */    
public static void removeFileSystemsListener(FileChangeListener l) {
    FileSystem[] fileSystems = getFileSystems();
    for (int i=0; i<fileSystems.length; i++) {
        fileSystems[i].removeFileChangeListener(l);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:Util.java

示例11: ensureListensOnFS

import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
private void ensureListensOnFS(FileObject f) {
    try {
        FileSystem fs = f.getFileSystem();
        if (!system2RecursiveListener.containsKey(fs)) {
            FileChangeListener l = new RootAddedDeletedListener();
            system2RecursiveListener.put(fs, l);
            fs.addFileChangeListener(l);
        }
    } catch (FileStateInvalidException ex) {
        LOG.log(Level.FINE, null, ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ErrorAnnotator.java

示例12: checkFileStatus

import org.openide.filesystems.FileChangeListener; //导入依赖的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

示例13: create

import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
/**
 * Creates new support for the given directory and file name(s).
 * @param directory directory
 * @param fileNames file name(s)
 * @return new support
 */
public static ImportantFilesSupport create(FileObject directory, String... fileNames) {
    Parameters.notNull("directory", directory); // NOI18N
    Parameters.notNull("fileNames", fileNames); // NOI18N
    ImportantFilesSupport support = new ImportantFilesSupport(directory, fileNames);
    directory.addFileChangeListener(WeakListeners.create(FileChangeListener.class, support.fileChangeListener, directory));
    return support;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:ImportantFilesSupport.java

示例14: removeModelListner

import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
public static void removeModelListner(Project prj, FileChangeListener l){
    // WeakChangeListener will return true for its proxy.
    FileObject fo = getFOForBindingConfigFile(prj);
    if (fo != null) {
        fo.removeFileChangeListener(l);
    }

    fo = getFOForNBProjectDir(prj);
    if (fo != null) {
        fo.removeFileChangeListener(l);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ProjectHelper.java

示例15: DataObjectListener

import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
/**
 * @param fo The file object to listen upon at DataObject level
 * @param fcl The FileChangeListener to be called when the DataObject has been invalidated
 * 
 * @throws org.openide.loaders.DataObjectNotFoundException
 */
public DataObjectListener(FileObject fo, FileChangeListener fcl) throws DataObjectNotFoundException {
    this.fobj = fo;
    this.flisten = fcl;
    this.dobj = DataObject.find(fo);
    wlistener = WeakListeners.propertyChange(this, dobj);
    this.dobj.addPropertyChangeListener(wlistener);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:DefaultDataLoadersBridge.java


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