Disable MediaView for bulk editor (#5162)
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 26 Aug 2015 06:15:49 +0000 (08:15 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 26 Aug 2015 06:15:49 +0000 (08:15 +0200)
 - bulk editor does only activate media view when showing taxa
 - code trimming

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaViewPart.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IPartContentHasMedia.java

index 720cd61..4c97dbf 100644 (file)
@@ -42,6 +42,7 @@ import eu.etaxonomy.taxeditor.annotatedlineeditor.AnnotatedLineEditor;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel;
 import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
+import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput;
 import eu.etaxonomy.taxeditor.model.IDerivedUnitFacadePart;
 import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
 import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
@@ -309,4 +310,9 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe
                menu.remove(ITextEditorActionConstants.SHIFT_LEFT);
                menu.remove(ITextEditorActionConstants.CONTEXT_PREFERENCES);
        }
+
+       @Override
+       public boolean canAttachMedia() {
+           return getEditorInput() instanceof TaxonEditorInput?true:false;
+       }
 }
index 94107c2..74e264d 100644 (file)
@@ -86,11 +86,6 @@ public class MultiPageTaxonEditor extends FormEditor implements
                super.dispose();
        }
 
-       /*
-        * (non-Javadoc)
-        *
-        * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
-        */
        /** {@inheritDoc} */
        @Override
        protected void addPages() {
@@ -173,28 +168,11 @@ public class MultiPageTaxonEditor extends FormEditor implements
                firePropertyChange(PROP_DIRTY);
        }
 
-       /*
-        * (non-Javadoc)
-        *
-        * @see org.eclipse.ui.part.MultiPageEditorPart#isDirty()
-        */
-       /**
-        * <p>
-        * isDirty
-        * </p>
-        *
-        * @return a boolean.
-        */
        @Override
     public boolean isDirty() {
                return dirty;
        }
 
