Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 7d9cb69db0717b065370e97da8e40230e206cea2 (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
/**
 *
 */
package org.eclipse.papyrus.infra.core.sasheditor.internal;

import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage;


/**
 * A visitor used to lookup a PagePart from its raw model.
 *
 * @author cedric dumoulin
 *
 */
public class LookupModelPageVisitor extends PartVisitor {

	private Object rawModel;

	private IPage result;


	public LookupModelPageVisitor(Object rawModel) {
		this.rawModel = rawModel;
	}

	/**
	 * Get the result of the lookup.
	 *
	 * @return
	 */
	public IPage result() {
		return result;
	}

	/**
	 * Check if the part is for the specified rawModel.
	 *
	 * @param part
	 * @return
	 */
	private boolean isModelFor(PagePart part) {

		if (part.getRawModel() == rawModel) {
			result = part;
			return true;
		}
		// stop looking
		return false;
	}

	/**
	 * Check if it is this Component
	 */
	@Override
	protected boolean acceptEditorTile(ComponentPart part) {
		if (isModelFor(part)) {
			return false;
		}

		// Continue looking
		return true;
	}

	/**
	 * Check if it is this IEditor
	 */
	@Override
	protected boolean acceptEditorTile(EditorPart part) {
		if (isModelFor(part)) {
			return false;
		}

		// Continue looking
		return true;
	}

}

Back to the top