public void updateUserCodesFromEditor (final StyledDocument document, final DesignDocument designDocument) { NbDocument.runAtomic (document, new Runnable() { public void run () { updateUserCodesFromEditorCore (document, designDocument); } }); }
public synchronized ChangeInfo implement() { NbDocument.runAtomic((StyledDocument) doc, new Runnable() { public void run() { try { doc.insertString(offset, "/", null); } catch (BadLocationException ble) { ErrorManager.getDefault().notify(ble); } RecommentAction.actionPerformed(doc); } }); return null; }
public ChangeInfo implement() { NbDocument.runAtomic((StyledDocument) doc, new Runnable() { public void run() { try { final int start=Utilities.getRowStart(doc,offset); final int end=Utilities.getRowEnd(doc,offset); doc.remove(start,end-start+1); } catch (BadLocationException ble) { ErrorManager.getDefault().notify(ble); } RecommentAction.actionPerformed(doc); } }); return null; }
/** Clears the <code>doc</code> document. Helper method. */ private void clearDocument() { NbDocument.runAtomic(doc, new Runnable() { public void run() { try { doc.removeDocumentListener(getListener()); doc.remove(0, doc.getLength()); // remove all text doc.addDocumentListener(getListener()); } catch(BadLocationException ble) { ErrorManager.getDefault().notify( ErrorManager.INFORMATIONAL, ble); } } }); }
/** Clears the <code>doc</code> document. Helper method. */ private void clearDocument() { NbDocument.runAtomic(doc, new Runnable() { public void run() { try { doc.removeDocumentListener(getListener()); doc.remove(0, doc.getLength()); // remove all text doc.addDocumentListener(getListener()); } catch(BadLocationException ble) { ErrorManager.getDefault().notify( ErrorManager.INFORMATIONAL, ble); } } }); }
public synchronized @Override void close() throws IOException { try { NbDocument.runAtomic(this.doc, new Runnable () { public void run () { try { doc.remove(0,doc.getLength()); doc.insertString(0,new String(data,0,pos,encodingName),null); } catch (BadLocationException e) { ErrorManager.getDefault().notify(e); } catch (UnsupportedEncodingException ee) { ErrorManager.getDefault().notify (ee); } } }); } finally { synchronized (SourceFileObject.this) { text = null; } } } }
void setColorings(final SortedSet<SequenceElement> colorings, final int version /*, final Set<OffsetRange> addedTokens, final Set<OffsetRange> removedTokens*/) { NbDocument.runAtomic((StyledDocument) doc,
public synchronized ChangeInfo implement() { NbDocument.runAtomic((StyledDocument)doc, new Runnable() { public void run() { try {
public void actionPerformed(@SuppressWarnings("unused") final ActionEvent evt, final JTextComponent txt) { NbDocument.runAtomic((StyledDocument)txt.getDocument(), new Runnable() { public void run() { try { final BaseDocument doc = (BaseDocument)txt.getDocument(); final int s = Utilities.getRowStartFromLineOffset(doc, getSelectionStartLine(txt) - 1); final int e = Utilities.getRowEnd(txt, Utilities.getRowStartFromLineOffset(doc, getSelectionEndLine(txt) - 1)); doc.insertString(e, "\n//#enddebug", null); //NOI18N doc.insertString(s, "//#mdebug\n", null); //NOI18N txt.setSelectionEnd(txt.getSelectionStart()); } catch (BadLocationException ble) { ErrorManager.getDefault().notify(ble); } RecommentAction.actionPerformed(txt); } }); } }
public void runAtomic(final Runnable r) { assert r != null; final StyledDocument doc = getDocument(); if (doc == null) { throw new IllegalStateException (); } else { NbDocument.runAtomic(doc,r); } }
/** Clears the <code>doc</code> document. Helper method. */ private void clearDocument() { NbDocument.runAtomic( getDoc(), new Runnable() { public void run() { try { addRemoveDocListener(getDoc(), false); getDoc().remove(0, getDoc().getLength()); addRemoveDocListener(getDoc(), true); } catch (BadLocationException ble) { ERR.log(Level.INFO, null, ble); } } } ); }
/** * Replace the content of the document by the graph. */ public static void replaceDocument(final StyledDocument doc, BaseBean graph) { final ByteArrayOutputStream out = new ByteArrayOutputStream(); try { graph.write(out); } catch (IOException ioe) { Exceptions.printStackTrace(ioe); } NbDocument.runAtomic(doc, new Runnable() { public void run() { try { doc.remove(0, doc.getLength()); doc.insertString(0, out.toString(), null); } catch (BadLocationException ble) { Exceptions.printStackTrace(ble); } } }); }
/** * Replace the content of the document by the graph. */ private static void replaceDocument(final StyledDocument doc, BaseBean graph) { final StringWriter out = new StringWriter(); try { graph.write(out); } catch (Schema2BeansException ex) { Logger.getLogger(TomcatModuleConfiguration.class.getName()).log(Level.INFO, null, ex); } catch (IOException ioe) { Logger.getLogger(TomcatModuleConfiguration.class.getName()).log(Level.INFO, null, ioe); } NbDocument.runAtomic(doc, new Runnable() { public void run() { try { doc.remove(0, doc.getLength()); doc.insertString(0, out.toString(), null); } catch (BadLocationException ble) { Exceptions.printStackTrace(ble); } } }); }
public void generateCode (final StyledDocument document, final DesignDocument designDocument) { final Collection<CodePresenter> presenters = DocumentSupport.gatherAllPresentersOfClass (designDocument, CodePresenter.class); try { NbDocument.runAtomic (document, new Runnable() { public void run () { generateCodeCore (presenters, document); } }); } finally { usedMultiSectionIDs.remove (document); } Collection<CodeGlobalLevelPresenter> globalLevel = DocumentSupport.filterPresentersForClass (presenters, CodeGlobalLevelPresenter.class); for (CodeGlobalLevelPresenter presenter : globalLevel) presenter.performGlobalGeneration (document); }
NbDocument.runAtomic((StyledDocument)doc, new Runnable() { public void run() { try {
public void actionPerformed(@SuppressWarnings("unused") final ActionEvent evt, final JTextComponent txt) { final ProjectConfigurationProvider prov = J2MEProjectUtils.getConfigProviderForDoc(txt.getDocument()); if (prov == null) return; NbDocument.runAtomic((StyledDocument)txt.getDocument(), new Runnable() { public void run() { try { final BaseDocument doc = (BaseDocument)txt.getDocument(); final int s = Utilities.getRowStartFromLineOffset(doc, getSelectionStartLine(txt) - 1); final int e = Utilities.getRowEnd(txt, Utilities.getRowStartFromLineOffset(doc, getSelectionEndLine(txt) - 1)); final String text = doc.getText(s, e-s); doc.insertString(e, "\n//#else\n" + text + "\n//#endif", null); //NOI18N doc.insertString(s, "//#if \n", null); //NOI18N txt.setSelectionStart(s + 6); txt.setSelectionEnd(s + 6); } catch (BadLocationException ble) { ErrorManager.getDefault().notify(ble); } RecommentAction.actionPerformed(txt); } }); Completion.get().showCompletion(); } }
public void run() { if (!inRunAtomic) { inRunAtomic = true; StyledDocument sd = getDoc(); if (sd == null) { return; } // #57104 - avoid notifyModified() which takes file lock documentReloading = true; try { NbDocument.runAtomic(sd, this); } finally { documentReloading = false; // #57104 } return; } boolean noAsk = time == null || !isModified(); ERR.fine(documentID() + ": checkReload noAsk: " + noAsk); checkReload(noAsk); } }
public void defaultAction(final JTextComponent component) { Completion.get().hideCompletion(); Completion.get().hideDocumentation(); NbDocument.runAtomic((StyledDocument) component.getDocument(), new Runnable() { public void run() { Document doc = component.getDocument(); try { doc.remove(substituteOffset, component.getCaretPosition() - substituteOffset); doc.insertString(substituteOffset, getText(), null); } catch (BadLocationException e) { ErrorManager.getDefault().notify(e); } } }); }
NbDocument.runAtomic (doc, run); if (hold[0] != null) throw (BadLocationException) hold[0];
public static void actionPerformed(final Document document) { if (!((document instanceof StyledDocument) && (document instanceof BaseDocument))) return; final StyledDocument doc = (StyledDocument)document; final Project p = J2MEProjectUtils.getProjectForDocument(doc); if (p != null) { final ProjectConfigurationsHelper pch = p.getLookup().lookup(ProjectConfigurationsHelper.class); if (pch != null && pch.isPreprocessorOn()) try { J2MEProjectUtilitiesProvider utilProvider = Lookup.getDefault().lookup(J2MEProjectUtilitiesProvider.class); if (utilProvider == null) return; //we do not run in full NetBeans, but this should not happen here (no editor) final Source ppSource = utilProvider.createPPDocumentSource(doc); final Destination ppDestination = utilProvider.createPPDocumentDestination(doc); final ProjectConfiguration conf = pch.getActiveConfiguration(); final HashMap<String,String> identifiers=new HashMap<String,String>(pch.getAbilitiesFor(conf)); identifiers.put(conf.getDisplayName(),null); final CommentingPreProcessor cpp =new CommentingPreProcessor(ppSource, ppDestination, identifiers); //note: nbr transaction is already locked here try { doc.putProperty(TextSwitcher.SKIP_DUCUMENT_CHANGES, TextSwitcher.SKIP_DUCUMENT_CHANGES); NbDocument.runAtomic(doc,cpp); // NOI18N } finally { doc.putProperty(TextSwitcher.SKIP_DUCUMENT_CHANGES, null); } } catch (PreprocessorException pe) { ErrorManager.getDefault().notify(pe); } } } }