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 94607
Collapse All | Expand All

(-)apichanges.xml (+20 lines)
Lines 23-28 Link Here
23
<apidef name="text">Text API</apidef>
23
<apidef name="text">Text API</apidef>
24
</apidefs>
24
</apidefs>
25
<changes>
25
<changes>
26
    <change id="Line.SHOW_REUSE">
27
        <api name="text"/>
28
        <summary>Adding Line.SHOW_REUSE constant for Line.show method</summary>
29
        <version major="6" minor="13"/>
30
        <date day="7" month="2" year="2007"/>
31
        <author login="pnejedly"/>
32
        <compatibility addition="yes" binary="compatible" source="compatible" semantic="compatible" deprecation="no" deletion="no" modification="no"/>
33
        <description>
34
            <p>The <code>Line.show()</code> method accepts show mode constant,
35
            that influences the way the Line is displayed on the request.
36
            This additional constant provides a new mode for opening the line
37
            in a shared editor window that can be replaced by subsequent calls of
38
            <code>Line.show(SHOW_REUSE)</code> on <code>Line</code>s from different
39
            <code>Document</code>. This is useful for quick source browsing without
40
            cluttering the UI with too many opened editors.
41
            </p>
42
        </description>
43
        <class package="org.openide.text" name="Line"/>
44
        <issue number="94607"/>
45
    </change>
26
46
27
    <change id="CloneableEditorSupport.getEditorKit">
47
    <change id="CloneableEditorSupport.getEditorKit">
28
        <api name="text"/>
48
        <api name="text"/>
(-)manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.text
2
OpenIDE-Module: org.openide.text
3
OpenIDE-Module-Specification-Version: 6.12
3
OpenIDE-Module-Specification-Version: 6.13
4
OpenIDE-Module-Localizing-Bundle: org/openide/text/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/openide/text/Bundle.properties
5
5
(-)src/org/openide/text/Line.java (-1 / +11 lines)
Lines 69-74 Link Here
69
     */
69
     */
70
    public final static int SHOW_TOFRONT = 3;
70
    public final static int SHOW_TOFRONT = 3;
71
71
72
    /** Takes the focus in case the editor is already opened and shows the line.
73
     * Replaces (closes) the last editor opened using SHOW_REUSE in case 
74
     * the user haven't interacted with it much (e.g. haven't modified it).
75
     * Opens a new editor in case there is no such reusable editor
76
     * and marks it for editor reusal. 
77
     * @see #show(int) <code>show</code>
78
     */
79
    public final static int SHOW_REUSE = 4;
80
72
    /** Instance of null implementation of Line.Part */
81
    /** Instance of null implementation of Line.Part */
73
    static final private Line.Part nullPart = new Line.NullPart();
82
    static final private Line.Part nullPart = new Line.NullPart();
74
83
Lines 151-157 Link Here
151
    public abstract void show(int kind, int column);
160
    public abstract void show(int kind, int column);
152
161
153
    /** Shows the line (at the first column).
162
    /** Shows the line (at the first column).
154
    * @param kind one of {@link #SHOW_TRY_SHOW}, {@link #SHOW_SHOW}, or {@link #SHOW_GOTO}
163
    * @param kind one of {@link #SHOW_TRY_SHOW}, {@link #SHOW_SHOW}, {@link #SHOW_GOTO},
164
     * or {@link #SHOW_REUSE}
155
    * @see #show(int, int)
165
    * @see #show(int, int)
156
    */
166
    */
157
    public void show(int kind) {
167
    public void show(int kind) {
(-)src/org/openide/text/EditorSupportLineSet.java (-7 / +8 lines)
Lines 81-94 Link Here
81
                return;
81
                return;
82
            }
82
            }
83
83
84
            CloneableEditorSupport.Pane editor = support.openAt(pos, column);
84
            CloneableEditorSupport.Pane editor;
85
85
            
86
            if (kind == SHOW_GOTO) {
86
            if (kind == SHOW_REUSE) {
87
                editor.getComponent().requestActive();
87
                editor = support.openReuse(pos, column);
88
            } else if (kind == SHOW_TOFRONT) {
88
            } else {
89
                editor.getComponent().toFront();
89
                editor = support.openAt(pos, column);
90
                editor.getComponent().requestActive();
90
                if (kind == SHOW_TOFRONT) editor.getComponent().toFront();
91
            }
91
            }
