Project

General

Profile

Revision 30189b61

ID30189b61235b75309e433df5708c34d30187a37b
Parent 6140d10b
Child 6e0d89ec

Added by Katja Luther about 1 year ago

ref #7793: add cdm preference to disable multi classification functionality

View differences:

eu.etaxonomy.taxeditor.navigation/fragment.e4xmi
48 48
        <children xsi:type="menu:Menu" xmi:id="_yzFmYJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menu.new" label="%menu.label">
49 49
          <children xsi:type="menu:HandledMenuItem" xmi:id="_wzftMJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menu.new.taxon" label="%command.label.2" command="_Nx06MJIvEeeJAdt8ZUxyaw"/>
50 50
          <children xsi:type="menu:MenuSeparator" xmi:id="_33c4IJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.0"/>
51
          <children xsi:type="menu:HandledMenuItem" xmi:id="_4dTXMJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menu.new.classification" label="%command.label.3" command="_Vco-4JIxEeeJAdt8ZUxyaw"/>
51
          <children xsi:type="menu:HandledMenuItem" xmi:id="_4dTXMJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menu.new.classification" label="%command.label.3" command="_Vco-4JIxEeeJAdt8ZUxyaw">
52
            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_wlrJYNMPEeiXranio7VdMQ" coreExpressionId="noClassificationExists"/>
53
          </children>
52 54
        </children>
53 55
        <children xsi:type="menu:MenuSeparator" xmi:id="_24NMMJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.5"/>
54 56
        <children xsi:type="menu:DynamicMenuContribution" xmi:id="_3d1BwJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.dynamicmenucontribution.openInCdmViewer" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.CdmViewerContextMenuE4"/>
eu.etaxonomy.taxeditor.navigation/plugin.xml
46 46
            class="eu.etaxonomy.taxeditor.navigation.navigator.TaxonNodePropertyTester"
47 47
            id="eu.etaxonomy.taxeditor.navigation.navigator.navigatorPropertyTester"
48 48
            namespace="eu.etaxonomy.taxeditor.navigation.navigator.navigatorPropertyTester"
49
            properties="hasSynonyms,isClassification,isUnplaced,isExcluded"
49
            properties="hasSynonyms,isClassification,isUnplaced,isExcluded,noClassificationExists"
50 50
            type="java.lang.Object">
51 51
      </propertyTester>
52 52
      
......
174 174
               property="eu.etaxonomy.taxeditor.navigation.navigator.TaxonNodePropertyTester.isExcluded">
175 175
         </test>
176 176
      </definition>
177
       <definition
178
             id="noClassificationExists">
179
          <test
180
                property="eu.etaxonomy.taxeditor.navigation.navigator.TaxonNodePropertyTester.noClassificationExists">
181
          </test>
182
       </definition>
177 183
   </extension>
184
   <definition
185
            id="noClassificationExists">
186
         <not>
187
            <reference 
188
               definitionId="eu.etaxonomy.taxeditor.navigation.navigator.TaxonNodePropertyTester.noClassificationExists">
189
            </reference>
190
         </not>
191
      </definition>
178 192
   <extension
179 193
         id="eu.etaxonomy.taxeditor.navigation.workbench.model"
180 194
         name="Navigation Workbench Model"
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodePropertyTester.java
11 11

  
12 12
import org.eclipse.core.expressions.PropertyTester;
13 13

  
14
import eu.etaxonomy.cdm.api.service.IClassificationService;
15
import eu.etaxonomy.cdm.model.taxon.Classification;
14 16
import eu.etaxonomy.cdm.model.taxon.Taxon;
15 17
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
16 18
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
19
import eu.etaxonomy.taxeditor.store.CdmStore;
17 20
public class TaxonNodePropertyTester extends PropertyTester {
18 21

  
19 22
	private static final Object HAS_SYNONYMS = "hasSynonyms"; //$NON-NLS-1$
......
21 24
	private static final Object IS_CLASSIFICATION = "isClassification"; //$NON-NLS-1$
22 25
	private static final Object IS_UNPLACED = "isUnplaced";
23 26
	private static final Object IS_EXCLUDED = "isExcluded";
27
    private static final Object NO_CLASSIFICATION_EXIST = "noClassificationExist";
24 28
	/** {@inheritDoc} */
25 29
	@Override
26 30
    public boolean test(Object receiver, String property, Object[] args,
......
57 61
            TaxonNodeDto node = (TaxonNodeDto) receiver;
58 62
            return node.isExcluded();
59 63
        }
64
		if (NO_CLASSIFICATION_EXIST.equals(property)) {
65
           return 0 == CdmStore.getService(IClassificationService.class).count(Classification.class);
66
        }
60 67

  
61 68
		return false;
62 69
	}
70

  
71
	public static boolean noClassifiactionExists(){
72
	    int count = CdmStore.getService(IClassificationService.class).count(Classification.class);
73
	    return 0 == count;
74
	}
63 75
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/CloneClassificationHandlerE4.java
73 73
        canExecute = selection.size()==1
74 74
                && selection.getFirstElement() instanceof TaxonNode
75 75
                && ((TaxonNode) selection.getFirstElement()).getTaxon()==null
76
                && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES);
76
                && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES)
77
                && !PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISABLE_MULTI_CLASSIFICATION);
77 78
        menuItem.setVisible(canExecute);
78 79
        return canExecute;
79 80
    }
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/CreateClassificationHierarchyHandlerE4.java
56 56
        canExecute = selection.size()==1
