org.openide.util.Mutex Java Examples

The following examples show how to use org.openide.util.Mutex. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Repository.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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;
        }
    });
}
 
Example #2
Source File: ProjectProblemsProviders.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<? extends ProjectProblem> getProblems() {
    return problemsProviderSupport.getProblems(new ProjectProblemsProviderSupport.ProblemsCollector() {
        @Override
        public Collection<? extends ProjectProblemsProvider.ProjectProblem> collectProblems() {
            Collection<? extends ProjectProblemsProvider.ProjectProblem> currentProblems = ProjectManager.mutex().readAccess((Mutex.Action<Collection<? extends ProjectProblem>>) () -> {
                final Set<ProjectProblem> newProblems = new LinkedHashSet<ProjectProblem>();
                final Set<File> allFiles = new HashSet<>();
                newProblems.addAll(getReferenceProblems(helper,eval,refHelper,refProps,allFiles,false));
                newProblems.addAll(getPlatformProblems(eval, helper, callback, platformProps,false));
                updateFileListeners(allFiles);
                return Collections.unmodifiableSet(newProblems);
            });
            return currentProblems;
        }
    });
}
 
Example #3
Source File: LexerUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Forces to rebuild the document's {@link TokenHierarchy}.
 * 
 * @since 1.62
 * 
 * @param doc a swing document
 */
public  static void rebuildTokenHierarchy(final Document doc) {
    Mutex.EVENT.readAccess(new Runnable() {
        @Override
        public void run() {
            AtomicLockDocument nbdoc = LineDocumentUtils.as(doc, AtomicLockDocument.class);
            Runnable rebuild = new Runnable() {
                @Override
                public void run() {
                    MutableTextInput mti = (MutableTextInput) doc.getProperty(MutableTextInput.class);
                    if (mti != null) {
                        mti.tokenHierarchyControl().rebuild();
                    }
                }
            };
            if (nbdoc != null) {
                nbdoc.runAtomic(rebuild);
            } else {
                rebuild.run();
            }
        }
    });
}
 
Example #4
Source File: UpdateProjectImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Returns true if the project is of current version.
 * @return true if the project is of current version, otherwise false.
 */
public boolean isCurrent () {
    return ProjectManager.mutex().readAccess(new Mutex.Action<Boolean>() {
        public Boolean run() {
            synchronized (UpdateProjectImpl.this) {
                if (isCurrent == null) {
                    if ((cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2se-project/1",true) != null) ||
                    (cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2se-project/2",true) != null)) {
                        isCurrent = Boolean.FALSE;
                    } else {
                        isCurrent = Boolean.TRUE;
                    }
                }
                return isCurrent;
            }
        }
    }).booleanValue();
}
 
Example #5
Source File: Evaluator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void reset() {
    if (!project.getProjectDirectoryFile().exists()) {
        return; // recently deleted?
    }
    ProjectManager.mutex().readAccess(new Mutex.Action<Void>() {
        public @Override Void run() {
            final ModuleList moduleList;
            try {
                moduleList = project.getModuleList();
            } catch (IOException e) {
                Util.err.notify(ErrorManager.INFORMATIONAL, e);
                // but leave old evaluator in place for now
                return null;
            }
            synchronized (Evaluator.this) {
                loadedModuleList = true;
                delegate.removePropertyChangeListener(Evaluator.this);
                delegate = createEvaluator(moduleList);
                delegate.addPropertyChangeListener(Evaluator.this);
            }
            // XXX better to compute diff between previous and new values and fire just those
            pcs.firePropertyChange(null, null, null);
            return null;
        }
    });
}
 
Example #6
Source File: RemoteRepository.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void updateCurrentSettingsType () {
    Mutex.EVENT.readAccess(new Runnable() {
        @Override
        public void run() {
            GitURI uri = getURI();
            if (uri == null) {
                return;
            }
            for (ConnectionSettingsType type : settingTypes) {
                if (type.acceptUri(uri)) {
                    activeSettingsType = type;
                    break;
                }
            }
            if (urlFixed) {
                panel.tipLabel.setText(null);
                activeSettingsType.requestFocusInWindow();
            }
        }
    });
}
 
Example #7
Source File: WSUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void storeEditableProperties(final Project prj, final  String propertiesPath, final EditableProperties ep) 
    throws IOException {        
    try {
        ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
            @Override
            public Void run() throws IOException {                                             
                FileObject propertiesFo = prj.getProjectDirectory().getFileObject(propertiesPath);
                if (propertiesFo!=null) {
                    OutputStream os = null;
                    try {
                        os = propertiesFo.getOutputStream();
                        ep.store(os);
                    } finally {
                        if (os!=null) os.close();
                    }
                }
                return null;
            }
        });
    } catch (MutexException ex) {
    }
}
 
