Implement "Open in " bulk editor for taxon navigator #5609
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 1 Jun 2016 12:16:17 +0000 (14:16 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 1 Jun 2016 12:16:17 +0000 (14:16 +0200)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/defaultHandler/OpenBulkEditorForTaxonNodeHandler.java

index 5b7b601e78eae0be27acafd4fa4c1947d50811a9..3d07bf1f4d6da1253a9a1759187acd5388338b5d 100644 (file)
@@ -48,6 +48,7 @@ import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
 import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
 import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
 import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
 import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
@@ -110,7 +111,12 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe
                if (!(input instanceof AbstractBulkEditorInput)) {
                        throw new PartInitException("Invalid Input: Must be BulkEditorInput");
                }
                if (!(input instanceof AbstractBulkEditorInput)) {
                        throw new PartInitException("Invalid Input: Must be BulkEditorInput");
                }
-
+               else{
+                   AbstractBulkEditorInput<?> bulkEditorInput = (AbstractBulkEditorInput<?>)input;
+                   if(bulkEditorInput.getEntityUuid()!=null){
+                       bulkEditorInput.performSearch(new BulkEditorQuery(bulkEditorInput.getEntityUuid().toString(), null));
+                   }
+               }
                super.init(site, input);
        }
 
                super.init(site, input);
        }
 
@@ -176,15 +182,15 @@ public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDe
 
        private void displayWarningDialog() {
                IPreferenceStore prefs = PreferencesUtil.getPreferenceStore();
 
        private void displayWarningDialog() {
                IPreferenceStore prefs = PreferencesUtil.getPreferenceStore();
-               if (!prefs.getBoolean(PreferencesUtil.HIDE_BULKEDITOR_INFO)) {
+               if (!prefs.getBoolean(IPreferenceKeys.HIDE_BULKEDITOR_INFO)) {
                        String msg = "The Bulk Editor allows you to edit objects used to reference other objects, such as names, references, and authors.\n\n" +
                                                        "Any changes you make to an object in the Bulk Editor will be displayed wherever the object is used.\n\n" +
                                                        "For instance, a reference may be displayed with both a name and a descriptive element. If the reference name is changed here, the display of both the name and the descriptive element will be affected.";
                        MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm
                                                                                                (getSite().getShell(), "Bulk Editor", msg, "Do not show this message again",
                        String msg = "The Bulk Editor allows you to edit objects used to reference other objects, such as names, references, and authors.\n\n" +
                                                        "Any changes you make to an object in the Bulk Editor will be displayed wherever the object is used.\n\n" +
                                                        "For instance, a reference may be displayed with both a name and a descriptive element. If the reference name is changed here, the display of both the name and the descriptive element will be affected.";
                        MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm
                                                                                                (getSite().getShell(), "Bulk Editor", msg, "Do not show this message again",
-                                                                                                               false, null, PreferencesUtil.HIDE_BULKEDITOR_INFO);
+                                                                                                               false, null, IPreferenceKeys.HIDE_BULKEDITOR_INFO);
                        if (dialog.getReturnCode() == Window.OK) {
                        if (dialog.getReturnCode() == Window.OK) {
-                               prefs.setValue(PreferencesUtil.HIDE_BULKEDITOR_INFO, dialog.getToggleState());
+                               prefs.setValue(IPreferenceKeys.HIDE_BULKEDITOR_INFO, dialog.getToggleState());
                        }
                }
        }
                        }
                }
        }
index 22292b0a31bb513f7649d7c4424c1a5928eac947..8307781b14ade0829ede480496225ae37d16232f 100644 (file)
@@ -1,15 +1,31 @@
 package eu.etaxonomy.taxeditor.bulkeditor.handler.defaultHandler;
 
 package eu.etaxonomy.taxeditor.bulkeditor.handler.defaultHandler;
 
-import org.eclipse.core.commands.AbstractHandler;
+import java.util.UUID;
+
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.PartInitException;
+
+import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
+import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+public class OpenBulkEditorForTaxonNodeHandler extends DefaultOpenHandlerBase<TaxonNode> {
 
 
-public class OpenBulkEditorForTaxonNodeHandler extends AbstractHandler {
+    @Override
+    protected TaxonNode getEntity(UUID uuid) {
+        return CdmStore.getService(ITaxonNodeService.class).load(uuid);
+    }
 
 
-       @Override
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               System.out.println("event");
-               return null;
-       }
+    @Override
+    protected void open(ExecutionEvent event, TaxonNode entity) {
+        try {
+            BulkEditorUtil.openEditor(entity.getTaxon());
+        } catch (PartInitException e) {
+            MessagingUtils.error(this.getClass(), "Bulk Editor could not be opened for "+entity, e);
+        }
+    }
 
 }
 
 }