Java 类org.openide.util.Mutex 实例源码

项目:incubator-netbeans    文件:J2SEConfigurationProviderTest.java   
@SuppressWarnings({"unchecked", "rawtypes"})
private static void setActiveConfiguration(
        ProjectConfigurationProvider<?> pcp,
        final ProjectConfiguration pc) throws IOException {
    final ProjectConfigurationProvider _pcp = pcp;
    try {
        ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
            @Override
            public Void run() throws Exception {
                _pcp.setActiveConfiguration(pc);
                return null;
            }
        });
    } catch (MutexException me) {
        final Throwable inner = me.getCause();
        throw (inner instanceof IOException) ?
           (IOException) inner :
           new IOException (inner);
    }
}
项目:incubator-netbeans    文件:Repository.java   
public void selectUrl (final SVNUrl url, final boolean force) {
    Mutex.EVENT.readAccess(new Mutex.Action<Void>() {
        @Override
        public Void run () {
            DefaultComboBoxModel dcbm = (DefaultComboBoxModel) repositoryPanel.urlComboBox.getModel();
            int idx = dcbm.getIndexOf(url.toString());
            if(idx > -1) {
                dcbm.setSelectedItem(url.toString());    
            } else if(force) {
                RepositoryConnection rc = new RepositoryConnection(url.toString());
                dcbm.addElement(rc);
                dcbm.setSelectedItem(rc);
            }
            return null;
        }
    });
}
项目:incubator-netbeans    文件:SourceLevelQueryImpl.java   
@Override
public Result getSourceLevel(final FileObject file) {
    return ProjectManager.mutex().readAccess(new Mutex.Action<Result>() {
        @Override
        public Result run() {
            final Map<FileObject,R> data = init(true);
            for (Map.Entry<FileObject,R> entry : data.entrySet()) {
                FileObject root = entry.getKey();
                if (root == file || FileUtil.isParentOf(root, file)) {
                    return entry.getValue();
                }
            }
            return null;
        }
    });
}
项目:incubator-netbeans    文件:BasicReplaceResultsPanel.java   
public void showFinishedInfo() {
    final AbstractNode an = new AbstractNode(Children.LEAF);
    an.setIconBaseWithExtension(
            "org/netbeans/modules/search/res/info.png");            //NOI18N
    an.setDisplayName(NbBundle.getMessage(ResultView.class,
            "TEXT_INFO_REPLACE_FINISHED", //NOI18N
            resultModel.getSelectedMatchesCount()));
    Mutex.EVENT.writeAccess(new Runnable() {
        @Override
        public void run() {
            getOutlineView().getOutline().setRootVisible(true);
            getExplorerManager().setRootContext(an);
            getOutlineView().validate();
            getOutlineView().repaint();
            btnNext.setEnabled(false);
            btnPrev.setEnabled(false);
            btnTreeView.setEnabled(false);
            btnFlatView.setEnabled(false);
            btnExpand.setEnabled(false);
        }
    });
}
项目:incubator-netbeans    文件:MergeDialogComponent.java   
private void refreshName () {
    Mutex.EVENT.readAccess(new Runnable() {
        @Override
        public void run () {
            String name = org.openide.util.NbBundle.getMessage(MergeDialogComponent.class, "MergeDialogComponent.title");
            Component[] panels;
            synchronized (MergeDialogComponent.this) {
                panels = mergeTabbedPane.getComponents();
            }
            for (int i = 0; i < panels.length; i++) {
                MergePanel panel = (MergePanel) panels[i];
                MergeNode node = nodesForPanels.get(panel);
                if (node.getLookup().lookup(SaveCookie.class) != null) {
                    name = "<html><b>" + name + "*</b></html>"; //NOI18N
                    break;
                }
            }
            setName(name);
        }
    });
}
项目:incubator-netbeans    文件:ProjectLibraryProvider.java   
private static FileObject getSharedLibFolder(final File libBaseFolder, final Library lib) throws IOException {
    FileObject sharedLibFolder;
    try {
        sharedLibFolder = ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<FileObject>() {
            public FileObject run() throws IOException {
                FileObject lf = FileUtil.toFileObject(libBaseFolder);
                if (lf == null) {
                    lf = FileUtil.createFolder(libBaseFolder);
                }
                return lf.createFolder(getUniqueName(lf, lib.getName(), null));
            }
        });
    } catch (MutexException ex) {
        throw (IOException)ex.getException();
    }
    return sharedLibFolder;
}
项目:incubator-netbeans    文件:FileEncodingQueryTest.java   
public void testFileEncodingQuery () throws Exception {
    final Charset UTF8 = Charset.forName("UTF-8");
    final Charset ISO15 = Charset.forName("ISO-8859-15");
    final Charset CP1252 = Charset.forName("CP1252");
    FileObject java = sources.createData("a.java");
    Charset enc = FileEncodingQuery.getEncoding(java);
    assertEquals(UTF8,enc);
    FileObject xml = sources.createData("b.xml");
    enc = FileEncodingQuery.getEncoding(xml);
    assertEquals(ISO15,enc);
    ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
        public Void run() throws Exception {
            EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
            ep.setProperty(ProjectProperties.SOURCE_ENCODING, CP1252.name());
            helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
            ProjectManager.getDefault().saveProject(prj);
            return null;
        }
    });
    enc = FileEncodingQuery.getEncoding(java);
    assertEquals(CP1252,enc);
    FileObject standAloneJava = scratch.createData("b.java");
    enc = FileEncodingQuery.getEncoding(standAloneJava);
    assertEquals(Charset.defaultCharset(), enc);
}
项目:incubator-netbeans    文件:JPQLEditorTopComponent.java   
private void puComboboxActionPerformed() {
    if (puComboBox.getSelectedItem() != null) {
        FileObject pXml = puObject.getPrimaryFile();
        Project project = pXml != null ? FileOwnerQuery.getOwner(pXml) : null;
        PersistenceEnvironment pe = project != null ? project.getLookup().lookup(PersistenceEnvironment.class) : null;

        PersistenceUnit pu = (PersistenceUnit) puConfigMap.get(puComboBox.getSelectedItem());
        dbconn = JPAEditorUtil.findDatabaseConnection(pu, pe.getProject());
        if (dbconn != null) {
            if (dbconn.getJDBCConnection() == null) {
                Mutex.EVENT.readAccess(new Mutex.Action<DatabaseConnection>() {
                    @Override
                    public DatabaseConnection run() {
                        ConnectionManager.getDefault().showConnectionDialog(dbconn);
                        return dbconn;
                    }
                });
            }
        } else {
            //
        }
    }
}
项目:incubator-netbeans    文件:NodeOperationImpl.java   
/** Fired when the node is deleted.
 * @param ev event describing the node
 */
