--- /dev/null
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="eu.etaxonomy.taxeditor.store" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="eu.etaxonomy.taxeditor.store" id="eu.etaxonomy.taxeditor.store.adminPreferencePage" name="AdminPreference Page"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <element ref="page"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="page">
+ <annotation>
+ <appInfo>
+ <meta.element labelAttribute="name"/>
+ </appInfo>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ a unique name that will be used to identify this page.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ a translatable name that will be used in the UI for this page.
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ a name of the fully qualified class that implements
+<samp>eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.IE4AdminPreferencePage</samp>.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.IE4AdminPreferencePage"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="category" type="string">
+ <annotation>
+ <documentation>
+ a path indicating the location of the page in the preference tree. The path may either be a parent node ID or a sequence
+ of IDs separated by '/', representing the full path from the root node.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier" basedOn="eu.etaxonomy.taxeditor.store.adminPreferencePage/page/@id"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
--- /dev/null
+/**
+* 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.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+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.io.specimen.abcd206.in.Abcd206ImportConfigurator;
+import eu.etaxonomy.cdm.model.metadata.CdmPreference;
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
+import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author k.luther
+ * @since 23.03.2018
+ *
+ */
+public class AbcdImportPreference extends CdmPreferencePage implements IE4AdminPreferencePage, SelectionListener {
+
+ private Abcd206ImportConfigurator configurator;
+
+ private Combo nomenclaturalCodeSelectionCombo;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ final Composite composite = new Composite(parent, SWT.NULL);
+
+ GridLayout gridLayout = new GridLayout();
+ composite.setLayout(gridLayout);
+
+ configurator = PreferencesUtil.getAbcdImportConfigurationPreference(false);
+
+ Button checkBoxMediaSpecimen = new Button(composite, SWT.CHECK);
+ checkBoxMediaSpecimen.setSelection(configurator.isAddMediaAsMediaSpecimen());
+ checkBoxMediaSpecimen.setText("Import media as media specimen");
+ checkBoxMediaSpecimen
+ .setToolTipText("Any media attached to a ABCD unit will be imported as a sub derivative of the specimen created from this unit");
+ checkBoxMediaSpecimen.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setAddMediaAsMediaSpecimen(!configurator.isAddMediaAsMediaSpecimen());
+ }
+ });
+
+ Button checkBoxIgnoreExisting = new Button(composite, SWT.CHECK);
+ checkBoxIgnoreExisting.setSelection(configurator.isIgnoreImportOfExistingSpecimen());
+ checkBoxIgnoreExisting.setText("Do not import existing specimens");
+ checkBoxIgnoreExisting
+ .setToolTipText("Specimens that have previously been imported will be ignored in this import");
+ checkBoxIgnoreExisting.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setIgnoreImportOfExistingSpecimen(!configurator.isIgnoreImportOfExistingSpecimen());
+ }
+ });
+
+ Button checkBoxIgnoreAuthorship = new Button(composite, SWT.CHECK);
+ checkBoxIgnoreAuthorship.setSelection(configurator.isIgnoreAuthorship());
+ checkBoxIgnoreAuthorship.setText("Ignore Authorship for name matching");
+ checkBoxIgnoreAuthorship
+ .setToolTipText("Name matching with existing names will be done without "
+ + "the authorship part of the name");
+ checkBoxIgnoreAuthorship.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setIgnoreAuthorship(!configurator.isIgnoreAuthorship());
+ }
+ });
+
+ Button checkBoxMapUnitIdToCatalogNumber = new Button(composite, SWT.CHECK);
+ checkBoxMapUnitIdToCatalogNumber.setSelection(configurator.isMapUnitIdToCatalogNumber());
+ checkBoxMapUnitIdToCatalogNumber.setText("Map UnitID to catalog number");
+ checkBoxMapUnitIdToCatalogNumber
+ .setToolTipText("The UnitID of every ABCD unit will be mapped the catalog number "
+ + "of the specimen");
+ checkBoxMapUnitIdToCatalogNumber.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setMapUnitIdToCatalogNumber(!configurator.isMapUnitIdToCatalogNumber());
+ }
+ });
+//TODO: only one of the mappings can be checked!
+ Button checkBoxMapUnitIdToAccessionNumber = new Button(composite, SWT.CHECK);
+ checkBoxMapUnitIdToAccessionNumber.setSelection(configurator.isMapUnitIdToAccessionNumber());
+ checkBoxMapUnitIdToAccessionNumber.setText("Map UnitID to accession number");
+ checkBoxMapUnitIdToAccessionNumber
+ .setToolTipText("The UnitID of every ABCD unit will be mapped the accession number "
+ + "of the specimen");
+ checkBoxMapUnitIdToAccessionNumber.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setMapUnitIdToAccessionNumber(!configurator.isMapUnitIdToAccessionNumber());
+ }
+ });
+
+ Button checkBoxMapUnitIdToBarcode = new Button(composite, SWT.CHECK);
+ checkBoxMapUnitIdToBarcode.setSelection(configurator.isMapUnitIdToBarcode());
+ checkBoxMapUnitIdToBarcode.setText("Map UnitID to barcode");
+ checkBoxMapUnitIdToBarcode
+ .setToolTipText("The UnitID of every ABCD unit will be mapped the barcode "
+ + "of the specimen");
+ checkBoxMapUnitIdToBarcode.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setMapUnitIdToBarcode(!configurator.isMapUnitIdToBarcode());
+ }
+ });
+
+ Button checkBoxRemoveCountry = new Button(composite, SWT.CHECK);
+ checkBoxRemoveCountry.setSelection(configurator.isRemoveCountryFromLocalityText());
+ checkBoxRemoveCountry.setText("Remove country from locality text");
+ checkBoxRemoveCountry
+ .setToolTipText("If the locality text contains information about the "
+ + "country which is additionally stored in other ABCD "
+ + "elements then it is removed from the locality text");
+ checkBoxRemoveCountry.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setRemoveCountryFromLocalityText(!configurator.isRemoveCountryFromLocalityText());
+ }
+ });
+
+ Button checkBoxMoveToDefaultClassification = new Button(composite, SWT.CHECK);
+ checkBoxMoveToDefaultClassification.setSelection(configurator.isMoveNewTaxaToDefaultClassification());
+ checkBoxMoveToDefaultClassification.setText("Create new classification for new taxa");
+ checkBoxMoveToDefaultClassification
+ .setToolTipText("For taxa that do not exist in the data base "
+ + "a new classification will be created");
+ checkBoxMoveToDefaultClassification.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setMoveNewTaxaToDefaultClassification(!configurator.isMoveNewTaxaToDefaultClassification());
+ }
+ });
+
+ Button checkBoxImportSiblings = new Button(composite, SWT.CHECK);
+ checkBoxImportSiblings.setSelection(configurator.isGetSiblings());
+ checkBoxImportSiblings.setText("Import all children of cultures or tissue samples");
+ checkBoxImportSiblings
+ .setToolTipText("For a tissue sample or culture all children will be searched and imported");
+ checkBoxImportSiblings.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setGetSiblings(checkBoxImportSiblings.getSelection());
+ }
+ });
+
+ Button checkBoxAddIndividualsAssociations = new Button(composite, SWT.CHECK);
+ checkBoxAddIndividualsAssociations.setSelection(configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
+ checkBoxAddIndividualsAssociations.setText("Create an Individual Association for each Specimen");
+ checkBoxAddIndividualsAssociations
+ .setToolTipText("For each specimen associated to a taxon an indiviadual association to this taxon is created");
+ checkBoxAddIndividualsAssociations.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(!configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
+ }
+ });
+
+ Button checkBoxReuseDescriptiveGroups = new Button(composite, SWT.CHECK);
+ checkBoxReuseDescriptiveGroups.setSelection(configurator.isReuseExistingDescriptiveGroups());
+ checkBoxReuseDescriptiveGroups.setText("Reuse existing descriptive group");
+ checkBoxReuseDescriptiveGroups
+ .setToolTipText("Reuse one of the existing descriptive groups or create a new one for every import");
+ checkBoxReuseDescriptiveGroups.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups());
+ }
+ });
+
+ Button checkBoxReuseExistingTaxa = new Button(composite, SWT.CHECK);
+ checkBoxReuseExistingTaxa.setSelection(configurator.isReuseExistingTaxaWhenPossible());
+ checkBoxReuseExistingTaxa.setText("Reuse existing taxa when possible");
+ checkBoxReuseExistingTaxa
+ .setToolTipText("Reuse existing taxa when the name matches the identified name of the specimen");
+ checkBoxReuseExistingTaxa.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups());
+ }
+ });
+
+ GridData gridData = new GridData();
+ gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
+ gridData.horizontalIndent = 5;
+// classificationSelection.setLayoutData(gridData);
+
+ nomenclaturalCodeSelectionCombo = new Combo(composite, SWT.BORDER| SWT.READ_ONLY);
+ nomenclaturalCodeSelectionCombo.setLayoutData(gridData);
+ for(NomenclaturalCode code: NomenclaturalCode.values()){
+ nomenclaturalCodeSelectionCombo.add(code.getKey());
+ }
+
+
+
+ // TODO remember last selection
+ nomenclaturalCodeSelectionCombo.addSelectionListener(this);
+ return composite;
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ this.configurator.setNomenclaturalCode(NomenclaturalCode.getByKey(nomenclaturalCodeSelectionCombo.getText()));
+
+ }
+
+ @Override
+ public boolean performOk() {
+ if (configurator != null){
+ String configString = configurator.toString();
+
+ CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.AbcdImportConfig, configString);
+ pref.setAllowOverride(true);
+
+ ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
+ if (controller == null){
+ return false;
+ }
+ IPreferenceService service = controller.getPreferenceService();
+ service.set(pref);
+ }
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void createAbcdImportConfig() {
+ this.configurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS));
+ this.configurator.setAddMediaAsMediaSpecimen(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN));
+ this.configurator.setAllowReuseOtherClassifications(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS));
+ //this.abcdImportConfigurator.setClassificationUuid(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_CLASSIFICATION_UUID));
+ this.configurator.setDeduplicateClassifications(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS));
+ this.configurator.setDeduplicateReferences(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES));
+ // this.abcdImportConfigurator.setDefaultAuthor(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEFAULT_AUTHOR));
+ this.configurator.setGetSiblings(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS));
+ this.configurator.setIgnoreAuthorship(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP));
+ this.configurator.setIgnoreImportOfExistingSpecimen(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN));
+ this.configurator.setMapUnitIdToAccessionNumber(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER));
+ this.configurator.setMapUnitIdToBarcode(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE));
+ this.configurator.setMapUnitIdToCatalogNumber(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER));
+ this.configurator.setMoveNewTaxaToDefaultClassification(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION));
+ this.configurator.setReuseExistingDescriptiveGroups(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS));
+ this.configurator.setReuseExistingTaxaWhenPossible(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE));
+
+ }
+
+}
--- /dev/null
+/**
+ * Copyright (C) 2014 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.custom.CLabel;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.ui.element.CommandHandlerButton;
+
+/**
+ * @author a.oppermann
+ * @date 21.07.2014
+ *
+ */
+public class ChecklistEditorGeneralPreference extends CdmPreferencePage implements IE4AdminPreferencePage {
+
+ boolean isEditorActivated;
+ boolean isShowRank;
+ boolean isSortByVocabularyOrder;
+ boolean isShowSymbol;
+ boolean isShowIdInVocabulary;
+ Composite child ;
+
+ @Override
+ protected Control createContents(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+ isEditorActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
+ final Button activateCheckButton = new Button(composite, SWT.CHECK);
+ activateCheckButton.setText("Enable Distribution Editor");
+ activateCheckButton.setSelection(isEditorActivated);
+ activateCheckButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isEditorActivated = activateCheckButton.getSelection();
+
+ if(isEditorActivated){
+ child.setVisible(true);
+ child.setEnabled(true);
+ }else{
+ child.setVisible(false);
+ child.setEnabled(false);
+ }
+
+ }
+ });
+
+ child = new Composite(composite, SWT.NULL);
+ child.setLayout(new GridLayout());
+ child.setVisible(isEditorActivated);
+ final CLabel label = new CLabel(child, SWT.NULL);
+ label.setText("Please open the wizard below, in order to \n" + "choose the areas for the Distribution Editor");
+ final CommandHandlerButton button_openFeatureTree = new CommandHandlerButton(child, SWT.PUSH,
+ "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler");
+
+ button_openFeatureTree.setText("Open Distribution Selection Wizard");
+ final Button showIdInVocabulary = new Button(child, SWT.CHECK);
+ isShowIdInVocabulary = PreferencesUtil.isShowIdInVocabularyInChecklistEditor();
+ showIdInVocabulary.setText("Show Id in Vocabulary instead of full title of the areas");
+ showIdInVocabulary.setSelection(isShowIdInVocabulary);
+ showIdInVocabulary.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowIdInVocabulary = showIdInVocabulary.getSelection();
+
+ }
+ });
+
+ final Button showSymbol = new Button(child, SWT.CHECK);
+ isShowSymbol = PreferencesUtil.isShowSymbolInChecklistEditor();
+ showSymbol.setText("Show Symbol of the Status, if existing");
+ showSymbol.setSelection(isShowSymbol);
+ showSymbol.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowSymbol = showSymbol.getSelection();
+ }
+ });
+ PreferencesUtil.recursiveSetEnabled(button_openFeatureTree, CdmStore.isActive());
+ isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
+ final Button activateRankButton = new Button(child, SWT.CHECK);
+ activateRankButton.setText("Show Rank in Distribution Editor");
+ activateRankButton.setSelection(isShowRank);
+ activateRankButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowRank = activateRankButton.getSelection();
+ }
+ });
+ final Button sortNamedAreaByVocabularyOrder = new Button(child, SWT.CHECK);
+ isSortByVocabularyOrder = PreferencesUtil.isSortNamedAreaByOrderInVocabulary();
+ sortNamedAreaByVocabularyOrder.setText("Sort Areas by Order in Vocabulary");
+ sortNamedAreaByVocabularyOrder.setSelection(isSortByVocabularyOrder);
+ sortNamedAreaByVocabularyOrder.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isSortByVocabularyOrder = sortNamedAreaByVocabularyOrder.getSelection();
+ }
+ });
+
+ if(isEditorActivated){
+ child.setEnabled(true);
+ }else{
+ child.setEnabled(false);
+ }
+
+ return composite;
+ }
+
+ @Override
+ public boolean performOk() {
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, isEditorActivated);
+ PreferencesUtil.setSortNamedAreasByOrderInVocabulary(isSortByVocabularyOrder);
+ PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
+ PreferencesUtil.setShowSymbolInChecklistEditor(isShowSymbol);
+ PreferencesUtil.setShowIdInVocabularyInChecklistEditor(isShowIdInVocabulary);
+ return true;
+ }
+
+}
--- /dev/null
+/**
+* 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;
+
+/**
+ * @author k.luther
+ * @since 22.03.2018
+ *
+ */
+public interface IE4AdminPreferencePage {
+
+}
--- /dev/null
+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.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+
+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.PreferencePredicate;
+import eu.etaxonomy.taxeditor.l10n.Messages;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
+import eu.etaxonomy.taxeditor.preference.NameDetailsConfigurator;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+
+public class NameDetailsViewConfiguration extends CdmPreferencePage implements IE4AdminPreferencePage{
+
+ boolean isSimpleDetailsViewActivated;
+
+ Composite dbSettings ;
+ boolean isAllowOverride;
+ boolean isShowTaxon;
+ boolean isShowLSID;
+ boolean isShowNomenclaturalCode;
+ boolean isShowNameCache;
+ boolean isShowAppendedPhrase;
+ boolean isShowRank;
+ boolean isShowEpithets;
+ boolean isShowAuthorCache;
+ boolean isShowAuthorship;
+ boolean isShowNomenclaturalRef;
+ boolean isShowNomenclaturalStatus;
+ boolean isShowProtologue;
+ boolean isShowTypeDesignation;
+ boolean isShowNameRelationship;
+ boolean isShowHybrid;
+ boolean isShowNameApprobiation;
+
+
+ @Override
+ protected Control createContents(Composite parent) {
+
+ CdmPreference nameDetailsPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.NameDetailsView);
+ isAllowOverride = false;
+ if (nameDetailsPref != null){
+ //TODO: create checkbox
+
+ isAllowOverride = nameDetailsPref.isAllowOverride();
+ }
+
+
+
+ isSimpleDetailsViewActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION);
+
+ final Button activateCheckButton = new Button(parent, SWT.CHECK);
+ activateCheckButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
+ activateCheckButton.setText(Messages.NameDetailsViewConfiguration_activateSimpleDetailsView);
+ activateCheckButton.setSelection(isSimpleDetailsViewActivated);
+ activateCheckButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isSimpleDetailsViewActivated = activateCheckButton.getSelection();
+ //
+ if(isSimpleDetailsViewActivated){
+ dbSettings.setVisible(true);
+ dbSettings.setEnabled(true);
+ }else{
+ dbSettings.setVisible(false);
+ dbSettings.setEnabled(false);
+ }
+ }
+ });
+
+
+
+ dbSettings = new Composite(parent, SWT.NONE);
+ dbSettings.setLayout(new GridLayout());
+ dbSettings.setVisible(isSimpleDetailsViewActivated);
+// Table table = new Table(dbSettings,SWT.BORDER | SWT.CHECK);
+// TableColumn tableColumnValue = new TableColumn(table, SWT.CENTER);
+//
+// TableColumn tableColumnAllowOverride = new TableColumn(table, SWT.CENTER);
+
+
+
+ final Button allowLocalPreference = new Button(dbSettings, SWT.CHECK);
+// boolean isUseLocalPreference = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NAME_DETAILS);
+ allowLocalPreference.setText(Messages.DatabasePreferencesPage_UseLocalPreferences);
+ allowLocalPreference.setSelection(isAllowOverride);
+ allowLocalPreference.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isAllowOverride = allowLocalPreference.getSelection();
+
+ }
+ });
+ Label separator= new Label(dbSettings, SWT.HORIZONTAL | SWT.SEPARATOR);
+ separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ final Button showTaxon = new Button(dbSettings, SWT.CHECK);
+ isShowTaxon = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON);
+ showTaxon.setText(Messages.NameDetailsViewComposite_Show_Taxon);
+ showTaxon.setSelection(isShowTaxon);
+ showTaxon.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowTaxon = showTaxon.getSelection();
+
+ }
+ });
+
+ final Button showLsid = new Button(dbSettings, SWT.CHECK);
+ isShowLSID = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID);
+ showLsid.setText(Messages.NameDetailsViewComposite_Show_LSID);
+ showLsid.setSelection(isShowLSID);
+ showLsid.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowLSID = showLsid.getSelection();
+
+ }
+ });
+
+ final Button showNomenclaturalCode = new Button(dbSettings, SWT.CHECK);
+ isShowNomenclaturalCode = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE);
+ showNomenclaturalCode.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalCode);
+ showNomenclaturalCode.setSelection(isShowNomenclaturalCode);
+ showNomenclaturalCode.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowNomenclaturalCode = showNomenclaturalCode.getSelection();
+
+ }
+ });
+
+ final Button showNameCache = new Button(dbSettings, SWT.CHECK);
+ isShowNameCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE);
+ showNameCache.setText(Messages.NameDetailsViewComposite_Show_NameCache);
+ showNameCache.setSelection(isShowNameCache);
+ showNameCache.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowNameCache = showNameCache.getSelection();
+
+ }
+ });
+ final Button showAppendedPhrase = new Button(dbSettings, SWT.CHECK);
+ isShowAppendedPhrase= PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE);
+ showAppendedPhrase.setText(Messages.NameDetailsViewComposite_Show_AppendedPhrase);
+ showAppendedPhrase.setSelection(isShowAppendedPhrase);
+ showAppendedPhrase.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowAppendedPhrase = showAppendedPhrase.getSelection();
+
+ }
+ });
+
+ final Button showRank = new Button(dbSettings, SWT.CHECK);
+ isShowRank = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK);
+ showRank.setText(Messages.NameDetailsViewComposite_Show_Rank);
+ showRank.setSelection(isShowRank);
+ showRank.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowRank = showRank.getSelection();
+
+ }
+ });
+ final Button showEpithets = new Button(dbSettings, SWT.CHECK);
+ isShowEpithets = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS);
+ showEpithets.setText(Messages.NameDetailsViewComposite_Show_AtomisedEpithets);
+ showEpithets.setSelection(isShowEpithets);
+ showEpithets.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowEpithets = showEpithets.getSelection();
+
+ }
+ });
+
+ final Button showAuthorCache = new Button(dbSettings, SWT.CHECK);
+ isShowAuthorCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE);
+ showAuthorCache.setText(Messages.NameDetailsViewComposite_Show_AuthorCache);
+ showAuthorCache.setSelection(isShowAuthorCache);
+ showAuthorCache.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowAuthorCache = showAuthorCache.getSelection();
+
+ }
+ });
+
+ final Button showAuthorship = new Button(dbSettings, SWT.CHECK);
+ isShowAuthorship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP);
+ showAuthorship.setText(Messages.NameDetailsViewComposite_Show_Author);
+ showAuthorship.setSelection(isShowAuthorship);
+ showAuthorship.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowAuthorship = showAuthorship.getSelection();
+
+ }
+ });
+
+ final Button showNomenclaturalRef = new Button(dbSettings, SWT.CHECK);
+ isShowNomenclaturalRef = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE);
+ showNomenclaturalRef.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalReference);
+ showNomenclaturalRef.setSelection(isShowNomenclaturalRef);
+ showNomenclaturalRef.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowNomenclaturalRef = showNomenclaturalRef.getSelection();
+
+ }
+ });
+
+ final Button showNomenclaturalStatus = new Button(dbSettings, SWT.CHECK);
+ isShowNomenclaturalStatus = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS);
+ showNomenclaturalStatus.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalStatus);
+ showNomenclaturalStatus.setSelection(isShowNomenclaturalStatus);
+ showNomenclaturalStatus.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowNomenclaturalStatus = showNomenclaturalStatus.getSelection();
+
+ }
+ });
+
+ final Button showProtologue = new Button(dbSettings, SWT.CHECK);
+ isShowProtologue = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE);
+ showProtologue.setText(Messages.NameDetailsViewComposite_Show_Protologue);
+ showProtologue.setSelection(isShowProtologue);
+ showProtologue.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowProtologue = showProtologue.getSelection();
+
+ }
+ });
+
+ final Button showTypeDesignation = new Button(dbSettings, SWT.CHECK);
+ isShowTypeDesignation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION);
+ showTypeDesignation.setText(Messages.NameDetailsViewComposite_Show_TypeDesignation);
+ showTypeDesignation.setSelection(isShowTypeDesignation);
+ showTypeDesignation.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowTypeDesignation = showTypeDesignation.getSelection();
+
+ }
+ });
+
+
+ final Button showNameRelationship = new Button(dbSettings, SWT.CHECK);
+ isShowNameRelationship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP);
+ showNameRelationship.setText(Messages.NameDetailsViewComposite_Show_Namerelationships);
+ showNameRelationship.setSelection(isShowNameRelationship);
+ showNameRelationship.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowNameRelationship = showNameRelationship.getSelection();
+
+ }
+ });
+
+ final Button showHybrid = new Button(dbSettings, SWT.CHECK);
+ isShowHybrid = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID);
+ showHybrid.setText(Messages.NameDetailsViewComposite_Show_Hybrid);
+ showHybrid.setSelection(isShowHybrid);
+ showHybrid.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowHybrid = showHybrid.getSelection();
+
+ }
+ });
+ final Button showNameApprobiation = new Button(dbSettings, SWT.CHECK);
+ isShowNameApprobiation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION);
+ showNameApprobiation.setText(Messages.NameDetailsViewComposite_Show_NameApprobiation);
+ showNameApprobiation.setSelection(isShowNameApprobiation);
+ showNameApprobiation.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ isShowNameApprobiation = showNameApprobiation.getSelection();
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION, isShowNameApprobiation);
+ }
+ });
+
+
+
+
+ return dbSettings;
+ }
+
+ /**
+ *
+ */
+ protected NameDetailsConfigurator createNameDetailsViewConfig() {
+ NameDetailsConfigurator config = new NameDetailsConfigurator(isSimpleDetailsViewActivated);
+
+ config.setAppendedPhraseActivated(isShowAppendedPhrase);
+ config.setAtomisedEpithetsActivated(isShowEpithets);
+ config.setAuthorshipSectionActivated(isShowAuthorship);
+ config.setAuthorCacheActivated(isShowAuthorCache);
+ config.setLSIDActivated(isShowLSID);
+ config.setNameApprobiationActivated(isShowNameApprobiation);
+ config.setNameCacheActivated(isShowNameCache);
+ config.setNameRelationsSectionActivated(isShowNameRelationship);
+ config.setNomenclaturalCodeActived(isShowNomenclaturalCode);
+ config.setNomenclaturalStatusSectionActivated(isShowNomenclaturalStatus);
+ config.setNomenclaturalReferenceSectionActivated(isShowNomenclaturalRef);
+ config.setProtologueActivated(isShowProtologue);
+ config.setRankActivated(isShowRank);
+ config.setTaxonSectionActivated(isShowTaxon);
+ config.setTypeDesignationSectionActivated(isShowTypeDesignation);
+ config.setHybridActivated(isShowHybrid);
+
+
+ return config;
+ }
+
+
+ @Override
+ public boolean performOk() {
+ ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
+ if (controller == null){
+ return false;
+ }
+ IPreferenceService service = controller.getPreferenceService();
+ NameDetailsConfigurator config = createNameDetailsViewConfig();
+ String value = config.toString();
+// boolean allowOverride = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NAME_DETAILS);
+
+ CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.NameDetailsView, value);
+ pref.setAllowOverride(isAllowOverride);
+ service.set(pref);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, isShowTaxon);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, isShowLSID);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, isShowNomenclaturalCode);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE, isShowNameCache);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE, isShowAppendedPhrase);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, isShowRank);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, isShowEpithets);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, isShowAuthorship);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE, isShowAuthorCache);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, isShowNomenclaturalRef);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, isShowNomenclaturalStatus);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, isShowProtologue);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, isShowTypeDesignation);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, isShowNameRelationship);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID, isShowHybrid);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ALLOW_OVERRIDE_NAME_DETAILS, isAllowOverride);
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION, isSimpleDetailsViewActivated);
+ return true;
+ }
+
+}
--- /dev/null
+/**
+ * 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.databaseAdmin.preferencePage;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+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.cdm.model.name.NomenclaturalCode;
+import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * <p>
+ * NomenclaturalCodePreferences class.
+ * </p>
+ *
+ * @author k.luther
+ * @created 14.09.2018
+ */
+public class NomenclaturalCodePreferences extends CdmPreferencePage implements IE4AdminPreferencePage{
+
+ String actualCode;
+ Map<String, String> labelAndValues;
+ Map<String, Integer> keyAndIndex;
+ Combo nomenclaturalCode;
+
+
+ @Override
+ protected Control createContents(Composite parent) {
+// PreferencesUtil.setPreferredNomenclaturalCode(null, false);
+
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+
+ nomenclaturalCode= new Combo(composite, SWT.READ_ONLY);
+ nomenclaturalCode.setText("Available Codes");
+
+
+
+ nomenclaturalCode.setFont(parent.getFont());
+ getLabelAndValues();
+ keyAndIndex = new HashMap<>();
+ Integer index = 0;
+ for (String key: labelAndValues.keySet()) {
+ nomenclaturalCode.add(labelAndValues.get(key));
+ keyAndIndex.put(key, index);
+ index++;
+ }
+ index = keyAndIndex.get(actualCode);
+ nomenclaturalCode.select(index);
+
+ nomenclaturalCode.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent evt) {
+ String name = nomenclaturalCode.getText();
+ for (Entry<String, String> label:labelAndValues.entrySet()){
+ if (label.getValue().equals(name)){
+ actualCode = label.getKey();
+ }
+ }
+// actualCode = labelAndValues.get(name);;
+
+
+ }
+ });
+
+ return composite;
+
+ }
+
+ /**
+ * @return
+ */
+ private Map<String, String> getLabelAndValues() {
+ List<NomenclaturalCode> supportedCodes = NomenclaturalCodeHelper
+ .getSupportedCodes();
+ labelAndValues = new HashMap<>();
+ for (int i = 0; i < supportedCodes.size(); i++) {
+ labelAndValues.put(PreferencesUtil.getPreferenceKey(supportedCodes.get(i)), NomenclaturalCodeHelper
+ .getDescription(supportedCodes.get(i))) ;
+
+ }
+ return labelAndValues;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * Initialize the preference page
+ */
+ @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.NomenclaturalCode);
+ CdmPreference pref = service.find(key);
+ if (pref != null){
+ actualCode = pref.getValue();
+
+ }
+ }
+
+
+ }
+
+ @Override
+ public boolean performOk() {
+
+ boolean result = super.performOk();
+ if (labelAndValues != null){
+ String key = labelAndValues.get(actualCode);
+ NomenclaturalCode preferredCode = NomenclaturalCode.getByKey(actualCode);
+ PreferencesUtil.setPreferredNomenclaturalCode(actualCode, false);
+ }
+ return result;
+ }
+
+}
public boolean close() {
// Save preferred nomenclatural code before closing
- PreferencesUtil.setPreferredNomenclaturalCode(preferredCode, true);
+ PreferencesUtil.setPreferredNomenclaturalCode(PreferencesUtil.getPreferenceKey(preferredCode), true);
return super.close();
}
* object.
*/
public static CdmPreference setPreferredNomenclaturalCode(
- NomenclaturalCode preferredCode, boolean local) {
+ String preferenceKey, boolean local) {
if (local){
getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
- getPreferenceKey(preferredCode));
+ preferenceKey);
}
else{
ICdmRepository controller;
if (controller == null){
return null;
}
- if (preferredCode == null){
+ if (preferenceKey == null){
preference = controller.getPreferenceService().find(key);
if (preference == null){
return null;
} else{
- int index = StringUtils.lastIndexOf(preference.getValue(), ".");
- UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
- preferredCode = NomenclaturalCode.getByUuid(uuid);
+// int index = StringUtils.lastIndexOf(preference.getValue(), ".");
+// UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
+// preferredCode = NomenclaturalCode.getByUuid(uuid);
getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
- getPreferenceKey(preferredCode));
+ preferenceKey);
getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY,preference.isAllowOverride());
return preference;
}
} else{
- preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferredCode.getKey());
+ preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferenceKey);
controller.getPreferenceService().set(preference);
}
"name", "name.$", "relationsFromThisTaxon.$"));
configurator.setSynonymPropertyPath(Arrays.asList("$", "titleCache",
- "name", "name.$", "synonymRelations.relatedTo.*"));
+ "name", "name.$", "synonyms.relatedTo.*"));
// DEFAULT VALUES
// match mode is a simple like, actually all other match modes are kind
if (PreferencesUtil.getPreferredNomenclaturalCode(true) == null) {
- PreferencesUtil.setPreferredNomenclaturalCode(NomenclaturalCode.ICNAFP, true);
+ PreferencesUtil.setPreferredNomenclaturalCode(getPreferenceKey(NomenclaturalCode.ICNAFP), true);
}
config.setMapUnitIdToBarcode(Boolean.valueOf(valueString));
}else if (keyString.equals("overwriteExistingSpecimens")){
config.setOverwriteExistingSpecimens(Boolean.valueOf(valueString));
+ }else if (keyString.equals(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE)){
+ config.setNomenclaturalCode(NomenclaturalCode.fromString(valueString));
}else{
logger.debug("This key of the abcd configurator needs to be added to the transformer: " + keyString);
}
import eu.etaxonomy.cdm.api.service.ITaxonService;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.name.TaxonName;
-import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
// load taxon Crepis from cichorieae
UUID taxonBaseUuid = UUID.fromString("d0ae2121-1c32-4737-8c49-f871d429fd90");
List<String> taxonBasePropertyPaths = Arrays.asList(new String[] {
- "synonymRelations.synonym.name.status.type",
- "name.homotypicalGroup.typifiedNames.taxonBases.synonymRelations.relatedFrom.name.status"
+ "synonym.synonym.name.status.type",
+ "name.homotypicalGroup.typifiedNames.taxonBases.synonyms.relatedFrom.name.status"
});
TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).load(taxonBaseUuid, taxonBasePropertyPaths);
Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class);
<elements xsi:type="commands:Handler" xmi:id="_WLNcQSQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.OpenExternalAboutPlatformHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.OpenExternalAboutPlatformHandler" command="_UZ2zYCQsEeeq76l4saMAFQ"/>
<elements xsi:type="commands:Handler" xmi:id="_WLNcQiQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.OpenExternalParserHelpHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.OpenExternalParserHelpHandler" command="_UZ_WQCQsEeeq76l4saMAFQ"/>
<elements xsi:type="commands:Handler" xmi:id="_WLNcQyQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.handler.OpenDatabaseRepairWizardHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.handler.OpenDatabaseRepairWizardHandler" command="_Va29YCQsEeeq76l4saMAFQ"/>
- <elements xsi:type="commands:Handler" xmi:id="_WLNcRCQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.handler.OpenDatabasePreferencesWizardHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.handler.OpenDatabasePreferencesWizardHandler" command="_VawPsCQsEeeq76l4saMAFQ"/>
+ <elements xsi:type="commands:Handler" xmi:id="_WLNcRCQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.handler.OpenAdminPreferencesHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.handler.OpenAdminPreferencesHandler" command="_VawPsCQsEeeq76l4saMAFQ"/>
<elements xsi:type="commands:Handler" xmi:id="_S6Rf4CRAEeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.update.InstallNewSoftwareHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.update.InstallNewSoftwareHandler" command="_koenACRAEeeKsvEah5BAoQ"/>
<elements xsi:type="commands:Handler" xmi:id="_nSIiECUKEeeHw5lTgGMs1Q" elementId="eu.etaxonomy.taxeditor.handler.OpenImportPreferenceHandler" command="_fdEqUCUKEeeHw5lTgGMs1Q"/>
<elements xsi:type="commands:Handler" xmi:id="_2fnUYCZ0EeeQLpuomSmVoQ" elementId="eu.etaxonomy.taxeditor.workbench.OpenPartHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.OpenPartHandler" command="_hMjgECZsEeer_rabtodzWA"/>
<plugin>
<extension-point id="e4PreferencePages" name="e4PreferencePages" schema="schema/e4PreferencePages.exsd"/>
<extension-point id="e4PreferenceStoreProvider" name="e4PreferenceStoreProvider" schema="schema/e4PreferenceStoreProvider.exsd"/>
+ <extension-point id="adminPreferencePage" name="adminPreferencePage" schema="schema/adminPreferencePage.exsd"/>
<extension
id="eu.etaxonomy.taxeditor.workbench.workbench.model"
name="Taxonomic Editor Application Model"
--- /dev/null
+// $Id$
+/**
+* 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.workbench.handler;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Named;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.preference.IPreferencePage;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.preference.PreferenceManager;
+import org.eclipse.jface.preference.PreferenceNode;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Scans all extension for extension point <code>eu.etaxonomy.taxeditor.store.preferencePage</code> and
+ * creates the tree of preference nodes according to the <code>category</code> attribute of the
+ * extension point.<br>
+ * <b>Note:</b> If, for a given category, no parent node can be found then this page will not be
+ * added to the preferences
+ * @author pplitzner/k.luther
+ * @date 14.03.2018
+ *
+ */
+public class OpenAdminPreferencesHandler {
+
+ private static final String ATT_NAME = "name"; //$NON-NLS-1$
+ private static final String ATT_ID = "id"; //$NON-NLS-1$
+ private static final String ATT_CATEGORY = "category"; //$NON-NLS-1$
+ private static final String ATT_CLASS = "class"; //$NON-NLS-1$
+ private static final String EXTENSION_ELEMENT_PAGE = "page"; //$NON-NLS-1$
+ private static final String EXTENSION_POINT_ID = "eu.etaxonomy.taxeditor.store.adminPreferencePage"; //$NON-NLS-1$
+ private Logger logger = Logger.getLogger(OpenAdminPreferencesHandler.class);
+
+ @Execute
+ public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
+ List<PageWrapper> pagesYetToBeAdded = new ArrayList<>();
+ List<PageWrapper> rootPages = new ArrayList<>();
+ Map<String, PreferenceNode> idToNodeMap = new HashMap<>();
+
+ PreferenceManager manager = new PreferenceManager('/');
+
+ IExtensionRegistry reg = Platform.getExtensionRegistry();
+ IConfigurationElement[] extensions = reg
+ .getConfigurationElementsFor(EXTENSION_POINT_ID); //$NON-NLS-1$
+ for (IConfigurationElement configElement : extensions) {
+ if(configElement.getName().equals(EXTENSION_ELEMENT_PAGE)){ //$NON-NLS-1$
+ Object o;
+ try {
+ o = configElement.createExecutableExtension(ATT_CLASS);
+ if(o instanceof IPreferencePage){
+ IPreferencePage page = (IPreferencePage) o;
+ String category = configElement.getAttribute(ATT_CATEGORY);
+ String id = configElement.getAttribute(ATT_ID);
+ String name = configElement.getAttribute(ATT_NAME);
+
+ page.setTitle(name);
+ //add all root nodes
+ if(category==null){
+ rootPages.add(new PageWrapper(page, category, id, name));
+ }
+ //child nodes will be handled later
+ else{
+ pagesYetToBeAdded.add(new PageWrapper(page, category, id, name));
+ }
+ }
+ } catch (CoreException e) {
+ logger.error(String.format("Failed to initialize preference page for config element: %s", configElement), e); //$NON-NLS-1$
+ }
+ }
+ }
+
+ //sort root nodes
+ Collections.sort(rootPages, new PreferenceNodeComparator());
+ //add root nodes
+ rootPages.forEach(pageWrapper->{
+ PreferenceNode node = new PreferenceNode(pageWrapper.id, pageWrapper.page);
+ manager.addToRoot(node);
+ idToNodeMap.put(pageWrapper.id, node);
+ });
+
+ //sort child nodes
+ Collections.sort(pagesYetToBeAdded, new PreferenceNodeComparator());
+ //add child nodes
+ int size = pagesYetToBeAdded.size();
+ while(!pagesYetToBeAdded.isEmpty()){
+
+ Iterator<PageWrapper> iterator = pagesYetToBeAdded.iterator();
+ while(iterator.hasNext()){
+ PageWrapper pageWrapper = iterator.next();
+ if(addPage(pageWrapper, idToNodeMap)){
+ iterator.remove();
+ }
+ }
+ if(size==pagesYetToBeAdded.size()){
+ //avoid potential endless loop
+ break;
+ }
+ size = pagesYetToBeAdded.size();
+ }
+ PreferenceDialog dialog = new PreferenceDialog(shell, manager);
+ dialog.create();
+ dialog.getTreeViewer().expandAll();
+ dialog.open();
+ }
+
+ @CanExecute
+ public boolean canExecute()
+ {
+ return true;
+ }
+
+
+ private boolean addPage(PageWrapper pageWrapper, Map<String, PreferenceNode> idToNodeMap){
+ PreferenceNode node = new PreferenceNode(pageWrapper.id, pageWrapper.page);
+ PreferenceNode parent = idToNodeMap.get(pageWrapper.category);
+ if(parent!=null){
+ idToNodeMap.put(pageWrapper.id, node);
+ parent.add(node);
+ return true;
+ }
+ return false;
+ }
+
+ private class PreferenceNodeComparator implements Comparator<PageWrapper>{
+ @Override
+ public int compare(PageWrapper o1, PageWrapper o2) {
+ return o1.name.compareTo(o2.name);
+ }
+ }
+
+ private class PageWrapper{
+ IPreferencePage page;
+ String category;
+ String id;
+ String name;
+ public PageWrapper(IPreferencePage page, String category, String id, String name) {
+ super();
+ this.page = page;
+ this.category = category;
+ this.id = id;
+ this.name = name;
+ }
+ }
+}
+
+