Example #8
Source File: OpenProjectList.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void removeModuleInfo(final Project prj, final ModuleInfo info) {
    // info can be null in case we are closing a project from disabled module
    if (info != null) {
        MUTEX.writeAccess(new Mutex.Action<Void>() {
            public @Override Void run() {
            List<Project> prjlist = openProjectsModuleInfos.get(info);
            if (prjlist != null) {
                prjlist.remove(prj);
                if (prjlist.isEmpty()) {
                    info.removePropertyChangeListener(infoListener);
                    openProjectsModuleInfos.remove(info);
                }
            }
            return null;
        }
        });
    }
}
 
Example #9
Source File: SuiteProjectGenerator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void createSuiteProject(final File projectDir, final String platformID, final boolean application) throws IOException {
    try {
        ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
            public Void run() throws IOException {
                final FileObject dirFO = FileUtil.createFolder(projectDir);
                if (ProjectManager.getDefault().findProject(dirFO) != null) {
                    throw new IllegalArgumentException("Already a project in " + dirFO); // NOI18N
                }
                createSuiteProjectXML(dirFO);
                createPlatformProperties(dirFO, platformID);
                createProjectProperties(dirFO);
                ModuleList.refresh();
                ProjectManager.getDefault().clearNonProjectCache();
                if (application) {
                    initApplication(dirFO, platformID);
                }
                return null;
            }
        });
    } catch (MutexException e) {
        throw (IOException) e.getException();
    }
}
 
Example #10
Source File: AndroidConfigProvider.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
private void load() {
    ProjectManager.mutex().readAccess(new Mutex.Action<Void>() {
        @Override
        public Void run() {
            configs.clear();
            String propNames = auxProps.get(AndroidProjectProperties.PROP_CONFIG_NAMES, false);
            if (propNames != null) {
                for (String key : Splitter.on('|').split(propNames)) {
                    Config cfg = configForKey(key);
                    if (cfg != null) {
                        configs.put(cfg.getDisplayName(), cfg);
                    }
                }
            }
            String active = auxProps.get(AndroidProjectProperties.PROP_ACTIVE_CONFIG, false);
            fixConfigurations(active);
            return null;
        }
    });
}
 
Example #11
Source File: MiscPrivateUtilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void setProjectProperty(final Project project, final AntProjectHelper helper, final String name, final String value, final String propertyPath) {
    if (helper == null) {
        return;
    }
    try {
        ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction() {
            @Override
            public Object run() throws IOException {
                try {
                    EditableProperties ep = helper.getProperties(propertyPath);
                    ep.setProperty(name, value);
                    helper.putProperties(propertyPath, ep);
                    ProjectManager.getDefault().saveProject(project);
                } catch (IOException ioe) {
                    Logger.getLogger(MiscPrivateUtilities.class.getName()).log(Level.INFO, ioe.getLocalizedMessage(), ioe);
                }
                return null;
            }
        });
    } catch (MutexException e) {
        Logger.getLogger(MiscUtilities.class.getName()).log(Level.INFO, null, e);
    }
}
 
