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

(-)a/core.multiview/src/org/netbeans/core/multiview/ContextAwareDescription.java (-1 / +2 lines)
Lines 51-55 Link Here
51
 */
51
 */
52
@MimeLocation(subfolderName="MultiView")
52
@MimeLocation(subfolderName="MultiView")
53
public interface ContextAwareDescription extends MultiViewDescription {
53
public interface ContextAwareDescription extends MultiViewDescription {
54
    public ContextAwareDescription createContextAwareDescription(Lookup context);
54
    public ContextAwareDescription createContextAwareDescription(Lookup context, boolean isSplitDescription);
55
    public boolean isSplitDescription();
55
}
56
}
(-)a/core.multiview/src/org/netbeans/core/multiview/EditorsAction.java (-2 / +4 lines)
Lines 142-149 Link Here
142
                        if (thisPers.getDisplayName().equals(handler.getSelectedPerspective().getDisplayName())) {
142
                        if (thisPers.getDisplayName().equals(handler.getSelectedPerspective().getDisplayName())) {
143
                            item.setSelected(true);
143
                            item.setSelected(true);
144
                        }
144
                        }
145
                        group.add(item);
145
			if (!((ContextAwareDescription) Accessor.DEFAULT.extractDescription(thisPers)).isSplitDescription()) {
146
                        add(item);
146
			    group.add(item);
147
			    add(item);
148
			}
147
                    }
149
                    }
