cleanup
authorAndreas Müller <a.mueller@bgbm.org>
Thu, 17 Nov 2022 18:04:53 +0000 (19:04 +0100)
committerAndreas Müller <a.mueller@bgbm.org>
Thu, 17 Nov 2022 20:31:16 +0000 (21:31 +0100)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditor.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/ICdmEntitySession.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/e4/TaxonEditorInputE4.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/TaxonNameEditorE4.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/test/MockConversationEnabled.java

index f2dddc570450e094f1dc903818244f774bc32c35..fb9a1f739e5f9f0e5505e52d3f21a81bb5aad25b 100644 (file)
@@ -66,7 +66,6 @@ import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorQuery;
 import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
 import eu.etaxonomy.taxeditor.bulkeditor.input.GroupEditorInput;
 import eu.etaxonomy.taxeditor.bulkeditor.input.MediaEditorInput;
-import eu.etaxonomy.taxeditor.bulkeditor.input.NameEditorInput;
 import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput;
 import eu.etaxonomy.taxeditor.editor.IBulkEditor;
 import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
@@ -111,7 +110,7 @@ public class BulkEditor implements IPartContentHasDetails, IConversationEnabled,
     private BulkEditorQuery lastQuery = null;
 
     private BulkEditorComposite bulkEditorComposite;
-    
+
     private Set<AbstractPostOperation> operations = new HashSet<>();
 
     @Inject
@@ -147,7 +146,7 @@ public class BulkEditor implements IPartContentHasDetails, IConversationEnabled,
             String operationlabel = entry.getLabel();
             try {
                 entry.addContext(IOperationHistory.GLOBAL_UNDO_CONTEXT);
-                
+
                 status = entry.execute(new NullProgressMonitor(), uiInfoAdapter);
             } catch (ExecutionException e) {
                 MessagingUtils.operationDialog(AbstractUtility.class, e, TaxeditorStorePlugin.PLUGIN_ID, operationlabel, null);
@@ -178,7 +177,7 @@ public class BulkEditor implements IPartContentHasDetails, IConversationEnabled,
         if (lastQuery != null){
             bulkEditorComposite.performSearch(lastQuery, selection);
         }
-       
+
     }
 
 
@@ -186,7 +185,8 @@ public class BulkEditor implements IPartContentHasDetails, IConversationEnabled,
                return new StructuredSelection(this.bulkEditorComposite.getLastSelectedObject());
        }
 
-       @Focus
+       @Override
+    @Focus
        public void setFocus() {
         //make sure to bind again if maybe in another view the conversation was unbound
         if(conversation!=null && !conversation.isBound()){
@@ -241,6 +241,7 @@ public class BulkEditor implements IPartContentHasDetails, IConversationEnabled,
         return bulkEditorComposite.getCellSelection();
     }
 
+    @Override
     public void setSelection(IStructuredSelection selection){
         bulkEditorComposite.setSelection(selection);
     }
@@ -333,7 +334,7 @@ public class BulkEditor implements IPartContentHasDetails, IConversationEnabled,
             }else if (element instanceof Media && input instanceof MediaEditorInput){
                getEditorInput().addSaveCandidate((Media)element);
                 input.replaceInModel((Media)element);
-            }else if (element instanceof Media ) {             
+            }else if (element instanceof Media ) {
                 IStructuredSelection sel = getSelection();
                 Object firstElement = sel.getFirstElement();
                 if (firstElement instanceof TaxonBase){
@@ -344,7 +345,7 @@ public class BulkEditor implements IPartContentHasDetails, IConversationEnabled,
                     SpecimenOrObservationBase changedSpecimen = (SpecimenOrObservationBase)sel.getFirstElement();
                     getEditorInput().addSaveCandidate(changedSpecimen);
                     input.replaceInModel(changedSpecimen);
-                } 
+                }
             }else if(element instanceof Group){
                  Group oldGroup = ((GroupEditorInput)input).getEntityFromModel((Group)element);
                  ((GroupEditorInput)input).getSaveUserCandidates().addAll(oldGroup.getMembers());
@@ -375,7 +376,7 @@ public class BulkEditor implements IPartContentHasDetails, IConversationEnabled,
                        getEditorInput().addSaveCandidate(taxon);
                        input.replaceInModel(taxon);
                 }
