Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a9911c4e0fdb61d9a0a6b63e44fe04e120716578 (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
/*******************************************************************************
 * Copyright (c) 2012 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:
 * 		Henrik Rentz-Reichert (initial contribution)
 *
 *******************************************************************************/

package org.eclipse.etrice.generator.base;

import java.util.List;

import org.eclipse.etrice.core.fsm.fSM.AbstractInterfaceItem;
import org.eclipse.etrice.core.fsm.fSM.DetailCode;
import org.eclipse.etrice.core.naming.RoomNameProvider;
import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.EnumLiteral;
import org.eclipse.etrice.core.room.EnumerationType;
import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.Message;
import org.eclipse.etrice.core.room.Operation;
import org.eclipse.etrice.core.room.PortOperation;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.generator.fsm.base.DefaultFSMTranslationProvider;

import com.google.inject.Inject;

/**
 * A default implementation of an {@link ITranslationProvider}.
 *
 * @author Henrik Rentz-Reichert
 *
 */
public class DefaultTranslationProvider extends DefaultFSMTranslationProvider implements ITranslationProvider {

	/**
	 * the name provider for model objects
	 */
	@Inject
	protected RoomNameProvider roomNameProvider;

	/**
	 * utility methods
	 */
	@Inject
	protected RoomHelpers roomHelpers;

	/**
	 * @return the original String
	 * @see org.eclipse.etrice.generator.base.ITranslationProvider#getAttributeGetter(org.eclipse.etrice.core.room.Attribute, java.lang.String, java.lang.String)
	 */
	@Override
	public String getAttributeGetter(Attribute att, String index, String orig) {
		return orig;
	}

	/**
	 * @return the original String
	 * @see org.eclipse.etrice.generator.base.ITranslationProvider#getAttributeSetter(org.eclipse.etrice.core.room.Attribute, java.lang.String, java.lang.String, java.lang.String)
	 */
	@Override
	public String getAttributeSetter(Attribute att, String index, String value, String orig) {
		return orig;
	}

	/**
	 * @return the original String
	 * @see org.eclipse.etrice.generator.base.ITranslationProvider#getOperationText(org.eclipse.etrice.core.room.Operation, java.util.ArrayList, java.lang.String)
	 */
	@Override
	public String getOperationText(Operation op, List<String> args, String orig) {
		return orig;
	}

	/**
	 * @return the original String
	 * @see org.eclipse.etrice.generator.base.ITranslationProvider#getInterfaceItemMessageValue(org.eclipse.etrice.core.room.InterfaceItem, org.eclipse.etrice.core.room.Message, java.lang.String)
	 */
	@Override
	public String getInterfaceItemMessageValue(InterfaceItem item, Message msg, String orig) {
		return orig;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.etrice.generator.fsm.base.DefaultFSMTranslationProvider#translateTag(java.lang.String, org.eclipse.etrice.core.fsm.fSM.DetailCode)
	 */
	@Override
	public String translateTag(String tag, DetailCode code) {
		if (tag.equals("MODEL_LOCATION")) {
			return roomNameProvider.getDetailCodeLocation(code);
		}

		logger.logInfo("unrecognized tag '"+tag+"' in "
				+roomNameProvider.getDetailCodeLocation(code)+" of "
				+roomNameProvider.getClassLocation(roomHelpers.getRoomClass(code)));

		return super.translateTag(tag, code);
	}
	/* (non-Javadoc)
	 * @see org.eclipse.etrice.generator.base.ITranslationProvider#translateEnums()
	 */
	@Override
	public boolean translateEnums() {
		return false;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.etrice.generator.base.ITranslationProvider#getEnumText(org.eclipse.etrice.core.room.EnumLiteral)
	 */
	@Override
	public String getEnumText(EnumLiteral literal) {
		EnumerationType et = (EnumerationType) literal.eContainer();
		return et.getName()+"."+literal.getName();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.etrice.generator.base.ITranslationProvider#getInterfaceItemOperationText(org.eclipse.etrice.core.fsm.fSM.AbstractInterfaceItem, org.eclipse.etrice.core.room.PortOperation, java.util.ArrayList, java.lang.String)
	 */
	@Override
	public String getInterfaceItemOperationText(AbstractInterfaceItem item,
			PortOperation op, List<String> args, String orig) {
		return orig;
	}

}

Back to the top