@Override
public void nodeDestroyed(NodeEvent ev) {
    Node destroyedNode = ev.getNode();
    // stop to listen to destroyed node
    destroyedNode.removeNodeListener(this);
    listenerSet.remove(destroyedNode);
    // close top component (our outer class) if last node was destroyed
    if (listenerSet.isEmpty()) {
        // #68943 - stop to listen, as we are waving goodbye :-)
        tc.removePropertyChangeListener(this);
        Mutex.EVENT.readAccess(new Runnable() {
            @Override
            public void run() {
                if (dialog != null) {
                    dialog.setVisible(false);
                    dialog.dispose();
                    dialog = null;
                }
            }
        });
    }
}
项目:incubator-netbeans    文件:J2SEPersistenceProviderTest.java   
public void setUp() throws Exception {
    // in an attempt to find the cause of issue 90762
    Logger.getLogger(PersistenceScopesHelper.class.getName()).setLevel(Level.FINEST);
    // setup the project
    FileObject scratch = TestUtil.makeScratchDir(this);
    final FileObject projdir = scratch.createFolder("proj");
    MockLookup.setLayersAndInstances();
    // issue 90762: prevent AntProjectHelper from firing changes in a RP thread, which interferes with tests
    // see APH.fireExternalChange
    ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
        public Void run() throws Exception{
            J2SEProjectGenerator.setDefaultSourceLevel(new SpecificationVersion ("1.6"));
            J2SEProjectGenerator.createProject(FileUtil.toFile(projdir), "proj", "foo.Main", "manifest.mf", null, false);
            J2SEProjectGenerator.setDefaultSourceLevel(null);
            return null;
        }
    });
    project = ProjectManager.getDefault().findProject(projdir);
    Sources src = project.getLookup().lookup(Sources.class);
    SourceGroup[] groups = src.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    root = groups[0].getRootFolder();
    provider = project.getLookup().lookup(J2SEPersistenceProvider.class);
    persistenceLocation = new File(FileUtil.toFile(project.getProjectDirectory().getFileObject("src")), "META-INF");
}
项目:incubator-netbeans    文件:MultiDiffPanelController.java   
private void setupsChanged (final Map<File, Setup> newSetups, final List<DiffNode> nodes) {
    final Map<File, EditorCookie> cookies = getCookiesFromSetups(newSetups);
    final DiffNode[] nodeArray = nodes.toArray(new DiffNode[nodes.size()]);
    final Object modelDataList = fileListComponent.prepareModel(nodeArray);
    final Object modelDataTree = fileTreeComponent.prepareModel(nodeArray);
    Mutex.EVENT.readAccess(new Runnable() {
        @Override
        public void run() {
            dividerSet = false;
            setSetups(newSetups, cookies);
            fileListComponent.setModel(nodeArray, new HashMap<File, EditorCookie>(cookies), modelDataList);
            fileTreeComponent.setModel(nodeArray, sort(cookies, nodeArray), modelDataTree);
            updateView();
        }
    });
}
项目:incubator-netbeans    文件:UnboundTargetAlert.java   
/**
 * Show the alert.
 * If accepted, generate a binding for the command (and add a context menu item for the project).
 * @return true if the alert was accepted and there is now a binding, false if cancelled
 * @throws IOException if there is a problem writing bindings
 */
