static CloneableEditorSupport findRedirect(CloneableEditorSupport one, boolean check) { Map<Lookup,CloneableEditorSupport> all = CHECKED.get(); if (all == null) { all = new IdentityHashMap<Lookup, CloneableEditorSupport>(); CHECKED.set(all); } final Lookup lkp = one.getLookup(); try { if (check && all.containsKey(lkp)) { return null; } all.put(lkp, one); for (CloneableEditorSupportRedirector r : Lookup.getDefault().lookupAll(CloneableEditorSupportRedirector.class)) { CloneableEditorSupport ces = r.redirect(lkp); if (ces != null && ces != one) { return ces; } } return null; } finally { all.remove(lkp); } } }
/** Creates a Line for given offset. * @param offset the begining of line * @return line that should represent the given line */ public Line createLine(int offset) { PositionRef ref = new PositionRef(support.getPositionManager(), offset, Position.Bias.Forward); return new SupportLine(support.getLookup(), ref, support); }
out.writeBoolean(getLookup() == support.getLookup());
/** Find line object in the line set corresponding to current line number. * * @param line number of the line * @return line object * @exception IndexOutOfBoundsException if <code>line</code> is an invalid index for the original set of lines */ public Line getCurrent (int line) throws IndexOutOfBoundsException { PositionRef ref = new PositionRef (support.getPositionManager (), line, 0, Position.Bias.Forward); // obj can be null, sorry... org.openide.util.Lookup obj = support.getLookup (); return this.registerLine(new SupportLine(obj, ref, support)); }
/** Creates new editor component associated with * support object (possibly also with its * {@link CloneableEditorSupport#CloneableEditorSupport(org.openide.text.CloneableEditorSupport.Env, org.openide.util.Lookup) lookup}. * * @param support support that holds the document and operations above it * @param associateLookup true, if {@link #getLookup()} should return the lookup * associated with {@link CloneableEditorSupport}. */ public CloneableEditor(CloneableEditorSupport support, boolean associateLookup) { super(); this.support = support; updateName(); _setCloseOperation(); setMinimumSize(new Dimension(10, 10)); if (associateLookup) { associateLookup(support.getLookup()); } } @SuppressWarnings("deprecation")
/** Find line object in the line set corresponding to current line number. * * @param line number of the line * @return line object * @exception IndexOutOfBoundsException if <code>line</code> is an invalid index for the original set of lines */ public Line getCurrent(int line) throws IndexOutOfBoundsException { PositionRef ref = new PositionRef(support.getPositionManager(), line, 0, Position.Bias.Forward); // obj can be null, sorry... org.openide.util.Lookup obj = support.getLookup(); return this.registerLine(new SupportLine(obj, ref, support)); }
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); int offset; Object firstObject = in.readObject(); // New deserialization that uses Env environment, // and which could be null(!) see writeExternal. if (firstObject instanceof CloneableOpenSupport.Env) { CloneableOpenSupport.Env env = (CloneableOpenSupport.Env) firstObject; CloneableOpenSupport os = env.findCloneableOpenSupport(); support = (CloneableEditorSupport) os; } // load cursor position offset = ((Integer) in.readObject()).intValue(); if (!discard()) { cursorPosition = offset; } updateName(); isComponentOpened = true; if (in.available() > 0) { boolean associate = in.readBoolean(); if (associate && support != null) { associateLookup(support.getLookup()); } } }
/** Creates a Line for given offset. * @param offset the begining of line * @return line that should represent the given line */ public Line createLine (int offset) { StyledDocument doc = support.getDocument(); if (doc == null) // do nothing - document was probably closed return null; PositionRef ref = new PositionRef( support.getPositionManager (), offset, Position.Bias.Forward ); return new SupportLine (support.getLookup (), ref, support); }
/** Find line object in the line set corresponding to current line number. * * @param line number of the line * @return line object * @exception IndexOutOfBoundsException if <code>line</code> is an invalid index for the original set of lines */ public Line getCurrent (int line) throws IndexOutOfBoundsException { PositionRef ref = new PositionRef (support.getPositionManager (), line, 0, Position.Bias.Forward); // obj can be null, sorry... org.openide.util.Lookup obj = support.getLookup (); return this.registerLine(new SupportLine(obj, ref, support)); }
/** Creates a Line for given offset. * @param offset the begining of line * @return line that should represent the given line */ public Line createLine (int offset) { StyledDocument doc = support.getDocument(); if (doc == null) // do nothing - document was probably closed return null; PositionRef ref = new PositionRef( support.getPositionManager (), offset, Position.Bias.Forward ); return new SupportLine (support.getLookup (), ref, support); }