View | Details | Raw Unified | Return to bug 96129 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/EditorManager.java (-6 / +11 lines)
Lines 713-724 Link Here
713
        return null;
713
        return null;
714
    }
714
    }
715
715
716
    /*
716
    /**
717
     * Create the site and action bars for each inner editor.
717
     * Create the part and reference for each inner editor.
718
     */
718
     * 
719
    private IEditorReference[] openMultiEditor(final IEditorReference ref,
719
     * @param ref the MultiEditor ref
720
            final MultiEditor part, final EditorDescriptor desc,
720
     * @param part the part
721
            final MultiEditorInput input, final boolean setVisible)
721
     * @param input the MultiEditor input
722
     * @return the array of inner references to store in the MultiEditor ref
723
     */
724
    IEditorReference[] openMultiEditor(final IEditorReference ref,
725
            final MultiEditor part, 
726
            final MultiEditorInput input)
722
            throws PartInitException {
727
            throws PartInitException {
723
728
724
        String[] editorArray = input.getEditors();
729
        String[] editorArray = input.getEditors();
(-)Eclipse UI/org/eclipse/ui/internal/EditorReference.java (-3 / +39 lines)
Lines 43-48 Link Here
43
import org.eclipse.ui.internal.registry.EditorDescriptor;
43
import org.eclipse.ui.internal.registry.EditorDescriptor;
44
import org.eclipse.ui.internal.util.Util;
44
import org.eclipse.ui.internal.util.Util;
45
import org.eclipse.ui.part.IWorkbenchPartOrientation;
45
import org.eclipse.ui.part.IWorkbenchPartOrientation;
46
import org.eclipse.ui.part.MultiEditor;
47
import org.eclipse.ui.part.MultiEditorInput;
46
48
47
public class EditorReference extends WorkbenchPartReference implements
49
public class EditorReference extends WorkbenchPartReference implements
48
        IEditorReference {
50
        IEditorReference {
Lines 78-83 Link Here
78
80
79
    IEditorInput restoredInput;
81
    IEditorInput restoredInput;
80
    
82
    
83
	/**
84
	 * If the reference is instantiated as a MultiEditor, we need to dispose the
85
	 * inner references correctly.
86
	 */
87
	private IEditorReference[] multiEditorChildren = null;
88
89
    
81
    public EditorReference(EditorManager manager, IEditorInput input, EditorDescriptor desc) {
90
    public EditorReference(EditorManager manager, IEditorInput input, EditorDescriptor desc) {
82
        this.manager = manager;
91
        this.manager = manager;
83
        initListenersAndHandlers();
92
        initListenersAndHandlers();
Lines 231-237 Link Here
231
    }
240
    }
232
241
233
    protected void doDisposePart() {
242
    protected void doDisposePart() {
234
        if (part != null) {
243
    	if (multiEditorChildren!=null) {
244
    		for (int i=0; i<multiEditorChildren.length; ++i) {
245
    			EditorReference ref = (EditorReference)multiEditorChildren[i];
246
    			if (ref!=null) {
247
    				ref.dispose();
248
    			}
249
    		}
250
    		multiEditorChildren = null;
251
    	}
252
253
    	if (part != null) {
235
            EditorSite site = (EditorSite) ((IEditorPart)part).getEditorSite();
254
            EditorSite site = (EditorSite) ((IEditorPart)part).getEditorSite();
236
            manager.disposeEditorActionBars((EditorActionBars) site.getActionBars());
255
            manager.disposeEditorActionBars((EditorActionBars) site.getActionBars());
237
            site.dispose();
256
            site.dispose();
Lines 524-536 Link Here
524
                throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_missing_editor_descriptor, editorID));
543
                throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_missing_editor_descriptor, editorID));
525
            }
544
            }
526
            
545
            
527
            IEditorPart part;
546
            IEditorPart part = null;
528
            
547
            
529
            if (desc.isInternal()) {    
548
            if (desc.isInternal()) {    
530
                // Create an editor instance.
549
                // Create an editor instance.
531
                try {
550
                try {
532
                    UIStats.start(UIStats.CREATE_PART, editorID);
551
                    UIStats.start(UIStats.CREATE_PART, editorID);
533
                    part = manager.createPart(desc);
552
                    part = manager.createPart(desc);
553
                    
554
                    if (part != null && part instanceof MultiEditor) {
555
    					multiEditorChildren = manager.openMultiEditor(this,
556
    						(MultiEditor) part, (MultiEditorInput) editorInput);
557
    				}
534
                } finally {
558
                } finally {
535
                    UIStats.end(UIStats.CREATE_PART, this, editorID);
559
                    UIStats.end(UIStats.CREATE_PART, this, editorID);
536
                }
560
                }
Lines 625-628 Link Here
625
    
649
    
626
    }
650
    }
627
    
651
    
628
}
652
    /**
653
     * A quick way of finding out if this reference points to a MultiEditor.
654
     * It depends on the fact that a MultiEditor does not lazily 
655
     * instantiate it's child editors.
656
     * 
657
     * @return true if it has inner editor reference or the input is
658
     * MultiEditorInput.
659
     */
660
    public boolean isMultiReference() {
661
    	return multiEditorChildren!=null || restoredInput instanceof MultiEditorInput;
662
    }
663
}
664
(-)Eclipse UI/org/eclipse/ui/internal/PartList.java (+17 lines)
Lines 17-22 Link Here
17
import org.eclipse.ui.IWorkbenchPart;
17
import org.eclipse.ui.IWorkbenchPart;
18
import org.eclipse.ui.IWorkbenchPartConstants;
18
import org.eclipse.ui.IWorkbenchPartConstants;
19
import org.eclipse.ui.IWorkbenchPartReference;
19
import org.eclipse.ui.IWorkbenchPartReference;
20
import org.eclipse.ui.IWorkbenchPartSite;
21
import org.eclipse.ui.part.MultiEditor;
20
22
21
public abstract class PartList {
23
public abstract class PartList {
22
    private IWorkbenchPartReference activePartReference;
24
    private IWorkbenchPartReference activePartReference;
Lines 101-106 Link Here
101
        if (ref != null) {
103
        if (ref != null) {
102
            IWorkbenchPart part = ref.getPart(true); 
104
            IWorkbenchPart part = ref.getPart(true); 
103
            Assert.isNotNull(part);
105
            Assert.isNotNull(part);
106
            if (part instanceof MultiEditor) {
107
            	IWorkbenchPartSite site = ((MultiEditor) part)
108
						.getActiveEditor().getSite();
109
				if (site instanceof PartSite) {
110
					ref = ((PartSite) site).getPane().getPartReference();
111
				}
112
			}
104
        }
113
        }
105
114
106
        activePartReference = ref;
115
        activePartReference = ref;
Lines 119-124 Link Here
119
        if (ref != null) {
128
        if (ref != null) {
120
            IWorkbenchPart part = ref.getPart(true); 
129
            IWorkbenchPart part = ref.getPart(true); 
121
            Assert.isNotNull(part);
130
            Assert.isNotNull(part);
131
            if (part instanceof MultiEditor) {
132
            	IWorkbenchPartSite site = ((MultiEditor) part)
133
						.getActiveEditor().getSite();
134
				if (site instanceof PartSite) {
135
					ref = (IEditorReference) ((PartSite) site).getPane()
136
							.getPartReference();
137
				}
138
			}
122
        }
139
        }
123
140
124
        activeEditorReference = ref;
141
        activeEditorReference = ref;
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java (-25 / +39 lines)
Lines 760-765 Link Here
760
                makeActive(ref);
760
                makeActive(ref);
761
            } else if (newPartContainer == activeEditorContainer) {
761
            } else if (newPartContainer == activeEditorContainer) {
762
                if (ref instanceof IEditorReference) {
762
                if (ref instanceof IEditorReference) {
763
                	if (part!=null) {
764
                    	IWorkbenchPartSite site = part.getSite();
765
						if (site instanceof PartSite) {
766
							ref = ((PartSite) site).getPane()
767
									.getPartReference();
768
						}
769
                	}
763
                    makeActiveEditor((IEditorReference)ref);
770
                    makeActiveEditor((IEditorReference)ref);
764
                } else {
771
                } else {
765
                    makeActiveEditor(null);
772
                    makeActiveEditor(null);
Lines 1101-1107 Link Here
1101
     * @param ref the editor to make active, or <code>null</code> for no active editor
1108
     * @param ref the editor to make active, or <code>null</code> for no active editor
1102
     */
1109
     */
1103
    private void makeActiveEditor(IEditorReference ref) {
1110
    private void makeActiveEditor(IEditorReference ref) {
1104
        if (ref == getActiveEditor()) {
1111
        if (ref == getActiveEditorReference()) {
1105
            return;
1112
            return;
1106
        }
1113
        }
1107
        
1114
        
Lines 1115-1121 Link Here
1115
        actionSwitcher.updateTopEditor(part);
1122
        actionSwitcher.updateTopEditor(part);
1116
1123
1117
        if (ref != null) {
1124
        if (ref != null) {
1118
            activationList.bringToTop(ref);
1125
            activationList.bringToTop(getReference(part));
1119
        }
1126
        }
1120
        
1127
        
1121
        partList.setActiveEditor(ref);
1128
        partList.setActiveEditor(ref);
Lines 1473-1478 Link Here
1473
        if (isZoomed())
1480
        if (isZoomed())
1474
            zoomOut();
1481
            zoomOut();
1475
1482
1483
        makeActiveEditor(null);
1476
        makeActive(null);
1484
        makeActive(null);
1477
        
1485
        
1478
        // Close and dispose the editors.
1486
        // Close and dispose the editors.
Lines 2171-2176 Link Here
2171
     * This method is called when the page is deactivated.
2179
     * This method is called when the page is deactivated.
2172
     */
2180
     */
2173
    protected void onDeactivate() {
2181
    protected void onDeactivate() {
2182
    	makeActiveEditor(null);
2174
        makeActive(null);
2183
        makeActive(null);
2175
        if (getActivePerspective() != null)
2184
        if (getActivePerspective() != null)
2176
            getActivePerspective().onDeactivate();
2185
            getActivePerspective().onDeactivate();
Lines 2467-2472 Link Here
2467
        if (!certifyPart(part))
2476
        if (!certifyPart(part))
2468
            return;
2477
            return;
2469
2478
2479
        if (part instanceof MultiEditor) {
2480
            part = ((MultiEditor) part).getActiveEditor();
2481
        }
2482
2470
        // Real work.
2483
        // Real work.
2471
        setActivePart(part);
2484
        setActivePart(part);
2472
    }
2485
    }
Lines 2829-2836 Link Here
2829
            label = newPart != null ? newPart.getTitle() : "none"; //$NON-NLS-1$
2842
            label = newPart != null ? newPart.getTitle() : "none"; //$NON-NLS-1$
2830
        }
2843
        }
2831
        try {
2844
        try {
2832
            IWorkbenchPartReference partref = getReference(newPart); 
2845
            IWorkbenchPartReference partref = getReference(newPart);
2833
            partBeingActivated = partref;
2846
            IWorkbenchPartReference realPartRef = null;
2847
			if (newPart != null) {
2848
				IWorkbenchPartSite site = newPart.getSite();
2849
				if (site instanceof PartSite) {
2850
					realPartRef = ((PartSite) site).getPane()
2851
							.getPartReference();
2852
				}
2853
			}
2854
2855
            partBeingActivated = realPartRef;
2834
            
2856
            
2835
            UIStats.start(UIStats.ACTIVATE_PART, label);
2857
            UIStats.start(UIStats.ACTIVATE_PART, label);
2836
            // Notify perspective. It may deactivate fast view.
2858
            // Notify perspective. It may deactivate fast view.
Lines 2848-2856 Link Here
2848
            if (newPart != null) {
2870
            if (newPart != null) {
2849
                activationList.setActive(newPart);
2871
                activationList.setActive(newPart);
2850
                if (newPart instanceof IEditorPart) {
2872
                if (newPart instanceof IEditorPart) {
2851
                    IEditorReference ref = (IEditorReference) getReference(newPart);
2873
					makeActiveEditor((IEditorReference)realPartRef);
2852
                    makeActiveEditor(ref);
2874
				}
2853
                }
2854
            }
2875
            }
2855
            activatePart(newPart);
2876
            activatePart(newPart);
2856
            
2877
            
Lines 3470-3496 Link Here
3470
         */
3491
         */
3471
        void setActive(IWorkbenchPart part) {
3492
        void setActive(IWorkbenchPart part) {
3472
            if (parts.size() <= 0)
3493
            if (parts.size() <= 0)
3473
                return;
3494
				return;
3474
            PartPane pane = ((PartSite) part.getSite()).getPane();
3495
			IWorkbenchPartReference ref = getReference(part);
3475
            if (pane instanceof MultiEditorInnerPane) {
3496
			if (ref != null) {
3476
                MultiEditorInnerPane innerPane = (MultiEditorInnerPane) pane;
3497
				if (ref == parts.get(parts.size() - 1))
3477
                setActive(innerPane.getParentPane().getPartReference().getPart(
3498
					return;
3478
                        true));
3499
				parts.remove(ref);
3479
            } else {
3500
				parts.add(ref);
3480
                IWorkbenchPartReference ref = getReference(part);
3501
			}
3481
                if (ref != null) {
3482
	                if (ref == parts.get(parts.size() - 1))
3483
	                    return;
3484
	                parts.remove(ref);
3485
	                parts.add(ref);
3486
                }
3487
            }
3488
        }
3502
        }
3489
        
3503
        
3490
        /*
3504
        /*
3491
         * Ensures that the given part appears AFTER any other part in the same
3505
		 * Ensures that the given part appears AFTER any other part in the same
3492
         * container.
3506
		 * container.
3493
         */
3507
		 */
3494
        void bringToTop(IWorkbenchPartReference ref) {
3508
        void bringToTop(IWorkbenchPartReference ref) {
3495
            ILayoutContainer targetContainer = getContainer(ref);
3509
            ILayoutContainer targetContainer = getContainer(ref);
3496
            
3510
            
(-)Eclipse UI/org/eclipse/ui/part/MultiEditor.java (-15 lines)
Lines 77-97 Link Here
77
        return content;
77
        return content;
78
    }
78
    }
79
79
80
    /**
81
     * The <code>MultiEditor</code> implementation of this 
82
     * method extends the <code>EditorPart</code> implementation,
83
     * and disposes any inner editors.  Subclasses may extend.
84
     * 
85
     * @since 3.0
86
     */
87
    public void dispose() {
88
        super.dispose();
89
        IEditorPart[] editors = getInnerEditors();
90
        for (int i = 0; i < editors.length; i++) {
91
            editors[i].dispose();
92
        }
93
    }
94
95
    /*
80
    /*
96
     * @see IEditorPart#doSaveAs()
81
     * @see IEditorPart#doSaveAs()
97
     */
82
     */

Return to bug 96129