-                
+
             }
             else{
                 getEditorInput().addSaveCandidate((CdmBase)element);
index e54026ae3f78e203422420a0058e166d005b5f05..e49b0e8273c0afbf31d5dcdb6e69fc5840e9a7f9 100644 (file)
@@ -1,3 +1,11 @@
+/**
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
 package eu.etaxonomy.taxeditor.session;
 
 import java.util.Collection;
index 95dced8e0daed6e0e23a269848d20ae8bc372145..e10f95cbe10bee760410742f9a7a5a6fda3a79cf 100644 (file)
@@ -242,7 +242,6 @@ public class EditorUtil extends AbstractUtility {
                        partService.activate(part, true);
                        return;
                    }
-
             }
         }
         if (alreadyOpenInOtherClassification != null){
@@ -276,13 +275,11 @@ public class EditorUtil extends AbstractUtility {
     public static void showMedia(EModelService modelService, EPartService partService) {
         String partIdFactualData = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_MEDIA_E4_MEDIAVIEWPARTE4;
         showPart(partIdFactualData, modelService, partService);
-
     }
 
     public static void showFacts(EModelService modelService, EPartService partService) {
         String partIdFactualData = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DESCRIPTIVE_E4_FACTUALDATAPARTE4;
         showPart(partIdFactualData, modelService, partService);
-
     }
 
     public static Collection<MPart> checkForChanges(UUID taxonUUID, EPartService partService ){
index 8916c1ebc1596f3707c04b0388adcac241e3c983..0a5a6f37690a219b80c97d7d8f713cf29d6cbd0a 100644 (file)
@@ -126,7 +126,6 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput<TaxonNode>
         }
         init(taxonNode);
         setInitiallySelectedTaxonBase(getTaxon());
-
     }
 
     private void initForTaxonBase(UUID taxonBaseUuid) {
@@ -171,7 +170,6 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput<TaxonNode>
         }
     }
 
-
     private void initForParentTaxonNode(UUID parentNodeUuid){
        this.getCdmEntitySession().bind();
         TaxonName name = PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null);
@@ -258,7 +256,6 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput<TaxonNode>
 
     public static TaxonEditorInputE4 NewInstance(UUID taxonNodeUuid) {
         return new TaxonEditorInputE4(taxonNodeUuid, CdmType.TAXON_NODE);
-
     }
 
     public static TaxonEditorInputE4 NewInstanceFromTaxonBase(UUID taxonBaseUuid){
index 8841e7d7b5c63de522859e5b7990131496a4b946..71139af242d737f0727b9c970bed9f9883f5cd69 100644 (file)
@@ -104,9 +104,10 @@ import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
  * @author pplitzner
  * @date Aug 24, 2017
  */
-public class TaxonNameEditorE4 implements IConversationEnabled, IDirtyMarkable, IPartContentHasDetails,
-        IPartContentHasSupplementalData, IPartContentHasMedia, IPartContentHasFactualData, IPartChangeListener,
-        ISelectionListener, ISecuredEditor, IE4SavablePart, ITaxonEditor, IDropTargetableE4 {
+public class TaxonNameEditorE4
+        implements IConversationEnabled, IDirtyMarkable, IPartContentHasDetails,
+            IPartContentHasSupplementalData, IPartContentHasMedia, IPartContentHasFactualData, IPartChangeListener,
+            ISelectionListener, ISecuredEditor, IE4SavablePart, ITaxonEditor, IDropTargetableE4 {
 
     private Taxon taxon;
 
index 4baea928aa69807b7527f22125ae1ea87e0a2e37..e1af073be80b5b769f260557b1c70d598f104519 100644 (file)
@@ -122,14 +122,17 @@ public class FactualDataPartE4 extends AbstractCdmEditorPartE4
 
     @Override
     public void selectionChanged_internal(Object selection, MPart activePart, MPart thisPart) {
-        if(activePart==thisPart){
+        if(activePart == thisPart){
             return;
         }
 
         Object partObject = createPartObject(activePart);
 
-        if ((partObject instanceof DetailsPartE4 && !(selection instanceof TaxonName))|| partObject instanceof SupplementalDataPartE4
-                || partObject instanceof MediaViewPartE4 || partObject instanceof ConceptViewPartE4 || ((partObject instanceof AbstractCdmEditorPartE4) &&(((AbstractCdmEditorPartE4)partObject).getViewer().getInput() instanceof DescriptionElementBase))) {
+        if ( (partObject instanceof DetailsPartE4 && !(selection instanceof TaxonName))
+              || partObject instanceof SupplementalDataPartE4
+              || partObject instanceof MediaViewPartE4
+              || partObject instanceof ConceptViewPartE4
+              || ((partObject instanceof AbstractCdmEditorPartE4) &&(((AbstractCdmEditorPartE4)partObject).getViewer().getInput() instanceof DescriptionElementBase))) {
             // do not show empty page as these views are also used to edit the
             // description selected in this view
             return;
@@ -220,7 +223,7 @@ public class FactualDataPartE4 extends AbstractCdmEditorPartE4
                StructuredSelection selection = new StructuredSelection(object);
                viewer.setSelection(selection, true);
             }
-            
+
         }
 
 
index e4305e254b670661facc499aa16120893bc90331..70d71d8cd42a4510290154cfd7d53efc64cf9bee 100644 (file)
@@ -349,13 +349,14 @@ public class CdmStore {
             return mockCdmEntitySessionManager;
         }
     }
-    public static  ICdmEntitySessionManager getCurrentSessionManager() {
+    public static ICdmEntitySessionManager getCurrentSessionManager() {
         return getCurrentSessionManager(false);
     }
 
     public static  ICdmEntitySessionManager getCurrentSessionManager(boolean connecting) {
-        if (getDefault(connecting) != null) {
-            return getDefault(connecting).getSessionManager();
+        CdmStore cdmStore = getDefault(connecting);
+        if (cdmStore != null) {
+            return cdmStore.getSessionManager();
         }
         return null;
     }
index 302328d95e26e1f5477023e6f6b8c7c881fd009e..78976a08fae6adc89d9f87b0b54f080adb32afb1 100644 (file)
@@ -69,6 +69,7 @@ public abstract class AbstractCdmEditorPartE4
        private static final Logger logger = LogManager.getLogger(AbstractCdmEditorPartE4.class);
 
        private DelaySelection delaySelection = null;
+
     /**
      * This is the monitor for the DelaySelection runnable.
      * If it is <code>true</code> then it is currently delaying a selection.
@@ -146,20 +147,23 @@ public abstract class AbstractCdmEditorPartE4
             @Optional@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
             @Optional@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
             MPart thisPart, UISynchronize sync, EPartService partService){
+
         //multiple selections are not supported
-        if(activePart!=null
-                && thisPart!=null
+        if(activePart != null
+                && thisPart != null
                 && !activePart.equals(thisPart)
                 && selection instanceof IStructuredSelection
                 && ((IStructuredSelection) selection).size()>1){
             showEmptyPage();
             return;
         }
+
         // no active editor found
-        if(activePart==thisPart && WorkbenchUtility.getActiveEditorPart(partService)==null && showEmptyIfNoActiveEditor()){
+        if(activePart == thisPart && WorkbenchUtility.getActiveEditorPart(partService) == null && showEmptyIfNoActiveEditor()){
             showEmptyPage();
             return;
         }
+
         if (viewer != null && viewer.getControl()!= null && viewer.getInput() != null && !viewer.getControl().isDisposed()){
            try{
                viewer.getControl().setEnabled(isEnabled);
@@ -168,15 +172,17 @@ public abstract class AbstractCdmEditorPartE4
            }
         }
 
-        if((previousSelection!=null && selection!=null)
-               && (activePart != null &&  selectionProvidingPart != null && activePart.equals(selectionProvidingPart))
-               && (previousSelection==selection
+        //same as previous selection? => return
+        if((previousSelection != null && selection != null)
+               && (activePart != null && selectionProvidingPart != null
+                   && activePart.equals(selectionProvidingPart))
+               && (previousSelection == selection
                     || previousSelection.equals(selection)
                     || new StructuredSelection(selection).equals(previousSelection))
                 ) {
             return;
         }
-        if(delaySelection==null){
+        if(delaySelection == null){
             delaySelection = new DelaySelection(selection, activePart, thisPart);
         }else{
             delaySelection.setSelection(selection);
@@ -306,7 +312,6 @@ public abstract class AbstractCdmEditorPartE4
                 }
             }
         }
-
     }
 
     protected Object createPartObject(MPart activePart) {
index 1012c54a21e85d1c306ad9a66fce37373b1489b8..df8dbbe0436e07f6cf3becc5dc830c8ebe8405c8 100644 (file)
@@ -16,25 +16,17 @@ import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 /**
  * @author cmathew
  * @date 15 Jun 2015
- *
  */
 public class MockConversationEnabled implements IConversationEnabled {
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
-     */
     @Override
     public void update(CdmDataChangeMap arg0) {
         // TODO Auto-generated method stub
 
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
-     */
     @Override
     public ConversationHolder getConversationHolder() {
         return new ConversationHolderMock();
     }
-
-}
+}
\ No newline at end of file