public boolean accepted() throws IOException {
    String projectDisplayName = ProjectUtils.getInformation(project).getDisplayName();
    if (displayAlert(projectDisplayName)) {
        try {
            ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
                public Void run() throws IOException {
                    generateBindingAndAddContextMenuItem();
                    ProjectManager.getDefault().saveProject(project);
                    return null;
                }
            });
        } catch (MutexException e) {
            throw (IOException) e.getException();
        }
        return true;
    } else {
        return false;
    }
}
项目:incubator-netbeans    文件:ProjectProperties.java   
private void fireChange() {
    if (!cs.hasListeners()) {
        return;
    }
    final Mutex.Action<Void> action = new Mutex.Action<Void>() {
        public Void run() {
            cs.fireChange();
            return null;
        }
    };
    if (ProjectManager.mutex().isWriteAccess()) {
        // Run it right now. postReadRequest would be too late.
        ProjectManager.mutex().readAccess(action);
    } else if (ProjectManager.mutex().isReadAccess()) {
        // Run immediately also. No need to switch to read access.
        action.run();
    } else {
        // Not safe to acquire a new lock, so run later in read access.
        RP.post(new Runnable() {
            public void run() {
                ProjectManager.mutex().readAccess(action);
            }
        });
    }
}
项目:incubator-netbeans    文件:ProgressSupportTest.java   
public void testNoCancelButtonWhenNonCancellableInvocation() {
    List<ProgressSupport.Action> actions = new ArrayList<ProgressSupport.Action>();

    final AtomicBoolean cancelVisible = new AtomicBoolean();

    actions.add(new ProgressSupport.BackgroundAction() {
        public void run(final ProgressSupport.Context actionContext) {
            cancelVisible.set(Mutex.EVENT.readAccess(new Mutex.Action<Boolean>() {
                public Boolean run() {
                    return actionContext.getPanel().isCancelVisible();
                }
            }));
        }
    });

    ProgressSupport.invoke(actions);
    assertFalse(cancelVisible.get());
}
项目:incubator-netbeans    文件:JAXBWizProjectOpenedHookImpl.java   
@Override
protected void projectOpened() {
    Schemas scs = ProjectHelper.getXMLBindingSchemas(prj);
    if (scs != null && scs.sizeSchema() > 0){
        BigDecimal v = scs.getVersion();
        if ((v == null) || (JAXBWizModuleConstants.LATEST_CFG_VERSION.compareTo(v) > 0)){
            ProjectHelper.migrateProjectFromPreDot5Version(prj);
        }
        // Set endorsed classpath
        ProjectManager.mutex().writeAccess(
                new Mutex.Action() {
                    public Object run() {
                        try {
                            ProjectHelper.addJaxbApiEndorsed(prj);
                        } catch (java.io.IOException ex) {
                            ex.printStackTrace();
                        }
                        return null;
                    }
                });

    }
}
项目:incubator-netbeans    文件:ModuleList.java   
static ModuleList findOrCreateModuleListFromNetBeansOrgSources(final File root) throws IOException {
    return runProtected(sourceLists, new Mutex.ExceptionAction<ModuleList>() {
        public ModuleList run() throws IOException {
            ModuleList list = sourceLists.get(root);
            if (list == null) {
                File nbdestdir = findNetBeansOrgDestDir(root);
                if (nbdestdir.equals(new File(new File(root, "nbbuild"), "netbeans"))) { // NOI18N
                    list = createModuleListFromNetBeansOrgSources(root);
                } else {
                    // #143236: have a customized dest dir, perhaps referenced from orphan modules.
                    Map<String, ModuleEntry> entries = new HashMap<String, ModuleEntry>();
                    doScanNetBeansOrgSources(entries, root, 1, root, nbdestdir, null, Collections.<File>emptySet());
                    ModuleList sources = new ModuleList(entries, root);
                    ModuleList binaries = findOrCreateModuleListFromBinaries(nbdestdir);
                    list = merge(new ModuleList[] {sources, binaries}, root);
                }
                sourceLists.put(root, list);
            }
            return list;
        }
    });
}
项目:incubator-netbeans    文件:RebaseAction.java   
@NbBundle.Messages({
    "LBL_RebaseAction.continueExternalRebase.title=Cannot Continue Rebase",
    "MSG_RebaseAction.continueExternalRebase.text=Rebase was probably started by an external tool "
            + "in non-interactive mode. \nNetBeans IDE cannot continue and finish the action.\n\n"
            + "Please use the external tool or abort and restart rebase inside NetBeans."
})
private boolean checkRebaseFolder (File repository) {
    File folder = getRebaseFolder(repository);
    File messageFile = new File(folder, MESSAGE);
    if (messageFile.exists()) {
        return true;
    } else {
        Mutex.EVENT.readAccess(new Runnable() {
            @Override
            public void run () {
                JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
                    Bundle.MSG_RebaseAction_continueExternalRebase_text(),
                    Bundle.LBL_RebaseAction_continueExternalRebase_title(),
                    JOptionPane.ERROR_MESSAGE);
            }
        });
        return false;
    }
}
项目:incubator-netbeans    文件:UpdateHelper.java   
/**
 * Request saving of update. If the project is not of current version and the project can be updated, then
 * the update is done.
 * @return <code>true</code> if the metadata are of current version or updated.
 * @throws IOException if error occurs during saving.
 */
