41
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
* Delegate to configuration of the view
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
package com.nokia.tracecompiler.engine;
|
|
20 |
|
|
21 |
import java.util.ArrayList;
|
|
22 |
|
|
23 |
/**
|
|
24 |
* Delegate to configuration of the view
|
|
25 |
*
|
|
26 |
*/
|
|
27 |
final class ConfigurationDelegate implements TraceCompilerEngineConfiguration {
|
|
28 |
|
|
29 |
/**
|
|
30 |
* Configuration from view
|
|
31 |
*/
|
|
32 |
private TraceCompilerEngineConfiguration configuration;
|
|
33 |
|
|
34 |
/**
|
|
35 |
* Temporary list of configuration listeners
|
|
36 |
*/
|
|
37 |
private ArrayList<TraceCompilerEngineConfigurationListener> tempListeners;
|
|
38 |
|
|
39 |
/**
|
|
40 |
* Sets the configuration delegate
|
|
41 |
*
|
|
42 |
* @param configuration
|
|
43 |
* the configuration
|
|
44 |
*/
|
|
45 |
void setConfiguration(TraceCompilerEngineConfiguration configuration) {
|
|
46 |
this.configuration = configuration;
|
|
47 |
if (configuration != null && tempListeners != null) {
|
|
48 |
for (int i = 0; i < tempListeners.size(); i++) {
|
|
49 |
TraceCompilerEngineConfigurationListener listener = tempListeners
|
|
50 |
.get(i);
|
|
51 |
configuration.addConfigurationListener(listener);
|
|
52 |
listener.configurationCreated();
|
|
53 |
}
|
|
54 |
tempListeners.clear();
|
|
55 |
}
|
|
56 |
}
|
|
57 |
|
|
58 |
/*
|
|
59 |
* (non-Javadoc)
|
|
60 |
*
|
|
61 |
* @see com.nokia.tracecompiler.engine.TraceCompilerConfiguration#isAvailable()
|
|
62 |
*/
|
|
63 |
public boolean isAvailable() {
|
|
64 |
boolean retval;
|
|
65 |
if (configuration != null) {
|
|
66 |
retval = configuration.isAvailable();
|
|
67 |
} else {
|
|
68 |
retval = false;
|
|
69 |
}
|
|
70 |
return retval;
|
|
71 |
}
|
|
72 |
|
|
73 |
/*
|
|
74 |
* (non-Javadoc)
|
|
75 |
*
|
|
76 |
* @see com.nokia.tracecompiler.engine.TraceCompilerConfiguration#
|
|
77 |
* addConfigurationListener(com.nokia.tracecompiler.engine.TraceCompilerConfigurationListener)
|
|
78 |
*/
|
|
79 |
public void addConfigurationListener(
|
|
80 |
TraceCompilerEngineConfigurationListener configurationListener) {
|
|
81 |
if (configuration != null) {
|
|
82 |
configuration.addConfigurationListener(configurationListener);
|
|
83 |
} else {
|
|
84 |
if (tempListeners == null) {
|
|
85 |
tempListeners = new ArrayList<TraceCompilerEngineConfigurationListener>();
|
|
86 |
}
|
|
87 |
tempListeners.add(configurationListener);
|
|
88 |
}
|
|
89 |
}
|
|
90 |
|
|
91 |
/*
|
|
92 |
* (non-Javadoc)
|
|
93 |
*
|
|
94 |
* @see com.nokia.tracecompiler.engine.TraceCompilerConfiguration#
|
|
95 |
* removeConfigurationListener(com.nokia.tracecompiler.engine.TraceCompilerConfigurationListener)
|
|
96 |
*/
|
|
97 |
public void removeConfigurationListener(
|
|
98 |
TraceCompilerEngineConfigurationListener configurationListener) {
|
|
99 |
if (configuration != null) {
|
|
100 |
configuration.removeConfigurationListener(configurationListener);
|
|
101 |
} else {
|
|
102 |
if (tempListeners != null) {
|
|
103 |
tempListeners.remove(configurationListener);
|
|
104 |
}
|
|
105 |
}
|
|
106 |
}
|
|
107 |
|
|
108 |
/*
|
|
109 |
* (non-Javadoc)
|
|
110 |
*
|
|
111 |
* @see com.nokia.tracecompiler.engine.TraceCompilerConfiguration#getFlag(java.lang.String)
|
|
112 |
*/
|
|
113 |
public boolean getFlag(String flagName) {
|
|
114 |
boolean retval;
|
|
115 |
if (configuration != null) {
|
|
116 |
retval = configuration.getFlag(flagName);
|
|
117 |
} else {
|
|
118 |
retval = false;
|
|
119 |
}
|
|
120 |
return retval;
|
|
121 |
}
|
|
122 |
|
|
123 |
/*
|
|
124 |
* (non-Javadoc)
|
|
125 |
*
|
|
126 |
* @see com.nokia.tracecompiler.engine.TraceCompilerConfiguration#getText(java.lang.String)
|
|
127 |
*/
|
|
128 |
public String getText(String textName) {
|
|
129 |
String retval;
|
|
130 |
if (configuration != null) {
|
|
131 |
retval = configuration.getText(textName);
|
|
132 |
} else {
|
|
133 |
retval = ""; //$NON-NLS-1$
|
|
134 |
}
|
|
135 |
return retval;
|
|
136 |
}
|
|
137 |
|
|
138 |
/*
|
|
139 |
* (non-Javadoc)
|
|
140 |
*
|
|
141 |
* @see com.nokia.tracecompiler.engine.TraceCompilerConfiguration#getValue(java.lang.String)
|
|
142 |
*/
|
|
143 |
public int getValue(String valueName) {
|
|
144 |
int retval;
|
|
145 |
if (configuration != null) {
|
|
146 |
retval = configuration.getValue(valueName);
|
|
147 |
} else {
|
|
148 |
retval = 0;
|
|
149 |
}
|
|
150 |
return retval;
|
|
151 |
}
|
|
152 |
|
|
153 |
/*
|
|
154 |
* (non-Javadoc)
|
|
155 |
*
|
|
156 |
* @see com.nokia.tracecompiler.engine.TraceCompilerConfiguration#hasEntry(java.lang.String)
|
|
157 |
*/
|
|
158 |
public boolean hasEntry(String entryName) {
|
|
159 |
boolean retval;
|
|
160 |
if (configuration != null) {
|
|
161 |
retval = configuration.hasEntry(entryName);
|
|
162 |
} else {
|
|
163 |
retval = false;
|
|
164 |
}
|
|
165 |
return retval;
|
|
166 |
}
|
|
167 |
|
|
168 |
/*
|
|
169 |
* (non-Javadoc)
|
|
170 |
*
|
|
171 |
* @see com.nokia.tracecompiler.engine.TraceCompilerConfiguration#
|
|
172 |
* setFlag(java.lang.String, boolean)
|
|
173 |
*/
|
|
174 |
public void setFlag(String flagName, boolean flag) {
|
|
175 |
if (configuration != null) {
|
|
176 |
configuration.setFlag(flagName, flag);
|
|
177 |
}
|
|
178 |
}
|
|
179 |
|
|
180 |
/*
|
|
181 |
* (non-Javadoc)
|
|
182 |
*
|
|
183 |
* @see com.nokia.tracecompiler.engine.TraceCompilerConfiguration#
|
|
184 |
* setText(java.lang.String, java.lang.String)
|
|
185 |
*/
|
|
186 |
public void setText(String textName, String text) {
|
|
187 |
if (configuration != null) {
|
|
188 |
configuration.setText(textName, text);
|
|
189 |
}
|
|
190 |
}
|
|
191 |
|
|
192 |
/*
|
|
193 |
* (non-Javadoc)
|
|
194 |
*
|
|
195 |
* @see com.nokia.tracecompiler.engine.TraceCompilerConfiguration#setValue(java.lang.String,
|
|
196 |
* int)
|
|
197 |
*/
|
|
198 |
public void setValue(String valueName, int value) {
|
|
199 |
if (configuration != null) {
|
|
200 |
configuration.setValue(valueName, value);
|
|
201 |
}
|
|
202 |
}
|
|
203 |
|
|
204 |
}
|