Example #12
Source File: WebModules.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public WebModule findWebModule (final FileObject file) {
    Project owner = FileOwnerQuery.getOwner (file);
    if (project.equals (owner)) {
        // read modules under project READ access to prevent issues like #119734
        return ProjectManager.mutex().readAccess(new Mutex.Action<WebModule>() {
            public WebModule run() {
                synchronized (WebModules.this) {
                    List<FFWebModule> mods = getModules();
                    for (FFWebModule ffwm : mods) {
                        if (ffwm.contains (file)) {
                            WebModule wm = cache.get (ffwm);
                            if (wm == null) {
                                wm = WebModuleFactory.createWebModule (ffwm);
                                cache.put (ffwm, wm);
                            }
                            return wm;
                        }
                    }
                    return null;
                }
            }});
    }
    return null;
}
 
Example #13
Source File: SourceRoots.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@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()]);
            }
        }
    });
}
 
Example #14
Source File: RunConfigRemote.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static RunConfigRemote forProject(final PhpProject project) {
    return ProjectManager.mutex().readAccess(new Mutex.Action<RunConfigRemote>() {
        @Override
        public RunConfigRemote run() {
            return new RunConfigRemote()
                    .setUrl(ProjectPropertiesSupport.getUrl(project))
                    .setIndexParentDir(FileUtil.toFile(ProjectPropertiesSupport.getWebRootDirectory(project)))
                    .setIndexRelativePath(ProjectPropertiesSupport.getIndexFile(project))
                    .setArguments(ProjectPropertiesSupport.getArguments(project))
                    .setRemoteConfiguration(RemoteConnections.get().remoteConfigurationForName(ProjectPropertiesSupport.getRemoteConnection(project)))
                    .setUploadDirectory(ProjectPropertiesSupport.getRemoteDirectory(project))
                    .setUploadFilesType(ProjectPropertiesSupport.getRemoteUpload(project))
                    .setPermissionsPreserved(ProjectPropertiesSupport.areRemotePermissionsPreserved(project))
                    .setUploadDirectly(ProjectPropertiesSupport.isRemoteUploadDirectly(project));
        }
    });
}
 
Example #15
Source File: ClassPathProviderImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private FileObject getDir(final String propname) {
    return ProjectManager.mutex().readAccess(new Mutex.Action<FileObject>() {
        public FileObject run() {
            synchronized (ClassPathProviderImpl.this) {
                FileObject fo = (FileObject) ClassPathProviderImpl.this.dirCache.get (propname);
                if (fo == null ||  !fo.isValid()) {
                    String prop = evaluator.getProperty(propname);
                    if (prop != null) {
                        fo = helper.resolveFileObject(prop);
                        ClassPathProviderImpl.this.dirCache.put (propname, fo);
                    }
                }
                return fo;
            }
        }});
}
 
Example #16
Source File: GrailsProjectProperties.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void save() {
    try {
        // store properties
        ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
            public Void run() throws IOException {
                saveProperties();
                return null;
            }
        });
        ProjectManager.getDefault().saveProject(project);
    } catch (MutexException e) {
        Exceptions.printStackTrace((IOException) e.getException());
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
Example #17
Source File: Children.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Mutex getPMMutex() {
    for (;;) {
        Mutex mutex = null;
        WeakReference<Mutex> weakRef = pmMutexRef.get();
        if (weakRef != null) {
            mutex = weakRef.get();
        }
        if (mutex != null) {
            return mutex;
        }
        mutex = callPMMutexMethod();
        if (mutex != null) {
            WeakReference<Mutex> newWeakRef = new WeakReference<Mutex>(mutex);
            if (pmMutexRef.compareAndSet(weakRef, newWeakRef)) {
                return mutex;
            }
        } else {
            return null;
        }
    }
}
 
Example #18
Source File: InstanceDataObjectModuleTestHid.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void twiddle(final Module m, final int action) throws Exception {
    try {
        mgr.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
            public Void run() throws Exception {
                switch (action) {
                case TWIDDLE_ENABLE:
                    mgr.enable(m);
                    break;
                case TWIDDLE_DISABLE:
                    mgr.disable(m);
                    break;
                case TWIDDLE_RELOAD:
                    mgr.disable(m);
                    mgr.enable(m);
                    break;
                default:
                    throw new IllegalArgumentException("bad action: " + action);
                }
                return null;
            }
        });
    } catch (MutexException me) {
        throw me.getException();
    }
}
 
