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 (-30 / +31 lines)
Lines 713-753 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 site and action bars for each inner editor. Just like
718
     */
718
	 * createPart(), this method is called from the EditorReference.
719
    private IEditorReference[] openMultiEditor(final IEditorReference ref,
719
	 */
720
            final MultiEditor part, final EditorDescriptor desc,
720
	IEditorReference[] openMultiEditor(final IEditorReference ref, final MultiEditor part,
721
            final MultiEditorInput input, final boolean setVisible)
721
			final MultiEditorInput input) throws PartInitException {
722
            throws PartInitException {
723
722
724
        String[] editorArray = input.getEditors();
723
		String[] editorArray = input.getEditors();
725
        IEditorInput[] inputArray = input.getInput();
724
		IEditorInput[] inputArray = input.getInput();
726
725
727
        //find all descriptors
726
		// find all descriptors
728
        EditorDescriptor[] descArray = new EditorDescriptor[editorArray.length];
727
		EditorDescriptor[] descArray = new EditorDescriptor[editorArray.length];
729
        IEditorReference refArray[] = new IEditorReference[editorArray.length];
728
		IEditorPart partArray[] = new IEditorPart[editorArray.length];
730
        IEditorPart partArray[] = new IEditorPart[editorArray.length];
729
		IEditorReference[] refArray = new IEditorReference[editorArray.length];
731
730
732
        IEditorRegistry reg = getEditorRegistry();
731
		IEditorRegistry reg = getEditorRegistry();
733
        for (int i = 0; i < editorArray.length; i++) {
732
		for (int i = 0; i < editorArray.length; i++) {
734
            EditorDescriptor innerDesc = (EditorDescriptor) reg
733
			EditorDescriptor innerDesc = (EditorDescriptor) reg
735
                    .findEditor(editorArray[i]);
734
					.findEditor(editorArray[i]);
736
            if (innerDesc == null)
735
			if (innerDesc == null) {
737
                throw new PartInitException(
736
				throw new PartInitException(NLS.bind(
738
                        NLS.bind(WorkbenchMessages.EditorManager_unknownEditorIDMessage, editorArray[i] )); 
737
						WorkbenchMessages.EditorManager_unknownEditorIDMessage,
739
            descArray[i] = innerDesc;
738
						editorArray[i]));
740
            InnerEditor innerRef = new InnerEditor(ref, inputArray[i], descArray[i]); 
739
			}
741
            refArray[i] = innerRef;
740
			descArray[i] = innerDesc;
742
            partArray[i] = innerRef.getEditor(true);
741
			refArray[i] = new InnerEditor(ref, inputArray[i],
743
        }
742
					descArray[i]);
744
        part.setChildren(partArray);
743
			partArray[i] = refArray[i].getEditor(true);
745
        return refArray;
744
		}
745
		part.setChildren(partArray);
746
		return refArray;
746
    }
747
    }
747
748
748
    /*
749
    /*
749
     * Opens an editor part.
750
	 * Opens an editor part.
750
     */
751
	 */
751
    private void createEditorTab(final EditorReference ref, final String workbookId) throws PartInitException {
752
    private void createEditorTab(final EditorReference ref, final String workbookId) throws PartInitException {
752
        
753
        
753
        editorPresentation.addEditor(ref, workbookId);
754
        editorPresentation.addEditor(ref, workbookId);
(-)Eclipse UI/org/eclipse/ui/internal/EditorReference.java (-2 / +22 lines)
Lines 44-49 Link Here
44
import org.eclipse.ui.internal.registry.EditorDescriptor;
44
import org.eclipse.ui.internal.registry.EditorDescriptor;
45
import org.eclipse.ui.internal.util.Util;
45
import org.eclipse.ui.internal.util.Util;
46
import org.eclipse.ui.part.IWorkbenchPartOrientation;
46
import org.eclipse.ui.part.IWorkbenchPartOrientation;
47
import org.eclipse.ui.part.MultiEditor;
48
import org.eclipse.ui.part.MultiEditorInput;
47
import org.eclipse.ui.presentations.IPresentablePart;
49
import org.eclipse.ui.presentations.IPresentablePart;
48
50
49
public class EditorReference extends WorkbenchPartReference implements
51
public class EditorReference extends WorkbenchPartReference implements
Lines 79-84 Link Here
79
    String factoryId;
81
    String factoryId;
80
82
81
    IEditorInput restoredInput;
83
    IEditorInput restoredInput;
84
85
	/**
86
	 * If the reference is instantiated as a MultiEditor, we need to dispose the
87
	 * inner references correctly.
88
	 */
89
	private IEditorReference[] multiEditorChildren = null;
82
    
90
    
83
    public EditorReference(EditorManager manager, IEditorInput input, EditorDescriptor desc) {
91
    public EditorReference(EditorManager manager, IEditorInput input, EditorDescriptor desc) {
84
        this.manager = manager;
92
        this.manager = manager;
Lines 241-246 Link Here
241
    }
249
    }
242
250
243
    protected void doDisposePart() {
251
    protected void doDisposePart() {
252
    	if (multiEditorChildren!=null) {
253
    		for (int i=0; i<multiEditorChildren.length; ++i) {
254
    			EditorReference ref = (EditorReference)multiEditorChildren[i];
255
    			if (ref!=null) {
256
    				ref.dispose();
257
    			}
258
    		}
259
    		multiEditorChildren = null;
260
    	}
244
        if (part != null) {
261
        if (part != null) {
245
            EditorSite site = (EditorSite) ((IEditorPart)part).getEditorSite();
262
            EditorSite site = (EditorSite) ((IEditorPart)part).getEditorSite();
246
            manager.disposeEditorActionBars((EditorActionBars) site.getActionBars());
263
            manager.disposeEditorActionBars((EditorActionBars) site.getActionBars());
Lines 534-540 Link Here
534
                throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_missing_editor_descriptor, editorID)); //$NON-NLS-1$
551
                throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_missing_editor_descriptor, editorID)); //$NON-NLS-1$
535
            }
552
            }