public boolean requestUpdate() throws IOException {
    if (isCurrent()) {
        return true;
    }
    if (!updateProject.canUpdate()) {
        return false;
    }
    try {
        return ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Boolean>() {
            public Boolean run() throws IOException {                                        
                if (!isCurrent()) {
                    updateProject.saveUpdate(null);
                }
                return true;
            }
        });

    } catch (MutexException ex) {
        Exception inner = ex.getException();
        if (inner instanceof IOException) {
            throw (IOException) inner;
        }
        throw (RuntimeException) inner;
    }
}
项目:incubator-netbeans    文件:ProjectXMLManagerTest.java   
public void testExceptionWhenAddingTheSameModuleDependencyTwice() throws Exception {
    final NbModuleProject testingProject = generateTestingProject();
    final ProjectXMLManager testingPXM = new ProjectXMLManager(testingProject);
    ModuleEntry me = testingProject.getModuleList().getEntry(
            "org.netbeans.modules.java.project");
    final ModuleDependency md = new ModuleDependency(me, "1", null, false, true);
    boolean result = ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Boolean>() {
        public Boolean run() throws IOException {
            Element confData = testingProject.getPrimaryConfigurationData();
            Element moduleDependencies = ProjectXMLManager.findModuleDependencies(confData);
            ProjectXMLManager.createModuleDependencyElement(moduleDependencies, md, null);
            ProjectXMLManager.createModuleDependencyElement(moduleDependencies, md, null);
            testingProject.putPrimaryConfigurationData(confData);
            return true;
        }
    });
    assertTrue("adding dependencies", result);
    ProjectManager.getDefault().saveProject(testingProject);
    try {
        testingPXM.getDirectDependencies();
        fail("IllegalStateException was expected");
    } catch (IOException x) {
        // OK, expected exception was thrown
    }
}
项目:incubator-netbeans    文件:FreeformFileEncodingQueryImpl.java   
@Override
public Charset getEncoding(final FileObject file) {
    return ProjectManager.mutex().readAccess(new Mutex.Action<Charset>() {
        @Override
        public Charset run() {
            Charset toReturn = null;
            synchronized (FreeformFileEncodingQueryImpl.this) {
                if (encodingsCache == null) {
                    computeEncodingsCache();
                }
                if (encodingsCache.size() > 0) {
                    Set<File> roots = encodingsCache.keySet();
                    File parent = getNearestParent(roots, FileUtil.toFile(file));
                    if (parent != null) {
                        toReturn = encodingsCache.get(parent);
                    }
                }
            }
            return toReturn;
        }
    });
}
项目:incubator-netbeans    文件:ProjectXMLManagerTest.java   
public void testRemoveClassPathExtensions() throws Exception {
    final NbModuleProject testingProject = generateTestingProject();
    final ProjectXMLManager testingPXM = new ProjectXMLManager(testingProject);
    // apply and save project
    boolean result = ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Boolean>() {
        public Boolean run() throws IOException {
            testingPXM.removeClassPathExtensions();
            return true;
        }
    });
    assertTrue("removing class-path-extensions", result);
    ProjectManager.getDefault().saveProject(testingProject);

    final Map<String, String> newCPExts = testingPXM.getClassPathExtensions();
    assertEquals("number of class-path-extensions", 0, newCPExts.size());
}
项目:incubator-netbeans    文件:ProjectXMLManagerTest.java   
public void testDependenciesOrder() throws Exception { // #62003
    final NbModuleProject testingProject = generateTestingProject();
    final ProjectXMLManager testingPXM = new ProjectXMLManager(testingProject);
    ModuleEntry me = testingProject.getModuleList().getEntry(
            "org.netbeans.modules.java.project");
    final ModuleDependency md = new ModuleDependency(me, "1", null, false, true);
    boolean result = ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Boolean>() {
        public Boolean run() throws IOException, CyclicDependencyException {
            testingPXM.addDependency(md);
            return true;
        }
    });
    assertTrue("adding dependencies", result);
    ProjectManager.getDefault().saveProject(testingProject);
    checkDependenciesOrder(testingProject);
}
项目:incubator-netbeans    文件:SingleModulePropertiesTest.java   
public void testGetPublicPackages() throws Exception {
    final NbModuleProject p = generateStandaloneModule("module1");
    FileUtil.createData(p.getSourceDirectory(), "org/example/module1/One.java");
    FileUtil.createData(p.getSourceDirectory(), "org/example/module1/resources/Two.java");

    // apply and save project
    boolean result = ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Boolean>() {
        public Boolean run() throws IOException {
            ProjectXMLManager pxm = new ProjectXMLManager(p);
            pxm.replacePublicPackages(Collections.singleton("org.example.module1"));
            return true;
        }
    });
    assertTrue("replace public packages", result);
    ProjectManager.getDefault().saveProject(p);

    SingleModuleProperties props = loadProperties(p);
    PublicPackagesTableModel pptm = props.getPublicPackagesModel();
    assertEquals("number of available public packages", 2, pptm.getRowCount());
    assertEquals("number of selected public packages", 1, pptm.getSelectedPackages().size());
}
项目:incubator-netbeans    文件:SourceRoots.java   
@Override
public String[] getRootProperties() {
    synchronized (this) {
        if (sourceRootProperties != null) {
            return sourceRootProperties.toArray(new String[sourceRootProperties.size()]);
        }
    }
    return ProjectManager.mutex().readAccess(new Mutex.Action<String[]>() {
        @Override
        public String[] run() {
            synchronized (SourceRoots.this) {
                if (sourceRootProperties == null) {
                    readProjectMetadata();
                }
                return sourceRootProperties.toArray(new String[sourceRootProperties.size()]);
            }
        }
    });
}
项目:incubator-netbeans    文件:CopySupport.java   
@Override
public Transferable paste() throws IOException {
    if (java.awt.EventQueue.isDispatchThread())
        return doPaste();
    else { // reinvoke synchronously in AWT thread
        try {
            return Mutex.EVENT.readAccess(this);
        }
        catch (MutexException ex) {
            Exception e = ex.getException();
            if (e instanceof IOException)
                throw (IOException) e;
            else { // should not happen, ignore
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
                return ExTransferable.EMPTY;
            }
        }
    }
}
项目:incubator-netbeans    文件:CopySupport.java   
@Override
public Transferable paste() throws IOException {
    if (java.awt.EventQueue.isDispatchThread()) {
        return doPaste();
    }
    else { // reinvoke synchronously in AWT thread
        try {
            return Mutex.EVENT.readAccess(this);
        }
        catch (MutexException ex) {
            Exception e = ex.getException();
            if (e instanceof IOException)
                throw (IOException) e;
            else { // should not happen, ignore
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
                return transferable;
            }
        }
    }
}
项目:incubator-netbeans    文件:SelectUriStep.java   
public SelectUriStep (File repositoryFile, Map<String, GitRemoteConfig> remotes, Mode mode) {
    this.repositoryFile = repositoryFile;
    this.repository = new RemoteRepository(null);
    this.panel = new SelectUriPanel(repository.getPanel());
    this.remotes = remotes;
    this.inputFields = new JComponent[] {
        panel.cmbConfiguredRepositories,
        panel.rbConfiguredUri,
        panel.rbCreateNew,
        panel.lblRemoteNames,
        panel.cbPersistRemote,
        panel.cmbRemoteNames
    };
    this.mode = mode;
    remoteNameEditTimer = new Timer(300, this);
    remoteNameEditTimer.setRepeats(false);
    remoteNameEditTimer.stop();
    fillPanel();
    attachListeners();
    Mutex.EVENT.readAccess(new Runnable() {
        @Override
        public void run () {
            enableFields();
            validateBeforeNext();
        }
    });
}
项目:incubator-netbeans    文件:OpenFilesSearchScopeProvider.java   
protected boolean isFromEditorWindow(DataObject dobj,
        final TopComponent tc) {
    final EditorCookie editor = dobj.getLookup().lookup(
            EditorCookie.class);
    if (editor != null) {
        return Mutex.EVENT.readAccess(new Action<Boolean>() {
            @Override
            public Boolean run() {
                return (tc instanceof CloneableTopComponent) // #246597
                        || NbDocument.findRecentEditorPane(editor) != null;
            }
        });
    }
    return false;
}
项目:incubator-netbeans    文件:OpenProjectList.java   
public Project getMainProject() {
    return MUTEX.readAccess(new Mutex.Action<Project>() {
        public @Override Project run() {
            return mainProject;
        }
    });
}
项目:incubator-netbeans    文件:NbRepository.java   
@Override
protected void refreshAdditionalLayers() {
    Main.getModuleSystem().getManager().mutex().writeAccess(new Mutex.Action<Void>() {
        @Override
        public Void run() {
            try {
                ModuleLayeredFileSystem.getInstallationModuleLayer().setURLs(null);
            } catch (Exception ex) {
                Exceptions.printStackTrace(ex);
            }
            return null;
        }
    });
}
项目:incubator-netbeans    文件:AbstractSearchResultsPanel.java   
public void searchFinished() {
    Mutex.EVENT.writeAccess(new Runnable() {
        @Override
        public void run() {
            showRefreshButton();
        }
    });
}
项目:incubator-netbeans    文件:ActiveConfigAction.java   
private static @CheckForNull ProjectConfiguration getActiveConfiguration(final @NonNull ProjectConfigurationProvider<?> pcp) {
    return ProjectManager.mutex().readAccess(new Mutex.Action<ProjectConfiguration>() {
        public @Override ProjectConfiguration run() {
            return pcp.getActiveConfiguration();
        }
    });
}
项目:incubator-netbeans    文件:SearchScopeListTest.java   
/**
 * Test for bug 204118 - [71cat] AssertionError at
 * org.netbeans.modules.search.SearchScopeRegistry.addChangeListener.
 */
