- code cleanup
authorPatric Plitzner <p.plitzner@bgbm.org>
Mon, 26 Jan 2015 14:21:46 +0000 (14:21 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Mon, 26 Jan 2015 14:21:46 +0000 (14:21 +0000)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java

index 726b217db43996520759c42b9f3306456d301c96..ab67cf8c6221f297bd97db55a4176b697e168e5d 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * 
+ *
  */
 package eu.etaxonomy.taxeditor.editor.view.descriptive.handler;
 
@@ -7,13 +7,10 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
 
-import javax.lang.model.element.Element;
-
 import org.apache.log4j.Logger;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
 import org.eclipse.core.commands.common.NotDefinedException;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
@@ -23,16 +20,14 @@ import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.cdm.api.service.IDescriptionService;
 import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
 import eu.etaxonomy.taxeditor.editor.Page;
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
 import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionToOtherTaxonOperation;
-//import eu.etaxonomy.taxeditor.navigator.operation.ChangeAcceptedTaxonToSynonymOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -44,31 +39,32 @@ import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
  * @author a.kohlbecker
  * @created Okt. 11, 2013
  * @version 1.0
- * 
+ *
  */
 public class MoveDescriptionToOtherTaxonHandler extends AbstractHandler
-               implements IHandler, IPostOperationEnabled {
+               implements IPostOperationEnabled {
        private static final Logger logger = Logger
                        .getLogger(MoveDescriptionToOtherTaxonHandler.class);
        private MoveDescriptionToOtherTaxonOperation operation;
 
        private UUID newAcceptedTaxonNodeUuid;
        private TaxonNameEditor editor;
-       
+
        /* (non-Javadoc)
         * @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 {
+
                ISelection selection = HandlerUtil.getCurrentSelection(event);
-               
+
                if(selection instanceof IStructuredSelection){
 
                        List<TaxonDescription> descriptions = new ArrayList<TaxonDescription>();
-                       
+
                        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
-                       
+
                        for(Object element : structuredSelection.toArray()){
                                if (element instanceof TaxonDescription){
                                        UUID uuid = ((TaxonDescription)element).getUuid();
@@ -78,54 +74,56 @@ public class MoveDescriptionToOtherTaxonHandler extends AbstractHandler
                        if(descriptions.size() == 0){
                                return null;
                        }
-                       
-                       // Choose the target taxon                              
+
+                       // Choose the target taxon
                        List<UUID> excludeTaxa = new ArrayList<UUID>();
                        editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME);
                        excludeTaxa.add(descriptions.get(0).getTaxon().getUuid());
-                       TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event), 
-                                       editor.getConversationHolder(), 
-                                       "Choose the accepted taxon", 
-                                       excludeTaxa, 
-                                       null, 
-                                       null);                  
-       
+                       TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event),
+                                       editor.getConversationHolder(),
+                                       "Choose the accepted taxon",
+                                       excludeTaxa,
+                                       null,
+                                       null);
+
                        if (newAcceptedTaxonNode == null) {
                                return null;
                        }
-                       
+
                        newAcceptedTaxonNodeUuid = newAcceptedTaxonNode.getUuid();
-                                       
+
                        try {
                                for(TaxonDescription description : descriptions){
-                                       operation = new MoveDescriptionToOtherTaxonOperation(event.getCommand().getName(), 
+                                       operation = new MoveDescriptionToOtherTaxonOperation(event.getCommand().getName(),
                                                                                        editor.getUndoContext(), description, newAcceptedTaxonNode, this, editor);
-                                       EditorUtil.executeOperation(operation);
+                                       AbstractUtility.executeOperation(operation);
                                }
-                               
+
                        } catch (NotDefinedException e) {
                                logger.warn("Command name not set");
                        }
                }
-               
+
                return null;
-               
+
        }
 
        /* (non-Javadoc)
         * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
         */
        /** {@inheritDoc} */
-       public boolean postOperation(CdmBase objectAffectedByOperation) {
+       @Override
+    public boolean postOperation(CdmBase objectAffectedByOperation) {
                Display.getDefault().asyncExec(new Runnable(){
 
-                       public void run() {
-                               EditorUtil.close(editor.getMultiPageTaxonEditor());
-                               
+                       @Override
+            public void run() {
+                               AbstractUtility.close(editor.getMultiPageTaxonEditor());
+
                                try {
                                        MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid);
                                        if(possibleOpenEditor != null){
-                                               EditorUtil.close(possibleOpenEditor);
+                                               AbstractUtility.close(possibleOpenEditor);
                                        }
                                        EditorUtil.openTaxonNode(newAcceptedTaxonNodeUuid);
                                } catch (PartInitException e) {
@@ -135,10 +133,10 @@ public class MoveDescriptionToOtherTaxonHandler extends AbstractHandler
                                        MessagingUtils.warningDialog("Could not create Taxon", this, e.getMessage());
                                }
                        }
-                       
+
                });
-               
-               
+
+
                return true;
        }
 
@@ -147,8 +145,9 @@ public class MoveDescriptionToOtherTaxonHandler extends AbstractHandler
         *
         * @return a boolean.
         */
-       public boolean onComplete() {
+       @Override
+    public boolean onComplete() {
                // TODO Auto-generated method stub
                return false;
-       }       
+       }
 }