fix name editor menu for synonyms and misapplications
authorKatja Luther <k.luther@bgbm.org>
Fri, 27 Apr 2018 12:04:15 +0000 (14:04 +0200)
committerKatja Luther <k.luther@bgbm.org>
Fri, 27 Apr 2018 12:04:15 +0000 (14:04 +0200)
eu.etaxonomy.taxeditor.editor/fragment.e4xmi
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/NameEditorMenuPropertyTester.java
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle.properties
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle_de.properties
eu.etaxonomy.taxeditor.store/plugin.xml
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/ListComponent.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/NomenclaturalCodePreferences.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SpecimenAdminPreferences.java [new file with mode: 0755]

index e04b4ca8b6bb72853d6e538f9fa41f1c2a9da800..aa6ccaf833d9875dabb709ce551137d35d6d9eda 100644 (file)
       <handlers xmi:id="_lv9GYIvQEee7R4eqeQiXZg" elementId="eu.etaxonomy.taxeditor.editor.name.e4.handler.MoveSynonymToAnotherAcceptedTaxonHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.name.e4.handler.MoveSynonymToAnotherAcceptedTaxonHandlerE4" command="_jNvBQIvQEee7R4eqeQiXZg"/>
       <menus xsi:type="menu:PopupMenu" xmi:id="_tLceQYl4Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.nameeditor">
         <children xsi:type="menu:Menu" xmi:id="_R6buoIl5Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menu.new" label="%menu.label">
-          <children xsi:type="menu:HandledMenuItem" xmi:id="_FjdDgIl8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.newHeterotypicSynonym" label="%command.label.9" command="_ult4EIvOEee7R4eqeQiXZg"/>
-          <children xsi:type="menu:HandledMenuItem" xmi:id="_Gsr8cIl8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.newHomotypicSynonym" label="%command.label.10" command="_KpUFsIvPEee7R4eqeQiXZg"/>
+          <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_X1lWsEoREeiEhr9v9h_MoA" coreExpressionId="isNotMisapplication"/>
+          <children xsi:type="menu:HandledMenuItem" xmi:id="_FjdDgIl8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.newHeterotypicSynonym" label="%command.label.9" command="_ult4EIvOEee7R4eqeQiXZg">
+            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="__6Cq8EoNEeiEhr9v9h_MoA" coreExpressionId="isAcceptedTaxon"/>
+          </children>
+          <children xsi:type="menu:HandledMenuItem" xmi:id="_Gsr8cIl8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.newHomotypicSynonym" label="%command.label.10" command="_KpUFsIvPEee7R4eqeQiXZg">
+            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_C-LKUEoOEeiEhr9v9h_MoA" coreExpressionId="isAcceptedTaxon"/>
+          </children>
           <children xsi:type="menu:HandledMenuItem" xmi:id="_I6FoIIl8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.newSynonymInHomotypicGroup" label="%command.label.11" command="_VPLRIIvPEee7R4eqeQiXZg"/>
           <children xsi:type="menu:MenuSeparator" xmi:id="_LGspoIl8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.16"/>
-          <children xsi:type="menu:HandledMenuItem" xmi:id="_MCsX0Il8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.newMisapplication" label="%command.label.49" command="_c0byUIvPEee7R4eqeQiXZg"/>
+          <children xsi:type="menu:HandledMenuItem" xmi:id="_MCsX0Il8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.newMisapplication" label="%command.label.49" command="_c0byUIvPEee7R4eqeQiXZg">
+            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_G1zjMEoOEeiEhr9v9h_MoA" coreExpressionId="isAcceptedTaxon"/>
+          </children>
         </children>
         <children xsi:type="menu:Menu" xmi:id="_ZXIJsIl5Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menu.changeTo" label="%menu.label.0">
           <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_eERMsEn0EeiEhr9v9h_MoA" coreExpressionId="isNotAcceptedTaxon"/>
