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 2463-2468 Link Here
2463
        if (!certifyPart(part))
2463
        if (!certifyPart(part))
2464
            return;
2464
            return;
2465
2465
2466
        if (part instanceof MultiEditor) {
2467
            part = ((MultiEditor) part).getActiveEditor();
2468
        }
2469
2466
        // Real work.
2470
        // Real work.
2467
        setActivePart(part);
2471
        setActivePart(part);
2468
    }
2472
    }
Lines 2825-2832 Link Here
2825
            label = newPart != null ? newPart.getTitle() : "none"; //$NON-NLS-1$
2829
            label = newPart != null ? newPart.getTitle() : "none"; //$NON-NLS-1$
2826
        }
2830
        }
2827
        try {
2831
        try {
2828
            IWorkbenchPartReference partref = getReference(newPart); 
2832
            IWorkbenchPartReference parentRef = getReference(newPart); 
2829
            partBeingActivated = partref;
2833
            partBeingActivated = getReference(newPart, false);
2830
            
2834
            
2831
            UIStats.start(UIStats.ACTIVATE_PART, label);
2835
            UIStats.start(UIStats.ACTIVATE_PART, label);
2832
            // Notify perspective. It may deactivate fast view.
2836
            // Notify perspective. It may deactivate fast view.
Lines 2844-2858 Link Here
2844
            if (newPart != null) {
2848
            if (newPart != null) {
2845
                activationList.setActive(newPart);
2849
                activationList.setActive(newPart);
2846
                if (newPart instanceof IEditorPart) {
2850
                if (newPart instanceof IEditorPart) {
2847
                    IEditorReference ref = (IEditorReference) getReference(newPart);
2851
                    makeActiveEditor((IEditorReference)parentRef);
2848
                    makeActiveEditor(ref);
2849
                }
2852
                }
2850
            }
2853
            }
2851
            activatePart(newPart);
2854
            activatePart(newPart);
2852
            
2855
            
2853
            actionSwitcher.updateActivePart(newPart);
2856
            actionSwitcher.updateActivePart(newPart);
2854
            
2857
            
2855
            partList.setActivePart(partref);
2858
            partList.setActivePart(parentRef);
2856
        } finally {
2859
        } finally {
2857
            partBeingActivated = null;
2860
            partBeingActivated = null;
2858
        	Object blame = newPart == null ? (Object)this : newPart;
2861
        	Object blame = newPart == null ? (Object)this : newPart;
Lines 3435-3493 Link Here
3435
3438
3436
    /**
3439
    /**
3437
     * Returns the reference to the given part, or <code>null</code> if it has no reference 
3440
     * Returns the reference to the given part, or <code>null</code> if it has no reference 
3438
     * (i.e. it is not a top-level part in this workbench page).
3441
     * (i.e. it is not a top-level part in this workbench page).  For 
3442
     * the MultiEditor, it returns parent reference.
3439
     * 
3443
     * 
3440
     * @param part the part
3444
     * @param part the part
3441
     * @return the part's reference or <code>null</code> if the given part does not belong 
3445
     * @return the part's reference or <code>null</code> if the given part does not belong 
3442
     * to this workbench page
3446
     * to this workbench page
3443
     */
3447
     */
3444
    public IWorkbenchPartReference getReference(IWorkbenchPart part) {
3448
    public IWorkbenchPartReference getReference(IWorkbenchPart part) {
3445
        if (part == null) {
3449
		return getReference(part, true);
3446
            return null;
3450
	}
3447
        }
3451
3448
        IWorkbenchPartSite site = part.getSite();
3452
	/**
3449
        if (!(site instanceof PartSite)) {
3453
	 * Returns the reference to the given part, or <code>null</code> if it has
3450
        	return null;
3454
	 * no reference (i.e. it is not a top-level part in this workbench page).
3451
        }
3455
	 * 
3452
        PartSite partSite = ((PartSite) site);
3456
	 * @param part
3453
        PartPane pane = partSite.getPane();
3457
	 *            the part
3454
        if (pane instanceof MultiEditorInnerPane) {
3458
	 * @param findContainer
3455
            MultiEditorInnerPane innerPane = (MultiEditorInnerPane) pane;
3459
	 *            true - return the parent reference for InnerEditors
3456
            return innerPane.getParentPane().getPartReference();
3460
	 * @return the part's reference or <code>null</code> if the given part
3457
        }
3461
	 *         does not belong to this workbench page
3458
        return partSite.getPartReference();
3462
	 */
3463
	public IWorkbenchPartReference getReference(IWorkbenchPart part,
3464
			boolean findContainer) {
3465
		if (part == null) {
3466
			return null;
3467
		}
3468
		IWorkbenchPartSite site = part.getSite();
3469
		if (!(site instanceof PartSite)) {
3470
			return null;
3471
		}
3472
		PartSite partSite = ((PartSite) site);
3473
		PartPane pane = partSite.getPane();
3474
		if (findContainer && pane instanceof MultiEditorInnerPane) {
3475
			MultiEditorInnerPane innerPane = (MultiEditorInnerPane) pane;
3476
			return innerPane.getParentPane().getPartReference();
3477
		}
3478
		return partSite.getPartReference();
3459
    }
3479
    }
3460
3480
3461
    private class ActivationList {
3481
    private class ActivationList {
3462
        //List of parts in the activation order (oldest first)
3482
        // List of parts in the activation order (oldest first)
3463
        List parts = new ArrayList();
3483
        List parts = new ArrayList();
3464
3484
3465
        /*
3485
        /*
3466
         * Add/Move the active part to end of the list;
3486
		 * Add/Move the active part to end of the list;
3467
         */
3487
		 */
3468
        void setActive(IWorkbenchPart part) {
3488
        void setActive(IWorkbenchPart part) {
3469
            if (parts.size() <= 0)
3489
			if (parts.size() <= 0)
3470
                return;
3490
				return;
3471
            PartPane pane = ((PartSite) part.getSite()).getPane();
3491
			IWorkbenchPartReference ref = getReference(part);
3472
            if (pane instanceof MultiEditorInnerPane) {
3492
			if (ref != null) {
3473
                MultiEditorInnerPane innerPane = (MultiEditorInnerPane) pane;
3493
				if (ref == parts.get(parts.size() - 1))
3474
                setActive(innerPane.getParentPane().getPartReference().getPart(
3494
					return;
3475
                        true));
3495
				parts.remove(ref);
3476
            } else {
3496
				parts.add(ref);
3477
                IWorkbenchPartReference ref = getReference(part);
3497
			}
3478
                if (ref != null) {
3479
	                if (ref == parts.get(parts.size() - 1))
3480
	                    return;
3481
	                parts.remove(ref);
3482
	                parts.add(ref);
3483
                }
3484
            }
3485
        }
3498
        }
3486
        
3499
        
3487
        /*
3500
        /*
3488
         * Ensures that the given part appears AFTER any other part in the same
3501
		 * Ensures that the given part appears AFTER any other part in the same
3489
         * container.
3502
		 * container.
3490
         */
3503
		 */
3491
        void bringToTop(IWorkbenchPartReference ref) {
3504
        void bringToTop(IWorkbenchPartReference ref) {
3492
            ILayoutContainer targetContainer = getContainer(ref);
3505
            ILayoutContainer targetContainer = getContainer(ref);
3493
            
3506
            
(-)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