35 |
35 |
import org.eclipse.ui.menus.UIElement;
|
36 |
36 |
import org.txm.core.results.TXMResult;
|
37 |
37 |
import org.txm.rcp.editors.ITXMResultEditor;
|
38 |
|
import org.txm.rcp.editors.TXMEditor;
|
39 |
38 |
import org.txm.rcp.handlers.BaseAbstractHandler;
|
40 |
39 |
import org.txm.rcp.utils.SWTEditorsUtils;
|
41 |
40 |
import org.txm.rcp.views.corpora.CorporaView;
|
42 |
41 |
|
43 |
42 |
/**
|
44 |
|
* Swaps the persistence state of the selected TXM result nodes.
|
|
43 |
* Swaps the locked state of the selected TXM result nodes.
|
45 |
44 |
*
|
46 |
|
* @author sjacquot
|
|
45 |
* @author mdecorde
|
47 |
46 |
*
|
48 |
47 |
*/
|
49 |
48 |
public class SetTXMResultLockState extends BaseAbstractHandler implements IElementUpdater {
|
50 |
|
|
51 |
|
|
|
49 |
|
|
50 |
|
52 |
51 |
@Override
|
53 |
52 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
54 |
|
|
|
53 |
|
55 |
54 |
Object object = this.getCorporaViewSelectedObject(event);
|
56 |
|
if(object instanceof TXMResult) {
|
57 |
|
TXMResult result = ((TXMResult)object);
|
|
55 |
if (object instanceof TXMResult) {
|
|
56 |
TXMResult result = ((TXMResult) object);
|
58 |
57 |
result.setLocked(!result.isLocked());
|
59 |
58 |
|
60 |
59 |
if (result.isLocked()) {
|
... | ... | |
62 |
61 |
}
|
63 |
62 |
|
64 |
63 |
CorporaView.refresh();
|
65 |
|
//TODO should be done with a listener
|
|
64 |
// TODO: MD: should be done with a listener
|
66 |
65 |
for (ITXMResultEditor<?> editor : SWTEditorsUtils.getEditors()) {
|
67 |
66 |
editor.setLocked(editor.getResult().isLocked());
|
68 |
67 |
}
|
69 |
68 |
|
70 |
69 |
return null;
|
71 |
70 |
}
|
72 |
|
else {
|
|
71 |
else {
|
73 |
72 |
return super.logCanNotExecuteCommand(object);
|
74 |
73 |
}
|
75 |
74 |
}
|
76 |
|
|
|
75 |
|
77 |
76 |
/**
|
78 |
77 |
* Displays the checked mark in the menu item when the menu is created.
|
79 |
78 |
*/
|
80 |
79 |
@Override
|
81 |
80 |
public void updateElement(UIElement element, Map parameters) {
|
82 |
81 |
Object object = CorporaView.getFirstSelectedObject();
|
83 |
|
if(object != null && object instanceof TXMResult) {
|
84 |
|
element.setChecked(((TXMResult)object).isLocked());
|
|
82 |
if (object != null && object instanceof TXMResult) {
|
|
83 |
element.setChecked(((TXMResult) object).isLocked());
|
85 |
84 |
}
|
86 |
85 |
}
|
87 |
86 |
}
|