Index: openide/src/org/openide/text/CloneableEditor.java =================================================================== RCS file: /cvs/openide/src/org/openide/text/CloneableEditor.java,v retrieving revision 1.69 diff -u -r1.69 CloneableEditor.java --- openide/src/org/openide/text/CloneableEditor.java 13 Feb 2004 10:20:29 -0000 1.69 +++ openide/src/org/openide/text/CloneableEditor.java 2 Apr 2004 13:55:53 -0000 @@ -40,7 +40,7 @@ /** Cloneable top component to hold the editor kit. */ -public class CloneableEditor extends CloneableTopComponent { +public class CloneableEditor extends CloneableTopComponent implements CloneableEditorSupport.Pane { /** editor pane */ protected JEditorPane pane; @@ -388,7 +388,7 @@ * updated thru its {@link CloneableEditorSupport#messageName} and * {@link CloneableEditorSupport#messageToolTip} methods. * @see #cloneableEditorSupport() */ - protected void updateName() { + public void updateName() { final CloneableEditorSupport ces = cloneableEditorSupport(); if(ces != null) { Mutex.EVENT.writeAccess(new Runnable() { @@ -587,6 +587,18 @@ } return ourMode; } + + // + // Implements the CloneableEditorSupport.Pane interface + // + + public CloneableTopComponent getComponent() { + return this; + } + public JEditorPane getEditorPane() { + return pane; + } + } Index: openide/src/org/openide/text/CloneableEditorSupport.java =================================================================== RCS file: /cvs/openide/src/org/openide/text/CloneableEditorSupport.java,v retrieving revision 1.120 diff -u -r1.120 CloneableEditorSupport.java --- openide/src/org/openide/text/CloneableEditorSupport.java 15 Mar 2004 16:11:25 -0000 1.120 +++ openide/src/org/openide/text/CloneableEditorSupport.java 2 Apr 2004 13:56:01 -0000 @@ -145,7 +145,7 @@ private HashSet listeners; /** last selected editor. */ - transient CloneableEditor lastSelected; + transient Pane lastSelected; /** The time of the last save to determine the real external modifications */ @@ -687,19 +687,20 @@ Enumeration en = allEditors.getComponents (); while (en.hasMoreElements ()) { Object o = en.nextElement (); - if (o instanceof CloneableEditor) { - CloneableEditor ed = (CloneableEditor)o; + if (o instanceof Pane) { + Pane ed = (Pane)o; // #23491: pane could be still null, not yet shown component. // [PENDING] Right solution? TopComponent opened, but pane not. - if(ed.pane == null) { + JEditorPane p = ed.getEditorPane(); + if(p == null) { continue; } if (lastSelected == ed) { - ll.addFirst (ed.pane); + ll.addFirst (p); } else { - ll.add (ed.pane); + ll.add (p); } } } @@ -795,6 +796,11 @@ // initializes the document if not initialized prepareDocument (); + Pane pane = createPane (); + return pane.getComponent (); + } + + protected Pane createPane () { CloneableEditor ed = createCloneableEditor (); initializeCloneableEditor (ed); return ed; @@ -1616,8 +1622,8 @@ Enumeration en = allEditors.getComponents (); while (en.hasMoreElements()) { Object o = en.nextElement(); - if (o instanceof CloneableEditor) { - CloneableEditor e = (CloneableEditor)o; + if (o instanceof Pane) { + Pane e = (Pane)o; e.updateName(); } } @@ -1626,8 +1632,8 @@ // #18981. There could happen a thing also another class type // of CloneableTopCoponent then CloneableEditor could be in allEditors. /** Opens a CloneableEditor component. */ - private CloneableEditor openEditorComponent() { - CloneableEditor ce = null; + private Pane openPane () { + Pane ce = null; boolean displayMsgOpened = false; synchronized (getLock()) { ce = getAnyEditor(); @@ -1642,9 +1648,10 @@ // initializes the document if not initialized prepareDocument(); - ce = createCloneableEditor (); - initializeCloneableEditor(ce); - ce.setReference(allEditors); + CloneableEditor editor = createCloneableEditor (); + initializeCloneableEditor(editor); + editor.setReference(allEditors); + ce = editor; // signal opened msg should be displayed after subsequent open finishes displayMsgOpened = true; @@ -1652,7 +1659,7 @@ } // #36601 - open moved outside getLock() synchronization - ce.open(); + ce.getComponent ().open(); if (displayMsgOpened) { String msg = messageOpened (); @@ -1668,7 +1675,7 @@ /** If one or more editors are opened finds one. * @return an editor or null if none is opened */ - CloneableEditor getAnyEditor () { + private Pane getAnyEditor () { CloneableTopComponent ctc; ctc = allEditors.getArbitraryComponent(); @@ -1676,14 +1683,14 @@ return null; } - if(ctc instanceof CloneableEditor) { - return (CloneableEditor)ctc; + if(ctc instanceof Pane) { + return (Pane)ctc; } else { Enumeration en = allEditors.getComponents(); while(en.hasMoreElements()) { Object o = en.nextElement(); - if(o instanceof CloneableEditor) { - return (CloneableEditor)o; + if(o instanceof Pane) { + return (Pane)o; } } @@ -1696,11 +1703,11 @@ * @param pos where to place the caret * @return always non-null editor */ - final CloneableEditor openAt(final PositionRef pos, final int column) { - final CloneableEditor e = openEditorComponent(); + final Pane openAt(final PositionRef pos, final int column) { + final Pane e = openPane (); final Task t = prepareDocument (); - e.open(); - e.requestVisible(); + e.getComponent ().open(); + e.getComponent ().requestVisible(); class Selector implements TaskListener, Runnable { public void taskFinished (org.openide.util.Task t2) { @@ -1710,7 +1717,7 @@ public void run () { // #25435. Pane can be null. - JEditorPane ePane = e.pane; + JEditorPane ePane = e.getEditorPane (); if(ePane == null) { return; } @@ -2148,5 +2155,13 @@ } } + } + + /** Describes one existing editor. + */ + public interface Pane { + public JEditorPane getEditorPane (); + public CloneableTopComponent getComponent (); + public void updateName (); } } Index: openide/src/org/openide/text/EditorSupportLineSet.java =================================================================== RCS file: /cvs/openide/src/org/openide/text/EditorSupportLineSet.java,v retrieving revision 1.36 diff -u -r1.36 EditorSupportLineSet.java --- openide/src/org/openide/text/EditorSupportLineSet.java 30 Jan 2004 16:44:58 -0000 1.36 +++ openide/src/org/openide/text/EditorSupportLineSet.java 2 Apr 2004 13:56:02 -0000 @@ -74,10 +74,10 @@ if (kind == SHOW_TRY_SHOW && !support.isDocumentLoaded ()) return; - CloneableEditor editor = support.openAt(pos, column); + CloneableEditorSupport.Pane editor = support.openAt(pos, column); if (kind == SHOW_GOTO) { - editor.requestActive(); + editor.getComponent ().requestActive(); } }