148
                } else { // handler == null
150
                } else { // handler == null
149
                    //No reason to enable action on any TC because now it was enabled even for Welcome page
151
                    //No reason to enable action on any TC because now it was enabled even for Welcome page
(-)a/core.multiview/src/org/netbeans/core/multiview/MultiViewCloneableTopComponent.java (-3 / +18 lines)
Lines 106-112 Link Here
106
    
106
    
107
    private void setDeserializedMultiViewDescriptions(MultiViewDescription[] descriptions, 
107
    private void setDeserializedMultiViewDescriptions(MultiViewDescription[] descriptions, 
108
                                                      MultiViewDescription defaultDesc, Map existingElements) {
108
                                                      MultiViewDescription defaultDesc, Map existingElements) {
109
        peer.setDeserializedMultiViewDescriptions(descriptions, defaultDesc, existingElements);
109
        peer.setDeserializedMultiViewDescriptions(-1, descriptions, defaultDesc, null, existingElements);
110
    }
110
    }
111
    
111
    
112
    MultiViewModel getModel() {
112
    MultiViewModel getModel() {
Lines 173-181 Link Here
173
        Action[] superActions = super.getActions();
173
        Action[] superActions = super.getActions();
174
        Action[] acts = peer.peerGetActions(superActions);
174
        Action[] acts = peer.peerGetActions(superActions);
175
        
175
        
176
        Action[] myActions = new Action[acts.length + 2];
176
        Action[] myActions = new Action[acts.length + 3];
177
        System.arraycopy(acts, 0, myActions, 0, acts.length);
177
        System.arraycopy(acts, 0, myActions, 0, acts.length);
178
        myActions[acts.length + 1] = new EditorsAction();
178
        myActions[acts.length + 1] = new EditorsAction();
179
        myActions[acts.length + 2] = new SplitAction(true);
179
        return myActions;
180
        return myActions;
180
    }
181
    }
181
    
182
    
Lines 198-208 Link Here
198
    @Override
199
    @Override
199
    protected CloneableTopComponent createClonedObject() {
200
    protected CloneableTopComponent createClonedObject() {
200
        MultiViewCloneableTopComponent tc = new MultiViewCloneableTopComponent();
201
        MultiViewCloneableTopComponent tc = new MultiViewCloneableTopComponent();
201
        tc.setMultiViewDescriptions(peer.model.getDescriptions(), peer.model.getActiveDescription());;
202
        tc.setMultiViewDescriptions(peer.model.getDescriptions(), peer.model.getActiveDescription());
202
        tc.setCloseOperationHandler(peer.closeHandler);
203
        tc.setCloseOperationHandler(peer.closeHandler);
203
        tc.peer.copyMimeContext(peer);
204
        tc.peer.copyMimeContext(peer);
204
        return tc;
205
        return tc;
205
    }
206
    }
207
208
    public TopComponent splitComponent(int orientation) {
209
	peer.peerSplitComponent(orientation);
210
	return this;
211
    }
212
213
    public TopComponent clearSplit() {
214
	peer.peerClearSplit();
215
	return this;
216
    }
217
218
    public int getSplitOrientation() {
219
	return peer.getSplitOrientation();
220
    }
206
    
221
    
207
    /** Serialize this top component.
222
    /** Serialize this top component.
208
    * Subclasses wishing to store state must call the super method, then write to the stream.
223
    * Subclasses wishing to store state must call the super method, then write to the stream.
(-)a/core.multiview/src/org/netbeans/core/multiview/MultiViewModel.java (+9 lines)
Lines 73-78 Link Here
73
//    private Map nestedPerspectiveComponents; //key=description, value mull or perspectiveComponent
73
//    private Map nestedPerspectiveComponents; //key=description, value mull or perspectiveComponent
74
    private MultiViewDescription[] descriptions;
74
    private MultiViewDescription[] descriptions;
75
    private ButtonGroup group;
75
    private ButtonGroup group;
76
    private ButtonGroup groupSplit;
76
    private Collection<MultiViewElement> shownElements;
77
    private Collection<MultiViewElement> shownElements;
77
    private ArrayList<ElementSelectionListener> listeners;
78
    private ArrayList<ElementSelectionListener> listeners;
78
    private ActionRequestObserverFactory observerFactory;
79
    private ActionRequestObserverFactory observerFactory;
Lines 108-113 Link Here
108
        }
109
        }
109
        currentEditor = (defaultDescr == null || !nestedElements.containsKey(defaultDescr) ? descriptions[0] : defaultDescr);
110
        currentEditor = (defaultDescr == null || !nestedElements.containsKey(defaultDescr) ? descriptions[0] : defaultDescr);
110
        group = new BtnGroup();
111
        group = new BtnGroup();
112
	groupSplit = new BtnGroup();
111
    }
113
    }
112
    
114
    
113
    
115
    
Lines 196-201 Link Here
196
        return group;
198
        return group;
197
    }
199
    }
198
    
200
    
201
    /**
202
     * The button group where the togglebuttons for the split descriptions are put into.
203
     */
204
    ButtonGroup getButtonGroupSplit() {
205
        return groupSplit;
206
    }
207
    
199
    MultiViewElement getElementForDescription(MultiViewDescription description) {
208
    MultiViewElement getElementForDescription(MultiViewDescription description) {
200
        return getElementForDescription(description, true);
209
        return getElementForDescription(description, true);
201
    }
210
    }
(-)a/core.multiview/src/org/netbeans/core/multiview/MultiViewPeer.java (-12 / +112 lines)
Lines 71-76 Link Here
71
import javax.swing.InputMap;
71
import javax.swing.InputMap;
72
import javax.swing.JComponent;
72
import javax.swing.JComponent;
73
import javax.swing.JEditorPane;
73
import javax.swing.JEditorPane;
74
import javax.swing.JSplitPane;
74
import javax.swing.KeyStroke;
75
import javax.swing.KeyStroke;
75
import javax.swing.event.ChangeEvent;
76
import javax.swing.event.ChangeEvent;
76
import javax.swing.event.ChangeListener;
77
import javax.swing.event.ChangeListener;
Lines 130-135 Link Here
130
    private final PreferenceChangeListener editorSettingsListener = new PreferenceChangeListenerImpl();
131
    private final PreferenceChangeListener editorSettingsListener = new PreferenceChangeListenerImpl();
131
    private final PropertyChangeListener propListener;
132
    private final PropertyChangeListener propListener;
132
    private DelegateUndoRedo delegateUndoRedo;
133
    private DelegateUndoRedo delegateUndoRedo;
134
    private int splitOrientation = -1;
133
    
135
    
134
    MultiViewPeer(TopComponent pr, ActionRequestObserverFactory fact) {
136
    MultiViewPeer(TopComponent pr, ActionRequestObserverFactory fact) {
135
        selListener = new SelectionListener();
137
        selListener = new SelectionListener();
Lines 152-158 Link Here
152
        List<MultiViewDescription> arr = new ArrayList<MultiViewDescription>();
154
        List<MultiViewDescription> arr = new ArrayList<MultiViewDescription>();
153
        final Lookup lkp = MimeLookup.getLookup(mimeType);
155
        final Lookup lkp = MimeLookup.getLookup(mimeType);
154
        for (ContextAwareDescription d : lkp.lookupAll(ContextAwareDescription.class)) {
156
        for (ContextAwareDescription d : lkp.lookupAll(ContextAwareDescription.class)) {
155
            d = d.createContextAwareDescription(context.getLookup());
157
            d = d.createContextAwareDescription(context.getLookup(), false);
158
            arr.add(d);
159
            d = d.createContextAwareDescription(context.getLookup(), true);
156
            arr.add(d);
160
            arr.add(d);
157
        }
161
        }
158
        if (arr.isEmpty()) {
162
        if (arr.isEmpty()) {
Lines 187-200 Link Here
187
        closeHandler = handler;
191
        closeHandler = handler;
188
    }
192
    }
189
    
193
    
190
    void setDeserializedMultiViewDescriptions(MultiViewDescription[] descriptions, 
194
    void setDeserializedMultiViewDescriptions(int splitOrientation, MultiViewDescription[] descriptions,
191
                                                      MultiViewDescription defaultDesc, Map<MultiViewDescription, MultiViewElement> existingElements) {
195
       MultiViewDescription defaultDesc, MultiViewDescription defaultDescSplit, Map<MultiViewDescription, MultiViewElement> existingElements) {
192
        if (model != null) {
196
        if (model != null) {
193
            model.removeElementSelectionListener(selListener);
197
            model.removeElementSelectionListener(selListener);
194
        }
198
        }
199
	// if Design view was active before closing, set default to Source view
200
	defaultDesc = defaultDesc.getDisplayName().startsWith("&Design") ? descriptions[0] : defaultDesc; //NOI18N
201
	defaultDescSplit = defaultDescSplit.getDisplayName().startsWith("&Design") ? descriptions[1] : defaultDescSplit; //NOI18N
195
        model = new MultiViewModel(descriptions, defaultDesc, factory, existingElements);
202
        model = new MultiViewModel(descriptions, defaultDesc, factory, existingElements);
196
        model.addElementSelectionListener(selListener);
203
        model.addElementSelectionListener(selListener);
197
        tabs.setModel(model);
204
	tabs.setModel(model);
205
	this.splitOrientation = splitOrientation;
206
	if(splitOrientation != -1) {
207
	    tabs.peerSplitComponent(splitOrientation, this, defaultDesc, defaultDescSplit);
208
	}
198
    }
209
    }
199
    
210
    
200
    /**
211
    /**
Lines 257-262 Link Here
257
                }
268
                }
258
            });
269
            });
259
        }
270
        }
271
	if(peer instanceof MultiViewTopComponent || peer instanceof MultiViewCloneableTopComponent) {
272
            delegatingMap.put("splitWindowHorizantally", new javax.swing.AbstractAction() { // NOI18N
273
                @Override
274
                public void actionPerformed(ActionEvent evt) {
275
		    TopComponent split;
276
		    if(peer instanceof MultiViewTopComponent || peer instanceof MultiViewCloneableTopComponent) {
277
			split = ((MultiViewTopComponent) peer).splitComponent(JSplitPane.HORIZONTAL_SPLIT);
278
		    } else {
279
			split = ((MultiViewCloneableTopComponent) peer).splitComponent(JSplitPane.HORIZONTAL_SPLIT);
280
		    }
281
		    split.open();
282
		    split.requestActive();
283
                }
284
            });
285
            delegatingMap.put("splitWindowVertically", new javax.swing.AbstractAction() { // NOI18N
286
                @Override
287
                public void actionPerformed(ActionEvent evt) {
288
		    TopComponent split;
289
		    if(peer instanceof MultiViewTopComponent || peer instanceof MultiViewCloneableTopComponent) {
290
			split = ((MultiViewTopComponent) peer).splitComponent(JSplitPane.VERTICAL_SPLIT);
291
		    } else {
292
			split = ((MultiViewCloneableTopComponent) peer).splitComponent(JSplitPane.VERTICAL_SPLIT);
293
		    }
294
		    split.open();
295
		    split.requestActive();
296
                }
297
            });
298
            delegatingMap.put("clearSplit", new javax.swing.AbstractAction() { // NOI18N
299
		@Override
300
                public void actionPerformed(ActionEvent evt) {
301
		    TopComponent original;
302
		    if(peer instanceof MultiViewTopComponent || peer instanceof MultiViewCloneableTopComponent) {
303
			original = ((MultiViewTopComponent) peer).clearSplit();
304
		    } else {
305
			original = ((MultiViewCloneableTopComponent) peer).clearSplit();
306
		    }
307
		    original.open();
308
		    original.requestActive();
309
                }
310
            });
311
        }
260
        delegatingMap.put("closeWindow", new javax.swing.AbstractAction() { // NOI18N
312
        delegatingMap.put("closeWindow", new javax.swing.AbstractAction() { // NOI18N
261
           public void actionPerformed(ActionEvent evt) {
313
           public void actionPerformed(ActionEvent evt) {
262
               peer.close();
314
               peer.close();
Lines 283-289 Link Here
283
        JComponent jc = el.getToolbarRepresentation();
335
        JComponent jc = el.getToolbarRepresentation();
284
        assert jc != null : "MultiViewElement " + el.getClass() + " returns null as toolbar component."; //NOI18N
336
        assert jc != null : "MultiViewElement " + el.getClass() + " returns null as toolbar component."; //NOI18N
285
        jc.setOpaque(false);
337
        jc.setOpaque(false);
286
        tabs.setInnerToolBar(jc);
338
        tabs.setInnerToolBar(jc, ((ContextAwareDescription)model.getActiveDescription()).isSplitDescription());
287
        tabs.setToolbarBarVisible(isToolbarVisible());
339
        tabs.setToolbarBarVisible(isToolbarVisible());
288
        if (editorSettingsPreferences != null) {
340
        if (editorSettingsPreferences != null) {
289
            editorSettingsPreferences.addPreferenceChangeListener(editorSettingsListener);
341
            editorSettingsPreferences.addPreferenceChangeListener(editorSettingsListener);
Lines 315-320 Link Here
315
        showCurrentElement(true);
367
        showCurrentElement(true);
316
        tabs.setToolbarBarVisible(isToolbarVisible());
368
        tabs.setToolbarBarVisible(isToolbarVisible());
317
    }
369
    }
370
371
    void peerSplitComponent(int orientation) {
372
	splitOrientation = orientation;
373
	tabs.peerSplitComponent(orientation, this, null, null);
374
    }
375
376
    void peerClearSplit() {
377
	tabs.peerClearSplit();
378
	showCurrentElement();
379
	model.fireActivateCurrent();
380
	splitOrientation = -1;
381
    }
382
383
    int getSplitOrientation() {
384
	return splitOrientation;
385
    }
318
    
386
    
319
    boolean requestFocusInWindow() {
387
    boolean requestFocusInWindow() {
320
        // somehow this may be called when model is null
388
        // somehow this may be called when model is null
Lines 335-340 Link Here
335
     * hides the old element when switching elements.
403
     * hides the old element when switching elements.
336
     */
404
     */
337
    void hideElement(MultiViewDescription desc) {
405
    void hideElement(MultiViewDescription desc) {
406
	if (desc != null && splitOrientation != -1) {
407
	    MultiViewDescription topDesc = tabs.getTopComponentDescription();
408
	    MultiViewDescription bottomDesc = tabs.getBottomComponentDescription();
409
	    if (tabs.isHiddenTriggeredByMultiViewButton()
410
		    && (!topDesc.getDisplayName().equals(desc.getDisplayName())
411
		    || !bottomDesc.getDisplayName().equals(desc.getDisplayName()))) {
412
		MultiViewElement el = model.getElementForDescription(desc);
413
		el.componentHidden();
414
	    }
415
	    return;
416
	}
338
        if (desc != null) {
417
        if (desc != null) {
339
            MultiViewElement el = model.getElementForDescription(desc);
418
            MultiViewElement el = model.getElementForDescription(desc);
340
            el.componentHidden();
419
            el.componentHidden();
Lines 358-364 Link Here
358
        // also consider a usecase where multiple elements point to a single visual component.
437
        // also consider a usecase where multiple elements point to a single visual component.
359
        //. eg. property sheet uses same component and only changes model.
438
        //. eg. property sheet uses same component and only changes model.
360
        // in this case we probably should not remove and add the component from awt hierarchy
439
        // in this case we probably should not remove and add the component from awt hierarchy
361
        tabs.switchToCard(el, desc.getDisplayName());
440
        tabs.switchToCard(el, desc.getDisplayName(), ((ContextAwareDescription)desc).isSplitDescription());
362
        Image icon = desc.getIcon();
441
        Image icon = desc.getIcon();
363
        if( null == icon ) {
442
        if( null == icon ) {
364
            //#204072
443
            //#204072
Lines 389-395 Link Here
389
            assignLookup(el);
468
            assignLookup(el);
390
            
469
            
391
            if (peer.isVisible()) {
470
            if (peer.isVisible()) {
392
                tabs.setInnerToolBar(el.getToolbarRepresentation());
471
                tabs.setInnerToolBar(el.getToolbarRepresentation(), ((ContextAwareDescription)desc).isSplitDescription());
393
                tabs.setToolbarBarVisible(isToolbarVisible());
472
                tabs.setToolbarBarVisible(isToolbarVisible());
394
            }
473
            }
395
            
474
            
Lines 508-515 Link Here
508
            fromMime = false;
587
            fromMime = false;
509
        }
588
        }
510
        MultiViewDescription[] descs = model.getDescriptions();
589
        MultiViewDescription[] descs = model.getDescriptions();
511
        MultiViewDescription curr = model.getActiveDescription();
590
	MultiViewDescription curr = tabs.getTopComponentDescription();
591
	MultiViewDescription currSplit = tabs.getBottomComponentDescription();
512
        int currIndex = 0;
592
        int currIndex = 0;
593
        int currIndexSplit = 0;
594
513
        for (int i = 0; i < descs.length; i++) {
595
        for (int i = 0; i < descs.length; i++) {
514
            if (!fromMime) {
596
            if (!fromMime) {
515
                out.writeObject(descs[i]);
597
                out.writeObject(descs[i]);
Lines 526-533 Link Here
526
            if (descs[i] == curr) {
608
            if (descs[i] == curr) {
527
                currIndex = i;
609
                currIndex = i;
528
            }
610
            }
611
	    if (descs[i] == currSplit) {
612
                currIndexSplit = i;
613
            }
529
        }
614
        }
530
        out.writeObject(new Integer(currIndex));
615
        out.writeObject(new Integer(currIndex));
616
        out.writeObject(new Integer(currIndexSplit));
617
	out.writeObject(new Integer(splitOrientation));
531
        
618
        
532
    }
619
    }
533
620
Lines 539-547 Link Here
539
        ArrayList<MultiViewDescription> descList = new ArrayList<MultiViewDescription>();
626
        ArrayList<MultiViewDescription> descList = new ArrayList<MultiViewDescription>();
540
        HashMap<MultiViewDescription, MultiViewElement> map = new HashMap<MultiViewDescription, MultiViewElement>();
627
        HashMap<MultiViewDescription, MultiViewElement> map = new HashMap<MultiViewDescription, MultiViewElement>();
541
        int current = 0;
628
        int current = 0;
629
        int currentSplit = 0;
630
        int splitOrient = -1;
542
        CloseOperationHandler close = null;
631
        CloseOperationHandler close = null;
543
        try {
632
        try {
544
            int counting = 0;
633
            int counting = 0;
634
	    int intCounting = 0;
545
            MultiViewDescription lastDescription = null;
635
            MultiViewDescription lastDescription = null;
546
            while (true) {
636
            while (true) {
547
                Object obj = in.readObject();
637
                Object obj = in.readObject();
Lines 576-583 Link Here
576
                }
666
                }
577
                else if (obj instanceof Integer)  {
667
                else if (obj instanceof Integer)  {
578
                    Integer integ = (Integer)obj;
668
                    Integer integ = (Integer)obj;
579
                    current = integ.intValue();
669
		    if(intCounting == 0) {
580
                    break;
670
			intCounting++;
671
			current = integ.intValue();
672
		    } else if (intCounting == 1) {
673
			intCounting++;
674
			currentSplit = integ.intValue();
675
		    } else if (intCounting == 2) {
676
			splitOrient = integ.intValue();
677
			break;
678
		    }
581
                } 
679
                } 
582
                if (obj instanceof CloseOperationHandler) {
680
                if (obj instanceof CloseOperationHandler) {
583
                    close = (CloseOperationHandler)obj;
681
                    close = (CloseOperationHandler)obj;
Lines 597-606 Link Here
597
                descs = descList.toArray(descs);
695
                descs = descList.toArray(descs);
598
                //the integer with current element was not read yet, fallback to zero.
696
                //the integer with current element was not read yet, fallback to zero.
599
                MultiViewDescription currDesc = descs[0];
697
                MultiViewDescription currDesc = descs[0];
698
                MultiViewDescription currDescSplit = descs[1];
600
699
601
                //when error, ignore any deserialized elements..
700
                //when error, ignore any deserialized elements..
602
                map.clear();
701
                map.clear();
603
                setDeserializedMultiViewDescriptions(descs, currDesc, map);
702
                setDeserializedMultiViewDescriptions(1, descs, currDesc, currDescSplit, map);
604
            }
703
            }
605
            
704
            
606
            throw exc;
705
            throw exc;
Lines 616-622 Link Here
616
        MultiViewDescription[] descs = new MultiViewDescription[descList.size()];
715
        MultiViewDescription[] descs = new MultiViewDescription[descList.size()];
617
        descs = descList.toArray(descs);
716
        descs = descList.toArray(descs);
618
        MultiViewDescription currDesc = descs[current];
717
        MultiViewDescription currDesc = descs[current];
619
        setDeserializedMultiViewDescriptions(descs, currDesc, map);
718
        MultiViewDescription currDescSplit = descs[currentSplit];
719
        setDeserializedMultiViewDescriptions(splitOrient, descs, currDesc, currDescSplit, map);
620
    }    
720
    }    
621
721
622
    private Action[] getDefaultTCActions() {
722
    private Action[] getDefaultTCActions() {
(-)a/core.multiview/src/org/netbeans/core/multiview/MultiViewTopComponent.java (-3 / +22 lines)
Lines 101-107 Link Here
101
    
101
    
102
    private void setDeserializedMultiViewDescriptions(MultiViewDescription[] descriptions, 
102
    private void setDeserializedMultiViewDescriptions(MultiViewDescription[] descriptions, 
103
                                                      MultiViewDescription defaultDesc, Map existingElements) {
103
                                                      MultiViewDescription defaultDesc, Map existingElements) {
104
        peer.setDeserializedMultiViewDescriptions(descriptions, defaultDesc, existingElements);
104
        peer.setDeserializedMultiViewDescriptions(-1, descriptions, defaultDesc, null, existingElements);
105
    }
105
    }
106
    
106
    
107
    MultiViewModel getModel() {
107
    MultiViewModel getModel() {
Lines 161-169 Link Here
161
        //TEMP don't delegate to element's actions..
161
        //TEMP don't delegate to element's actions..
162
        Action[] superActions = superActions4Tests == null ? super.getActions() : superActions4Tests;
162
        Action[] superActions = superActions4Tests == null ? super.getActions() : superActions4Tests;
163
        Action[] acts = peer.peerGetActions(superActions);
163
        Action[] acts = peer.peerGetActions(superActions);
164
        Action[] myActions = new Action[acts.length + 2];
164
        Action[] myActions = new Action[acts.length + 3];
165
        System.arraycopy(acts, 0, myActions, 0, acts.length);
165
        System.arraycopy(acts, 0, myActions, 0, acts.length);
166
        myActions[acts.length + 1] = new EditorsAction();
166
        myActions[acts.length + 1] = new EditorsAction();
167
        myActions[acts.length + 2] = new SplitAction(true);
167
        return myActions;
168
        return myActions;
168
    }
169
    }
169
    
170
    
Lines 292-307 Link Here
292
        SubComponent[] res = new SubComponent[perspectives.length];
293
        SubComponent[] res = new SubComponent[perspectives.length];
293
        for( int i=0; i<perspectives.length; i++ ) {
294
        for( int i=0; i<perspectives.length; i++ ) {
294
            final MultiViewPerspective mvp = perspectives[i];
295
            final MultiViewPerspective mvp = perspectives[i];
296
	    MultiViewDescription descr = Accessor.DEFAULT.extractDescription(mvp);
297
	    Lookup lookup = descr == null ? peer.getLookup() :
298
		    model.getElementForDescription(descr, false) == null ? peer.getLookup() : model.getElementForDescription(descr, false).getLookup();
299
	    boolean showing = peer.tabs.isShowing(descr);
295
            res[i] = new SubComponent( Actions.cutAmpersand(mvp.getDisplayName()), new ActionListener() {
300
            res[i] = new SubComponent( Actions.cutAmpersand(mvp.getDisplayName()), new ActionListener() {
296
301
297
                @Override
302
                @Override
298
                public void actionPerformed( ActionEvent e ) {
303
                public void actionPerformed( ActionEvent e ) {
299
                    peer.getMultiViewHandlerDelegate().requestActive( mvp );
304
                    peer.getMultiViewHandlerDelegate().requestActive( mvp );
300
                }
305
                }
301
            }, mvp == model.getSelectedPerspective() );
306
            }, mvp == model.getSelectedPerspective(), lookup, showing );
302
        }
307
        }
303
        return res;
308
        return res;
304
    }
309
    }
310
311
    public TopComponent splitComponent(int orientation) {
312
	peer.peerSplitComponent(orientation);
313
	return this;
314
    }
315
316
    public TopComponent clearSplit() {
317
	peer.peerClearSplit();
318
	return this;
319
    }
320
321
    public int getSplitOrientation() {
322
	return peer.getSplitOrientation();
323
    }
305
    
324
    
306
//    public Lookup getLookup() {
325
//    public Lookup getLookup() {
307
//        return peer.getLookup(super.getLookup());
326
//        return peer.getLookup(super.getLookup());
(-)a/core.multiview/src/org/netbeans/core/multiview/SplitAction.java (+231 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.core.multiview;
43
44
import java.awt.event.ActionEvent;
45
import java.util.Map;
46
import javax.swing.AbstractAction;
47
import javax.swing.Action;
48
import javax.swing.JComponent;
49
import javax.swing.JMenu;
50
import javax.swing.JMenuItem;
51
import javax.swing.JSplitPane;
52
import javax.swing.SwingUtilities;
53
import org.openide.awt.DynamicMenuContent;
54
import org.openide.awt.Mnemonics;
55
import org.openide.util.NbBundle;
56
import org.openide.util.NbBundle.Messages;
57
import org.openide.util.actions.Presenter;
58
import org.openide.windows.TopComponent;
59
import org.openide.windows.WindowManager;
60
61
/**
62
 * Action to show in main menu to split document.
63
 *
64
 * @author Th. Oikonomou
65
 */
66
@Messages({"CTL_SplitDocumentAction=&Split Document", "CTL_SplitAction=&Split"})
67
public class SplitAction extends AbstractAction implements Presenter.Menu, Presenter.Popup {
68
69
    boolean useSplitName = false;
70
71
    public SplitAction() {
72
	super(Bundle.CTL_SplitDocumentAction());
73
    }
74
75
    public SplitAction(boolean useSplitName) {
76
	super(Bundle.CTL_SplitDocumentAction());
77
	this.useSplitName = useSplitName;
78
    }
79
80
    static Action createSplitAction(Map map) {
81
	Object nameObj = map.get("displayName"); //NOI18N
82
	if (nameObj == null) {
83
	    return null;
84
	}
85
	return new SplitAction(nameObj.toString().equals(Bundle.CTL_SplitAction()));
86
    }
87
88
    @Override
89
    public void actionPerformed(ActionEvent ev) {
90
	assert false;
91
    }
92
93
    @Override
94
    public JMenuItem getMenuPresenter() {
95
	JMenu menu = new SplitAction.UpdatingMenu();
96
	String label = useSplitName ? Bundle.CTL_SplitAction() : Bundle.CTL_SplitDocumentAction();
97
	Mnemonics.setLocalizedText(menu, label);
98
	return menu;
99
    }
100
101
    @Override
102
    public JMenuItem getPopupPresenter() {
103
	JMenu menu = new SplitAction.UpdatingMenu();
104
	String label = useSplitName ? Bundle.CTL_SplitAction() : Bundle.CTL_SplitDocumentAction();
105
	Mnemonics.setLocalizedText(menu, label);
106
	return menu;
107
    }
108
109
    private static final class UpdatingMenu extends JMenu implements DynamicMenuContent {
110
111
	@Override
112
	public JComponent[] synchMenuPresenters(JComponent[] items) {
113
	    return getMenuPresenters();
114
	}
115
116
	@Override
117
	public JComponent[] getMenuPresenters() {
118
	    assert SwingUtilities.isEventDispatchThread() : "Must be called from AWT";
119
	    removeAll();
120
	    final TopComponent tc = WindowManager.getDefault().getRegistry().getActivated();
121
	    if (tc != null) {
122
		setEnabled(true);
123
		if (tc instanceof MultiViewTopComponent || tc instanceof MultiViewCloneableTopComponent) {
124
		    JMenuItem item = new JMenuItem(new SplitDocumentAction(tc, JSplitPane.VERTICAL_SPLIT));
125
		    Mnemonics.setLocalizedText(item, item.getText());
126
		    add(item);
127
		    item = new JMenuItem(new SplitDocumentAction(tc, JSplitPane.HORIZONTAL_SPLIT));
128
		    Mnemonics.setLocalizedText(item, item.getText());
129
		    add(item);
130
		    item = new JMenuItem(new ClearSplitAction(tc));
131
		    Mnemonics.setLocalizedText(item, item.getText());
132
		    add(item);
133
		} else { // tc is not splitable
134
		    //No reason to enable action on any TC because now it was enabled even for Welcome page
135
		    setEnabled(false);
136
		    /*JRadioButtonMenuItem but = new JRadioButtonMenuItem();
137
		     Mnemonics.setLocalizedText(but, NbBundle.getMessage(EditorsAction.class, "EditorsAction.source"));
138
		     but.setSelected(true);
139
		     add(but);*/
140
		}
141
	    } else { // tc == null
142
		setEnabled(false);
143
	    }
144
	    return new JComponent[]{this};
145
	}
146
    }
147
148
    @NbBundle.Messages({"LBL_SplitDocumentActionVertical=&Vertically",
149
	"LBL_SplitDocumentActionHorizontal=&Horizontally",
150
	"LBL_ValueSplitVertical=splitVertically",
151
	"LBL_ValueSplitHorizontal=splitHorizontally"})
152
    private static class SplitDocumentAction extends AbstractAction {
153
154
	private final TopComponent tc;
155
	private final int orientation;
156
157
	public SplitDocumentAction(TopComponent tc, int orientation) {
158
	    this.tc = tc;
159
	    this.orientation = orientation;
160
	    putValue(Action.NAME, orientation == JSplitPane.VERTICAL_SPLIT ? Bundle.LBL_SplitDocumentActionVertical() : Bundle.LBL_SplitDocumentActionHorizontal());
161
	    //hack to insert extra actions into JDev's popup menu
162
	    putValue("_nb_action_id_", orientation == JSplitPane.VERTICAL_SPLIT ? Bundle.LBL_ValueSplitVertical() : Bundle.LBL_ValueSplitHorizontal()); //NOI18N
163
	    if (tc instanceof MultiViewTopComponent) {
164
		setEnabled(((MultiViewTopComponent) tc).getSplitOrientation() == -1
165
			|| ((MultiViewTopComponent) tc).getSplitOrientation() != orientation);
166
	    } else if (tc instanceof MultiViewCloneableTopComponent) {
167
		setEnabled(((MultiViewCloneableTopComponent) tc).getSplitOrientation() == -1
168
			|| ((MultiViewCloneableTopComponent) tc).getSplitOrientation() != orientation);
169
	    } else {
170
		setEnabled(false);
171
	    }
172
	}
173
174
	@Override
175
	public void actionPerformed(ActionEvent evt) {
176
	    splitWindow(tc, orientation);
177
	}
178
    }
179
180
    @NbBundle.Messages({"LBL_ClearSplitAction=&Clear",
181
	"LBL_ValueClearSplit=clearSplit"})
182
    private static class ClearSplitAction extends AbstractAction {
183
184
	private final TopComponent tc;
185
186
	public ClearSplitAction(TopComponent tc) {
187
	    this.tc = tc;
188
	    putValue(Action.NAME, Bundle.LBL_ClearSplitAction());
189
	    //hack to insert extra actions into JDev's popup menu
190
	    putValue("_nb_action_id_", Bundle.LBL_ValueClearSplit()); //NOI18N
191
	    if (tc instanceof MultiViewTopComponent) {
192
		setEnabled(((MultiViewTopComponent) tc).getSplitOrientation() != -1);
193
	    } else if (tc instanceof MultiViewCloneableTopComponent) {
194
		setEnabled(((MultiViewCloneableTopComponent) tc).getSplitOrientation() != -1);
195
	    } else {
196
		setEnabled(false);
197
	    }
198
	}
199
200
	@Override
201
	public void actionPerformed(ActionEvent evt) {
202
	    clearSplit(tc);
203
	}
204
    }
205
206
    static void splitWindow(TopComponent tc, int orientation) {
207
	if (tc instanceof MultiViewTopComponent || tc instanceof MultiViewCloneableTopComponent) {
208
	    TopComponent split;
209
	    if (tc instanceof MultiViewTopComponent) {
210
		split = ((MultiViewTopComponent) tc).splitComponent(orientation);
211
	    } else {
212
		split = ((MultiViewCloneableTopComponent) tc).splitComponent(orientation);
213
	    }
214
	    split.open();
215
	    split.requestActive();
216
	}
217
    }
218
219
    static void clearSplit(TopComponent tc) {
220
	if (tc instanceof MultiViewTopComponent || tc instanceof MultiViewCloneableTopComponent) {
221
	    TopComponent original;
222
	    if (tc instanceof MultiViewTopComponent) {
223
		original = ((MultiViewTopComponent) tc).clearSplit();
224
	    } else {
225
		original = ((MultiViewCloneableTopComponent) tc).clearSplit();
226
	    }
227
	    original.open();
228
	    original.requestActive();
229
	}
230
    }
231
}
(-)a/core.multiview/src/org/netbeans/core/multiview/TabsComponent.java (-17 / +447 lines)
Lines 46-51 Link Here
46
46
47
import java.awt.*;
47
import java.awt.*;
48
import java.awt.event.*;
48
import java.awt.event.*;
49
import java.beans.PropertyChangeEvent;
50
import java.beans.PropertyChangeListener;
49
import java.util.Enumeration;
51
import java.util.Enumeration;
50
import java.util.HashSet;
52
import java.util.HashSet;
51
import java.util.Set;
53
import java.util.Set;
Lines 72-81 Link Here
72
    MultiViewModel model;
74
    MultiViewModel model;
73
    private MouseListener buttonMouseListener = null;
75
    private MouseListener buttonMouseListener = null;
74
    private JComponent toolbarPanel;
76
    private JComponent toolbarPanel;
77
    private JComponent toolbarPanelSplit;
75
    JPanel componentPanel; /** package private for tests */
78
    JPanel componentPanel; /** package private for tests */
79
    JPanel componentPanelSplit; /** package private for tests */
76
    private CardLayout cardLayout;
80
    private CardLayout cardLayout;
81
    private CardLayout cardLayoutSplit;
77
    private Set<MultiViewElement> alreadyAddedElements;
82
    private Set<MultiViewElement> alreadyAddedElements;
83
    private Set<MultiViewElement> alreadyAddedElementsSplit;
78
    private JToolBar bar;
84
    private JToolBar bar;
85
    private JToolBar barSplit;
86
87
    private JSplitPane splitPane;
88
    private AWTEventListener awtEventListener;
89
    private boolean isTopLeft = true;
90
    private JPanel topLeftComponent;
91
    private JPanel bottomRightComponent;
92
    private Dimension barMinSize;
93
    private Dimension panelMinSizep;
94
    private MultiViewDescription[] topBottomDescriptions = null;
95
    private PropertyChangeListener splitterPropertyChangeListener;
96
    private boolean removeSplit = false;
97
    private MultiViewPeer mvPeer;
98
    private boolean hiddenTriggeredByMultiViewButton = false;
79
    
99
    
80
    private static final boolean AQUA = "Aqua".equals(UIManager.getLookAndFeel().getID()); //NOI18N
100
    private static final boolean AQUA = "Aqua".equals(UIManager.getLookAndFeel().getID()); //NOI18N
81
101
Lines 124-140 Link Here
124
        int prefHeight = -1;
144
        int prefHeight = -1;
125
        int prefWidth = -1;
145
        int prefWidth = -1;
126
        for (int i = 0; i < descs.length; i++) {
146
        for (int i = 0; i < descs.length; i++) {
127
            JToggleButton button = createButton(descs[i]);
147
	    if (descs[i] instanceof ContextAwareDescription && !((ContextAwareDescription)descs[i]).isSplitDescription()) {
128
            model.getButtonGroup().add(button);
148
		JToggleButton button = createButton(descs[i]);
129
            GridBagConstraints cons = new GridBagConstraints();
149
		model.getButtonGroup().add(button);
130
            cons.anchor = GridBagConstraints.WEST;
150
		GridBagConstraints cons = new GridBagConstraints();
131
            prefHeight = Math.max(button.getPreferredSize().height, prefHeight);
151
		cons.anchor = GridBagConstraints.WEST;
132
            bar.add(button, cons);
152
		prefHeight = Math.max(button.getPreferredSize().height, prefHeight);
133
            prefWidth = Math.max(button.getPreferredSize().width, prefWidth);
153
		bar.add(button, cons);
134
            if (descs[i] == model.getActiveDescription()) {
154
		prefWidth = Math.max(button.getPreferredSize().width, prefWidth);
135
                active = button;
155
		if (descs[i] == model.getActiveDescription()) {
136
                
156
		    active = button;
137
            }
157
		}
158
	    }
138
        }
159
        }
139
        Enumeration en = model.getButtonGroup().getElements();
160
        Enumeration en = model.getButtonGroup().getElements();
140
        while (en.hasMoreElements()) {
161
        while (en.hasMoreElements()) {
Lines 158-164 Link Here
158
    }
179
    }
159
180
160
    
181
    
161
    void switchToCard(MultiViewElement elem, String id) {
182
    MultiViewDescription getTopComponentDescription() {
183
	return topBottomDescriptions == null ? model.getActiveDescription() : topBottomDescriptions[0];
184
    }
185
186
    MultiViewDescription getBottomComponentDescription() {
187
	return topBottomDescriptions == null ? model.getActiveDescription() : topBottomDescriptions[1];
188
    }
189
190
    void peerClearSplit() {
191
	MultiViewDescription activeDescription = topBottomDescriptions[0];
192
	Toolkit.getDefaultToolkit().removeAWTEventListener(getAWTEventListener());
193
	splitPane.removePropertyChangeListener(splitterPropertyChangeListener);
194
	removeAll();
195
	splitPane = null;
196
	topBottomDescriptions = null;
197
	isTopLeft = true;
198
	topLeftComponent = null;
199
	bottomRightComponent = null;
200
	alreadyAddedElementsSplit = null;
201
	awtEventListener = null;
202
	barSplit = null;
203
	cardLayoutSplit = null;
204
	componentPanelSplit = null;
205
	toolbarPanelSplit = null;
206
	splitterPropertyChangeListener = null;
207
	mvPeer = null;
208
	
209
	add(bar, BorderLayout.NORTH);
210
        add(componentPanel, BorderLayout.CENTER);
211
	model.setActiveDescription(activeDescription);
212
    }
213
214
    private void setupSplit() {
215
	topLeftComponent = new JPanel(new BorderLayout());
216
	barMinSize = bar.getMinimumSize();
217
	panelMinSizep = componentPanel.getMinimumSize();
218
	topLeftComponent.add(bar, BorderLayout.NORTH);
219
        topLeftComponent.add(componentPanel, BorderLayout.CENTER);
220
221
	bottomRightComponent = new JPanel();
222
	barSplit = new JToolBar();
223
        Border b = (Border)UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N
224
        barSplit.setBorder(b);
225
        barSplit.setFloatable(false);
226
        barSplit.setFocusable(true);
227
        if( "Windows".equals( UIManager.getLookAndFeel().getID())
228
                && !isXPTheme()) {
229
            barSplit.setRollover(true);
230
        } else if( AQUA ) {
231
            barSplit.setBackground(UIManager.getColor("NbExplorerView.background"));
232
        }
233
234
        bottomRightComponent.setLayout(new BorderLayout());
235
        bottomRightComponent.add(barSplit, BorderLayout.NORTH);
236
        startTogglingSplit();
237
        setToolbarBarVisibleSplit(bar.isVisible());
238
239
        componentPanelSplit = new JPanel();
240
        cardLayoutSplit = new CardLayout();
241
        componentPanelSplit.setLayout(cardLayoutSplit);
242
        bottomRightComponent.add(componentPanelSplit, BorderLayout.CENTER);
243
        alreadyAddedElementsSplit = new HashSet<MultiViewElement>();
244
245
        MultiViewDescription[] descs = model.getDescriptions();
246
        MultiViewDescription def = model.getActiveDescription();
247
        GridBagLayout grid = new GridBagLayout();
248
        barSplit.setLayout(grid);
249
	JToggleButton activeSplit = null;
250
        int prefHeight = -1;
251
        int prefWidth = -1;
252
        for (int i = 0; i < descs.length; i++) {
253
	    if (descs[i] instanceof ContextAwareDescription && ((ContextAwareDescription)descs[i]).isSplitDescription()) {
254
		JToggleButton button = createButton(descs[i]);
255
		model.getButtonGroupSplit().add(button);
256
		GridBagConstraints cons = new GridBagConstraints();
257
		cons.anchor = GridBagConstraints.WEST;
258
		prefHeight = Math.max(button.getPreferredSize().height, prefHeight);
259
		barSplit.add(button, cons);
260
		prefWidth = Math.max(button.getPreferredSize().width, prefWidth);
261
		if (descs[i].getDisplayName().startsWith(def.getDisplayName())) {
262
		    activeSplit = button;
263
		}
264
	    }
265
        }
266
        Enumeration en = model.getButtonGroupSplit().getElements();
267
        while (en.hasMoreElements()) {
268
            JToggleButton but = (JToggleButton)en.nextElement();
269
            Insets ins = but.getBorder().getBorderInsets(but);
270
            but.setPreferredSize(new Dimension(prefWidth + 10, prefHeight));
271
            but.setMinimumSize(new Dimension(prefWidth + 10, prefHeight));
272
273
        }
274
        if (activeSplit != null) {
275
            activeSplit.setSelected(true);
276
        }
277
278
        toolbarPanelSplit = getEmptyInnerToolBar();
279
        GridBagConstraints cons = new GridBagConstraints();
280
        cons.anchor = GridBagConstraints.EAST;
281
        cons.fill = GridBagConstraints.BOTH;
282
        cons.gridwidth = GridBagConstraints.REMAINDER;
283
        cons.weightx = 1;
284
285
        barSplit.add(toolbarPanelSplit, cons);
286
    }
287
288
    void peerSplitComponent(int orientation, MultiViewPeer mvPeer, MultiViewDescription defaultDesc, MultiViewDescription defaultDescClone) {
289
	MultiViewDescription[] descriptions = model.getDescriptions();
290
	this.mvPeer = mvPeer;
291
292
	MultiViewDescription activeDescription = model.getActiveDescription();
293
	if (splitPane == null) {
294
	    splitPane = new JSplitPane();
295
	    topBottomDescriptions = new MultiViewDescription[2];
296
	    if (defaultDesc != null && defaultDescClone != null) {// called during deserialization
297
		topBottomDescriptions[0] = defaultDesc;
298
		topBottomDescriptions[1] = defaultDescClone;
299
	    } else {
300
		int activeDescIndex = 0;
301
		for (int i = 0; i < descriptions.length; i++) {
302
		    MultiViewDescription multiViewDescription = descriptions[i];
303
		    if (multiViewDescription.getDisplayName().equals(activeDescription.getDisplayName())) {
304
			activeDescIndex = i;
305
			break;
306
		    }
307
		}
308
		topBottomDescriptions[0] = descriptions[activeDescIndex];
309
		topBottomDescriptions[1] = descriptions[activeDescIndex + 1];
310
	    }
311
	    
312
	    setupSplit();
313
	    splitPane.setOneTouchExpandable(true);
314
	    splitPane.setContinuousLayout(true);
315
	    splitPane.setResizeWeight(0.5);
316
317
	    removeAll();
318
	    Toolkit.getDefaultToolkit().addAWTEventListener(getAWTEventListener(), MouseEvent.MOUSE_EVENT_MASK | MouseEvent.MOUSE_MOTION_EVENT_MASK);
319
	    add(splitPane, BorderLayout.CENTER);
320
321
322
	    MultiViewDescription bottomDescription = topBottomDescriptions[1];
323
	    isTopLeft = false;
324
	    model.setActiveDescription(bottomDescription);
325
	    if (defaultDesc != null && defaultDescClone != null) {// called during deserialization
326
		selecteAppropriateButton();
327
	    }
328
329
	    MultiViewDescription topDescription = topBottomDescriptions[0];
330
	    isTopLeft = true;
331
	    model.setActiveDescription(topDescription);
332
	    if (defaultDesc != null && defaultDescClone != null) {// called during deserialization
333
		selecteAppropriateButton();
334
	    }
335
	} else {
336
	    topLeftComponent = (JPanel) splitPane.getTopComponent();
337
	    bottomRightComponent = (JPanel) splitPane.getBottomComponent();
338
	}
339
	if(orientation != splitPane.getOrientation()) {
340
	    splitPane.removePropertyChangeListener(splitterPropertyChangeListener);
341
	    splitterPropertyChangeListener = null;
342
	}
343
	splitPane.setOrientation(orientation);
344
	splitPane.setTopComponent(topLeftComponent);
345
	splitPane.setBottomComponent(bottomRightComponent);
346
	splitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, getSplitterPropertyChangeListener(orientation));
347
	topLeftComponent.setMinimumSize(new Dimension(0, 0));
348
	bottomRightComponent.setMinimumSize(new Dimension(0, 0));
349
    }
350
351
    private void selecteAppropriateButton() {
352
	Enumeration en = model.getButtonGroupSplit().getElements();
353
	while (en.hasMoreElements()) {
354
	    JToggleButton but = (JToggleButton) en.nextElement();
355
	    MultiViewDescription buttonsDescription = ((TabsButtonModel) but.getModel()).getButtonsDescription();
356
	    if (buttonsDescription == (isTopLeft ? topBottomDescriptions[0] : topBottomDescriptions[1])) {
357
		but.setSelected(true);
358
	    }
359
	}
360
    }
361
362
    private PropertyChangeListener getSplitterPropertyChangeListener(final int orientation) {
363
	if (splitterPropertyChangeListener == null) {
364
	    splitterPropertyChangeListener = new PropertyChangeListener() {
365
		@Override
366
		public void propertyChange(PropertyChangeEvent pce) {
367
		    if (splitPane != null) {
368
			int current = Integer.parseInt(pce.getNewValue().toString());
369
			int dividerSize = splitPane.getDividerSize();
370
			int splitSize;
371
			int topMinSize;
372
			int bottomMinSize;
373
			if (orientation == JSplitPane.VERTICAL_SPLIT) {
374
			    splitSize = splitPane.getHeight();
375
			    topMinSize = (int) topLeftComponent.getMinimumSize().getHeight();
376
			    bottomMinSize = (int) bottomRightComponent.getMinimumSize().getHeight();
377
			} else {
378
			    splitSize = splitPane.getWidth();
379
			    topMinSize = (int) topLeftComponent.getMinimumSize().getWidth();
380
			    bottomMinSize = (int) bottomRightComponent.getMinimumSize().getWidth();
381
			}
382
			int min = topMinSize;
383
			int max = splitSize - bottomMinSize - dividerSize;
384
			if (current <= min || current >= max) {
385
			    removeSplit = true;
386
			} else {
387
			    removeSplit = false;
388
			}
389
		    }
390
		}
391
	    };
392
	}
393
	return splitterPropertyChangeListener;
394
    }
395
396
397
    @NbBundle.Messages({"LBL_ClearAllSplitsDialogMessage=Do you really want to clear the split?",
398
	"LBL_ClearAllSplitsDialogTitle=Clear Split"})
399
    private AWTEventListener getAWTEventListener() {
400
	if (awtEventListener == null) {
401
	    awtEventListener = new AWTEventListener() {
402
                @Override
403
                public void eventDispatched(AWTEvent event) {
404
                    MouseEvent e = (MouseEvent) event;
405
		    if (splitPane != null && e.getID() == MouseEvent.MOUSE_PRESSED) {
406
			MultiViewDescription activeDescription = null;
407
			Point locationOnScreen = e.getLocationOnScreen();
408
			SwingUtilities.convertPointFromScreen(locationOnScreen, splitPane);
409
			Component component = e.getComponent();
410
			while(component != null && component != splitPane) {
411
			    component = component.getParent();
412
			}
413
			if (component == splitPane && splitPane.getTopComponent().getBounds().contains(locationOnScreen)) {
414
			    isTopLeft = true;
415
			    activeDescription = topBottomDescriptions[0];
416
			} else if (component == splitPane && splitPane.getBottomComponent().getBounds().contains(locationOnScreen)) {
417
			    isTopLeft = false;
418
			    activeDescription = topBottomDescriptions[1];
419
			}
420
			if (activeDescription != null) {
421
			    if (!model.getActiveDescription().equals(activeDescription) ||
422
				    ((ContextAwareDescription)model.getActiveDescription()).isSplitDescription() != ((ContextAwareDescription)activeDescription).isSplitDescription()) {
423
				model.setActiveDescription(activeDescription);
424
			    }
425
			}
426
		    } else if (splitPane != null && e.getID() == MouseEvent.MOUSE_RELEASED) {
427
			if (removeSplit) {
428
			    if (e.getClickCount() != 0) {
429
				return;
430
			    }
431
			    if (mvPeer != null) {
432
				mvPeer.peerClearSplit();
433
				bar.setMinimumSize(barMinSize);
434
				componentPanel.setMinimumSize(panelMinSizep);
435
			    }
436
			    removeSplit = false;
437
			}
438
		    }
439
                }
440
            };
441
        }
442
        return awtEventListener;
443
    }
444
445
    private void changeSplitOrientation(int orientation) {
446
	splitPane.removePropertyChangeListener(splitterPropertyChangeListener);
447
	splitterPropertyChangeListener = null;
448
	splitPane.setOrientation(orientation);
449
	splitPane.setDividerLocation(0.5);
450
	splitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, getSplitterPropertyChangeListener(orientation));
451
    }
452
453
    boolean isHiddenTriggeredByMultiViewButton() {
454
	return hiddenTriggeredByMultiViewButton;
455
    }
456
457
    boolean isShowing(MultiViewDescription descr) {
458
	if(descr == null) {
459
	    return false;
460
	}
461
	if(splitPane == null) {
462
	    return model.getActiveDescription() == descr;
463
	}
464
	return isTopLeft ? topBottomDescriptions[1] == descr : topBottomDescriptions[0] == descr;
465
    }
466
467
    void switchToCard(MultiViewElement elem, String id, boolean isSplitElement) {
468
	if (isSplitElement) {
469
	    switchToCardSplit(elem, id);
470
	    return;
471
	}
162
        if (! alreadyAddedElements.contains(elem)) {
472
        if (! alreadyAddedElements.contains(elem)) {
163
            componentPanel.add(elem.getVisualRepresentation(), id);
473
            componentPanel.add(elem.getVisualRepresentation(), id);
164
            alreadyAddedElements.add(elem);
474
            alreadyAddedElements.add(elem);
Lines 166-171 Link Here
166
        cardLayout.show(componentPanel, id);
476
        cardLayout.show(componentPanel, id);
167
    }
477
    }
168
478
479
    private void switchToCardSplit(MultiViewElement elem, String id) {
480
	if (!alreadyAddedElementsSplit.contains(elem)) {
481
	    componentPanelSplit.add(elem.getVisualRepresentation(), id);
482
	    alreadyAddedElementsSplit.add(elem);
483
	}
484
	cardLayoutSplit.show(componentPanelSplit, id);
485
    }
486
169
    /** Part of 130919 fix - don't hold visual representations after close */
487
    /** Part of 130919 fix - don't hold visual representations after close */
170
    void peerComponentClosed() {
488
    void peerComponentClosed() {
171
        if (componentPanel != null) {
489
        if (componentPanel != null) {
Lines 174-192 Link Here
174
        if (alreadyAddedElements != null) {
492
        if (alreadyAddedElements != null) {
175
            alreadyAddedElements.clear();
493
            alreadyAddedElements.clear();
176
        }
494
        }
495
        if (componentPanelSplit != null) {
496
            componentPanelSplit.removeAll();
497
        }
498
        if (alreadyAddedElementsSplit != null) {
499
            alreadyAddedElementsSplit.clear();
500
        }
177
    }
501
    }
178
    
502
    
179
    void changeActiveManually(MultiViewDescription desc) {
503
    void changeActiveManually(MultiViewDescription desc) {
180
        Enumeration en = model.getButtonGroup().getElements();
504
        Enumeration en = model.getButtonGroup().getElements();
505
	MultiViewDescription activeDescription = model.getActiveDescription();
506
	if (((ContextAwareDescription) activeDescription).isSplitDescription()) {
507
	    en = model.getButtonGroupSplit().getElements();
508
	}
181
        while (en.hasMoreElements()) {
509
        while (en.hasMoreElements()) {
182
            JToggleButton obj = (JToggleButton)en.nextElement();
510
            JToggleButton obj = (JToggleButton)en.nextElement();
183
            
511
            
184
            if (obj.getModel() instanceof TabsComponent.TabsButtonModel) {
512
            if (obj.getModel() instanceof TabsComponent.TabsButtonModel) {
185
                TabsButtonModel btnmodel = (TabsButtonModel)obj.getModel();
513
                TabsButtonModel btnmodel = (TabsButtonModel)obj.getModel();
186
                if (btnmodel.getButtonsDescription().equals(desc)) {
514
                if (btnmodel.getButtonsDescription().getDisplayName().equals(desc.getDisplayName())) {
187
                    obj.setSelected(true);
515
		    if (splitPane != null) {
188
                    MultiViewElement elem = model.getElementForDescription(desc);
516
			TabsComponent.this.hiddenTriggeredByMultiViewButton = true;
189
                    elem.getVisualRepresentation().requestFocus();
517
			if (((ContextAwareDescription) activeDescription).isSplitDescription()) {
518
			    model.getButtonGroupSplit().setSelected(obj.getModel(), true);
519
			    TabsComponent.this.isTopLeft = false;
520
			    TabsComponent.this.topBottomDescriptions[1] = btnmodel.getButtonsDescription();
521
			} else {
522
			    model.getButtonGroup().setSelected(obj.getModel(), true);
523
			    TabsComponent.this.isTopLeft = true;
524
			    TabsComponent.this.topBottomDescriptions[0] = btnmodel.getButtonsDescription();
525
			}
526
			model.fireActivateCurrent();
527
			TabsComponent.this.hiddenTriggeredByMultiViewButton = false;
528
		    } else {
529
			obj.setSelected(true);
530
			MultiViewElement elem = model.getElementForDescription(desc);
531
			elem.getVisualRepresentation().requestFocus();
532
		    }
190
                    break;
533
                    break;
191
                }
534
                }
192
            }
535
            }
Lines 195-200 Link Here
195
538
196
    void changeVisibleManually(MultiViewDescription desc) {
539
    void changeVisibleManually(MultiViewDescription desc) {
197
        Enumeration en = model.getButtonGroup().getElements();
540
        Enumeration en = model.getButtonGroup().getElements();
541
	if (((ContextAwareDescription) model.getActiveDescription()).isSplitDescription()) {
542
	    en = model.getButtonGroupSplit().getElements();
543
	    desc = model.getActiveDescription();
544
	}
198
        while (en.hasMoreElements()) {
545
        while (en.hasMoreElements()) {
199
            JToggleButton obj = (JToggleButton)en.nextElement();
546
            JToggleButton obj = (JToggleButton)en.nextElement();
200
            
547
            
Lines 232-238 Link Here
232
        return button;
579
        return button;
233
    }
580
    }
234
581
235
    void setInnerToolBar(JComponent innerbar) {
582
    void setInnerToolBar(JComponent innerbar, boolean isSplitElement) {
583
	if (isSplitElement) {
584
	    setInnerToolBarSplit(innerbar);
585
	    return;
586
	}
236
        synchronized (getTreeLock()) {
587
        synchronized (getTreeLock()) {
237
            if (toolbarPanel != null) {
588
            if (toolbarPanel != null) {
238
                bar.remove(toolbarPanel);
589
                bar.remove(toolbarPanel);
Lines 264-269 Link Here
264
            bar.repaint();
615
            bar.repaint();
265
        }
616
        }
266
    }
617
    }
618
619
    private void setInnerToolBarSplit(JComponent innerbar) {
620
        synchronized (getTreeLock()) {
621
            if (toolbarPanelSplit != null) {
622
                barSplit.remove(toolbarPanelSplit);
623
            }
624
            if (innerbar == null) {
625
                innerbar = getEmptyInnerToolBar();
626
            }
627
            innerbar.putClientProperty(TOOLBAR_MARKER, "X"); //NOI18N
628
            // need to set it to null, because CloneableEditor set's the border for the editor bar part only..
629
            if (!AQUA) {
630
                innerbar.setBorder(null);
631
            } else {
632
                innerbar.setBorder (BorderFactory.createEmptyBorder(2, 0, 2, 0));
633
            }
634
            toolbarPanelSplit = innerbar;
635
            GridBagConstraints cons = new GridBagConstraints();
636
            cons.anchor = GridBagConstraints.EAST;
637
            cons.fill = GridBagConstraints.BOTH;
638
            cons.gridwidth = GridBagConstraints.REMAINDER;
639
            cons.weightx = 1;
640
            toolbarPanelSplit.setMinimumSize(new Dimension(10, 10));
641
//            cons.gridwidth = GridBagConstraints.REMAINDER;
642
643
            barSplit.add(toolbarPanelSplit, cons);
644
645
            // rootcycle is the tabscomponent..
646
//            toolbarPanel.setFocusCycleRoot(false);
647
            barSplit.revalidate();
648
            barSplit.repaint();
649
        }
650
    }
267
    
651
    
268
    void setToolbarBarVisible(boolean visible) {
652
    void setToolbarBarVisible(boolean visible) {
269
        if (toolbarVisible == visible) {
653
        if (toolbarVisible == visible) {
Lines 272-277 Link Here
272
        toolbarVisible = visible;
656
        toolbarVisible = visible;
273
        bar.setVisible(visible);
657
        bar.setVisible(visible);
274
    }
658
    }
659
660
    void setToolbarBarVisibleSplit(boolean visible) {
661
        if (toolbarVisible == visible) {
662
            return;
663
        }
664
        toolbarVisible = visible;
665
        barSplit.setVisible(visible);
666
    }
275
    
667
    
276
    
668
    
277
    
669
    
Lines 338-343 Link Here
338
        input.put(stroke, "TogglesGoDown");//NOI18N
730
        input.put(stroke, "TogglesGoDown");//NOI18N
339
    }
731
    }
340
732
733
    void startTogglingSplit() {
734
        ActionMap map = barSplit.getActionMap();
735
        Action act = new TogglesGoEastAction();
736
        // JToolbar action name
737
        map.put("navigateRight", act);//NOI18N
738
        InputMap input = barSplit.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
739
740
        act = new TogglesGoWestAction();
741
        // JToolbar action name
742
        map.put("navigateLeft", act);//NOI18N
743
744
        act = new TogglesGoDownAction();
745
        map.put("TogglesGoDown", act);//NOI18N
746
        // JToolbar action name
747
        map.put("navigateUp", act);//NOI18N
748
        KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE"); //NOI18N
749
        input.put(stroke, "TogglesGoDown");//NOI18N
750
    }
751
341
    
752
    
342
    private class TogglesGoWestAction extends AbstractAction {
753
    private class TogglesGoWestAction extends AbstractAction {
343
        
754
        
Lines 421-426 Link Here
421
            AbstractButton b = (AbstractButton)e.getComponent();
832
            AbstractButton b = (AbstractButton)e.getComponent();
422
            MultiViewModel model = TabsComponent.this.model;
833
            MultiViewModel model = TabsComponent.this.model;
423
            if (model != null) {
834
            if (model != null) {
835
		if (TabsComponent.this.splitPane != null) {
836
		    ButtonModel buttonModel = b.getModel();
837
		    if (buttonModel instanceof TabsButtonModel) {
838
			MultiViewDescription buttonsDescription = ((TabsButtonModel) buttonModel).getButtonsDescription();
839
			TabsComponent.this.hiddenTriggeredByMultiViewButton = true;
840
			if(((ContextAwareDescription)buttonsDescription).isSplitDescription()) {
841
			    model.getButtonGroupSplit().setSelected(b.getModel(), true);
842
			    TabsComponent.this.isTopLeft = false;
843
			    TabsComponent.this.topBottomDescriptions[1] = buttonsDescription;
844
			} else {
845
			    model.getButtonGroup().setSelected(b.getModel(), true);
846
			    TabsComponent.this.isTopLeft = true;
847
			    TabsComponent.this.topBottomDescriptions[0] = buttonsDescription;
848
			}
849
			model.fireActivateCurrent();
850
			TabsComponent.this.hiddenTriggeredByMultiViewButton = false;
851
		    }
852
		    return;
853
		}
424
                model.getButtonGroup().setSelected(b.getModel(), true);
854
                model.getButtonGroup().setSelected(b.getModel(), true);
425
                model.fireActivateCurrent();
855
                model.fireActivateCurrent();
426
            }
856
            }
(-)a/core.multiview/src/org/netbeans/core/multiview/resources/mf-layer.xml (-1 / +17 lines)
Lines 43-49 Link Here
43
Version 2 license, then the option applies only if the new code is
43
Version 2 license, then the option applies only if the new code is
44
made subject to such option by the copyright holder.
44
made subject to such option by the copyright holder.
45
-->
45
-->
46
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
46
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
47
<filesystem>
47
<filesystem>
48
    <folder name="Menu">
48
    <folder name="Menu">
49
        <folder name="View">
49
        <folder name="View">
Lines 51-57 Link Here
51
                <attr name="position" intvalue="100"/>
51
                <attr name="position" intvalue="100"/>
52
                <attr name="misplaced.action.allowed" boolvalue="true"/>
52
                <attr name="misplaced.action.allowed" boolvalue="true"/>
53
            </file>
53
            </file>
54
            <file name="org-netbeans-core-multiview-SplitAction.instance">
55
                <!--org.netbeans.core.multiview.SplitAction-->
56
                <attr bundlevalue="org.netbeans.core.multiview.Bundle#CTL_SplitAction" name="displayName"/>
57
                <attr name="instanceCreate" methodvalue="org.netbeans.core.multiview.SplitAction.createSplitAction"/>
58
                <attr intvalue="150" name="position"/>
59
            </file>
60
        </folder>
61
        <folder name="Window">
62
            <folder name="ConfigureWindow">
63
		<file name="org-netbeans-core-multiview-SplitAction.instance">
64
		    <!--org.netbeans.core.multiview.SplitAction-->
65
		    <attr bundlevalue="org.netbeans.core.multiview.Bundle#CTL_SplitDocumentAction" name="displayName"/>
66
		    <attr name="instanceCreate" methodvalue="org.netbeans.core.multiview.SplitAction.createSplitAction"/>
67
                    <attr intvalue="950" name="position"/>
68
		</file>
54
            </folder>
69
            </folder>
70
        </folder>
55
    </folder>
71
    </folder>
56
    <!--    folder name="Actions">
72
    <!--    folder name="Actions">
57
        <folder name="Window">
73
        <folder name="Window">
(-)a/core.multiview/src/org/netbeans/core/spi/multiview/MultiViewFactory.java (-5 / +12 lines)
Lines 202-208 Link Here
202
    }
202
    }
203
    
203
    
204
    static MultiViewDescription createMultiViewDescription(Map map) {
204
    static MultiViewDescription createMultiViewDescription(Map map) {
205
        return new MapMVD(map, null);
205
        return new MapMVD(map, null, false);
206
    }
206
    }
207
    
207
    
208
    private static final class Blank implements MultiViewElement, Serializable {
208
    private static final class Blank implements MultiViewElement, Serializable {
Lines 368-376 Link Here
368
    MultiViewDescription, ContextAwareDescription , SourceCheckDescription {
368
    MultiViewDescription, ContextAwareDescription , SourceCheckDescription {
369
        private final Map map;
369
        private final Map map;
370
        private final Lookup context;
370
        private final Lookup context;
371
        public MapMVD(Map map, Lookup context) {
371
	private boolean isSplitDescription;
372
        public MapMVD(Map map, Lookup context, boolean isSplitDescription) {
372
            this.map = map;
373
            this.map = map;
373
            this.context = context;
374
            this.context = context;
375
	    this.isSplitDescription = isSplitDescription;
374
        }
376
        }
375
        
377
        
376
        private <T> T get(String attr, Class<T> type) {
378
        private <T> T get(String attr, Class<T> type) {
Lines 461-473 Link Here
461
        }
463
        }
462
464
463
        @Override
465
        @Override
464
        public ContextAwareDescription createContextAwareDescription(Lookup context) {
466
	public ContextAwareDescription createContextAwareDescription(Lookup context, boolean isSplitDescription) {
465
            return new MapMVD(map, context);
467
	    return new MapMVD(map, context, isSplitDescription);
466
        }
468
	}
467
469
468
        @Override
470
        @Override
469
        public boolean isSourceView() {
471
        public boolean isSourceView() {
470
            return Boolean.TRUE.equals(map.get("sourceview")); // NOI18N
472
            return Boolean.TRUE.equals(map.get("sourceview")); // NOI18N
471
        }
473
        }
474
475
	@Override
476
	public boolean isSplitDescription() {
477
	    return isSplitDescription;
478
	}
472
    }
479
    }
473
}
480
}
(-)a/openide.windows/apichanges.xml (+14 lines)
Lines 50-55 Link Here
50
<apidef name="winsys">Window System API</apidef>
50
<apidef name="winsys">Window System API</apidef>
51
</apidefs>
51
</apidefs>
52
<changes>
52
<changes>
53
<change id="topcomponent.SubComponent_lookup_and_showing">
54
    <api name="winsys"/>
55
    <summary>Added methods getLookup() and isShowing() in TopComponent.SubComponent.</summary>
56
    <version major="6" minor="63"/>
57
    <date day="19" month="4" year="2013"/>
58
    <author login="theofanis"/>
59
    <compatibility addition="yes" source="compatible" semantic="compatible" deprecation="no" deletion="no" modification="no"/>
60
    <description>
61
        <p>The new methods can be used in cunjunction with split multiview window, where e.g. the pallette
62
	    needs to know which two of the available subcomponents are showing and query their lookup.</p>
63
    </description>
64
    <class package="org.openide.windows" name="TopComponent"/>
65
    <issue number="228448"/>
66
</change>
53
<change id="stop_request_attention">
67
<change id="stop_request_attention">
54
    <api name="winsys"/>
68
    <api name="winsys"/>
55
    <summary>Allow TopComponent's header to be permanently highlighted to draw user's attention.
69
    <summary>Allow TopComponent's header to be permanently highlighted to draw user's attention.
(-)a/openide.windows/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.windows
2
OpenIDE-Module: org.openide.windows
3
OpenIDE-Module-Specification-Version: 6.62
3
OpenIDE-Module-Specification-Version: 6.63
4
OpenIDE-Module-Localizing-Bundle: org/openide/windows/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/openide/windows/Bundle.properties
5
AutoUpdate-Essential-Module: true
5
AutoUpdate-Essential-Module: true
6
6
(-)a/openide.windows/src/org/openide/windows/TopComponent.java (-3 / +24 lines)
Lines 1589-1594 Link Here
1589
        private final String description;
1589
        private final String description;
1590
        private final boolean active;
1590
        private final boolean active;
1591
        private final ActionListener activator;
1591
        private final ActionListener activator;
1592
        private final Lookup lookup;
1593
        private final boolean showing;
1592
1594
1593
        /**
1595
        /**
1594
         * C'tor
1596
         * C'tor
Lines 1597-1605 Link Here
1597
         * to be actived.
1599
         * to be actived.
1598
         * @param active True if the given sub-component is currently active,
1600
         * @param active True if the given sub-component is currently active,
1599
         * e.g. multiview sub-tab is selected.
1601
         * e.g. multiview sub-tab is selected.
1602
         * @param lookup the lookup of the given sub-component
1603
         * @param showing True if the given sub-component is currently showing,
1604
         * e.g. multiview sub-tab is selected or part of a split.
1600
         */
1605
         */
1601
        public SubComponent( String displayName, ActionListener activator, boolean active ) {
1606
        public SubComponent( String displayName, ActionListener activator, boolean active, Lookup lookup, boolean showing ) {
1602
            this( displayName, null, activator, active );
1607
            this( displayName, null, activator, active, lookup, showing );
1603
        }
1608
        }
1604
1609
1605
        /**
1610
        /**
Lines 1610-1623 Link Here
1610
         * to be actived.
1615
         * to be actived.
1611
         * @param active True if the given sub-component is currently active,
1616
         * @param active True if the given sub-component is currently active,
1612
         * e.g. multiview sub-tab is selected.
1617
         * e.g. multiview sub-tab is selected.
1618
         * @param lookup the lookup of the given sub-component
1619
         * @param showing True if the given sub-component is currently showing,
1620
         * e.g. multiview sub-tab is selected or part of a split.
1613
         */
1621
         */
1614
        public SubComponent( String displayName, String description, ActionListener activator, boolean active ) {
1622
        public SubComponent( String displayName, String description, ActionListener activator, boolean active, Lookup lookup, boolean showing ) {
1615
            this.displayName = displayName;
1623
            this.displayName = displayName;
1616
            this.description = description;
1624
            this.description = description;
1617
            this.active = active;
1625
            this.active = active;
1618
            this.activator = activator;
1626
            this.activator = activator;
1627
            this.lookup = lookup;
1628
	    this.showing = showing;
1619
        }
1629
        }
1620
1630
1631
	public Lookup getLookup() {
1632
	    return lookup;
1633
	}
1634
1635
	/**
1636
         * @return True if this sub-component is the active/selected one or part of a split.
1637
         */
1638
        public boolean isShowing() {
1639
	    return showing;
1640
	}
1641
1621
        /**
1642
        /**
1622
         * @return True if this sub-component is the active/selected one.
1643
         * @return True if this sub-component is the active/selected one.
1623
         */
1644
         */
(-)a/spi.palette/src/org/netbeans/spi/palette/PaletteSwitch.java (+10 lines)
Lines 185-190 Link Here
185
            return null;
185
            return null;
186
        
186
        
187
        PaletteController pc = (PaletteController)tc.getLookup().lookup( PaletteController.class );
187
        PaletteController pc = (PaletteController)tc.getLookup().lookup( PaletteController.class );
188
	if (pc == null && isOpened) {
189
	    TopComponent.SubComponent[] subComponents = tc.getSubComponents();
190
	    for (int i = 0; i < subComponents.length; i++) {
191
		TopComponent.SubComponent subComponent = subComponents[i];
192
		pc = (PaletteController) subComponent.getLookup().lookup(PaletteController.class);
193
		if(pc != null && (subComponent.isActive() || subComponent.isShowing())) {
194
		    break;
195
		}
196
	    }
197
	}
188
        if( null == pc && isOpened ) {
198
        if( null == pc && isOpened ) {
189
            //check if there's any palette assigned to TopComponent's mime type
199
            //check if there's any palette assigned to TopComponent's mime type
190
            Node[] activeNodes = tc.getActivatedNodes();
200
            Node[] activeNodes = tc.getActivatedNodes();

Return to bug 228448