public void testAddChangeListener() throws InterruptedException,
        InvocationTargetException {

    final CustomChangeListener cl = new CustomChangeListener();
    final CustomChangeListener cl2 = new CustomChangeListener();

    final SearchScopeList ssl = new SearchScopeList();
    ssl.addChangeListener(cl);
    ssl.addChangeListener(cl2);

    Mutex.EVENT.writeAccess(new Mutex.Action<Boolean>() {
        @Override
        public Boolean run() {
            for (SearchScopeDefinition ssd
                    : ssl.getSeachScopeDefinitions()) {
                if (ssd instanceof CustomSearchScope) {
                    ((CustomSearchScope) ssd).fireChangeEvent();
                }
            }
            return true;
        }
    });

    assertEquals(3, cl.getCounter());
    assertEquals(3, cl.getCounter());
}
项目:incubator-netbeans    文件:BaseProgressUtils.java   
@Override
public void runOffEventDispatchThread(Runnable operation, String operationDescr, AtomicBoolean cancelOperation, boolean waitForCanceled, int waitCursorAfter, int dialogAfter) {
    if (Mutex.EVENT.isReadAccess()) {
        // PENDING: the EDT should continue to service events.
        TRIVIAL.post(operation).waitFinished();
    } else {
        operation.run();
    }
}
项目:incubator-netbeans    文件:MenuBar.java   
@Override
public void updateUI() {
    if (EventQueue.isDispatchThread()) {
        super.updateUI();
    } else {
        Mutex.EVENT.readAccess(this);
    }
}
项目:incubator-netbeans    文件:JFXProjectUtils.java   
/**
 * Checks whether file nbproject/jfx-impl.xml equals current template. 
 * @param proj
 * @return
 * @throws IOException 
 */
