return composite;
}
+ @Override
+ public boolean performOk() {
+ PreferencesUtil.updateDBPreferences();
+ return true;
+
+ }
+
}
public static final String DISTRIBUTION_AREA_OCCURENCE_STATUS = "eu.etaxonomy.taxeditor.checklist.distributionAreaStatus";
public static final String DISTRIBUTION_AREA_OCCURENCE_STATUS_GRAYED = "eu.etaxonomy.taxeditor.checklist.distributionAreaStatusGrayed";
public static final String DISTRIBUTION_VOCABULARIES = "eu.etaxonomy.taxeditor.checklist.distributionVocabularies";
+ public static final String DISTRIBUTION_VOCABULARIES_ALLOW_OVERRIDE = "eu.etaxonomy.taxeditor.checklist.distributionVocabulariesAllowOverride";
+ public static final String DISTRIBUTION_VOCABULARIES_OVERRIDE = "eu.etaxonomy.taxeditor.checklist.distributionVocabulariesOverride";
public static final String CHECKLIST_AREA_DISPLAY = "eu.etaxonomy.taxeditor.checklist.checklistAreaDisplay";
public static final String CHECKLIST_AREA_DISPLAY_ID_IN_VOCABULARY = "IdInVocabulary";
public static final String CHECKLIST_AREA_DISPLAY_TITLE = "Title";
+
}
//Distribution Editor
preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
if (preference != null){
- if (!prefStore.getBoolean(DISTRIBUTION_AREA_PREFRENCES_ACTIVE_OVERRIDE) || !preference.isAllowOverride()){
+ if (!prefStore.getBoolean(DISTRIBUTION_VOCABULARIES_OVERRIDE) || !preference.isAllowOverride()){
prefStore.setValue(DISTRIBUTION_VOCABULARIES, preference.getValue());
+ prefStore.setValue(DISTRIBUTION_VOCABULARIES_ALLOW_OVERRIDE, preference.getValue());
}
+ }else{
+ prefStore.setValue(DISTRIBUTION_VOCABULARIES_ALLOW_OVERRIDE,true);
+ prefStore.setToDefault(DISTRIBUTION_VOCABULARIES);
}
preference = getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
preference = getPreferenceFromDB(PreferencePredicate.CommonNameAreaVocabularies);
if (preference != null){
- if (!prefStore.getBoolean(COMMON_NAME_AREA_VOCABULARIES_OVERRIDE) || !preference.isAllowOverride()){
+ if (!prefStore.getBoolean(COMMON_NAME_AREA_VOCABULARIES) || !preference.isAllowOverride()){
prefStore.setValue(COMMON_NAME_AREA_VOCABULARIES, preference.getValue());
+ prefStore.setValue(COMMON_NAME_AREA_VOCABULARIES_ALLOW_OVERRIDE, preference.isAllowOverride());
}
+ }else{
+ prefStore.setToDefault(COMMON_NAME_AREA_VOCABULARIES);
+ prefStore.setValue(COMMON_NAME_AREA_VOCABULARIES_ALLOW_OVERRIDE, true);
}
preference = getPreferenceFromDB(PreferencePredicate.CommonNameReferencesWithMarker);
*/
package eu.etaxonomy.taxeditor.ui.dialog.selection;
+import java.util.ArrayList;
+import java.util.List;
import java.util.UUID;
+import org.apache.commons.lang.StringUtils;
import org.eclipse.swt.widgets.Shell;
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
+import eu.etaxonomy.cdm.model.common.TermType;
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
import eu.etaxonomy.cdm.model.location.NamedArea;
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* @author k.luther
private static UUID[] createVocabularyUuidList() {
String preselectedVocString = PreferencesUtil.getPreferenceStore().getString(IPreferenceKeys.COMMON_NAME_AREA_VOCABULARIES);
+ if (StringUtils.isBlank(preselectedVocString)){
+ return null;
+ }
String[] preselectedVocArray = preselectedVocString.split(";");
UUID[] uuidList = new UUID[preselectedVocArray.length];
int i = 0;
}
return uuidList;
}
+ @Override
+ protected void init() {
+ vocabularies = getAvailableVocabularies();
+ }
+
+
+ protected List<TermVocabulary> getAvailableVocabularies(){
+ List<TermVocabulary> vocabularies = new ArrayList();
+
+ if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.COMMON_NAME_AREA_VOCABULARIES_ALLOW_OVERRIDE)){
+ UUID[] preselectedVocabularyUuids = createVocabularyUuidList();
+
+ for(int i=0;i<preselectedVocabularyUuids.length;i++){
+ TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]);
+ vocabularies.add(preselectedVocabulary);
+ }
+ }else{
+ vocabularies = CdmStore.getService(IVocabularyService.class).listByTermType(TermType.NamedArea, true, null, null, null, null);
+ }
+ return vocabularies;
+ }
/**
* Creates a filtered selection dialog to select a named area.
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.service.IVocabularyService;
-import eu.etaxonomy.cdm.model.common.TermType;
import eu.etaxonomy.cdm.model.common.TermVocabulary;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
-import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* @author k.luther
/**
* @param parentShell
*/
- protected FilterDialog(Shell parentShell, Object preferenceId, List<TermVocabulary> selectedVocabularies) {
+ protected FilterDialog(Shell parentShell, Object preferenceId, List<TermVocabulary> selectedVocabularies, List<TermVocabulary> vocabularies) {
super(parentShell);
- vocabularies = CdmStore.getService(IVocabularyService.class).listByTermType(TermType.NamedArea, true, null, null, null, null);
+ this.vocabularies = vocabularies;
this.preferenceId = preferenceId;
this.selectedVocabularies = selectedVocabularies;
this.tempSelectedVocabularies = new ArrayList();
this.tempSelectedVocabularies.addAll(selectedVocabularies);
-
-
+
+
}
@Override
@Override
protected void okPressed(){
-
+
for (TermVocabulary voc: vocabularies){
if (tempSelectedVocabularies.contains(voc)){
PreferencesUtil.getPreferenceStore().setValue(getPrefKey(voc), false);
}
super.okPressed();
}
-
+
private String getPrefKey(TermVocabulary vocabulary){
return "hide_"+NamedAreaSelectionDialog.class.getCanonicalName()+vocabulary.getUuid()+preferenceId;
}
import java.util.List;
import java.util.UUID;
+import org.apache.commons.lang.StringUtils;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.Dialog;
}
protected List<TermVocabulary> selectedVocabularies;
- protected ArrayList<TermVocabulary> preselectedVocabularies;
+ protected List<TermVocabulary> vocabularies;
super(shell, //conversation,
title, multi, NamedAreaSelectionDialog.class.getCanonicalName(), namedArea);
- preselectedVocabularies = new ArrayList<TermVocabulary>();
+ selectedVocabularies = new ArrayList<TermVocabulary>();
+ this.preferenceID = preferenceId;
if (preselectedVocabularyUuids == null || preselectedVocabularyUuids.length == 0){
preselectedVocabularyUuids = createVocabularyUuidList();
}
- for(int i=0;i<preselectedVocabularyUuids.length;i++){
- TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]);
- preselectedVocabularies.add(preselectedVocabulary);
+ if (preselectedVocabularyUuids != null){
+ for(int i=0;i<preselectedVocabularyUuids.length;i++){
+ TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]);
+ selectedVocabularies.add(preselectedVocabulary);
+ }
}
protected List<TermVocabulary> createSelectedVocabularies() {
List<TermVocabulary> tempSelectedVocabularies = new ArrayList<TermVocabulary>();
- for(TermVocabulary vocabulary:selectedVocabularies){
- if(preselectedVocabularies.contains(vocabulary)
+ for(TermVocabulary vocabulary:vocabularies){
+ if((selectedVocabularies.contains(vocabulary) && !PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary)))
|| !PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary))){
tempSelectedVocabularies.add(vocabulary);
}
private static UUID[] createVocabularyUuidList() {
String preselectedVocString = PreferencesUtil.getPreferenceStore().getString(IPreferenceKeys.DISTRIBUTION_VOCABULARIES);
+ if (StringUtils.isBlank(preselectedVocString)){
+ return null;
+ }
String[] preselectedVocArray = preselectedVocString.split(";");
UUID[] uuidList = new UUID[preselectedVocArray.length];
int i = 0;
/** {@inheritDoc} */
@Override
protected void init() {
- selectedVocabularies = getAvailableVocabularies();
+ vocabularies = getAvailableVocabularies();
}
private List<TermVocabulary> getAvailableVocabularies(){
- List<TermVocabulary> vocabularies = CdmStore.getService(IVocabularyService.class).listByTermType(TermType.NamedArea, true, null, null, null, null);
+ vocabularies = new ArrayList();
+ if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_VOCABULARIES_ALLOW_OVERRIDE)){
+ UUID[] preselectedVocabularyUuids = createVocabularyUuidList();
+
+ for(int i=0;i<preselectedVocabularyUuids.length;i++){
+ TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]);
+ vocabularies.add(preselectedVocabulary);
+ }
+ }else{
+ vocabularies = CdmStore.getService(IVocabularyService.class).listByTermType(TermType.NamedArea, true, null, null, null, null);
+ }
+ //List<TermVocabulary> vocabularies = CdmStore.getService(IVocabularyService.class).listByTermType(TermType.NamedArea, true, null, null, null, null);
return vocabularies;
}
String text = null;
if (source instanceof Button){
Shell shell = ((Button)source).getShell();
- Dialog dialog = new FilterDialog(getShell(), preferenceID, selectedVocabularies);
+ Dialog dialog = new FilterDialog(getShell(), preferenceID, selectedVocabularies, vocabularies);
if(dialog!=null){
dialog.open();
}
}
- /**
- *
- */
- public void setSelectedVocabularies() {
- // TODO Auto-generated method stub
- }
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.ui.dialog.selection.AbstractFilteredCdmResourceSelectionDialog#callService(java.lang.String)
*/
@Override
void callService(String pattern) {
- model = CdmStore.getService(ITermService.class).getUuidAndTitleCache(selectedVocabularies, limitOfInitialElements, pattern, PreferencesUtil.getGlobalLanguage());
+ if (selectedVocabularies == null || selectedVocabularies.size() == 0){
+ model = CdmStore.getService(ITermService.class).getUuidAndTitleCache(vocabularies, limitOfInitialElements, pattern, PreferencesUtil.getGlobalLanguage());
+ }else{
+ model = CdmStore.getService(ITermService.class).getUuidAndTitleCache(selectedVocabularies, limitOfInitialElements, pattern, PreferencesUtil.getGlobalLanguage());
+ }
}
}