page.name.100 = Distribution\r
page.name.101 = Term Editor\r
page.name.102 = Name Details View\r
+page.name.103 = Name Features\r
view.name = Datasource\r
view.name.0 = Progress\r
view.name.1 = Message\r
handledmenuitem.label.19 = Update Sortindices\r
\r
command.commandname.19 = Open Area Wizard\r
+\r
+page.name.59 = Name Features\r
+page.name.60 = Name Features\r
+page.name.61 = Name Details View
\ No newline at end of file
#Properties file for eu.etaxonomy.taxeditor.store, German
page.name = Lokale Pr\u00e4ferenzen
page.name.0 = Faktendaten
-page.name.1 = Merkmale
+page.name.1 = Taxon Merkmale
page.name.2 = Verbreitungsstatus
page.name.3 = Taxonomisch
page.name.4 = Nomenklatur-Code
page.name.100 = Verbreitungs-Daten
page.name.101 = Term Editor
page.name.102 = Name Details View
+page.name.103 = Namensmerkmale
view.name = Datenquelle
view.name.0 = Fortschritt
view.name.1 = Nachrichten
handledmenuitem.label.16 = Term Suche
handledmenuitem.label.17 = Occurrence Suche
handledmenuitem.label.18 = Update Caches
-handledmenuitem.label.19 = Update Sortindices
\ No newline at end of file
+handledmenuitem.label.19 = Update Sortindices
+
+page.name.59 = Namensmerkmale
+page.name.60 = Namensmerkmale
+page.name.61 = Name Details View
\ No newline at end of file
class="eu.etaxonomy.taxeditor.preference.menu.FeatureMenuPreferences"
id="eu.etaxonomy.taxeditor.preferences.feature"
name="%page.name.1">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.description"
+ class="eu.etaxonomy.taxeditor.preference.menu.NameFeatureMenuPreferences"
+ id="eu.etaxonomy.taxeditor.preferences.nameFeature"
+ name="%page.name.59">
</page>
<page
category="eu.etaxonomy.taxeditor.preferences.description"
id="eu.etaxonomy.taxeditor.preferences.commonnamelanguages"
name="%page.name.58">
</page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.description"
+ class="eu.etaxonomy.taxeditor.preference.menu.NameFeatureMenuPreference"
+ id="eu.etaxonomy.taxeditor.preferences.feature2"
+ name="%page.name.60">
+ </page>
</extension>
category="eu.etaxonomy.taxeditor.preferences.general"
class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.NameDetailsViewAdminConfiguration"
id="eu.etaxonomy.taxeditor.store.scientificNameDetails"
- name="Name Details View">
+ name="%page.name.61">
</page>
</extension>
</plugin>
import eu.etaxonomy.cdm.api.service.IPreferenceService;
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
-import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum;
-import eu.etaxonomy.cdm.model.metadata.TermOrder;
+import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
+import eu.etaxonomy.taxeditor.l10n.Messages;
import eu.etaxonomy.taxeditor.preference.ChecklistEditorGeneralPreference;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.store.CdmStore;
@Override
public boolean performOk() {
- if (distributionEditorPref == null){
+ if (!isApply()){
return true;
}
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
return false;
}
IPreferenceService service = controller.getPreferenceService();
+ CdmPreference pref;
+ if (isEditorActivated == null){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DistributionEditorActivated));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DistributionEditorActivated, Boolean.toString(isEditorActivated));
+ pref.setAllowOverride(allowOverrideActivatedButton.getSelection());
+ service.set(pref);
+ }
+ if(displayArea.equals(Messages.Preference_Use_Default)){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DisplayOfAreasInDistributionEditor));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DisplayOfAreasInDistributionEditor, this.displayArea);
+ pref.setAllowOverride(allowOverrideAreaDisplayButton.getSelection());
+ service.set(pref);
+ }
- CdmPreference pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DistributionEditorActivated, Boolean.toString(isEditorActivated));
- pref.setAllowOverride(this.distributionEditorPref.isAllowOverride());
- service.set(pref);
-
- pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DisplayOfAreasInDistributionEditor, this.displayArea);
- pref.setAllowOverride(prefAreaDisplay.isAllowOverride());
- service.set(pref);
-
- pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DisplayOfStatus, this.displayStatus);
- pref.setAllowOverride(prefStatusDisplay.isAllowOverride());
- service.set(pref);
-
- pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.ShowRankInDistributionEditor, Boolean.toString(isShowRank));
- pref.setAllowOverride(prefRank.isAllowOverride());
- service.set(pref);
-
- pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.AreasSortedInDistributionEditor, this.orderAreas);
- pref.setAllowOverride(prefAreaSort.isAllowOverride());
- service.set(pref);
+ if (displayStatus.equals(Messages.Preference_Use_Default)){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DisplayOfStatus));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DisplayOfStatus, this.displayStatus);
+ pref.setAllowOverride(allowOverrideStatusDisplayButton.getSelection());
+ service.set(pref);
+ }
- pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.OwnDescriptionForDistributionEditor, Boolean.toString(ownDescriptionForDistributionEditor));
- pref.setAllowOverride(prefOwnDescription.isAllowOverride());
- service.set(pref);
+ if (isShowRank == null){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowRankInDistributionEditor));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.ShowRankInDistributionEditor, Boolean.toString(isShowRank));
+ pref.setAllowOverride(allowOverrideRankButton.getSelection());
+ service.set(pref);
+ }
+ if (orderAreas.equals(Messages.Preference_Use_Default)){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AreasSortedInDistributionEditor));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.AreasSortedInDistributionEditor, this.orderAreas);
+ pref.setAllowOverride(allowOverrideOrderAreasButton.getSelection());
+ service.set(pref);
+ }
+ if (ownDescriptionForDistributionEditor == null){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.OwnDescriptionForDistributionEditor));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.OwnDescriptionForDistributionEditor, Boolean.toString(ownDescriptionForDistributionEditor));
+ pref.setAllowOverride(prefOwnDescription.isAllowOverride());
+ service.set(pref);
+ }
// if (statusPref != null){
// service.set(statusPref);
// }
@Override
public void getValues() {
super.getValues();
- distributionEditorPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
- if (distributionEditorPref == null){
- distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString());
+ //distributionEditorPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
+ if (distributionEditorPref != null){
+ isEditorActivated = Boolean.valueOf(distributionEditorPref.getValue());
}
- isEditorActivated = Boolean.valueOf(distributionEditorPref.getValue());
-// allowOverrideActivated = distributionEditorPref.isAllowOverride();
+
+
isAdminPreference = true;
if (prefAreaDisplay != null){
this.displayArea = prefAreaDisplay.getValue();
}else{
- this.displayArea = ((TermDisplayEnum)PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue()).getKey();
+ this.displayArea = Messages.Preference_Use_Default;
}
if (prefStatusDisplay != null){
this.displayStatus = prefStatusDisplay.getValue();
}else{
- this.displayStatus = ((TermDisplayEnum)PreferencePredicate.DisplayOfStatus.getDefaultValue()).getKey();
+ this.displayStatus = Messages.Preference_Use_Default;
}
if (prefAreaSort != null){
if (prefAreaSort.getValue() != null){
this.orderAreas = prefAreaSort.getValue().toString();
}else{
- this.orderAreas = ((TermOrder)PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue()).getKey();
+ this.orderAreas = Messages.Preference_Use_Default;
}
}else{
- this.orderAreas = ((TermOrder)PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue()).getKey();
+ this.orderAreas = Messages.Preference_Use_Default;
}
this.isShowRank = Boolean.valueOf(prefRank.getValue().toString());
}else{
- this.isShowRank = Boolean.valueOf(PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString());
+ this.isShowRank = null;
}
@Override
public boolean performOk() {
-
+ if (!isApply()){
+ return true;
+ }
if (controller != null){
IPreferenceService service = controller.getPreferenceService();
@Override
public boolean performOk() {
+ if (!isApply()){
+ return true;
+ }
if (nameDetailsConfig == null){
return true;
}
@Override
public boolean performOk() {
- if (actualCode != null){
- CdmPreference pref = CdmPreference.NewDatabaseInstance(PreferencePredicate.NomenclaturalCode, actualCode.toString());
- pref.setAllowOverride(allowOverride);
- PreferencesUtil.setPreferredNomenclaturalCode(pref);
- }
+ if (!isApply()){
+ return true;
+ }
+ CdmPreference pref = CdmPreference.NewDatabaseInstance(PreferencePredicate.NomenclaturalCode, actualCode.toString());
+ pref.setAllowOverride(allowOverride);
+ PreferencesUtil.setPreferredNomenclaturalCode(pref);
+
return true;
}
@Override
public boolean performOk() {
- if (pref == null){
+ if (!isApply()){
return true;
}
String text = publishFlagBehaviour.getText();
this.isShowSpecimenRelatedIssues = Boolean.valueOf(showSpecimenPref.getValue());
this.allowOverrideShowSpecimenRelatedIssues = showSpecimenPref.isAllowOverride();
}else{
- showSpecimenPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, Boolean.toString(true));
- this.isShowSpecimenRelatedIssues = true;
+ //showSpecimenPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, Boolean.toString(true));
+// this.isShowSpecimenRelatedIssues = true;
this.allowOverrideShowSpecimenRelatedIssues = true;
}
this.isShowCollectingAreaInGeneralSection = Boolean.valueOf(isShowCollectingAreaInGeneralSectionPref.getValue());
this.allowOverrideShowCollectingAreaInGeneralSection = isShowCollectingAreaInGeneralSectionPref.isAllowOverride();
}else{
- this.isShowCollectingAreaInGeneralSection = (Boolean) PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue();
+// this.isShowCollectingAreaInGeneralSection = (Boolean) PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue();
this.allowOverrideShowCollectingAreaInGeneralSection = true;
}
this.isDeterminationOnlyForFieldUnits = Boolean.valueOf(isDeterminationOnlyForFieldUnitsPref.getValue());
this.allowOverrideDeterminationOnlyForFieldUnits = isDeterminationOnlyForFieldUnitsPref.isAllowOverride();
}else{
- this.isDeterminationOnlyForFieldUnits =(Boolean)PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue();
+// this.isDeterminationOnlyForFieldUnits =(Boolean)PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue();
this.allowOverrideDeterminationOnlyForFieldUnits = true;
}
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonAssociations);
this.isShowTaxonAssociation = Boolean.valueOf(isShowTaxonAssociationPref.getValue());
this.allowOverrideShowTaxonAssociation = isShowTaxonAssociationPref.isAllowOverride();
}else{
- this.isShowTaxonAssociation = (Boolean)PreferencePredicate.ShowTaxonAssociations.getDefaultValue();
+// this.isShowTaxonAssociation = (Boolean)PreferencePredicate.ShowTaxonAssociations.getDefaultValue();
this.allowOverrideShowTaxonAssociation = true;
}
this.isShowLifeForm = Boolean.valueOf(isShowLifeFormPref.getValue());
this.allowOverrideShowLifeForm = isShowLifeFormPref.isAllowOverride();
} else{
- this.isShowLifeForm = (Boolean)PreferencePredicate.ShowLifeForm.getDefaultValue();
+// this.isShowLifeForm = (Boolean)PreferencePredicate.ShowLifeForm.getDefaultValue();
this.allowOverrideShowLifeForm = true;
}
@Override
public boolean performOk() {
- if (showSpecimenPref == null){
+ if (!isApply()){
return true;
}
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
if (controller != null){
IPreferenceService service = controller.getPreferenceService();
+ CdmPreference pref;
+ if (isShowCollectingAreaInGeneralSection == null){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowCollectingAreasInGeneralSection, Boolean.toString(this.isShowCollectingAreaInGeneralSection));
+ pref.setAllowOverride(allowOverrideShowCollectingAreaInGeneralSection);
+ service.set(pref);
+ }
+ if (isShowSpecimenRelatedIssues == null){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowSpecimen));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, Boolean.toString(this.isShowSpecimenRelatedIssues));
+ pref.setAllowOverride(allowOverrideShowSpecimenRelatedIssues);
+ service.set(pref);
+ }
- CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowCollectingAreasInGeneralSection, Boolean.toString(this.isShowCollectingAreaInGeneralSection));
- pref.setAllowOverride(allowOverrideShowCollectingAreaInGeneralSection);
- service.set(pref);
- pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, Boolean.toString(this.isShowSpecimenRelatedIssues));
- pref.setAllowOverride(allowOverrideShowSpecimenRelatedIssues);
- service.set(pref);
-
- pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DeterminationOnlyForFieldUnits, Boolean.toString(this.isDeterminationOnlyForFieldUnits));
- pref.setAllowOverride(allowOverrideDeterminationOnlyForFieldUnits);
- service.set(pref);
-
- pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowTaxonAssociations, Boolean.toString(this.isShowTaxonAssociation));
- pref.setAllowOverride(allowOverrideShowTaxonAssociation);
- service.set(pref);
-
- pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowLifeForm, Boolean.toString(this.isShowLifeForm));
- pref.setAllowOverride(allowOverrideShowLifeForm);
- service.set(pref);
+ if (isDeterminationOnlyForFieldUnits == null){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DeterminationOnlyForFieldUnits, Boolean.toString(this.isDeterminationOnlyForFieldUnits));
+ pref.setAllowOverride(allowOverrideDeterminationOnlyForFieldUnits);
+ service.set(pref);
+ }
+ if (isShowTaxonAssociation == null){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonAssociations));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowTaxonAssociations, Boolean.toString(this.isShowTaxonAssociation));
+ pref.setAllowOverride(allowOverrideShowTaxonAssociation);
+ service.set(pref);
+ }
+ if (isShowLifeForm == null){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowLifeForm));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowLifeForm, Boolean.toString(this.isShowLifeForm));
+ pref.setAllowOverride(allowOverrideShowLifeForm);
+ service.set(pref);
+ }
PreferencesUtil.updateDBPreferences();
@Override
public boolean performOk() {
- if (pref == null){
+ if (!isApply()){
return true;
}
PreferencesUtil.setPreferenceToDB(pref);
TermOrder_natural=Natural
ChecklistEditorGeneralPreference_Configure_area_order=Order of Areas
-Preference_Use_Default= (Use Default)
+Preference_Use_Default= Use Default
*/
public class ChecklistEditorGeneralPreference extends CdmPreferencePage implements SelectionListener {
- protected boolean isEditorActivated;
+
+
+ protected Boolean isEditorActivated;
protected boolean overrideActivated;
boolean isUseLocal;
- protected boolean isShowRank;
+ protected Boolean isShowRank;
protected String orderAreas;
protected String displayStatus;
protected String displayArea;
- protected boolean ownDescriptionForDistributionEditor;
+ protected Boolean ownDescriptionForDistributionEditor;
protected boolean overrideOwnDescriptionForDistributionEditor;
protected boolean overrideAreaVoc;
getValues();
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayout(new GridLayout());
- if (!isAdminPreference && !distributionEditorPref.isAllowOverride()&& !isEditorActivated ) {
+ if (!isAdminPreference && distributionEditorPref != null && !distributionEditorPref.isAllowOverride()&& !isEditorActivated ) {
Label label = new Label(composite, SWT.NONE);
label.setText(
"The CDM settings don't allow to set the preferences for using the distribution editor locally. If you need to make local settings, please ask an administrator.");
separator.setLayoutData(sepGrid);
activateCombo = createBooleanCombo(activateComp, ENABLE, DISABLE, PreferencePredicate.DistributionEditorActivated, Messages.ChecklistEditorGeneralPreference_enable, isAdminPreference);
- if (isEditorActivated) {
- activateCombo.select(0);
- } else {
- activateCombo.select(1);
+
+ int index = 0;
+ for (String itemLabel : activateCombo.getItems()) {
+ if (isEditorActivated == null && itemLabel.equals(Messages.Preference_Use_Default)) {
+ activateCombo.select(index);
+ break;
+ }
+ if (isEditorActivated != null && itemLabel.equals(ENABLE) && isEditorActivated){
+ activateCombo.select(index);
+ break;
+ }
+ if (isEditorActivated != null && itemLabel.equals(DISABLE) && !isEditorActivated){
+ activateCombo.select(index);
+ break;
+ }
+ index++;
}
+
activateCombo.addSelectionListener(this);
if (isAdminPreference) {
allowOverrideActivatedButton = createAllowOverrideButton(activateComp);
- allowOverrideActivatedButton.setSelection(this.distributionEditorPref.isAllowOverride());
+ allowOverrideActivatedButton.setSelection(this.distributionEditorPref != null? this.distributionEditorPref.isAllowOverride(): true);
allowOverrideActivatedButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setApply(true);
+ if (distributionEditorPref == null){
+ distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue() != null ? PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString(): null);
+ }
distributionEditorPref.setAllowOverride(!distributionEditorPref.isAllowOverride());
}
});
child = createComposite(composite);
if (!isAdminPreference) {
- child.setEnabled(isEditorActivated);
+ if (isEditorActivated != null){
+ child.setEnabled(isEditorActivated);
+ }else{
+ child.setEnabled(Boolean.parseBoolean(distributionEditorPref.getValue().toString()));
+ }
}
separator = new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR);
sepGrid = createTextGridData();
activateRankCombo = createBooleanCombo(child, SHOW_RANK, NO_RANK,
PreferencePredicate.ShowRankInDistributionEditor, Messages.ChecklistEditorGeneralPreference_show_rank, isAdminPreference);
-
- if (isShowRank) {
- activateRankCombo.select(0);
- } else {
- activateRankCombo.select(1);
+ index = 0;
+ for (String itemLabel : activateRankCombo.getItems()) {
+ if (isShowRank == null && itemLabel.equals(Messages.Preference_Use_Default)) {
+ activateRankCombo.select(index);
+ break;
+ }
+ if (isShowRank != null && itemLabel.equals(SHOW_RANK) && isShowRank){
+ activateRankCombo.select(index);
+ break;
+ }
+ if (isShowRank != null && itemLabel.equals(NO_RANK) && !isShowRank){
+ activateRankCombo.select(index);
+ break;
+ }
+ index++;
}
activateRankCombo.addSelectionListener(this);
if (isAdminPreference) {
allowOverrideRankButton = createAllowOverrideButton(child);
- allowOverrideRankButton.setSelection(prefRank.isAllowOverride());
+ allowOverrideRankButton.setSelection(prefRank != null? prefRank.isAllowOverride():true);
allowOverrideRankButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
areaOrderSelectionCombo = createCombo(child, TermOrder.values(), PreferencePredicate.AreasSortedInDistributionEditor, Messages.ChecklistEditorGeneralPreference_Configure_area_order, isAdminPreference);
- int index = 0;
+ index = 0;
TermOrder areaOrder;
- try {
- if (orderAreas != null) {
- areaOrder = TermOrder.valueOf(orderAreas);
- } else {
- areaOrder = TermOrder.IdInVoc;
- }
- } catch (IllegalArgumentException e) {
+ try {
+ if (orderAreas != null) {
+ areaOrder = TermOrder.valueOf(orderAreas);
+ } else {
areaOrder = TermOrder.IdInVoc;
}
- for (String itemLabel : areaOrderSelectionCombo.getItems()) {
- if (itemLabel.startsWith(areaOrder.getLabel())) {
- areaOrderSelectionCombo.select(index);
- break;
- }
- index++;
+ } catch (IllegalArgumentException e) {
+ areaOrder = TermOrder.IdInVoc;
+ }
+ for (String itemLabel : areaOrderSelectionCombo.getItems()) {
+ if (itemLabel.equals(Messages.Preference_Use_Default) && orderAreas.equals(Messages.Preference_Use_Default)){
+ areaOrderSelectionCombo.select(index);
+ break;
}
+ if (itemLabel.startsWith(areaOrder.getLabel())) {
+ areaOrderSelectionCombo.select(index);
+ break;
+ }
+
+ index++;
+ }
areaOrderSelectionCombo.addSelectionListener(this);
if (isAdminPreference) {
allowOverrideOrderAreasButton = createAllowOverrideButton(child);
- allowOverrideOrderAreasButton.setSelection(prefAreaSort.isAllowOverride());
+ allowOverrideOrderAreasButton.setSelection(prefAreaSort != null? prefAreaSort.isAllowOverride(): true);
allowOverrideOrderAreasButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
separator.setLayoutData(sepGrid);
areaDisplaySelectionCombo = createCombo(child, TermDisplayEnum.values(), PreferencePredicate.DisplayOfAreasInDistributionEditor, Messages.ChecklistEditorGeneralPreference_Configure_display_of_Areas, isAdminPreference);
+
index = 0;
- if (PreferencesUtil.getStringValue(PreferencePredicate.DistributionEditorActivated.getKey()) != null) {
- TermDisplayEnum areaDisplay;
- try {
- if (displayArea != null) {
- areaDisplay = TermDisplayEnum.byKey(displayArea);
- } else {
- areaDisplay = TermDisplayEnum.Title;
- }
- } catch (IllegalArgumentException e) {
+ TermDisplayEnum areaDisplay;
+ try {
+ if (displayArea != null) {
+ areaDisplay = TermDisplayEnum.valueOf(displayArea);
+ } else {
areaDisplay = TermDisplayEnum.Title;
}
-
- for (String itemLabel : areaDisplaySelectionCombo.getItems()) {
- if (itemLabel.startsWith(areaDisplay.getLabel())) {
- areaDisplaySelectionCombo.select(index);
- break;
- }
- index++;
+ } catch (IllegalArgumentException e) {
+ areaDisplay = TermDisplayEnum.Title;
+ }
+ for (String itemLabel : areaDisplaySelectionCombo.getItems()) {
+ if (itemLabel.equals(Messages.Preference_Use_Default) && displayArea.equals(Messages.Preference_Use_Default)){
+ areaDisplaySelectionCombo.select(index);
+ break;
}
+ if (itemLabel.startsWith(areaDisplay.getLabel())) {
+ areaDisplaySelectionCombo.select(index);
+ break;
+ }
+
+ index++;
}
areaDisplaySelectionCombo.addSelectionListener(this);
if (isAdminPreference) {
allowOverrideAreaDisplayButton = createAllowOverrideButton(child);
- allowOverrideAreaDisplayButton.setSelection(prefAreaDisplay.isAllowOverride());
+ allowOverrideAreaDisplayButton.setSelection(prefAreaDisplay != null? prefAreaDisplay.isAllowOverride(): true);
allowOverrideAreaDisplayButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
statusDisplaySelectionCombo = createCombo(child, TermDisplayEnum.values(), PreferencePredicate.DisplayOfStatus, Messages.ChecklistEditorGeneralPreference_Configure_display_of_Status, isAdminPreference);
index = 0;
- if (displayStatus != null) {
- TermDisplayEnum statusDisplay;
- try {
- statusDisplay = TermDisplayEnum.byKey(displayStatus);
- } catch (IllegalArgumentException e) {
+ TermDisplayEnum statusDisplay;
+ try {
+ if (displayStatus != null) {
+ statusDisplay = TermDisplayEnum.valueOf(displayStatus);
+ } else {
statusDisplay = TermDisplayEnum.Title;
}
- for (String itemLabel : statusDisplaySelectionCombo.getItems()) {
- if (itemLabel.startsWith(statusDisplay.getLabel())) {
- statusDisplaySelectionCombo.select(index);
- break;
- }
- index++;
+ } catch (IllegalArgumentException e) {
+ statusDisplay = TermDisplayEnum.Title;
+ }
+ for (String itemLabel : statusDisplaySelectionCombo.getItems()) {
+ if (itemLabel.equals(Messages.Preference_Use_Default) && displayStatus.equals(Messages.Preference_Use_Default)){
+ statusDisplaySelectionCombo.select(index);
+ break;
+ }
+ if (itemLabel.startsWith(statusDisplay.getLabel())) {
+ statusDisplaySelectionCombo.select(index);
+ break;
}
+
+ index++;
}
statusDisplaySelectionCombo.addSelectionListener(this);
if (isAdminPreference) {
allowOverrideStatusDisplayButton = createAllowOverrideButton(child);
- allowOverrideStatusDisplayButton.setSelection(prefStatusDisplay.isAllowOverride());
+ allowOverrideStatusDisplayButton.setSelection(prefStatusDisplay != null ? prefStatusDisplay.isAllowOverride(): true);
allowOverrideStatusDisplayButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
.setText(Messages.ChecklistEditorGeneralPreference_open_distribution_selection);
if (!isAdminPreference) {
- PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);
+
+ //PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);
if (distributionEditorPref != null && !distributionEditorPref.isAllowOverride()){
activateComp.setEnabled(false);
}
@Override
public boolean performOk() {
- // if (distributionEditorPref == null || this.distributionEditorPref.isAllowOverride()) {
-
- PreferencesUtil.setBooleanValue(PreferencePredicate.DistributionEditorActivated.getKey(),
- isEditorActivated);
+ if (!isApply()){
+ return true;
+ }
boolean override = false;
- if (distributionEditorPref == null
- || isEditorActivated != Boolean.parseBoolean(distributionEditorPref.getValue())) {
+ if (isEditorActivated != null ) {
override = true;
+ PreferencesUtil.setStringValue(PreferencePredicate.DistributionEditorActivated.getKey(), isEditorActivated.toString());
}
PreferencesUtil.setBooleanValue(
PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()),
override);
- PreferencesUtil.setSortNamedAreasInDistributionEditor(orderAreas);
+
+
override = false;
- if (prefAreaSort == null || orderAreas != prefAreaSort.getValue()) {
+ if (!orderAreas.equals(Messages.Preference_Use_Default) ) {
override = true;
+ PreferencesUtil.setSortNamedAreasInDistributionEditor(orderAreas);
}
PreferencesUtil.setBooleanValue(
PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()),
override);
- PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
+
+
+
+
+
override = false;
- if (prefRank == null || isShowRank != Boolean.parseBoolean(prefRank.getValue())) {
+ if (isShowRank != null ) {
override = true;
+ PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
}
PreferencesUtil.setBooleanValue(
PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()),
- true);
- PreferencesUtil.setDisplayStatusInChecklistEditor(displayStatus);
+ override);
+
+
override = false;
- if (prefStatusDisplay == null || displayStatus != prefStatusDisplay.getValue()) {
+ if (!displayStatus.equals(Messages.Preference_Use_Default)) {
override = true;
+ PreferencesUtil.setDisplayStatusInChecklistEditor(displayStatus);
}
PreferencesUtil.setBooleanValue(
PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()),
- true);
- PreferencesUtil.setAreaDisplayInChecklistEditor(displayArea);
+ override);
+
+
+
+
override = false;
- if (prefAreaDisplay == null || displayArea != prefAreaDisplay.getValue()) {
+ if (!displayArea.equals(Messages.Preference_Use_Default) ) {
override = true;
+ PreferencesUtil.setAreaDisplayInChecklistEditor(displayArea);
}
PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(
- PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), overrideAreaDisplay);
+ PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), override);
+
+
+
+
PreferencesUtil.setOwnDescriptionForChecklistEditor(ownDescriptionForDistributionEditor);
PreferencesUtil.setBooleanValue(
PreferencesUtil.prefOverrideKey(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey()),
true);
- // if (statusPref != null){
- // PreferencesUtil.setStringValue(PreferencePredicate.AvailableDistributionStatus.getKey(),
- // "");
- // //PreferencesUtil.setStringValue(PreferencePredicate.AvailableDistributionStatus.getKey(),
- // statusPref.getValue());
- // PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.AvailableDistributionStatus.getKey()),true);
- //
- // }
- // if (areaVocPref != null){
- // PreferencesUtil.setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(),
- // "");
- // PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey()),
- // true);
- // }
PreferencesUtil.firePreferencesChanged(this.getClass());
- //}
return true;
}
setApply(true);
if (e.getSource().equals(statusDisplaySelectionCombo)) {
String text = statusDisplaySelectionCombo.getText();
+ if(text.equals(Messages.Preference_Use_Default)){
+ displayStatus = Messages.Preference_Use_Default;
+ if(isAdminPreference){
+ prefStatusDisplay.setAllowOverride(true);
+ allowOverrideStatusDisplayButton.setSelection(true);
+ }
+
+ return;
+ }
for (TermDisplayEnum display : TermDisplayEnum.values()) {
if (text.startsWith(display.getLabel())) {
displayStatus = display.getKey();
break;
}
+
}
}
if (e.getSource().equals(areaDisplaySelectionCombo)) {
String text = areaDisplaySelectionCombo.getText();
+ if(text.equals(Messages.Preference_Use_Default)){
+ displayArea = Messages.Preference_Use_Default;
+ if (isAdminPreference){
+ prefAreaDisplay.setAllowOverride(true);
+ allowOverrideAreaDisplayButton.setSelection(true);
+ }
+ return;
+ }
for (TermDisplayEnum display : TermDisplayEnum.values()) {
if (text.startsWith(display.getLabel())) {
displayArea = display.getKey();
}
if (e.getSource().equals(areaOrderSelectionCombo)) {
String text = areaOrderSelectionCombo.getText();
+ if(text.equals(Messages.Preference_Use_Default)){
+ orderAreas = Messages.Preference_Use_Default;
+ if (isAdminPreference){
+ prefAreaSort.setAllowOverride(true);
+ allowOverrideOrderAreasButton.setSelection(true);
+ }
+ return;
+ }
for (TermOrder display : TermOrder.values()) {
if (text.startsWith(display.getLabel())) {
orderAreas = display.getKey();
}
if (e.getSource().equals(this.activateRankCombo)) {
String text = activateRankCombo.getText();
- text = text.replace(Messages.Preference_Use_Default, "");
+ if(text.equals(Messages.Preference_Use_Default)){
+ isShowRank = null;
+ if (isAdminPreference){
+ prefRank.setAllowOverride(true);
+ allowOverrideRankButton.setSelection(true);
+ }
+ return;
+ }
if (text.equals(SHOW_RANK)){
isShowRank = true;
}else{
if (e.getSource().equals(this.activateCombo)) {
String text = activateCombo.getText();
- text = text.replace(" (Default)", "");
+ if(text.equals(Messages.Preference_Use_Default)){
+ isEditorActivated = null;
+ if (isAdminPreference){
+ if (distributionEditorPref == null){
+ distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue() != null ? PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString(): null);
+ }
+ distributionEditorPref.setAllowOverride(true);
+ allowOverrideActivatedButton.setSelection(true);
+ }
+ return;
+ }
if (text.equals(ENABLE)){
isEditorActivated = true;
}else{
isEditorActivated = false;
}
+
}
- PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);
+ //PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);
}
/**
isAdminPreference = false;
setPreferenceStore(PreferencesUtil.getPreferenceStore());
distributionEditorPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
+ overrideActivated = PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()), true);
if (distributionEditorPref != null) {
- // isAllowOverride = distributionEditorPref.isAllowOverride();
-
if (distributionEditorPref.isAllowOverride() ) {
- isEditorActivated = PreferencesUtil
- .getBooleanValue(PreferencePredicate.DistributionEditorActivated.getKey(), true);
+ if (overrideActivated){
+ isEditorActivated = PreferencesUtil.getBooleanValue(PreferencePredicate.DistributionEditorActivated.getKey(), true);
+ }
} else {
isEditorActivated = Boolean.valueOf(distributionEditorPref.getValue());
}
- overrideActivated = PreferencesUtil.getBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()), true);
+
} else {
- isEditorActivated = PreferencesUtil
- .getBooleanValue(PreferencePredicate.DistributionEditorActivated.getKey(), true);
- // isAllowOverride = true;
- overrideActivated = PreferencesUtil.getBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()), true);
- distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue() != null ? PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString(): null);
+ if(!overrideActivated){
+ isEditorActivated = null;
+ }else{
+ isEditorActivated = PreferencesUtil.getBooleanValue(PreferencePredicate.DistributionEditorActivated.getKey(), true);
+ }
+ //distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue() != null ? PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString(): null);
}
prefAreaVoc = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
prefAreaDisplay = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DisplayOfAreasInDistributionEditor);
+ overrideAreaDisplay = PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), true);
if (prefAreaDisplay != null) {
-
- if (prefAreaDisplay.isAllowOverride()) {
- displayArea = PreferencesUtil.displayAreaInChecklistEditor();
- overrideAreaDisplay = PreferencesUtil.getBooleanValue(PreferencesUtil
- .prefOverrideKey(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), true);
+ if (prefAreaDisplay.isAllowOverride()){
+ if (overrideActivated) {
+ displayArea = PreferencesUtil.displayAreaInChecklistEditor();
+ }else{
+ displayArea = Messages.Preference_Use_Default;
+ }
} else {
displayArea = prefAreaDisplay.getValue();
}
} else {
- displayArea = PreferencesUtil.displayAreaInChecklistEditor();
-
- overrideAreaDisplay = PreferencesUtil.getBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), true);
- prefAreaDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfAreasInDistributionEditor, PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString(): null);
+ if (overrideAreaDisplay){
+ displayArea = PreferencesUtil.displayAreaInChecklistEditor();
+ } else{
+ displayArea = Messages.Preference_Use_Default;
+ }
+ //prefAreaDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfAreasInDistributionEditor, PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString(): null);
}
prefStatusDisplay = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DisplayOfStatus);
+ overrideStatusDisplay = PreferencesUtil
+ .getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()), true);
if (prefStatusDisplay != null) {
-
- if (prefStatusDisplay.isAllowOverride()) {
- displayStatus = PreferencesUtil.displayStatusInChecklistEditor();
- overrideStatusDisplay = PreferencesUtil
- .getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()), true);
+ if (prefStatusDisplay.isAllowOverride()){
+ if (overrideStatusDisplay) {
+ displayStatus = PreferencesUtil.displayStatusInChecklistEditor();
+ }else{
+ displayStatus = Messages.Preference_Use_Default;
+ }
} else {
this.displayStatus = prefStatusDisplay.getValue();
}
} else {
- displayStatus = PreferencesUtil.displayStatusInChecklistEditor();
-
- overrideStatusDisplay = PreferencesUtil
- .getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()), true);
- prefStatusDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfStatus, PreferencePredicate.DisplayOfStatus.getDefaultValue() != null ? PreferencePredicate.DisplayOfStatus.getDefaultValue().toString(): null);
+ if (overrideStatusDisplay){
+ displayStatus = PreferencesUtil.displayStatusInChecklistEditor();
+ } else{
+ displayStatus = Messages.Preference_Use_Default;
+ }
+ //prefStatusDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfStatus, PreferencePredicate.DisplayOfStatus.getDefaultValue() != null ? PreferencePredicate.DisplayOfStatus.getDefaultValue().toString(): null);
}
prefAreaSort = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AreasSortedInDistributionEditor);
+ overrideOrderAreas = PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()), true);
if (prefAreaSort != null) {
-
- if (prefAreaSort.isAllowOverride()) {
- orderAreas = PreferencesUtil.getSortNamedAreasInDistributionEditor();
- overrideOrderAreas = PreferencesUtil.getBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()), true);
+ if (prefAreaSort.isAllowOverride()){
+ if(overrideOrderAreas) {
+ orderAreas = PreferencesUtil.getSortNamedAreasInDistributionEditor();
+ }else{
+ orderAreas = Messages.Preference_Use_Default;
+ }
} else {
if (prefAreaSort.getValue() != null) {
orderAreas = prefAreaSort.getValue().toString();
orderAreas = ((TermOrder) PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue())
.getKey();
}
+
}
} else {
- orderAreas = PreferencesUtil.getSortNamedAreasInDistributionEditor();
- overrideOrderAreas = PreferencesUtil.getBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()), true);
- prefAreaSort = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AreasSortedInDistributionEditor, PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue().toString(): null);
+ if (overrideOrderAreas){
+ orderAreas = PreferencesUtil.getSortNamedAreasInDistributionEditor();
+ }else{
+ orderAreas = Messages.Preference_Use_Default;
+ }
+ //prefAreaSort = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AreasSortedInDistributionEditor, PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue().toString(): null);
}
prefRank = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowRankInDistributionEditor);
+ overrideRank = PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()), true);
if (prefRank != null) {
- if (prefRank.isAllowOverride()) {
- isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
- overrideRank = PreferencesUtil.getBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()), true);
+ if (prefRank.isAllowOverride()){
+ if(overrideRank) {
+ isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
+ }
+
} else {
this.isShowRank = Boolean.valueOf(prefRank.getValue().toString());
}
} else {
- isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
- overrideRank = PreferencesUtil.getBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()), true);
- prefRank = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowRankInDistributionEditor, PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString(): null);
+ if (overrideRank){
+ isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
+ } else {
+ isShowRank = null;
+ }
+
+ //refRank = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowRankInDistributionEditor, PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString(): null);
}
prefOwnDescription = PreferencesUtil
// allowOverrideOwnDescriptionForDistributionEditor = true;
overrideOwnDescriptionForDistributionEditor = PreferencesUtil.getBooleanValue(
PreferencesUtil.prefOverrideKey(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey()), true);
- prefOwnDescription = CdmPreference.NewTaxEditorInstance(PreferencePredicate.OwnDescriptionForDistributionEditor, PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue() != null ? PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue().toString(): null);
+ //prefOwnDescription = CdmPreference.NewTaxEditorInstance(PreferencePredicate.OwnDescriptionForDistributionEditor, PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue() != null ? PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue().toString(): null);
}
commandHandlerString = "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler";
*/
public interface IE4PreferencePage {
+ boolean isApply();
}
import org.eclipse.swt.custom.CLabel;
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 eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
-public class NameDetailsViewConfiguration extends CdmPreferencePage {
+public class NameDetailsViewConfiguration extends CdmPreferencePage implements SelectionListener{
- protected boolean isSimpleDetailsViewActivated;
+ /**
+ *
+ */
+ private static final String DISABLE = "Disable";
+ /**
+ *
+ */
+ private static final String ENABLE = "Enable";
+ protected Boolean isSimpleDetailsViewActivated;
boolean isUseLocalSettings;
protected NameDetailsConfigurator nameDetailsConfig;
Composite localSettings ;
protected Button showHybrid;
protected Button showNameApprobiation;
+ Composite dbSettings;
+
@Override
protected Control createContents(Composite parent) {
getValues();
nameDetailsConfig = new NameDetailsConfigurator(false);
}
- activateCheckButton = createBooleanCombo(title, "Enable", "Disable", PreferencePredicate.SimpleDetailsViewActivated, Messages.NameDetailsViewConfiguration_activateSimpleDetailsView, isAdminPreference);
+ activateCheckButton = createBooleanCombo(title, ENABLE, DISABLE, PreferencePredicate.SimpleDetailsViewActivated, Messages.NameDetailsViewConfiguration_activateSimpleDetailsView, isAdminPreference);
if (isAdminPreference){
allowLocalPreference = createAllowOverrideButton(title);
});
}
- Composite dbSettings = new Composite(parent, SWT.NONE);
+ dbSettings = new Composite(parent, SWT.NONE);
// activateCheckButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
// activateCheckButton.setText(Messages.NameDetailsViewConfiguration_activateSimpleDetailsView);
isSimpleDetailsViewActivated = nameDetailsConfig.isSimpleDetailsViewActivated();
- activateCheckButton.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- isSimpleDetailsViewActivated = activateCheckButton.getSelectionIndex() == 0? true:false;
- nameDetailsConfig.setSimpleDetailsViewActivated(isSimpleDetailsViewActivated);
- dbSettings.setEnabled(isSimpleDetailsViewActivated);
- PreferencesUtil.recursiveSetEnabled(dbSettings, isSimpleDetailsViewActivated);
- if (isSimpleDetailsViewActivated){
- showSecDetail.setEnabled(isShowTaxon);
- secEnabled.setEnabled(isShowTaxon);
- }
-
- }
- });
+ activateCheckButton.addSelectionListener(this);
+// new SelectionAdapter(){
+// @Override
+// public void widgetSelected(SelectionEvent e) {
+// setApply(true);
+// isSimpleDetailsViewActivated = activateCheckButton.getSelectionIndex() == 0? true:false;
+// nameDetailsConfig.setSimpleDetailsViewActivated(isSimpleDetailsViewActivated);
+// dbSettings.setEnabled(isSimpleDetailsViewActivated);
+// PreferencesUtil.recursiveSetEnabled(dbSettings, isSimpleDetailsViewActivated);
+// if (isSimpleDetailsViewActivated){
+// showSecDetail.setEnabled(isShowTaxon);
+// secEnabled.setEnabled(isShowTaxon);
+// }
+//
+// }
+// });
dbSettings.setLayout(new GridLayout());
}
protected void setButtonSelections(){
- int index = isSimpleDetailsViewActivated?0:1;
+
+ int index = 0;
+ if (isSimpleDetailsViewActivated != null){
+ if (isSimpleDetailsViewActivated){
+ index = 1;
+ }else{
+ index = 2;
+ }
+ }
activateCheckButton.select(index);
if (isAdminPreference){
allowLocalPreference.setSelection(isAllowOverride);
super.performDefaults();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (e.getSource().equals(activateCheckButton)){
+ String text = activateCheckButton.getText();
+ if(text.equals(Messages.Preference_Use_Default)){
+ isSimpleDetailsViewActivated = null;
+ if (isAdminPreference){
+ nameDetailsPref.setAllowOverride(true);
+ allowLocalPreference.setSelection(true);
+ }
+ return;
+ }
+ if (text.equals(ENABLE)){
+ isSimpleDetailsViewActivated = true;
+ }else{
+ isSimpleDetailsViewActivated = false;
+ }
+ dbSettings.setEnabled(isSimpleDetailsViewActivated);
+ PreferencesUtil.recursiveSetEnabled(dbSettings, isSimpleDetailsViewActivated);
+ if (isSimpleDetailsViewActivated){
+ showSecDetail.setEnabled(isShowTaxon);
+ secEnabled.setEnabled(isShowTaxon);
+ }
+ }
+
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
}
CdmPreference pref = getDBPreferenceValue(name);
String prefValue = null;
String overrideKey = createPreferenceString(createOverridePreferenceString(name));
- boolean override = true;
- if (getPreferenceStore().contains(overrideKey)){
- override = getPreferenceStore().getBoolean(overrideKey);
- }
+ boolean override = getPreferenceStore().getBoolean(overrideKey);
+
if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
String dbSpecific = prefKey(name);
if (getPreferenceStore().contains(dbSpecific)){
CdmPreference pref = getDBPreferenceValue(name);
String overrideKey = createPreferenceString(createOverridePreferenceString(name));
- boolean override = true;
- if (getPreferenceStore().contains(overrideKey)){
- override = getPreferenceStore().getBoolean(overrideKey);
- }
+ boolean override = getPreferenceStore().getBoolean(overrideKey);
+
if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
String dbSpecific = prefKey(name);
return getPreferenceStore().getBoolean(dbSpecific);
return prefs;
+ }
+
+ public static void setPreferencesToDB(CdmPreference preference, boolean setDefault){
+ ICdmRepository controller;
+
+
+ try{
+ if(CdmStore.isActive()){
+ controller = CdmStore.getCurrentApplicationConfiguration();
+
+ if (setDefault){
+ controller.getPreferenceService().remove(preference.getKey());
+ }else{
+ controller.getPreferenceService().set(preference);
+ }
+ }
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+
+
+
}
public static CdmPreference getPreferenceFromDB(PrefKey key){
getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES, true);
//Distribution Editor:
- getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DistributionEditorActivated.getKey()), Boolean.valueOf(PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString()));
+// getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DistributionEditorActivated.getKey()), Boolean.valueOf(PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString()));
// getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString());
// getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DisplayOfStatus.getKey()), PreferencePredicate.DisplayOfStatus.getDefaultValue().toString());
private static final String LOCAL_SETTINGS_NOT_ALLOWED = Messages.SpecimenOrObservationPreferences_0;
private static final String DESCRIPTION = Messages.SpecimenOrObservationPreferences_1;
- protected boolean isShowSpecimenRelatedIssues;
+ protected Boolean isShowSpecimenRelatedIssues;
protected boolean allowOverrideShowSpecimenRelatedIssues;
protected boolean overrideShowSpecimenRelatedIssues;
- protected boolean isShowCollectingAreaInGeneralSection;
+ protected Boolean isShowCollectingAreaInGeneralSection;
protected boolean allowOverrideShowCollectingAreaInGeneralSection;
protected boolean overrideShowCollectionAreaInGeneralSection;
- protected boolean isDeterminationOnlyForFieldUnits;
+ protected Boolean isDeterminationOnlyForFieldUnits;
protected boolean allowOverrideDeterminationOnlyForFieldUnits;
protected boolean overrideDeterminationOnlyForFieldUnits;
- protected boolean isShowTaxonAssociation;
+ protected Boolean isShowTaxonAssociation;
protected boolean allowOverrideShowTaxonAssociation;
protected boolean overrideShowTaxonAssociation;
- protected boolean isShowLifeForm;
+ protected Boolean isShowLifeForm;
protected boolean allowOverrideShowLifeForm;
protected boolean overrideShowLifeForm;
Composite composite;
boolean isEditingAllowed = true;
if(!isAdminPreference){
CdmPreferenceCache cache = CdmPreferenceCache.instance();
- PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowSpecimen);
- CdmPreference showSpecimenPref = cache.findBestMatching(key);
+
if (showSpecimenPref != null){
if (!showSpecimenPref.isAllowOverride() ){
- Label label = new Label(parent, SWT.NONE);
- label.setText(LOCAL_SETTINGS_NOT_ALLOWED);
+
isEditingAllowed = false;
}
}
}
-
- Label label = new Label(parent, SWT.NONE);
- label.setText(DESCRIPTION);
+ if (isEditingAllowed){
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(DESCRIPTION);
+ }else{
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(LOCAL_SETTINGS_NOT_ALLOWED);
+ this.noDefaultAndApplyButton();
+ return parent;
+ }
Composite titleComp = createComposite(parent);
GridData gridData = createTextGridData();
showSpecimenButton = createBooleanCombo(titleComp, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowSpecimen, Messages.DatabasePreferncesPage_Show_Specimen, isAdminPreference);
showSpecimenButton.addSelectionListener(this);
- if (isShowSpecimenRelatedIssues){
- showSpecimenButton.select(0);
- }else{
- showSpecimenButton.select(1);
+ int index = 0;
+ for (String itemLabel : showSpecimenButton.getItems()) {
+ if (isShowSpecimenRelatedIssues == null && itemLabel.equals(Messages.Preference_Use_Default)) {
+ showSpecimenButton.select(index);
+ break;
+ }
+ if (isShowSpecimenRelatedIssues != null && itemLabel.equals(Messages.GeneralPreference_yes) && isShowSpecimenRelatedIssues){
+ showSpecimenButton.select(index);
+ break;
+ }
+ if (isShowSpecimenRelatedIssues != null && itemLabel.equals(Messages.GeneralPreference_no) && !isShowSpecimenRelatedIssues){
+ showSpecimenButton.select(index);
+ break;
+ }
+ index++;
}
-
+ showSpecimenButton.setEnabled(isEditingAllowed);
if (isAdminPreference){
allowOverrideIsShowSpecimenRelatedIssuesButton = createAllowOverrideButton(titleComp);
showCollectingAreaInGeneralSectionButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowCollectingAreasInGeneralSection, Messages.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section, isAdminPreference);
showCollectingAreaInGeneralSectionButton.addSelectionListener(this);
- if (isShowCollectingAreaInGeneralSection){
- showCollectingAreaInGeneralSectionButton.select(0);
- }else{
- showCollectingAreaInGeneralSectionButton.select(1);
+ index = 0;
+ for (String itemLabel : showCollectingAreaInGeneralSectionButton.getItems()) {
+ if (isShowCollectingAreaInGeneralSection == null && itemLabel.equals(Messages.Preference_Use_Default)) {
+ showCollectingAreaInGeneralSectionButton.select(index);
+ break;
+ }
+ if (isShowCollectingAreaInGeneralSection != null && itemLabel.equals(Messages.GeneralPreference_yes) && isShowCollectingAreaInGeneralSection){
+ showCollectingAreaInGeneralSectionButton.select(index);
+ break;
+ }
+ if (isShowCollectingAreaInGeneralSection != null && itemLabel.equals(Messages.GeneralPreference_no) && !isShowCollectingAreaInGeneralSection){
+ showCollectingAreaInGeneralSectionButton.select(index);
+ break;
+ }
+ index++;
}
if (isAdminPreference){
allowOverrideShowCollectingAreaButton = createAllowOverrideButton(composite);
}
});
}
-
+ if (showCollectingAreaInGeneralSection != null && !showCollectingAreaInGeneralSection.isAllowOverride() ){
+ isEditingAllowed = false;
+ }
+ showCollectingAreaInGeneralSectionButton.setEnabled(isEditingAllowed);
determinationOnlyForFieldUnitsButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.DeterminationOnlyForFieldUnits, Messages.DatabasePreferncesPage_Determination_only_for_field_unnits, isAdminPreference);
determinationOnlyForFieldUnitsButton.addSelectionListener(this);
- if (isDeterminationOnlyForFieldUnits){
- determinationOnlyForFieldUnitsButton.select(0);
- }else{
- determinationOnlyForFieldUnitsButton.select(1);
+ index = 0;
+ for (String itemLabel : determinationOnlyForFieldUnitsButton.getItems()) {
+ if (isDeterminationOnlyForFieldUnits == null && itemLabel.equals(Messages.Preference_Use_Default)) {
+ determinationOnlyForFieldUnitsButton.select(index);
+ break;
+ }
+ if (isDeterminationOnlyForFieldUnits != null && itemLabel.equals(Messages.GeneralPreference_yes) && isDeterminationOnlyForFieldUnits){
+ determinationOnlyForFieldUnitsButton.select(index);
+ break;
+ }
+ if (isDeterminationOnlyForFieldUnits != null && itemLabel.equals(Messages.GeneralPreference_no) && !isDeterminationOnlyForFieldUnits){
+ determinationOnlyForFieldUnitsButton.select(index);
+ break;
+ }
+ index++;
}
-
+ if (showDeterminationOnlyForFieldUnits != null && !showDeterminationOnlyForFieldUnits.isAllowOverride() ){
+ isEditingAllowed = false;
+ }
+ determinationOnlyForFieldUnitsButton.setEnabled(isEditingAllowed);
if (isAdminPreference){
allowOverridesDeterminationOnlyForFieldUnitsButton = createAllowOverrideButton(composite);
allowOverridesDeterminationOnlyForFieldUnitsButton.setSelection(allowOverrideDeterminationOnlyForFieldUnits);
showTaxonAssociationButton.addSelectionListener(this);
- if (isShowTaxonAssociation){
- showTaxonAssociationButton.select(0);
- }else{
- showTaxonAssociationButton.select(1);
+ index = 0;
+ for (String itemLabel : showTaxonAssociationButton.getItems()) {
+ if (isShowTaxonAssociation == null && itemLabel.equals(Messages.Preference_Use_Default)) {
+ showTaxonAssociationButton.select(index);
+ break;
+ }
+ if (isShowTaxonAssociation != null && itemLabel.equals(Messages.GeneralPreference_yes) && isShowTaxonAssociation){
+ showTaxonAssociationButton.select(index);
+ break;
+ }
+ if (isShowTaxonAssociation != null && itemLabel.equals(Messages.GeneralPreference_no) && !isShowTaxonAssociation){
+ showTaxonAssociationButton.select(index);
+ break;
+ }
+ index++;
+ }
+ if (showTaxonAssociation != null && !showTaxonAssociation.isAllowOverride() ){
+ isEditingAllowed = false;
}
+ showTaxonAssociationButton.setEnabled(isEditingAllowed);
if (isAdminPreference){
allowOverrideIsShowTaxonAssociationButton = createAllowOverrideButton(composite);
allowOverrideIsShowTaxonAssociationButton.setSelection(allowOverrideShowTaxonAssociation);
showLifeFormButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowLifeForm, Messages.DatabasePreferncesPage_Life_Form, isAdminPreference);
showLifeFormButton.addSelectionListener(this);
- if (isShowLifeForm){
- showLifeFormButton.select(0);
- }else{
- showLifeFormButton.select(1);
+ index = 0;
+ for (String itemLabel: showLifeFormButton.getItems()) {
+ if (isShowLifeForm == null && itemLabel.equals(Messages.Preference_Use_Default)) {
+ showLifeFormButton.select(index);
+ break;
+ }
+ if (isShowLifeForm != null && itemLabel.equals(Messages.GeneralPreference_yes) && isShowLifeForm){
+ showLifeFormButton.select(index);
+ break;
+ }
+ if (isShowLifeForm != null && itemLabel.equals(Messages.GeneralPreference_no) && !isShowLifeForm){
+ showLifeFormButton.select(index);
+ break;
+ }
+ index++;
}
-
+ if (showLifeForm != null && !showLifeForm.isAllowOverride() ){
+ isEditingAllowed = false;
+ }
+ showLifeFormButton.setEnabled(isEditingAllowed);
if (isAdminPreference){
allowOverrideShowLifeFormButton = createAllowOverrideButton(composite);
allowOverrideShowLifeFormButton.setSelection(allowOverrideShowLifeForm);
protected void getValues() {
CdmPreferenceCache cache = CdmPreferenceCache.instance();
- isShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimen.getKey());
+
+ overrideShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowSpecimen.getKey()), true);
+
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowSpecimen);
- showSpecimenPref = cache.findBestMatching(key);
- if (showSpecimenPref == null){
+ showSpecimenPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowSpecimen);
+
+
+ if (showSpecimenPref != null) {
+ if (showSpecimenPref.isAllowOverride() ) {
+ if (overrideShowSpecimenRelatedIssues){
+ isShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimen.getKey(), true);
+ }
+ } else {
+ isShowSpecimenRelatedIssues = Boolean.valueOf(showSpecimenPref.getValue());
+ }
+
+ } else {
+ if(!overrideShowSpecimenRelatedIssues){
+ isShowSpecimenRelatedIssues = null;
+ }else{
+ isShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimen.getKey(), true);
+ }
showSpecimenPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, PreferencePredicate.ShowSpecimen.getDefaultValue() != null ? PreferencePredicate.ShowSpecimen.getDefaultValue().toString(): null);
}
- allowOverrideShowSpecimenRelatedIssues = showSpecimenPref != null ? showSpecimenPref.isAllowOverride():true;
- isShowCollectingAreaInGeneralSection = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), true);
+
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection);
- showCollectingAreaInGeneralSection = cache.findBestMatching(key);
- if (showCollectingAreaInGeneralSection == null){
+ showCollectingAreaInGeneralSection = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
+ overrideShowCollectionAreaInGeneralSection = PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), true);
+ allowOverrideShowCollectingAreaInGeneralSection = showCollectingAreaInGeneralSection != null ? showCollectingAreaInGeneralSection.isAllowOverride():true;
+ if (showCollectingAreaInGeneralSection != null) {
+ if (showCollectingAreaInGeneralSection.isAllowOverride() ) {
+ if (overrideShowCollectionAreaInGeneralSection){
+ isShowCollectingAreaInGeneralSection = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), true);
+ }
+
+ } else {
+ isShowCollectingAreaInGeneralSection = Boolean.valueOf(showCollectingAreaInGeneralSection.getValue());
+
+ }
+
+ } else {
+ if(!overrideShowCollectionAreaInGeneralSection){
+ isShowCollectingAreaInGeneralSection = null;
+ }else{
+ isShowCollectingAreaInGeneralSection = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), true);
+ }
showCollectingAreaInGeneralSection = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowCollectingAreasInGeneralSection, PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue() != null ? PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue().toString(): null);
}
- allowOverrideShowCollectingAreaInGeneralSection = showCollectingAreaInGeneralSection != null ? showCollectingAreaInGeneralSection.isAllowOverride():true;
- isDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey());
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
- showDeterminationOnlyForFieldUnits = cache.findBestMatching(key);
- if (showDeterminationOnlyForFieldUnits == null){
+ showDeterminationOnlyForFieldUnits = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
+ overrideDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), true);
+ if (showDeterminationOnlyForFieldUnits != null) {
+ if (showDeterminationOnlyForFieldUnits.isAllowOverride() ) {
+ if (overrideDeterminationOnlyForFieldUnits){
+ isDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey());
+ }
+
+ } else {
+ isDeterminationOnlyForFieldUnits = Boolean.valueOf(showDeterminationOnlyForFieldUnits.getValue());
+
+ }
+
+ } else {
+ if(!overrideDeterminationOnlyForFieldUnits){
+ isDeterminationOnlyForFieldUnits = null;
+ }else{
+ isDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey(), true);
+ }
showDeterminationOnlyForFieldUnits = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DeterminationOnlyForFieldUnits, PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue() != null ? PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue().toString(): null);
}
+
allowOverrideDeterminationOnlyForFieldUnits = showDeterminationOnlyForFieldUnits != null ? showDeterminationOnlyForFieldUnits.isAllowOverride():true;
- isShowTaxonAssociation = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey());
+
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonAssociations);
- showTaxonAssociation = cache.findBestMatching(key);
- if (showTaxonAssociation == null){
+ showTaxonAssociation = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
+ overrideShowTaxonAssociation = PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowTaxonAssociations.getKey()), true);
+ if (showTaxonAssociation != null) {
+ if (showTaxonAssociation.isAllowOverride() ) {
+ if (overrideShowTaxonAssociation){
+ isShowTaxonAssociation = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey());
+ }
+
+ } else {
+ isShowTaxonAssociation = Boolean.valueOf(showTaxonAssociation.getValue());
+
+ }
+
+ } else {
+ if(!overrideShowTaxonAssociation){
+ isShowTaxonAssociation = null;
+ }else{
+ isShowTaxonAssociation = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey(), true);
+ }
showTaxonAssociation = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowTaxonAssociations, PreferencePredicate.ShowTaxonAssociations.getDefaultValue() != null ? PreferencePredicate.ShowTaxonAssociations.getDefaultValue().toString(): null);
}
+
allowOverrideShowTaxonAssociation = showTaxonAssociation != null ? showTaxonAssociation.isAllowOverride():true;
- isShowLifeForm = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowLifeForm.getKey());
+
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowLifeForm);
- showLifeForm = cache.findBestMatching(key);
- if (showLifeForm == null){
+ showLifeForm = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowLifeForm);
+ overrideShowLifeForm = PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowLifeForm.getKey()), true);
+ if (showLifeForm != null) {
+ if (showLifeForm.isAllowOverride() ) {
+ if (overrideShowLifeForm){
+ isShowLifeForm = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowLifeForm.getKey());
+ }
+
+ } else {
+ isShowLifeForm = Boolean.valueOf(showLifeForm.getValue());
+
+ }
+
+ } else {
+ if(!overrideShowLifeForm){
+ isShowLifeForm = null;
+ }else{
+ isShowLifeForm = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowLifeForm.getKey(), true);
+ }
showLifeForm = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowLifeForm, PreferencePredicate.ShowLifeForm.getDefaultValue() != null ? PreferencePredicate.ShowLifeForm.getDefaultValue().toString(): null);
}
+
allowOverrideShowLifeForm = showLifeForm != null ? showLifeForm.isAllowOverride():true;
@Override
public boolean performOk() {
- if (allowOverrideShowSpecimenRelatedIssues){
- PreferencesUtil.setBooleanValue(PreferencePredicate.ShowSpecimen.getKey(), isShowSpecimenRelatedIssues);
- boolean test = isShowSpecimenRelatedIssues != Boolean.parseBoolean(showSpecimenPref.getValue());
- PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowSpecimen.getKey()), isShowSpecimenRelatedIssues != Boolean.parseBoolean(showSpecimenPref.getValue()));
+
+ boolean override = false;
+ if (isShowSpecimenRelatedIssues != null ) {
+ override = true;
+ PreferencesUtil.setStringValue(PreferencePredicate.ShowSpecimen.getKey(), isShowSpecimenRelatedIssues.toString());
}
- if (allowOverrideShowCollectingAreaInGeneralSection){
- PreferencesUtil.setBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), isShowCollectingAreaInGeneralSection);
- PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), isShowCollectingAreaInGeneralSection != Boolean.parseBoolean(showCollectingAreaInGeneralSection.getValue()));
+ PreferencesUtil.setBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowSpecimen.getKey()),
+ override);
+
+ override = false;
+ if (isShowCollectingAreaInGeneralSection != null ) {
+ override = true;
+ PreferencesUtil.setStringValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), isShowCollectingAreaInGeneralSection.toString());
}
- if (allowOverrideDeterminationOnlyForFieldUnits){
- PreferencesUtil.setBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey(), isDeterminationOnlyForFieldUnits);
- PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), isDeterminationOnlyForFieldUnits != Boolean.parseBoolean(showDeterminationOnlyForFieldUnits.getValue()));
+ PreferencesUtil.setBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()),
+ override);
+
+ override = false;
+ if (isDeterminationOnlyForFieldUnits != null ) {
+ override = true;
+ PreferencesUtil.setStringValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey(), isDeterminationOnlyForFieldUnits.toString());
}
- if (allowOverrideShowTaxonAssociation){
- PreferencesUtil.setBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey(), isShowTaxonAssociation);
- PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowTaxonAssociations.getKey()), isShowTaxonAssociation != Boolean.parseBoolean(showTaxonAssociation.getValue()));
+ PreferencesUtil.setBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()),
+ override);
+
+ override = false;
+ if (isShowTaxonAssociation != null ) {
+ override = true;
+ PreferencesUtil.setStringValue(PreferencePredicate.ShowTaxonAssociations.getKey(), isShowTaxonAssociation.toString());
}
- if (allowOverrideShowLifeForm){
- PreferencesUtil.setBooleanValue(PreferencePredicate.ShowLifeForm.getKey(), isShowLifeForm);
- PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowLifeForm.getKey()), isShowLifeForm != Boolean.parseBoolean(showLifeForm.getValue()));
+ PreferencesUtil.setBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowTaxonAssociations.getKey()),
+ override);
+
+ override = false;
+ if (isShowLifeForm != null ) {
+ override = true;
+ PreferencesUtil.setStringValue(PreferencePredicate.ShowLifeForm.getKey(), isShowLifeForm.toString());
}
+ PreferencesUtil.setBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowLifeForm.getKey()),
+ override);
+
return true;
}
@Override
public void widgetSelected(SelectionEvent e) {
setApply(true);
- if (e.getSource().equals(showSpecimenButton)){
+ if (e.getSource().equals(this.showSpecimenButton)) {
String text = showSpecimenButton.getText();
- text = text.replace(Messages.Preference_Use_Default, "");
+ if(text.equals(Messages.Preference_Use_Default)){
+ isShowSpecimenRelatedIssues = null;
+ if (isAdminPreference){
+ allowOverrideIsShowSpecimenRelatedIssuesButton.setSelection(true);
+ }
+ return;
+ }
if (text.equals(Messages.GeneralPreference_yes)){
isShowSpecimenRelatedIssues = true;
}else{
isShowSpecimenRelatedIssues = false;
}
}
- if (e.getSource().equals(showCollectingAreaInGeneralSectionButton)){
+
+ if (e.getSource().equals(this.showCollectingAreaInGeneralSectionButton)) {
String text = showCollectingAreaInGeneralSectionButton.getText();
- text = text.replace(" (Use default)", "");
+ if(text.equals(Messages.Preference_Use_Default)){
+ isShowCollectingAreaInGeneralSection = null;
+ if (isAdminPreference){
+ //showCollectingAreaInGeneralSection.setAllowOverride(true);
+ allowOverrideShowCollectingAreaButton.setSelection(true);
+ }
+ return;
+ }
if (text.equals(Messages.GeneralPreference_yes)){
isShowCollectingAreaInGeneralSection = true;
}else{
}
}
- if (e.getSource().equals(determinationOnlyForFieldUnitsButton)){
+ if (e.getSource().equals(this.determinationOnlyForFieldUnitsButton)) {
String text = determinationOnlyForFieldUnitsButton.getText();
- text = text.replace(" (Use default)", "");
+ if(text.equals(Messages.Preference_Use_Default)){
+ isDeterminationOnlyForFieldUnits = null;
+ if (isAdminPreference){
+ //showDeterminationOnlyForFieldUnits.setAllowOverride(true);
+ allowOverridesDeterminationOnlyForFieldUnitsButton.setSelection(true);
+ }
+ return;
+ }
if (text.equals(Messages.GeneralPreference_yes)){
isDeterminationOnlyForFieldUnits = true;
}else{
isDeterminationOnlyForFieldUnits = false;
}
}
- if (e.getSource().equals(showTaxonAssociationButton)){
+
+ if (e.getSource().equals(this.showTaxonAssociationButton)) {
String text = showTaxonAssociationButton.getText();
- text = text.replace(" (Use default)", "");
+ if(text.equals(Messages.Preference_Use_Default)){
+ isShowTaxonAssociation = null;
+ if (isAdminPreference){
+ //showTaxonAssociation.setAllowOverride(true);
+ allowOverrideIsShowTaxonAssociationButton.setSelection(true);
+ }
+ return;
+ }
if (text.equals(Messages.GeneralPreference_yes)){
isShowTaxonAssociation = true;
}else{
isShowTaxonAssociation = false;
}
}
- if (e.getSource().equals(showLifeFormButton)){
+
+ if (e.getSource().equals(this.showLifeFormButton)) {
String text = showLifeFormButton.getText();
- text = text.replace(" (Use default)", "");
+ if(text.equals(Messages.Preference_Use_Default)){
+ isShowLifeForm = null;
+ if (isAdminPreference){
+ //showLifeForm.setAllowOverride(true);
+ allowOverrideShowLifeFormButton.setSelection(true);
+ }
+ return;
+ }
if (text.equals(Messages.GeneralPreference_yes)){
isShowLifeForm = true;
}else{
isShowLifeForm = false;
}
}
+
}
/**
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
-import eu.etaxonomy.cdm.model.metadata.CdmPreference;
import eu.etaxonomy.cdm.model.metadata.IKeyLabel;
import eu.etaxonomy.cdm.model.metadata.IPreferencePredicate;
import eu.etaxonomy.taxeditor.l10n.Messages;
*/
public abstract class CdmPreferencePage extends PreferencePage implements IE4PreferencePage {
- private boolean isApply = false;
+
private boolean isDefaultButtonActivated = true;
protected boolean isAdminPreference;
+ private boolean isApply;
+
+
public CdmPreferencePage() {
this(null, null);
return allowOverrideCheckButton;
}
+ @Override
public boolean isApply() {
return isApply;
}
Combo booleanCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
- CdmPreference dbPref = PreferencesUtil.getPreferenceFromDB(predicate);
- boolean defaultValue = true;
- if (dbPref != null && !isAdminPage){
- defaultValue = Boolean.valueOf(dbPref.getValue());
- }else{
- defaultValue = (Boolean)predicate.getDefaultValue();
- }
- if (defaultValue){
- booleanCombo.add(textTrue + Messages.Preference_Use_Default);
- booleanCombo.add(textFalse);
- }else{
+// CdmPreference dbPref = PreferencesUtil.getPreferenceFromDB(predicate);
+// boolean defaultValue = true;
+// if (dbPref != null && !isAdminPage){
+// defaultValue = Boolean.valueOf(dbPref.getValue());
+// }else{
+// defaultValue = (Boolean)predicate.getDefaultValue();
+// }
+// if (defaultValue){
+ booleanCombo.add(Messages.Preference_Use_Default);
booleanCombo.add(textTrue);
- booleanCombo.add(textFalse + Messages.Preference_Use_Default);
- }
+ booleanCombo.add(textFalse);
+// }else{
+//
+// booleanCombo.add(textFalse + Messages.Preference_Use_Default);
+// }
return booleanCombo;
}
Combo booleanCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
- CdmPreference dbPref = PreferencesUtil.getPreferenceFromDB(predicate);
- String defaultValue = null;
- if (dbPref != null && !isAdminPage){
- defaultValue = dbPref.getValue() != null? dbPref.getValue().toString():null ;
- }else{
- Object defaultObject = predicate.getDefaultValue();
- if (defaultObject != null){
- if (defaultObject instanceof IKeyLabel){
- defaultValue = ((IKeyLabel)defaultObject).getKey();
- }else{
- defaultValue = predicate.getDefaultValue().toString();
- }
- }
-
- }
-
+// CdmPreference dbPref = PreferencesUtil.getPreferenceFromDB(predicate);
+// String defaultValue = null;
+// if (dbPref != null && !isAdminPage){
+// defaultValue = dbPref.getValue() != null? dbPref.getValue().toString():null ;
+// }else{
+// Object defaultObject = predicate.getDefaultValue();
+// if (defaultObject != null){
+// if (defaultObject instanceof IKeyLabel){
+// defaultValue = ((IKeyLabel)defaultObject).getKey();
+// }else{
+// defaultValue = predicate.getDefaultValue().toString();
+// }
+// }
+//
+// }
+ booleanCombo.add(Messages.Preference_Use_Default);;
for (IKeyLabel value: enumValues){
- if (defaultValue.equals(value.getKey())){
- booleanCombo.add(value.getLabel() + Messages.Preference_Use_Default);
- }else{
- booleanCombo.add(value.getLabel());
- }
+ booleanCombo.add(value.getLabel());
}
return booleanCombo;
*
*/
public abstract class FieldEditorPreferencePageE4 extends FieldEditorPreferencePage implements IE4PreferencePage{
+ boolean isApply = false;
public FieldEditorPreferencePageE4() {
init();
setPreferenceStore(PreferencesUtil.getPreferenceStore());
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isApply() {
+ return isApply;
+ }
--- /dev/null
+/**
+* Copyright (C) 2019 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.preference.menu;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.term.TermType;
+import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
+import eu.etaxonomy.taxeditor.l10n.Messages;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author k.luther
+ * @since 14.05.2019
+ *
+ */
+public class NameFeatureMenuPreference extends AbstractMenuPreferences<Feature> {
+ /** Constant <code>PLUGIN_ID="eu.etaxonomy.taxeditor.preferences.feat"{trunked}</code> */
+ public static final String PLUGIN_ID = "eu.etaxonomy.taxeditor.preferences.nameFeature"; //$NON-NLS-1$
+
+ /**
+ * <p>Constructor for FeatureMenuPreferences.</p>
+ */
+ public NameFeatureMenuPreference() {
+ super("Name Feature Preferences", //$NON-NLS-1$
+ Messages.FeatureMenuPreferences_display,
+ false);
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.preference.menu.AbstractMenuPreferences#getTermClass()
+ */
+ /** {@inheritDoc} */
+ @Override
+ protected TermType getTermType() {
+ return TermType.Feature;
+ }
+ @Override
+ protected List<Feature> getTerms(){
+ if(CdmStore.isActive() ){
+ List<Feature> termList = new ArrayList(TermEditorInput.getDefaultNameFeatureTree().getDistinctFeatures());
+ return termList;
+ }
+ return new ArrayList<Feature>();
+ }
+}
*/
public class NomenclaturalCodePreferences extends FieldEditorPreferencePageE4 {
CdmPreference pref;
+
@Override
protected void createFieldEditors() {
PreferencesUtil.setPreferredNomenclaturalCode(null, false);
+ isApply = true;
if (pref.isAllowOverride()) {
addField(new ComboFieldEditor(
PreferencesUtil.createPreferenceString(PreferencePredicate.NomenclaturalCode.getKey()),
@Override
public boolean performOk() {
-
+ if (!isApply()){
+ return true;
+ }
boolean result = super.performOk();
String value = pref.getValue();
String test = PreferencesUtil.getStringValue(PreferencePredicate.NomenclaturalCode.getKey(), true);
setWindowTitle(Messages.AvailableDistributionStatusWizard_WIZARD_TITLE);
// TODO if preferenceStore has elements checked load elements in wizard
prefs = PreferencesUtil.getPreferencesFromDB(PreferencePredicate.AvailableDistributionStatus);
- if (prefs == null) {
+ if (prefs == null || prefs.isEmpty()) {
prefs = new ArrayList();
+ prefs.add(CdmPreference.NewTaxEditorInstance(PreferencePredicate.AvailableDistributionStatus, null));
}
aPage = new AvailableDistributionPerAreaStatusPage(Messages.AvailableDistributionStatusWizard_PAGE_TITLE, prefs, false);
private Map<Object, List> cachedTermMap = new HashMap<>();
+ //new cache for features!!
+ //dinstinguish preferences for both
+ //load at start
+
public TermManager(){
}