Refine search
public PositionRef createPositionRef(int offset, Bias bias) { assert locked.get(); return editor.createPositionRef(offset, bias); } }
public static StyledDocument openDocument(CloneableEditorSupport ces) { if (ces == null) { return null; } StyledDocument document = null; try { try { document = ces.openDocument(); } catch (UserQuestionException e) { e.confirmed(); document = ces.openDocument(); } } catch (IOException ex) { Exceptions.printStackTrace(ex); } ces.prepareDocument().waitFinished(); return document; }
@Override public JComponent getPreviewComponent() { if (previewPane == null) { previewPane = new JEditorPane(); previewPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(FmtOptions.class, "AN_Preview")); //NOI18N previewPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(FmtOptions.class, "AD_Preview")); //NOI18N previewPane.setEditorKit(CloneableEditorSupport.getEditorKit(FileUtils.PHP_MIME_TYPE)); previewPane.setEditable(false); } return previewPane; }
/** When closing last view, also close the document. * @return <code>true</code> if close succeeded */ protected boolean closeLast() { if (!support.canClose ()) { // if we cannot close the last window return false; } // close everything and do not ask support.notifyClosed (); if (support.getLastSelected() == this) { support.setLastSelected(null); } return true; }
@Override public java.lang.String getUndoOrRedoPresentationName() { if (support.isDocumentReady()) { return new DocLockedRun(8, support.getDocument(), 0, true).stringResult; } else { return ""; } }
/** Creates editor kit for this source. * @return editor kit */ protected EditorKit createEditorKit() { if (kit != null) { return kit; } if (mimeType != null) { kit = getEditorKit(mimeType); } else { String defaultMIMEType = cesEnv().getMimeType(); kit = getEditorKit(defaultMIMEType); } return kit; }
/** *@return PositionBounds representing the position of the name of the entity that is being * refactored or PostionBounds representing the start of the file if the position * of the entity could not be resolved. */ public PositionBounds getPositionBounds(){ if (elementName != null){ try { BaseDocument doc = getDocument(); String text = doc.getText(0, doc.getLength()); int offset = text.indexOf(elementName); if (offset > -1){ PositionRef start = editorSupport.createPositionRef(offset, Bias.Forward); PositionRef end = editorSupport.createPositionRef(offset + elementName.length(), Bias.Backward); return new PositionBounds(start, end); } } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } } return getDefaultPositionBounds(); }
CloneableEditorSupport redirect = CloneableEditorSupportRedirector.findRedirect(this); if (redirect != null) { redirect.print(); return; Object o = NbDocument.findPageable(openDocument()); notifyProblem(e, "CTL_Bad_File"); // NOI18N } catch (IOException e) { Exceptions.printStackTrace(e); } catch (PrinterAbortException e) { // user exception notifyProblem(e, "CTL_Printer_Abort"); // NOI18N }catch (PrinterException e) { notifyProblem(e, "EXC_Printer_Problem"); // NOI18N } finally { synchronized (LOCK_PRINTING) {
+ " Name:" + CloneableEditor.this.getName()); Task prepareTask = support.prepareDocument(); assert prepareTask != null : "Failed to get prepareTask"; prepareTask.waitFinished(); final Throwable ex = support.getPrepareDocumentRuntimeException(); if (ex == null) { isDocLoadingCanceled = false; if (support.asynchronousOpen()) { if (ex instanceof CloneableEditorSupport.DelegateIOExc) { if (ex.getCause() instanceof UserQuestionException) { prepareTask = support.prepareDocument(); assert prepareTask != null : "Failed to get prepareTask"; prepareTask.waitFinished(); prepareTask = support.prepareDocument(); assert prepareTask != null : "Failed to get prepareTask"; prepareTask.waitFinished(); EditorKit k = support.cesKit(); if (newInitialize() && k instanceof Callable) { try { doc = support.getDocument(); if (doc == null && LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE,"DoInitialize.initNonVisual CANNOT set kit because doc is null!"
StyledDocument document = null; try { document = editorSupport[0].openDocument(); } catch (IOException e) { Exceptions.printStackTrace(e); if (document != null && activeView != null) { ProjectUtils.requestVisibility(activeView.getContext(), ProjectUtils.getSourceEditorViewDisplayName()); JEditorPane[] panes = editorSupport[0].getOpenedPanes();
doc = (BaseDocument)ces.openDocument(); doc.readLock(); Exceptions.printStackTrace(ie); } catch (BadLocationException ble) { Exceptions.printStackTrace(ble); } finally { if (doc != null) { PositionRef startPos = ces.createPositionRef(start, Bias.Forward); PositionRef endPos = ces.createPositionRef(end, Bias.Forward); Difference diff = new Difference(Difference.Kind.CHANGE, startPos, endPos, oldCode, newCode, desc); diffs.add(diff);
BaseDocument result = (BaseDocument) editorSupport.getDocument(); result.insertString(0, text, null); } catch (InterruptedException ex) { Exceptions.printStackTrace(ex); } catch (InvocationTargetException ex) { Exceptions.printStackTrace(ex); } catch (FileNotFoundException ex) { Exceptions.printStackTrace(ex); } catch (IOException ex) { Exceptions.printStackTrace(ex);
public void open() { try { PositionRef pos = ed.getRange().getBegin(); int line = pos.getLine(); int column = pos.getColumn(); Line l = pos.getCloneableEditorSupport().getLineSet().getCurrent(line); l.show(Line.SHOW_GOTO, column); } catch (IOException ex) { Exceptions.printStackTrace(ex); } }
CloneableEditorSupport support = CsmUtilities.findCloneableEditorSupport(containingFile); try { document = support.openDocument(); } catch (IOException ex) { return null; true, trueBodyStratOffset.get(), bodyText.length()); } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); true, trueBodyStratOffset.get(), bodyText.length()); } catch (BadLocationException ex) { Exceptions.printStackTrace(ex);
public LockedDocument(FileObject fo) throws IOException { this.fo = fo; editor = (CloneableEditorSupport)getEditorCookie(fo); document = (BaseDocument)editor.openDocument(); }
public void run () { doc.removeUndoableEditListener (getUndoRedo ()); final JEditorPane[] panes = getOpenedPanes(); final int[] carets; if (panes != null) { getPositionManager().documentClosed(); updateLineSet(true); fireDocumentChange(doc, true); clearDocument(); throw t; } finally { synchronized (getLock()) { documentStatus = targetStatus; getLock().notifyAll();
/** Remove annotation to this Annotatable class * @param anno annotation which will be detached from this class */ @Override protected void removeAnnotation(final Annotation anno) { super.removeAnnotation(anno); final StyledDocument doc = pos.getCloneableEditorSupport().getDocument(); // document is not opened and so no annotation is attached to it if (doc == null) { return; } pos.getCloneableEditorSupport().prepareDocument().waitFinished(); doc.render(new Runnable() { public void run() { synchronized (getAnnotations()) { if (anno.isInDocument()) { anno.setInDocument(false); NbDocument.removeAnnotation(doc, anno); } } } }); }
/** @return the position as swing.text.Position object. * @exception IOException when an exception occured during reading the file. */ public Position getPosition() throws IOException { if(manager.getCloneableEditorSupport().getDocument() == null) { manager.getCloneableEditorSupport ().openDocument (); } synchronized(manager.getLock()) { Manager.PositionKind p = (Manager.PositionKind)kind; return p.pos; } }
public void run() { synchronized (editor.getLock()) { /* editor.getLock(): fixes deadlock - this lock is acquired later anyhow, so we are changing the order in which the locks are acquired */ try { // [MaM] remember doclen to compute new length // of the inserted string (the length changes // because insertString removes \r characters // from it) int docLen = doc.getLength(); int p1 = end.getOffset(); doc.insertString(p1, text, null); int p2 = (p1 + doc.getLength()) - docLen; end = editor.createPositionRef(p1, end.getPositionBias()); PositionRef posBegin = editor.createPositionRef(p1, Position.Bias.Forward); PositionRef posEnd = editor.createPositionRef(p2, Position.Bias.Backward); hold[1] = new PositionBounds(posBegin, posEnd); } catch (BadLocationException e) { hold[0] = e; } } } };
env.removePropertyChangeListener(getListener()); env.addPropertyChangeListener(getListener()); kit = createEditorKit (); if (doc == null) { doc = createStyledDocument (kit); synchronized (getLock ()) { prepareDocumentRuntimeException = ex; documentStatus = DOCUMENT_NO; getLock ().notifyAll ();