Révision 569
| tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 569) | ||
|---|---|---|
| 93 | 93 |
*/ |
| 94 | 94 |
protected HashMap<String, Object> lastComputingParameters = new HashMap<String, Object>(); |
| 95 | 95 |
|
| 96 |
public HashMap<String, Object> getLastComputingParameters() {
|
|
| 97 |
return lastComputingParameters; |
|
| 98 |
} |
|
| 96 | 99 |
|
| 97 | 100 |
/** |
| 98 | 101 |
* Creates a new TXMResult, child of the specified parent. |
| ... | ... | |
| 165 | 168 |
} |
| 166 | 169 |
} |
| 167 | 170 |
|
| 171 |
protected Object getParameterForKey(String key) {
|
|
| 172 |
Field[] fields = this.getClass().getDeclaredFields(); |
|
| 173 |
for (Field f : fields) {
|
|
| 174 |
Parameter parameter = f.getAnnotation(Parameter.class); |
|
| 175 |
if (parameter == null || parameter.type() != Parameter.COMPUTING) {
|
|
| 176 |
continue; |
|
| 177 |
} |
|
| 178 |
f.setAccessible(true); |
|
| 179 |
if (parameter.key().equals(key)) {
|
|
| 180 |
try {
|
|
| 181 |
return f.get(this); |
|
| 182 |
} catch (Exception e) {
|
|
| 183 |
e.printStackTrace(); |
|
| 184 |
} |
|
| 185 |
} |
|
| 186 |
} |
|
| 187 |
return null; |
|
| 188 |
} |
|
| 189 |
|
|
| 190 |
protected boolean hasParameterChanged(String key) {
|
|
| 191 |
if ("".equals(key)) {
|
|
| 192 |
return false; |
|
| 193 |
} |
|
| 194 |
Object o = lastComputingParameters.get(key); |
|
| 195 |
Object newValue = getParameterForKey(key); |
|
| 196 |
if (o == null && newValue != null) {
|
|
| 197 |
return true; |
|
| 198 |
} else {
|
|
| 199 |
return o.equals(newValue); |
|
| 200 |
} |
|
| 201 |
} |
|
| 202 |
|
|
| 168 | 203 |
/** |
| 169 | 204 |
* Updates the dirty states by comparing TXMResult @Parameter with previously used parameters in the compute() method. |
| 170 | 205 |
* |
| tmp/org.txm.core/src/java/org/txm/core/results/Parameter.java (revision 569) | ||
|---|---|---|
| 21 | 21 |
public final int COMPUTING = 0, RENDERING = 1; |
| 22 | 22 |
|
| 23 | 23 |
// FIXME: could be used to automate saveParameters(), loadParameters(), etc. for accessing the preferences node value of a key in TXMResult class |
| 24 |
//public String preferenceName() default "";
|
|
| 24 |
public String key() default "";
|
|
| 25 | 25 |
|
| 26 | 26 |
|
| 27 | 27 |
public int type() default Parameter.COMPUTING; |
Formats disponibles : Unified diff