Example #19
Source File: ProgressSupportTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example #20
Source File: WebModules.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public ClassPath findClassPath (final FileObject file, final String type) {
    Project owner = FileOwnerQuery.getOwner (file);
    if (owner != null && owner.equals (project)) {
        // read modules under project READ access to prevent issues like #119734
        return ProjectManager.mutex().readAccess(new Mutex.Action<ClassPath>() {
            public ClassPath run() {
                synchronized (WebModules.this) {
                    List<FFWebModule> mods = getModules();
                    for (FFWebModule ffwm : mods) {
                        if (ffwm.contains (file)) {
                            return ffwm.findClassPath (file, type);
                        }
                    }
                }
                return null;
            }
        });
    }
    return null;
}
 
Example #21
Source File: NbPlatform.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void removePlatform(final NbPlatform plaf) throws IOException {
    try {
        ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
            @Override public Void run() throws IOException {
                EditableProperties props = PropertyUtils.getGlobalProperties();
                props.remove(PLATFORM_PREFIX + plaf.getID() + PLATFORM_DEST_DIR_SUFFIX);
                props.remove(PLATFORM_PREFIX + plaf.getID() + PLATFORM_HARNESS_DIR_SUFFIX);
                props.remove(PLATFORM_PREFIX + plaf.getID() + PLATFORM_LABEL_SUFFIX);
                props.remove(PLATFORM_PREFIX + plaf.getID() + PLATFORM_SOURCES_SUFFIX);
                props.remove(PLATFORM_PREFIX + plaf.getID() + PLATFORM_JAVADOC_SUFFIX);
                PropertyUtils.putGlobalProperties(props);
                return null;
            }
        });
    } catch (MutexException e) {
        throw (IOException) e.getException();
    }
    getPlatformsInternal().remove(plaf);
    ModuleList.refresh(); // #97262
    LOG.log(Level.FINE, "NbPlatform removed: {0}", plaf);
}
 
Example #22
Source File: RebaseAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@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;
    }
}
 
Example #23
Source File: UpdateProjectImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public boolean isCurrent() {
    return ProjectManager.mutex().readAccess(new Mutex.Action<Boolean>() {
        public Boolean run() {
            synchronized (this) {
                if (isCurrent == null) {
                    isCurrent = cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-earproject/1",true) == null //NOI18N
                        ? Boolean.TRUE : Boolean.FALSE;
                }
                return isCurrent;
            }
        }
    }).booleanValue();
}
 
Example #24
Source File: AuxiliaryConfigImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean removeConfigurationFragment(final String elementName, final String namespace, final boolean shared) throws IllegalArgumentException {
    return ProjectManager.mutex(false, project).writeAccess(new Mutex.Action<Boolean>() {
        @Override
        public Boolean run() {
            AuxiliaryConfiguration delegate = project.getLookup().lookup(AuxiliaryConfiguration.class);
            boolean result = false;
            if (delegate != null) {
                result |= delegate.removeConfigurationFragment(elementName, namespace, shared);
            }
            result |= removeFallbackImpl(elementName, namespace, shared);
            return result;
        }
    });
}
 
Example #25
Source File: ExplorerTopComponent.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
public void redo() throws CannotRedoException {
    if (java.awt.EventQueue.isDispatchThread()) {
        superRedo();
    } else {
        try {
            Mutex.EVENT.readAccess(runRedo);
        } catch (MutexException ex) {
            Exception e = ex.getException();
            if (e instanceof CannotRedoException)
                throw (CannotRedoException) e;
            else // should not happen, ignore
                e.printStackTrace();
        }
    }
}
 
