Révision 1403
tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 1403) | ||
---|---|---|
1566 | 1566 |
|
1567 | 1567 |
/** |
1568 | 1568 |
* Clones nodes. Creates a local node for the destination result and copy it all the source result parameters. |
1569 |
* @param srcResult |
|
1570 |
* @param dstResult |
|
1569 |
* @param srcResult node path
|
|
1570 |
* @param dstResult node path
|
|
1571 | 1571 |
*/ |
1572 |
public static void cloneNode(TXMResult srcResult, TXMResult dstResult) { |
|
1573 |
Preferences preferences = preferencesRootNode.node(srcResult.getParametersNodePath()); |
|
1574 |
if(preferences != null) { |
|
1572 |
public static void cloneNode(String srcResult, String dstResult) { |
|
1573 |
Preferences preferences = preferencesRootNode.node(srcResult); |
|
1574 |
Preferences dstPreferences = preferencesRootNode.node(dstResult); |
|
1575 |
if (preferences != null) { |
|
1575 | 1576 |
try { |
1576 |
String[] keys = preferences.keys(); |
|
1577 |
for(int i = 0; i < keys.length; i++) { |
|
1578 |
dstResult.saveParameter(keys[i], preferences.get(keys[i], "")); |
|
1577 |
for(String key : preferences.keys()) { |
|
1578 |
dstPreferences.put(key, preferences.get(key, "")); |
|
1579 | 1579 |
} |
1580 | 1580 |
} |
1581 | 1581 |
catch(BackingStoreException e) { |
... | ... | |
1584 | 1584 |
} |
1585 | 1585 |
} |
1586 | 1586 |
} |
1587 |
|
|
1588 |
/** |
|
1589 |
* Clones nodes. Creates a local node for the destination result and copy it all the source result parameters. |
|
1590 |
* @param srcResult |
|
1591 |
* @param dstResult |
|
1592 |
*/ |
|
1593 |
public static void cloneNode(TXMResult srcResult, TXMResult dstResult) { |
|
1594 |
cloneNode(srcResult.getParametersNodePath(), dstResult.getParametersNodePath()); |
|
1595 |
} |
|
1587 | 1596 |
|
1588 | 1597 |
|
1589 | 1598 |
|
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1403) | ||
---|---|---|
21 | 21 |
import org.apache.commons.lang.StringUtils; |
22 | 22 |
import org.eclipse.core.runtime.IProgressMonitor; |
23 | 23 |
import org.eclipse.core.runtime.preferences.DefaultScope; |
24 |
import org.eclipse.osgi.util.NLS; |
|
24 | 25 |
import org.osgi.framework.FrameworkUtil; |
25 | 26 |
import org.osgi.service.prefs.BackingStoreException; |
26 | 27 |
import org.txm.Toolbox; |
... | ... | |
1798 | 1799 |
public abstract void clean(); |
1799 | 1800 |
|
1800 | 1801 |
@Override |
1801 |
public Object clone() { |
|
1802 |
public TXMResult clone() { |
|
1803 |
return clone(null, true); |
|
1804 |
} |
|
1805 |
|
|
1806 |
public TXMResult clone(boolean all) { |
|
1807 |
return clone(null, all); |
|
1808 |
} |
|
1809 |
/** |
|
1810 |
* recursive method to clone a result |
|
1811 |
* @param newParent necessary for cloning children in the right clone parent |
|
1812 |
* @param all |
|
1813 |
* @return |
|
1814 |
*/ |
|
1815 |
protected TXMResult clone(TXMResult newParent, boolean all) { |
|
1802 | 1816 |
TXMResult clone = null; |
1803 | 1817 |
try { |
1804 |
clone = (TXMResult) super.clone(); |
|
1805 |
clone.parametersNodePath = this.getProject().getParametersNodeRootPath()+ createUUID() + "_" + this.getClass().getSimpleName(); //$NON-NLS-1$; |
|
1806 |
this.parent.addChild(clone); |
|
1807 |
TXMPreferences.cloneNode(this, clone); |
|
1808 |
clone.dirty = true; |
|
1818 |
String newNodePath = this.getProject().getParametersNodeRootPath()+ createUUID() + "_" + this.getClass().getSimpleName(); |
|
1819 |
TXMPreferences.cloneNode(this.getParametersNodePath(), newNodePath); |
|
1820 |
|
|
1821 |
if (newParent != null) { // change the cloned node parent preference |
|
1822 |
TXMPreferences.put(newNodePath, TXMPreferences.PARENT_PARAMETERS_NODE_PATH, newParent.getParametersNodePath()); |
|
1823 |
} |
|
1824 |
clone = this.getClass().getDeclaredConstructor(String.class).newInstance(newNodePath); |
|
1825 |
|
|
1826 |
if (all) { |
|
1827 |
for (TXMResult child : this.children) { |
|
1828 |
child.clone(clone, all); |
|
1829 |
} |
|
1830 |
} |
|
1809 | 1831 |
} catch (Exception e) { |
1832 |
System.out.println(NLS.bind("Fail to clone {0}: {1}", this, e)); |
|
1810 | 1833 |
Log.printStackTrace(e); |
1811 | 1834 |
} |
1812 | 1835 |
return clone; |
tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/results/ChartResult.java (revision 1403) | ||
---|---|---|
24 | 24 |
*/ |
25 | 25 |
public abstract class ChartResult extends TXMResult { |
26 | 26 |
|
27 |
|
|
27 |
|
|
28 | 28 |
/** |
29 | 29 |
* Linked charts engine. |
30 | 30 |
*/ |
31 | 31 |
protected ChartsEngine chartsEngine; |
32 |
|
|
32 |
|
|
33 | 33 |
/** |
34 | 34 |
* The chart object. |
35 | 35 |
*/ |
36 | 36 |
protected Object chart; |
37 |
|
|
37 |
|
|
38 | 38 |
/** |
39 | 39 |
* The chart dirty state. |
40 | 40 |
*/ |
41 | 41 |
protected boolean chartDirty; |
42 |
|
|
42 |
|
|
43 | 43 |
/** |
44 | 44 |
* If true, the view (zoom, pan, etc.) will be reset when the chart will be updated. |
45 | 45 |
*/ |
46 | 46 |
protected boolean needsToResetView; |
47 |
|
|
47 |
|
|
48 | 48 |
/** |
49 | 49 |
* If true, the items selection will cleared when the chart will be updated. |
50 | 50 |
*/ |
51 | 51 |
protected boolean needsToClearItemsSelection; |
52 | 52 |
|
53 |
|
|
54 |
|
|
55 | 53 |
|
54 |
|
|
55 |
|
|
56 | 56 |
/** |
57 | 57 |
* The chart type; |
58 | 58 |
*/ |
59 | 59 |
@Parameter(key=ChartsEnginePreferences.CHART_TYPE, type=Parameter.RENDERING) |
60 | 60 |
protected String chartType; |
61 |
|
|
62 |
|
|
61 |
|
|
62 |
|
|
63 | 63 |
/** |
64 | 64 |
* To show/hide title. |
65 | 65 |
*/ |
66 | 66 |
@Parameter(key=ChartsEnginePreferences.SHOW_TITLE, type=Parameter.RENDERING) |
67 | 67 |
protected boolean titleVisible; |
68 |
|
|
68 |
|
|
69 | 69 |
/** |
70 | 70 |
* To show/hide legend. |
71 | 71 |
*/ |
... | ... | |
83 | 83 |
*/ |
84 | 84 |
@Parameter(key=ChartsEnginePreferences.RENDERING_COLORS_MODE, type=Parameter.RENDERING) |
85 | 85 |
protected int renderingColorsMode; |
86 |
|
|
86 |
|
|
87 | 87 |
/** |
88 | 88 |
* Font. |
89 | 89 |
*/ |
90 | 90 |
@Parameter(key=ChartsEnginePreferences.FONT, type=Parameter.RENDERING) |
91 | 91 |
protected String font; |
92 | 92 |
|
93 |
|
|
93 |
|
|
94 | 94 |
/** |
95 | 95 |
* Multiple lines styles/strokes. |
96 | 96 |
*/ |
97 | 97 |
@Parameter(key=ChartsEnginePreferences.MULTIPLE_LINE_STROKES, type=Parameter.RENDERING) |
98 | 98 |
protected boolean multipleLineStrokes; |
99 |
|
|
100 |
|
|
101 | 99 |
|
102 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 | 103 |
/** |
104 | 104 |
* Creates a new ChartResult child of the specified parent. |
105 | 105 |
* @param parent |
... | ... | |
107 | 107 |
public ChartResult(TXMResult parent) { |
108 | 108 |
this(null, parent); |
109 | 109 |
} |
110 |
|
|
111 |
|
|
110 |
|
|
111 |
|
|
112 | 112 |
/** |
113 | 113 |
* Creates a new ChartResult with no parent. |
114 | 114 |
* If a local node exist with the parent_uuid, the parent will be retrieved and this result will be added to it. |
... | ... | |
117 | 117 |
public ChartResult(String parametersNodePath) { |
118 | 118 |
this(parametersNodePath, null); |
119 | 119 |
} |
120 |
|
|
120 |
|
|
121 | 121 |
/** |
122 | 122 |
* Creates a new ChartResult child of the specified parent. |
123 | 123 |
* @param uuid |
... | ... | |
130 | 130 |
this.needsToResetView = false; |
131 | 131 |
this.needsToClearItemsSelection = false; |
132 | 132 |
} |
133 |
|
|
134 |
|
|
133 |
|
|
134 |
|
|
135 | 135 |
@Override |
136 | 136 |
protected boolean autoLoadParametersFromAnnotations() throws Exception { |
137 | 137 |
return (super.autoLoadParametersFromAnnotations() |
... | ... | |
175 | 175 |
return false; |
176 | 176 |
} |
177 | 177 |
} |
178 |
|
|
178 |
|
|
179 | 179 |
/** |
180 | 180 |
* Renders the chart using the right chart creator. |
181 | 181 |
* The chart is created if needed then it is updated. |
... | ... | |
198 | 198 |
return true; |
199 | 199 |
} |
200 | 200 |
|
201 |
|
|
201 |
|
|
202 | 202 |
ChartCreator chartCreator = this.getChartCreator(); |
203 |
|
|
203 |
|
|
204 | 204 |
// try to find a chart creator in other charts engines |
205 | 205 |
if(chartCreator == null) { |
206 | 206 |
for (int i = 0; i < ChartsEngine.getChartsEngines().size(); i++) { |
... | ... | |
215 | 215 |
} |
216 | 216 |
} |
217 | 217 |
} |
218 |
|
|
219 |
|
|
218 |
|
|
219 |
|
|
220 | 220 |
if(chartCreator != null) { |
221 |
|
|
221 |
|
|
222 | 222 |
// FIXME: fix #1 |
223 | 223 |
// FIXME: SJ: without this, this.hasParameterChanged(ChartsEnginePreferences.CHART_TYPE) returns true for results that added their computing parameters in the parameter history. |
224 | 224 |
// Since the stack is shared by computing and rendering parameters, this.hasParameterChanged(ChartsEnginePreferences.CHART_TYPE) returns true because the parameter doesn't exist in the last stack entry filled only with the computing parameter |
... | ... | |
238 | 238 |
//(this.getLastParametersFromHistory().get(ChartsEnginePreferences.CHART_TYPE) != null && |
239 | 239 |
this.hasParameterChanged(ChartsEnginePreferences.CHART_TYPE) |
240 | 240 |
//) |
241 |
|
|
241 |
|
|
242 | 242 |
) { |
243 | 243 |
Log.finest("+++ ChartResult.renderChart(): creating chart."); //$NON-NLS-1$ |
244 | 244 |
|
245 | 245 |
this.chart = chartCreator.createChart(this); |
246 | 246 |
} |
247 |
|
|
247 |
|
|
248 | 248 |
// Updating |
249 | 249 |
Log.finest("ChartResult.renderChart(): updating chart."); |
250 |
|
|
250 |
|
|
251 | 251 |
// the update must be done here (BEFORE the call of this.updateLastRenderingParameters()) rather than in the SWTChartComponentsProvider => the problem is that for File based Engine, the file may be created twice, need to check this |
252 | 252 |
// also before the call of this.updateLastParameters() to be able to check if a computing parameter has changed in the chart creators |
253 | 253 |
chartCreator.updateChart(this); |
254 |
|
|
254 |
|
|
255 | 255 |
// FIXME: needed by the above fix #1 |
256 | 256 |
// reupdate the last computing parameters |
257 | 257 |
this.updateLastParameters(); |
258 |
|
|
258 |
|
|
259 | 259 |
this.updateLastRenderingParameters(); |
260 |
|
|
260 |
|
|
261 | 261 |
this.needsToClearItemsSelection = false; |
262 | 262 |
this.needsToResetView = false; |
263 |
|
|
263 |
|
|
264 | 264 |
this.chartDirty = false; |
265 |
|
|
265 |
|
|
266 | 266 |
// Debug |
267 | 267 |
Log.finest("ChartResult.renderChart(): chart rendering done."); //$NON-NLS-1$ |
268 | 268 |
|
269 | 269 |
return true; |
270 |
|
|
270 |
|
|
271 | 271 |
} |
272 | 272 |
else { |
273 | 273 |
Log.severe("ChartResult.renderChart(): can not find any suitable chart creator for result: " + this.getClass() + "."); //$NON-NLS-1$ |
274 | 274 |
return false; |
275 | 275 |
} |
276 | 276 |
} |
277 |
|
|
278 |
|
|
277 |
|
|
278 |
|
|
279 | 279 |
@Override |
280 | 280 |
public boolean hasParameterChanged(String key) { |
281 | 281 |
if (key.isEmpty()) { |
... | ... | |
283 | 283 |
} |
284 | 284 |
return super.hasParameterChanged(key); |
285 | 285 |
} |
286 |
|
|
287 | 286 |
|
288 |
|
|
287 |
|
|
288 |
|
|
289 | 289 |
@Override |
290 | 290 |
public String dumpParameters() { |
291 | 291 |
return super.dumpParameters() + "\n" + this.dumpParameters(Parameter.RENDERING); //$NON-NLS-1$ |
292 | 292 |
} |
293 |
|
|
293 |
|
|
294 | 294 |
/** |
295 | 295 |
* Updates the parameters used for last rendering. |
296 | 296 |
* |
... | ... | |
299 | 299 |
protected void updateLastRenderingParameters() throws Exception { |
300 | 300 |
this.updateLastParameters(Parameter.RENDERING, true); |
301 | 301 |
} |
302 |
|
|
302 |
|
|
303 | 303 |
/** |
304 | 304 |
* Clears the parameters used for last rendering. |
305 | 305 |
* Dedicated to force a chart recreation, eg. for cloning the chart result or for dynamically changing the chart type . |
... | ... | |
308 | 308 |
public void clearLastRenderingParameters() { |
309 | 309 |
this.clearLastParameters(Parameter.RENDERING); |
310 | 310 |
} |
311 |
|
|
312 |
|
|
311 |
|
|
312 |
|
|
313 | 313 |
/** |
314 | 314 |
* |
315 | 315 |
* @return |
316 | 316 |
* @throws Exception |
317 | 317 |
*/ |
318 | 318 |
public final boolean isChartDirtyFromHistory() throws Exception { |
319 |
|
|
319 |
|
|
320 | 320 |
List<Field> fields = this.getAllFields(); |
321 | 321 |
|
322 | 322 |
for (Field f : fields) { |
... | ... | |
324 | 324 |
if (parameter == null || parameter.type() != Parameter.RENDERING) { |
325 | 325 |
continue; |
326 | 326 |
} |
327 |
|
|
327 |
|
|
328 | 328 |
String name; |
329 | 329 |
if(!parameter.key().isEmpty()) { |
330 | 330 |
name = parameter.key(); |
... | ... | |
332 | 332 |
else { |
333 | 333 |
name = f.getName(); |
334 | 334 |
} |
335 |
|
|
335 |
|
|
336 | 336 |
f.setAccessible(true); // not to set accessible to test the field values |
337 |
|
|
337 |
|
|
338 | 338 |
// FIXME: old version |
339 | 339 |
//Object previousValue = this.lastParameters.get(name); |
340 | 340 |
// FIXME: new version with stack |
341 | 341 |
Object previousValue = this.getLastParametersFromHistory().get(name); |
342 |
|
|
343 |
|
|
342 |
|
|
343 |
|
|
344 | 344 |
Object newValue = f.get(this); |
345 | 345 |
this.updateChartDirty(previousValue, newValue); |
346 | 346 |
if (this.chartDirty) { |
... | ... | |
351 | 351 |
} |
352 | 352 |
return this.chartDirty; |
353 | 353 |
} |
354 |
|
|
355 |
|
|
354 |
|
|
355 |
|
|
356 | 356 |
/** |
357 | 357 |
* Updates the chart dirty state by comparing an old parameter with a new one. |
358 | 358 |
* |
... | ... | |
368 | 368 |
this.chartDirty = true; |
369 | 369 |
} |
370 | 370 |
} |
371 |
|
|
371 |
|
|
372 | 372 |
@Override |
373 |
public Object clone() {
|
|
373 |
public ChartResult clone() {
|
|
374 | 374 |
ChartResult clone = null; |
375 |
try { |
|
376 |
clone = (ChartResult) super.clone(); |
|
377 |
clone.chart = null; |
|
378 |
// FIXME: would be nice to clone the chart if possible instead of clearing the last rendering parameters? |
|
379 |
//clone.chart = this.chart.clone(); |
|
380 |
clone.clearLastRenderingParameters(); // to force recreation of the chart at next computing |
|
381 |
clone.chartDirty = true; |
|
382 |
clone.hasBeenComputedOnce = false; |
|
383 |
} |
|
384 |
catch(Exception e) { |
|
385 |
} |
|
386 |
return clone; |
|
375 |
clone = (ChartResult) super.clone(); |
|
376 |
clone.chart = null; |
|
377 |
// FIXME: would be nice to clone the chart if possible instead of clearing the last rendering parameters? |
|
378 |
//clone.chart = this.chart.clone(); |
|
379 |
clone.clearLastRenderingParameters(); // to force recreation of the chart at next computing |
|
380 |
clone.chartDirty = true; |
|
381 |
clone.hasBeenComputedOnce = false; |
|
382 |
return clone; |
|
387 | 383 |
} |
388 |
|
|
384 |
|
|
389 | 385 |
/** |
390 | 386 |
* @return the chart |
391 | 387 |
*/ |
... | ... | |
409 | 405 |
public ChartCreator getChartCreator() { |
410 | 406 |
return this.chartsEngine.getChartCreator(this); |
411 | 407 |
} |
412 |
|
|
408 |
|
|
413 | 409 |
/** |
414 | 410 |
* @param chartType the chartType to set |
415 | 411 |
*/ |
416 | 412 |
public void setChartType(String chartType) { |
417 | 413 |
this.chartType = chartType; |
418 | 414 |
// clear all last parameters to force a full recomputing |
419 |
// this.clearLastComputingParameters(); |
|
420 |
// this.clearLastRenderingParameters(); |
|
415 |
// this.clearLastComputingParameters();
|
|
416 |
// this.clearLastRenderingParameters();
|
|
421 | 417 |
} |
422 | 418 |
|
423 | 419 |
/** |
... | ... | |
435 | 431 |
return ChartsEnginePreferences.DEFAULT_CHART_TYPE.equals(this.chartType); |
436 | 432 |
} |
437 | 433 |
|
438 |
|
|
439 |
|
|
434 |
|
|
435 |
|
|
440 | 436 |
/** |
441 | 437 |
* @return the chartDirty |
442 | 438 |
*/ |
... | ... | |
593 | 589 |
this.chart = chart; |
594 | 590 |
} |
595 | 591 |
|
596 |
|
|
597 | 592 |
|
593 |
|
|
598 | 594 |
// FIXME |
599 |
// public Object createChart(IProgressMonitor monitor, String chartType) { |
|
600 |
// Object chart = null; |
|
601 |
// ChartCreator chartCreator = ChartsEngine.getCurrent().getChartCreator(this.getClass(), chartType); |
|
602 |
// return chart; |
|
603 |
// } |
|
604 |
|
|
595 |
// public Object createChart(IProgressMonitor monitor, String chartType) {
|
|
596 |
// Object chart = null;
|
|
597 |
// ChartCreator chartCreator = ChartsEngine.getCurrent().getChartCreator(this.getClass(), chartType);
|
|
598 |
// return chart;
|
|
599 |
// }
|
|
600 |
|
|
605 | 601 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreatePartitionDialog.java (revision 1403) | ||
---|---|---|
340 | 340 |
} |
341 | 341 |
}); |
342 | 342 |
|
343 |
Button importButton = new Button(advanceContainer, SWT.NONE); |
|
344 |
importButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER, |
|
345 |
GridData.FILL, false, false)); |
|
346 |
importButton.setText("Import from properties file..."); //$NON-NLS-1$ |
|
347 |
importButton.addListener(SWT.Selection, new Listener() { |
|
348 |
@Override |
|
349 |
public void handleEvent(Event event) { |
|
350 |
FileDialog d = new FileDialog(event.display.getActiveShell()); |
|
351 |
d.setFilterExtensions(new String[] {"*.properties"}); |
|
352 |
d.setText("Select a properties file containing CQL queries"); |
|
353 |
String path = d.open(); |
|
354 |
if (path != null) { |
|
355 |
Properties props = new Properties(); |
|
356 |
try { |
|
357 |
props.load(IOUtils.getReader(new File(path))); |
|
358 |
for (Object key : props.keySet()) { |
|
359 |
String value = props.getProperty(key.toString()); |
|
360 |
QueryWidget qw = addQueryField(key.toString().substring(0, Math.min(20, key.toString().length())), value); |
|
361 |
} |
|
362 |
} catch (Exception e) { |
|
363 |
// TODO Auto-generated catch block |
|
364 |
e.printStackTrace(); |
|
365 |
} |
|
366 |
} |
|
367 |
|
|
368 |
} |
|
369 |
}); |
|
343 |
//TODO enable when specified |
|
344 |
// Button importButton = new Button(advanceContainer, SWT.NONE); |
|
345 |
// importButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER, |
|
346 |
// GridData.FILL, false, false)); |
|
347 |
// importButton.setText("Import from properties file..."); //$NON-NLS-1$ |
|
348 |
// importButton.addListener(SWT.Selection, new Listener() { |
|
349 |
// @Override |
|
350 |
// public void handleEvent(Event event) { |
|
351 |
// FileDialog d = new FileDialog(event.display.getActiveShell()); |
|
352 |
// d.setFilterExtensions(new String[] {"*.properties"}); |
|
353 |
// d.setText("Select a properties file containing CQL queries"); |
|
354 |
// String path = d.open(); |
|
355 |
// if (path != null) { |
|
356 |
// Properties props = new Properties(); |
|
357 |
// try { |
|
358 |
// props.load(IOUtils.getReader(new File(path))); |
|
359 |
// for (Object key : props.keySet()) { |
|
360 |
// String value = props.getProperty(key.toString()); |
|
361 |
// QueryWidget qw = addQueryField(key.toString().substring(0, Math.min(20, key.toString().length())), value); |
|
362 |
// } |
|
363 |
// } catch (Exception e) { |
|
364 |
// // TODO Auto-generated catch block |
|
365 |
// e.printStackTrace(); |
|
366 |
// } |
|
367 |
// } |
|
368 |
// |
|
369 |
// } |
|
370 |
// }); |
|
370 | 371 |
|
371 | 372 |
compositeForAdvanced = new Composite(scrollComposite, SWT.NONE); |
372 | 373 |
GridLayout layoutForAdvanced = new GridLayout(3, false); |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/results/CloneTXMResult.java (revision 1403) | ||
---|---|---|
44 | 44 |
public class CloneTXMResult extends BaseAbstractHandler { |
45 | 45 |
|
46 | 46 |
|
47 |
|
|
47 |
|
|
48 | 48 |
/* (non-Javadoc) |
49 | 49 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
50 | 50 |
*/ |
51 | 51 |
@Override |
52 | 52 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
53 | 53 |
|
54 |
System.out.println("CloneTXMResult.execute(): clone tests."); |
|
54 |
//System.out.println("CloneTXMResult.execute(): clone tests.");
|
|
55 | 55 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
56 |
System.out.println("CloneTXMResult.execute() selection class: " + selection); |
|
57 |
if(selection.getFirstElement() instanceof TXMResult) { |
|
58 |
TXMResult srcNode = ((TXMResult) selection.getFirstElement()); |
|
59 |
TXMResult clone = (TXMResult) srcNode.clone(); |
|
60 |
|
|
61 |
// FIXME: hierarchy tests |
|
62 |
//srcNode.addChild(clone); |
|
63 |
CorporaView.refresh(); |
|
64 |
return null; |
|
65 |
} |
|
66 |
else { |
|
56 |
//System.out.println("CloneTXMResult.execute() selection class: " + selection); |
|
57 |
|
|
58 |
if (!(selection.getFirstElement() instanceof TXMResult)) { |
|
59 |
System.out.println("Only TXMResult can be cloned."); |
|
67 | 60 |
return super.logCanNotExecuteCommand(selection); |
68 | 61 |
} |
69 | 62 |
|
63 |
TXMResult srcNode = ((TXMResult) selection.getFirstElement()); |
|
64 |
|
|
65 |
TXMResult parent = srcNode.getParent(); |
|
70 | 66 |
|
67 |
srcNode.clone(false); |
|
68 |
|
|
69 |
CorporaView.refreshObject(parent); |
|
70 |
return null; |
|
71 | 71 |
} |
72 |
|
|
73 | 72 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/results/CloneTXMResultTree.java (revision 1403) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.rcp.handlers.results; |
|
29 |
|
|
30 |
import org.eclipse.core.commands.ExecutionEvent; |
|
31 |
import org.eclipse.core.commands.ExecutionException; |
|
32 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
33 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
34 |
import org.txm.core.results.TXMResult; |
|
35 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
|
36 |
import org.txm.rcp.views.corpora.CorporaView; |
|
37 |
|
|
38 |
/** |
|
39 |
* Clone the selected TXM result node. |
|
40 |
* |
|
41 |
* @author sjacquot |
|
42 |
* |
|
43 |
*/ |
|
44 |
public class CloneTXMResultTree extends BaseAbstractHandler { |
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
/* (non-Javadoc) |
|
49 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
50 |
*/ |
|
51 |
@Override |
|
52 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
53 |
|
|
54 |
//System.out.println("CloneTXMResult.execute(): clone tests."); |
|
55 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
56 |
//System.out.println("CloneTXMResult.execute() selection class: " + selection); |
|
57 |
|
|
58 |
if (!(selection.getFirstElement() instanceof TXMResult)) { |
|
59 |
System.out.println("Only TXMResult can be cloned"); |
|
60 |
return super.logCanNotExecuteCommand(selection); |
|
61 |
} |
|
62 |
|
|
63 |
TXMResult srcNode = ((TXMResult) selection.getFirstElement()); |
|
64 |
|
|
65 |
TXMResult parent = srcNode.getParent(); |
|
66 |
|
|
67 |
srcNode.clone(); |
|
68 |
|
|
69 |
CorporaView.refreshObject(parent); |
|
70 |
return null; |
|
71 |
|
|
72 |
} |
|
73 |
|
|
74 |
} |
|
0 | 75 |
tmp/org.txm.rcp/plugin.xml (revision 1403) | ||
---|---|---|
2019 | 2019 |
</reference> |
2020 | 2020 |
</visibleWhen> |
2021 | 2021 |
</command> |
2022 |
<command |
|
2023 |
commandId="org.txm.rcp.handlers.results.CloneTXMResult" |
|
2024 |
label="Cloner" |
|
2025 |
style="push"> |
|
2026 |
<visibleWhen |
|
2027 |
checkEnabled="false"> |
|
2028 |
<and> |
|
2029 |
<reference |
|
2030 |
definitionId="OneTXMResultSelected"> |
|
2031 |
</reference> |
|
2032 |
<not> |
|
2033 |
<reference |
|
2034 |
definitionId="OneMainCorpusSelected"> |
|
2035 |
</reference> |
|
2036 |
</not> |
|
2037 |
</and> |
|
2038 |
</visibleWhen> |
|
2039 |
</command> |
|
2040 |
<command |
|
2041 |
commandId="org.txm.rcp.handlers.results.CloneTXMResultTree" |
|
2042 |
label="Cloner tout" |
|
2043 |
style="push"> |
|
2044 |
<visibleWhen |
|
2045 |
checkEnabled="false"> |
|
2046 |
<and> |
|
2047 |
<reference |
|
2048 |
definitionId="OneTXMResultSelected"> |
|
2049 |
</reference> |
|
2050 |
<not> |
|
2051 |
<reference |
|
2052 |
definitionId="OneMainCorpusSelected"> |
|
2053 |
</reference> |
|
2054 |
</not> |
|
2055 |
</and> |
|
2056 |
</visibleWhen> |
|
2057 |
</command> |
|
2022 | 2058 |
|
2023 | 2059 |
<command |
2024 | 2060 |
commandId="org.txm.rcp.handlers.results.DeleteObject" |
... | ... | |
2570 | 2606 |
</command> |
2571 | 2607 |
<command |
2572 | 2608 |
defaultHandler="org.txm.rcp.handlers.results.CloneTXMResult" |
2573 |
id="CloneTXMResult" |
|
2609 |
id="org.txm.rcp.handlers.results.CloneTXMResult"
|
|
2574 | 2610 |
name="Clone"> |
2575 | 2611 |
</command> |
2612 |
<command |
|
2613 |
defaultHandler="org.txm.rcp.handlers.results.CloneTXMResultTree" |
|
2614 |
id="org.txm.rcp.handlers.results.CloneTXMResultTree" |
|
2615 |
name="Clone all"> |
|
2616 |
</command> |
|
2576 | 2617 |
</extension> |
2577 | 2618 |
<extension |
2578 | 2619 |
id="scripts" |
tmp/org.txm.partition.rcp/plugin.xml (revision 1403) | ||
---|---|---|
64 | 64 |
</or> |
65 | 65 |
</visibleWhen> |
66 | 66 |
</command> |
67 |
<command |
|
68 |
commandId="CloneTXMResult" |
|
69 |
style="push"> |
|
70 |
<visibleWhen |
|
71 |
checkEnabled="false"> |
|
72 |
<test |
|
73 |
property="org.txm.partition.rcp.test1"> |
|
74 |
</test> |
|
75 |
</visibleWhen> |
|
76 |
</command> |
|
77 | 67 |
</menuContribution> |
78 | 68 |
</extension> |
79 | 69 |
<extension |
Formats disponibles : Unified diff