Merge branch 'develop' into LibrAlign
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 18 Aug 2015 12:56:14 +0000 (14:56 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 18 Aug 2015 12:56:14 +0000 (14:56 +0200)
44 files changed:
eu.etaxonomy.taxeditor.application/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.application/plugin.xml
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/update/P2Util.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/MergeGroupHandler.java
eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin.properties
eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_de.properties
eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_en.properties
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/KeyEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/DeleteNodeOperation.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/DataImportEditorInput.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/GbifImportEditorInput.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientTaxonService.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/derivate/operation/MoveDerivateOperation.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionElementsHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/MoveDescriptionElementsOperation.java
eu.etaxonomy.taxeditor.molecular/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.molecular/build.properties
eu.etaxonomy.taxeditor.navigation/plugin.xml
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/PolytomousKeyViewPart.java
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigatorContentService.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigatorDnDService.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigatorViewer.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TreeNodeDragListener.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TreeNodeDropAdapter.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java
eu.etaxonomy.taxeditor.store/plugin.xml
eu.etaxonomy.taxeditor.store/schema/eu.etaxonomy.taxeditor.store.cdmViewer.exsd
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/DefinedTermMenu.java [deleted file]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/DefinedTermMenuFactory.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteConfiguratorDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteNodeConfiguratorComposite.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/UriWithLabelElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/FeatureDistributionDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/key/PolytomousKeyNodeDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/ImageFileElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/MediaDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/MediaRepresentationPartElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerContextMenu.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java
pom.xml

index 81bdf0a83e67d6553289f32ec6d37f413fdd5f0b..6a5c286864b932de03a3eebef50559186709fc25 100644 (file)
@@ -21,6 +21,7 @@ Require-Bundle: org.eclipse.ui,
  eu.etaxonomy.taxeditor.bulkeditor,
  eu.etaxonomy.taxeditor.editor,
  eu.etaxonomy.taxeditor.printpublisher,
+ eu.etaxonomy.taxeditor.molecular,
  eu.etaxonomy.taxeditor.help,
  org.eclipse.equinox.ds,
  org.eclipse.equinox.util,
index b74e209ce9d93b65fa3e04ed7461db32d7388015..f6e4ab946c5c8d097e40cd1c545415db42e68b5e 100644 (file)
        id="eu_etaxonomy_taxeditor_product"\r
        point="org.eclipse.core.runtime.products">\r
     <product\r
-          application="eu.etaxonomy.taxeditor.application.application"\r
+          application="eu.etaxonomy.taxeditor.editor.application"\r
           name="EDIT Taxonomic Editor">\r
        <property\r
              name="appName"\r
index 0a6fb6395ee0530208f6a66839ed79d4f627685d..9e1731c4cf7cdcc7c73745e5bcf39b1d8ef705b1 100644 (file)
@@ -7,6 +7,7 @@ import java.util.List;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.OperationCanceledException;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.IJobChangeEvent;
@@ -15,15 +16,17 @@ import org.eclipse.core.runtime.jobs.JobChangeAdapter;
 import org.eclipse.equinox.internal.p2.ui.ProvUI;
 import org.eclipse.equinox.internal.p2.ui.model.ElementUtils;
 import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
 import org.eclipse.equinox.p2.core.IProvisioningAgent;
 import org.eclipse.equinox.p2.core.ProvisionException;
 import org.eclipse.equinox.p2.operations.ProvisioningJob;
 import org.eclipse.equinox.p2.operations.ProvisioningSession;
+import org.eclipse.equinox.p2.operations.RepositoryTracker;
 import org.eclipse.equinox.p2.operations.Update;
 import org.eclipse.equinox.p2.operations.UpdateOperation;
-import org.eclipse.equinox.p2.repository.IRepository;
-import org.eclipse.equinox.p2.repository.IRepositoryManager;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
 import org.eclipse.equinox.p2.ui.ProvisioningUI;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.PlatformUI;
@@ -143,7 +146,7 @@ public class P2Util {
      *
      */
     public static void checkForUpdates() {
-
+        // the main job which performs the update
         Job updateJob = new Job("Update Job") {
             @Override
             public IStatus run(IProgressMonitor monitor) {
@@ -159,21 +162,6 @@ public class P2Util {
      */
     private static IStatus doCheckForUpdates(IProgressMonitor monitor) {
 
-     // force refresh all the caches before
-        IMetadataRepositoryManager metaManager = ProvUI.getMetadataRepositoryManager(ProvisioningUI.getDefaultUI().getSession());
-        URI[] repos = metaManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
-        for(URI repo : repos) {
-            try {
-                metaManager.refreshRepository(repo, monitor);
-            } catch (ProvisionException pe) {
-                IStatus errorStatus = new Status(IStatus.ERROR, TaxonomicEditorPlugin.PLUGIN_ID,
-                        "Error occured while reloading cache.", pe);
-
-            } catch (OperationCanceledException oce) {
-                IStatus errorStatus = new Status(IStatus.ERROR, TaxonomicEditorPlugin.PLUGIN_ID,
-                        "Error occured while reloading cache.", oce);
-            }
-        }
         BundleContext bundleContext = TaxonomicEditorPlugin.getContext();
         ServiceReference reference = bundleContext.getServiceReference(IProvisioningAgent.SERVICE_NAME);
         if (reference == null) {
index 5c0e8676ed02da8bbc536308dd3309393683d872..4a8ae8a3ce9df24256ef97a5e99e4312e99a7e11 100644 (file)
@@ -22,12 +22,17 @@ import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.handlers.HandlerUtil;
 import org.eclipse.ui.texteditor.IDocumentProvider;
 
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.strategy.merge.MergeException;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityContainer;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel;
 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
 import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants;
 import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
+import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
  * <p>MergeGroupHandler class.</p>
@@ -71,10 +76,41 @@ public class MergeGroupHandler extends AbstractHandler {
                        }                       
                        Object targetEntity = ((IEntityContainer<?>) targetAnnotation).getEntity();
                        
+                       TeamOrPersonBase teamOrPerson = null;
+                       Reference ref = null;
+                       if (targetEntity instanceof TeamOrPersonBase){
+                               teamOrPerson = HibernateProxyHelper.deproxy(targetEntity, TeamOrPersonBase.class);
+                       } else if(targetEntity instanceof Reference){
+                               ref = HibernateProxyHelper.deproxy(targetEntity, Reference.class);
+                       }
                        logger.info("Merging group");
 //                     model.printAnnotations();
                        for (LineAnnotation annotation : candidateAnnotations) {
+                               //first check whether entities are mergeable
+                               
                                
+                       try{
+                               if (ref != null){
+                                       Reference ref2 = HibernateProxyHelper.deproxy(annotation.getEntity(), Reference.class);
+                                       
+                                       if (!CdmStore.getCommonService().isMergeable(ref, ref2, null)){
+                                               MessageDialog.openWarning(HandlerUtil.getActiveShell(event), 
+                                                               "No merge possible", "A merge of " + ref.getTitleCache() + " and " + ref2.getTitleCache() + " is not possible.");
+                                               return null;
+                                       }
+                               }
+                               if (teamOrPerson != null){
+                                       TeamOrPersonBase teamOrPerson2 = HibernateProxyHelper.deproxy(annotation.getEntity(), TeamOrPersonBase.class);
+                                       
+                                       if (!CdmStore.getCommonService().isMergeable(teamOrPerson, teamOrPerson2, null)){
+                                               MessageDialog.openWarning(HandlerUtil.getActiveShell(event), 
+                                                               "No merge possible", "A merge of " + teamOrPerson.getTitleCache() + " and " + teamOrPerson2.getTitleCache() + " is not possible.");
+                                               return null;
+                                       }
+                               }
+                       }catch(MergeException e){
+                                       
+                       }
                                ((BulkEditor) editor).removeAnnotatedLine(annotation);
                                
                                // Mark entity container for merging with target entity
index 1c03030fc915ddc834cf1df4280e190e31a92032..8281fca55730c8e4d81a2fa766ff092f498fea7d 100644 (file)
@@ -9,7 +9,7 @@ editor.name.1 = Key
 editor.name.2 = Polytomous Key Graph Editor\r
 editor.name.3 = Polytomous Key List Editor\r
 editor.name.4 = Cdm Authority Editor\r
-editor.name.5 = Derivative View\r
+editor.name.5 = Derivative Editor\r
 view.name = Factual Data\r
 view.name.0 = Uses\r
 view.name.1 = Media\r
@@ -112,7 +112,7 @@ command.name.32 = Create Concept Relation
 command.name.33 = Open Related Concept\r
 category.name.7 = -- Group\r
 command.name.34 = Edit CDM Authorities\r
-command.name.35 = Open Derivative View\r
+command.name.35 = Open Derivative Editor\r
 scheme.description = The default key binding scheme for the Taxonomic Editor\r
 scheme.name = Taxonomic Editor Default Key Bindings\r
 editor.name.6 = Specimen Import Editor\r
index 803b460b910b316e22385caaf708145194e9e992..a4d096a11d103606e828005e75ba6cb461142e33 100644 (file)
@@ -112,7 +112,7 @@ command.name.32 = Erstelle Konzeptrelationen
 command.name.33 = \u00d6ffne verbundenes Konzept
 category.name.7 = -- Gruppe
 command.name.34 = Bearbeite CDM Rechte
-command.name.35 = \u00d6ffne Derivate Ansicht
+command.name.35 = \u00d6ffne Derivat-Editor
 scheme.description = Die Standard Tastenkombinationsschema f\u00fcr den Taxonomischen Editor
 scheme.name = Taxonomic Editor Standard Tastenkombinationen
 editor.name.6 = Specimen Import Editor
index 65d48bae536842cd7d76985773f77ae134851e3f..17a5b049048252c4a6b4c41bee895d67cbf1b017 100644 (file)
@@ -111,7 +111,6 @@ command.name.32 = Create Concept Relation
 command.name.33 = Open Related Concept\r
 category.name.7 = -- Group\r
 command.name.34 = Edit CDM Authorities\r
-command.name.35 = Open Derivate View\r
 scheme.description = The default key binding scheme for the Taxonomic Editor\r
 scheme.name = Taxonomic Editor Default Key Bindingseditor.name.6 = Specimen Import Editor\r
 editor.name.7 = Gbif Import Editor\r
index b3c364a17b50b074d2136075a4a9e7c32af3de97..b9a3d50db54a0e6946d6ef4b413333c62c4b3d6a 100644 (file)
                commandId="eu.etaxonomy.taxeditor.editor.command.new.name"
                label="%command.label.46"
                style="push">
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
          <command
                commandId="eu.etaxonomy.taxeditor.editor.command.new.reference"
                label="%command.label.47"
                style="push">
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
          <command
                commandId="eu.etaxonomy.taxeditor.editor.command.new.team"
                label="%command.label.1"
                style="push">
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
          <command
                commandId="eu.etaxonomy.taxeditor.editor.command.new.person"
                label="%command.label.2"
                style="push">
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
          <separator
                name="eu.etaxonomy.navigation.menu.new.separator2"
                commandId="eu.etaxonomy.taxeditor.editor.command.new.specimen"
                label="%command.label.3"
                style="push">
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
          <separator
                name="eu.etaxonomy.navigation.menu.new.separator3"
                commandId="eu.etaxonomy.taxeditor.editor.command.new.datasource"
                label="%command.label.48"
                style="push">
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
       </menuContribution>
       <menuContribution
                   name="org.eclipse.ui.views.showView.viewId"
                   value="eu.etaxonomy.taxeditor.editor.view.descriptive">
             </parameter>
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
          <command
                commandId="org.eclipse.ui.views.showView"
                   name="org.eclipse.ui.views.showView.viewId"
                   value="eu.etaxonomy.taxeditor.editor.view.media">
             </parameter>
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
          <command
                commandId="org.eclipse.ui.views.showView"
                   name="org.eclipse.ui.views.showView.viewId"
                   value="eu.etaxonomy.taxeditor.editor.view.concept">
             </parameter>
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
          <command
                commandId="org.eclipse.ui.views.showView"
                   value="eu.etaxonomy.taxeditor.editor.view.concept.graph">
             </parameter>
             <visibleWhen
-                  checkEnabled="true">
-               <and>
-                  <reference
-                        definitionId="isShowExperimentalFeatures">
-                  </reference>
-                  <reference
-                        definitionId="isCdmStoreConnected">
-                  </reference>
-               </and>
+                  checkEnabled="false">
+               <reference
+                     definitionId="isShowExperimentalFeatures">
+               </reference>
             </visibleWhen>
          </command>
       </menuContribution>
                commandId="eu.etaxonomy.taxeditor.editor.command.openParent"
                label="%command.label.8"
                style="push">
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
       </menuContribution>
       <menuContribution
             <visibleWhen
                   checkEnabled="true">
                <or>
-                  <reference
-                        definitionId="isDescriptionElement">
-                  </reference>
                   <reference
                         definitionId="isFeatureNodeContainer">
                   </reference>
                   name="org.eclipse.ui.views.showView.viewId"
                   value="eu.etaxonomy.taxeditor.editor.view.validation.problems">
             </parameter>
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
       </menuContribution>
    </extension>
             id="eu.etaxonomy.taxeditor.editor.media.command.delete"
             name="%command.name.49">
       </command>
+      
       <category
             id="eu.etaxonomy.taxeditor.editor.new.category"
             name="%category.name.4">
       <command
             categoryId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.category"
             defaultHandler="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.MoveDescriptionToOtherTaxonHandler"
-            id="eu.etaxonomy.taxeditor.editor.commands.description.moveDescriptionToTaxon"
+            id="eu.etaxonomy.taxeditor.editor.view.descriptive.command.moveDescriptionToTaxon"
             name="%command.name.13">
       </command>
+       
       <command
             categoryId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.category"
             defaultHandler="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.MoveDescriptionElementsHandler"
-            id="eu.etaxonomy.taxeditor.description.commands.moveDescriptionElements"
+            id="eu.etaxonomy.taxeditor.editor.view.descriptive.command.moveDescriptionElements"
             name="%command.name.12">
       </command>
         
          </description>
       </wizard>
    </extension>
+    <extension
+          point="eu.etaxonomy.taxeditor.store.cdmViewer">
+       <cdmViewer
+             class="eu.etaxonomy.taxeditor.editor.EditorCdmViewer">
+       </cdmViewer>
+    </extension>
 </plugin>
index 5fc0b2b9a7398afbfecf0dc27e8f399364f39646..7b9a605cf3719f445a17a58678363142ff271d39 100644 (file)
@@ -83,6 +83,7 @@ public class KeyEditor extends FormEditor implements IConversationEnabled,
 
        @Override
        public void setFocus() {
+               getConversationHolder().commit(true);
                getConversationHolder().bind();
                super.setFocus();
        }
index ceae45d69d43fd57c6ea825e9928e868b7ac14f8..dc81964bcb980a3f797810c654c7f6c6b073264f 100644 (file)
@@ -345,7 +345,8 @@ public class PolytomousKeyListEditor extends EditorPart implements
        @Override
        public boolean postOperation(CdmBase objectAffectedByOperation) {
                viewer.refresh();
-
+               getConversationHolder().bind();
+               getConversationHolder().commit(true);
                editor.changed(objectAffectedByOperation);
 
                if (objectAffectedByOperation != null) {
index 3b4ae0d7ab1d1bcad784e2b7d041f4eabee34ad3..f31a83125aa62cf9cf7d9846550908e69a0b318d 100644 (file)
@@ -12,9 +12,12 @@ import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
+import eu.etaxonomy.cdm.api.service.DeleteResult;
 import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;
 import eu.etaxonomy.cdm.api.service.ITaxonService;
 import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
+import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -52,15 +55,27 @@ public class DeleteNodeOperation extends AbstractPostTaxonOperation {
                controller = (ICdmApplicationConfiguration) CdmStore.getCurrentApplicationConfiguration();
                
                IPolytomousKeyNodeService service = controller.getPolytomousKeyNodeService();
-               
+               DeleteResult result;
                if (node.getChildren().size()>0){
                        if(! MessageDialog.openQuestion(null, "Confirm deletion of children", "The selected node has children, do you want to delete them, too?")) {
-                               service.delete(node.getUuid(), false);
+                               result = service.delete(node.getUuid(), false);
                        } else{
-                               service.delete(node.getUuid(), true);
+                               result = service.delete(node.getUuid(), true);
                        }
                } else{
-                       service.delete(node.getUuid(), true);
+                       result = service.delete(node.getUuid(), true);
+               }
+               
+               if (!result.isOk() || result.getExceptions().size() > 0){
+                       Exception t = new Exception();
+                       if (result.getExceptions().size() >1){
+                               for (Exception e:result.getExceptions()){
+                                       t.addSuppressed(e);
+                               }
+                       }else {
+                               t = result.getExceptions().iterator().next();
+                       }
+                       MessagingUtils.errorDialog("Exception occured. Delete not possible", getClass(),null, TaxeditorBulkeditorPlugin.PLUGIN_ID, t, true);
                }
                return postExecute(null);
        }
index a74d15d44c56ca2ddcb11d95df5fc740297d1631..5be66c8bce3a9913d602e7e09673efd28c78891d 100644 (file)
@@ -21,6 +21,9 @@ import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
+ * Input for {@link DataImportEditor}. This class queries a data source for
+ * occurrences and passes them to the editor.
+ *
  * @author pplitzner
  * @date 25.02.2014
  *
@@ -35,65 +38,40 @@ public abstract class DataImportEditorInput<T> implements IEditorInput {
 
     protected OccurenceQuery query;
 
-    /**
-     * @param results
-     */
     public DataImportEditorInput() {
         this.conversationHolder = CdmStore.createConversation();
     }
 
-
-    /* (non-Javadoc)
-     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
-     */
     @Override
     public Object getAdapter(Class adapter) {
         // TODO Auto-generated method stub
         return null;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#exists()
-     */
     @Override
     public boolean exists() {
         return false;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
-     */
     @Override
     public ImageDescriptor getImageDescriptor() {
         // TODO Auto-generated method stub
         return null;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#getPersistable()
-     */
     @Override
     public IPersistableElement getPersistable() {
         return null;
     }
 
-    /**
-     * @return the results
-     */
     public Collection<T> getResults() {
         return results;
     }
 
-    /**
-     * @param results the results to set
-     */
     public void setResults(Collection<T> results) {
         this.results = results;
     }
 
-    /**
-     * @return the conversationHolder
-     */
     public ConversationHolder getConversationHolder() {
         return conversationHolder;
     }
index ed7c89cc0cf3313004d0ee90754c186585ec99ec..3aaf22c5269c7e72b2681852295ae285da873d1f 100644 (file)
@@ -26,9 +26,6 @@ import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse;
  */
 public class GbifImportEditorInput extends DataImportEditorInput<GbifResponse> {
 
-    /**
-     * @param query
-     */
     public GbifImportEditorInput(OccurenceQuery query) {
         super();
         this.query = query;
@@ -50,25 +47,16 @@ public class GbifImportEditorInput extends DataImportEditorInput<GbifResponse> {
     }
 
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#getName()
-     */
     @Override
     public String getName() {
         return "[GBIF] " + query.toString();
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#getToolTipText()
-     */
     @Override
     public String getToolTipText() {
         return "[GBIF] " + query.toString();
     }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#hashCode()
-     */
     @Override
     public int hashCode() {
         final int prime = 31;
@@ -77,9 +65,6 @@ public class GbifImportEditorInput extends DataImportEditorInput<GbifResponse> {
         return result;
     }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
     @Override
     public boolean equals(Object obj) {
         if (this == obj) {
index 407234ba7fa2c07b1571cc83d8bc912576efefd7..d1daa7b1f27dea8b4fb874d0ca0f72fe003eb84d 100644 (file)
@@ -1344,7 +1344,7 @@ public class TransientTaxonService implements ITaxonService {
     public List<List<Synonym>> getSynonymsByHomotypicGroup(Taxon taxon, List<String> propertyPaths) {
         return defaultService.getSynonymsByHomotypicGroup(taxon, propertyPaths);
     }
-
+    
     @Override
     public Synonym changeRelatedTaxonToSynonym(Taxon fromTaxon, Taxon toTaxon,
             TaxonRelationshipType oldRelationshipType,
index 7548960d901fee8e5cf57967c11d847e1f60866a..a7845395ed1b783ac5bb80dc3a0cf5d933986ed5 100644 (file)
@@ -166,7 +166,7 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
             DerivateViewEditorInput derivateViewEditorInput = (DerivateViewEditorInput) getEditorInput();
             return derivateViewEditorInput.getName();
         }
-        return "Derivative View";
+        return "Derivative Editor";
     }
 
     /* (non-Javadoc)
index b863dcbe28a14aa047007dccf5189f11df1cd582..9931904ff8478df078fe61513974fef264703074 100644 (file)
@@ -63,7 +63,7 @@ public class MoveDerivateOperation extends AbstractPostOperation<CdmBase>  {
             derivateView = (DerivateView) getPostOperationEnabled();
         }
         if(derivateView==null){
-            MessagingUtils.operationDialog(this, new NullPointerException("DerivativeView was null"), TaxeditorEditorPlugin.PLUGIN_ID, this.getLabel(), getLabel());
+            MessagingUtils.operationDialog(this, new NullPointerException("Derivative Editor was null"), TaxeditorEditorPlugin.PLUGIN_ID, this.getLabel(), getLabel());
             return Status.CANCEL_STATUS;
         }
         if(derivateView.isDirty()){
index 0c2306ba6081a6da06c1e32e6b2dedc3cd552664..9a801a4d412797995c6899f6ae3f8c6045152438 100644 (file)
@@ -20,25 +20,36 @@ import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.commands.common.NotDefinedException;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.cdm.api.service.IDescriptionService;
 import eu.etaxonomy.cdm.api.service.ITaxonService;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.common.Annotation;
 import eu.etaxonomy.cdm.model.common.AnnotationType;
+import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
+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.name.TaxonNameEditor;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionElementsOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonBaseSelectionDialog;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
 
 
 /**
@@ -46,8 +57,9 @@ import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonBaseSelectionDialog;
  * @created Feb 8, 2011
  * @version 1.0
  */
-public class MoveDescriptionElementsHandler extends AbstractHandler {
-
+public class MoveDescriptionElementsHandler extends AbstractHandler implements IPostOperationEnabled{
+       private UUID newAcceptedTaxonNodeUuid;
+       private TaxonNameEditor editor;
        /* (non-Javadoc)
         * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
         */
@@ -55,7 +67,7 @@ public class MoveDescriptionElementsHandler extends AbstractHandler {
        public Object execute(ExecutionEvent event) throws ExecutionException {
                
 //             ConversationHolder conversation = CdmStore.createConversation();
-               
+               editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME);
                ISelection selection = HandlerUtil.getCurrentSelection(event);
                
                if(selection instanceof IStructuredSelection){
@@ -81,14 +93,28 @@ public class MoveDescriptionElementsHandler extends AbstractHandler {
                        if(elements.size() == 0){
                                return null;
                        }
+                       DescriptionBase description = elements.get(0).getInDescription();
+                       List<UUID> excludeTaxa = new ArrayList<UUID>();
+                       if (description.isInstanceOf(TaxonDescription.class)){
+                               TaxonDescription taxonDescription = HibernateProxyHelper.deproxy(description, TaxonDescription.class);
+                               Taxon actualTaxon = taxonDescription.getTaxon();
+                               excludeTaxa.add(actualTaxon.getUuid());
+                       }
                        
-                       Taxon targetTaxon = TaxonBaseSelectionDialog.selectTaxon(HandlerUtil.getActiveShell(event), EditorUtil.getActiveMultiPageTaxonEditor().getConversationHolder(), null);
+                       
+                       TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event),
+                                       editor.getConversationHolder(),
+                                       "Choose the accepted taxon",
+                                       excludeTaxa,
+                                       null,
+                                       null);
+                       Taxon targetTaxon = newAcceptedTaxonNode.getTaxon();
                        
                        if(targetTaxon == null){
                                // canceled
                                return null;
                        }
-                                               
+                       newAcceptedTaxonNodeUuid = newAcceptedTaxonNode.getUuid();                      
                        TaxonDescription targetDescription = TaxonDescription.NewInstance(targetTaxon);
                        String moveMessage = String.format("Elements moved from %s", EditorUtil.getActiveMultiPageTaxonEditor().getTaxon());
                        targetDescription.setTitleCache(moveMessage, true);
@@ -99,10 +125,11 @@ public class MoveDescriptionElementsHandler extends AbstractHandler {
                        try {
                                AbstractPostOperation operation = new MoveDescriptionElementsOperation(
                                                event.getCommand().getName(), EditorUtil.getUndoContext(), 
-                                               targetDescription, elements, false, (IPostOperationEnabled) EditorUtil.getView(DescriptiveViewPart.ID, true));
+                                               targetDescription, elements, false, this);
+                               
                                EditorUtil.executeOperation(operation);
-//                             conversation.commit(true);
-                               CdmStore.getService(ITaxonService.class).saveOrUpdate(targetTaxon);
+                               
+                               //CdmStore.getService(ITaxonService.class).saveOrUpdate(targetTaxon);
                                
                        } catch (NotDefinedException e) {
                                MessagingUtils.error(getClass(), e);
@@ -112,4 +139,44 @@ public class MoveDescriptionElementsHandler extends AbstractHandler {
                return null;
        }
 
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
+        */
+       /** {@inheritDoc} */
+       @Override
+    public boolean postOperation(CdmBase objectAffectedByOperation) {
+               
+               editor.getConversationHolder().bind();
+               editor.getConversationHolder().commit(true);
+               Display.getDefault().asyncExec(new Runnable(){
+                       
+            public void run() {
+                               //AbstractUtility.close(editor.getMultiPageTaxonEditor());
+
+                               try {
+                                       MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid);
+                                       if(possibleOpenEditor != null){
+                                               AbstractUtility.close(possibleOpenEditor);
+                                       }
+                                       EditorUtil.openTaxonNode(newAcceptedTaxonNodeUuid);
+                               } catch (PartInitException e) {
+                                       MessagingUtils.error(this.getClass(), e);
+                                       throw new RuntimeException(e);
+                               } catch (Exception e) {
+                                       MessagingUtils.warningDialog("Could not create Taxon", this, e.getMessage());
+                               }
+                       }
+
+               });
+
+
+               return true;
+       }
+
+       @Override
+       public boolean onComplete() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+       
 }
index ab67cf8c6221f297bd97db55a4176b697e168e5d..c4b57e9cb4629968822bd35d951b0bbb9c407a00 100644 (file)
@@ -20,6 +20,7 @@ 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.DescriptionBase;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
@@ -28,6 +29,7 @@ import eu.etaxonomy.taxeditor.editor.Page;
 import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionToOtherTaxonOperation;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -66,8 +68,14 @@ public class MoveDescriptionToOtherTaxonHandler extends AbstractHandler
                        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
 
                        for(Object element : structuredSelection.toArray()){
-                               if (element instanceof TaxonDescription){
-                                       UUID uuid = ((TaxonDescription)element).getUuid();
+                               UUID uuid = null;
+                               if (element instanceof FeatureNodeContainer){
+                                       uuid = ((FeatureNodeContainer)element).getDescription().getUuid();
+                               }       else if (element instanceof DescriptionBase){
+                                       uuid = ((DescriptionBase)element).getUuid();
+                               }
+                               
+                               if (uuid != null){
                                        descriptions.add((TaxonDescription) CdmStore.getService(IDescriptionService.class).load(uuid, null));
                                }
                        }
index 5b4b0053ed727bfea012bd536bf289b3378dd06e..fd74d72745e6dc55a6ef9ba1e3f7b74ca6c2f8d1 100644 (file)
@@ -17,10 +17,17 @@ import org.eclipse.core.commands.operations.IUndoContext;
 import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PartInitException;
 
 import eu.etaxonomy.cdm.api.service.IDescriptionService;
+import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.description.DescriptionBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -30,7 +37,7 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  * @created Feb 8, 2011
  * @version 1.0
  */
-public class MoveDescriptionElementsOperation extends AbstractPostTaxonOperation {
+public class MoveDescriptionElementsOperation extends AbstractPostTaxonOperation{
 
        private Collection<DescriptionElementBase> descriptionElements;
        private DescriptionBase targetDescription;
@@ -68,6 +75,7 @@ public class MoveDescriptionElementsOperation extends AbstractPostTaxonOperation
                
                service.moveDescriptionElementsToDescription(descriptionElements, targetDescription, isCopy);
                
+               
                return postExecute(targetDescription);
        }
 
@@ -90,5 +98,7 @@ public class MoveDescriptionElementsOperation extends AbstractPostTaxonOperation
                // TODO Auto-generated method stub
                return null;
        }
+       
+       
 
 }
index 38ab0a72ca64c613b5b7b894d6a665d6afbc38a3..05dba64f189a6a8eeac1d30c54bd3e541a0f3c3d 100644 (file)
@@ -16,3 +16,7 @@ Require-Bundle: org.eclipse.ui,
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
 Bundle-Vendor: EDIT
+Export-Package: eu.etaxonomy.taxeditor.molecular,
+ eu.etaxonomy.taxeditor.molecular.editor,
+ eu.etaxonomy.taxeditor.molecular.handler
+Bundle-ClassPath: .
index e4bf8ac385bd985f3c91555d812a0bdfba38c571..bdd1c23c42f573c05d209014e892ed57663fdf11 100644 (file)
@@ -1,4 +1,6 @@
-bin.includes = META-INF/,\
+bin.includes = .,\
+                          META-INF/,\
                plugin.xml,\
                icons/,\
                OSGI-INF/
+source.. = src/main/java/
index 2ace44ef5c2038708d29704c16ca45c31fa1c80a..86609245a3571b0d1283dfd2b75e6977e441a567 100644 (file)
          <dynamic
                class="eu.etaxonomy.taxeditor.navigation.RecentNamesContributionItem"
                id="eu.etaxonomy.taxeditor.navigation.recentnames">
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </dynamic>
       </menuContribution>
       <menuContribution
                   name="org.eclipse.ui.views.showView.viewId"
                   value="eu.etaxonomy.taxeditor.navigation.navigator">
             </parameter>
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
          <command
                commandId="org.eclipse.ui.views.showView"
                   name="org.eclipse.ui.views.showView.viewId"
                   value="eu.etaxonomy.taxeditor.navigation.key.polytomous.polytomousKeyViewPart">
             </parameter>
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
       </menuContribution>
       <menuContribution
                id="eu.etaxonomy.taxeditor.navigation.search.toolbar">
             <control
                   class="eu.etaxonomy.taxeditor.navigation.search.SearchBar">
-               <visibleWhen
-                     checkEnabled="true">
-                  <reference
-                        definitionId="isCdmStoreConnected">
-                  </reference>
-               </visibleWhen>
             </control>
          </toolbar>
       </menuContribution>
                commandId="eu.etaxonomy.taxeditor.navigation.command.create.taxonNode"
                label="%command.label.13"
                style="push">
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
          <separator
                name="eu.etaxonomy.navigation.menu.new.separator1"
                id="eu.etaxonomy.taxeditor.navigation.create.classificationHandler"
                label="%command.label.14"
                style="push">
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
       </menuContribution>
       <menuContribution
          </with>
       </definition>
    </extension>
+   <extension
+         point="eu.etaxonomy.taxeditor.store.cdmViewer">
+      <cdmViewer
+            class="eu.etaxonomy.taxeditor.navigation.NavigationCdmViewer">
+      </cdmViewer>
+   </extension>
 </plugin>
index 6075a5062f122bba9aaa72f6a72341269d26685e..09861da31f570eab8ec72987fa1871250de4df73 100644 (file)
@@ -247,6 +247,8 @@ public class PolytomousKeyViewPart extends ViewPart implements
         */
        @Override
        public boolean postOperation(CdmBase objectAffectedByOperation) {
+               getConversationHolder().bind();
+               getConversationHolder().commit(true);
                viewer.refresh();
                return true;
        }
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigatorContentService.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigatorContentService.java
new file mode 100644 (file)
index 0000000..46c659b
--- /dev/null
@@ -0,0 +1,30 @@
+package eu.etaxonomy.taxeditor.navigation.navigator;
+
+import org.eclipse.ui.internal.navigator.NavigatorContentService;
+import org.eclipse.ui.navigator.INavigatorDnDService;
+
+public class TaxonNavigatorContentService extends NavigatorContentService {
+
+       private TaxonNavigatorDnDService navigatorDnDService;
+
+       public TaxonNavigatorContentService(String viewerID) {
+               super(viewerID);
+               
+               
+       }
+       
+       public TaxonNavigatorContentService(String aViewerId,
+                       TaxonNavigatorViewer taxonNavigatorViewer) {
+               super(aViewerId, taxonNavigatorViewer);
+               getDnDService();
+       }
+
+       @Override
+       public TaxonNavigatorDnDService getDnDService() {
+               if (navigatorDnDService == null) {
+                       navigatorDnDService = new TaxonNavigatorDnDService(this);
+               }
+               return navigatorDnDService;
+       }
+
+}
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigatorDnDService.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigatorDnDService.java
new file mode 100644 (file)
index 0000000..5de170c
--- /dev/null
@@ -0,0 +1,170 @@
+package eu.etaxonomy.taxeditor.navigation.navigator;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.ui.internal.navigator.dnd.CommonDropAdapterDescriptor;
+import org.eclipse.ui.internal.navigator.dnd.CommonDropDescriptorManager;
+import org.eclipse.ui.internal.navigator.extensions.CommonDragAssistantDescriptor;
+import org.eclipse.ui.internal.navigator.extensions.NavigatorViewerDescriptor;
+import org.eclipse.ui.navigator.CommonDragAdapterAssistant;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
+import org.eclipse.ui.navigator.INavigatorContentService;
+import org.eclipse.ui.navigator.INavigatorDnDService;
+
+import eu.etaxonomy.taxeditor.navigation.navigator.dnd.TaxonNavigatorDragAdapterAssistant;
+
+public class TaxonNavigatorDnDService implements INavigatorDnDService {
+       private static final CommonDropAdapterAssistant[] NO_ASSISTANTS = new CommonDropAdapterAssistant[0];
+
+       private INavigatorContentService contentService;
+
+       private TaxonNavigatorDragAdapterAssistant[] dragAssistants;
+       
+       private TreeNodeDropAdapter dropAdapter;
+
+       private final Map dropAssistants = new HashMap();
+       
+       public TaxonNavigatorDnDService(INavigatorContentService contentService){
+               this.contentService = contentService;
+       }
+       
+       
+       @Override
+       public CommonDragAdapterAssistant[] getCommonDragAssistants() {
+               
+               return dragAssistants;
+       }
+
+       @Override
+       public void bindDragAssistant(CommonDragAdapterAssistant anAssistant) {
+               if(dragAssistants == null) 
+                       initializeDragAssistants(); 
+               TaxonNavigatorDragAdapterAssistant[] newDragAssistants = new TaxonNavigatorDragAdapterAssistant[dragAssistants.length + 1];
+               System.arraycopy(dragAssistants, 0, newDragAssistants, 0, dragAssistants.length);
+               newDragAssistants[dragAssistants.length] = (TaxonNavigatorDragAdapterAssistant) anAssistant;
+               dragAssistants = newDragAssistants;             
+
+       }
+       
+       private void initializeDragAssistants() {
+               int i = 0;
+               Set dragDescriptors = ((NavigatorViewerDescriptor) contentService
+                               .getViewerDescriptor()).getDragAssistants();
+               dragAssistants = new TaxonNavigatorDragAdapterAssistant[dragDescriptors
+                               .size()];
+               for (Iterator iter = dragDescriptors.iterator(); iter.hasNext();) {
+                       CommonDragAssistantDescriptor descriptor = (CommonDragAssistantDescriptor) iter
+                                       .next();
+                       dragAssistants[i++] = (TaxonNavigatorDragAdapterAssistant) descriptor.createDragAssistant();
+               }
+       }
+
+       @Override
+       public CommonDropAdapterAssistant[] findCommonDropAdapterAssistants(
+                       Object aDropTarget, TransferData aTransferType) {
+               CommonDropAdapterDescriptor[] descriptors = CommonDropDescriptorManager
+                               .getInstance().findCommonDropAdapterAssistants(aDropTarget,
+                                               contentService);
+
+               if (descriptors.length == 0) {
+                       return NO_ASSISTANTS;
+               }
+
+               if (LocalSelectionTransfer.getTransfer().isSupportedType(aTransferType)  
+                                               && LocalSelectionTransfer.getTransfer().getSelection() instanceof IStructuredSelection) {
+                       return getAssistantsBySelection(descriptors, (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection());
+               } 
+               return getAssistantsByTransferData(descriptors, aTransferType);
+       }
+       
+       private CommonDropAdapterAssistant[] getAssistantsByTransferData(
+                       CommonDropAdapterDescriptor[] descriptors,
+                       TransferData aTransferType) {
+
+               Set assistants = new LinkedHashSet();
+               for (int i = 0; i < descriptors.length; i++) {
+                       CommonDropAdapterAssistant asst = getAssistant(descriptors[i]);
+                       if (asst.isSupportedType(aTransferType)) {
+                               assistants.add(asst);
+                       }
+               }
+               return sortAssistants((CommonDropAdapterAssistant[]) assistants
+                               .toArray(new CommonDropAdapterAssistant[assistants.size()]));
+
+       }
+       
+       private CommonDropAdapterAssistant[] getAssistantsBySelection(
+                       CommonDropAdapterDescriptor[] descriptors, IStructuredSelection aSelection) {
+
+               Set assistants = new LinkedHashSet(); 
+                       
+               for (int i = 0; i < descriptors.length; i++) {
+                       if(descriptors[i].areDragElementsSupported(aSelection)) {
+                               assistants.add(getAssistant(descriptors[i]));
+                       }
+               }  
+
+               return sortAssistants((CommonDropAdapterAssistant[]) assistants
+                               .toArray(new CommonDropAdapterAssistant[assistants.size()]));
+       }
+       
+       private CommonDropAdapterAssistant getAssistant(
+                       CommonDropAdapterDescriptor descriptor) {
+               TreeNodeDropAdapterAssistant asst = (TreeNodeDropAdapterAssistant) dropAssistants
+                               .get(descriptor);
+               if (asst != null) {
+                       return asst;
+               }
+               synchronized (dropAssistants) {
+                       asst = (TreeNodeDropAdapterAssistant) dropAssistants.get(descriptor);
+                       if (asst == null) {
+                               dropAssistants.put(descriptor, (asst = (TreeNodeDropAdapterAssistant) descriptor
+                                               .createDropAssistant()));
+                               asst.init(contentService);
+                               //asst.setCommonDropAdapter(dropAdapter);
+                       }
+               }
+               return asst;
+       }
+
+
+       private CommonDropAdapterAssistant[] sortAssistants(CommonDropAdapterAssistant[] array) {
+               Arrays.sort(array, new Comparator() {
+                       public int compare(Object arg0, Object arg1) {
+                               CommonDropAdapterAssistant a = (CommonDropAdapterAssistant) arg0;
+                               CommonDropAdapterAssistant b = (CommonDropAdapterAssistant) arg1;
+                               // This is to ensure that the navigator resources drop assistant will
+                               // always be first on the list of drop assistant, if a conflict ever 
+                               // occurs.
+                               String id = "org.eclipse.ui.navigator.resources."; //$NON-NLS-1$
+                               if (a.getClass().getName().startsWith(id))
+                                       return -1;
+                               if (b.getClass().getName().startsWith(id))
+                                       return 1;
+                               return a.getClass().getName().compareTo(b.getClass().getName());
+                       }
+               });
+               return array;
+       }
+
+       @Override
+       public CommonDropAdapterAssistant[] findCommonDropAdapterAssistants(
+                       Object aDropTarget, IStructuredSelection theDragSelection) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public void setDropAdaptor(TreeNodeDropAdapter da) {
+               dropAdapter = da;
+       }
+}
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigatorViewer.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigatorViewer.java
new file mode 100644 (file)
index 0000000..8fdabb8
--- /dev/null
@@ -0,0 +1,54 @@
+package eu.etaxonomy.taxeditor.navigation.navigator;
+
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.internal.navigator.NavigatorContentService;
+import org.eclipse.ui.internal.navigator.dnd.NavigatorDnDService;
+import org.eclipse.ui.navigator.CommonDragAdapter;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.INavigatorContentService;
+
+import eu.etaxonomy.taxeditor.dnd.transfer.TaxonNodeTransfer;
+
+public class TaxonNavigatorViewer extends CommonViewer {
+
+       private NavigatorContentService contentService;
+       String viewerId;
+
+       public TaxonNavigatorViewer(String aViewerId, Composite aParent, int aStyle) {
+               super(aViewerId, aParent, aStyle);
+               contentService = new TaxonNavigatorContentService(aViewerId, this);
+               viewerId = aViewerId;
+       }
+
+       @Override
+       protected void initDragAndDrop() {
+
+               int operations =  DND.DROP_MOVE ;
+
+               CommonDragAdapter dragAdapter = createDragAdapter();
+               addDragSupport(operations, dragAdapter.getSupportedDragTransfers(),
+                               dragAdapter);
+               Transfer[] transfers = new Transfer[] { TaxonNodeTransfer.getInstance() };
+               TreeNodeDropAdapter dropAdapter = createTreeNodeDropAdapter();
+               addDropSupport(operations, transfers, dropAdapter);
+
+               TaxonNavigatorDnDService dnd = (TaxonNavigatorDnDService)getNavigatorContentService().getDnDService();
+               dnd.setDropAdaptor(dropAdapter);
+       }
+       
+       
+       protected TreeNodeDropAdapter createTreeNodeDropAdapter() {
+               return new TreeNodeDropAdapter(this);
+       }
+       
+       public NavigatorContentService getNavigatorContentService(){
+               if (contentService == null){
+                       contentService = new TaxonNavigatorContentService(viewerId);
+               } 
+               return contentService;
+       }
+       
+}
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TreeNodeDragListener.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TreeNodeDragListener.java
new file mode 100644 (file)
index 0000000..9cd02f9
--- /dev/null
@@ -0,0 +1,83 @@
+// $Id$
+/**
+* Copyright (C) 2015 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.navigation.navigator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.dnd.DragSourceAdapter;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.ui.navigator.CommonViewer;
+
+
+import eu.etaxonomy.cdm.model.common.DefinedTermBase;
+import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.dnd.transfer.TaxonNodeTransfer;
+import eu.etaxonomy.taxeditor.editor.definedterm.TermTransfer;
+
+/**
+ * @author k.luther
+ * @date 02.06.2015
+ *
+ */
+public class TreeNodeDragListener extends DragSourceAdapter {
+       private CommonViewer viewer;
+
+       /**
+        * 
+        */
+       public TreeNodeDragListener(CommonViewer viewer) {
+               this.viewer = viewer;
+       }
+
+       
+       public void setViewer(CommonViewer viewer){
+               this.viewer = viewer;
+       }
+       /* (non-Javadoc)
+        * @see org.eclipse.swt.dnd.DragSourceAdapter#dragStart(org.eclipse.swt.dnd.DragSourceEvent)
+        */
+       @Override
+       public void dragStart(DragSourceEvent event) {
+               
+               event.doit = true;// set to false if needed - default is true
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.swt.dnd.DragSourceAdapter#dragFinished(org.eclipse.swt.dnd.DragSourceEvent)
+        */
+       @Override
+       public void dragFinished(DragSourceEvent event) {
+               // TODO Auto-generated method stub
+               super.dragFinished(event);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.swt.dnd.DragSourceAdapter#dragSetData(org.eclipse.swt.dnd.DragSourceEvent)
+        */
+       @Override
+       public void dragSetData(DragSourceEvent event) {
+               
+               IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+               List<ITaxonTreeNode> taxonNodes = new ArrayList<ITaxonTreeNode>();
+               
+               for (Object object : selection.toList()){
+                       taxonNodes.add((ITaxonTreeNode)object);
+                       }
+                       
+               if (TaxonNodeTransfer.getInstance().isSupportedType(
+                               event.dataType)) {
+                       event.data = taxonNodes.toArray(new TaxonNode[taxonNodes.size()]);
+               }
+       }
+}
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TreeNodeDropAdapter.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TreeNodeDropAdapter.java
new file mode 100644 (file)
index 0000000..448da05
--- /dev/null
@@ -0,0 +1,284 @@
+// $Id$
+/**
+* Copyright (C) 2015 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.navigation.navigator;
+
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IconAndMessageDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerDropAdapter;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
+import org.eclipse.ui.navigator.CommonViewer;
+
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.common.OrderedTermBase;
+import eu.etaxonomy.cdm.model.common.TermBase;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
+import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;
+import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
+import eu.etaxonomy.taxeditor.navigation.navigator.operation.MoveTaxonOperation;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * <p>TreeNodeDropAdapter class.</p>
+ *
+ * @author k.luther
+ * @date 02.06.2015
+ * @version 1.0
+ */
+public class TreeNodeDropAdapter extends ViewerDropAdapter implements IPostOperationEnabled {
+
+       /**
+        * @param viewer
+        */
+       protected TreeNodeDropAdapter(TaxonNavigatorViewer navigatorViewer) {
+               super(navigatorViewer);
+               this.navigatorViewer = navigatorViewer;
+               
+       }
+       
+       private final TaxonNavigatorViewer navigatorViewer;
+       private static final Logger logger = Logger.getLogger(TreeNodeDropAdapter.class);
+
+       /** Constant <code>ID="eu.etaxonomy.taxeditor.navigation.navig"{trunked}</code> */
+       public static final String ID = "eu.etaxonomy.taxeditor.navigation.navigator.dropassistant"; //$NON-NLS-1$
+
+       private static final EnumSet<CRUD> UPDATE = EnumSet.of(CRUD.UPDATE);
+       
+       
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#handleDrop(org.eclipse.ui.navigator.CommonDropAdapter, org.eclipse.swt.dnd.DropTargetEvent, java.lang.Object)
+        */
+       /** {@inheritDoc} */
+       @Override
+       public boolean performDrop(Object target) {
+
+               
+               if (target instanceof ITaxonTreeNode) {
+                       Set<TaxonNode> taxonNodes = getSelectedTaxa();
+                       ITaxonTreeNode targetTreeNode = (ITaxonTreeNode) target;
+                       if (targetTreeNode instanceof Classification){
+                               targetTreeNode = ((Classification)targetTreeNode).getRootNode();
+                               targetTreeNode = HibernateProxyHelper.deproxy(targetTreeNode, TaxonNode.class);
+                       }
+                       if(taxonNodes != null) {
+                               if (taxonNodes.size() == 1){
+                                       return moveTaxon(taxonNodes.iterator().next(), targetTreeNode);
+                               } else{
+                                       if( MessageDialog.openConfirm(null, "Moving taxon", "The operation move accepted taxon to other parent is available only for a single taxon.")){
+                                               return true;
+                                       }
+                               }
+            }
+               }
+               
+               return false;
+       }
+
+       private Set<TaxonNode> getSelectedTaxa(){
+               HashSet<TaxonNode> taxonNodes = new HashSet<TaxonNode>();
+
+               ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
+               if (selection instanceof TreeSelection) {
+
+                       Iterator selectionIterator = ((TreeSelection) selection).iterator();
+
+                       while (selectionIterator.hasNext()){
+                               Object object = selectionIterator.next();
+                               if(object instanceof TaxonNode){
+                                       TaxonNode taxonNode = (TaxonNode) object;
+                                       taxonNodes.add(taxonNode);
+                               }
+                       }
+               }
+               return taxonNodes.size() > 0 ? taxonNodes : null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.navigator.CommonDropAdapter#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData)
+        */
+       /** {@inheritDoc} */
+       @Override
+       public boolean validateDrop(Object target, int operation,
+                       TransferData transferType) {
+               
+               if (target instanceof ITaxonTreeNode) {
+                       
+                   // check users permissions with target taxonnode and taxon
+                   if (target instanceof TaxonNode) {
+                       TaxonNode targetNode = (TaxonNode)target;
+                       Boolean hasTargetNodePermission = CdmStore.currentAuthentiationHasPermission(targetNode, UPDATE);
+                Boolean hasTargetTaxonPermission = CdmStore.currentAuthentiationHasPermission(targetNode.getTaxon(), UPDATE);
+
+                if(logger.isDebugEnabled()){
+                    logger.debug("target: " + targetNode.getTaxon().getTitleCache());
+                }
+
+                       if(!hasTargetNodePermission || ! hasTargetNodePermission){
+                           if(logger.isDebugEnabled()){
+                               logger.debug("CANCEL_STATUS for target node: " + hasTargetNodePermission.toString() + " " + hasTargetTaxonPermission.toString() + " ");
+                           }
+                           return false;
+                       }
+                   }
+
+                   // do not allow to drop onto itself and
+                   // check users permissions with all selected taxon nodes and taxa
+                   for(TaxonNode taxonNode : getSelectedTaxa()){
+                           logger.debug("selectedTaxa: " + taxonNode.getTaxon().getTitleCache());
+                               Boolean isSameTaxonNode = taxonNode.equals(target);
+                               Boolean hasTaxonNodePermission = CdmStore.currentAuthentiationHasPermission(taxonNode, UPDATE);
+                               Boolean hasTaxonPermission = CdmStore.currentAuthentiationHasPermission(taxonNode.getTaxon(), UPDATE);
+                if (
+                               isSameTaxonNode
+                               || !hasTaxonNodePermission
+                   || !hasTaxonPermission
+                       ) {
+                    if(logger.isDebugEnabled()){
+                        logger.debug("CANCEL_STATUS for selected  " + isSameTaxonNode.toString() + " " + hasTaxonNodePermission.toString() + " " + hasTaxonPermission.toString() + " ");
+                    }
+                                       return false;
+                               }
+                       }
+                       logger.debug("OK_STATUS");
+                       return true;
+               }
+               logger.debug("CANCEL_STATUS");
+               return false;
+       }
+
+
+       /**
+        * @param childTaxonNode
+        * @param parentTaxon
+        * @return
+        */
+       private boolean moveTaxon(TaxonNode taxonNode, ITaxonTreeNode targetITaxonTreeNode) {
+
+               TaxonNavigator taxonNavigator;
+               taxonNavigator = (TaxonNavigator) NavigationUtil.showView(TaxonNavigator.ID);
+
+               if(targetITaxonTreeNode instanceof TaxonNode){
+
+                       TaxonNode targetTaxonNode = (TaxonNode) targetITaxonTreeNode;
+               // Make sure parent taxon does not have unsaved changes
+                       if (NavigationUtil.isDirty(targetTaxonNode)){
+                               MessageDialog.openWarning(NavigationUtil.getShell(), "Unsaved Parent Taxon", "There are unsaved " +
+                               "changes in the parent taxon. Pleas save first.");
+                               return false;
+                       }
+
+               }
+               if (!PreferencesUtil.getSortNodesNaturally()){
+                       IUndoContext workspaceUndoContext = NavigationUtil.getWorkbenchUndoContext();
+                       if (workspaceUndoContext == null) {
+                               logger.error("Workspace undo context is null. DND operation cancelled");
+                               return false;
+                       }
+       
+                       AbstractPostOperation operation = new MoveTaxonOperation
+                                       ("Move Taxon", workspaceUndoContext, taxonNode, targetITaxonTreeNode, this, taxonNavigator, true);
+                       NavigationUtil.executeOperation(operation);
+                       
+                       logger.info("Moved taxa to new parent " + targetITaxonTreeNode);
+                       return true;
+               }else{
+                       String[] buttonLables = {"Parent", "Predecessor", "Cancel"};
+                       MessageDialog dialog = new MessageDialog(null, "Target node", null, "Do you want to use the target node as parent or do you want to move the taxon below the target.", MessageDialog.QUESTION_WITH_CANCEL, buttonLables, 0);
+                       dialog.open();
+                       int returnCode = dialog.getReturnCode();
+                       if (returnCode == 0){
+                               IUndoContext workspaceUndoContext = NavigationUtil.getWorkbenchUndoContext();
+                               if (workspaceUndoContext == null) {
+                                       logger.error("Workspace undo context is null. DND operation cancelled");
+                                       return false;
+                               }
+               
+                               AbstractPostOperation operation = new MoveTaxonOperation
+                                               ("Move Taxon", workspaceUndoContext, taxonNode, targetITaxonTreeNode, this, taxonNavigator, true);
+                               NavigationUtil.executeOperation(operation);
+                               
+                               logger.info("Moved taxa to new parent " + targetITaxonTreeNode);
+                               return true;
+                       }else if (returnCode == 1){
+                               IUndoContext workspaceUndoContext = NavigationUtil.getWorkbenchUndoContext();
+                               if (workspaceUndoContext == null) {
+                                       logger.error("Workspace undo context is null. DND operation cancelled");
+                                       return false;
+                               }
+               
+                               AbstractPostOperation operation = new MoveTaxonOperation
+                                               ("Move Taxon", workspaceUndoContext, taxonNode, targetITaxonTreeNode, this, taxonNavigator, false);
+                               NavigationUtil.executeOperation(operation);
+                               
+                               logger.info("Moved taxa to new parent " + targetITaxonTreeNode);
+                               return true;
+                       } else{
+                               return false;
+                       }
+                       
+                       
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
+        */
+       /** {@inheritDoc} */
+       @Override
+    public boolean postOperation(CdmBase objectAffectedByOperation) {
+               return true;
+       }
+
+       /**
+        * <p>onComplete</p>
+        *
+        * @return a boolean.
+        */
+       @Override
+    public boolean onComplete() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+       @Override
+       public void dragOver(DropTargetEvent event) {
+               super.dragOver(event);
+               event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_INSERT_AFTER;
+               
+       }
+       
+}
index 55df02ba26580f05fa4cc09d74df9336257d6b6e..5a8650098b30cf91fe380d90fb7f994e7be7fc87 100644 (file)
@@ -87,6 +87,7 @@ public class DeleteHandler extends AbstractHandler{
                                ITaxonTreeNode treeNode = treeNodes.iterator().next();
                                ITaxonTreeNode taxonNode =treeNode;
                                TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator();
+                               //configNodes.setDeleteTaxon(false);
                                if (taxonNode instanceof Classification && taxonNode.hasChildNodes()){
                                        if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification? The tree has children, they will be deleted, too.")){
                                                return null;
@@ -122,9 +123,10 @@ public class DeleteHandler extends AbstractHandler{
 
                                                }
                                        }else{
-                                               if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected node?")){
+                                               if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(configNodes, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected node?")){
                                                        return null;
-                                               }
+                                               } 
+                                               config.setTaxonNodeConfig(configNodes);
                                        }
                                }
 
index 3b026cdf1defab4f62980e29d838b4e9da7d8d98..41a4ad279bcfe7f014dca98ed5648424dd114637 100644 (file)
                      name="org.eclipse.ui.views.showView.viewId"
                      value="eu.etaxonomy.taxeditor.view.derivateSearch.DerivateSearchView">
                </parameter>
-               <visibleWhen
-                     checkEnabled="true">
-                  <reference
-                        definitionId="isCdmStoreConnected">
-                  </reference>
-               </visibleWhen>
             </command>
             <separator
                   name="eu.etaxonomy.taxeditor.store.showViewMenu.details"
                      name="org.eclipse.ui.views.showView.viewId"
                      value="eu.etaxonomy.taxeditor.view.detail">
                </parameter>
-               <visibleWhen
-                     checkEnabled="true">
-                  <reference
-                        definitionId="isCdmStoreConnected">
-                  </reference>
-               </visibleWhen>
             </command>
             <command
                   commandId="org.eclipse.ui.views.showView"
                      name="org.eclipse.ui.views.showView.viewId"
                      value="eu.etaxonomy.taxeditor.view.supplementalData">
                </parameter>
-               <visibleWhen
-                     checkEnabled="true">
-                  <reference
-                        definitionId="isCdmStoreConnected">
-                  </reference>
-               </visibleWhen>
             </command>
             <!-- Originally used by validation framework, currently not in use -->
        <!--        <command
                </parameter>
                <visibleWhen
                      checkEnabled="true">
-                  <and>
-                     <reference
-                           definitionId="isShowExperimentalFeatures">
-                     </reference>
-                     <reference
-                           definitionId="isCdmStoreConnected">
-                     </reference>
-                  </and>
+                  <reference
+                        definitionId="isShowExperimentalFeatures">
+                  </reference>
                </visibleWhen>
             </command>
          </menu>
       </menuContribution>
+      <menuContribution
+            class="eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermMenuFactory"
+            locationURI="menu:org.eclipse.ui.main.menu.window?before=eu.etaxonomy.taxeditor.application.windowMenu.last">
+      </menuContribution>
       <menuContribution
             locationURI="menu:org.eclipse.ui.main.menu.file?after=eu.etaxonomy.taxeditor.application.filemenu.io">
          <command
                commandId="eu.etaxonomy.taxeditor.store.operations.showLoginWindow"
                label="%command.label.5"
                style="push">
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
          </command>
          <separator
                name="eu.etaxonomy.taxeditor.application.filemenu.login"
             </visibleWhen>
          </command>
       </menuContribution>
-      <menuContribution
-            allPopups="false"
-            locationURI="menu:org.eclipse.ui.main.menu.window?before=eu.etaxonomy.taxeditor.application.windowMenu.last">
-         <dynamic
-               class="eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermMenu"
-               id="eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermMenu">
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
-         </dynamic>
-      </menuContribution>
    </extension>
    <extension
          point="org.eclipse.ui.handlers">
index b233e53f9d3ec4f27bf630e383492765ef7fbdbe..42791ec3b89d6c6967cb86041814a7d482ff7619 100644 (file)
@@ -21,8 +21,7 @@
       </annotation>
       <complexType>
          <sequence>
-            <element ref="cdmViewer" minOccurs="0" maxOccurs="unbounded"/>
-            <element ref="viewCommandMapping" minOccurs="0" maxOccurs="unbounded"/>
+            <element ref="cdmViewer" minOccurs="1" maxOccurs="unbounded"/>
          </sequence>
          <attribute name="point" type="string" use="required">
             <annotation>
       </complexType>
    </element>
 
-   <element name="viewCommandMapping">
-      <annotation>
-         <documentation>
-            Maps a viewing class, like editors or views, to a command which opens it.
-         </documentation>
-      </annotation>
-      <complexType>
-         <attribute name="commandId" type="string" use="required">
-            <annotation>
-               <documentation>
-                  The command which opens the viewer to show the selected object
-               </documentation>
-               <appInfo>
-                  <meta.attribute kind="identifier" basedOn="org.eclipse.ui.commands/command/@id"/>
-               </appInfo>
-            </annotation>
-         </attribute>
-         <attribute name="viewerName" type="string">
-            <annotation>
-               <documentation>
-                  The name of the viewer which shows the selected element
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="selection" type="string" use="required">
-            <annotation>
-               <documentation>
-                  The class of the selected element
-               </documentation>
-               <appInfo>
-                  <meta.attribute kind="java"/>
-               </appInfo>
-            </annotation>
-         </attribute>
-      </complexType>
-   </element>
-
    <annotation>
       <appInfo>
          <meta.section type="since"/>
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/DefinedTermMenu.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/DefinedTermMenu.java
deleted file mode 100644 (file)
index 4f3e777..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-// $Id$
-/**
-* Copyright (C) 2009 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.definedterm;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.swt.SWT;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.CompoundContributionItem;
-import org.eclipse.ui.menus.CommandContributionItem;
-import org.eclipse.ui.menus.CommandContributionItemParameter;
-
-import eu.etaxonomy.cdm.model.common.TermType;
-
-/**
- * Menu used in the store plugin xml to dynamically generate menu (sub-menu) contribution items
- * for term types which when clicked open the defined term editor for the chosen term type
- *
- * @author pplitzner
- * @date 21 Jul 2015
- *
- */
-
-public class DefinedTermMenu extends CompoundContributionItem {
-
-
-    @Override
-    protected IContributionItem[] getContributionItems() {
-        Collection<IContributionItem> items = new ArrayList<IContributionItem>();
-           MenuManager dtMenuManager =
-                   new MenuManager("Term Editor","eu.etaxonomy.taxeditor.store.definedTermEditorMenu");
-
-           dtMenuManager.setVisible(true);
-
-           items.add(dtMenuManager);
-           List<TermType> ttList = new ArrayList<TermType>(EnumSet.allOf(TermType.class));
-           Collections.sort(ttList,new SortByTermTypeMessage());
-           for (TermType tt : ttList)
-           {
-               // if term type has a parent, do not add it
-               // it will be added in the recursive call
-               if(tt.getKindOf() == null) {
-                   IContributionItem ici = addChildTermsToMenuManager(tt);
-                   if(ici != null) {
-                       dtMenuManager.add(ici);
-                   }
-               }
-           }
-           return items.toArray(new IContributionItem[]{});
-       }
-
-       private IContributionItem addChildTermsToMenuManager(TermType termType) {
-
-               //FIXME : need a better way to find out if a term type can be editable (ticket 3853)
-               if(termType.getEmptyDefinedTermBase() != null) {
-                       Set<TermType> children = termType.getGeneralizationOf();
-                       // term type has no children, so create menu item
-                       if(children.isEmpty()) {
-                               return createMenuItem(termType);
-                       }
-                       // term type has children, so create sub menu
-                       MenuManager dtMenuManager =
-                                       new MenuManager(termType.getMessage(),"eu.etaxonomy.taxeditor.store." + termType.getKey() + "Menu");
-                       dtMenuManager.setVisible(true);
-                       dtMenuManager.add(createDefaultMenuItem(termType));
-
-                       Separator sep = new Separator();
-                       dtMenuManager.add(sep);
-                       // add child items to the sub menu
-                       for(TermType tt : children) {
-                               IContributionItem item = addChildTermsToMenuManager(tt);
-                               if(item != null) {
-                                       dtMenuManager.add(item);
-                               }
-                       }
-                       return dtMenuManager;
-               } else {
-                       return null;
-               }
-
-       }
-
-       private CommandContributionItem createMenuItem(TermType termType) {
-
-               Map<String, String> params = new HashMap<String, String>();
-               params.put("eu.etaxonomy.taxeditor.store.openDefinedTermEditor.termTypeUuid",
-                               termType.getUuid().toString());
-
-        CommandContributionItemParameter p = new CommandContributionItemParameter(
-                PlatformUI.getWorkbench(),
-                "",
-                "eu.etaxonomy.taxeditor.store.openDefinedTermEditor",
-                params,
-                null,
-                null,
-                null,
-                termType.getMessage(),
-                "",
-                "",
-                SWT.PUSH,
-                "",
-                true);
-
-        CommandContributionItem item = new CommandContributionItem(p);
-        return item;
-
-       }
-
-       private CommandContributionItem createDefaultMenuItem(TermType termType) {
-
-               Map<String, String> params = new HashMap<String, String>();
-               params.put("eu.etaxonomy.taxeditor.store.openDefinedTermEditor.termTypeUuid",
-                               termType.getUuid().toString());
-
-        CommandContributionItemParameter p = new CommandContributionItemParameter(
-                PlatformUI.getWorkbench(),
-                "",
-                "eu.etaxonomy.taxeditor.store.openDefinedTermEditor",
-                params,
-                null,
-                null,
-                null,
-                "Other " + termType.getMessage() + "s",
-                "",
-                "",
-                SWT.PUSH,
-                "",
-                true);
-
-
-
-        CommandContributionItem item = new CommandContributionItem(p);
-        return item;
-
-       }
-
-       private class SortByTermTypeMessage implements Comparator<TermType> {
-           @Override
-        public int compare(TermType t1, TermType t2) {
-               return t1.getMessage().compareTo(t2.getMessage());
-           }
-       }
-
-
-}
index f266729565dcd7e2221fcfcef4b6f27eb76435bc..9bd7ccbda2d8ed188e837b2cd847829e0abab79a 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
 * Copyright (C) 2009 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.
 */
@@ -34,77 +34,78 @@ import eu.etaxonomy.cdm.model.common.TermType;
 /**
  * Menu factory used in the store plugin xml to dynamically generate menu (sub-menu) contribution items
  * for term types which when clicked open the defined term editor for the chosen term type
- *
+ * 
  * @author c.mathew
  * @date 18 Jul 2013
  *
  */
 
-public class DefinedTermMenuFactory extends ExtensionContributionFactory {
-
+public class DefinedTermMenuFactory extends ExtensionContributionFactory {     
+       
        @Override
        public void createContributionItems(IServiceLocator serviceLocator,
-               IContributionRoot additions) {
-           MenuManager dtMenuManager =
-                   new MenuManager("Term Editor","eu.etaxonomy.taxeditor.store.definedTermEditorMenu");
-
-           dtMenuManager.setVisible(true);
-
-           additions.addContributionItem(dtMenuManager, null);
-           List<TermType> ttList = new ArrayList<TermType>(EnumSet.allOf(TermType.class));
-           Collections.sort(ttList,new SortByTermTypeMessage());
-           for (TermType tt : ttList)
-           {
-               // if term type has a parent, do not add it
-               // it will be added in the recursive call
-               if(tt.getKindOf() == null) {
-                   IContributionItem ici = addChildTermsToMenuManager(tt, serviceLocator);
-                   if(ici != null) {
-                       dtMenuManager.add(ici);
-                   }
-               }
-           }
+                       IContributionRoot additions) {
+               
+               MenuManager dtMenuManager = 
+                               new MenuManager("Term Editor","eu.etaxonomy.taxeditor.store.definedTermEditorMenu"); 
+               
+               dtMenuManager.setVisible(true);
+        
+               additions.addContributionItem(dtMenuManager, null);
+               List<TermType> ttList = new ArrayList<TermType>(EnumSet.allOf(TermType.class));
+               Collections.sort(ttList,new SortByTermTypeMessage());
+        for (TermType tt : ttList)
+        {
+               // if term type has a parent, do not add it
+               // it will be added in the recursive call
+               if(tt.getKindOf() == null) {
+                       IContributionItem ici = addChildTermsToMenuManager(tt, serviceLocator);                 
+                       if(ici != null) {                                                       
+                               dtMenuManager.add(ici);
+                       }
+               }
+        }                                     
        }
-
+       
        private IContributionItem addChildTermsToMenuManager(TermType termType, IServiceLocator serviceLocator) {
-
+       
                //FIXME : need a better way to find out if a term type can be editable (ticket 3853)
                if(termType.getEmptyDefinedTermBase() != null) {
                        Set<TermType> children = termType.getGeneralizationOf();
                        // term type has no children, so create menu item
-                       if(children.isEmpty()) {
+                       if(children.isEmpty()) {                        
                                return createMenuItem(termType, serviceLocator);
                        }
-                       // term type has children, so create sub menu
-                       MenuManager dtMenuManager =
-                                       new MenuManager(termType.getMessage(),"eu.etaxonomy.taxeditor.store." + termType.getKey() + "Menu");
+                       // term type has children, so create sub menu           
+                       MenuManager dtMenuManager = 
+                                       new MenuManager(termType.getMessage(),"eu.etaxonomy.taxeditor.store." + termType.getKey() + "Menu"); 
                        dtMenuManager.setVisible(true);
                        dtMenuManager.add(createDefaultMenuItem(termType, serviceLocator));
 
                        Separator sep = new Separator();
                        dtMenuManager.add(sep);
                        // add child items to the sub menu
-                       for(TermType tt : children) {
+                       for(TermType tt : children) {                   
                                IContributionItem item = addChildTermsToMenuManager(tt,serviceLocator);
-                               if(item != null) {
+                               if(item != null) {                              
                                        dtMenuManager.add(item);
-                               }
-                       }
+                               }                                       
+                       }               
                        return dtMenuManager;
                } else {
                        return null;
                }
-
+               
        }
-
+       
        private CommandContributionItem createMenuItem(TermType termType, IServiceLocator serviceLocator) {
-
+               
                Map<String, String> params = new HashMap<String, String>();
                params.put("eu.etaxonomy.taxeditor.store.openDefinedTermEditor.termTypeUuid",
-                               termType.getUuid().toString());
-
+                               termType.getUuid().toString());         
+               
         CommandContributionItemParameter p = new CommandContributionItemParameter(
-                serviceLocator,
+                serviceLocator, 
                 "",
                 "eu.etaxonomy.taxeditor.store.openDefinedTermEditor",
                 params,
@@ -113,24 +114,24 @@ public class DefinedTermMenuFactory extends ExtensionContributionFactory {
                 null,
                 termType.getMessage(),
                 "",
-                "",
+                "",                
                 SWT.PUSH,
                 "",
                 true);
-
-        CommandContributionItem item = new CommandContributionItem(p);
+   
+        CommandContributionItem item = new CommandContributionItem(p);   
         return item;
-
+               
        }
-
+       
        private CommandContributionItem createDefaultMenuItem(TermType termType, IServiceLocator serviceLocator) {
-
+               
                Map<String, String> params = new HashMap<String, String>();
                params.put("eu.etaxonomy.taxeditor.store.openDefinedTermEditor.termTypeUuid",
-                               termType.getUuid().toString());
-
+                               termType.getUuid().toString());         
+               
         CommandContributionItemParameter p = new CommandContributionItemParameter(
-                serviceLocator,
+                serviceLocator, 
                 "",
                 "eu.etaxonomy.taxeditor.store.openDefinedTermEditor",
                 params,
@@ -139,24 +140,23 @@ public class DefinedTermMenuFactory extends ExtensionContributionFactory {
                 null,
                 "Other " + termType.getMessage() + "s",
                 "",
-                "",
+                "",                
                 SWT.PUSH,
                 "",
                 true);
-
-
-
-        CommandContributionItem item = new CommandContributionItem(p);
+        
+        
+   
+        CommandContributionItem item = new CommandContributionItem(p);   
         return item;
-
+               
        }
-
+       
        private class SortByTermTypeMessage implements Comparator<TermType> {
-           @Override
-        public int compare(TermType t1, TermType t2) {
+           public int compare(TermType t1, TermType t2) {
                return t1.getMessage().compareTo(t2.getMessage());
            }
        }
-
+       
 
 }
index eb36edac26f314ac4853c445ef28331754b62449..647addd10ccaea42b89725ac4b201456b51c25e5 100644 (file)
@@ -20,6 +20,7 @@ import org.eclipse.swt.widgets.Shell;
 import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
 import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
 import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
 
 /**
  * Abstract subclass of MessageDialog providing the functionality to configure
@@ -49,7 +50,10 @@ public class DeleteConfiguratorDialog extends MessageDialog{
         }
         else if(configurator instanceof SpecimenDeleteConfigurator){
             composite.addConfiguratorComposite(new DeleteSpecimenConfiguratorComposite((SpecimenDeleteConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
+        } else if(configurator instanceof TaxonNodeDeletionConfigurator){
+            composite.addConfiguratorComposite(new DeleteNodeConfiguratorComposite((TaxonNodeDeletionConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
         }
+        
         return composite;
     }
 
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteNodeConfiguratorComposite.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteNodeConfiguratorComposite.java
new file mode 100644 (file)
index 0000000..4901526
--- /dev/null
@@ -0,0 +1,76 @@
+package eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator;
+/**
+* Copyright (C) 2015 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.
+*/
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.beans.PojoProperties;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.layout.RowLayout;
+
+import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
+/**
+ * @author kluther
+ * @date Jul 13, 2015
+ *
+ */
+public class DeleteNodeConfiguratorComposite extends Composite {
+       // $Id$
+       
+       private final DataBindingContext m_bindingContext;
+
+       private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
+       private final TaxonNodeDeletionConfigurator configurator;
+       private final Button btnDeleteTaxon;
+
+
+           /**
+            * Create the composite.
+            * @param parent
+            * @param style
+            */
+           public DeleteNodeConfiguratorComposite(TaxonNodeDeletionConfigurator configurator, Composite parent, int style) {
+               super(parent, style);
+               this.configurator = configurator;
+               addDisposeListener(new DisposeListener() {
+                   @Override
+                   public void widgetDisposed(DisposeEvent e) {
+                       toolkit.dispose();
+                   }
+               });
+               toolkit.paintBordersFor(this);
+               setLayout(new RowLayout(SWT.VERTICAL));
+               setBackground(getBackground());
+
+               btnDeleteTaxon = new Button(this, SWT.CHECK);
+               btnDeleteTaxon.setText("Delete taxon if possible");
+            
+               m_bindingContext = initDataBindings();
+
+           }
+
+           protected DataBindingContext initDataBindings() {
+               DataBindingContext bindingContext = new DataBindingContext();
+               //
+               IObservableValue observeSelectionBtnDeleteTaxonObserveWidget = WidgetProperties.selection().observe(btnDeleteTaxon);
+               IObservableValue deleteTaxonIfPossibleConfiguratorObserveValue = PojoProperties.value("deleteTaxon").observe(configurator);
+               bindingContext.bindValue(observeSelectionBtnDeleteTaxonObserveWidget, deleteTaxonIfPossibleConfiguratorObserveValue, null, null);
+               //
+               return bindingContext;
+           }
+       }
+
+
index e7ef5ec0b227a867e3d6522b53d4c36cf154acef..ee6867db2b3a57827f7e4f552affc3713903b1bc 100644 (file)
@@ -13,7 +13,6 @@ package eu.etaxonomy.taxeditor.ui.element;
 import java.net.URI;
 
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 
 /**
@@ -44,11 +43,9 @@ public class UriWithLabelElement extends TextWithLabelElement {
 
        public URI getUri(){
         try {
-            labelException.setBackground(getPersistentBackground());
             labelException.setText("");
             return new URI(super.getText());
         } catch (Exception e) {
-            labelException.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
             labelException.setText(e.getMessage());
             return null;
         }
index be33fcb1029f0e39218ecb5e447a69c07e3fa686..8e4dcea681aa717b96cf72ccf715eb49efc4d571 100644 (file)
@@ -113,6 +113,7 @@ public class FeatureDistributionDetailElement extends AbstractCdmDetailElement<F
                                getTaxonDescriptions(),
                 false, 
                 false, 
+               
                 null,
                 presenceAbsenceTermColors, 
                 languages);
index b11a177a5c0b2dc1e137b3d51692c9012709bbf2..46c95c83d6c2a41313356e78855b29ded5eeaa1a 100644 (file)
@@ -64,13 +64,19 @@ public class PolytomousKeyNodeDetailElement extends
                element_statement = formFactory.createKeyStatementElement(formElement,
                                "State(ment)", entity.getStatement(), 50, style);
 
-               //if (entity.isLeaf()) {
+               if (entity.isLeaf()) {
                        selection_taxon = formFactory
                                        .createSelectionElement(Taxon.class,
                                                        getConversationHolder(), formElement, "Taxon",
                                                        entity.getTaxon(), EntitySelectionElement.NOTHING,
                                                        style);
-               //}
+               } else{
+                       selection_taxon = formFactory
+                                       .createSelectionElement(Taxon.class,
+                                                       getConversationHolder(), formElement, "Taxon",
+                                                       entity.getTaxon(), EntitySelectionElement.DELETABLE,
+                                                       style);
+               }
 
                selection_subkey = formFactory
                                .createSelectionElement(PolytomousKey.class,
index 9d016cb3175be5d881d8eb238c4c495ff5b1410d..fbde0b7e0ed056e51d0b6d809db9aa24e4a535ac 100644 (file)
@@ -119,13 +119,7 @@ public class ImageFileElement extends MediaRepresentationPartElement<ImageFile>
                        try {
                            URI uri = text_uri.getUri();
                                getEntity().setUri(uri);
-                               if(uri==null){
-                                   //buffer URI if parsing error occurred
-                                   MediaDetailElement parentMediaDetailElement = getParentMediaDetailElement();
-                                   if(parentMediaDetailElement!=null){
-                                       parentMediaDetailElement.setUriBuffer(text_uri.getText());
-                                   }
-                               }
+
 
                                loadImage(getEntity().getUri(), true);
 
index 1c27665647713fdd53c267767588114f683fb708..e05ed4064260e68d770df99dec3a5c11e950a8bd 100644 (file)
@@ -9,7 +9,6 @@
 */
 package eu.etaxonomy.taxeditor.ui.section.media;
 
-import java.net.URI;
 import java.util.List;
 import java.util.Set;
 
@@ -17,7 +16,6 @@ import eu.etaxonomy.cdm.model.media.Media;
 import eu.etaxonomy.cdm.model.media.MediaRepresentation;
 import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
 import eu.etaxonomy.cdm.model.media.MediaUtils;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
@@ -41,11 +39,6 @@ public class MediaDetailElement extends AbstractCdmDetailElement<Media>{
     private ICdmFormElement parentFormElement;
     private int style;
 
-    /**
-     * Used to store the URI even if it is invalid and thus cannot be stored in CDM
-     */
-    private String uriBuffer;
-
     public MediaDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
         super(formFactory, formElement);
     }
@@ -70,25 +63,11 @@ public class MediaDetailElement extends AbstractCdmDetailElement<Media>{
     public void handleEvent(Object eventSource){
         if(eventSource==textUri){
             textUri.setBackground(getPersistentBackground());
-            URI uri = textUri.getUri();
-            singleMediaRepresentationPart.setUri(uri);
-            if(uri==null){
-                uriBuffer=textUri.getText();
-            }
+            singleMediaRepresentationPart.setUri(textUri.getUri());
         }
     }
 
-    public void toggleAdvancedMediaView() {
-        if (getEntity().getRepresentations() != null
-                && (getEntity().getRepresentations().size() > 1 ||
-                        (getEntity().getRepresentations().size() == 1
-                        && getEntity().getRepresentations().iterator().next().getParts().size() > 1))) {
-            MessagingUtils.informationDialog("Toggling not possible",
-                    "Media has consists of multiple representations or representatio parts");
-            // toggling is only possible if there are no more than one
-            // MediaRepresentation resp. MediaRepresentationParts
-            return;
-        }
+    public void toggleAdvancedMediaView(){
         isAdvancedMediaView = !isAdvancedMediaView;
         showAdvancedView();
         reflowParentScrolledForm(true);
@@ -102,23 +81,13 @@ public class MediaDetailElement extends AbstractCdmDetailElement<Media>{
             section_mediaRepresentation = formFactory.createMediaRepresentationSection(getConversationHolder(), parentFormElement, style);
             section_mediaRepresentation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
             section_mediaRepresentation.setEntity(getEntity());
-            //set buffered uri as text if uri had parsing problems in simple view
-            if(uriBuffer!=null){
-                section_mediaRepresentation.getLayoutComposite().getChildren();
-            }
         }
         else{
             if(section_mediaRepresentation!=null){
                 removeElementsAndControls(section_mediaRepresentation);
             }
             textUri = formFactory.createUriWithLabelElement(parentFormElement, "Media URI", null, style);
-            URI uri = singleMediaRepresentationPart.getUri();
-            textUri.setUri(uri);
-            //set buffered uri as text if uri had parsing problems in advanced view
-            if(uri==null && uriBuffer!=null){
-                textUri.setText(uriBuffer);
-                textUri.getUri();
-            }
+            textUri.setUri(singleMediaRepresentationPart.getUri());
             textUri.getLayoutComposite().layout();
         }
     }
@@ -147,12 +116,4 @@ public class MediaDetailElement extends AbstractCdmDetailElement<Media>{
         return isAdvancedMediaView;
     }
 
-    public void setUriBuffer(String uriBuffer) {
-        this.uriBuffer = uriBuffer;
-    }
-
-    public String getUriBuffer() {
-        return uriBuffer;
-    }
-
 }
index 663848da419d2bef3ba02e2b78c73f4c0911f147..5a295254788c851528ec31c0a1eb5e141f4d2b17 100644 (file)
@@ -58,14 +58,8 @@ public class MediaRepresentationPartElement<T extends MediaRepresentationPart> e
                        text_size.setText(FileUtils.byteCountToDisplaySize(entity.getSize()));
                }
                if(entity.getUri() != null){
-                       text_uri.setUri(entity.getUri());
-               } else {
-            String uriBuffer = getParentMediaDetailElement().getUriBuffer();
-            if(uriBuffer!=null){
-                text_uri.setText(uriBuffer);
-                text_uri.getUri();//just to update the error label
-            }
-        }
+                       text_uri.setText(entity.getUri().toString());
+               }
        }
 
        @Override
@@ -73,27 +67,8 @@ public class MediaRepresentationPartElement<T extends MediaRepresentationPart> e
                if(eventSource == text_uri){
                    URI uri = text_uri.getUri();
                    getEntity().setUri(uri);
-                   if(uri==null){
-                //buffer URI if parsing error occurred
-                MediaDetailElement parentMediaDetailElement = getParentMediaDetailElement();
-                if(parentMediaDetailElement!=null){
-                    parentMediaDetailElement.setUriBuffer(text_uri.getText());
-                }
-            }
-
                    firePropertyChangeEvent(this);
                }
        }
 
-    protected MediaDetailElement getParentMediaDetailElement() {
-        ICdmFormElement parentElement = getParentElement();
-        while(parentElement!=null){
-            parentElement = parentElement.getParentElement();
-            if(parentElement instanceof MediaDetailElement){
-                return (MediaDetailElement) parentElement;
-            }
-        }
-        return null;
-    }
-
 }
index f2eef9fe3e63113dab460be3d7cf8bb122b58d87..712bec9d8a40c91ee3024b635122163b36d2e5a8 100644 (file)
@@ -3,8 +3,6 @@ package eu.etaxonomy.taxeditor.view;
 import java.util.Map;
 import java.util.Map.Entry;
 
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.common.NotDefinedException;
 import org.eclipse.jface.action.ContributionItem;
 import org.eclipse.jface.action.IContributionItem;
 import org.eclipse.jface.viewers.ISelection;
@@ -17,10 +15,6 @@ import org.eclipse.swt.widgets.MenuItem;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.actions.CompoundContributionItem;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.IHandlerService;
-
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
 
 /**
  * Generic context menu for opening elements in the taxeditor.
@@ -34,40 +28,20 @@ public class CdmViewerContextMenu extends CompoundContributionItem {
                 new ContributionItem() {
                     @Override
                     public void fill(Menu menu, int index) {
-                        final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-                        final ISelection selection = window.getActivePage().getSelection();
-
                         MenuItem addItem = new MenuItem(menu, SWT.CASCADE);
                         addItem.setText("Open in...");
                         Menu addMenu = new Menu(menu);
                         addItem.setMenu(addMenu);
+                        final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+                        final ISelection selection = window.getActivePage().getSelection();
                         if(selection instanceof IStructuredSelection){
                             Object firstElement = ((IStructuredSelection) selection).getFirstElement();
-                            Map<String, String> availableViewers = CdmViewerUtil.getAvailableViewers(firstElement);
-                            for(Entry<String, String> entry:availableViewers.entrySet()){
-                                final String commandId = entry.getKey();
-                                String viewerName = entry.getValue();
+                            Map<Entry<Class<?>, String>, ICdmViewer> nameViewerMap = CdmViewerUtil.getNameViewerMap(firstElement);
+                            for(Entry<Entry<Class<?>, String>, ICdmViewer> entry:nameViewerMap.entrySet()){
+                                Entry<Class<?>, String> viewerClass = entry.getKey();
                                 MenuItem menuItem = new MenuItem(addMenu, SWT.NONE);
-                                menuItem.setText(viewerName);
-                                menuItem.addSelectionListener(new SelectionAdapter() {
-
-                                    @Override
-                                    public void widgetSelected(SelectionEvent e) {
-                                        ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
-
-                                        Command command = commandService.getCommand(commandId);
-                                        if(command.isEnabled()) {
-                                            IHandlerService handlerService = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class);
-                                            try {
-                                                handlerService.executeCommand(commandId, null);
-                                            } catch (NotDefinedException nde) {
-                                                throw new RuntimeException("Could not find open command: " + commandId);
-                                            } catch (Exception exception) {
-                                                MessagingUtils.error(getClass(), "An exception occured while trying execute "+commandId, exception);
-                                            }
-                                        }
-                                    }
-                                }) ;
+                                menuItem.setText(viewerClass.getValue());
+                                menuItem.addSelectionListener(new OpenInViewerListener(entry.getValue(), firstElement, viewerClass.getKey()));
                             }
                         }
                     }
index 88552f12f0310ef70e47948aa38a5608012bb516..6f5c6f67ab73666cdc2aec92a0f81f8c881aedca 100644 (file)
@@ -32,7 +32,7 @@ public class CdmViewerUtil {
 
     public static  Map<Entry<Class<?>, String>, ICdmViewer> getNameViewerMap(Object input){
         Map<Entry<Class<?>, String>, ICdmViewer> nameViewerMap = new HashMap<Entry<Class<?>, String>, ICdmViewer>();
-
+    
         IExtensionRegistry reg = Platform.getExtensionRegistry();
         IConfigurationElement[] extensions = reg
                 .getConfigurationElementsFor("eu.etaxonomy.taxeditor.store.cdmViewer");
@@ -56,30 +56,4 @@ public class CdmViewerUtil {
         return nameViewerMap;
     }
 
-    public static  Map<String, String> getAvailableViewers(Object input){
-        Map<String, String> commandViewerNameMap = new HashMap<String, String>();
-
-        if(input!=null){
-            IExtensionRegistry reg = Platform.getExtensionRegistry();
-            IConfigurationElement[] extensions = reg
-                    .getConfigurationElementsFor("eu.etaxonomy.taxeditor.store.cdmViewer");
-            for (IConfigurationElement configElement : extensions) {
-                if(configElement.getName().equals("viewCommandMapping")){
-                    String commandId = configElement.getAttribute("commandId");
-                    String viewerName = configElement.getAttribute("viewerName");
-                    try {
-                        Object selectionObject = configElement.createExecutableExtension("selection");
-                        Class<? extends Object> selectionClass = selectionObject.getClass();
-                        if(input.getClass().isAssignableFrom(selectionClass)){
-                            commandViewerNameMap.put(commandId, viewerName);
-                        }
-                    } catch (CoreException e) {
-                        MessagingUtils.error(CdmViewerChooser.class, "Could not initalize selection class element of cdmViewer extension", e);
-                    }
-                }
-            }
-        }
-        return commandViewerNameMap;
-    }
-
 }
diff --git a/pom.xml b/pom.xml
index d63142b3edb00e275b6c03fd827933810fdb6528..44ff82a0435db2349a683eb4e550959c0dfce9c0 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -19,6 +19,7 @@
     <java.codelevel>1.6</java.codelevel>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <cdmlib.version>3.8.0-SNAPSHOT</cdmlib.version>
+    <!-- TODO can we use project.version ????? -->
     <tycho.version>0.22.0</tycho.version>
     <taxeditor.version>3.8.0-SNAPSHOT</taxeditor.version>
     <update.dir>snapshot</update.dir>
     <module>eu.etaxonomy.taxeditor.bulkeditor</module>
     <module>eu.etaxonomy.taxeditor.printpublisher</module>
     <module>eu.etaxonomy.taxeditor.help</module>
+    <module>eu.etaxonomy.taxeditor.molecular</module>
+    <module>eu.etaxonomy.taxeditor.molecular.lib</module>
     <module>eu.etaxonomy.taxeditor.application</module>
     <module>eu.etaxonomy.taxeditor.feature.platform</module>
     <module>eu.etaxonomy.taxeditor.feature</module>
-    <module>eu.etaxonomy.taxeditor.molecular</module>
-    <module>eu.etaxonomy.taxeditor.molecular.lib</module>
     <module>eu.etaxonomy.taxeditor</module>
   </modules>
   <scm>