eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaContentProvider.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaLabelProvider.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaViewPart.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/handler/AddExistingMediaHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/handler/AddImageGalleryHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/handler/CreateMediaHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/handler/DeleteMediaHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/handler/MoveImageDownInListHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/handler/MoveImageUpInListHandler.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/AddExistingMediaToImageGalleryOperation.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/AddMediaToImageGalleryOperation.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/CreateImageOperation.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/DeleteMediaOperation.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/GrantedAuthoritySelectionDialog.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/GroupSelectionDialog.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/InstitutionSelectionDialog.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/MediaSelectionDialog.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NameSelectionDialog.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NamedAreaSelectionDialog.java -text
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalAuthorTeamSelectionDialog.java -text
</reference>
</visibleWhen>
</command>
+ <command
+ commandId="taxeditor-editor.useExistingImage"
+ label="Use Existing Image"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="isImageGallery">
+ </reference>
+ </visibleWhen>
+ </command>
<command
commandId="taxeditor-editor.command.moveimgdown"
label="%command.label.39"
id="taxeditor-editor.newimage"
name="%command.name.21">
</command>
+ <command
+ categoryId="eu.etaxonomy.taxeditor.editor.media.category"
+ defaultHandler="eu.etaxonomy.taxeditor.editor.view.media.handler.AddExistingMediaHandler"
+ id="taxeditor-editor.useExistingImage"
+ name="Use Existing Image">
+ </command>
<command
categoryId="eu.etaxonomy.taxeditor.editor.media.category"
defaultHandler="eu.etaxonomy.taxeditor.editor.view.media.handler.MoveImageUpInListHandler"
--- /dev/null
+package eu.etaxonomy.taxeditor.editor.view.media.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.common.NotDefinedException;
+
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
+import eu.etaxonomy.cdm.model.media.Media;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.view.media.operation.AddExistingMediaToImageGalleryOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.MediaSelectionDialog;
+
+public class AddExistingMediaHandler extends CreateMediaHandler {
+
+ /**
+ * @param event
+ * @param postOperationEnabled
+ * @param description
+ */
+ @Override
+ protected void executeOperation(ExecutionEvent event, IPostOperationEnabled postOperationEnabled,
+ DescriptionBase description) {
+ AbstractPostOperation operation = null;
+ try {
+
+ //select media
+ Media media = MediaSelectionDialog.select(AbstractUtility.getShell(), null, null);
+ // TODO use undo context specific to editor
+ operation = new AddExistingMediaToImageGalleryOperation(media, event.getCommand().getName(),
+ EditorUtil.getUndoContext(), description, postOperationEnabled);
+ AbstractUtility.executeOperation(operation);
+ } catch (NotDefinedException e) {
+ MessagingUtils.warn(getClass(), "Command name not set.");
+ }
+ }
+
+}
/**
- *
+ *
*/
package eu.etaxonomy.taxeditor.editor.view.media.handler;
import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.view.media.operation.AddMediaToImageGalleryOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
/** {@inheritDoc} */
- public Object execute(ExecutionEvent event) throws ExecutionException {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart part = HandlerUtil.getActivePart(event);
IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;
-
-
+
+
DescriptionBase description = null;
-
+
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof FormEditor) {
editor = ((FormEditor) editor).getActiveEditor();
}
-
+
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof TreeSelection) {
TreePath[] paths = ((TreeSelection) selection).getPaths();
-
+
int count = paths[0].getSegmentCount();
-
+
for (int i = 0; i < count; i++ ) {
if (paths[0].getSegment(i) instanceof DescriptionBase) {
description = (DescriptionBase) paths[0].getSegment(i);
}
}
}
-
+
if(description != null){
- AbstractPostOperation operation = null;
- try {
- // TODO use undo context specific to editor
- operation = new AddMediaToImageGalleryOperation(event.getCommand().getName(),
- EditorUtil.getUndoContext(), description, postOperationEnabled);
- EditorUtil.executeOperation(operation);
- } catch (NotDefinedException e) {
- MessagingUtils.warn(getClass(), "Command name not set.");
- }
+ executeOperation(event, postOperationEnabled, description);
}
-
+
return null;
}
+ /**
+ * @param event
+ * @param postOperationEnabled
+ * @param description
+ */
+ protected void executeOperation(ExecutionEvent event, IPostOperationEnabled postOperationEnabled,
+ DescriptionBase description) {
+ AbstractPostOperation operation = null;
+ try {
+ // TODO use undo context specific to editor
+ operation = new AddMediaToImageGalleryOperation(event.getCommand().getName(),
+ EditorUtil.getUndoContext(), description, postOperationEnabled);
+ AbstractUtility.executeOperation(operation);
+ } catch (NotDefinedException e) {
+ MessagingUtils.warn(getClass(), "Command name not set.");
+ }
+ }
+
}
--- /dev/null
+/**
+* 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.editor.view.media.operation;
+
+import org.eclipse.core.commands.operations.IUndoContext;
+
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
+import eu.etaxonomy.cdm.model.media.Media;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+
+/**
+ *
+ * This operation adds an already existing {@link Media} to the currently selected {@link DescriptionBase}.
+ * @author pplitzner
+ * @date 01.09.2014
+ *
+ */
+public class AddExistingMediaToImageGalleryOperation extends AddMediaToImageGalleryOperation {
+
+ public AddExistingMediaToImageGalleryOperation(Media media, String label,
+ IUndoContext undoContext, DescriptionBase<?> description, IPostOperationEnabled postOperationEnabled) {
+ super(media, label, undoContext, description, postOperationEnabled);
+
+ }
+}
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* 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.
*/
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
/**
- * <p>AddMediaToImageGalleryOperation class.</p>
+ * This operation creates a new {@link Media} and adds it to the currently selected {@link DescriptionBase}.
*
* @author p.ciardelli
* @author n.hoffmann
* @version 1.0
*/
public class AddMediaToImageGalleryOperation extends AbstractPostTaxonOperation {
-
- private DescriptionBase description;
+
+ private final DescriptionBase<?> description;
private Media media;
/**
* @param description a {@link eu.etaxonomy.cdm.model.description.DescriptionBase} object.
*/
public AddMediaToImageGalleryOperation(String label,
- IUndoContext undoContext, DescriptionBase description, IPostOperationEnabled postOperationEnabled) {
- super(label, undoContext, postOperationEnabled);
+ IUndoContext undoContext, DescriptionBase<?> description, IPostOperationEnabled postOperationEnabled) {
+ this(null, label, undoContext, description, postOperationEnabled);
+ media = Media.NewInstance();
+ }
+
+ protected AddMediaToImageGalleryOperation(Media media, String label,
+ IUndoContext undoContext, DescriptionBase<?> description, IPostOperationEnabled postOperationEnabled) {
+ super(label, undoContext, postOperationEnabled);
- this.description = description;
- media = Media.NewInstance();
+ this.description = description;
+ this.media = media;
}
/* (non-Javadoc)
throws ExecutionException {
monitor.worked(20);
-
+
ImagesUtility.addMediaToGallery(description, media);
-
+
monitor.worked(40);
-
+
return postExecute(media);
}
public static Amplification select(Shell shell, ConversationHolder conversation, Amplification amplification){
AmplificationSelectionDialog dialog = new AmplificationSelectionDialog(shell, conversation,
- "Choose Unit", false, AmplificationSelectionDialog.class.getCanonicalName(), amplification);
+ "Choose Amplification", false, AmplificationSelectionDialog.class.getCanonicalName(), amplification);
return getSelectionFromDialog(dialog);
}
if(amplification != null){
return amplification;
}
- MessagingUtils.error(this.getClass(), "Selected unit is not an amplification", null);
+ MessagingUtils.error(this.getClass(), "Selected element is not an amplification", null);
return null;
}
--- /dev/null
+// $Id$
+/**
+ * Copyright (C) 2014 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.ui.dialog.selection;
+
+import java.util.UUID;
+
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.service.IMediaService;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.media.Media;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author pplitzner
+ * @date 11.03.2014
+ *
+ */
+public class MediaSelectionDialog extends
+AbstractFilteredCdmResourceSelectionDialog<Media> {
+
+ public static Media select(Shell shell, ConversationHolder conversation, Media media){
+ MediaSelectionDialog dialog = new MediaSelectionDialog(shell, conversation,
+ "Choose Media", false, MediaSelectionDialog.class.getCanonicalName(), media);
+ return getSelectionFromDialog(dialog);
+ }
+
+ /**
+ * <p>Constructor for FilteredDerivedUnitSelectionDialog.</p>
+ */
+ protected MediaSelectionDialog(Shell shell, ConversationHolder conversation, String title,
+ boolean multi, String settings, Media cdmObject) {
+ super(shell, conversation, title, multi, settings, cdmObject);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected Media getPersistentObject(UUID uuid) {
+ Object object = CdmStore.getService(IMediaService.class).load(uuid);
+
+ Media media = (Media) HibernateProxyHelper.deproxy(object);
+
+ if(media != null){
+ return media;
+ }
+ MessagingUtils.error(this.getClass(), "Selected element is not media", null);
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected void initModel() {
+ model = CdmStore.getService(IMediaService.class).getUuidAndTitleCache();
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.ui.dialog.selection.AbstractFilteredCdmResourceSelectionDialog#getTitle(eu.etaxonomy.cdm.model.common.ICdmBase)
+ */
+ @Override
+ protected String getTitle(Media cdmObject) {
+ if(cdmObject!=null){
+ return cdmObject.getTitleCache();
+ }
+ return super.getTitle(cdmObject);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected String getNewWizardLinkText() {
+ return "";
+ }
+}
public static Primer select(Shell shell, ConversationHolder conversation, Primer primer){
PrimerSelectionDialog dialog = new PrimerSelectionDialog(shell, conversation,
- "Choose Unit", false, PrimerSelectionDialog.class.getCanonicalName(), primer);
+ "Choose Primer", false, PrimerSelectionDialog.class.getCanonicalName(), primer);
return getSelectionFromDialog(dialog);
}
if(primer != null){
return primer;
}
- MessagingUtils.error(this.getClass(), "Selected unit is not a primer", null);
+ MessagingUtils.error(this.getClass(), "Selected element is not a primer", null);
return null;
}
*/
public class SelectionDialogFactory {
- public static <T extends ICdmBase> T getSelectionFromDialog(Class<T> clazz, Shell shell, ConversationHolder conversation, T curentSelection){
+ public static <T extends ICdmBase> T getSelectionFromDialog(Class<T> clazz, Shell shell, ConversationHolder conversation, T currentSelection){
if(clazz.equals(Taxon.class)){
- return (T) TaxonBaseSelectionDialog.selectTaxon(shell, conversation, (Taxon) curentSelection);
+ return (T) TaxonBaseSelectionDialog.selectTaxon(shell, conversation, (Taxon) currentSelection);
}
if(clazz.equals(Synonym.class)){
return (T) TaxonBaseSelectionDialog.selectSynonym(shell, conversation);
return (T) TaxonBaseSelectionDialog.selectTaxonBase(shell, conversation);
}
if(clazz.equals(Classification.class)){
- return (T) ClassificationSelectionDialog.select(shell, conversation, (Classification) curentSelection);
+ return (T) ClassificationSelectionDialog.select(shell, conversation, (Classification) currentSelection);
}
if(clazz.equals(TaxonNode.class)){
- return (T) TaxonNodeSelectionDialog.select(shell, conversation, null, null, (TaxonNode) curentSelection, null);
+ return (T) TaxonNodeSelectionDialog.select(shell, conversation, null, null, (TaxonNode) currentSelection, null);
}
if(clazz.equals(Reference.class)){
- return (T) ReferenceSelectionDialog.select(shell, conversation, (Reference) curentSelection);
+ return (T) ReferenceSelectionDialog.select(shell, conversation, (Reference) currentSelection);
}
if(clazz.equals(TaxonNameBase.class)){
- return (T) NameSelectionDialog.select(shell, conversation, (TaxonNameBase) curentSelection);
+ return (T) NameSelectionDialog.select(shell, conversation, (TaxonNameBase) currentSelection);
}
if(clazz.equals(Team.class)){
- return (T) TeamSelectionDialog.select(shell, conversation, (Team) curentSelection);
+ return (T) TeamSelectionDialog.select(shell, conversation, (Team) currentSelection);
}
if(clazz.equals(AgentBase.class)){
- return (T) AgentSelectionDialog.select(shell, conversation, (AgentBase) curentSelection);
+ return (T) AgentSelectionDialog.select(shell, conversation, (AgentBase) currentSelection);
}
if(clazz.equals(Feature.class)){
- return (T) FeatureSelectionDialog.select(shell, conversation, (Feature) curentSelection);
+ return (T) FeatureSelectionDialog.select(shell, conversation, (Feature) currentSelection);
}
if(clazz.equals(FeatureTree.class)){
- return (T) FeatureTreeSelectionDialog.select(shell, conversation, (FeatureTree) curentSelection);
+ return (T) FeatureTreeSelectionDialog.select(shell, conversation, (FeatureTree) currentSelection);
}
if(clazz.equals(PolytomousKey.class)){
- return (T) PolytomousKeySelectionDialog.select(shell, conversation, (PolytomousKey) curentSelection);
+ return (T) PolytomousKeySelectionDialog.select(shell, conversation, (PolytomousKey) currentSelection);
}
if(clazz.equals(PolytomousKeyNode.class)){
MessagingUtils.warningDialog("Not implemented yet", SelectionDialogFactory.class,
return null;
}
if(clazz.equals(DerivedUnit.class)){
- return (T) DerivedUnitSelectionDialog.select(shell, conversation, (DerivedUnit) curentSelection);
+ return (T) DerivedUnitSelectionDialog.select(shell, conversation, (DerivedUnit) currentSelection);
}
if(clazz.equals(FieldUnit.class)){
- return (T) FieldUnitSelectionDialog.select(shell, conversation, (FieldUnit) curentSelection);
+ return (T) FieldUnitSelectionDialog.select(shell, conversation, (FieldUnit) currentSelection);
}
if(clazz.equals(NamedArea.class)){
- return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) curentSelection);
+ return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection);
}
if(clazz.equals(Collection.class)){
- return (T) CollectionSelectionDialog.select(shell, conversation, (Collection) curentSelection);
+ return (T) CollectionSelectionDialog.select(shell, conversation, (Collection) currentSelection);
}
if(clazz.equals(User.class)){
- return (T) UserSelectionDialog.select(shell, conversation, (User) curentSelection);
+ return (T) UserSelectionDialog.select(shell, conversation, (User) currentSelection);
}
if(clazz.equals(GrantedAuthorityImpl.class)){
- return (T) GrantedAuthoritySelectionDialog.select(shell, conversation, (GrantedAuthorityImpl) curentSelection);
+ return (T) GrantedAuthoritySelectionDialog.select(shell, conversation, (GrantedAuthorityImpl) currentSelection);
}
if (clazz.equals(Person.class)){
- return (T) PersonSelectionDialog.select(shell, conversation, (Person) curentSelection);
+ return (T) PersonSelectionDialog.select(shell, conversation, (Person) currentSelection);
}
if(clazz.equals(Group.class)){
- return (T) GroupSelectionDialog.select(shell, conversation, (Group) curentSelection);
+ return (T) GroupSelectionDialog.select(shell, conversation, (Group) currentSelection);
}
if(clazz.equals(Institution.class)){
- return (T) InstitutionSelectionDialog.select(shell, conversation, (Institution) curentSelection);
+ return (T) InstitutionSelectionDialog.select(shell, conversation, (Institution) currentSelection);
}
if(clazz.equals(Primer.class)){
- return (T) PrimerSelectionDialog.select(shell, conversation, (Primer) curentSelection);
+ return (T) PrimerSelectionDialog.select(shell, conversation, (Primer) currentSelection);
}
if(clazz.equals(Amplification.class)){
- return (T) AmplificationSelectionDialog.select(shell, conversation, (Amplification) curentSelection);
+ return (T) AmplificationSelectionDialog.select(shell, conversation, (Amplification) currentSelection);
}
return null;