/** Load the document into memory. This is done * in different thread. A task for the thread is returned * so anyone may test whether the loading has been finished * or is still in process. * * @return task for control over loading */ public Task prepareDocument() { synchronized (getLock()) { switch (documentStatus) { case DOCUMENT_NO: documentStatus = DOCUMENT_LOADING; return prepareDocument(false); default: if (prepareTask == null) { // should never happen throw new IllegalStateException(); } return prepareTask; } } }
/** Load the document into memory. This is done * in different thread. A task for the thread is returned * so anyone may test whether the loading has been finished * or is still in process. * * @return task for control over loading */ public Task prepareDocument() { synchronized (getLock()) { switch (documentStatus) { case DOCUMENT_NO: documentStatus = DOCUMENT_LOADING; return prepareDocument(false); default: if (prepareTask == null) { // should never happen throw new IllegalStateException(); } return prepareTask; } } }
case DOCUMENT_NO: documentStatus = DOCUMENT_LOADING; prepareDocument(false); return openDocumentImpl();
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; }
/** Prepares document, creates and initializes * new <code>CloneableEditor</code> component. * Typically do not override this method. * For creating your own <code>CloneableEditor</code> type component * override {@link #createCloneableEditor} method. * * @return the {@link CloneableEditor} for this support */ protected CloneableTopComponent createCloneableTopComponent () { // initializes the document if not initialized prepareDocument (); Pane pane = createPane (); pane.getComponent().putClientProperty(PROP_PANE, pane); return pane.getComponent (); }
/** Prepares document, creates and initializes * new <code>CloneableEditor</code> component. * Typically do not override this method. * For creating your own <code>CloneableEditor</code> type component * override {@link #createCloneableEditor} method. * * @return the {@link CloneableEditor} for this support */ protected CloneableTopComponent createCloneableTopComponent () { // initializes the document if not initialized prepareDocument (); Pane pane = createPane (); pane.getComponent().putClientProperty(PROP_PANE, pane); return pane.getComponent (); }
/** Prepares document, creates and initializes * new <code>CloneableEditor</code> component. * Typically do not override this method. * For creating your own <code>CloneableEditor</code> type component * override {@link #createCloneableEditor} method. * * @return the {@link CloneableEditor} for this support */ protected CloneableTopComponent createCloneableTopComponent() { // initializes the document if not initialized prepareDocument(); Pane pane = createPane(); pane.getComponent().putClientProperty(PROP_PANE, pane); return pane.getComponent(); }
/** 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); } } } }); }
/** 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 = position.getCloneableEditorSupport().getDocument(); // document is not opened and so no annotation is attached to it if (doc == null) { return; } position.getCloneableEditorSupport().prepareDocument().waitFinished(); doc.render(new Runnable() { public void run() { synchronized (getAnnotations()) { if (anno.isInDocument()) { anno.setInDocument(false); NbDocument.removeAnnotation(doc, anno); } } } }); }
/** Remove annotation to this Annotatable class * @param anno annotation which will be detached from this class */ protected void removeAnnotation(Annotation anno) { super.removeAnnotation(anno); 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(); if (anno.isInDocument()) { anno.setInDocument(false); NbDocument.removeAnnotation(doc, anno); } }
/** Remove annotation to this Annotatable class * @param anno annotation which will be detached from this class */ protected void removeAnnotation(Annotation anno) { super.removeAnnotation(anno); StyledDocument doc = position.getCloneableEditorSupport ().getDocument (); // document is not opened and so no annotation is attached to it if (doc == null) return; position.getCloneableEditorSupport().prepareDocument().waitFinished(); if (anno.isInDocument()) { anno.setInDocument(false); NbDocument.removeAnnotation(doc, anno); } }
/** Add annotation to this Annotatable class * @param anno annotation which will be attached to this class */ @Override protected void addAnnotation(final Annotation anno) { super.addAnnotation(anno); final StyledDocument doc = position.getCloneableEditorSupport().getDocument(); // document is not opened and so the annotation will be added to document later if (doc == null) { return; } position.getCloneableEditorSupport().prepareDocument().waitFinished(); doc.render(new Runnable() { public void run() { try { synchronized (getAnnotations()) { if (!anno.isInDocument()) { anno.setInDocument(true); NbDocument.addAnnotation(doc, position.getPosition(), length, anno); } } } catch (IOException ex) { Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex); } } }); }
/** Remove annotation to this Annotatable class * @param anno annotation which will be detached from this class */ protected void removeAnnotation(Annotation anno) { super.removeAnnotation(anno); 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(); if (anno.isInDocument()) { anno.setInDocument(false); NbDocument.removeAnnotation(doc, anno); } }
/** Remove annotation to this Annotatable class * @param anno annotation which will be detached from this class */ protected void removeAnnotation(Annotation anno) { super.removeAnnotation(anno); StyledDocument doc = position.getCloneableEditorSupport ().getDocument (); // document is not opened and so no annotation is attached to it if (doc == null) return; position.getCloneableEditorSupport().prepareDocument().waitFinished(); if (anno.isInDocument()) { anno.setInDocument(false); NbDocument.removeAnnotation(doc, anno); } }
/** Add annotation to this Annotatable class * @param anno annotation which will be attached to this class */ @Override protected void addAnnotation(final Annotation anno) { super.addAnnotation(anno); final StyledDocument doc = pos.getCloneableEditorSupport().getDocument(); // document is not opened and so the annotation will be added to document later if (doc == null) { return; } pos.getCloneableEditorSupport().prepareDocument().waitFinished(); doc.render(new Runnable() { public void run() { try { synchronized (getAnnotations()) { if (!anno.isInDocument()) { anno.setInDocument(true); // #33165 - find position that is surely at begining of line FindAnnotationPosition fap = new FindAnnotationPosition(doc, pos.getPosition()); doc.render(fap); NbDocument.addAnnotation(doc, fap.getAnnotationPosition(), -1, anno); } } } catch (IOException ex) { Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex); } } }); }
/** Add annotation to this Annotatable class * @param anno annotation which will be attached to this class */ protected void addAnnotation(Annotation anno) { super.addAnnotation(anno); StyledDocument doc = position.getCloneableEditorSupport ().getDocument (); // document is not opened and so the annotation will be added to document later if (doc == null) return; position.getCloneableEditorSupport().prepareDocument().waitFinished(); try { if (!anno.isInDocument()) { anno.setInDocument(true); NbDocument.addAnnotation(doc, position.getPosition(), length, anno); } } catch (IOException ex) { ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex); } }
/** Add annotation to this Annotatable class * @param anno annotation which will be attached to this class */ protected void addAnnotation(Annotation anno) { super.addAnnotation(anno); StyledDocument doc = position.getCloneableEditorSupport ().getDocument (); // document is not opened and so the annotation will be added to document later if (doc == null) return; position.getCloneableEditorSupport().prepareDocument().waitFinished(); try { if (!anno.isInDocument()) { anno.setInDocument(true); NbDocument.addAnnotation(doc, position.getPosition(), length, anno); } } catch (IOException ex) { ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex); } }
/** Add annotation to this Annotatable class * @param anno annotation which will be attached to this class */ protected void addAnnotation(Annotation anno) { super.addAnnotation(anno); StyledDocument doc = pos.getCloneableEditorSupport ().getDocument (); // document is not opened and so the annotation will be added to document later if (doc == null) return; pos.getCloneableEditorSupport().prepareDocument().waitFinished(); try { if (!anno.isInDocument()) { anno.setInDocument(true); // #33165 - find position that is surely at begining of line FindAnnotationPosition fap = new FindAnnotationPosition(doc, pos.getPosition()); doc.render(fap); NbDocument.addAnnotation (doc, fap.getAnnotationPosition(), -1, anno); } } catch (IOException ex) { ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex); } }
/** Add annotation to this Annotatable class * @param anno annotation which will be attached to this class */ protected void addAnnotation(Annotation anno) { super.addAnnotation(anno); StyledDocument doc = pos.getCloneableEditorSupport ().getDocument (); // document is not opened and so the annotation will be added to document later if (doc == null) return; pos.getCloneableEditorSupport().prepareDocument().waitFinished(); try { if (!anno.isInDocument()) { anno.setInDocument(true); // #33165 - find position that is surely at begining of line FindAnnotationPosition fap = new FindAnnotationPosition(doc, pos.getPosition()); doc.render(fap); NbDocument.addAnnotation (doc, fap.getAnnotationPosition(), -1, anno); } } catch (IOException ex) { ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex); } }
prepareDocument(); ce = createPane (); ce.getComponent().putClientProperty(PROP_PANE, ce);