Revision 9a3af936
Added by Patrick Plitzner over 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/menu/AbstractMenuPreferences.java | ||
---|---|---|
18 | 18 |
import org.eclipse.core.commands.Parameterization; |
19 | 19 |
import org.eclipse.core.commands.ParameterizedCommand; |
20 | 20 |
import org.eclipse.core.commands.common.NotDefinedException; |
21 |
import org.eclipse.core.runtime.IStatus; |
|
22 | 21 |
import org.eclipse.jface.viewers.CheckStateChangedEvent; |
23 | 22 |
import org.eclipse.jface.viewers.CheckboxTableViewer; |
24 | 23 |
import org.eclipse.jface.viewers.ICheckStateListener; |
25 |
import org.eclipse.jface.wizard.WizardDialog; |
|
26 | 24 |
import org.eclipse.swt.SWT; |
27 | 25 |
import org.eclipse.swt.events.SelectionAdapter; |
28 | 26 |
import org.eclipse.swt.events.SelectionEvent; |
... | ... | |
45 | 43 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
46 | 44 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
47 | 45 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
48 |
import eu.etaxonomy.taxeditor.preference.wizard.VocabularyTermWizard; |
|
49 | 46 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
50 | 47 |
import eu.etaxonomy.taxeditor.store.TermStore; |
51 | 48 |
|
... | ... | |
60 | 57 |
private Button toggleButton; |
61 | 58 |
protected HashMap<DefinedTermBase<T>, Button> menuButtons; |
62 | 59 |
|
63 |
protected Button newButton; |
|
64 | 60 |
protected Button editButton; |
65 | 61 |
protected Button removeButton; |
66 | 62 |
|
... | ... | |
91 | 87 |
} |
92 | 88 |
|
93 | 89 |
protected List<T> getTerms(){ |
94 |
if(!CdmStore.isActive() || getTermClass()==null) { |
|
95 |
return new ArrayList<T>(); |
|
96 |
} else { |
|
97 |
return TermStore.getTerms(getTermClass()); |
|
90 |
if(CdmStore.isActive() && getTermType()!=null){ |
|
91 |
return TermStore.getTerms(getTermType(), null); |
|
98 | 92 |
} |
93 |
return new ArrayList<T>(); |
|
99 | 94 |
} |
100 | 95 |
|
101 | 96 |
/** |
... | ... | |
175 | 170 |
addEditButtonListeners(); |
176 | 171 |
} |
177 | 172 |
|
178 |
/** |
|
179 |
* Implement this method in MenuPreference Pages where the vocabulary should be editable, editable flag |
|
180 |
* is set. |
|
181 |
*/ |
|
182 |
protected void addNewButtonListeners() { |
|
183 |
newButton.addSelectionListener(new SelectionAdapter(){ |
|
184 |
@Override |
|
185 |
public void widgetSelected(SelectionEvent e) { |
|
186 |
VocabularyTermWizard<T> wizard = new VocabularyTermWizard<T>(getTermClass(), getConversationHolder()); |
|
187 |
|
|
188 |
WizardDialog dialog = new WizardDialog(AbstractUtility.getShell(), wizard); |
|
189 |
if(dialog.open() == IStatus.OK){ |
|
190 |
tableViewer.setInput(getTerms()); |
|
191 |
} |
|
192 |
} |
|
193 |
|
|
194 |
}); |
|
195 |
} |
|
196 |
|
|
197 | 173 |
/** |
198 | 174 |
* Implement this method in MenuPreference Pages where the vocabulary should be editable, editable flag |
199 | 175 |
* is set. |
... | ... | |
212 | 188 |
parameter = command.getParameter("eu.etaxonomy.taxeditor.store.openDefinedTermEditor.termTypeUuid"); |
213 | 189 |
|
214 | 190 |
Parameterization[] parameterizations = new Parameterization[]{ |
215 |
new Parameterization(parameter, TermType.valueOf(getTermClass().getSimpleName()).getUuid().toString())
|
|
191 |
new Parameterization(parameter, getTermType().getUuid().toString())
|
|
216 | 192 |
}; |
217 | 193 |
|
218 | 194 |
ParameterizedCommand pCommand = new ParameterizedCommand(command, parameterizations); |
... | ... | |
305 | 281 |
} |
306 | 282 |
} |
307 | 283 |
|
308 |
protected abstract Class<T> getTermClass();
|
|
284 |
protected abstract TermType getTermType();
|
|
309 | 285 |
|
310 | 286 |
@Override |
311 | 287 |
public ConversationHolder getConversationHolder() { |
Also available in: Unified diff
fix #5496 Refactor preference pages to use TermType