public static boolean isJFXImplCurrent(final @NonNull Project proj) throws IOException {
    Boolean isJfxCurrent = true;
    final FileObject projDir = proj.getProjectDirectory();
    try {
        isJfxCurrent = ProjectManager.mutex().readAccess(new Mutex.ExceptionAction<Boolean>() {
            @Override
            public Boolean run() throws Exception {
                FileObject jfxBuildFile = projDir.getFileObject(JFX_BUILD_IMPL_PATH); // NOI18N
                Boolean isCurrent = false;
                if (jfxBuildFile != null) {
                    final InputStream in = jfxBuildFile.getInputStream();
                    if(in != null) {
                        try {
                            isCurrent = isJfxImplCurrentVer(computeCrc32( in ));
                        } finally {
                            in.close();
                        }
                    }
                }
                return isCurrent;
            }
        });
    } catch (MutexException mux) {
        isJfxCurrent = false;
        LOGGER.log(Level.INFO, "Problem reading " + JFX_BUILD_IMPL_PATH, mux.getException()); // NOI18N
    }
    return isJfxCurrent;
}
项目:incubator-netbeans    文件:ToolbarWithOverflow.java   
@Override
   public void updateUI() {
Mutex.EVENT.readAccess(new Runnable() {
    @Override
    public void run() {
    superUpdateUI();
    }
});
   }
