Refine search
Mutex.EVENT.readAccess(new Runnable() { public void run() { clearActionPerformers();
/** Setter for lists items. * @param content Array of list items. */ public void setContent(final String[] content) { final JList list = contentList; if (list == null) { return; } // #18055: Ensure it runs in AWT thread. // Remove this when component handling will be assured // by other means that runs always in AWT. Mutex.EVENT.writeAccess( new Runnable() { @Override public void run() { list.setListData(content); list.revalidate(); list.repaint(); contentLabelPanel.setVisible(content.length > 0); } } ); }
public void reorder(final int[] perm) { MUTEX.postWriteRequest(new Runnable() { public void run() { Node[] n = nodes.toArray(new Node[nodes.size()]); List<Node> l = (List<Node>) nodes; for (int i = 0; i < n.length; i++) { l.set(perm[i], n[i]); } refresh(); } }); }
/** Tests whether this thread has already entered the mutex in write access. * If it returns true, calling <code>writeAccess</code> will be executed * immediatelly without any other blocking. <code>postReadAccess</code> * will be delayed until a write access runnable is over. * * @return true if the thread is in write access section * @since 4.48 */ public boolean isWriteAccess() { if (this == EVENT) { return javax.swing.SwingUtilities.isEventDispatchThread(); } if (wrapper != null) { Mutex m = (Mutex)LOCK; return m.isWriteAccess(); } Thread t = Thread.currentThread(); ThreadInfo info; synchronized (LOCK) { info = getThreadInfo(t); if (info != null) { if (info.counts[X] > 0) { return true; } } } return false; }
return m.isReadAccess(); info = getThreadInfo(t);
if (m.isWriteAccess() || m.isReadAccess()) { run.run(); } else {
/** * Try to load a config XML file from a named path. * If the file does not exist, return NONEXISTENT; or if there is any load error, return null. */ private Document loadXml(String path) { assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess(); assert Thread.holdsLock(modifiedMetadataPaths); FileObject xml = dir.getFileObject(path); if (xml == null || !xml.isData()) { return NONEXISTENT; } try { Document doc = XMLUtil.parse(new InputSource(xml.getInputStream()), false, true, XMLUtil.defaultErrorHandler(), null); return doc; } catch (IOException e) { if (!QUIETLY_SWALLOW_XML_LOAD_ERRORS) { LOG.log(Level.INFO, "Load XML: {0}", xml.getPath()); //NOI18N ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); } } catch (SAXException e) { if (!QUIETLY_SWALLOW_XML_LOAD_ERRORS) { LOG.log(Level.INFO, "Load XML: {0}", xml.getPath()); //NOI18N ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); } } return null; }
public void run() throws IOException { h[0] = createProject(dirFO, name, "src", "test", mainClass, manifestFile, manifestFile == null, librariesDefinition); //NOI18N final J2SEProject p = (J2SEProject) ProjectManager.getDefault().findProject(dirFO); ProjectManager.getDefault().saveProject(p); final ReferenceHelper refHelper = p.getReferenceHelper(); try { ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() { public Void run() throws Exception { copyRequiredLibraries(h[0], refHelper); return null; } }); } catch (MutexException ex) { Exceptions.printStackTrace(ex.getException()); } FileObject srcFolder = dirFO.createFolder("src"); // NOI18N dirFO.createFolder("test"); // NOI18N if ( mainClass != null ) { createMainClass( mainClass, srcFolder ); } } });
/** * Try to load a config XML file from a named path. * If the file does not exist, or there is any load error, return null. */ private Document loadXml(String path) { assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess(); assert Thread.holdsLock(modifiedMetadataPaths); FileObject xml = dir.getFileObject(path); if (xml == null || !xml.isData()) { return null; } File f = FileUtil.toFile(xml); assert f != null; try { return XMLUtil.parse(new InputSource(f.toURI().toString()), false, true, XMLUtil.defaultErrorHandler(), null); } catch (IOException e) { if (!QUIETLY_SWALLOW_XML_LOAD_ERRORS) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); } } catch (SAXException e) { if (!QUIETLY_SWALLOW_XML_LOAD_ERRORS) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); } } return null; }
public void fileDataCreated( final FileEvent fe ) { FileObject fo = fe.getFile(); if ( FileUtil.isParentOf( root, fo ) && isVisible( root, fo ) ) { if (ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess()) { PackageRootNode.PKG_VIEW_RP.post(new Runnable() { public void run() { fileDataCreated(fe); } }); return; } FileObject parent = fo.getParent(); if (!parent.isFolder()) { throw new IllegalStateException(FileUtil.getFileDisplayName(parent) + " is not a folder!"); //NOI18N } // XXX consider using group.contains() here if ( !VisibilityQuery.getDefault().isVisible( parent ) ) { return; // Adding file into ignored directory } PackageNode n = get( parent ); if ( n == null && !contains( parent ) ) { add(parent, false, true); refreshKeysAsync(); } else if ( n != null ) { n.updateChildren(); } } }
public void save() { try { // store properties ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() { @Override public Void run() throws IOException { saveProperties(); saveCustomizerExtenders(); ProjectManager.getDefault().saveProject(project); return null; } }); } catch (MutexException e) { Exceptions.printStackTrace((IOException) e.getException()); } }
public static Properties getProjectProperties(final Project project) { final Properties props = new Properties(); final FileObject propFile = project.getProjectDirectory().getFileObject("nbproject/project.properties"); // NOI18N if (propFile != null) { ProjectManager.mutex().readAccess(new Runnable() { public void run() { InputStream in = null; try { in = propFile.getInputStream(); props.load(in); } catch (IOException ex) { LOGGER.finest("Could not load properties file: " + propFile.getPath()); // NOI18N } finally { if (in != null) { try { in.close(); } catch (IOException ex) { // ignore } } } } }); } return props; }
@Override protected List<Node> getNodes() { List<Node> list = new ArrayList<>(); // #172092 List<FileObject> includePath = ProjectManager.mutex().readAccess(new Mutex.Action<List<FileObject>>() { @Override public List<FileObject> run() { return PhpSourcePath.getIncludePath(project.getProjectDirectory()); } }); for (FileObject fileObject : includePath) { if (fileObject != null && fileObject.isFolder()) { DataFolder df = DataFolder.findFolder(fileObject); list.add(new IncludePathNode(df, project)); } } return list; }
public static DataObject create(final ScalaPlatform plat, final DataFolder f, final String idName) throws IOException { W w = new W(plat, f, idName); f.getPrimaryFile().getFileSystem().runAtomicAction(w); try { ProjectManager.mutex().writeAccess( new Mutex.ExceptionAction<Void> () { public Void run () throws Exception { EditableProperties props = PropertyUtils.getGlobalProperties(); generatePlatformProperties(plat, idName, props); PropertyUtils.putGlobalProperties (props); return null; } }); } catch (MutexException me) { Exception originalException = me.getException(); if (originalException instanceof RuntimeException) { throw (RuntimeException) originalException; } else if (originalException instanceof IOException) { throw (IOException) originalException; } else { throw new IllegalStateException (); //Should never happen } } return w.holder; }
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); } }
public void run() throws IOException { ProjectManager.mutex().writeAccess(new Runnable() { public void run() { updateProject(); } }); } });
public static EditableProperties readFromFile(final @NonNull FileObject propsFO) throws IOException { final EditableProperties ep = new EditableProperties(true); if(propsFO != null) { assert propsFO.isData(); try { ProjectManager.mutex().readAccess(new Mutex.ExceptionAction<Void>() { @Override public Void run() throws Exception { final InputStream is = propsFO.getInputStream(); try { ep.load(is); } finally { if (is != null) { is.close(); } } return null; } }); } catch (MutexException mux) { throw (IOException) mux.getException(); } } return ep; }
private void readPrivateProperties () { ProjectManager.mutex().readAccess(new Runnable() { public void run () { appArgs = project.getUpdateHelper().getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH).getProperty(J2SEProjectProperties.APPLICATION_ARGS); workDir = project.getUpdateHelper().getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH).getProperty(J2SEProjectProperties.RUN_WORK_DIR); } }); }
public GuardedActions(int type, Object p1) { this.type = type; this.p1 = p1; if (Children.MUTEX.isReadAccess() || Children.MUTEX.isWriteAccess()) { ret = run(); } else { ret = Children.MUTEX.readAccess(this); } }
public static void saveToFile(final @NonNull FileObject propsFO, final @NonNull EditableProperties ep) throws IOException { if(propsFO != null) { assert propsFO.isData(); try { ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() { @Override public Void run() throws Exception { OutputStream os = null; FileLock lock = null; try { lock = propsFO.lock(); os = propsFO.getOutputStream(lock); ep.store(os); } finally { if (os != null) { os.close(); } if (lock != null) { lock.releaseLock(); } } return null; } }); } catch (MutexException mux) { throw (IOException) mux.getException(); } } }