Revision c1c83a38
Added by Katja Luther over 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElement.java | ||
---|---|---|
8 | 8 |
import java.util.Observer; |
9 | 9 |
|
10 | 10 |
import org.eclipse.core.runtime.IStatus; |
11 |
|
|
12 | 11 |
import org.eclipse.jface.wizard.WizardDialog; |
13 | 12 |
import org.eclipse.swt.SWT; |
14 | 13 |
import org.eclipse.swt.events.SelectionAdapter; |
... | ... | |
79 | 78 |
public static final int ALL = EDITABLE | DELETABLE | SELECTABLE; // 111 |
80 | 79 |
|
81 | 80 |
protected T entity; |
81 |
protected T filteredEntity; |
|
82 | 82 |
|
83 | 83 |
protected Label label; |
84 | 84 |
protected Text text; |
... | ... | |
131 | 131 |
*/ |
132 | 132 |
public EntitySelectionElement(CdmFormFactory formFactory, |
133 | 133 |
ConversationHolder conversation, ICdmFormElement parentElement, |
134 |
String labelString, T entity, int mode, int style) { |
|
134 |
String labelString, T entity, int mode, int style, boolean filterElement) {
|
|
135 | 135 |
super(formFactory, parentElement); |
136 | 136 |
|
137 | 137 |
this.isEditable = (mode & EDITABLE) == EDITABLE; |
... | ... | |
147 | 147 |
} |
148 | 148 |
|
149 | 149 |
createControls(getLayoutComposite(), SWT.NULL); |
150 |
|
|
151 |
setEntity(entity); |
|
150 |
if (filterElement){ |
|
151 |
setFilteredEntity(entity); |
|
152 |
}else{ |
|
153 |
setEntity(entity); |
|
154 |
} |
|
152 | 155 |
} |
153 | 156 |
|
154 | 157 |
public EntitySelectionElement(CdmFormFactory formFactory, |
158 |
ConversationHolder conversation, ICdmFormElement parentElement, |
|
159 |
String labelString, T entity, int mode, int style){ |
|
160 |
this(formFactory, conversation, parentElement, labelString, entity, mode, style, false); |
|
161 |
} |
|
162 |
|
|
163 |
/** |
|
164 |
* @param entity2 |
|
165 |
*/ |
|
166 |
private void setFilteredEntity(T filterEntity) { |
|
167 |
this.filteredEntity =filterEntity; |
|
168 |
|
|
169 |
} |
|
170 |
|
|
171 |
public EntitySelectionElement(CdmFormFactory formFactory, |
|
155 | 172 |
ConversationHolder conversation, ICdmFormElement parentElement, Class<T> clazz, |
156 |
String labelString, T entity, int mode, int style) { |
|
157 |
this(formFactory, conversation, parentElement, labelString, entity, mode, style); |
|
173 |
String labelString, T entity, int mode, int style, boolean filterElement) {
|
|
174 |
this(formFactory, conversation, parentElement, labelString, entity, mode, style, filterElement);
|
|
158 | 175 |
this.clazz = clazz; |
159 | 176 |
} |
160 | 177 |
|
178 |
public EntitySelectionElement(CdmFormFactory formFactory, |
|
179 |
ConversationHolder conversation, ICdmFormElement parentElement, Class<T> clazz, |
|
180 |
String labelString, T entity, int mode, int style){ |
|
181 |
this(formFactory, conversation, parentElement, labelString, entity, mode, style, false); |
|
182 |
} |
|
183 |
|
|
161 | 184 |
private void createControls(Composite parent, int style) { |
162 | 185 |
|
163 | 186 |
label = formFactory.createLabel(getLayoutComposite(), labelString, |
... | ... | |
220 | 243 |
|
221 | 244 |
@Override |
222 | 245 |
public void widgetSelected(SelectionEvent e) { |
223 |
T selection = SelectionDialogFactory.getSelectionFromDialog(clazz, getShell(), getConversationHolder(), getEntity(), getParentElement()); |
|
246 |
T selection = SelectionDialogFactory.getSelectionFromDialog(clazz, getShell(), getConversationHolder(), getFilteredEntity(), getParentElement());
|
|
224 | 247 |
setSelectionInternal(selection); |
225 | 248 |
} |
226 | 249 |
|
227 | 250 |
/** |
251 |
* @return |
|
252 |
*/ |
|
253 |
public T getFilteredEntity() { |
|
254 |
|
|
255 |
return this.filteredEntity; |
|
256 |
} |
|
257 |
|
|
258 |
/** |
|
228 | 259 |
* Return the selected object |
229 | 260 |
* |
230 | 261 |
* @return a T object. |
... | ... | |
426 | 457 |
if (dialog.open() == IStatus.OK) { |
427 | 458 |
selectionElement.updateFromWizard(); |
428 | 459 |
//if the edited entity has already been persisted |
429 |
//but the transient entity is still set in this
|
|
460 |
//but the transient entity is still set in this |
|
430 | 461 |
//EntitySelectionElement, re-load it and set it |
431 | 462 |
IService<T> service = CdmStore.getService(entity); |
432 | 463 |
if(entity.getId()==0){ |
Also available in: Unified diff
fix #5671: add filter element for selection dialog