protected boolean allowOverrideFreeText;
private boolean isOverrideFreeText = true;
+
+ protected Boolean isShowSpecimenAsSource;
+
+ protected Combo comboShowSpecimenAsSource;
+ protected CdmPreference prefShowSpecimenAsSource = null;
+ Button allowOverrideShowSpecimenButton;
+
+ protected boolean allowOverrideSpecimen;
+ private boolean isOverrideSpecimen = true;
comboShowModifierFreeText.setEnabled(allowOverrideFreeText);
}
+ //Show specimen as source
+ comboShowSpecimenAsSource = createBooleanCombo(composite, SHOW, DO_NOT_SHOW, PreferencePredicate.ShowSpecimenInFactSource, Messages.FactualData_showSpecimenAsSource, isAdminPreference);
+ comboShowSpecimenAsSource.addSelectionListener(this);
+ if (this.isAdminPreference){
+ allowOverrideShowSpecimenButton = createAllowOverrideButton(composite);
+ allowOverrideShowSpecimenButton.setSelection(allowOverrideSpecimen);
+ allowOverrideShowSpecimenButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ allowOverrideSpecimen = !allowOverrideSpecimen;
+ setApply(true);
+ }
+ });
+ }
+ index = 0;
+ if(isShowSpecimenAsSource==null){
+ comboShowSpecimenAsSource.select(0);
+ } else{
+ for (String itemLabel : comboShowSpecimenAsSource.getItems()){
+ if (itemLabel.startsWith(this.SHOW) && isShowSpecimenAsSource){
+ comboShowSpecimenAsSource.select(index);
+ break;
+ }
+ if (itemLabel.startsWith(DO_NOT_SHOW) && !isShowSpecimenAsSource){
+ comboShowSpecimenAsSource.select(index);
+ break;
+ }
+ index++;
+ }
+ }
+ if (!isAdminPreference){
+ comboShowSpecimenAsSource.setEnabled(allowOverrideSpecimen);
+ }
return composite;
}else{
PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowModifierFreeText.getKey()), false);
}
+
+ if (isShowSpecimenAsSource != null){
+ PreferencesUtil.setStringValue(PreferencePredicate.ShowSpecimenInFactSource.getKey(), Boolean.toString(isShowSpecimenAsSource));
+ PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowSpecimenInFactSource.getKey()), true);
+
+ }else{
+ PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowSpecimenInFactSource.getKey()), false);
+ }
}
return true;
isShowModifier = Boolean.valueOf(showModifierString);
}
- isOverride = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowModifier.getKey()));
+ isOverride = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowModifier.getKey()), true);
if (!isOverride){
isShowModifier = null;
}
isShowModifierFreeText = Boolean.valueOf(showModifierStringFreeText);
}
- isOverrideFreeText = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowModifierFreeText.getKey()));
+ isOverrideFreeText = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowModifierFreeText.getKey()), true);
if (!isOverrideFreeText){
isShowModifierFreeText = null;
}
+
+ // get specimen values
+ prefShowSpecimenAsSource = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowSpecimenInFactSource);
+ if (prefShowSpecimenAsSource == null){
+ prefShowSpecimenAsSource = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimenInFactSource, PreferencePredicate.ShowSpecimenInFactSource.getDefaultValue().toString());
+ }
+ allowOverrideSpecimen = prefShowSpecimenAsSource.isAllowOverride();
+ isShowSpecimenAsSource = null;
+ String showSpecimenString = PreferencesUtil.getStringValue(PreferencePredicate.ShowSpecimenInFactSource.getKey(), true);
+ if (showSpecimenString != null){
+ isShowSpecimenAsSource = Boolean.valueOf(showSpecimenString);
+ }
+
+ isOverrideSpecimen = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowSpecimenInFactSource.getKey()), true);
+ if (!isOverrideSpecimen){
+ isShowSpecimenAsSource = null;
+ }
}
if (isAdminPreference){
allowOverrideFreeTextButton.setSelection(allowOverrideFreeText);
}
+
+ isShowSpecimenAsSource = null;
+ allowOverrideSpecimen = true;
+
+ comboShowSpecimenAsSource.select(0);
+ if (isAdminPreference){
+ allowOverrideShowSpecimenButton.setSelection(allowOverrideSpecimen);
+ }
setApply(true);
super.performDefaults();
}
}
}
+
+ if (e.getSource().equals(this.comboShowSpecimenAsSource)) {
+ String text = comboShowSpecimenAsSource.getText();
+ if (text.startsWith(Messages.Preference_Use_Default)){
+ isOverrideSpecimen = false;
+ isShowSpecimenAsSource = null;
+
+ }else if (text.equals(SHOW)){
+ isShowSpecimenAsSource = true;
+ isOverrideSpecimen = true;
+ }else{
+ isShowSpecimenAsSource = false;
+ isOverrideSpecimen = true;
+ }
+
+ }
+
setApply(true);
}
.createSelectionElement(TaxonName.class,
formElement, "Name in Source",
null, EntitySelectionElement.ALL, SWT.NULL);
- selection_specimen = formFactory
- .createSelectionElement(SpecimenOrObservationBase.class,
- formElement, "Specimen",
- null, EntitySelectionElement.ALL, SWT.NULL);
+ if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimenInFactSource.getKey())) {
+ selection_specimen = formFactory
+ .createSelectionElement(SpecimenOrObservationBase.class,
+ formElement, "Specimen",
+ null, EntitySelectionElement.ALL, SWT.NULL);
+ }
externalLinks = formFactory.createExternalLinksSection(formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
if (getEntity() != null){
text_referenceDetail.setText(entity.getCitationMicroReference());
text_originalInfo.setText(entity.getOriginalInfo());
selection_name.setEntity(entity.getNameUsedInSource());
- selection_specimen.setEntity(entity.getSpecimen());
+ if (selection_specimen != null) {
+ selection_specimen.setEntity(entity.getSpecimen());
+ }
combo_origsourcetype.setSelection(entity.getType());
externalLinks.setEntity(entity);
}