536
            
553
            
537
            IEditorPart part;
554
            IEditorPart part = null;
538
            
555
            
539
            if (desc.isInternal()) {    
556
            if (desc.isInternal()) {    
540
                // Create an editor instance.
557
                // Create an editor instance.
Lines 544-550 Link Here
544
                } finally {
561
                } finally {
545
                    UIStats.end(UIStats.CREATE_PART, this, editorID);
562
                    UIStats.end(UIStats.CREATE_PART, this, editorID);
546
                }
563
                }
547
                
564
                if (part != null && part instanceof MultiEditor) {
565
					multiEditorChildren = manager.openMultiEditor(this,
566
												(MultiEditor) part, (MultiEditorInput) editorInput);
567
				}
548
            } else if (desc.getId().equals(
568
            } else if (desc.getId().equals(
549
                    IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID)) {
569
                    IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID)) {
550
                
570
                
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java (-42 / +55 lines)
Lines 2467-2472 Link Here
2467
        if (!certifyPart(part))
2467
        if (!certifyPart(part))
2468
            return;
2468
            return;
2469
2469
2470
        if (part instanceof MultiEditor) {
2471
            part = ((MultiEditor) part).getActiveEditor();
2472
        }
2473
2470
        // Real work.
2474
        // Real work.
2471
        setActivePart(part);
2475
        setActivePart(part);
2472
    }
2476
    }
Lines 2829-2836 Link Here
2829
            label = newPart != null ? newPart.getTitle() : "none"; //$NON-NLS-1$
2833
            label = newPart != null ? newPart.getTitle() : "none"; //$NON-NLS-1$
2830
        }
2834
        }
