+ protected Control createContents(Composite parent) {
+ getValues();
+
+ boolean isEditingAllowed = true;
+ if(!isAdminPreference){
+ CdmPreferenceCache cache = CdmPreferenceCache.instance();
+
+ if (showSpecimenPref != null){
+ if (!showSpecimenPref.isAllowOverride() ){
+
+ isEditingAllowed = false;
+
+ }
+ }
+ }
+ 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();
+
+ Label separator= new Label(titleComp, SWT.HORIZONTAL | SWT.SEPARATOR);
+ separator.setLayoutData(gridData);
+ separator.setVisible(false);
+ showSpecimenButton = createBooleanCombo(titleComp, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowSpecimen, Messages.DatabasePreferncesPage_Show_Specimen, isAdminPreference);
+
+ showSpecimenButton.addSelectionListener(this);
+ int index = 0;
+ for (String itemLabel : showSpecimenButton.getItems()) {
+ if (isShowSpecimenRelatedIssues == null && itemLabel.startsWith(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);
+ allowOverrideIsShowSpecimenRelatedIssuesButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
+ allowOverrideIsShowSpecimenRelatedIssuesButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setApply(true);
+ allowOverrideShowSpecimenRelatedIssues = allowOverrideIsShowSpecimenRelatedIssuesButton.getSelection();
+ }
+ });
+ }
+
+ composite = createComposite(parent);
+ //composite.setEnabled(isShowSpecimenRelatedIssues);
+ gridData = createTextGridData();
+
+ separator= new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
+ separator.setLayoutData(gridData);
+
+ showCollectingAreaInGeneralSectionButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowCollectingAreasInGeneralSection, Messages.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section, isAdminPreference);
+
+ showCollectingAreaInGeneralSectionButton.addSelectionListener(this);
+ index = 0;
+ for (String itemLabel : showCollectingAreaInGeneralSectionButton.getItems()) {
+ if (isShowCollectingAreaInGeneralSection == null && itemLabel.startsWith(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);
+ allowOverrideShowCollectingAreaButton.setSelection(allowOverrideShowCollectingAreaInGeneralSection);
+ allowOverrideShowCollectingAreaButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setApply(true);
+ allowOverrideShowCollectingAreaInGeneralSection = allowOverrideShowCollectingAreaButton.getSelection();
+ }
+ });
+ }
+ 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);
+ index = 0;
+ for (String itemLabel : determinationOnlyForFieldUnitsButton.getItems()) {
+ if (isDeterminationOnlyForFieldUnits == null && itemLabel.startsWith(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);
+ allowOverridesDeterminationOnlyForFieldUnitsButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setApply(true);
+ allowOverrideDeterminationOnlyForFieldUnits = allowOverridesDeterminationOnlyForFieldUnitsButton.getSelection();
+ }
+ });
+ }
+
+ showTaxonAssociationButton =createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowTaxonAssociations, Messages.DatabasePreferncesPage_Taxon_Associations, isAdminPreference);
+
+
+ showTaxonAssociationButton.addSelectionListener(this);
+ index = 0;
+ for (String itemLabel : showTaxonAssociationButton.getItems()) {
+ if (isShowTaxonAssociation == null && itemLabel.startsWith(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);
+ allowOverrideIsShowTaxonAssociationButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setApply(true);
+ allowOverrideShowTaxonAssociation = allowOverrideIsShowTaxonAssociationButton.getSelection();
+ }
+ });
+ }
+
+ showLifeFormButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowLifeForm, Messages.DatabasePreferncesPage_Life_Form, isAdminPreference);
+ showLifeFormButton.addSelectionListener(this);
+
+ index = 0;
+ for (String itemLabel: showLifeFormButton.getItems()) {
+ if (isShowLifeForm == null && itemLabel.startsWith(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);
+ allowOverrideShowLifeFormButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setApply(true);
+ allowOverrideShowLifeForm = allowOverrideShowLifeFormButton.getSelection();
+ }
+ });
+ }
+
+ if (!isEditingAllowed){
+ PreferencesUtil.recursiveSetEnabled(composite, false);
+ }
+
+ return composite;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void getValues() {
+ CdmPreferenceCache cache = CdmPreferenceCache.instance();
+
+
+ overrideShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowSpecimen.getKey()), true) != null? PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowSpecimen.getKey()), true): false;
+
+ PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowSpecimen);
+ 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);
+ }
+
+
+
+
+ key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection);
+ showCollectingAreaInGeneralSection = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
+ overrideShowCollectionAreaInGeneralSection = PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), true) != null? PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), true): false;
+ 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);
+ }
+
+
+ key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
+ showDeterminationOnlyForFieldUnits = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
+ overrideDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), true) != null? PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), true): false;
+ 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;
+
+
+ key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonAssociations);
+ showTaxonAssociation = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
+ overrideShowTaxonAssociation = PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowTaxonAssociations.getKey()), true) != null? PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowTaxonAssociations.getKey()), true): false;
+ 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;
+
+
+ key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowLifeForm);
+ showLifeForm = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowLifeForm);
+ overrideShowLifeForm = PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowLifeForm.getKey()), true) != null? PreferencesUtil.getBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowLifeForm.getKey()), true): false;
+ if (showLifeForm != null) {
+ if (showLifeForm.isAllowOverride() ) {
+ if (overrideShowLifeForm){
+ isShowLifeForm = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowLifeForm.getKey());
+ }
+
+ } else {
+ isShowLifeForm = Boolean.valueOf(showLifeForm.getValue());
+
+ }
+