-          <children xsi:type="menu:HandledMenuItem" xmi:id="_Nt_cAIl8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.changeToAccepted" label="%command.label.12" command="_oBnccIvPEee7R4eqeQiXZg"/>
-          <children xsi:type="menu:HandledMenuItem" xmi:id="_POj24Il8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.nameEditor.menuItem.changeToSynonym" label="%command.label.13" command="_yh49QIvPEee7R4eqeQiXZg"/>
-          <children xsi:type="menu:HandledMenuItem" xmi:id="_QbC4IIl8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.changeToMisapplication" label="%command.label.14" command="_56AaUIvPEee7R4eqeQiXZg"/>
+          <children xsi:type="menu:HandledMenuItem" xmi:id="_Nt_cAIl8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.changeToAccepted" label="%command.label.12" command="_oBnccIvPEee7R4eqeQiXZg">
+            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_lSby0EoQEeiEhr9v9h_MoA" coreExpressionId="isSynonym"/>
+          </children>
+          <children xsi:type="menu:HandledMenuItem" xmi:id="_POj24Il8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.nameEditor.menuItem.changeToSynonym" label="%command.label.13" command="_yh49QIvPEee7R4eqeQiXZg">
+            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_h6hb0EoQEeiEhr9v9h_MoA" coreExpressionId="isMisapplication"/>
+          </children>
+          <children xsi:type="menu:HandledMenuItem" xmi:id="_QbC4IIl8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.changeToMisapplication" label="%command.label.14" command="_56AaUIvPEee7R4eqeQiXZg">
+            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_fYbSgEoQEeiEhr9v9h_MoA" coreExpressionId="isSynonym"/>
+          </children>
         </children>
         <children xsi:type="menu:MenuSeparator" xmi:id="_a0anEIl5Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.13"/>
         <children xsi:type="menu:HandledMenuItem" xmi:id="_bu3dIIl5Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.delete" label="%command.label.15" command="_CoVcYIvQEee7R4eqeQiXZg"/>
index 2fd077f45e38d28396a67103fa6c89f3631ba4d1..3f957e265b9ef4ede5fb42d4b632909d4d031767 100644 (file)
                   property="eu.etaxonomy.taxeditor.editor.name.propertyTester.isMisapplication">
             </test>
          </with>
+      </definition>
+           <definition
+            id="isNotMisapplication">
+         <with
+               variable="selection">
+            <test
+                  property="eu.etaxonomy.taxeditor.editor.name.propertyTester.isNotMisapplication">
+            </test>
+         </with>
       </definition>
       <definition
             id="isTaxonBase">
             class="eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester"
             id="eu.etaxonomy.taxeditor.editor.name.propertyTester"
             namespace="eu.etaxonomy.taxeditor.editor.name.propertyTester"
-            properties="isAcceptedTaxon,isSynonym,isMisapplication,isTaxonBase,hasEmptyNames,isAcceptedAndHasNoHomotypicSynonyms,isNotHomotypicSynonymOfAcceptedTaxon,isNotAcceptedTaxon,isSynonymInHomotypicalGroupWithMoreSynonyms,isOrphaned"
+            properties="isAcceptedTaxon,isSynonym,isMisapplication,isNotMisapplication,isTaxonBase,hasEmptyNames,isAcceptedAndHasNoHomotypicSynonyms,isNotHomotypicSynonymOfAcceptedTaxon,isNotAcceptedTaxon,isSynonymInHomotypicalGroupWithMoreSynonyms,isOrphaned"
             type="java.lang.Object">
       </propertyTester>
       <propertyTester
