}
if (configurator != null){
String configString = configurator.toString();
-
+ Abcd206ImportConfigurator defaultConfig = Abcd206ImportConfigurator.NewInstance(null,null);
+ if (configString.equals(defaultConfig.toString())){
+ configString = null;
+ }
CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AbcdImportConfig, configString);
pref.setAllowOverride(allowOverride);
NameDetailsConfigurator config = createNameDetailsViewConfig();
String value = config.toString();
-
+ if (config.isAllowOverride() && !config.isSimpleDetailsViewActivated()){
+ // is default, should delete from db
+ value = null;
+ }
CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.NameDetailsView, value);
pref.setAllowOverride(isAllowOverride);
service.set(pref);
isAllowOverride = pref.isAllowOverride();
CdmPreferenceCache cache = CdmPreferenceCache.instance();
cache.put(pref);
+ }else {
+ isAllowOverride = true;
}
*/
public class NomenclaturalCodePreferences extends CdmPreferencePage implements IE4AdminPreferencePage{
- String actualCode = null;
- Map<String, String> labelAndValues;
- Map<String, Integer> keyAndIndex;
+ NomenclaturalCode actualCode = null;
+ Map<NomenclaturalCode, String> labelAndValues;
+ Map<NomenclaturalCode, Integer> keyAndIndex;
Combo nomenclaturalCode;
Button allowOverrideButton;
boolean allowOverride;
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
CdmPreference pref = service.find(key);
if (pref != null){
- actualCode = pref.getValue();
+ actualCode = NomenclaturalCode.fromString(pref.getValue());
allowOverride = pref.isAllowOverride();
}else{
- actualCode = PreferencesUtil.getPreferenceKey(PreferencesUtil.getPreferredNomenclaturalCode());
+ actualCode = NomenclaturalCode.fromString(PreferencePredicate.NomenclaturalCode.getDefaultValue().toString());
allowOverride = true;
}
getLabelAndValues();
keyAndIndex = new HashMap<>();
Integer index = 0;
- for (String key: labelAndValues.keySet()) {
+ for (NomenclaturalCode key: labelAndValues.keySet()) {
nomenclaturalCode.add(labelAndValues.get(key));
keyAndIndex.put(key, index);
index++;
public void widgetSelected(SelectionEvent evt) {
setApply(true);
String name = nomenclaturalCode.getText();
- for (Entry<String, String> label:labelAndValues.entrySet()){
+ for (Entry<NomenclaturalCode, String> label:labelAndValues.entrySet()){
if (label.getValue().equals(name)){
actualCode = label.getKey();
}
/**
* @return
*/
- private Map<String, String> getLabelAndValues() {
+ private Map<NomenclaturalCode, String> getLabelAndValues() {
List<NomenclaturalCode> supportedCodes = NomenclaturalCodeHelper
.getSupportedCodes();
labelAndValues = new HashMap<>();
for (int i = 0; i < supportedCodes.size(); i++) {
- labelAndValues.put(PreferencesUtil.getPreferenceKey(supportedCodes.get(i)), NomenclaturalCodeHelper
+ labelAndValues.put(supportedCodes.get(i), NomenclaturalCodeHelper
.getDescription(supportedCodes.get(i))) ;
}
@Override
public boolean performOk() {
if (actualCode != null){
- CdmPreference pref = CdmPreference.NewDatabaseInstance(PreferencePredicate.NomenclaturalCode, actualCode);
+ CdmPreference pref = CdmPreference.NewDatabaseInstance(PreferencePredicate.NomenclaturalCode, actualCode.toString());
pref.setAllowOverride(allowOverride);
PreferencesUtil.setPreferredNomenclaturalCode(pref);
}
@Override
protected void performDefaults() {
- actualCode = PreferencePredicate.NomenclaturalCode.getDefaultValue().toString();
+ actualCode = (NomenclaturalCode)PreferencePredicate.NomenclaturalCode.getDefaultValue();
allowOverride = true;
Integer index = keyAndIndex.get(actualCode);
if(index!=null){
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
import eu.etaxonomy.cdm.model.metadata.PublishEnum;
+import eu.etaxonomy.taxeditor.l10n.Messages;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.preference.PublishFlagLocalPreference;
import eu.etaxonomy.taxeditor.store.CdmStore;
return true;
}
String text = publishFlagBehaviour.getText();
+ text = text.replace(Messages.Preference_Use_Default, "");
for (PublishEnum display: PublishEnum.values()){
if (display.getLabel().equals(text)){
text = display.getKey();
public static String TermOrder_natural;
public static String ChecklistEditorGeneralPreference_Configure_area_order;
+ public static String Preference_Use_Default;
static {
TermOrder_natural=Natural
ChecklistEditorGeneralPreference_Configure_area_order=Order of Areas
+Preference_Use_Default= (Use Default)
PreferencesUtil.setBooleanValue(PreferencePredicate.DistributionEditorActivated.getKey(),
isEditorActivated);
-
+ boolean override = false;
if (distributionEditorPref == null
|| isEditorActivated != Boolean.parseBoolean(distributionEditorPref.getValue())) {
- PreferencesUtil.setBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()),
- true);
+ override = true;
}
+ PreferencesUtil.setBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()),
+ override);
PreferencesUtil.setSortNamedAreasInDistributionEditor(orderAreas);
+ override = false;
if (prefAreaSort == null || orderAreas != prefAreaSort.getValue()) {
- PreferencesUtil.setBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()),
- true);
+ override = true;
}
+ PreferencesUtil.setBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()),
+ override);
PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
+ override = false;
if (prefRank == null || isShowRank != Boolean.parseBoolean(prefRank.getValue())) {
- PreferencesUtil.setBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()),
- true);
+ override = true;
}
+ PreferencesUtil.setBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()),
+ true);
PreferencesUtil.setDisplayStatusInChecklistEditor(displayStatus);
+ override = false;
if (prefStatusDisplay == null || displayStatus != prefStatusDisplay.getValue()) {
- PreferencesUtil.setBooleanValue(
- PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()),
- true);
+ override = true;
}
+ PreferencesUtil.setBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()),
+ true);
PreferencesUtil.setAreaDisplayInChecklistEditor(displayArea);
+ override = false;
if (prefAreaDisplay == null || displayArea != prefAreaDisplay.getValue()) {
- PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(
- PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), overrideAreaDisplay);
+ override = true;
}
+ PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(
+ PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), overrideAreaDisplay);
PreferencesUtil.setOwnDescriptionForChecklistEditor(ownDescriptionForDistributionEditor);
PreferencesUtil.setBooleanValue(
PreferencesUtil.prefOverrideKey(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey()),
}
if (e.getSource().equals(this.activateRankCombo)) {
String text = activateRankCombo.getText();
- text = text.replace(" (Default)", "");
+ text = text.replace(Messages.Preference_Use_Default, "");
if (text.equals(SHOW_RANK)){
isShowRank = true;
}else{
public void widgetSelected(SelectionEvent e) {
if (e.getSource().equals(this.showIOMenuButton)) {
String text = showIOMenuButton.getText();
- text = text.replace(" (Default)", "");
+ text = text.replace(Messages.Preference_Use_Default, "");
if (text.equals(SHOW)){
isShowIOMenu = true;
}else{
}
if (e.getSource().equals(this.showChecklistPerspectiveButton)) {
String text = showChecklistPerspectiveButton.getText();
- text = text.replace(" (Default)", "");
+ text = text.replace(Messages.Preference_Use_Default, "");
if (text.equals(SHOW)){
isShowCheckListPerspective = true;
}else{
}
if (e.getSource().equals(this.showTaxonNodeWizardButton)) {
String text = showTaxonNodeWizardButton.getText();
- text = text.replace(" (Default)", "");
+ text = text.replace(Messages.Preference_Use_Default, "");
if (text.equals(SHOW)){
isShowTaxonNodeWizard = true;
}else{
isShowTaxonNodeWizard = false;
}
}
+ this.setApply(true);
}
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
protected NameDetailsConfigurator nameDetailsConfig;
Composite localSettings ;
+ CdmPreference nameDetailsPref;
protected boolean isShowTaxon;
protected boolean isShowNameApprobiation ;
private Button showSecDetail;
private Button secEnabled;
- protected Button activateCheckButton;
+ protected Combo activateCheckButton;
protected Button allowLocalPreference;
protected Button showTaxon;
protected Button showLsid;
nameDetailsConfig = new NameDetailsConfigurator(false);
}
- activateCheckButton = new Button(title, SWT.CHECK);
- allowLocalPreference = createAllowOverrideButton(title);
+ activateCheckButton = createBooleanCombo(title, "Enable", "Disable", PreferencePredicate.SimpleDetailsViewActivated, Messages.NameDetailsViewConfiguration_activateSimpleDetailsView, isAdminPreference);
+ if (isAdminPreference){
+ allowLocalPreference = createAllowOverrideButton(title);
+
+ allowLocalPreference.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setApply(true);
+ if (isAdminPreference){
+ isAllowOverride = allowLocalPreference.getSelection();
+ }else{
+ isOverride = allowLocalPreference.getSelection();
+ }
+
+ }
+ });
+
+ }
Composite dbSettings = new Composite(parent, SWT.NONE);
- activateCheckButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
- activateCheckButton.setText(Messages.NameDetailsViewConfiguration_activateSimpleDetailsView);
+// 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.getSelection();
+ isSimpleDetailsViewActivated = activateCheckButton.getSelectionIndex() == 0? true:false;
nameDetailsConfig.setSimpleDetailsViewActivated(isSimpleDetailsViewActivated);
dbSettings.setEnabled(isSimpleDetailsViewActivated);
PreferencesUtil.recursiveSetEnabled(dbSettings, isSimpleDetailsViewActivated);
});
- allowLocalPreference.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- if (isAdminPreference){
- isAllowOverride = allowLocalPreference.getSelection();
- }else{
- isOverride = allowLocalPreference.getSelection();
- }
-
- }
- });
-
dbSettings.setLayout(new GridLayout());
dbSettings.setEnabled(isSimpleDetailsViewActivated);
public boolean performOk() {
if (nameDetailsConfig != null){
PreferencesUtil.setStringValue(PreferencePredicate.NameDetailsView.getKey(), nameDetailsConfig.toString());
- PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.NameDetailsView.getKey()), isOverride);
+ if (nameDetailsPref == null || !nameDetailsConfig.toString().equals(nameDetailsPref.getValue())) {
+ PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.NameDetailsView.getKey()), true);
+ }
}
return true;
@Override
public void getValues(){
if (nameDetailsConfig == null){
- CdmPreference nameDetailsPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.NameDetailsView);
+ nameDetailsPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.NameDetailsView);
isAdminPreference = false;
isAllowOverride = true;
if (nameDetailsPref != null){
}
protected void setButtonSelections(){
- activateCheckButton.setSelection(isSimpleDetailsViewActivated);;
+ int index = isSimpleDetailsViewActivated?0:1;
+ activateCheckButton.select(index);
if (isAdminPreference){
allowLocalPreference.setSelection(isAllowOverride);
- }else{
- allowLocalPreference.setSelection(isOverride);
}
showTaxon.setSelection(isShowTaxon);
showLsid.setSelection(isShowLSID);
*
*
**/
- public static int getIntValue(String name) {
+ public static int getIntValue(String name, boolean local) {
CdmPreference pref= getDBPreferenceValue(name);
String prefValue = null;
if (pref != null){
}catch(NumberFormatException e){
logger.debug("Preference value of " + name + " is not a number");
}
- if (result == null){
+
+ String overrideKey = createPreferenceString(createOverridePreferenceString(name));
+ boolean override = true;
+ if (getPreferenceStore().contains(overrideKey)){
+ override = getPreferenceStore().getBoolean(overrideKey);
+ }
+ if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
String dbSpecific = prefKey(name);
if (getPreferenceStore().contains(dbSpecific)){
result = getPreferenceStore().getInt(dbSpecific);
}
return result;
-
}
public static boolean getBooleanValue(String name) {
public static boolean getBooleanValue(String name, boolean local) {
if (CdmStore.isActive()){
CdmPreference pref = getDBPreferenceValue(name);
- String prefValue = null;
- if (pref == null || local){
+
+ String overrideKey = createPreferenceString(createOverridePreferenceString(name));
+ boolean override = true;
+ if (getPreferenceStore().contains(overrideKey)){
+ override = getPreferenceStore().getBoolean(overrideKey);
+ }
+ if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
String dbSpecific = prefKey(name);
- if (getPreferenceStore().contains(dbSpecific)){
- return getPreferenceStore().getBoolean(dbSpecific);
- }else{
- return getPreferenceStore().
- getBoolean(name);
- }
- }else{
+ return getPreferenceStore().getBoolean(dbSpecific);
+ }else{
return Boolean.valueOf(pref.getValue());
}
*
*
**/
- public static float getFloatValue(String name) {
+ public static float getFloatValue(String name, boolean local) {
CdmPreference pref = getDBPreferenceValue(name);
String prefValue = null;
if (pref != null){
}catch(NumberFormatException e){
logger.debug("Preference value of " + name + " is not a number");
}
- if (result == null){
+ String overrideKey = createPreferenceString(createOverridePreferenceString(name));
+ boolean override = true;
+ if (getPreferenceStore().contains(overrideKey)){
+ override = getPreferenceStore().getBoolean(overrideKey);
+ }
+ if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
String dbSpecific = prefKey(name);
if (getPreferenceStore().contains(dbSpecific)){
result = getPreferenceStore().getFloat(dbSpecific);
getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowIdInSource.getKey()), Boolean.valueOf(PreferencePredicate.ShowIdInSource.getDefaultValue().toString()));
getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DisableMultiClassification.getKey()), Boolean.valueOf(PreferencePredicate.DisableMultiClassification.getDefaultValue().toString()));
getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowImportExportMenu.getKey()), Boolean.valueOf(PreferencePredicate.ShowImportExportMenu.getDefaultValue().toString()));
+ getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowSpecimen.getKey()), Boolean.valueOf(PreferencePredicate.ShowSpecimen.getDefaultValue().toString()));
}
}else{
value = getStringValue(PreferencePredicate.NameDetailsView.getKey(), local);
}
- String [] sections = value.split(";");
- Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
- String[] sectionValues;
- for (String sectionValue: sections){
- sectionValues = sectionValue.split(":");
- sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
- }
-
- config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
-
- config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
-
- config.setSecDetailsActivated(getValue(sectionMap, "taxon.SecDetails"));
- config.setSecEnabled(getValue(sectionMap, "taxon.SecEnabled"));
-
- config.setLSIDActivated(getValue(sectionMap, "lsid"));
-
- config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
-
- config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
-
- config.setRankActivated(getValue(sectionMap, "rank"));
-
- config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
-
- config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
-
- config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
-
- config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
-
- config.setProtologueActivated(getValue(sectionMap,"protologue"));
-
- config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
-
- config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
-
+ if (value!= null){
+ String [] sections = value.split(";");
+ Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
+ String[] sectionValues;
+ for (String sectionValue: sections){
+ sectionValues = sectionValue.split(":");
+ sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
+ }
+ config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
+ config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
+ config.setSecDetailsActivated(getValue(sectionMap, "taxon.SecDetails"));
+ config.setSecEnabled(getValue(sectionMap, "taxon.SecEnabled"));
+ config.setLSIDActivated(getValue(sectionMap, "lsid"));
+ config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
+ config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
+ config.setRankActivated(getValue(sectionMap, "rank"));
+ config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
+ config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
+ config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
+ config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
+ config.setProtologueActivated(getValue(sectionMap,"protologue"));
+ config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
+ config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
config.setHybridActivated(getValue(sectionMap,"hybrid"));
-
+ }
return config;
}
}
}
PreferencesUtil.setStringValue(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey(), text);
- PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey()), allowOverride);
+ if (pref == null || !pref.getValue().equals(text)){
+ PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey()), true);
+ }else{
+ PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey()), false);
+ }
}
return true;
}
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
* @date 13.02.2014
*
*/
-public class SpecimenOrObservationPreferences extends CdmPreferencePage {
+public class SpecimenOrObservationPreferences extends CdmPreferencePage implements SelectionListener{
private static final String LOCAL_SETTINGS_NOT_ALLOWED = Messages.SpecimenOrObservationPreferences_0;
private static final String DESCRIPTION = Messages.SpecimenOrObservationPreferences_1;
protected boolean overrideShowLifeForm;
Composite composite;
- protected Button showSpecimenButton;
+ protected Combo showSpecimenButton;
protected Button allowOverrideIsShowSpecimenRelatedIssuesButton;
- protected Button showCollectingAreaInGeneralSectionButton;
+ protected Combo showCollectingAreaInGeneralSectionButton;
protected Button allowOverrideShowCollectingAreaButton;
- protected Button determinationOnlyForFieldUnitsButton;
+ protected Combo determinationOnlyForFieldUnitsButton;
protected Button allowOverridesDeterminationOnlyForFieldUnitsButton;
- protected Button showTaxonAssociationButton;
+ protected Combo showTaxonAssociationButton;
protected Button allowOverrideIsShowTaxonAssociationButton;
protected Button allowOverrideShowLifeFormButton;
- protected Button showLifeFormButton;
+ protected Combo showLifeFormButton;
+ CdmPreference showSpecimenPref;
+ CdmPreference showCollectingAreaInGeneralSection;
+ CdmPreference showDeterminationOnlyForFieldUnits;
+ CdmPreference showTaxonAssociation;
+ CdmPreference showLifeForm;
@Override
public void init() {
Label separator= new Label(titleComp, SWT.HORIZONTAL | SWT.SEPARATOR);
separator.setLayoutData(gridData);
separator.setVisible(false);
- showSpecimenButton = new Button(titleComp, SWT.CHECK);
-
- showSpecimenButton.setText(Messages.DatabasePreferncesPage_Show_Specimen);
-
- showSpecimenButton.setSelection(isShowSpecimenRelatedIssues);
- showSpecimenButton.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- isShowSpecimenRelatedIssues = showSpecimenButton.getSelection();
-// if(isShowSpecimenRelatedIssues){
-// //composite.setVisible(true);
-// composite.setEnabled(true);
-// }else{
-// //composite.setVisible(false);
-// composite.setEnabled(false);
-// }
- }
- });
- allowOverrideIsShowSpecimenRelatedIssuesButton = createAllowOverrideButton(titleComp);
+ 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);
+ }
if (isAdminPreference){
+ allowOverrideIsShowSpecimenRelatedIssuesButton = createAllowOverrideButton(titleComp);
allowOverrideIsShowSpecimenRelatedIssuesButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
allowOverrideIsShowSpecimenRelatedIssuesButton.addSelectionListener(new SelectionAdapter(){
@Override
allowOverrideShowSpecimenRelatedIssues = allowOverrideIsShowSpecimenRelatedIssuesButton.getSelection();
}
});
- }else{
- allowOverrideIsShowSpecimenRelatedIssuesButton.setSelection(overrideShowSpecimenRelatedIssues);
- allowOverrideIsShowSpecimenRelatedIssuesButton.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- overrideShowSpecimenRelatedIssues = allowOverrideIsShowSpecimenRelatedIssuesButton.getSelection();
- }
- });
- if (!allowOverrideShowSpecimenRelatedIssues){
- showSpecimenButton.setEnabled(false);
- allowOverrideIsShowSpecimenRelatedIssuesButton.setEnabled(false);
- }
}
+
composite = createComposite(parent);
//composite.setEnabled(isShowSpecimenRelatedIssues);
gridData = createTextGridData();
separator= new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
separator.setLayoutData(gridData);
- showCollectingAreaInGeneralSectionButton = new Button(composite, SWT.CHECK);
-
- showCollectingAreaInGeneralSectionButton.setText(Messages.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section);
+ showCollectingAreaInGeneralSectionButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowCollectingAreasInGeneralSection, Messages.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section, isAdminPreference);
- showCollectingAreaInGeneralSectionButton.setSelection(isShowCollectingAreaInGeneralSection);
- showCollectingAreaInGeneralSectionButton.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- isShowCollectingAreaInGeneralSection = showCollectingAreaInGeneralSectionButton.getSelection();
-
- }
- });
- allowOverrideShowCollectingAreaButton = createAllowOverrideButton(composite);
+ showCollectingAreaInGeneralSectionButton.addSelectionListener(this);
+ if (isShowCollectingAreaInGeneralSection){
+ showCollectingAreaInGeneralSectionButton.select(0);
+ }else{
+ showCollectingAreaInGeneralSectionButton.select(1);
+ }
if (isAdminPreference){
+ allowOverrideShowCollectingAreaButton = createAllowOverrideButton(composite);
allowOverrideShowCollectingAreaButton.setSelection(allowOverrideShowCollectingAreaInGeneralSection);
allowOverrideShowCollectingAreaButton.addSelectionListener(new SelectionAdapter(){
@Override
allowOverrideShowCollectingAreaInGeneralSection = allowOverrideShowCollectingAreaButton.getSelection();
}
});
- }else{
- allowOverrideShowCollectingAreaButton.setSelection(overrideShowCollectionAreaInGeneralSection);
- allowOverrideShowCollectingAreaButton.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- overrideShowCollectionAreaInGeneralSection = allowOverrideShowCollectingAreaButton.getSelection();
- }
- });
- if (!allowOverrideShowCollectingAreaInGeneralSection){
- showCollectingAreaInGeneralSectionButton.setEnabled(false);
- allowOverrideShowCollectingAreaButton.setEnabled(false);
- }
}
- determinationOnlyForFieldUnitsButton = new Button(composite, SWT.CHECK);
- determinationOnlyForFieldUnitsButton.setText(Messages.DatabasePreferncesPage_Determination_only_for_field_unnits);
- determinationOnlyForFieldUnitsButton.setSelection(isDeterminationOnlyForFieldUnits);
- determinationOnlyForFieldUnitsButton.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- isDeterminationOnlyForFieldUnits = determinationOnlyForFieldUnitsButton.getSelection();
- }
- });
+ 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);
+ }
- allowOverridesDeterminationOnlyForFieldUnitsButton = createAllowOverrideButton(composite);
if (isAdminPreference){
+ allowOverridesDeterminationOnlyForFieldUnitsButton = createAllowOverrideButton(composite);
allowOverridesDeterminationOnlyForFieldUnitsButton.setSelection(allowOverrideDeterminationOnlyForFieldUnits);
allowOverridesDeterminationOnlyForFieldUnitsButton.addSelectionListener(new SelectionAdapter(){
@Override
allowOverrideDeterminationOnlyForFieldUnits = allowOverridesDeterminationOnlyForFieldUnitsButton.getSelection();
}
});
- }else{
- allowOverridesDeterminationOnlyForFieldUnitsButton.setSelection(overrideDeterminationOnlyForFieldUnits);
- allowOverridesDeterminationOnlyForFieldUnitsButton.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- overrideDeterminationOnlyForFieldUnits = allowOverridesDeterminationOnlyForFieldUnitsButton.getSelection();
- }
- });
- if (!allowOverrideDeterminationOnlyForFieldUnits){
- determinationOnlyForFieldUnitsButton.setEnabled(false);
- allowOverridesDeterminationOnlyForFieldUnitsButton.setEnabled(false);
- }
}
- showTaxonAssociationButton = new Button(composite, SWT.CHECK);
+ showTaxonAssociationButton =createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowTaxonAssociations, Messages.DatabasePreferncesPage_Taxon_Associations, isAdminPreference);
- showTaxonAssociationButton.setText(Messages.DatabasePreferncesPage_Taxon_Associations);
- showTaxonAssociationButton.setSelection(isShowTaxonAssociation);
- showTaxonAssociationButton.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- isShowTaxonAssociation = showTaxonAssociationButton.getSelection();
-
- }
- });
- allowOverrideIsShowTaxonAssociationButton = createAllowOverrideButton(composite);
+ showTaxonAssociationButton.addSelectionListener(this);
+ if (isShowTaxonAssociation){
+ showTaxonAssociationButton.select(0);
+ }else{
+ showTaxonAssociationButton.select(1);
+ }
if (isAdminPreference){
+ allowOverrideIsShowTaxonAssociationButton = createAllowOverrideButton(composite);
allowOverrideIsShowTaxonAssociationButton.setSelection(allowOverrideShowTaxonAssociation);
allowOverrideIsShowTaxonAssociationButton.addSelectionListener(new SelectionAdapter(){
@Override
allowOverrideShowTaxonAssociation = allowOverrideIsShowTaxonAssociationButton.getSelection();
}
});
- }else{
- allowOverrideIsShowTaxonAssociationButton.setSelection(overrideShowTaxonAssociation);
- allowOverrideIsShowTaxonAssociationButton.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- overrideShowTaxonAssociation = allowOverrideIsShowTaxonAssociationButton.getSelection();
- }
- });
- if (!allowOverrideShowTaxonAssociation){
- showTaxonAssociationButton.setEnabled(false);
- allowOverrideIsShowTaxonAssociationButton.setEnabled(false);
- }
}
- showLifeFormButton = new Button(composite, SWT.CHECK);
- showLifeFormButton.setText(Messages.DatabasePreferncesPage_Life_Form);
- showLifeFormButton.setSelection(isShowLifeForm);
- showLifeFormButton.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- isShowLifeForm = showLifeFormButton.getSelection();
+ 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);
+ }
- allowOverrideShowLifeFormButton = createAllowOverrideButton(composite);
if (isAdminPreference){
+ allowOverrideShowLifeFormButton = createAllowOverrideButton(composite);
allowOverrideShowLifeFormButton.setSelection(allowOverrideShowLifeForm);
allowOverrideShowLifeFormButton.addSelectionListener(new SelectionAdapter(){
@Override
allowOverrideShowLifeForm = allowOverrideShowLifeFormButton.getSelection();
}
});
- }else{
- allowOverrideShowLifeFormButton.setSelection(overrideShowLifeForm);
- //showLifeFormButton.setEnabled(overrideShowLifeForm);
- allowOverrideShowLifeFormButton.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e) {
- setApply(true);
- overrideShowLifeForm = allowOverrideShowLifeFormButton.getSelection();
- //showLifeFormButton.setEnabled(overrideShowLifeForm);
- }
- });
- if (!allowOverrideShowLifeForm){
- showLifeFormButton.setEnabled(false);
- allowOverrideShowLifeFormButton.setEnabled(false);
- }
}
if (!isEditingAllowed){
PreferencesUtil.recursiveSetEnabled(composite, false);
}
- // composite.setVisible(isShowSpecimenRelatedIssues);
- // composite.setEnabled(isShowSpecimenRelatedIssues);
+
return composite;
}
protected void getValues() {
CdmPreferenceCache cache = CdmPreferenceCache.instance();
- isShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimen.getKey(), true);
+ isShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimen.getKey());
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowSpecimen);
- CdmPreference showSpecimenPref = cache.findBestMatching(key);
+ showSpecimenPref = cache.findBestMatching(key);
+ if (showSpecimenPref == null){
+ showSpecimenPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, PreferencePredicate.ShowSpecimen.getDefaultValue() != null ? PreferencePredicate.ShowSpecimen.getDefaultValue().toString(): null);
+ }
allowOverrideShowSpecimenRelatedIssues = showSpecimenPref != null ? showSpecimenPref.isAllowOverride():true;
- overrideShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowSpecimen.getKey()), true);
+
isShowCollectingAreaInGeneralSection = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), true);
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection);
- CdmPreference showCollectingAreaInGeneralSection = cache.findBestMatching(key);
+ showCollectingAreaInGeneralSection = cache.findBestMatching(key);
+ if (showCollectingAreaInGeneralSection == null){
+ showCollectingAreaInGeneralSection = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowCollectingAreasInGeneralSection, PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue() != null ? PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue().toString(): null);
+ }
allowOverrideShowCollectingAreaInGeneralSection = showCollectingAreaInGeneralSection != null ? showCollectingAreaInGeneralSection.isAllowOverride():true;
- overrideShowCollectionAreaInGeneralSection = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), true);
+
isDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey());
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
- CdmPreference showDeterminationOnlyForFieldUnits = cache.findBestMatching(key);
+ showDeterminationOnlyForFieldUnits = cache.findBestMatching(key);
+ if (showDeterminationOnlyForFieldUnits == null){
+ showDeterminationOnlyForFieldUnits = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DeterminationOnlyForFieldUnits, PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue() != null ? PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue().toString(): null);
+ }
allowOverrideDeterminationOnlyForFieldUnits = showDeterminationOnlyForFieldUnits != null ? showDeterminationOnlyForFieldUnits.isAllowOverride():true;
- overrideDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), true);
isShowTaxonAssociation = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey());
- key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
- CdmPreference showTaxonAssociation = cache.findBestMatching(key);
+ key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonAssociations);
+ showTaxonAssociation = cache.findBestMatching(key);
+ if (showTaxonAssociation == null){
+ showTaxonAssociation = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowTaxonAssociations, PreferencePredicate.ShowTaxonAssociations.getDefaultValue() != null ? PreferencePredicate.ShowTaxonAssociations.getDefaultValue().toString(): null);
+ }
allowOverrideShowTaxonAssociation = showTaxonAssociation != null ? showTaxonAssociation.isAllowOverride():true;
- overrideShowTaxonAssociation = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowTaxonAssociations.getKey()), true);
isShowLifeForm = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowLifeForm.getKey());
- key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
- CdmPreference showLifeForm = cache.findBestMatching(key);
+ key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowLifeForm);
+ showLifeForm = cache.findBestMatching(key);
+ if (showLifeForm == null){
+ showLifeForm = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowLifeForm, PreferencePredicate.ShowLifeForm.getDefaultValue() != null ? PreferencePredicate.ShowLifeForm.getDefaultValue().toString(): null);
+ }
allowOverrideShowLifeForm = showLifeForm != null ? showLifeForm.isAllowOverride():true;
- overrideShowLifeForm = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowLifeForm.getKey()), true);
}
public boolean performOk() {
if (allowOverrideShowSpecimenRelatedIssues){
PreferencesUtil.setBooleanValue(PreferencePredicate.ShowSpecimen.getKey(), isShowSpecimenRelatedIssues);
- PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowSpecimen.getKey()), overrideShowSpecimenRelatedIssues);
+ boolean test = isShowSpecimenRelatedIssues != Boolean.parseBoolean(showSpecimenPref.getValue());
+ PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowSpecimen.getKey()), isShowSpecimenRelatedIssues != Boolean.parseBoolean(showSpecimenPref.getValue()));
}
if (allowOverrideShowCollectingAreaInGeneralSection){
PreferencesUtil.setBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), isShowCollectingAreaInGeneralSection);
- PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), overrideShowCollectionAreaInGeneralSection);
+ PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), isShowCollectingAreaInGeneralSection != Boolean.parseBoolean(showCollectingAreaInGeneralSection.getValue()));
}
if (allowOverrideDeterminationOnlyForFieldUnits){
PreferencesUtil.setBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey(), isDeterminationOnlyForFieldUnits);
- PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), overrideDeterminationOnlyForFieldUnits);
+ PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), isDeterminationOnlyForFieldUnits != Boolean.parseBoolean(showDeterminationOnlyForFieldUnits.getValue()));
}
if (allowOverrideShowTaxonAssociation){
PreferencesUtil.setBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey(), isShowTaxonAssociation);
- PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowTaxonAssociations.getKey()), overrideShowTaxonAssociation);
+ PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowTaxonAssociations.getKey()), isShowTaxonAssociation != Boolean.parseBoolean(showTaxonAssociation.getValue()));
}
if (allowOverrideShowLifeForm){
PreferencesUtil.setBooleanValue(PreferencePredicate.ShowLifeForm.getKey(), isShowLifeForm);
- PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowLifeForm.getKey()), overrideShowLifeForm);
+ PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowLifeForm.getKey()), isShowLifeForm != Boolean.parseBoolean(showLifeForm.getValue()));
}
return true;
}
@Override
protected void performDefaults() {
isShowSpecimenRelatedIssues = (Boolean)PreferencePredicate.ShowSpecimen.getDefaultValue();
- showSpecimenButton.setSelection(isShowSpecimenRelatedIssues);
-
- allowOverrideShowSpecimenRelatedIssues = true;
- allowOverrideIsShowSpecimenRelatedIssuesButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
-
+ if (isShowSpecimenRelatedIssues){
+ showSpecimenButton.select(0);
+ }else{
+ showSpecimenButton.select(1);
+ }
+ if (allowOverrideIsShowSpecimenRelatedIssuesButton != null){
+ allowOverrideShowSpecimenRelatedIssues = true;
+ allowOverrideIsShowSpecimenRelatedIssuesButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
+ }
isShowCollectingAreaInGeneralSection = (Boolean)PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue();
- showCollectingAreaInGeneralSectionButton.setSelection(isShowCollectingAreaInGeneralSection);
-
- allowOverrideShowCollectingAreaInGeneralSection = true;
- allowOverrideShowCollectingAreaButton.setSelection(allowOverrideShowCollectingAreaInGeneralSection);
-
+ if (isShowCollectingAreaInGeneralSection){
+ showCollectingAreaInGeneralSectionButton.select(0);
+ }else{
+ showCollectingAreaInGeneralSectionButton.select(1);
+ }
+ if (allowOverrideShowCollectingAreaButton != null){
+ allowOverrideShowCollectingAreaInGeneralSection = true;
+ allowOverrideShowCollectingAreaButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
+ }
isDeterminationOnlyForFieldUnits = (Boolean) PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue();
- determinationOnlyForFieldUnitsButton.setSelection(isDeterminationOnlyForFieldUnits);
-
- allowOverrideDeterminationOnlyForFieldUnits = true;
- allowOverridesDeterminationOnlyForFieldUnitsButton.setSelection(allowOverrideDeterminationOnlyForFieldUnits);
+ if (isDeterminationOnlyForFieldUnits){
+ determinationOnlyForFieldUnitsButton.select(0);
+ }else{
+ determinationOnlyForFieldUnitsButton.select(1);
+ }
+ if (allowOverridesDeterminationOnlyForFieldUnitsButton != null){
+ allowOverrideDeterminationOnlyForFieldUnits = true;
+ allowOverridesDeterminationOnlyForFieldUnitsButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
+ }
isShowTaxonAssociation = (Boolean) PreferencePredicate.ShowTaxonAssociations.getDefaultValue();
- showTaxonAssociationButton.setSelection(isShowTaxonAssociation);
+ if (isShowTaxonAssociation){
+ showTaxonAssociationButton.select(0);
+ }else{
+ showTaxonAssociationButton.select(1);
+ }
+ if (allowOverrideIsShowTaxonAssociationButton != null){
+ allowOverrideShowTaxonAssociation = true;
+ allowOverrideIsShowTaxonAssociationButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
+ }
- allowOverrideShowTaxonAssociation = true;
- allowOverrideIsShowTaxonAssociationButton.setSelection(allowOverrideShowTaxonAssociation);
isShowLifeForm = (Boolean) PreferencePredicate.ShowLifeForm.getDefaultValue();
- showLifeFormButton.setSelection(isShowLifeForm);
- allowOverrideShowLifeForm = true;
- allowOverrideShowLifeFormButton.setSelection(allowOverrideShowLifeForm);
+ if (isShowLifeForm){
+ showLifeFormButton.select(0);
+ }else{
+ showLifeFormButton.select(1);
+ }
+ if (allowOverrideShowLifeFormButton != null){
+ allowOverrideShowLifeForm = true;
+ allowOverrideShowLifeFormButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
+ }
+
super.performDefaults();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setApply(true);
+ if (e.getSource().equals(showSpecimenButton)){
+ String text = showSpecimenButton.getText();
+ text = text.replace(Messages.Preference_Use_Default, "");
+ if (text.equals(Messages.GeneralPreference_yes)){
+ isShowSpecimenRelatedIssues = true;
+ }else{
+ isShowSpecimenRelatedIssues = false;
+ }
+ }
+ if (e.getSource().equals(showCollectingAreaInGeneralSectionButton)){
+ String text = showCollectingAreaInGeneralSectionButton.getText();
+ text = text.replace(" (Use default)", "");
+ if (text.equals(Messages.GeneralPreference_yes)){
+ isShowCollectingAreaInGeneralSection = true;
+ }else{
+ isShowCollectingAreaInGeneralSection = false;
+ }
+ }
+
+ if (e.getSource().equals(determinationOnlyForFieldUnitsButton)){
+ String text = determinationOnlyForFieldUnitsButton.getText();
+ text = text.replace(" (Use default)", "");
+ if (text.equals(Messages.GeneralPreference_yes)){
+ isDeterminationOnlyForFieldUnits = true;
+ }else{
+ isDeterminationOnlyForFieldUnits = false;
+ }
+ }
+ if (e.getSource().equals(showTaxonAssociationButton)){
+ String text = showTaxonAssociationButton.getText();
+ text = text.replace(" (Use default)", "");
+ if (text.equals(Messages.GeneralPreference_yes)){
+ isShowTaxonAssociation = true;
+ }else{
+ isShowTaxonAssociation = false;
+ }
+ }
+ if (e.getSource().equals(showLifeFormButton)){
+ String text = showLifeFormButton.getText();
+ text = text.replace(" (Use default)", "");
+ if (text.equals(Messages.GeneralPreference_yes)){
+ isShowLifeForm = true;
+ }else{
+ isShowLifeForm = false;
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+
}
defaultValue = (Boolean)predicate.getDefaultValue();
}
if (defaultValue){
- booleanCombo.add(textTrue + " (Use Default)");
+ booleanCombo.add(textTrue + Messages.Preference_Use_Default);
booleanCombo.add(textFalse);
}else{
booleanCombo.add(textTrue);
- booleanCombo.add(textFalse +" (Use Default)");
+ booleanCombo.add(textFalse + Messages.Preference_Use_Default);
}
return booleanCombo;
for (IKeyLabel value: enumValues){
if (defaultValue.equals(value.getKey())){
- booleanCombo.add(value.getLabel() + " (Use Default)");
+ booleanCombo.add(value.getLabel() + Messages.Preference_Use_Default);
}else{
booleanCombo.add(value.getLabel());
}
import java.util.List;
-import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.ComboFieldEditor;
import eu.etaxonomy.cdm.api.application.ICdmRepository;
PreferencesUtil.setPreferredNomenclaturalCode(null, false);
if (pref.isAllowOverride()) {
addField(new ComboFieldEditor(
- PreferencesUtil.createPreferenceString(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.NomenclaturalCode.getKey())),
+ PreferencesUtil.createPreferenceString(PreferencePredicate.NomenclaturalCode.getKey()),
Messages.NomenclaturalCodePreferences_available_codes, getLabelAndValues(),
getFieldEditorParent()));
- addField(new BooleanFieldEditor(
- PreferencesUtil.createPreferenceString(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.NomenclaturalCode.getKey())),
- Messages.NomenclaturalCodePreferences_useLocalCode,
- getFieldEditorParent()));
+
} else {
setDescription(Messages.NomenclaturalCodePreferences_localChangesNotAllowed);
}
List<NomenclaturalCode> supportedCodes = NomenclaturalCodeHelper
.getSupportedCodes();
String[][] labelAndValues = new String[supportedCodes.size()][2];
+ String label;
for (int i = 0; i < supportedCodes.size(); i++) {
- labelAndValues[i][0] = NomenclaturalCodeHelper
- .getDescription(supportedCodes.get(i));
+ label = NomenclaturalCodeHelper
+ .getDescription(supportedCodes.get(i));
+ String value = supportedCodes.get(i).toString();
+ String prefValue = pref.getValue();
+ if (pref.getValue().equals(supportedCodes.get(i).toString())) {
+ label +=Messages.Preference_Use_Default;
+ }
+ labelAndValues[i][0] = label;
labelAndValues[i][1] = PreferencesUtil
.getPreferenceKey(supportedCodes.get(i));
}
public boolean performOk() {
boolean result = super.performOk();
-// if (result){
-// String value = getPreferenceStore().getString(IPreferenceKeys.PREFERRED_NOMENCLATURAL_CODE_KEY);
-// CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.NomenclaturalCode, value);
-// ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
-// if (controller == null){
-// return false;
-// }
-// IPreferenceService service = controller.getPreferenceService();
-// service.set(pref);
-// }
- return result;
- }
+ String value = pref.getValue();
+ String test = PreferencesUtil.getStringValue(PreferencePredicate.NomenclaturalCode.getKey(), true);
+ if (!pref.getValue().equals(PreferencesUtil.getStringValue(PreferencePredicate.NomenclaturalCode.getKey(), true))) {
+ PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.NomenclaturalCode.getKey()), true);
+ }else{
+ PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.NomenclaturalCode.getKey()), false);
+ }
+ return result;
+ }
+
}
Object[] checkedElements = aPage.getViewer().getCheckedElements();
ArrayList<UUID> listUIIDChecked = new ArrayList<UUID>();
+ int countChecked = 0;
for (Object o : checkedElements) {
if(o instanceof TermVocabularyDto){
TermVocabularyDto vocDto = (TermVocabularyDto) o;
listUIIDChecked.add(vocDto.getUuid());
+ countChecked++;
}
}
String saveCheckedElements = StringUtils.join(listUIIDChecked, ";"); //$NON-NLS-1$
-
+ int countVoc = aPage.getVocabularies().size();
String predicate = null;
pref = aPage.getPreference();
if (pref != null){
}
if (!localPref){
- if (StringUtils.isBlank(saveCheckedElements)){
+ if (StringUtils.isBlank(saveCheckedElements) || countChecked == countVoc){
saveCheckedElements = null;
}
CdmPreference savePref = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.getByKey(predicate), saveCheckedElements);