92
            editor.getComponent().requestActive();
92
        }
93
        }
93
94
94
        /** This method will be used for annotation of part of the text on the line.*/
95
        /** This method will be used for annotation of part of the text on the line.*/
(-)src/org/openide/text/CloneableEditorSupport.java (-5 / +39 lines)
Lines 1599-1604 Link Here
1599
            return false;
1599
            return false;
1600
        }
1600
        }
1601
1601
1602
        // source modified, remove it from tab-reusing slot
1603
        lastReusable.clear();
1602
        updateTitles();
1604
        updateTitles();
1603
1605
1604
        return true;
1606
        return true;
Lines 1960-1970 Link Here
1960
        }
1962
        }
1961
    }
1963
    }
1962
1964
1965
    private static Reference<CloneableTopComponent> lastReusable = new WeakReference(null);
1966
    
1967
    // temporal - should be replaced by better impl in winsys
1968
    private static void replaceTc(TopComponent orig, TopComponent open) {
1969
        orig.close();
1970
        open.open();
1971
    }
1972
1963
    // #18981. There could happen a thing also another class type
1973
    // #18981. There could happen a thing also another class type
1964
    // of CloneableTopCoponent then CloneableEditor could be in allEditors.
1974
    // of CloneableTopCoponent then CloneableEditor could be in allEditors.
1965
1975
1966
    /** Opens a <code>CloneableEditor</code> component. */
1976
    /** Opens a <code>CloneableEditor</code> component. */
1967
    private Pane openPane() {
1977
    private Pane openPane(boolean reuse) {
1968
        Pane ce = null;
1978
        Pane ce = null;
1969
        boolean displayMsgOpened = false;
1979
        boolean displayMsgOpened = false;
1970
1980
Lines 1991-1998 Link Here
1991
        }
2001
        }
1992
2002
1993
        // #36601 - open moved outside getLock() synchronization
2003
        // #36601 - open moved outside getLock() synchronization
1994
        ce.getComponent().open();
2004
        CloneableTopComponent ctc = ce.getComponent();
1995
2005
        if (reuse && displayMsgOpened) {
2006
            CloneableTopComponent last = lastReusable.get();
2007
            if (last != null) {
2008
                replaceTc(last, ctc);
2009
            } else {
2010
                ctc.open();
2011
            }
2012
            lastReusable = new WeakReference(ctc);
2013
        } else {
2014
            ctc.open();
2015
        }
2016
        
1996
        if (displayMsgOpened) {
2017
        if (displayMsgOpened) {
1997
            String msg = messageOpened();
2018
            String msg = messageOpened();
1998
2019
Lines 2046-2052 Link Here
2046
            return null;
2067
            return null;
2047
        }
2068
        }
2048
    }
2069
    }
2049
2070
   
2071
    final Pane openReuse(final PositionRef pos, final int column) {
2072
        return openAtImpl(pos, column, true);
2073
    }
2074
    
2050
    /** Forcibly create one editor component. Then set the caret
2075
    /** Forcibly create one editor component. Then set the caret
2051
    * to the given position.
2076
    * to the given position.
2052
    * @param pos where to place the caret
2077
    * @param pos where to place the caret
Lines 2054-2060 Link Here
2054
    * @since 5.2
2079
    * @since 5.2
2055
    */
2080
    */
2056
    protected final Pane openAt(final PositionRef pos, final int column) {
2081
    protected final Pane openAt(final PositionRef pos, final int column) {
2057
        final Pane e = openPane();
2082
        return openAtImpl(pos, column,false);
2083
    }
2084
    /** Forcibly create one editor component. Then set the caret
2085
    * to the given position.
2086
    * @param pos where to place the caret
2087
    * @return always non-<code>null</code> editor
2088
    * @since 5.2
2089
    */
2090
    private final Pane openAtImpl(final PositionRef pos, final int column, boolean reuse) {
2091
        final Pane e = openPane(reuse);
2058
        final Task t = prepareDocument();
2092
        final Task t = prepareDocument();
2059
        e.ensureVisible();
2093
        e.ensureVisible();
2060
        class Selector implements TaskListener, Runnable {
2094
        class Selector implements TaskListener, Runnable {

Return to bug 94607