Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 44295 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/actions/NewEditorAction.java (-2 / +15 lines)
Lines 12-22 Link Here
12
package org.eclipse.ui.internal.actions;
12
package org.eclipse.ui.internal.actions;
13
13
14
import org.eclipse.ui.IEditorPart;
14
import org.eclipse.ui.IEditorPart;
15
import org.eclipse.ui.IPersistableEditor;
15
import org.eclipse.ui.IWorkbenchPage;
16
import org.eclipse.ui.IWorkbenchPage;
16
import org.eclipse.ui.IWorkbenchWindow;
17
import org.eclipse.ui.IWorkbenchWindow;
17
import org.eclipse.ui.PartInitException;
18
import org.eclipse.ui.PartInitException;
19
import org.eclipse.ui.XMLMemento;
18
import org.eclipse.ui.internal.ActiveEditorAction;
20
import org.eclipse.ui.internal.ActiveEditorAction;
21
import org.eclipse.ui.internal.IWorkbenchConstants;
19
import org.eclipse.ui.internal.WorkbenchMessages;
22
import org.eclipse.ui.internal.WorkbenchMessages;
23
import org.eclipse.ui.internal.WorkbenchPage;
20
import org.eclipse.ui.internal.dialogs.DialogUtil;
24
import org.eclipse.ui.internal.dialogs.DialogUtil;
21
25
22
/**
26
/**
Lines 52-59 Link Here
52
			return;
56
			return;
53
		}
57
		}
54
		try {
58
		try {
55
			page.openEditor(editor.getEditorInput(), editorId, true, IWorkbenchPage.MATCH_NONE);
59
			if (editor instanceof IPersistableEditor) {
56
        } catch (PartInitException e) {
60
				XMLMemento editorState = XMLMemento
61
						.createWriteRoot(IWorkbenchConstants.TAG_EDITOR_STATE);
62
				((IPersistableEditor) editor).saveState(editorState);
63
				((WorkbenchPage) page).openEditor(editor.getEditorInput(),
64
						editorId, true, IWorkbenchPage.MATCH_NONE, editorState);
65
			} else {
66
				page.openEditor(editor.getEditorInput(), editorId, true,
67
						IWorkbenchPage.MATCH_NONE);
68
			}
69
		} catch (PartInitException e) {
57
            DialogUtil.openError(page.getWorkbenchWindow().getShell(),
70
            DialogUtil.openError(page.getWorkbenchWindow().getShell(),
58
                    WorkbenchMessages.Error,
71
                    WorkbenchMessages.Error,
59
                    e.getMessage(), e);
72
                    e.getMessage(), e);
(-)Eclipse UI/org/eclipse/ui/internal/EditorManager.java (-3 / +21 lines)
Lines 665-670 Link Here
665
	 */
665
	 */
666
	public IEditorReference openEditor(String editorId, IEditorInput input,
666
	public IEditorReference openEditor(String editorId, IEditorInput input,
667
			boolean setVisible) throws PartInitException {
667
			boolean setVisible) throws PartInitException {
668
		return openEditor(editorId, input, setVisible, null);
669
	}
670
671
	/**
672
	 * @param editorId
673
	 *            the editor part id
674
	 * @param input
675
	 *            the input
676
	 * @param setVisible
677
	 *            if this is to be created visible ... not used
678
	 * @param editorState
679
	 *            an {@link IMemento} <editorState> for persistable
680
	 *            editors. Can be <code>null</code>.
681
	 * @return a created editor reference
682
	 * @throws PartInitException
683
	 */
684
	public IEditorReference openEditor(String editorId, IEditorInput input,
685
			boolean setVisible, IMemento editorState) throws PartInitException {
668
		if (editorId == null || input == null) {
686
		if (editorId == null || input == null) {
669
			throw new IllegalArgumentException();
687
			throw new IllegalArgumentException();
670
		}
688
		}
Lines 677-683 Link Here
677
					editorId));
695
					editorId));
678
		}
696
		}
679
697
680
		IEditorReference result = openEditorFromDescriptor(desc, input);
698
		IEditorReference result = openEditorFromDescriptor(desc, input, editorState);
