Project

General

Profile

« Previous | Next » 

Revision be719c48

Added by Patrick Plitzner over 7 years ago

ref #6058 store named area filters more individually

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NamedAreaSelectionDialog.java
63 63
			}else{
64 64
				selectedVocabularies.remove(vocabulary);
65 65
			}
66
			PreferencesUtil.getPreferenceStore().setValue(getPrefKey(vocabulary), isChecked());
66
			PreferencesUtil.getPreferenceStore().setValue(getPrefKey(vocabulary), !isChecked());
67 67
			initModel();
68 68
		}
69 69
	}
70 70

  
71 71
	protected Collection<TermVocabulary> selectedVocabularies;
72 72
    protected ArrayList<TermVocabulary> preselectedVocabularies;
73
    private Object preferenceID;
73 74

  
74 75

  
75 76
	/**
......
80 81
	 * @param namedArea
81 82
	 * 				A namedArea that should be selected when the dialog opens
82 83
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
84
	 * @param preferenceId a class which is used for generating the preference key so that every 
85
	 * dialogs can be grouped to have their own preferences depending on this id
83 86
	 * @param preselectedVocabularyUuids the {@link UUID}s of the pre-selected vocabularies
84 87
	 * @return a {@link eu.etaxonomy.cdm.model.location.NamedArea} object.
85 88
	 */
86
	public static NamedArea select(Shell shell, ConversationHolder conversation, NamedArea namedArea, UUID... preselectedVocabularyUuids) {
89
	public static NamedArea select(Shell shell, ConversationHolder conversation, NamedArea namedArea, String preferenceId, UUID... preselectedVocabularyUuids) {
87 90
		NamedAreaSelectionDialog dialog = new NamedAreaSelectionDialog(shell, conversation,
88
				"Choose an area", false, namedArea, preselectedVocabularyUuids);
91
				"Choose an area", false, namedArea, preferenceId, preselectedVocabularyUuids);
89 92
		return getSelectionFromDialog(dialog);
90 93
	}
91 94

  
92
	protected NamedAreaSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, NamedArea namedArea, UUID... preselectedVocabularyUuids) {
95
	protected NamedAreaSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, NamedArea namedArea, Object preferenceId, UUID... preselectedVocabularyUuids) {
93 96
		super(shell, conversation, title, multi, NamedAreaSelectionDialog.class.getCanonicalName(), namedArea);
97
		this.preferenceID = preferenceId;
94 98
		preselectedVocabularies = new ArrayList<TermVocabulary>();
95 99
		for(int i=0;i<preselectedVocabularyUuids.length;i++){
96 100
			TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]);
......
99 103
		Collection<TermVocabulary> tempSelectedVocabularies = new HashSet<>();
100 104
		for(TermVocabulary vocabulary:selectedVocabularies){
101 105
			if(preselectedVocabularies.contains(vocabulary)
102
					|| PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary))){
106
					|| !PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary))){
103 107
				tempSelectedVocabularies.add(vocabulary);
104 108
			}
105 109
		}
......
120 124
			    action.setChecked(true);
121 125
			}
122 126
			else{
123
				action.setChecked(PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary)));
127
				action.setChecked(!PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary)));
124 128
			}
125 129
		}
126 130
	}
127 131
	
128 132
	private String getPrefKey(TermVocabulary vocabulary){
129
		return NamedAreaSelectionDialog.class.toString()+vocabulary.getUuid();
133
		return "hide_"+NamedAreaSelectionDialog.class.getCanonicalName()+vocabulary.getUuid()+preferenceID;
130 134
	}
131 135

  
132 136
	/** {@inheritDoc} */
......
147 151
	@Override
148 152
	protected void init() {
149 153
		selectedVocabularies = getAvailableVocabularies();
150
		for(TermVocabulary vocabulary:selectedVocabularies){
151
			PreferencesUtil.getPreferenceStore().setDefault(getPrefKey(vocabulary), true);
152
		}
153 154
	}
154 155

  
155 156
	private List<TermVocabulary> getAvailableVocabularies(){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionDialogFactory.java
126 126
		}
127 127
		if(clazz.equals(NamedArea.class)){
128 128
		    if(parentElement instanceof IEntityElement && ((IEntityElement) parentElement).getEntity() instanceof DerivedUnitFacade){
129
		        return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection, Country.uuidCountryVocabulary);
129
		        return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection, DerivedUnit.class.getCanonicalName(), Country.uuidCountryVocabulary);
130 130
		    }
131 131
		    else{
132
		        return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection);
132
		        return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection, parentElement.getClass().getCanonicalName());
133 133
		    }
134 134
		}
135 135
		if(clazz.equals(Collection.class)){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectingAreasDetailSection.java
15 15
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16 16
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
17 17
import eu.etaxonomy.cdm.model.location.NamedArea;
18
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
18 19
import eu.etaxonomy.taxeditor.ui.dialog.selection.NamedAreaSelectionDialog;
19 20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
20 21
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
......
59 60
	/** {@inheritDoc} */
60 61
	@Override
61 62
	public NamedArea createNewElement() {
62
		NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null);
63
		NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null, FieldUnit.class.getCanonicalName());
63 64

  
64 65
		return selection;
65 66
	}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/GeoScopeDetailSection.java
59 59
	/** {@inheritDoc} */
60 60
	@Override
61 61
	public NamedArea createNewElement() {
62
		NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null);
62
		NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null, Classification.class.getCanonicalName());
63 63

  
64 64
		return selection;
65 65
	}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/GeoScopePolyKeyDetailSection.java
42 42
	/** {@inheritDoc} */
43 43
	@Override
44 44
	public NamedArea createNewElement() {
45
		NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null);
45
		NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null, PolytomousKey.class.getCanonicalName());
46 46

  
47 47
		return selection;
48 48
	}

Also available in: Unified diff