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


Java FileUtil.runAtomicAction方法代码示例

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


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

示例1: registerDrivers

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static void registerDrivers(final String newLocation) {
    try {
        // registering the drivers in an atomic action so the Drivers node
        // is refreshed only once
        FileUtil.runAtomicAction(new FileSystem.AtomicAction() {
            @Override
            public void run() {
                registerDriver(DRIVER_NAME_NET, DRIVER_DISP_NAME_NET, DRIVER_CLASS_NET,
                        new String[]{DRIVER_PATH_NET, DRIVER_PATH_EMBEDDED}, newLocation);
                registerDriver(DRIVER_NAME_EMBEDDED, DRIVER_DISP_NAME_EMBEDDED,
                        DRIVER_CLASS_EMBEDDED, new String[]{DRIVER_PATH_EMBEDDED}, newLocation);
            }
        });
    } catch (IOException e) {
        Exceptions.printStackTrace(e);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DerbyOptions.java

示例2: doDestroy

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void doDestroy(final Node[] sel) {
    try {
        FileUtil.runAtomicAction(new FileSystem.AtomicAction() {

                                                                           public void run() throws IOException {
                                                                               for (int i = 0; i <
                                                                                               sel.length; i++) {
                                                                                   try {
                                                                                       sel[i].destroy();
                                                                                   }
                                                                                   catch (IOException e) {
                                                                                       Exceptions.printStackTrace(e);
                                                                                   }
                                                                               }
                                                                           }
                                                                       });
    } catch (IOException ioe) {
        throw (IllegalStateException) new IllegalStateException(ioe.toString()).initCause(ioe);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ExplorerActions.java

示例3: refreshModuleList

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static void refreshModuleList () {
    // XXX: the modules list should be refresh automatically when config/Modules/ changes
    final FileObject modulesRoot = FileUtil.getConfigFile(MODULES);
    LOG.log (Level.FINE,
            "It\'s a hack: Call refresh on " + modulesRoot +
            " file object.");
    if (modulesRoot != null) {
        try {
            FileUtil.runAtomicAction (new FileSystem.AtomicAction () {

                @Override
                public void run () throws IOException {
                    modulesRoot.getParent ().refresh ();
                    modulesRoot.refresh ();
                }
            });
        } catch (IOException ex) {
            Exceptions.printStackTrace (ex);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:PluginImporter.java

示例4: testCreatedShadowFoundInParent

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testCreatedShadowFoundInParent() throws Exception {
    class R implements FileSystem.AtomicAction {
        @Override
        public void run() throws IOException {
            DataObject[] old = folder.getChildren();
            assertEquals("No children yet", 0, old.length);
            DataShadow ds = original.createShadow(folder);
            assertEquals("Parent is OK", folder, ds.getFolder());
            DataObject[] arr = folder.getChildren();
            List<DataObject> all = Arrays.asList(arr);
            assertTrue("Newly created " + ds + " shall be in list of children", all.contains(ds));
        }
    }
    R action = new R();
    FileUtil.runAtomicAction(action);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:DataShadowTest.java

示例5: registerLibraryTypeProvider

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public static void registerLibraryTypeProvider (final Class<? extends LibraryTypeProvider> provider) throws Exception {
    final MockLibraryTypeRegistry mr = Lookup.getDefault().lookup(MockLibraryTypeRegistry.class);
    if (mr != null) {
        mr.register(provider.newInstance());
        return;
    }
    FileObject root = FileUtil.getConfigRoot();
    StringTokenizer tk = new StringTokenizer("org-netbeans-api-project-libraries/LibraryTypeProviders","/");
    while (tk.hasMoreElements()) {
        String pathElement = tk.nextToken();
        FileObject tmp = root.getFileObject(pathElement);
        if (tmp == null) {
            tmp = root.createFolder(pathElement);
        }
        root = tmp;
    }
    final FileObject rootFin = root;
    if (root.getChildren().length == 0) {
        FileUtil.runAtomicAction(new FileSystem.AtomicAction() {
            @Override
            public void run() throws IOException {
                FileObject inst = rootFin.createData("TestLibraryTypeProvider","instance");
                inst.setAttribute("instanceClass", getBinaryName(provider));
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:LibrariesTestUtil.java

示例6: runAtomic

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void runAtomic(@NonNull final Runnable r) {
    FileUtil.runAtomicAction(new Runnable() {
        @Override
        public void run() {
            ProjectManager.mutex().writeAccess(new Runnable() {
                @Override
                public void run() {
                    r.run();
                }
            });
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:ProjectHooks.java

示例7: testFilesScannedAferSourceRootCreatedDeleted

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testFilesScannedAferSourceRootCreatedDeleted() throws Exception {
    final TestHandler handler = new TestHandler();
    final Logger logger = Logger.getLogger(RepositoryUpdater.class.getName()+".tests");
    logger.setLevel (Level.FINEST);
    logger.addHandler(handler);
    final File srcRoot1File = FileUtil.toFile(srcRoot1);
    final ClassPath cp1 = ClassPathSupport.createClassPath(FileUtil.urlForArchiveOrDir(srcRoot1File));
    globalPathRegistry_register(SOURCES,new ClassPath[]{cp1});
    assertTrue (handler.await());
    indexerFactory.indexer.setExpectedFile(new URL[0], new URL[0], new URL[0]);
    eindexerFactory.indexer.setExpectedFile(new URL[0], new URL[0], new URL[0]);
    assertTrue(indexerFactory.indexer.awaitDeleted(TIME));
    assertTrue(eindexerFactory.indexer.awaitDeleted());
    assertTrue(indexerFactory.indexer.awaitIndex(TIME));
    assertTrue(eindexerFactory.indexer.awaitIndex());

    indexerFactory.indexer.setExpectedFile(new URL[0], new URL[0], new URL[0]);
    eindexerFactory.indexer.setExpectedFile(new URL[0], new URL[0], new URL[0]);
    srcRoot1.delete();

    final File a = new File(srcRoot1File,"folder/a.foo");
    final File b = new File(srcRoot1File,"folder/b.emb");
    indexerFactory.indexer.setExpectedFile(new URL[]{org.openide.util.Utilities.toURI(a).toURL()}, new URL[0], new URL[0]);
    eindexerFactory.indexer.setExpectedFile(new URL[]{org.openide.util.Utilities.toURI(b).toURL()}, new URL[0], new URL[0]);
    FileUtil.runAtomicAction(new FileSystem.AtomicAction() {
        @Override
        public void run() throws IOException {
            FileUtil.createFolder(srcRoot1File);
            FileUtil.createData(a);
            FileUtil.createData(b);
        }
    });
    assertTrue(indexerFactory.indexer.awaitDeleted(TIME));
    assertTrue(eindexerFactory.indexer.awaitDeleted());
    assertTrue(indexerFactory.indexer.awaitIndex(TIME));
    assertTrue(eindexerFactory.indexer.awaitIndex());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:RepositoryUpdaterTest.java

示例8: load

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
public void load(final List<Module> modules) {
    FileUtil.runAtomicAction(new Runnable() {
        @Override
        public void run() {
            loadImpl(modules);
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:NbInstaller.java

示例9: unload

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
public void unload(final List<Module> modules) {
    FileUtil.runAtomicAction(new Runnable() {
        @Override
        public void run() {
            unloadImpl(modules);
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:NbInstaller.java

示例10: refreshFromGetter

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void refreshFromGetter(final FileObject parent,boolean asyncFire)  {
    try {
        if (asyncFire) {
            FileUtil.runAtomicAction(new AsyncRefreshAtomicAction(parent));
        } else {
            parent.refresh();
        }
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:FileObjectFactory.java

示例11: testFiredFromManyAtomicActions

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testFiredFromManyAtomicActions() throws Exception {
    final File workDir = getWorkDir();
    final FileObject workDirFo = FileUtil.toFileObject(workDir);

    final MyAtomicAction myAtomicAction = new MyAtomicAction();
    MyFileChangeListener myChangeListener = new MyFileChangeListener(myAtomicAction);
    FileUtil.addRecursiveListener(myChangeListener, workDir);

    assertEquals("files before", 0, workDir.list().length);

    for (int i = 0; i < RUNS; ++i) {
        final int j = i;
        myAtomicAction.runnable = new Runnable() {
            @Override
            public void run() {
                try {
                    FileUtil.createData(workDirFo, FILE_PREFIX + j);
                } catch (IOException ex) {
                    // checked later
                }
            }
        };
        FileUtil.runAtomicAction(myAtomicAction);
    }

    assertEquals("files after", RUNS, workDir.list().length);
    assertEquals(printEvents(myChangeListener.notFromAtomicAction), 0, myChangeListener.notFromAtomicAction.size());
    assertEquals("events", RUNS, myChangeListener.events.get());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:FsEventFromAtomicActionTest.java

示例12: testFiredFromOneAtomicAction

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testFiredFromOneAtomicAction() throws Exception {
    final File workDir = getWorkDir();
    final FileObject workDirFo = FileUtil.toFileObject(workDir);

    final AtomicAction myAtomicAction = new AtomicAction() {
        @Override
        public void run() throws IOException {
            try {
                for (int i = 0; i < RUNS; ++i) {
                    FileUtil.createData(workDirFo, FILE_PREFIX + i);
                }
            } catch (IOException ex) {
                // checked later
            }
        }
    };
    MyFileChangeListener myChangeListener = new MyFileChangeListener(myAtomicAction);
    FileUtil.addRecursiveListener(myChangeListener, workDir);

    assertEquals("files before", 0, workDir.list().length);

    FileUtil.runAtomicAction(myAtomicAction);

    assertEquals("files after", RUNS, workDir.list().length);
    assertEquals(printEvents(myChangeListener.notFromAtomicAction), 0, myChangeListener.notFromAtomicAction.size());
    assertEquals("events", RUNS, myChangeListener.events.get());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:FsEventFromAtomicActionTest.java

示例13: handleDrop

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
 * Perform the drop operation.
 *
 * @return True if the drop has been successful.
 */
private boolean handleDrop( final Transferable t ) {
    final boolean[] res = { false };
    FileUtil.runAtomicAction(new Runnable() {
        @Override
        public void run() {
            res[0] = handleDropImpl(t);
        }
    });
    return res[0];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:DnDSupport.java

示例14: getBookFile

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public static File getBookFile(File dataDir, File workDir) throws IOException {
    final File source = new File(dataDir, "sample.book");
    final File target = new File(workDir, "sample.book");
    if (target.exists()) {
        return target;
    }
    FileUtil.runAtomicAction(new FileSystem.AtomicAction() {

        @Override
        public void run() throws IOException {
            BufferedInputStream is = new BufferedInputStream(new FileInputStream(source));
            try {
                BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(target));
                try {
                    FileUtil.copy(is, os);
                } finally {
                    os.close();
                }
            } finally {
                is.close();
            }
        }
    });

    FileUtil.refreshFor(target);
    return target;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:Helper.java

示例15: saveThisEntry

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/** Helper method. Saves this entry. */
    private void saveThisEntry() throws IOException {
        FileSystem.AtomicAction aa = new SaveImpl(this);
        FileUtil.runAtomicAction(aa);
//        super.saveDocument();
        // #32777 - it can happen that save operation was interrupted
        // and file is still modified. Mark it unmodified only when it is really
        // not modified.
        if (!env.isModified()) {
            myEntry.setModified(false);
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:PropertiesEditorSupport.java


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