Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: bb301453d41189174e43ecc799ec8bfac62a579f (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
151
152
153
154
155
156
157
158
159
/*******************************************************************************
 * Copyright (c) 2010 protos software gmbh (http://www.protos.de).
 * 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:
 * 		Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
 * 
 *******************************************************************************/

package org.eclipse.etrice.core.ui.outline;

import java.util.Collections;
import java.util.List;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.ui.editor.outline.ContentOutlineNode;
import org.eclipse.xtext.ui.editor.outline.transformer.AbstractDeclarativeSemanticModelTransformer;

import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.ActorRef;
import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.Message;
import org.eclipse.etrice.core.room.Operation;
import org.eclipse.etrice.core.room.Port;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.SAPRef;
import org.eclipse.etrice.core.room.SPPRef;
import org.eclipse.etrice.core.room.ServiceImplementation;
import org.eclipse.etrice.core.room.State;

/**
 * customization of the default outline structure
 * 
 */
public class RoomTransformer extends AbstractDeclarativeSemanticModelTransformer {
	// cf. org.eclipse.xtext.example.ui.outline.FowlerDslTransformer

	// transform actor class
	
	public boolean consumeNode(ActorClass ac) {
		return true;
	}

	public ContentOutlineNode createNode(ActorClass ac, ContentOutlineNode outlineParentNode) {
		ContentOutlineNode result = super.createNode(ac, outlineParentNode);
		if (ac.getIfPorts().size()>0 || ac.getIfSPPs().size()>0) {
			ContentOutlineNode iface = new ContentOutlineNode("Interface");
			result.getChildren().add(iface);
			for (Port port : ac.getIfPorts())
				transformSemanticNode(port, iface);
			for (SPPRef spp : ac.getIfSPPs())
				transformSemanticNode(spp, iface);
		}
		if (ac.getIntPorts().size()>0 || ac.getServiceImplementations().size()>0 ||
				ac.getStrSAPs().size()>0 || ac.getAttributes().size()>0 ||
				ac.getActorRefs().size()>0) {
			ContentOutlineNode structure = new ContentOutlineNode("Structure");
			result.getChildren().add(structure);
			for (Port port : ac.getIntPorts())
				transformSemanticNode(port, structure);
			for (ServiceImplementation svc : ac.getServiceImplementations())
				transformSemanticNode(svc, structure);
			for (SAPRef sap : ac.getStrSAPs())
				transformSemanticNode(sap, structure);
			for (Attribute attr : ac.getAttributes())
				transformSemanticNode(attr, structure);
			for (ActorRef ar : ac.getActorRefs())
				transformSemanticNode(ar, structure);
		}
		if (ac.getOperations().size()>0 || ac.getStateMachine()!=null) {
			ContentOutlineNode behavior = new ContentOutlineNode("Behavior");
			result.getChildren().add(behavior);
			for (Operation op : ac.getOperations())
				transformSemanticNode(op, behavior);
			if (ac.getStateMachine()!=null) {
				ContentOutlineNode sm = new ContentOutlineNode("StateMachine");
				behavior.getChildren().add(sm);
				for (State s : ac.getStateMachine().getStates()) {
					transformSemanticNode(s, sm);
				}
			}
		}
		return result;
	}

	public List<EObject> getChildren(ActorClass ac) {
		return Collections.emptyList();
	}

	// transform state
	
	public boolean consumeNode(State state) {
		return true;
	}

	public ContentOutlineNode createNode(State state, ContentOutlineNode outlineParentNode) {
		ContentOutlineNode result = super.createNode(state, outlineParentNode);
		
		if (state.getSubgraph()!=null)
			for (State s : state.getSubgraph().getStates()) {
				transformSemanticNode(s, result);
			}
		
		return result;
	}

	public List<EObject> getChildren(State state) {
		return Collections.emptyList();
	}
	
	// transform protocol
	
	public boolean consumeNode(ProtocolClass pc) {
		return true;
	}

	public ContentOutlineNode createNode(ProtocolClass pc, ContentOutlineNode outlineParentNode) {
		ContentOutlineNode result = super.createNode(pc, outlineParentNode);
		
		if (pc.getIncomingMessages().size()>0) {
			ContentOutlineNode msgs = new ContentOutlineNode("incoming");
			result.getChildren().add(msgs);
			for (Message m : pc.getIncomingMessages())
				transformSemanticNode(m, msgs);
		}
		
		if (pc.getOutgoingMessages().size()>0) {
			ContentOutlineNode msgs = new ContentOutlineNode("outgoing");
			result.getChildren().add(msgs);
			for (Message m : pc.getOutgoingMessages())
				transformSemanticNode(m, msgs);
		}
		
		return result;
	}

	public List<EObject> getChildren(ProtocolClass pc) {
		return Collections.emptyList();
	}
	
	public boolean consumeNode(Message m) {
		return true;
	}

	public List<EObject> getChildren(Message m) {
		return Collections.emptyList();
	}
	
	public boolean consumeNode(Operation op) {
		return true;
	}

	public List<EObject> getChildren(Operation op) {
		return Collections.emptyList();
	}
}

Back to the top