done: #3097 (disable editors if a user has insufficient grants for a taxon or taxon...
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / AbstractCdmEditorViewPart.java
1 /**
2 *
3 */
4 package eu.etaxonomy.taxeditor.view;
5
6 import org.eclipse.swt.widgets.Composite;
7 import org.eclipse.ui.IEditorPart;
8
9 import eu.etaxonomy.taxeditor.editor.ISecuredEditor;
10 import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
11 import eu.etaxonomy.taxeditor.store.StoreUtil;
12
13 /**
14 * <p>
15 * Abstract AbstractCdmEditorViewPart class.
16 * </p>
17 *
18 * @author n.hoffmann
19 * @created Sep 21, 2010
20 * @version 1.0
21 */
22 public abstract class AbstractCdmEditorViewPart extends AbstractCdmViewPart {
23
24 /*
25 * (non-Javadoc)
26 *
27 * @see
28 * eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#createPartControl(org
29 * .eclipse.swt.widgets.Composite)
30 */
31 /** {@inheritDoc} */
32 @Override
33 public void createPartControl(Composite parent) {
34
35 super.createPartControl(parent);
36
37 }
38
39 /**
40 * <p>
41 * getEditor
42 * </p>
43 *
44 * @return the currently active editor
45 */
46 public IEditorPart getEditor() {
47 return StoreUtil.getActiveEditor();
48 }
49
50 /** {@inheritDoc} */
51 @Override
52 public void setFocus() {
53 super.setFocus();
54
55 if(getEditor() != null && ISecuredEditor.class.isAssignableFrom(getEditor().getClass())){
56 boolean doEnable = ((ISecuredEditor)getEditor()).permissionsSatisfied();
57 setEnabled(doEnable);
58 }
59 }
60
61 /** {@inheritDoc} */
62 @Override
63 public void changed(Object object) {
64 if (part instanceof AbstractCdmViewPart) {
65 ((AbstractCdmViewPart) part).changed(object);
66 } else {
67 IEditorPart editor = getEditor();
68 if (editor != null
69 && editor instanceof IDirtyMarkableSelectionProvider) {
70
71 ((IDirtyMarkableSelectionProvider) editor).changed(object);
72
73 }
74 }
75 }
76
77 }