Example #26
Source File: OpenProjectList.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void add(final Project p) {
    final UnloadedProjectInformation projectInfo;
    // #183681: call outside of lock
        projectInfo = ProjectInfoAccessor.DEFAULT.getProjectInfo(
                ProjectUtils.getInformation(p).getDisplayName(),
                ProjectUtils.getInformation(p).getIcon(),
                p.getProjectDirectory().toURL());
    OpenProjectList.MUTEX.writeAccess(new Mutex.Action<Void>() {
        public @Override Void run() {
        int index = getIndex(p);
        if (index == -1) {
            // Project not in list
            if (LOGGER.isLoggable(Level.FINE)) {
                log(Level.FINE, "add new recent project: " + p);
            }
            if (recentProjects.size() == size) {
                // Need some space for the newly added project
                recentProjects.remove(size - 1);
                recentProjectsInfos.remove(size - 1);
            }
        } else {
            LOGGER.log(Level.FINE, "re-add recent project: {0} @{1}", new Object[] {p, index});
            // Project is in list => just move it to first place
            recentProjects.remove(index);
            recentProjectsInfos.remove(index);
        }
        recentProjects.add(0, new ProjectReference(p));
        recentProjectsInfos.add(0, projectInfo);
        return null;
    }
    });
}
 
Example #27
Source File: NbProjectManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Save one project (if it was in fact modified).
 * <p>Acquires write access.</p>
 * <p class="nonnormative">
 * Although the project infrastructure permits a modified project to be saved
 * at any time, current UI principles dictate that the "save project" concept
 * should be internal only - i.e. a project customizer should automatically
 * save the project when it is closed e.g. with an "OK" button. Currently there
 * is no UI display of modified projects; this module does not ensure that modified projects
 * are saved at system exit time the way modified files are, though the Project UI
 * implementation module currently does this check.
 * </p>
 * @param p the project to save
 * @throws IOException if it cannot be saved
 * @see ProjectFactory#saveProject
 */
public void saveProject(final Project p) throws IOException {
    try {
        getMutex().writeAccess(new Mutex.ExceptionAction<Void>() {
            @Override
            public Void run() throws IOException {
                //removed projects are the ones that cannot be mapped to an existing project type anymore.
                if (removedProjects.contains(p)) {
                    return null;
                }
                if (modifiedProjects.contains(p)) {
                    ProjectFactory f = proj2Factory.get(p);
                    if (f != null) {
                        f.saveProject(p);
                        LOG.log(Level.FINE, "saveProject({0})", p.getProjectDirectory());
                    } else {
                        LOG.log(Level.WARNING, "Project {0} was already deleted", p);
                    }
                    modifiedProjects.remove(p);
                }
                return null;
            }
        });
    } catch (MutexException e) {
        //##91398 have a more descriptive error message, in case of RO folders.
        // the correct reporting still up to the specific project type.
        if (!p.getProjectDirectory().canWrite()) {
            throw new IOException("Project folder is not writeable.");
        }
        throw (IOException)e.getException();
    }
}
 
Example #28
Source File: ProjectInfoImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Get the text from the named element of the primary configuration node.
 *
 * @param elementName name of the element that contains the property value
 * @return the property value, or '???' if not found
 */
protected String getElementTextFromConfiguration(final String elementName) {
    return ProjectManager.mutex().readAccess(new Mutex.Action<String>() {
        @Override
        public String run() {
            Element data = getPrimaryConfigurationData();
            Element element = XMLUtil.findElement(data, elementName, null);
            String name = element == null ? null : XMLUtil.findText(element);
            if (name == null) {
                name = UNKNOWN;
            }
            return name;
        }
    });
}
 
Example #29
Source File: MenuBar.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void updateUI() {
    if (EventQueue.isDispatchThread()) {
        super.updateUI();
    } else {
        Mutex.EVENT.readAccess(this);
    }
}
 
Example #30
Source File: OptionsDisplayer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void showWaitCursor() {
    Mutex.EVENT.readAccess(new Runnable() {

        public void run() {
            JFrame mainWindow = (JFrame) WindowManager.getDefault().getMainWindow();
            mainWindow.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            mainWindow.getGlassPane().setVisible(true);
            StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(OptionsDisplayerImpl.class, "CTL_Loading_Options"));
        }
    });
}