Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b2b938e1685d42e680911bd7aaf916147dd89381 (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
102
103
104
105
106
107
108
109
110
111
112
/*
 * Copyright (c) 2007 Borland Software Corporation
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Dmitry Stadnik (Borland) - initial API and implementation
 */

«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»

«EXTENSION xpt::editor::Utils»

«DEFINE className FOR gmfgen::GenDiagram»ValidationMarker«ENDDEFINE»

«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«editorGen.editor.packageName».«EXPAND className»«ENDDEFINE»

«DEFINE ValidationMarker FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::copyright FOR editorGen-»
package «editorGen.editor.packageName»;

«EXPAND xpt::Common::generatedClassComment»
public class «EXPAND className» {

	«EXPAND xpt::Common::generatedMemberComment»
	private static final String KEY = "validation_marker"; //$NON-NLS-1$

	«EXPAND xpt::Common::generatedMemberComment»
	public static final «EXPAND className»[] EMPTY_ARRAY = new «EXPAND className»[0];

	«EXPAND xpt::Common::generatedMemberComment»
	private final String location;

	«EXPAND xpt::Common::generatedMemberComment»
	private final String message;

	«EXPAND xpt::Common::generatedMemberComment»
	private final int statusSeverity;

	«EXPAND xpt::Common::generatedMemberComment»
	public «EXPAND className»(String location, String message, int statusSeverity) {
		this.location = location;
		this.message = message;
		this.statusSeverity = statusSeverity;
	}

	«EXPAND xpt::Common::generatedMemberComment»
	public String getLocation() {
		return location;
	}

	«EXPAND xpt::Common::generatedMemberComment»
	public String getMessage() {
		return message;
	}

	«EXPAND xpt::Common::generatedMemberComment»
	public int getStatusSeverity() {
		return statusSeverity;	
	}

	«EXPAND xpt::Common::generatedMemberComment»
	private static java.util.Map getMarkers(org.eclipse.gef.EditPartViewer viewer) {
		java.util.Map markers = (java.util.Map) viewer.getProperty(KEY);
		if (markers == null) {
			markers = new java.util.HashMap();
			viewer.setProperty(KEY, markers);
		}
		return markers;
	}

	«EXPAND xpt::Common::generatedMemberComment»
	private static java.util.Set getMarkers(org.eclipse.gef.EditPartViewer viewer, String viewId, boolean create) {
		java.util.Set markers = (java.util.Set) getMarkers(viewer).get(viewId);
		if (markers == null) {
			if (!create) {
				return java.util.Collections.EMPTY_SET;
			}
			markers = new java.util.HashSet();
			getMarkers(viewer).put(viewId, markers);
		}
		return markers;
	}

	«EXPAND xpt::Common::generatedMemberComment»
	public static «EXPAND className»[] getMarkers(org.eclipse.gef.EditPartViewer viewer, String viewId) {
		java.util.Set markers = getMarkers(viewer, viewId, false);
		if (markers.isEmpty()) {
			return EMPTY_ARRAY;
		}
		return («EXPAND className»[]) markers.toArray(new «EXPAND className»[markers.size()]);
	}

	«EXPAND xpt::Common::generatedMemberComment»
	public static void removeAllMarkers(org.eclipse.gef.EditPartViewer viewer) {
		getMarkers(viewer).clear();
	}

	«EXPAND xpt::Common::generatedMemberComment»
	public void add(org.eclipse.gef.EditPartViewer viewer, String viewId) {
		getMarkers(viewer, viewId, true).add(this);
	}
	«EXPAND additions-»
}
«ENDDEFINE»

«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»

Back to the top