index 7fb6c13594df21f35950e47486edc4f549d9335f..82fc05f0d01a7f7836ff7ad49cad7166408e4bb2 100644 (file)
@@ -34,6 +34,7 @@ public class NameEditorMenuPropertyTester extends PropertyTester {
        private static final String NOT_ACCEPTED = "isNotAcceptedTaxon"; //$NON-NLS-1$
        private static final String SYNONYM = "isSynonym"; //$NON-NLS-1$
        private static final String MISAPPLICATION = "isMisapplication"; //$NON-NLS-1$
+       private static final String NOT_MISAPPLICATION = "isNotMisapplication"; //$NON-NLS-1$
        private static final String TAXONBASE = "isTaxonBase"; //$NON-NLS-1$
        private static final String CONCEPT = "isConceptRelation"; //$NON-NLS-1$
        private static final String EMPTY_NAMES = "hasEmptyNames"; //$NON-NLS-1$
@@ -75,6 +76,9 @@ public class NameEditorMenuPropertyTester extends PropertyTester {
                        else if(MISAPPLICATION.equals(property)){
                                return isMisapplication(selectedElement);
                        }
+                       else if(NOT_MISAPPLICATION.equals(property)){
+                return isNotMisapplication(selectedElement);
+            }
                        else if(TAXONBASE.equals(property)){
                                return isTaxonBase(selectedElement);
                        }
@@ -115,6 +119,11 @@ public class NameEditorMenuPropertyTester extends PropertyTester {
         return !isAccepted(selectedElement);
     }
 
+       public static boolean isNotMisapplication(Object selectedElement) {
+
+        return !isMisapplication(selectedElement);
+    }
+
        public static boolean isSynonymInHomotypicalGroupWithMoreSynonyms(Object selectedElement) {
                if (isSynonym(selectedElement)){
                        Synonym synonym = (Synonym) selectedElement;
index 7938290b3a5593645cd5edbf42b1e93b44bf30eb..26a7cdf4ab1013ae6868c6b56eeb59294c7077f5 100644 (file)
@@ -190,4 +190,5 @@ page.name.43 = Nomenclatural Code Admin
 page.name.44 = Name Details\r
 extension-point.name = Cdm Viewer\r
 extension-point.name.0 = Preference Page\r
-extension-point.name.1 = Admin Preference Page
\ No newline at end of file
+extension-point.name.1 = Admin Preference Page\r
+page.name.45 = Specimen Preferences
\ No newline at end of file
index 6ab5f5660f6379c8070f216500dc375959477372..013d377101d6d47f5958fbb766c305e7cb996655 100644 (file)
@@ -189,5 +189,6 @@ page.name.42 = Datenbank Pr
 page.name.43 = Nomenklatorischer Code
 page.name.44 = Detailsview für wissenschaftliche Namen
 extension-point.name = Cdm Viewer
-extension-point.name.0 = Preference Page
-extension-point.name.1 = Admin Preference Page
\ No newline at end of file
+extension-point.name.0 = Präferenzen
+extension-point.name.1 = Admin Präferenzen
+page.name.45 = Specimen Präferenzen
\ No newline at end of file
index 526e4b3c8ec47cc9fa12afddb75ac05ae8e35710..e693d7d3bc4d7b658ee7d6e5c7a7c4ac542b17c8 100755 (executable)
          class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.AbcdImportProvider"
          id="eu.etaxonomy.taxeditor.store.abcdImportProvider"
          name="%page.name.41">
+   </page>
+    <page
+         category="eu.etaxonomy.taxeditor.preferences.general"
+         class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.SpecimenAdminPreferences"
+         id="eu.etaxonomy.taxeditor.store.specimenAdminPreferences"
+         name="%page.name.45">
    </page>
    <page
         
index b12ba0d100b655b679f2fc4ad6e035e93f67fd59..9f5239ae29c395ea1fe02d57aee5b12b5de069c4 100755 (executable)
@@ -55,7 +55,10 @@ public class ListComponent
         list.setBounds (clientArea.x, clientArea.y, 100, 500);
 
         CdmPreference providerListPreference = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.BioCaseProvider);
-        String allProviderString = providerListPreference.getValue();
+        String allProviderString = "";
+        if (providerListPreference != null){
+            allProviderString  = providerListPreference.getValue();
+        }
 //         = PreferencesUtil.getPreferenceStore().getString(IPreferenceKeys.BIOCASE_PROVIDER_LIST);
         //the string is structured like this: http://ww3.bgbm.org/biocase/pywrapper.cgi?dsa=DNA_Bank;http:...;
         String[] providerArray = allProviderString.split(";");
index 226e536792bde2aae044935d8ceeeead1a234646..333e9e48fbc7aeadc4ffbb221f29d957653ebca7 100755 (executable)
@@ -129,6 +129,8 @@ public class NomenclaturalCodePreferences extends CdmPreferencePage implements I
               if (pref != null){
                   actualCode = pref.getValue();
 
+              }else{
+                  actualCode = PreferencesUtil.getPreferenceKey(PreferencesUtil.getPreferredNomenclaturalCode());
               }
           }
 
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SpecimenAdminPreferences.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SpecimenAdminPreferences.java
new file mode 100755 (executable)
index 0000000..03fb987
--- /dev/null
@@ -0,0 +1,166 @@
+/**
+* Copyright (C) 2018 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.databaseAdmin.preferencePage;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import eu.etaxonomy.cdm.api.application.ICdmRepository;
+import eu.etaxonomy.cdm.api.service.IPreferenceService;
+import eu.etaxonomy.cdm.model.metadata.CdmPreference;
+import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
+import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
+import eu.etaxonomy.taxeditor.l10n.Messages;
+import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author k.luther
+ * @since 27.04.2018
+ *
+ */
+public class SpecimenAdminPreferences extends CdmPreferencePage implements IE4AdminPreferencePage {
+
+
+
+    boolean isShowCollectingAreaInGeneralSection = false;
+    boolean isDeterminationOnlyForFieldUnits = false;
+    boolean isShowTaxonAssociation = false;
+    boolean isShowLifeForm = false;
+    boolean isUseLocalPreference = false;
+
+
+    @Override
+    protected Control createContents(Composite parent) {
+        Composite composite = new Composite(parent, SWT.NULL);
+
+        final Button showCollectingAreaInGeneralSectionButton = new Button(composite, SWT.CHECK);
+
+        showCollectingAreaInGeneralSectionButton.setText(Messages.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section);
+
+        showCollectingAreaInGeneralSectionButton.setSelection(isShowCollectingAreaInGeneralSection);
+        showCollectingAreaInGeneralSectionButton.addSelectionListener(new SelectionAdapter(){
+             @Override
+             public void widgetSelected(SelectionEvent e) {
+                 isShowCollectingAreaInGeneralSection = showCollectingAreaInGeneralSectionButton.getSelection();
+
+              }
+         });
+
+        final Button determinationOnlyForFieldUnitsButton = new Button(composite, SWT.CHECK);
+
+        determinationOnlyForFieldUnitsButton.setText(Messages.DatabasePreferncesPage_Determination_only_for_field_unnits);
+
+        determinationOnlyForFieldUnitsButton.setSelection(isDeterminationOnlyForFieldUnits);
+        determinationOnlyForFieldUnitsButton.addSelectionListener(new SelectionAdapter(){
+             @Override
+             public void widgetSelected(SelectionEvent e) {
+                 isDeterminationOnlyForFieldUnits = determinationOnlyForFieldUnitsButton.getSelection();
+                               }
+         });
+
+        final Button showTaxonAssociationButton = new Button(composite, SWT.CHECK);
+
+        showTaxonAssociationButton.setText(Messages.DatabasePreferncesPage_Taxon_Associations);
+
+        showTaxonAssociationButton.setSelection(isShowTaxonAssociation);
+        showTaxonAssociationButton.addSelectionListener(new SelectionAdapter(){
+             @Override
+             public void widgetSelected(SelectionEvent e) {
+                 isShowTaxonAssociation = showTaxonAssociationButton.getSelection();
+
+              }
+         });
+
+        final Button showLifeFormButton = new Button(composite, SWT.CHECK);
+        showLifeFormButton.setText(Messages.DatabasePreferncesPage_Life_Form);
+        showLifeFormButton.setSelection(isShowLifeForm);
+        showLifeFormButton.addSelectionListener(new SelectionAdapter(){
+             @Override
+             public void widgetSelected(SelectionEvent e) {
+                 isShowLifeForm = showLifeFormButton.getSelection();
+
+              }
+         });
+
+    //    Composite useLocalComp = new Composite(composite, SWT.NONE);
+
+
+        final Button useLocalPreference = new Button(composite, SWT.CHECK);
+
+        useLocalPreference.setText(Messages.DatabasePreferencesPage_UseLocalPreferences);
+        GridData gridData = new GridData(SWT.FILL, SWT.BOTTOM, false, false);
+        gridData.verticalIndent = 10;
+        useLocalPreference.setLayoutData(gridData);
+
+        useLocalPreference.setSelection(isUseLocalPreference);
+        useLocalPreference.addSelectionListener(new SelectionAdapter(){
+             @Override
+             public void widgetSelected(SelectionEvent e) {
+                 isUseLocalPreference = useLocalPreference.getSelection();
+
+              }
+         });
+        return composite;
+    }
+
+    @Override
+    public void init() {
+        super.init();
+        if(!CdmStore.isActive()){
+            return;
+        }
+          ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
+          if (controller != null){
+              IPreferenceService service = controller.getPreferenceService();
+              PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection);
+              CdmPreference isShowCollectingAreaInGeneralSectionPref = service.find(key);
+              if (isShowCollectingAreaInGeneralSectionPref != null){
+                  this.isShowCollectingAreaInGeneralSection = Boolean.valueOf(isShowCollectingAreaInGeneralSectionPref.getValue());
+              }
+              key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
+              CdmPreference isDeterminationOnlyForFieldUnitsPref = service.find(key);
+              if (isDeterminationOnlyForFieldUnitsPref != null){
+                  this.isDeterminationOnlyForFieldUnits = Boolean.valueOf(isDeterminationOnlyForFieldUnitsPref.getValue());
+              }
+              key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.ShowTaxonAssociations);
+              CdmPreference isShowTaxonAssociationPref = service.find(key);
+              if (isShowTaxonAssociationPref != null){
+                  this.isShowTaxonAssociation = Boolean.valueOf(isShowTaxonAssociationPref.getValue());
+                  isUseLocalPreference = isShowTaxonAssociationPref.isAllowOverride();
+              }
+
+              key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.ShowLifeForm);
+              CdmPreference isShowLifeFormPref = service.find(key);
+              if (isShowLifeFormPref != null){
+                  this.isShowLifeForm = Boolean.valueOf(isShowLifeFormPref.getValue());
+              }
+
+
+
+
+          }
+
+
+    }
+
+    @Override
+     public boolean performOk() {
+
+
+        return true;
+    }
+
+}