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

(-)core/windows/src/org/netbeans/core/windows/actions/ActionUtils.java (-2 / +11 lines)
Line 213 Link Here
213
            setEnabled(tc instanceof TopComponent.Cloneable);
213
            boolean canClone = (tc instanceof TopComponent.Cloneable);
214
--
214
            if (tc instanceof TopComponent.Cloneable2) {
215
                canClone = ((TopComponent.Cloneable2)tc).canClone();
216
            }
217
            setEnabled(canClone);
Line 286 Link Here
290
            if (tc instanceof TopComponent.Cloneable2) {
291
                if (!((TopComponent.Cloneable2)tc).canClone()) {
292
                    // shall not get here, but just in case it does, just ignore.
293
                    return;
294
                }
295
            }
(-)core/windows/src/org/netbeans/core/windows/actions/CloneDocumentAction.java (-4 / +10 lines)
Line 49 Link Here
49
        
49
        if (tc instanceof TopComponent.Cloneable2) {
50
--
50
            if (!((TopComponent.Cloneable2)tc).canClone()) {
51
                return;
52
            }
53
        }
Line 69 Link Here
69
        setEnabled(tc instanceof TopComponent.Cloneable
73
        boolean tcCloneable = (tc instanceof TopComponent.Cloneable);
70
--
74
        if (tc instanceof TopComponent.Cloneable2) {
75
            tcCloneable = ((TopComponent.Cloneable2)tc).canClone();
76
        }
77
        setEnabled(tcCloneable
(-)core/windows/src/org/netbeans/core/windows/view/dnd/TopComponentDragSupport.java (-20 / +31 lines)
Lines 303-306 Link Here
303
        if(firstTC instanceof TopComponent.Cloneable) {
303
        canCopy = (firstTC instanceof TopComponent.Cloneable);
304
            canCopy = true;
304
        if (firstTC instanceof TopComponent.Cloneable2) {
305
        } else {
305
            canCopy = ((TopComponent.Cloneable2)firstTC).canClone();
306
            canCopy = false;
307
--
Line 816 Link Here
816
                return tc;
815
                Object toReturn = tc;
817
--
816
                if (tc instanceof TopComponent.Cloneable2) {
817
                    if (!((TopComponent.Cloneable2)tc).canClone()) {
818
                        toReturn = null;
819
                    }
820
                }
821
                return toReturn;
Lines 830-839 Link Here
830
                return new DataFlavor[] {
835
                boolean canClone = true;
831
                    new DataFlavor(MIME_TOP_COMPONENT, null),
836
                if (tc instanceof TopComponent.Cloneable2) {
832
                    new DataFlavor(
837
                    canClone = ((TopComponent.Cloneable2)tc).canClone();
833
                        MIME_TOP_COMPONENT_CLONEABLE, null)
838
                }
834
                };
839
                if (canClone) {
835
            } else {
840
                    return new DataFlavor[] {
836
                return new DataFlavor[] {
841
                        new DataFlavor(MIME_TOP_COMPONENT, null),
837
                    new DataFlavor(MIME_TOP_COMPONENT, null)
842
                        new DataFlavor(
838
                };
843
                            MIME_TOP_COMPONENT_CLONEABLE, null)
839
            }
844
                    };
840
--
845
                }
846
                // otherwise go with the default..
847
            } 
848
            return new DataFlavor[] {
849
                new DataFlavor(MIME_TOP_COMPONENT, null)
850
            };
Line 855 Link Here
855
                return true;
866
                boolean canClone = true;
856
--
867
                if (tc instanceof TopComponent.Cloneable2) {
868
                    canClone = ((TopComponent.Cloneable2)tc).canClone();
869
                }
870
                return canClone;
(-)openide/src/org/openide/windows/DummyWindowManager.java (-20 / +23 lines)
Lines 202-208 Link Here
202
                if (DEFAULT_ACTIONS_CLONEABLE == null) {
202
                boolean canClone = true;
203
                    DEFAULT_ACTIONS_CLONEABLE = loadActions (new String[] {
203
                if (tc instanceof TopComponent.Cloneable2) {
204
                        "Save", // NOI18N
204
                    canClone = ((TopComponent.Cloneable2)tc).canClone();
205
                        "CloneView", // NOI18N
206
                        null,
207
                        "CloseView" // NOI18N
208
                    });
209
--
Lines 210-217 Link Here
210
                return DEFAULT_ACTIONS_CLONEABLE;
206
                if (canClone) {
211
            } else {
207
                    if (DEFAULT_ACTIONS_CLONEABLE == null) {
212
                if (DEFAULT_ACTIONS_NOT_CLONEABLE == null) {
208
                        DEFAULT_ACTIONS_CLONEABLE = loadActions (new String[] {
213
                    DEFAULT_ACTIONS_NOT_CLONEABLE = loadActions (new String[] {
209
                            "Save", // NOI18N
214
                        "Save", // NOI18N
210
                            "CloneView", // NOI18N
215
                        null,
211
                            null,
216
                        "CloseView" // NOI18N
212
                            "CloseView" // NOI18N
217
                    });
213
                        });
218
--
214
                    }
215
                    return DEFAULT_ACTIONS_CLONEABLE;
Lines 219-220 Link Here
219
                return DEFAULT_ACTIONS_NOT_CLONEABLE;
217
                // if cannot clone, go on..
220
            }
218
            } 
221
--
219
            if (DEFAULT_ACTIONS_NOT_CLONEABLE == null) {
220
                DEFAULT_ACTIONS_NOT_CLONEABLE = loadActions (new String[] {
221
                   "Save", // NOI18N
222
                    null,
223
                    "CloseView" // NOI18N
224
                });
225
             }
226
             return DEFAULT_ACTIONS_NOT_CLONEABLE;
(-)openide/src/org/openide/windows/TopComponent.java (-9 / +30 lines)
Lines 169-176 Link Here
169
            am.put("cloneWindow", new javax.swing.AbstractAction() { // NOI18N
169
            boolean canClone = true;
170
                public void actionPerformed(ActionEvent evt) {
170
            if (this instanceof TopComponent.Cloneable2) {
171
                    TopComponent cloned = ((TopComponent.Cloneable)
171
                canClone = ((TopComponent.Cloneable2)this).canClone();
172
                        TopComponent.this).cloneComponent();
172
            }
173
                    cloned.open();
173
            if (canClone) {
174
                    cloned.requestActive();
174
                am.put("cloneWindow", new javax.swing.AbstractAction() { // NOI18N
175
                }
175
                    public void actionPerformed(ActionEvent evt) {
176
            });
176
                        TopComponent cloned = ((TopComponent.Cloneable)
177
--
177
                            TopComponent.this).cloneComponent();
178
                        cloned.open();
179
                        cloned.requestActive();
180
                    }
181
                });
182
            }
Line 767 Link Here
773
    }
774
    
775
    // mkleint - multiviews.
776
    /**
777
     * Extension of TopCpmponent.Cloneable.
778
     *Each top component that wishes to be cloned conditionally should implement
779
    * this interface, so CloneAction can check it and call the cloneComponent
780
    * method. The condition shall be constant during lifecycle of the TopComponent,
781
     * allows to subclass TopComponent.Cloneable classes and prohibit cloning for them.
782
     * 
783
     */
784
    public static interface Cloneable2 extends Cloneable {
785
        /**
786
         * 
787
         */
788
        public boolean canClone();
(-)openide/api/doc/changes/apichanges.xml (+41 lines)
Line 119 Link Here
119
    <api name="editor"/>
120
    <summary>Instance based Cloneability of TopComponents. </summary>
121
    <version major="4" minor="31"/>
122
    <date day="1" month="5" year="2004"/>
123
    <author login="mkleint"/>
124
    <compatibility addition="yes" modification="no" deprecation="no" semantic="compatible"/>
125
    <description>
126
        Introduced new interface TopComponent.Cloneable2 which extends TopComponent.Cloneable and add method canClone(). Classes
127
        implementing this interface can decide wheather a particular instance is cloneable or not.
128
    </description>
129
    <class package="org.openide.windows" name="TopComponent"/>
130
    <issue number="42646"/>
131
    </change>
132
  
133
    <change>
134
    <api name="editor"/>
135
    <summary>  </summary>
136
    <version major="4" minor="30"/>
137
    <date day="20" month="4" year="2004"/>
138
    <author login="mkleint"/>
139
    <compatibility addition="yes" modification="yes" deprecation="yes" semantic="compatible"/>
140
    <description>
141
        In order to implement MultiViews, these changes were necessary to the org.openide.text package.
142
        <ul>
143
            <li>Added new subinterface to NbDocument -> NbDocument.CustomToolbar which lets the implementors to define a custom toolbar. 
144
            It allows to present the toolbar in different environments (eg. multiviews)</li>
145
            <li>CloneableEditorSupport defined a new interface CloneableEditorSupport.Pane and has a new protected method createPane() </li>
146
            <li>The deprecated EditorSupport has a new protected method createPane() </li>
147
            <li>CloneableEditor implements CloneableEditorSupport.Pane, thus 
148
            updateTitle was changed from protected to public and 2 additional methods from Pane interfacewere added</li>
149
            
150
        </ul>
151
    </description>
152
    <class package="org.openide.text" name="NbDocument"/>
153
    <class package="org.openide.text" name="CloneableEditorSupport"/>
154
    <class package="org.openide.text" name="CloneableEditor"/>
155
    <class package="org.openide.text" name="EditorSupport"/>
156
    <issue number="41085"/>
157
    </change>
158
  
159
    <change>

Return to bug 42646