681
		return result;
699
		return result;
682
	}
700
	}
683
701
Lines 685-696 Link Here
685
	 * Open a new editor
703
	 * Open a new editor
686
	 */
704
	 */
687
	private IEditorReference openEditorFromDescriptor(EditorDescriptor desc,
705
	private IEditorReference openEditorFromDescriptor(EditorDescriptor desc,
688
			IEditorInput input) throws PartInitException {
706
			IEditorInput input, IMemento editorState) throws PartInitException {
689
		IEditorReference result = null;
707
		IEditorReference result = null;
690
		if (desc.isInternal()) {
708
		if (desc.isInternal()) {
691
			result = reuseInternalEditor(desc, input);
709
			result = reuseInternalEditor(desc, input);
692
			if (result == null) {
710
			if (result == null) {
693
				result = new EditorReference(this, input, desc);
711
				result = new EditorReference(this, input, desc, editorState);
694
			}
712
			}
695
		} else if (desc.getId()
713
		} else if (desc.getId()
696
				.equals(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID)) {
714
				.equals(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID)) {
(-)Eclipse UI/org/eclipse/ui/internal/EditorReference.java (-9 / +36 lines)
Lines 57-63 Link Here
57
57
58
    private IMemento editorMemento;
58
    private IMemento editorMemento;
59
59
60
	private IMemento editorState;
60
	private IMemento editorState = null;
61
61
62
    /**
62
    /**
63
     * Flag that lets us detect malfunctioning editors that don't fire PROP_INPUT events.
63
     * Flag that lets us detect malfunctioning editors that don't fire PROP_INPUT events.
Lines 90-105 Link Here
90
	private IEditorReference[] multiEditorChildren = null;
90
	private IEditorReference[] multiEditorChildren = null;
91
91
92
    
92
    
93
    public EditorReference(EditorManager manager, IEditorInput input, EditorDescriptor desc) {
93
    /**
94
        this.manager = manager;
94
	 * @param manager
95
        initListenersAndHandlers();
95
	 *            The editor manager for this reference
96
        restoredInput = input;
96
	 * @param input
97
        init(desc.getId(), desc.getLabel(), "", desc.getImageDescriptor(), desc.getLabel(), "");  //$NON-NLS-1$//$NON-NLS-2$
97
	 *            our input
98
    }
98
	 * @param desc
99
	 *            the descriptor from the declaration
100
	 */
101
	public EditorReference(EditorManager manager, IEditorInput input,
102
			EditorDescriptor desc) {
103
		this(manager, input, desc, null);
104
	}
99
    
105
    
100
    /**
106
    /**
101
     * Constructs a new editor reference for use by editors being restored from a memento.
107
	 * @param manager
102
     */
108
	 *            The editor manager for this reference
109
	 * @param input
110
	 *            our input
111
	 * @param desc
112
	 *            the descriptor from the declaration
113
	 * @param editorState
114
	 *            propogate state from another editor. Can be <code>null</code>.
115
	 */
116
	public EditorReference(EditorManager manager, IEditorInput input,
117
			EditorDescriptor desc, IMemento editorState) {
118
		this.manager = manager;
119
		initListenersAndHandlers();
120
		restoredInput = input;
121
		this.editorState = editorState;
122
		init(desc.getId(), desc.getLabel(),
123
				"", desc.getImageDescriptor(), desc.getLabel(), ""); //$NON-NLS-1$//$NON-NLS-2$
124
	}
125
    
126
    /**
127
	 * Constructs a new editor reference for use by editors being restored from
128
	 * a memento.
129
	 */
103
    EditorReference(EditorManager manager, IMemento memento) {
130
    EditorReference(EditorManager manager, IMemento memento) {
104
        this.manager = manager;
131
        this.manager = manager;
105
        initListenersAndHandlers();
132
        initListenersAndHandlers();
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java (-5 / +15 lines)
Lines 2467-2472 Link Here
2467
    public IEditorPart openEditor(final IEditorInput input,
2467
    public IEditorPart openEditor(final IEditorInput input,
2468
            final String editorID, final boolean activate, final int matchFlags)
2468
            final String editorID, final boolean activate, final int matchFlags)
2469
            throws PartInitException {
2469
            throws PartInitException {
2470
    	return openEditor(input, editorID, activate, matchFlags, null);
2471
    }
2472
	
2473
    /**
2474
     * This is not public API but for use internally.  editorState can be <code>null</code>.
2475
     */
2476
    public IEditorPart openEditor(final IEditorInput input,
2477
            final String editorID, final boolean activate, final int matchFlags,
2478
            final IMemento editorState)
2479
            throws PartInitException {
2470
        if (input == null || editorID == null) {
2480
        if (input == null || editorID == null) {
2471
            throw new IllegalArgumentException();
2481
            throw new IllegalArgumentException();
2472
        }
2482
        }
Lines 2478-2484 Link Here
2478
                    public void run() {
2488
                    public void run() {
2479
                        try {
2489
                        try {
2480
                            result[0] = busyOpenEditor(input, editorID,
2490
                            result[0] = busyOpenEditor(input, editorID,
2481
                                    activate, matchFlags);
2491
                                    activate, matchFlags, editorState);
2482
                        } catch (PartInitException e) {
2492
                        } catch (PartInitException e) {
2483
                            ex[0] = e;
2493
                            ex[0] = e;
2484
                        }
2494
                        }
Lines 2494-2507 Link Here
2494
     * @see #openEditor(IEditorInput, String, boolean, int)
2504
     * @see #openEditor(IEditorInput, String, boolean, int)
2495
	 */
2505
	 */
2496
    private IEditorPart busyOpenEditor(IEditorInput input, String editorID,
2506
    private IEditorPart busyOpenEditor(IEditorInput input, String editorID,
2497
            boolean activate, int matchFlags) throws PartInitException {
2507
            boolean activate, int matchFlags, IMemento editorState) throws PartInitException {
2498
2508
2499
        final Workbench workbench = (Workbench) getWorkbenchWindow()
2509
        final Workbench workbench = (Workbench) getWorkbenchWindow()
2500
                .getWorkbench();
2510
                .getWorkbench();
2501
        workbench.largeUpdateStart();
2511
        workbench.largeUpdateStart();
2502
2512
2503
        try {
2513
        try {
2504
            return busyOpenEditorBatched(input, editorID, activate, matchFlags);
2514
            return busyOpenEditorBatched(input, editorID, activate, matchFlags, editorState);
2505
2515
2506
        } finally {
2516
        } finally {
2507
            workbench.largeUpdateEnd();
2517
            workbench.largeUpdateEnd();
Lines 2514-2520 Link Here
2514
     * @see IWorkbenchPage#openEditor(IEditorInput, String, boolean)
2524
     * @see IWorkbenchPage#openEditor(IEditorInput, String, boolean)
2515
     */
2525
     */
2516
    private IEditorPart busyOpenEditorBatched(IEditorInput input,
2526
    private IEditorPart busyOpenEditorBatched(IEditorInput input,
2517
            String editorID, boolean activate,  int matchFlags) throws PartInitException {
2527
            String editorID, boolean activate,  int matchFlags, IMemento editorState) throws PartInitException {
2518
2528
2519
        // If an editor already exists for the input, use it.
2529
        // If an editor already exists for the input, use it.
2520
		IEditorPart editor = getEditorManager().findEditor(editorID, input, matchFlags);
2530
		IEditorPart editor = getEditorManager().findEditor(editorID, input, matchFlags);
Lines 2566-2572 Link Here
2566
        // Otherwise, create a new one. This may cause the new editor to
2576
        // Otherwise, create a new one. This may cause the new editor to
2567
        // become the visible (i.e top) editor.
2577
        // become the visible (i.e top) editor.
2568
        IEditorReference ref = null;
2578
        IEditorReference ref = null;
2569
        ref = getEditorManager().openEditor(editorID, input, true);
2579
        ref = getEditorManager().openEditor(editorID, input, true, editorState);
2570
        if (ref != null) {
2580
        if (ref != null) {
2571
            editor = ref.getEditor(true);
2581
            editor = ref.getEditor(true);
2572
        }
2582
        }

Return to bug 44295