• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FileChangeAdapter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getKey2Desc

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
private synchronized Map<String, Description> getKey2Desc(final Object fo) {
    Map<String, Description> result = fo2Key2Desc.get(fo);
    
    if (result == null) {
        files.add(new CleanableWeakReference<Object>(fo));
        fo2Key2Desc.put(fo, result = Collections.synchronizedMap(new LinkedHashMap<String, Description>()));
        pcs.firePropertyChange("fos", null, fo);
        
        if (fo instanceof FileObject) {
            ((FileObject)fo).addFileChangeListener(new FileChangeAdapter() {
                @Override
                public void fileDeleted(FileEvent ev) {
                    fileDeletedSync(ev, (FileObject)fo);
                }
            });
        }
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:TimesCollectorPeer.java


示例2: testDeadlockWhileRefesh

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

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
public void testRemoveListenerFromAFileObj() throws Exception {
    File f = new File(new File(getWorkDir(), "dir"), "X.txt");
    final File pf = f.getParentFile();
    pf.mkdirs();
    f.createNewFile();
    
    FileObject fo = FileUtil.toFileObject(f);
    assertTrue("Is data", fo.isData());
    
    f.delete();
    pf.delete();
    FileObject parent = FileUtil.toFileObject(getWorkDir()).createData("dir");
    assertTrue("Also data", parent.isData());
    
    
    fo.removeFileChangeListener(new FileChangeAdapter());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:WatcherTest.java


示例5: AnnotationTypesFolder

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
/** Creates new AnnotationTypesFolder */
private AnnotationTypesFolder(FileObject fo, DataFolder fld) {
    super(fld);
    recreate();
    instanceFinished();
    
    // add listener on changes in annotation types folder
    fo.addFileChangeListener(new FileChangeAdapter() {
        public void fileDeleted(FileEvent fe) {
            AnnotationType type;
            for (Iterator it = AnnotationTypes.getTypes().getAnnotationTypeNames(); it.hasNext(); ) {
                type = AnnotationTypes.getTypes().getType((String)it.next());
                if ( type != null && ((FileObject)type.getProp(AnnotationType.PROP_FILE)).equals(fe.getFile()) ) {
                    AnnotationTypes.getTypes().removeType(type.getName());
                    break;
                }
            }
        }
    });
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:AnnotationTypesFolder.java


示例6: installModulesInstallationListener

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
/** See issue #57773 for details. Toolbar should be updated with possible changes after
   module install/uninstall */
private void installModulesInstallationListener(){
    moduleRegListener = new FileChangeAdapter() {
        public @Override void fileChanged(FileEvent fe) {
            //some module installed/uninstalled. Refresh toolbar content
            Runnable r = new Runnable() {
                public void run() {
                    if (isToolbarVisible()) {
                        checkPresentersRemoved();
                        checkPresentersAdded();                                
                    }
                }
             };
            Utilities.runInEventDispatchThread(r);
        }
    };

    FileObject moduleRegistry = FileUtil.getConfigFile("Modules"); //NOI18N

    if (moduleRegistry !=null){
        moduleRegistry.addFileChangeListener(
            FileUtil.weakFileChangeListener(moduleRegListener, moduleRegistry));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:NbEditorToolBar.java


示例7: MatDefDataObject

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
@SuppressWarnings("LeakingThisInConstructor")
public MatDefDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);
    registerEditor("text/jme-materialdefinition", true);
    contentLookup = new AbstractLookup(lookupContents);
    lookupContents.add(this);
    lookup = new ProxyLookup(getCookieSet().getLookup(), contentLookup);
    findAssetManager();
    final MatDefMetaData metaData = new MatDefMetaData(this);
    lookupContents.add(metaData);
    pf.addFileChangeListener(new FileChangeAdapter() {
        @Override
        public void fileChanged(FileEvent fe) {
            super.fileChanged(fe);
            metaData.save();
            if (file.isDirty()) {
                file.setLoaded(false);
                file.setDirty(false);
            }
        }
    });

}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:24,代码来源:MatDefDataObject.java


示例8: projectOpened

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
@Override
protected void projectOpened() {
    project.getProjectDirectory().addRecursiveListener(new FileChangeAdapter(){

        @Override
        public void fileChanged(FileEvent fe) {
            if ( fe.getFile().getPath().endsWith(".java")){
                //System.out.println("Adding to compile queue "+fe.getFile());
                RecompileQueue.getProjectQueue(project).addChanged(fe.getFile());
            }
            super.fileChanged(fe); 
        }
        
    });
    
    BuildScriptHelper.refreshBuildScript(project, BuildScriptType.J2SE.getStylesheet(), true);
}
 
开发者ID:shannah,项目名称:mirah-nbm,代码行数:18,代码来源:JavaSEMirahProjectOpenedHook.java


示例9: projectOpened

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
@Override
protected void projectOpened() {
    project.getProjectDirectory().addRecursiveListener(new FileChangeAdapter(){

        @Override
        public void fileChanged(FileEvent fe) {
            if ( fe.getFile().getPath().endsWith(".java")){
                //System.out.println("Adding to compile queue "+fe.getFile());
                RecompileQueue.getProjectQueue(project).addChanged(fe.getFile());
            }
            super.fileChanged(fe); 
        }
        
    });
    
    //BuildScriptHelper.refreshBuildScript(project, BuildScriptType.J2SE.getStylesheet(), true);
    MavenMirahExtender ext = new MavenMirahExtender(project);
    
    //if ( !ext.isCurrent() ){
    //    ext.activate();
    //}
    Preferences prefs = ProjectUtils.getPreferences(project, MirahExtenderImplementation.class, true);
    prefs.put("project_type", "maven");
    System.out.println("Setting project type in prefs to maven");
}
 
开发者ID:shannah,项目名称:mirah-nbm,代码行数:26,代码来源:MavenMirahProjectOpenedHook.java


示例10: PlatformConvertor

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
private PlatformConvertor(@NonNull final XMLDataObject  object) {
    Parameters.notNull("object", object);
    this.holder = object;
    this.holder.getPrimaryFile().addFileChangeListener( new FileChangeAdapter () {
        @Override
        public void fileDeleted (final FileEvent fe) {
            if (!defaultPlatform) {
                try {
                ProjectManager.mutex().writeAccess( new Mutex.ExceptionAction<Void> () {
                    @Override
                    public Void run () throws IOException {
                        String systemName = fe.getFile().getName();
                        String propPrefix =  "platforms." + systemName + ".";   //NOI18N
                        boolean changed = false;
                        EditableProperties props = PropertyUtils.getGlobalProperties();
                        for (Iterator<String> it = props.keySet().iterator(); it.hasNext(); ) {
                            String key = it.next ();
                            if (key.startsWith(propPrefix)) {
                                it.remove();
                                changed =true;
                            }
                        }
                        if (changed) {
                            PropertyUtils.putGlobalProperties(props);
                        }
                        return null;
                    }
                });
                } catch (MutexException e) {
                    Exceptions.printStackTrace(e);
                }
            }
        }
    });
    cookies = new InstanceContent();
    cookies.add(this);
    lookup = new AbstractLookup(cookies);
    cookies.add(Node.class, this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:PlatformConvertor.java


示例11: LocalizedBundleInfo

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
/** Use factory method instead. */
private LocalizedBundleInfo(FileObject[] bundleFOs) throws IOException {
    if (bundleFOs == null || bundleFOs.length == 0) {
        throw new IllegalArgumentException();
    }
    props = new EditableProperties[bundleFOs.length];
    paths = new File[bundleFOs.length];
    for (int i = 0; i < bundleFOs.length; i++) {
        InputStream bundleIS = bundleFOs[i].getInputStream();
        try {
            props[i] = new EditableProperties(true);
            props[i].load(bundleIS);
        } finally {
            bundleIS.close();
        }
        paths[i] = FileUtil.toFile(bundleFOs[i]);
        bundleFOs[i].addFileChangeListener(new FileChangeAdapter() {
            public void fileChanged(FileEvent fe) {
                try {
                    LocalizedBundleInfo.this.reload();
                } catch (IOException e) {
                    Util.err.log(ErrorManager.WARNING,
                            "Cannot reload localized bundle info " + // NOI18N
                            FileUtil.getFileDisplayName(fe.getFile()));
                }
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:LocalizedBundleInfo.java


示例12: testLogExtCmd

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
@RandomlyFails
public void testLogExtCmd () throws Exception {
    waitForInitialScan();
    FileChangeAdapter fca = new FileChangeAdapter();
    workdirFO.addRecursiveListener(fca);
    FileUtil.refreshFor(repositoryLocation);
    Thread.sleep(11000); // some time for initial scans to finish and event logger to settle down
    File gitFolder = new File(repositoryLocation, ".git");
    final File lockFile = new File(gitFolder, "index.lock");
    Logger GESTURES_LOG = Logger.getLogger("org.netbeans.ui.vcs");
    ExternalCommandUsageHandler h = new ExternalCommandUsageHandler();
    GESTURES_LOG.addHandler(h);
    lockFile.createNewFile();
    FileUtil.refreshFor(repositoryLocation);
    pause(); 
    lockFile.delete();
    FileUtil.refreshFor(repositoryLocation);
    
    h.waitForEvent();
    assertNotNull(h.event);
    assertEquals(1, h.numberOfEvents);
    assertTrue(h.event.time > 0);
    assertEquals("GIT", h.event.vcs);
    assertEquals("UNKNOWN", h.event.command);
    assertTrue(h.event.external);
    assertEquals(Long.valueOf(0), h.event.modifications);
    GESTURES_LOG.removeHandler(h);
    workdirFO.removeRecursiveListener(fca);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:ExternalChangesTest.java


示例13: testLogExtCmdChanges

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
@RandomlyFails
public void testLogExtCmdChanges () throws Exception {
    waitForInitialScan();
    FileChangeAdapter fca = new FileChangeAdapter();
    workdirFO.addRecursiveListener(fca);
    final File toAdd = new File(modifiedFile.getParentFile(), "toAdd");
    File toDelete = new File(modifiedFile.getParentFile(), "toDelete");
    toDelete.createNewFile();
    FileUtil.refreshFor(repositoryLocation);
    Thread.sleep(11000); // some time for initial scans to finish and event logger to settle down
    File gitFolder = new File(repositoryLocation, ".git");
    final File lockFile = new File(gitFolder, "index.lock");
    
    Logger.getLogger(FilesystemInterceptor.class.getName()).setLevel(Level.ALL);
    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(Level.ALL);
    Logger.getLogger(FilesystemInterceptor.class.getName()).addHandler(ch);
    
    assertTrue(lockFile.createNewFile());
    FileUtil.refreshFor(repositoryLocation);
    pause();
    Thread.sleep(1100);
    assertTrue(lockFile.delete());
    FileUtil.refreshFor(repositoryLocation);
    Thread.sleep(1100);
    
    Logger GESTURES_LOG = Logger.getLogger("org.netbeans.ui.vcs");
    ExternalCommandUsageHandler h = new ExternalCommandUsageHandler();
    GESTURES_LOG.addHandler(h);
    assertTrue(lockFile.createNewFile());
    FileUtil.refreshFor(repositoryLocation);
    // modification
    write(modifiedFile, "testExternalCommandLoggedChanges");
    // delete
    toDelete.delete();
    // create
    toAdd.createNewFile();
    FileUtil.refreshFor(repositoryLocation);
    pause();
    Thread.sleep(1100);
    assertTrue(lockFile.delete());
    FileUtil.refreshFor(repositoryLocation);
    
    h.waitForEvent();
    assertNotNull(h.event);
    assertEquals(1, h.numberOfEvents);
    assertTrue(h.event.time > 0);
    assertEquals("GIT", h.event.vcs);
    assertEquals("UNKNOWN", h.event.command);
    assertTrue(h.event.external);
    assertEquals(Long.valueOf(3), h.event.modifications);
    GESTURES_LOG.removeHandler(h);
    workdirFO.removeRecursiveListener(fca);
    Logger.getLogger(FilesystemInterceptor.class.getName()).removeHandler(ch);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:56,代码来源:ExternalChangesTest.java


示例14: JavadocResult

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
JavadocResult(@NullAllowed String groupId, @NullAllowed String artifactId, @NullAllowed String version, @NullAllowed String classifier, @NonNull URL binary, @NullAllowed File javadocJar, @NonNull Function<File, List<Coordinates>> coorProvider) {
    javadocJarFile = javadocJar;
    this.groupId = groupId;
    this.artifactId = artifactId;
    this.version = version;
    this.binary = binary;
    this.classifier = classifier;
    this.gav = MavenFileOwnerQueryImpl.cacheKey(groupId, artifactId, version);
    this.coorProvider = coorProvider;

    support = new ChangeSupport(this);
    mfoListener = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            //external root in local repository changed..
            checkChanges();
        }
    };
    projectListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (NbMavenProject.PROP_PROJECT.equals(event.getPropertyName())) {
                checkChanges();
            }
        }
    };
    javadocJarChangeListener = new FileChangeAdapter() {
        @Override
        public void fileDataCreated(FileEvent fe) {
            //source jar was created..
            checkChanges();
        }

    };
    MavenFileOwnerQueryImpl.getInstance().addChangeListener(
            WeakListeners.create(ChangeListener.class, mfoListener, MavenFileOwnerQueryImpl.getInstance()));
    if (javadocJarFile != null) {
        FileUtil.addFileChangeListener(javadocJarChangeListener, javadocJarFile);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:RepositoryForBinaryQueryImpl.java


示例15: testRefreshRecursively

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
public void testRefreshRecursively() throws IOException {
    File f = new File(dataRootDir, "workdir/root-test-versioned");
    f.mkdirs();
    FileObject fo = FileUtil.toFileObject(f);
    fo = fo.createFolder("folder");
    fo.addRecursiveListener(new FileChangeAdapter());
    assertTrue(inteceptor.getRefreshRecursivelyFiles().contains(FileUtil.toFile(fo)));     
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:VCSInterceptorTest.java


示例16: testNewChildNoticed

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
public void testNewChildNoticed() throws Exception {
    FileObject fileObject1 = testFolder.createData("fileObject1");
    FileObject[] arr = testFolder.getChildren();
    assertEquals("One child", 1, arr.length);
    assertEquals("Right child", fileObject1, arr[0]);

    File file = FileUtil.toFile(fileObject1);
    assertNotNull("File found", file);
    arr = null;
    fileObject1 = null;
    Reference<FileObject> ref = new WeakReference<FileObject>(fileObject1);
    assertGC("File Object can disappear", ref);

    Thread.sleep(100);

    class L extends FileChangeAdapter {
        int cnt;
        FileEvent event;

        @Override
        public void fileDataCreated(FileEvent fe) {
            cnt++;
            event = fe;
        }

    }
    L listener = new L();
    testFolder.addRecursiveListener(listener);

    File nfile = new File(file.getParentFile(), "new.txt");
    nfile.createNewFile();

    testFolder.refresh();

    assertEquals("Change notified", 1, listener.cnt);
    assertEquals("Right file", nfile, FileUtil.toFile(listener.event.getFile()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:ExternalTouchTest.java


示例17: testDeleteOfAChildNoticed

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
public void testDeleteOfAChildNoticed() throws Exception {
    FileObject fileObject1 = testFolder.createData("fileObject1");
    FileObject[] arr = testFolder.getChildren();
    assertEquals("One child", 1, arr.length);
    assertEquals("Right child", fileObject1, arr[0]);

    File file = FileUtil.toFile(fileObject1);
    assertNotNull("File found", file);
    arr = null;
    fileObject1 = null;
    Reference<FileObject> ref = new WeakReference<FileObject>(fileObject1);
    assertGC("File Object can disappear", ref);

    Thread.sleep(100);

    class L extends FileChangeAdapter {
        int cnt;
        FileEvent event;

        @Override
        public void fileDeleted(FileEvent fe) {
            cnt++;
            event = fe;
        }

    }
    L listener = new L();
    testFolder.addRecursiveListener(listener);

    file.delete();

    testFolder.refresh();

    assertEquals("Change notified", 1, listener.cnt);
    assertEquals("Right file", file, FileUtil.toFile(listener.event.getFile()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:ExternalTouchTest.java


示例18: testAsyncCall

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
public void testAsyncCall() throws Exception {
    final FileObject workDirFo = FileBasedFileSystem.getFileObject(getWorkDir());
    File f = new File(getWorkDir(), "a");
    assertNull(workDirFo.getFileObject("a"));
    assertTrue(f.createNewFile());
    final Thread t = Thread.currentThread();
    class FileChange extends FileChangeAdapter {
        private boolean called = false;
        @Override
        public void fileDataCreated(FileEvent fe) {
            assertNotSame(t, Thread.currentThread());
            called = true;
            synchronized (workDirFo) {
                workDirFo.notifyAll();
            }
        }
        public boolean isCalled() {
            return called;
        }            
    } 
    FileChange fcl = new FileChange();
    workDirFo.addFileChangeListener(fcl);
    try {
        assertNotNull(FileUtil.toFileObject(f));
        synchronized(workDirFo) {
            workDirFo.wait();
        }
        assertNotNull(workDirFo.getFileObject("a"));                
        assertTrue(fcl.isCalled());
    } finally {
        workDirFo.removeFileChangeListener(fcl);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:FolderObjTest.java


示例19: testRefresh109490

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
public void testRefresh109490() throws Exception {
    final File wDir = getWorkDir();
    final FileObject wDirFo = FileBasedFileSystem.getFileObject(wDir);
    final List<FileEvent> fileEvents = new ArrayList<FileEvent>();
    FileSystem fs = wDirFo.getFileSystem();
    FileChangeListener fListener = new FileChangeAdapter() {

        @Override
        public void fileDataCreated(FileEvent fe) {
            super.fileDataCreated(fe);
            fileEvents.add(fe);
        }
    };
    try {
        fs.addFileChangeListener(fListener);

        File file = new File(wDir, "testao.f");
        File file2 = new File(wDir, "testc1.f");
        assertEquals(file.hashCode(), file2.hashCode());
        wDirFo.getChildren();
        assertTrue(file.createNewFile());
        assertTrue(file2.createNewFile());
        assertEquals(0, fileEvents.size());
        fs.refresh(true);
        assertEquals(2, fileEvents.size());
        assertEquals(Arrays.asList(wDirFo.getChildren()).toString(), 2,wDirFo.getChildren().length);
        assertTrue(Arrays.asList(wDirFo.getChildren()).toString().indexOf(file.getName()) != -1);            
        assertTrue(Arrays.asList(wDirFo.getChildren()).toString().indexOf(file2.getName()) != -1);                        
    } finally {
        fs.removeFileChangeListener(fListener);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:FolderObjTest.java


示例20: testDelete

import org.openide.filesystems.FileChangeAdapter; //导入依赖的package包/类
/**
 * Test of delete method, of class org.netbeans.modules.masterfs.filebasedfs.fileobjects.FolderObj.
 */
public void testDelete() throws IOException {
    File f = testFile;
    
    FileObject testFo = FileBasedFileSystem.getFileObject(testFile);
    assertNotNull(testFo);
    
    final List<FileEvent> l = new ArrayList<FileEvent>();
    FileChangeListener fcl = new FileChangeAdapter () {
        @Override
        public void fileDeleted(FileEvent fe) {
            l.add(fe);
        }            
    };
    FileObject fo = FileUtil.createData(testFo, "delete/the/whole/structure/in/depth/todelete.txt");
    fo.addFileChangeListener(fcl);
    
    FileObject toDelete = testFo.getFileObject("delete");        
    assertNotNull(toDelete);
    toDelete.addFileChangeListener(fcl);

    FileObject toGC = testFo.getFileObject("delete/the/whole/structure");
    assertNotNull(toGC);
    Reference<FileObject> toGCRef = new WeakReference<FileObject>(toGC);
    toGC.addFileChangeListener(fcl);
    toGC = null;
    
    assertGC("", toGCRef);
    toDelete.delete();
    assertEquals(0,testFo.getChildren().length);
    toDelete = testFo.getFileObject("delete");        
    assertNull(toDelete);        
    assertEquals(2, l.size());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:FolderObjTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CatalinaProperties类代码示例发布时间:2022-05-22
下一篇:
Java TaskTracker类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap