Revision 5aeccadc
Added by Katja Luther over 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NamedAreaSelectionDialog.java | ||
---|---|---|
16 | 16 |
import org.eclipse.core.runtime.CoreException; |
17 | 17 |
import org.eclipse.jface.action.Action; |
18 | 18 |
import org.eclipse.jface.action.IAction; |
19 |
import org.eclipse.jface.action.IMenuManager; |
|
19 |
import org.eclipse.jface.dialogs.Dialog; |
|
20 |
import org.eclipse.swt.SWT; |
|
21 |
import org.eclipse.swt.events.SelectionEvent; |
|
22 |
import org.eclipse.swt.events.SelectionListener; |
|
23 |
import org.eclipse.swt.widgets.Button; |
|
20 | 24 |
import org.eclipse.swt.widgets.Composite; |
21 | 25 |
import org.eclipse.swt.widgets.Control; |
22 | 26 |
import org.eclipse.swt.widgets.Shell; |
23 | 27 |
import org.eclipse.swt.widgets.Text; |
28 |
import org.eclipse.wb.swt.ResourceManager; |
|
24 | 29 |
|
25 | 30 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
26 | 31 |
import eu.etaxonomy.cdm.api.service.ITermService; |
... | ... | |
62 | 67 |
} |
63 | 68 |
PreferencesUtil.getPreferenceStore().setValue(getPrefKey(vocabulary), !isChecked()); |
64 | 69 |
search(); |
65 |
try { |
|
66 |
fillContentProvider(null); |
|
67 |
} catch (CoreException coreException) { |
|
68 |
// TODO Auto-generated catch block |
|
69 |
coreException.printStackTrace(); |
|
70 |
} |
|
71 | 70 |
} |
72 | 71 |
} |
73 | 72 |
|
74 | 73 |
protected List<TermVocabulary> selectedVocabularies; |
75 | 74 |
protected ArrayList<TermVocabulary> preselectedVocabularies; |
76 |
private Object preferenceID; |
|
75 |
|
|
77 | 76 |
|
78 | 77 |
|
79 | 78 |
/** |
... | ... | |
103 | 102 |
TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]); |
104 | 103 |
preselectedVocabularies.add(preselectedVocabulary); |
105 | 104 |
} |
106 |
List<TermVocabulary> tempSelectedVocabularies = new ArrayList<>(); |
|
107 |
for(TermVocabulary vocabulary:selectedVocabularies){ |
|
105 |
|
|
106 |
|
|
107 |
selectedVocabularies = createSelectedVocabularies();; |
|
108 |
// search;//re-init to consider pre-selected vocabularies |
|
109 |
} |
|
110 |
|
|
111 |
private List<TermVocabulary> createSelectedVocabularies() { |
|
112 |
List<TermVocabulary> tempSelectedVocabularies = new ArrayList<TermVocabulary>(); |
|
113 |
for(TermVocabulary vocabulary:selectedVocabularies){ |
|
108 | 114 |
if(preselectedVocabularies.contains(vocabulary) |
109 | 115 |
|| !PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary))){ |
110 | 116 |
tempSelectedVocabularies.add(vocabulary); |
111 | 117 |
} |
112 | 118 |
} |
113 |
selectedVocabularies = tempSelectedVocabularies; |
|
114 |
// search;//re-init to consider pre-selected vocabularies |
|
115 |
} |
|
119 |
return tempSelectedVocabularies; |
|
120 |
} |
|
116 | 121 |
|
117 | 122 |
/** {@inheritDoc} */ |
118 |
@Override |
|
119 |
protected void fillViewMenu(IMenuManager menuManager) { |
|
120 |
|
|
121 |
// super.fillViewMenu(menuManager); |
|
122 |
|
|
123 |
for(TermVocabulary<NamedArea> vocabulary : getAvailableVocabularies()){ |
|
124 |
IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary); |
|
125 |
menuManager.add(action); |
|
126 |
if(preselectedVocabularies.contains(vocabulary)) { |
|
127 |
action.setChecked(true); |
|
128 |
} |
|
129 |
else{ |
|
130 |
action.setChecked(!PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary))); |
|
131 |
} |
|
132 |
} |
|
133 |
} |
|
123 |
// @Override
|
|
124 |
// protected void fillViewMenu(IMenuManager menuManager) {
|
|
125 |
// |
|
126 |
//// super.fillViewMenu(menuManager);
|
|
127 |
// |
|
128 |
// for(TermVocabulary<NamedArea> vocabulary : getAvailableVocabularies()){
|
|
129 |
// IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary);
|
|
130 |
// menuManager.add(action);
|
|
131 |
// if(preselectedVocabularies.contains(vocabulary)) {
|
|
132 |
// action.setChecked(true);
|
|
133 |
// }
|
|
134 |
// else{
|
|
135 |
// action.setChecked(!PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary)));
|
|
136 |
// }
|
|
137 |
// }
|
|
138 |
// }
|
|
134 | 139 |
|
135 | 140 |
private String getPrefKey(TermVocabulary vocabulary){ |
136 | 141 |
return "hide_"+NamedAreaSelectionDialog.class.getCanonicalName()+vocabulary.getUuid()+preferenceID; |
... | ... | |
175 | 180 |
}else{ |
176 | 181 |
model = CdmStore.getService(ITermService.class).getUuidAndTitleCache(selectedVocabularies, limitOfInitialElements, pattern, PreferencesUtil.getGlobalLanguage()); |
177 | 182 |
} |
178 |
|
|
183 |
try { |
|
184 |
fillContentProvider(null); |
|
185 |
} catch (CoreException e) { |
|
186 |
// TODO Auto-generated catch block |
|
187 |
e.printStackTrace(); |
|
188 |
} |
|
179 | 189 |
// Set<NamedArea> terms = new HashSet<NamedArea>(); |
180 | 190 |
// for(TermVocabulary<NamedArea> vocabulary : selectedVocabularies){ |
181 | 191 |
// terms.addAll(vocabulary.getTermsOrderedByLabels(CdmStore.getDefaultLanguage())); |
... | ... | |
192 | 202 |
// } |
193 | 203 |
} |
194 | 204 |
|
195 |
/** {@inheritDoc} */ |
|
196 |
@Override |
|
197 |
protected Control createExtendedContentArea(Composite parent) { |
|
198 |
return null; |
|
199 |
} |
|
205 |
// /** {@inheritDoc} */
|
|
206 |
// @Override
|
|
207 |
// protected Control createExtendedContentArea(Composite parent) {
|
|
208 |
// return null;
|
|
209 |
// }
|
|
200 | 210 |
|
201 | 211 |
/** {@inheritDoc} */ |
202 | 212 |
@Override |
... | ... | |
218 | 228 |
|
219 | 229 |
/** {@inheritDoc} */ |
220 | 230 |
@Override |
221 |
protected String getNewWizardLinkText() {
|
|
231 |
protected String[] getNewWizardText() {
|
|
222 | 232 |
return null; |
223 | 233 |
} |
234 |
|
|
235 |
@Override |
|
236 |
void createFilterButton(Composite searchAndFilter) |
|
237 |
{ |
|
238 |
filterButton = new Button(searchAndFilter, SWT.NONE); |
|
239 |
// filterButton.setText("Filter"); |
|
240 |
filterButton.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/funnel-icon.png")); |
|
241 |
// SelectionListener filterSelectionListener = new FilterSelectionListener(preferenceID, this); |
|
242 |
filterButton.addSelectionListener(new SelectionListener(){ |
|
243 |
@Override |
|
244 |
public void widgetSelected(SelectionEvent e) { |
|
245 |
|
|
246 |
Object source = e.getSource(); |
|
247 |
String text = null; |
|
248 |
if (source instanceof Button){ |
|
249 |
Shell shell = ((Button)source).getShell(); |
|
250 |
Dialog dialog = new FilterDialog(getShell(), preferenceID, selectedVocabularies); |
|
251 |
if(dialog!=null){ |
|
252 |
dialog.open(); |
|
253 |
} |
|
254 |
createSelectedVocabularies(); |
|
255 |
} |
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
} |
|
261 |
|
|
262 |
@Override |
|
263 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
264 |
// TODO Auto-generated method stub |
|
265 |
|
|
266 |
} |
|
267 |
|
|
268 |
|
|
269 |
}); |
|
270 |
|
|
271 |
} |
|
272 |
|
|
273 |
/** |
|
274 |
* |
|
275 |
*/ |
|
276 |
public void setSelectedVocabularies() { |
|
277 |
// TODO Auto-generated method stub |
|
278 |
|
|
279 |
} |
|
280 |
|
|
224 | 281 |
} |
Also available in: Unified diff
e4 migration of selection dialogs