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


Java FileSystem.AtomicAction方法代码示例

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


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

示例1: getTime

import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
/** The time when the data has been modified
*/
public Date getTime() {
    // #32777 - refresh file object and return always the actual time
    action = new FileSystem.AtomicAction() {
        public void run() throws IOException {
            getFileImpl().refresh(false);
        }
    };
    try {
        getFileImpl().getFileSystem().runAtomicAction(action);
    } catch (IOException ex) {
        //Nothing to do here
    }
    
    return getFileImpl ().lastModified ();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DataEditorSupport.java

示例2: testCreatedShadowFoundInParent

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

示例3: runConcurrent

import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
public static Future<Void> runConcurrent(@NonNull final FileSystem.AtomicAction action) throws IOException {
    Parameters.notNull("action", action);   //NOI18N
    final FileManagerTransaction fmtx = TransactionContext.get().get(FileManagerTransaction.class);
    if (fmtx == null) {
        throw new IllegalStateException("No FileManagerTransaction");   //NOI18N
    }
    final Future<Void> res;
    fmtx.fork();
    try {
        action.run();
    } finally {
        res = fmtx.join();
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:FileManagerTransaction.java

示例4: setActiveAtomicAction

import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
public void setActiveAtomicAction(FileSystem.AtomicAction aa) {
    synchronized (this) {
        LOGGER.log(Level.FINE, "setActiveAtomicAction({0})", aa); //NOI18N
        if (aa != null) {
            assert activeAA == null : "Expecting no activeAA: " + activeAA; //NOI18N
            activeAA = aa;
        } else {
            assert activeAA != null : "Expecting some activeAA"; //NOI18N
            activeAA = null;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:RepositoryUpdater.java

示例5: isOurs

import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
/** Check if a given file event in the Modules/ folder was a result
 * of our own manipulations, as opposed to some other code (or polled
 * refresh) manipulating one of these XML files. See #15573.
 */
private boolean isOurs(FileEvent ev) {
    for (FileSystem.AtomicAction action : myAtomicActions) {
        if (ev.firedFrom(action)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ModuleList.java

示例6: runCheckCode

import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
private static void runCheckCode(FileSystem.AtomicAction code) throws IOException {
    try {
        reentrantCheck.set(Boolean.TRUE);
        code.run();
    } finally {
        reentrantCheck.set(null);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ProvidedExtensionsProxy.java

示例7: testWhoCreatesConstructor

import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
public void testWhoCreatesConstructor() throws Exception {
    FileObject root = FileUtil.getConfigRoot();
    FileObject fo = FileUtil.createFolder (root, "ToolbarsWhoCreates");
    final DataFolder df = DataFolder.findFolder(fo);
    ToolbarPool pool = new ToolbarPool(df);

    assertEquals("No children now", 0, pool.getToolbars().length);

    class Atom implements FileSystem.AtomicAction {

        FileObject m1, m2;

        public void run() throws IOException {
            m1 = FileUtil.createFolder(df.getPrimaryFile(), "m1");
            DataFolder f1 = DataFolder.findFolder(m1);
            InstanceDataObject.create(f1, "X", MyAction.class);
        }
    }
    Atom atom = new Atom();
    df.getPrimaryFile().getFileSystem().runAtomicAction(atom);

    assertEquals("One toolbar is there", 1, pool.getToolbars().length);
    Toolbar tb = pool.getToolbars()[0];
    assertEquals("Pool name", "m1", tb.getName());
    assertEquals("Has one subcomponent", 1, tb.getComponents().length);
    Object o1 = tb.getComponent(0);
    if (!(o1 instanceof JButton)) {
        fail("Need JPanel " + o1);
    }
    assertEquals("And now the action is created", 1, MyAction.counter);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:ToolbarPoolTest.java

示例8: writeInstance

import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
private static Object writeInstance (final FileObject folder, final String name, final Object inst) throws IOException {
    class W implements FileSystem.AtomicAction {
        public Object create;
        
        public void run () throws IOException {
            FileObject fo = FileUtil.createData (folder, name);
            FileLock lock = fo.lock ();
            ObjectOutputStream oos = new ObjectOutputStream (fo.getOutputStream (lock));
            oos.writeObject (inst);
            oos.close ();
            lock.releaseLock ();
            
            DataObject obj = DataObject.find (fo);
            InstanceCookie ic = obj.getCookie(InstanceCookie.class);
            
            assertNotNull ("Cookie created", ic);
            try {
                create = ic.instanceCreate ();
                assertEquals ("The same instance class", inst.getClass(), create.getClass ());
            } catch (ClassNotFoundException ex) {
                fail (ex.getMessage ());
            }
        }
    }
    W w = new W ();
    folder.getFileSystem ().runAtomicAction (w);
    return w.create;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:ToolbarPoolTest.java

示例9: testClientPropertiesMayBePropagated

import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
public void testClientPropertiesMayBePropagated() throws Exception {
    mb.addContainerListener(this);
    assertEquals("No children now", 0, mb.getComponentCount());
    
    class Atom implements FileSystem.AtomicAction {
        FileObject m1, m2;
        
        public void run() throws IOException {
            m1 = FileUtil.createFolder(df.getPrimaryFile(), "m1");
            m1.setAttribute("property-prefix", "ahoj.");
            m1.setAttribute("ahoj.jardo", "Hi!");
            m2 = FileUtil.createFolder(df.getPrimaryFile(), "m2");
            m2.setAttribute("property-prefix", "buk-");
            m2.setAttribute("buk-muk", "Hello!");
        }
    }
    Atom atom = new Atom();
    df.getPrimaryFile().getFileSystem().runAtomicAction(atom);
    mb.waitFinished();
    
    assertEquals("Two children there", 2, mb.getComponentCount());
    final JMenuItem c0 = (JMenuItem) mb.getComponent(0);
    assertEquals("Programatic names deduced from the folder", "m1", c0.getName());
    final JMenuItem c1 = (JMenuItem) mb.getComponent(1);
    assertEquals("Programatic names deduced from the folder", "m2", c1.getName());
    
    assertEquals("Hi!", c0.getClientProperty("jardo"));
    assertEquals("Hello!", c1.getClientProperty("muk"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:MenuBarTest.java

示例10: testDeleteInvalidatesCreateCreatesWhenChangeHappensInAtomicAction

import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
public void testDeleteInvalidatesCreateCreatesWhenChangeHappensInAtomicAction () throws Exception {
    DataShadow shade = original.createShadow (folder);
    FileObject primary = shade.getPrimaryFile ();

    assertTrue ("Is valid now", shade.isValid ());
    
    class DeleteCreate implements FileSystem.AtomicAction {
        public FileObject fo;
        
        public void run () throws java.io.IOException {
            FileSystem fs = original.getPrimaryFile ().getFileSystem ();
            String create = original.getPrimaryFile ().getPath ();
            original.getPrimaryFile ().delete ();
            
            fo = FileUtil.createData (fs.getRoot (), create);
        }
    }
    DeleteCreate deleteCreate = new DeleteCreate ();
    original.getPrimaryFile ().getFileSystem ().runAtomicAction (deleteCreate);
    
    assertTrue ("Shadow is valid (again)", shade.isValid ());
    assertFalse ("Original is gone", original.isValid ());
    DataObject orig = DataObject.find (deleteCreate.fo);
    if (orig == original) {
        fail ("new original shall be created");
    }
    assertTrue ("New orig is valid", orig.isValid ());
    
    // life would be nicer without this sleep, but somewhere inside
    // the DataShadow validation a request is send to RP with a delay
    // to not slow down regular apps. If you managed to kill next line,
    // you will have done the right job. Meanwhile it is here:
    Thread.sleep (2000);
    
    assertEquals ("Shadow's original is updated", orig, shade.getOriginal ());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:DataShadowTest.java

示例11: runAtomicAction

import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
public void runAtomicAction(FileSystem.AtomicAction task) throws IOException {
    assert atomicAction == null;
    atomicAction = task;
    try {
        fileSystem.runAtomicAction(task);
    } finally {
        atomicAction = null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:StorageImpl.java

示例12: saveThisEntry

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

示例13: testNumericOrdering

import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
public void testNumericOrdering() throws Exception {
    class Tst implements FileSystem.AtomicAction {
        public void run() throws IOException {
            init();
        }
        
        void init() throws IOException {
            FileObject inst = FileUtil.createData(root, "inst/positional/X.instance");
            inst.setAttribute("instanceCreate", Long.valueOf(1000));
            inst.setAttribute("position", 3);
            FileObject inst2 = FileUtil.createData(root, "inst/positional/A.instance");
            inst2.setAttribute("instanceCreate", Long.valueOf(500));
            inst2.setAttribute("position", 1);
            FileObject inst3 = FileUtil.createData(root, "inst/positional/B.instance");
            inst3.setAttribute("instanceCreate", Long.valueOf(1500));
            inst3.setAttribute("position", 4);
            FileObject inst4 = FileUtil.createData(root, "inst/positional/C.instance");
            inst4.setAttribute("instanceCreate", Long.valueOf(700));
            inst4.setAttribute("position", 2);
        }
        
        void verify() {
            Lookup l = Lookups.forPath("inst/positional");
            Iterator<? extends Long> lng = l.lookupAll(Long.class).iterator();
            assertEquals(Long.valueOf(500), lng.next());
            assertEquals(Long.valueOf(700), lng.next());
            assertEquals(Long.valueOf(1000), lng.next());
            assertEquals(Long.valueOf(1500), lng.next());
            Iterator<? extends Lookup.Item<Long>> items = l.lookupResult(Long.class).allItems().iterator();
            assertEquals("inst/positional/A", items.next().getId());
            assertEquals("inst/positional/C", items.next().getId());
            assertEquals("inst/positional/X", items.next().getId());
            assertEquals("inst/positional/B", items.next().getId());
        }
    }
    
    Tst tst = new Tst();
    root.getFileSystem().runAtomicAction(tst);
    tst.verify();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:RecognizeInstanceFilesTest.java

示例14: writeOut

import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
/** Write information about a module out to disk.
 * If the old status is given as null, this is a newly
 * added module; create an appropriate status and return it.
 * Else update the existing status and return it (it is
 * assumed properties are already updated).
 * Should write the XML and create/rewrite/delete the serialized
 * installer file as needed.
 */
private DiskStatus writeOut(Module m, DiskStatus old) throws IOException {
    final DiskStatus nue;
    if (old == null) {
        nue = new DiskStatus();
        nue.module = m;
        nue.setDiskProps(computeProperties(m));
    } else {
        nue = old;
    }
    FileSystem.AtomicAction aa = new FileSystem.AtomicAction() {
        public void run() throws IOException {
            if (nue.file == null) {
                nue.file = FileUtil.createData(folder, ((String)nue.diskProps.get("name")).replace('.', '-') + ".xml"); // NOI18N
            } else {
                // Just verify that no one else touched it since we last did.
                if (/*nue.lastApprovedChange != nue.file.lastModified().getTime()*/nue.dirty) {
                    // Oops, something is wrong. #156764 - log at lower level.
                    LOG.log(Level.INFO, null, new IOException("Will not clobber external changes in " + nue.file));
                    return;
                }
            }
            LOG.fine("ModuleList: (re)writing " + nue.file);
            FileLock lock = nue.file.lock();
            try {
                OutputStream os = nue.file.getOutputStream(lock);
                try {
                    writeStatus(nue.diskProps, os);
                } finally {
                    os.close();
                }
            } finally {
                lock.releaseLock();
            }
            //nue.lastApprovedChange = nue.file.lastModified().getTime();
        }
    };
    myAtomicActions.add(aa);
    folder.getFileSystem().runAtomicAction(aa);
    return nue;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:49,代码来源:ModuleList.java

示例15: saveDocument

import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
/** Saves document. Overrides superclass method, adds checking
 * for read-only property of saving file and warns user in that case. */
@Override
public void saveDocument() throws IOException {
    FileSystem.AtomicAction aa = new SaveImpl(this);
    FileUtil.runAtomicAction(aa);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:DataEditorSupport.java


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