Skip to main content
summaryrefslogtreecommitdiffstats
blob: dfb03e26942b5764b0eef7875c95bf6bdcfb88b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package org.eclipse.ui.tests.api;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.*;
import org.eclipse.ui.tests.util.*;

public class MockEditorPart extends MockWorkbenchPart implements IEditorPart {

	private static final String BASE = "org.eclipse.ui.tests.api.MockEditorPart";
	public static final String ID1 = BASE + "1";
	public static final String ID2 = BASE + "2";
	public static final String NAME = "Mock Editor 1";

	private IEditorInput input;
	private boolean dirty = false;
	private boolean saveNeeded = false;
	
	public MockEditorPart() {
		super();
	}
	
	/**
	 * @see IEditorPart#doSave(IProgressMonitor)
	 */
	public void doSave(IProgressMonitor monitor) {
		dirty = false;
		callTrace.add( "doSave" );
	}

	/**
	 * @see IEditorPart#doSaveAs()
	 */
	public void doSaveAs() {
	}

	/**
	 * @see IEditorPart#getEditorInput()
	 */
	public IEditorInput getEditorInput() {
		return input;
	}

	/**
	 * @see IEditorPart#getEditorSite()
	 */
	public IEditorSite getEditorSite() {
		return (IEditorSite)getSite();
	}

	/**
	 * @see IEditorPart#gotoMarker(IMarker)
	 */
	public void gotoMarker(IMarker marker) {
		callTrace.add( "gotoMarker" );	
	}

	/**
	 * @see IEditorPart#init(IEditorSite, IEditorInput)
	 */
	public void init(IEditorSite site, IEditorInput input)
		throws PartInitException {
		this.input = input;
		setSite(site);
		callTrace.add( "init" );
	}

	/**
	 * @see IEditorPart#isDirty()
	 */
	public boolean isDirty() {
		callTrace.add( "isDirty" );
		return dirty;
	}

	public void setDirty( boolean value )
	{
		dirty = value;	
	}

	/**
	 * @see IEditorPart#isSaveAsAllowed()
	 */
	public boolean isSaveAsAllowed() {
		return false;
	}

	/**
	 * @see IEditorPart#isSaveOnCloseNeeded()
	 */
	public boolean isSaveOnCloseNeeded() {
		callTrace.add( "isSaveOnCloseNeeded" );
		return saveNeeded;
	}
	
	public void setSaveNeeded( boolean value )
	{
		saveNeeded = value;
	}
}

Back to the top