57 57
                && selection.getFirstElement() instanceof TaxonNode
58 58
                && ((TaxonNode) selection.getFirstElement()).getTaxon()==null
59
                && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES);
59
                && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES)
60
                && !PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISABLE_MULTI_CLASSIFICATION);
60 61
        menuItem.setVisible(canExecute);
61 62
        return canExecute;
62 63
    }
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/NewClassificationHandlerE4.java
11 11

  
12 12
import javax.inject.Named;
13 13

  
14
import org.eclipse.e4.core.di.annotations.CanExecute;
14 15
import org.eclipse.e4.core.di.annotations.Execute;
15 16
import org.eclipse.e4.core.di.annotations.Optional;
17
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
16 18
import org.eclipse.e4.ui.services.IServiceConstants;
17 19
import org.eclipse.jface.viewers.ITreeSelection;
18 20
import org.eclipse.jface.wizard.WizardDialog;
19 21
import org.eclipse.swt.widgets.Shell;
20 22

  
23
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNodePropertyTester;
21 24
import eu.etaxonomy.taxeditor.newWizard.NewClassificationWizard;
25
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
26
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
22 27

  
23 28
/**
24 29
 *
......
37 42
		dialog.open();
38 43

  
39 44
	}
45

  
46
    @CanExecute
47
    private boolean canExecute(MHandledMenuItem menuItem){
48
        boolean canExecute = false;
49

  
50
        canExecute = TaxonNodePropertyTester.noClassifiactionExists() || !PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISABLE_MULTI_CLASSIFICATION);
51
        menuItem.setVisible(canExecute);
52
        return canExecute;
53
    }
40 54
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/IPreferenceKeys.java
252 252
    public static final String SHOW_TAXONNODE_WIZARD = "eu.etaxonomy.taxeditor.menu.showTaxonNodeWizard";
253 253
    public static final String IS_SEARCH_FOR_IDENTIFIER_AS_DEFAULT = "eu.etaxonomy.taxeditor.search.reference.defaultIdentifier";
254 254
    public static final String SEARCH_FOR_IDENTIFIER_AND_TITLECACHE = "eu.etaxonomy.taxeditor.search.reference.identifierAndTitleCache";
255
    public static final String DISABLE_MULTI_CLASSIFICATION = "eu.etaxonomy.taxeditor.classification.multi";
256

  
257
    public static final String SHOW_ID_IN_SOURCE = "eu.etaxonomy.taxeditor.source.detail.IdInSource";
258
    public static final String SHOW_NAME_IN_SOURCE = "eu.etaxonomy.taxeditor.source.detail.nameInSource";
259

  
255 260

  
256 261

  
257 262

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
606 606

  
607 607
		getPreferenceStore().setDefault(FILTER_COMMON_NAME_REFERENCES, false);
608 608
		getPreferenceStore().setDefault(SHOW_SPECIMEN, true);
609
		getPreferenceStore().setDefault(SHOW_TAXONNODE_WIZARD, false);
609
		getPreferenceStore().setDefault(SHOW_TAXONNODE_WIZARD, true);
610
		getPreferenceStore().setDefault(SHOW_NAME_IN_SOURCE, true);
611
		getPreferenceStore().setDefault(SHOW_ID_IN_SOURCE, true);
612
		getPreferenceStore().setDefault(DISABLE_MULTI_CLASSIFICATION, false);
610 613

  
611 614
	}
612 615

  
......
1732 1735
        }
1733 1736
    }
1734 1737

  
1738
    preference = getPreferenceFromDB(PreferencePredicate.UseOnlyReferencesWithCommonNameMarker);
1739
    if (preference != null){
1740
        if (!prefStore.getBoolean(FILTER_COMMON_NAME_REFERENCES) ||  !preference.isAllowOverride()){
1741
            prefStore.setValue(FILTER_COMMON_NAME_REFERENCES, preference.getValue());
1742
        }
1743
    }
1744

  
1745

  
1735 1746
    preference = getPreferenceFromDB(PreferencePredicate.ShowTaxonNodeWizard);
1736 1747
    if (preference != null){
1737 1748
        if (!prefStore.getBoolean(SHOW_TAXONNODE_WIZARD) ||  !preference.isAllowOverride()){
......
1739 1750
        }
1740 1751
    }
1741 1752

  
1753
    preference = getPreferenceFromDB(PreferencePredicate.ShowIdInSource);
1754
    if (preference != null){
1755
        if (!prefStore.getBoolean(SHOW_ID_IN_SOURCE) ||  !preference.isAllowOverride()){
1756
            prefStore.setValue(SHOW_ID_IN_SOURCE, preference.getValue());
1757
        }
1758
    }
1759

  
1760
    preference = getPreferenceFromDB(PreferencePredicate.ShowNameInSource);
1761
    if (preference != null){
1762
        if (!prefStore.getBoolean(SHOW_NAME_IN_SOURCE) ||  !preference.isAllowOverride()){
1763
            prefStore.setValue(SHOW_NAME_IN_SOURCE, preference.getValue());
1764
        }
1765
    }
1766

  
1767
    preference = getPreferenceFromDB(PreferencePredicate.DisableMultiClassification);
1768
    if (preference != null){
1769
        if (!prefStore.getBoolean(DISABLE_MULTI_CLASSIFICATION) ||  !preference.isAllowOverride()){
1770
            prefStore.setValue(DISABLE_MULTI_CLASSIFICATION, preference.getValue());
1771
        }
1772
    }
1773

  
1742 1774
}
1743 1775

  
1744 1776

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)