From 026790369f6b4d7149e6b8c28cad1e643c7a31c9 Mon Sep 17 00:00:00 2001
From: Patrick Plitzner
Date: Wed, 26 Aug 2015 08:15:49 +0200
Subject: [PATCH] Disable MediaView for bulk editor (#5162)
- bulk editor does only activate media view when showing taxa
- code trimming
---
.../taxeditor/bulkeditor/BulkEditor.java | 6 ++
.../editor/MultiPageTaxonEditor.java | 99 ++-----------------
.../editor/view/derivate/DerivateView.java | 52 +---------
.../editor/view/media/MediaViewPart.java | 2 +-
.../taxeditor/model/IPartContentHasMedia.java | 28 ++++--
5 files changed, 36 insertions(+), 151 deletions(-)
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java
index 720cd6157..4c97dbfb5 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java
@@ -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;
+ }
}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java
index 94107c24a..74e264dc5 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java
@@ -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()
- */
- /**
- *
- * isDirty
- *
- *
- * @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
* super.handlePropertyChange(int propertyId)
.
*/
- /*
- * (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
- * ()
- */
- /**
- *
- * getConversationHolder
- *
- *
- * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
- * object.
- */
@Override
public ConversationHolder getConversationHolder() {
return conversation;
}
- /**
- *
- * setConversationHolder
- *
- *
- * @param conversation
- * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
- * object.
- */
public void setConversationHolder(ConversationHolder conversation) {
this.conversation = conversation;
}
- /**
- *
- * Getter for the field undoContext
.
- *
- *
- * @return a {@link org.eclipse.core.commands.operations.IUndoContext}
- * object.
- */
public IUndoContext getUndoContext() {
return undoContext;
}
- /**
- *
- * Setter for the field undoContext
.
- *
- *
- * @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);
}
- /**
- *
- * onComplete
- *
- *
- * @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;
+ }
}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java
index a7845395e..c805c6f16 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java
@@ -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 multiLinkSingleReads = new HashSet();
for(Entry> 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;
+ }
+
}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaViewPart.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaViewPart.java
index 07cbd473d..f3c171437 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaViewPart.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaViewPart.java
@@ -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));
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IPartContentHasMedia.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IPartContentHasMedia.java
index 3b6997e0a..42bd4714e 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IPartContentHasMedia.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IPartContentHasMedia.java
@@ -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 true
if media can be attached to the editor input and
+ * false
otherwise
+ *
+ * @return true or false depending on the input of the implementing part
+ */
+ public boolean canAttachMedia();
+
}
--
2.34.1