Index: openide/src/org/openide/text/DocumentLine.java =================================================================== RCS file: /cvs/openide/src/org/openide/text/DocumentLine.java,v retrieving revision 1.53 diff -u -r1.53 DocumentLine.java --- openide/src/org/openide/text/DocumentLine.java 25 Mar 2004 16:04:55 -0000 1.53 +++ openide/src/org/openide/text/DocumentLine.java 18 May 2004 22:56:08 -0000 @@ -7,7 +7,7 @@ * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original - * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ @@ -36,28 +36,9 @@ /** reference to one position on the line */ protected PositionRef pos; - /** is breakpoint there - presistent state - @deprecated since 1.20 */ - private boolean breakpoint; - - /** error line - transient state - @deprecated since 1.20 */ - private transient boolean error; - - /** current line - transient state - @deprecated since 1.20 */ - private transient boolean current; - /** listener for changes of state of the document */ private transient LR listener; - /** weak document listener assigned to the document or null */ - private transient DocumentListener docL; - - /** weak map that assignes to editor supports whether they have current or error line - * selected. (EditorSupport, DocumentLine[2]), where Line[0] is current and Line[1] is error */ - private static WeakHashMap assigned = new WeakHashMap (5); - /** List of Line.Part which exist for this line*/ private List lineParts = new ArrayList(3); @@ -103,106 +84,27 @@ */ public abstract void show(int kind, int column); - /* Sets the breakpoint. */ - public void setBreakpoint(boolean b) { - if (breakpoint != b) { - breakpoint = b; - refreshState (); - } - } - - /* Tests if the breakpoint is set. */ - public boolean isBreakpoint () { - return breakpoint; - } - - /* Marks the error. */ - public void markError () { - DocumentLine previous = registerLine (1, this); - if (previous != null) { - previous.error = false; - previous.refreshState (); - } - - error = true; - - refreshState (); - } - - /* Unmarks error at this line. */ - public void unmarkError () { - error = false; - registerLine (1, null); - - refreshState (); - } - - /* Marks this line as current. */ - public void markCurrentLine () { - DocumentLine previous = registerLine (0, this); - if (previous != null) { - previous.current = false; - previous.refreshState (); - } - - current = true; - refreshState (); - } - - /* Unmarks this line as current. */ - public void unmarkCurrentLine () { - current = false; - registerLine (0, null); - - refreshState (); - } - - /** Refreshes the current line. - * - * @deprecated since 1.20. */ - synchronized void refreshState () { - StyledDocument doc = pos.getCloneableEditorSupport ().getDocument (); - - if (doc != null) { - // the document is in memory, mark the state - - if (docL != null) { - doc.removeDocumentListener (docL); - } - - // error line - if (error) { - NbDocument.markError (doc, pos.getOffset ()); - - doc.addDocumentListener (docL = org.openide.util.WeakListeners.document (listener, doc)); - - return; - } - - // current line - if (current) { - NbDocument.markCurrent (doc, pos.getOffset ()); - return; - } - - // breakpoint line - if (breakpoint) { - NbDocument.markBreakpoint (doc, pos.getOffset ()); - return; - } - - NbDocument.markNormal (doc, pos.getOffset ()); - return; - } + // Long-deprecated stuff. + public void setBreakpoint(boolean b) {} + public boolean isBreakpoint() { + return false; } + public void markError() {} + public void unmarkError() {} + public void markCurrentLine() {} + public void unmarkCurrentLine() {} public int hashCode () { - return pos.getCloneableEditorSupport ().hashCode (); + return pos.getCloneableEditorSupport ().hashCode () ^ getLineNumber(); } public boolean equals (Object o) { if (o instanceof DocumentLine) { DocumentLine dl = (DocumentLine)o; + if (dl.pos == pos) { + // No need to check anything else. + return true; + } if (dl.pos.getCloneableEditorSupport () == pos.getCloneableEditorSupport ()) { return dl.getLineNumber () == getLineNumber (); } @@ -212,40 +114,6 @@ // - // Work with global hash table - // - - /** Register this line as the one stored - * under indx-index (0 = current, 1 = error). - * - * @param indx index to register - * @param line value to add (this or null) - * @return the previous value - * - * @deprecated since 1.20 */ - private DocumentLine registerLine (int indx, DocumentLine line) { - DocumentLine prev; - - CloneableEditorSupport es = pos.getCloneableEditorSupport (); - - DocumentLine[] arr = (DocumentLine[])assigned.get (es); - - if (arr != null) { - // remember the previous - prev = arr[indx]; - } else { - // create new array - arr = new DocumentLine[2]; - assigned.put (es, arr); - prev = null; - } - arr[indx] = line; - return prev; - - } - - - // // Serialization // @@ -254,7 +122,7 @@ private void writeObject (ObjectOutputStream oos) throws IOException { // do not do default read/write object oos.writeObject (pos); - oos.writeBoolean (breakpoint); + oos.writeBoolean (false); // was breakpoint } /** Read important fields. @@ -262,7 +130,6 @@ private void readObject (ObjectInputStream ois) throws IOException, ClassNotFoundException { pos = (PositionRef)ois.readObject (); - setBreakpoint (ois.readBoolean ()); lineParts = new ArrayList(3); } @@ -717,60 +584,27 @@ /** Definition of actions performed in Listener */ - private final class LR implements Runnable, ChangeListener, DocumentListener { - private static final int REFRESH = 0; - private static final int UNMARK = 1; - private static final int ATTACH_DETACH = 2; + private final class LR implements Runnable, ChangeListener { - private int actionId; private EnhancedChangeEvent ev; public LR() {} - public LR (int actionId) { - this.actionId = actionId; - } - public LR (EnhancedChangeEvent ev) { - this.actionId = ATTACH_DETACH; this.ev = ev; } public void run () { - switch (actionId) { - case REFRESH: refreshState (); break; - case UNMARK: unmarkError (); break; - case ATTACH_DETACH: attachDetachAnnotations(ev.getDocument(), ev.isClosingDocument()); ev = null; break; - } + attachDetachAnnotations(ev.getDocument(), ev.isClosingDocument()); + ev = null; } - private void invoke(int op) { - // part of #33165 - done synchronously not invoking into EQ - //SwingUtilities.invokeLater(new LR(op)); - new LR(op).run(); - } - - private void invoke(EnhancedChangeEvent ev) { - // part of #33165 - done synchronously not invoking into EQ - //SwingUtilities.invokeLater(new LR(ev)); - new LR(ev).run(); - } - public void stateChanged (ChangeEvent ev) { - invoke(REFRESH); - invoke((EnhancedChangeEvent)ev); - } - - public void removeUpdate(final javax.swing.event.DocumentEvent p0) { - invoke(UNMARK); - } - - public void insertUpdate(final javax.swing.event.DocumentEvent p0) { - invoke(UNMARK); + // part of #33165 - done synchronously not invoking into EQ + //SwingUtilities.invokeLater(new LR((EnhancedChangeEvent)ev)); + new LR((EnhancedChangeEvent)ev).run(); } - public void changedUpdate(final javax.swing.event.DocumentEvent p0) { - } } /** Abstract implementation of {@link Line.Set}.