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


Java Mutex类代码示例

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


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

示例1: setActiveConfiguration

import org.openide.util.Mutex; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:J2SEConfigurationProviderTest.java

示例2: selectUrl

import org.openide.util.Mutex; //导入依赖的package包/类
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;
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:Repository.java

示例3: getSourceLevel

import org.openide.util.Mutex; //导入依赖的package包/类
@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;
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:SourceLevelQueryImpl.java

示例4: showFinishedInfo

import org.openide.util.Mutex; //导入依赖的package包/类
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);
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:BasicReplaceResultsPanel.java

示例5: refreshName

import org.openide.util.Mutex; //导入依赖的package包/类
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);
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:MergeDialogComponent.java

示例6: getSharedLibFolder

import org.openide.util.Mutex; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ProjectLibraryProvider.java

示例7: testFileEncodingQuery

import org.openide.util.Mutex; //导入依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:FileEncodingQueryTest.java

示例8: puComboboxActionPerformed

import org.openide.util.Mutex; //导入依赖的package包/类
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 {
            //
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:JPQLEditorTopComponent.java

示例9: nodeDestroyed

import org.openide.util.Mutex; //导入依赖的package包/类
/** 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;
                }
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:NodeOperationImpl.java

示例10: setUp

import org.openide.util.Mutex; //导入依赖的package包/类
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");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:J2SEPersistenceProviderTest.java

示例11: setupsChanged

import org.openide.util.Mutex; //导入依赖的package包/类
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();
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:MultiDiffPanelController.java

示例12: accepted

import org.openide.util.Mutex; //导入依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:UnboundTargetAlert.java

示例13: fireChange

import org.openide.util.Mutex; //导入依赖的package包/类
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);
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ProjectProperties.java

示例14: testNoCancelButtonWhenNonCancellableInvocation

import org.openide.util.Mutex; //导入依赖的package包/类
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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ProgressSupportTest.java

示例15: projectOpened

import org.openide.util.Mutex; //导入依赖的package包/类
@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;
                    }
                });

    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:JAXBWizProjectOpenedHookImpl.java


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