2831
        try {
2835
        try {
2832
            IWorkbenchPartReference partref = getReference(newPart); 
2836
            IWorkbenchPartReference parentRef = getReference(newPart); 
2833
            partBeingActivated = partref;
2837
            partBeingActivated = getReference(newPart, false);
2834
            
2838
            
2835
            UIStats.start(UIStats.ACTIVATE_PART, label);
2839
            UIStats.start(UIStats.ACTIVATE_PART, label);
2836
            // Notify perspective. It may deactivate fast view.
2840
            // Notify perspective. It may deactivate fast view.
Lines 2848-2862 Link Here
2848
            if (newPart != null) {
2852
            if (newPart != null) {
2849
                activationList.setActive(newPart);
2853
                activationList.setActive(newPart);
2850
                if (newPart instanceof IEditorPart) {
2854
                if (newPart instanceof IEditorPart) {
2851
                    IEditorReference ref = (IEditorReference) getReference(newPart);
2855
                    makeActiveEditor((IEditorReference)parentRef);
2852
                    makeActiveEditor(ref);
2853
                }
2856
                }
2854
            }
2857
            }
2855
            activatePart(newPart);
2858
            activatePart(newPart);
2856
            
2859
            
2857
            actionSwitcher.updateActivePart(newPart);
2860
            actionSwitcher.updateActivePart(newPart);
2858
            
2861
            
2859
            partList.setActivePart(partref);
2862
            partList.setActivePart(parentRef);
2860
        } finally {
2863
        } finally {
2861
            partBeingActivated = null;
2864
            partBeingActivated = null;
2862
        	Object blame = newPart == null ? (Object)this : newPart;
2865
        	Object blame = newPart == null ? (Object)this : newPart;
Lines 3439-3497 Link Here
3439
3442
3440
    /**
3443
    /**
3441
     * Returns the reference to the given part, or <code>null</code> if it has no reference 
3444
     * Returns the reference to the given part, or <code>null</code> if it has no reference 
3442
     * (i.e. it is not a top-level part in this workbench page).
3445
     * (i.e. it is not a top-level part in this workbench page).  For 
3446
     * the MultiEditor, it returns parent reference.
3443
     * 
3447
     * 
3444
     * @param part the part
3448
     * @param part the part
3445
     * @return the part's reference or <code>null</code> if the given part does not belong 
3449
     * @return the part's reference or <code>null</code> if the given part does not belong 
3446
     * to this workbench page
3450
     * to this workbench page
3447
     */
3451
     */
3448
    public IWorkbenchPartReference getReference(IWorkbenchPart part) {
3452
    public IWorkbenchPartReference getReference(IWorkbenchPart part) {
3449
        if (part == null) {
3453
		return getReference(part, true);
3450
            return null;
3454
	}
3451
        }
3455
3452
        IWorkbenchPartSite site = part.getSite();
3456
	/**
3453
        if (!(site instanceof PartSite)) {
3457
	 * Returns the reference to the given part, or <code>null</code> if it has
3454
        	return null;
3458
	 * no reference (i.e. it is not a top-level part in this workbench page).
3455
        }
3459
	 * 
3456
        PartSite partSite = ((PartSite) site);
3460
	 * @param part
3457
        PartPane pane = partSite.getPane();
3461
	 *            the part
3458
        if (pane instanceof MultiEditorInnerPane) {
3462
	 * @param findContainer
3459
            MultiEditorInnerPane innerPane = (MultiEditorInnerPane) pane;
3463
	 *            true - return the parent reference for InnerEditors
3460
            return innerPane.getParentPane().getPartReference();
3464
	 * @return the part's reference or <code>null</code> if the given part
3461
        }
3465
	 *         does not belong to this workbench page
3462
        return partSite.getPartReference();
3466
	 */
3467
	public IWorkbenchPartReference getReference(IWorkbenchPart part,
3468
			boolean findContainer) {
3469
		if (part == null) {
3470
			return null;
3471
		}
3472
		IWorkbenchPartSite site = part.getSite();
3473
		if (!(site instanceof PartSite)) {
3474
			return null;
3475
		}
3476
		PartSite partSite = ((PartSite) site);
3477
		PartPane pane = partSite.getPane();
3478
		if (findContainer && pane instanceof MultiEditorInnerPane) {
3479
			MultiEditorInnerPane innerPane = (MultiEditorInnerPane) pane;
3480
			return innerPane.getParentPane().getPartReference();
3481
		}
3482
		return partSite.getPartReference();
3463
    }
3483
    }
3464
3484
3465
    private class ActivationList {
3485
    private class ActivationList {
3466
        //List of parts in the activation order (oldest first)
3486
        // List of parts in the activation order (oldest first)
3467
        List parts = new ArrayList();
3487
        List parts = new ArrayList();
3468
3488
3469
        /*
3489
        /*
3470
         * Add/Move the active part to end of the list;
3490
		 * Add/Move the active part to end of the list;
3471
         */
3491
		 */
3472
        void setActive(IWorkbenchPart part) {
3492
        void setActive(IWorkbenchPart part) {
3473
            if (parts.size() <= 0)
3493
			if (parts.size() <= 0)
3474
                return;
3494
				return;
3475
            PartPane pane = ((PartSite) part.getSite()).getPane();
3495
			IWorkbenchPartReference ref = getReference(part);
3476
            if (pane instanceof MultiEditorInnerPane) {
3496
			if (ref != null) {
3477
                MultiEditorInnerPane innerPane = (MultiEditorInnerPane) pane;
3497
				if (ref == parts.get(parts.size() - 1))
3478
                setActive(innerPane.getParentPane().getPartReference().getPart(
3498
					return;
3479
                        true));
3499
				parts.remove(ref);
3480
            } else {
3500
				parts.add(ref);
3481
                IWorkbenchPartReference ref = getReference(part);
3501
			}
3482
                if (ref != null) {
3483
	                if (ref == parts.get(parts.size() - 1))
3484
	                    return;
3485
	                parts.remove(ref);
3486
	                parts.add(ref);
3487
                }
3488
            }
3489
        }
3502
        }
3490
        
3503
        
3491
        /*
3504
        /*
3492
         * 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
3493
         * container.
3506
		 * container.
3494
         */
3507
		 */
3495
        void bringToTop(IWorkbenchPartReference ref) {
3508
        void bringToTop(IWorkbenchPartReference ref) {
3496
            ILayoutContainer targetContainer = getContainer(ref);
3509
            ILayoutContainer targetContainer = getContainer(ref);
3497
            
3510
            
(-)Eclipse UI/org/eclipse/ui/part/MultiEditor.java (-14 lines)
Lines 77-96 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
80
95
    /*
81
    /*
96
     * @see IEditorPart#doSaveAs()
82
     * @see IEditorPart#doSaveAs()

Return to bug 96129