This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 41291
Collapse All | Expand All

(-)openide/src/org/openide/text/CloneableEditor.java (-2 / +14 lines)
Lines 40-46 Link Here
40
40
41
/** Cloneable top component to hold the editor kit.
41
/** Cloneable top component to hold the editor kit.
42
 */
42
 */
43
public class CloneableEditor extends CloneableTopComponent {
43
public class CloneableEditor extends CloneableTopComponent implements CloneableEditorSupport.Pane {
44
    /** editor pane  */
44
    /** editor pane  */
45
    protected JEditorPane pane;
45
    protected JEditorPane pane;
46
46
Lines 388-394 Link Here
388
     * updated thru its {@link CloneableEditorSupport#messageName} and 
388
     * updated thru its {@link CloneableEditorSupport#messageName} and 
389
     * {@link CloneableEditorSupport#messageToolTip} methods.
389
     * {@link CloneableEditorSupport#messageToolTip} methods.
390
     * @see #cloneableEditorSupport() */
390
     * @see #cloneableEditorSupport() */
391
    protected void updateName() {
391
    public void updateName() {
392
        final CloneableEditorSupport ces = cloneableEditorSupport();
392
        final CloneableEditorSupport ces = cloneableEditorSupport();
393
        if(ces != null) {
393
        if(ces != null) {
394
            Mutex.EVENT.writeAccess(new Runnable() {
394
            Mutex.EVENT.writeAccess(new Runnable() {
Lines 587-592 Link Here
587
        }
587
        }
588
        return ourMode;
588
        return ourMode;
589
    }
589
    }
590
    
591
    //
592
    // Implements the CloneableEditorSupport.Pane interface
593
    //
594
    
590
595
596
    public CloneableTopComponent getComponent() {
597
        return this;
598
    }    
591
599
600
    public JEditorPane getEditorPane() {
601
        return pane;
602
    }
603
    
592
}
604
}
(-)openide/src/org/openide/text/CloneableEditorSupport.java (-24 / +39 lines)
Lines 145-151 Link Here
145
    private HashSet listeners;
145
    private HashSet listeners;
146
146
147
    /** last selected editor. */
147
    /** last selected editor. */
148
    transient CloneableEditor lastSelected;
148
    transient Pane lastSelected;
149
149
150
150
151
    /** The time of the last save to determine the real external modifications */
151
    /** The time of the last save to determine the real external modifications */
Lines 687-705 Link Here
687
        Enumeration en = allEditors.getComponents ();
687
        Enumeration en = allEditors.getComponents ();
688
        while (en.hasMoreElements ()) {
688
        while (en.hasMoreElements ()) {
689
            Object o = en.nextElement ();
689
            Object o = en.nextElement ();
690
            if (o instanceof CloneableEditor) {
690
            if (o instanceof Pane) {
691
                CloneableEditor ed = (CloneableEditor)o;
691
                Pane ed = (Pane)o;
692
                
692
                
693
                // #23491: pane could be still null, not yet shown component.
693
                // #23491: pane could be still null, not yet shown component.
694
                // [PENDING] Right solution? TopComponent opened, but pane not.
694
                // [PENDING] Right solution? TopComponent opened, but pane not.
695
                if(ed.pane == null) {
695
                JEditorPane p = ed.getEditorPane();
696
                if(p == null) {
696
                    continue;
697
                    continue;
697
                }
698
                }
698
                
699
                
699
                if (lastSelected == ed) {
700
                if (lastSelected == ed) {
700
                    ll.addFirst (ed.pane);
701
                    ll.addFirst (p);
701
                } else {
702
                } else {
702
                    ll.add (ed.pane);
703
                    ll.add (p);
703
                }
704
                }
704
            }
705
            }
705
        }
706
        }
Lines 795-800 Link Here
795
        // initializes the document if not initialized
796
        // initializes the document if not initialized
796
        prepareDocument ();
797
        prepareDocument ();
797
        
798
        
799
        Pane pane = createPane ();
800
        return pane.getComponent ();
801
    }
802
    
803
    protected Pane createPane () {
798
        CloneableEditor ed = createCloneableEditor ();
804
        CloneableEditor ed = createCloneableEditor ();
799
        initializeCloneableEditor (ed);
805
        initializeCloneableEditor (ed);
800
        return ed;
806
        return ed;
Lines 1616-1623 Link Here
1616
        Enumeration en = allEditors.getComponents ();
1622
        Enumeration en = allEditors.getComponents ();
1617
        while (en.hasMoreElements()) {
1623
        while (en.hasMoreElements()) {
1618
            Object o = en.nextElement();
1624
            Object o = en.nextElement();
1619
            if (o instanceof CloneableEditor) {
1625
            if (o instanceof Pane) {
1620
                CloneableEditor e = (CloneableEditor)o;
1626
                Pane e = (Pane)o;
1621
                e.updateName();
1627
                e.updateName();
1622
            }
1628
            }
1623
        }
1629
        }
Lines 1626-1633 Link Here
1626
    // #18981. There could happen a thing also another class type
1632
    // #18981. There could happen a thing also another class type
1627
    // of CloneableTopCoponent then CloneableEditor could be in allEditors.
1633
    // of CloneableTopCoponent then CloneableEditor could be in allEditors.
1628
    /** Opens a <code>CloneableEditor</code> component. */
1634
    /** Opens a <code>CloneableEditor</code> component. */
1629
    private CloneableEditor openEditorComponent() {
1635
    private Pane openPane () {
1630
        CloneableEditor ce = null;
1636
        Pane ce = null;
1631
        boolean displayMsgOpened = false;
1637
        boolean displayMsgOpened = false;
1632
        synchronized (getLock()) {
1638
        synchronized (getLock()) {
1633
            ce = getAnyEditor();
1639
            ce = getAnyEditor();
Lines 1642-1650 Link Here
1642
                // initializes the document if not initialized
1648
                // initializes the document if not initialized
1643
                prepareDocument();
1649
                prepareDocument();
1644
1650
1645
                ce = createCloneableEditor ();
1651
                CloneableEditor editor = createCloneableEditor ();
1646
                initializeCloneableEditor(ce);
1652
                initializeCloneableEditor(editor);
1647
                ce.setReference(allEditors);
1653
                editor.setReference(allEditors);
1654
                ce = editor;
1648
                
1655
                
1649
                // signal opened msg should be displayed after subsequent open finishes
1656
                // signal opened msg should be displayed after subsequent open finishes
1650
                displayMsgOpened = true;
1657
                displayMsgOpened = true;
Lines 1652-1658 Link Here
1652
        }
1659
        }
1653
1660
1654
        // #36601 - open moved outside getLock() synchronization
1661
        // #36601 - open moved outside getLock() synchronization
1655
        ce.open();
1662
        ce.getComponent ().open();
1656
1663
1657
        if (displayMsgOpened) {
1664
        if (displayMsgOpened) {
1658
            String msg = messageOpened ();
1665
            String msg = messageOpened ();
Lines 1668-1674 Link Here
1668
    /** If one or more editors are opened finds one.
1675
    /** If one or more editors are opened finds one.
1669
    * @return an editor or null if none is opened
1676
    * @return an editor or null if none is opened
1670
    */
1677
    */
1671
    CloneableEditor getAnyEditor () {
1678
    private Pane getAnyEditor () {
1672
        CloneableTopComponent ctc;
1679
        CloneableTopComponent ctc;
1673
        ctc = allEditors.getArbitraryComponent();
1680
        ctc = allEditors.getArbitraryComponent();
1674
        
1681
        
Lines 1676-1689 Link Here
1676
            return null;
1683
            return null;
1677
        }
1684
        }
1678
1685
1679
        if(ctc instanceof CloneableEditor) {
1686
        if(ctc instanceof Pane) {
1680
            return (CloneableEditor)ctc;
1687
            return (Pane)ctc;
1681
        } else {
1688
        } else {
1682
            Enumeration en = allEditors.getComponents();
1689
            Enumeration en = allEditors.getComponents();
1683
            while(en.hasMoreElements()) {
1690
            while(en.hasMoreElements()) {
1684
                Object o = en.nextElement();
1691
                Object o = en.nextElement();
1685
                if(o instanceof CloneableEditor) {
1692
                if(o instanceof Pane) {
1686
                    return (CloneableEditor)o;
1693
                    return (Pane)o;
1687
                }
1694
                }
1688
            }
1695
            }
1689
1696
Lines 1696-1706 Link Here
1696
    * @param pos where to place the caret
1703
    * @param pos where to place the caret
1697
    * @return always non-<code>null</code> editor
1704
    * @return always non-<code>null</code> editor
1698
    */
1705
    */
1699
    final CloneableEditor openAt(final PositionRef pos, final int column) {
1706
    final Pane openAt(final PositionRef pos, final int column) {
1700
        final CloneableEditor e = openEditorComponent();
1707
        final Pane e = openPane ();
1701
        final Task t = prepareDocument ();
1708
        final Task t = prepareDocument ();
1702
        e.open();
1709
        e.getComponent ().open();
1703
        e.requestVisible();
1710
        e.getComponent ().requestVisible();
1704
        
1711
        
1705
        class Selector implements TaskListener, Runnable {
1712
        class Selector implements TaskListener, Runnable {
1706
            public void taskFinished (org.openide.util.Task t2) {
1713
            public void taskFinished (org.openide.util.Task t2) {
Lines 1710-1716 Link Here
1710
            
1717
            
1711
            public void run () {
1718
            public void run () {
1712
                // #25435. Pane can be null.
1719
                // #25435. Pane can be null.
1713
                JEditorPane ePane = e.pane;
1720
                JEditorPane ePane = e.getEditorPane ();
1714
                if(ePane == null) {
1721
                if(ePane == null) {
1715
                    return;
1722
                    return;
1716
                }
1723
                }
Lines 2148-2152 Link Here
2148
            }
2155
            }
2149
        }
2156
        }
2150
2157
2158
    }
2159
    
2160
    /** Describes one existing editor.
2161
     */
2162
    public interface Pane {
2163
        public JEditorPane getEditorPane ();
2164
        public CloneableTopComponent getComponent ();
2165
        public void updateName ();
2151
    }
2166
    }
2152
}
2167
}
(-)openide/src/org/openide/text/EditorSupportLineSet.java (-2 / +2 lines)
Lines 74-83 Link Here
74
74
75
            if (kind == SHOW_TRY_SHOW && !support.isDocumentLoaded ()) return;
75
            if (kind == SHOW_TRY_SHOW && !support.isDocumentLoaded ()) return;
76
76
77
            CloneableEditor editor = support.openAt(pos, column);
77
            CloneableEditorSupport.Pane editor = support.openAt(pos, column);
78
78
79
            if (kind == SHOW_GOTO) {
79
            if (kind == SHOW_GOTO) {
80
                editor.requestActive();
80
                editor.getComponent ().requestActive();
81
            }
81
            }
82
        }
82
        }
83
83

Return to bug 41291