-       /*
-        * (non-Javadoc)
-        *
-        * @see org.eclipse.ui.forms.editor.FormEditor#editorDirtyStateChanged()
-        */
        /** {@inheritDoc} */
        @Override
        public void editorDirtyStateChanged() {
@@ -210,11 +188,6 @@ public class MultiPageTaxonEditor extends FormEditor implements
         * place before passing property change along to
         * <code>super.handlePropertyChange(int propertyId)</code>.
         */
-       /*
-        * (non-Javadoc)
-        *
-        * @see org.eclipse.ui.part.MultiPageEditorPart#handlePropertyChange(int)
-        */
        @Override
     protected void handlePropertyChange(int propertyId) {
                if (propertyId == PROP_DIRTY) {
@@ -312,9 +285,6 @@ public class MultiPageTaxonEditor extends FormEditor implements
         setPartName();
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#forceDirty()
-     */
     @Override
     public void forceDirty() {
         changed(null);
@@ -329,60 +299,19 @@ public class MultiPageTaxonEditor extends FormEditor implements
                return input.getTaxon();
        }
 
-       /*
-        * (non-Javadoc)
-        *
-        * @see
-        * eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder
-        * ()
-        */
-       /**
-        * <p>
-        * getConversationHolder
-        * </p>
-        *
-        * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
-        *         object.
-        */
        @Override
     public ConversationHolder getConversationHolder() {
                return conversation;
        }
 
-       /**
-        * <p>
-        * setConversationHolder
-        * </p>
-        *
-        * @param conversation
-        *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
-        *            object.
-        */
        public void setConversationHolder(ConversationHolder conversation) {
                this.conversation = conversation;
        }
 
-       /**
-        * <p>
-        * Getter for the field <code>undoContext</code>.
-        * </p>
-        *
-        * @return a {@link org.eclipse.core.commands.operations.IUndoContext}
-        *         object.
-        */
        public IUndoContext getUndoContext() {
                return undoContext;
        }
 
-       /**
-        * <p>
-        * Setter for the field <code>undoContext</code>.
-        * </p>
-        *
-        * @param undoContext
-        *            a {@link org.eclipse.core.commands.operations.IUndoContext}
-        *            object.
-        */
        public void setUndoContext(IUndoContext undoContext) {
                this.undoContext = undoContext;
        }
@@ -397,14 +326,7 @@ public class MultiPageTaxonEditor extends FormEditor implements
                getActiveEditor().setFocus();
        }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu
-     * .etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
-     */
-    /** {@inheritDoc} */
+       /** {@inheritDoc} */
     @Override
     public void update(CdmDataChangeMap events) {
         if (dataChangeBehavior == null) {
@@ -414,13 +336,6 @@ public class MultiPageTaxonEditor extends FormEditor implements
         DataChangeBridge.handleDataChange(events, dataChangeBehavior);
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * eu.etaxonomy.taxeditor.store.operations.IPostOperationEnabled#postOperation
-     * ()
-     */
     /** {@inheritDoc} */
     @Override
     public boolean postOperation(CdmBase objectAffectedByOperation) {
@@ -496,13 +411,6 @@ public class MultiPageTaxonEditor extends FormEditor implements
                return editorPage != null && editorPage.redraw(focus);
        }
 
-       /**
-        * <p>
-        * onComplete
-        * </p>
-        *
-        * @return a boolean.
-        */
        @Override
     public boolean onComplete() {
                return false;
@@ -549,4 +457,9 @@ public class MultiPageTaxonEditor extends FormEditor implements
                }
                return true;
        }
+
+       @Override
+       public boolean canAttachMedia() {
+           return true;
+       }
 }
index a784539..c805c6f 100644 (file)
@@ -79,9 +79,6 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
     public DerivateView() {
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
-     */
     @Override
     public void createPartControl(Composite parent) {
         viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
@@ -123,9 +120,6 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         viewer.addDropSupport(dndOperations, transfers, new DerivateDropListener(this));
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
-     */
     @Override
     public void doSave(IProgressMonitor monitor) {
         String taskName = "Saving hierarchy";
@@ -150,16 +144,10 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         refreshTree();
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.part.EditorPart#doSaveAs()
-     */
     @Override
     public void doSaveAs() {
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.part.EditorPart#getTitleToolTip()
-     */
     @Override
     public String getTitleToolTip() {
         if(getEditorInput() instanceof DerivateViewEditorInput){
@@ -169,9 +157,6 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         return "Derivative Editor";
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
-     */
     @Override
     public void init(IEditorSite site, IEditorInput input) throws PartInitException {
         setSite(site);
@@ -183,9 +168,6 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         }
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.part.EditorPart#isDirty()
-     */
     @Override
     public boolean isDirty() {
         return isDirty;
@@ -198,18 +180,11 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         this.isDirty = isDirty;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
-     */
     @Override
     public boolean isSaveAsAllowed() {
         return false;
     }
 
-
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
-     */
     @Override
     public void setFocus() {
         viewer.getControl().setFocus();
@@ -219,16 +194,10 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         }
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
-     */
     @Override
     public void update(CdmDataChangeMap changeEvents) {
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
-     */
     @Override
     public ConversationHolder getConversationHolder() {
         return conversation;
@@ -241,9 +210,6 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         return viewer;
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#changed(java.lang.Object)
-     */
     @Override
     public void changed(Object element) {
         setDirty(true);
@@ -251,9 +217,6 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         viewer.refresh();
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#forceDirty()
-     */
     @Override
     public void forceDirty() {
         changed(null);
@@ -281,7 +244,6 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         viewer.refresh();
     }
 
-
     private void generateMultiLinkSingleReads() {
         Set<SingleRead> multiLinkSingleReads = new HashSet<SingleRead>();
         for(Entry<SingleRead, Collection<Sequence>> entry:CdmStore.getService(ISequenceService.class).getSingleReadSequencesMap().entrySet()){
@@ -299,9 +261,6 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         return this.multiLinkSingleReads;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
-     */
     @Override
     public void selectionChanged(SelectionChangedEvent event) {
         this.selection  = event.getSelection();
@@ -315,9 +274,6 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         return labelProvider;
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.operation.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
-     */
     @Override
     public boolean postOperation(CdmBase objectAffectedByOperation) {
         refreshTree();
@@ -327,12 +283,14 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         return true;
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.operation.IPostOperationEnabled#onComplete()
-     */
     @Override
     public boolean onComplete() {
         return true;
     }
 
+    @Override
+    public boolean canAttachMedia() {
+        return true;
+    }
+
 }
index 07cbd47..f3c1714 100644 (file)
@@ -112,7 +112,7 @@ public class MediaViewPart extends AbstractCdmEditorViewPart implements IPartCon
             return;
         }
 
-               if(part instanceof IPartContentHasMedia){
+               if(part instanceof IPartContentHasMedia && ((IPartContentHasMedia) part).canAttachMedia()){
                    if(part instanceof MultiPageTaxonEditor){
                        IEditorInput input = ((IEditorPart) part).getEditorInput();
                        showViewer(part, new StructuredSelection(input));
index 3b6997e..42bd471 100644 (file)
@@ -1,20 +1,20 @@
 // $Id$
 /**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
 
 package eu.etaxonomy.taxeditor.model;
 
-
 /**
  *
- * Clients implementing this interface indicate, that the data they present is suitable for the media view
- * and that the media view should handle selection from the implementing part.
+ * Clients implementing this interface indicate, that the data they present is
+ * suitable for the media view and that the media view should handle selection
+ * from the implementing part.
  *
  * @author pplitzner
  * @date Sep 16, 2014
@@ -22,4 +22,12 @@ package eu.etaxonomy.taxeditor.model;
  */
 public interface IPartContentHasMedia {
 
+    /**
+     * Return <code>true</code> if media can be attached to the editor input and
+     * <code>false</code> otherwise
+     *
+     * @return true or false depending on the input of the implementing part
+     */
+    public boolean canAttachMedia();
+
 }