reintegrated campanula branch: removed enum DetailType and all its uses
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / AbstractCdmEditorViewPart.java
index afa592fa171aa06f0426f840532ede686655fd36..8d1f9ad9d6bd7cb678f7b18bfbb77491f5f1d8ad 100644 (file)
@@ -1,19 +1,20 @@
 /**
- * 
+ *
  */
 package eu.etaxonomy.taxeditor.view;
 
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.IEditorPart;
 
+import eu.etaxonomy.taxeditor.editor.ISecuredEditor;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
 
 /**
  * <p>
  * Abstract AbstractCdmEditorViewPart class.
  * </p>
- * 
+ *
  * @author n.hoffmann
  * @created Sep 21, 2010
  * @version 1.0
@@ -22,7 +23,7 @@ public abstract class AbstractCdmEditorViewPart extends AbstractCdmViewPart {
 
        /*
         * (non-Javadoc)
-        * 
+        *
         * @see
         * eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#createPartControl(org
         * .eclipse.swt.widgets.Composite)
@@ -30,36 +31,42 @@ public abstract class AbstractCdmEditorViewPart extends AbstractCdmViewPart {
        /** {@inheritDoc} */
        @Override
        public void createPartControl(Composite parent) {
-
                super.createPartControl(parent);
-
        }
 
        /**
         * <p>
         * getEditor
         * </p>
-        * 
+        *
         * @return the currently active editor
         */
        public IEditorPart getEditor() {
-               return StoreUtil.getActiveEditor();
+               return AbstractUtility.getActiveEditor();
        }
 
        /** {@inheritDoc} */
        @Override
-       public void changed(Object object) {
-               if (part instanceof AbstractCdmViewPart) {
-                       ((AbstractCdmViewPart) part).changed(object);
-               } else {
-                       IEditorPart editor = getEditor();
-                       if (editor != null
-                                       && editor instanceof IDirtyMarkableSelectionProvider) {
-
-                               ((IDirtyMarkableSelectionProvider) editor).changed(object);
+       public void setFocus() {
+               super.setFocus();
 
-                       }
+               if(getEditor() != null && ISecuredEditor.class.isAssignableFrom(getEditor().getClass())){
+                       boolean doEnable = ((ISecuredEditor)getEditor()).permissionsSatisfied();
+                       setEnabled(doEnable);
                }
-       }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void changed(Object object) {
+        if (part instanceof AbstractCdmViewPart) {
+            ((AbstractCdmViewPart) part).changed(object);
+        } else {
+            IEditorPart editor = getEditor();
+            if (editor != null && editor instanceof IDirtyMarkableSelectionProvider) {
+                ((IDirtyMarkableSelectionProvider) editor).changed(object);
+            }
+        }
+    }
 
 }