+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;
+ }
+
+}