Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1998481c8262bff0c6073884ae7f88464ea590c5 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*******************************************************************************
 * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal and others
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/ 
 * 
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors: 
 *    Alexander Shatalin (Borland) - initial API and implementation
 *    Michael Golubev (Montages) - #386838 - migrate to Xtend2
 *    Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
 *****************************************************************************/
package xpt.navigator

import com.google.inject.Inject
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenNavigator
import xpt.Common

@com.google.inject.Singleton class NavigatorGroup {
	@Inject extension Common;

	def className(GenNavigator it) '''«it.navigatorGroupClassName»'''

	def packageName(GenNavigator it) '''«it.packageName»'''

	def qualifiedClassName(GenNavigator it) '''«packageName(it)».«className(it)»'''

	def fullPath(GenNavigator it) '''«qualifiedClassName(it)»'''

	def extendsList(GenNavigator it) '''extends «getAbstractNavigatorItemQualifiedClassName()»'''

	def NavigatorGroup(GenNavigator it) '''
		«copyright(editorGen)»
		package «packageName(it)»;
		
		«generatedClassComment()»
		public class «className(it)» «extendsList(it)» {
		
			«attributes(it)»
		
			«constructor(it)»
			
			«getGroupName(it)»
			
			«getIcon(it)»
			
			«getChildren(it)»
			
			«addChildren(it)»
			
			«addChild(it)»
			
			«isEmpty(it)»
			
			«equals(it)»
			
			«hashCode(it)»
		
			«additions(it)»
		}
	'''

	def attributes(GenNavigator it) '''
		«generatedMemberComment()»
		private String myGroupName;
			
		«generatedMemberComment()»
		private String myIcon;
			
		«generatedMemberComment()»
		private java.util.Collection myChildren = new java.util.LinkedList();
	'''

	def constructor(GenNavigator it) '''
		«generatedMemberComment()»
		«className(it)»(String groupName, String icon, Object parent) {
			super(parent);
			myGroupName = groupName;
			myIcon = icon;
		}
	'''

	def getGroupName(GenNavigator it) '''
			«generatedMemberComment()»
		public String getGroupName() {
			return myGroupName;
		}
	'''

	def getIcon(GenNavigator it) '''
		«generatedMemberComment()»
		public String getIcon() {
			return myIcon;
		}
	'''

	def getChildren(GenNavigator it) '''
		«generatedMemberComment()»
		public Object[] getChildren() {
			return myChildren.toArray();
		}
	'''

	def addChildren(GenNavigator it) '''
		«generatedMemberComment()»
		public void addChildren(java.util.Collection children) {
			myChildren.addAll(children);
		}
	'''

	def addChild(GenNavigator it) '''
		«generatedMemberComment()»
		public void addChild(Object child) {
			myChildren.add(child);
		}
	'''

	def isEmpty(GenNavigator it) '''
		«generatedMemberComment()»
		public boolean isEmpty() {
			return myChildren.size() == 0;
		}
	'''

	def equals(GenNavigator it) '''
		«generatedMemberComment()»
		public boolean equals(Object obj) {
			if (obj instanceof «qualifiedClassName(it)») {
				«qualifiedClassName(it)» anotherGroup = («qualifiedClassName(it)») obj;
				if (getGroupName().equals(anotherGroup.getGroupName())) {
					return getParent().equals(anotherGroup.getParent());
				}
			}
			return super.equals(obj);
		}
	'''

	def hashCode(GenNavigator it) '''
		«generatedMemberComment()»
		public int hashCode() {
			return getGroupName().hashCode();
		}
	'''

	def additions(GenNavigator it) ''''''

}

Back to the top