项目:incubator-netbeans    文件:AnnotationBar.java   
/** Implementation */
@Override
public void removeUpdate(DocumentEvent e) {
    final int length = e.getDocument().getLength();
    Mutex.EVENT.readAccess(new Runnable() {
        @Override
        public void run () {
            if (length == 0) { // external reload
                hideBar();
            }
            repaint();
        }
    });
}
项目:incubator-netbeans    文件:JFXProjectProblems.java   
@NbBundle.Messages({"LBL_ResolveFXJDK=Choose FX-enabled Java Platform - \"{0}\" Project"})
@Override
public Future<Result> resolve() {
    final ChooseOtherPlatformPanel choosePlatform = new ChooseOtherPlatformPanel(type);
    final DialogDescriptor dd = new DialogDescriptor(choosePlatform, Bundle.LBL_ResolveFXJDK(ProjectUtils.getInformation(project).getDisplayName()));
    if (DialogDisplayer.getDefault().notify(dd) == DialogDescriptor.OK_OPTION) {
        final Callable<ProjectProblemsProvider.Result> resultFnc =
                new Callable<Result>() {
            @Override
            public Result call() throws Exception {
                final JavaPlatform jp = choosePlatform.getSelectedPlatform();
                if(jp != null) {
                    try {
                        ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
                            @Override
                            public Void run() throws IOException {
                                platformSetter.setProjectPlatform(jp);
                                JFXProjectUtils.updateClassPathExtension(project);
                                return null;
                            }
                        });
                    } catch (MutexException e) {
                        throw (IOException) e.getCause();
                    }
                    LOGGER.info("Set " + PLATFORM_ACTIVE + " to platform " + jp);
                    return ProjectProblemsProvider.Result.create(ProjectProblemsProvider.Status.RESOLVED);
                }
                return ProjectProblemsProvider.Result.create(ProjectProblemsProvider.Status.UNRESOLVED);
            }
        };
        final RunnableFuture<Result> result = new FutureTask<Result>(resultFnc);
        RP.post(result);
        return result;
    }
    return new JFXProjectProblems.Done(
            Result.create(ProjectProblemsProvider.Status.UNRESOLVED));
}
项目:incubator-netbeans    文件:ReferenceHelper.java   
RawReference getRawReference(final String foreignProjectName, final String id, final boolean escaped) {
    return ProjectManager.mutex().readAccess(new Mutex.Action<RawReference>() {
        public RawReference run() {
            Element references = loadReferences();
            if (references != null) {
                try {
                    return getRawReference(foreignProjectName, id, references, escaped);
                } catch (IllegalArgumentException e) {
                    Logger.getLogger(this.getClass().getName()).log(Level.INFO, null, e);
                }
            }
            return null;
        }
    });
}