當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。