Revision b478a42f
Added by Niels Hoffmann almost 13 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialogs/filteredSelection/AbstractFilteredCdmResourceSelectionDialog.java | ||
---|---|---|
11 | 11 |
package eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection; |
12 | 12 |
|
13 | 13 |
import java.lang.reflect.Field; |
14 |
import java.security.acl.LastOwnerException; |
|
15 | 14 |
import java.text.Collator; |
16 | 15 |
import java.util.Comparator; |
17 | 16 |
import java.util.HashSet; |
... | ... | |
30 | 29 |
import org.eclipse.jface.window.Window; |
31 | 30 |
import org.eclipse.jface.wizard.WizardDialog; |
32 | 31 |
import org.eclipse.swt.SWT; |
33 |
import org.eclipse.swt.events.ModifyEvent; |
|
34 | 32 |
import org.eclipse.swt.events.SelectionAdapter; |
35 | 33 |
import org.eclipse.swt.events.SelectionEvent; |
36 | 34 |
import org.eclipse.swt.events.SelectionListener; |
... | ... | |
92 | 90 |
|
93 | 91 |
initModel(); |
94 | 92 |
|
95 |
if (cdmObject != null) { |
|
96 |
setInitialPattern(getTitle(cdmObject)); |
|
93 |
String objectTitle = getTitle(cdmObject); |
|
94 |
if (objectTitle != null) { |
|
95 |
setInitialPattern(objectTitle); |
|
97 | 96 |
} |
98 | 97 |
|
99 |
ILabelProvider labelProvider = new FilteredCdmResourceLabelProvider(); |
|
100 |
setListLabelProvider(labelProvider); |
|
101 |
setDetailsLabelProvider(labelProvider); |
|
98 |
setListLabelProvider(createListLabelProvider()); |
|
99 |
setDetailsLabelProvider(createDetailsLabelProvider()); |
|
102 | 100 |
|
103 | 101 |
setSelectionHistory(new ResourceSelectionHistory()); |
104 | 102 |
} |
105 | 103 |
|
104 |
/** |
|
105 |
* By default, we are returning the standard list label provider |
|
106 |
* |
|
107 |
* Override in subclasses if you want different behavior |
|
108 |
* |
|
109 |
* @return |
|
110 |
*/ |
|
111 |
protected ILabelProvider createDetailsLabelProvider() { |
|
112 |
return createListLabelProvider(); |
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* |
|
117 |
* @return |
|
118 |
*/ |
|
119 |
protected ILabelProvider createListLabelProvider() { |
|
120 |
return new FilteredCdmResourceLabelProvider(); |
|
121 |
} |
|
122 |
|
|
106 | 123 |
/** |
107 | 124 |
* Override in subclasses. |
108 | 125 |
* Will run before initModel() |
... | ... | |
185 | 202 |
if (cdmObject instanceof IIdentifiableEntity) { |
186 | 203 |
return ((IIdentifiableEntity) cdmObject).getTitleCache(); |
187 | 204 |
} |
188 |
return null; |
|
205 |
throw new IllegalArgumentException("Generic method only" + |
|
206 |
" supports cdmObject of type IIdentifiableEntity." + |
|
207 |
" Please implement specific method in subclass."); |
|
189 | 208 |
} |
190 | 209 |
|
191 | 210 |
|
... | ... | |
266 | 285 |
// this also is not the nicest way to do it. |
267 | 286 |
// I am still amazed, that FilteredSelectionDialog does not offer any methods to change its data |
268 | 287 |
// once it was opened. Am I doing it wrong? |
269 |
((Text) getPatternControl()).setText(getTitle(cdmObject)); |
|
288 |
String pattern = getTitle(cdmObject); |
|
289 |
((Text) getPatternControl()).setText(pattern); |
|
270 | 290 |
} |
271 | 291 |
|
272 | 292 |
/* (non-Javadoc) |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialogs/filteredSelection/GroupSelectionDialog.java | ||
---|---|---|
89 | 89 |
protected Group getPersistentObject(UUID uuid) { |
90 | 90 |
return CdmStore.getService(IGroupService.class).load(uuid); |
91 | 91 |
} |
92 |
|
|
93 |
@Override |
|
94 |
protected String getTitle(Group group) { |
|
95 |
return group != null ? group.getName() : ""; |
|
96 |
} |
|
92 | 97 |
|
93 | 98 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialogs/filteredSelection/UserSelectionDialog.java | ||
---|---|---|
96 | 96 |
return CdmStore.getService(IUserService.class).load(uuid); |
97 | 97 |
} |
98 | 98 |
|
99 |
@Override |
|
100 |
protected String getTitle(User user) { |
|
101 |
return user != null ? user.getUsername() : ""; |
|
102 |
} |
|
103 |
|
|
99 | 104 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/group/MemberDetailElement.java | ||
---|---|---|
66 | 66 |
selection_user = (UserSelectionElement) formFactory |
67 | 67 |
.createSelectionElement(SelectionType.USER, |
68 | 68 |
getConversationHolder(), element, "Member", entity, |
69 |
UserSelectionElement.DEFAULT, style);
|
|
69 |
UserSelectionElement.EDITABLE, style);
|
|
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
/* |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EditFromSelectionWizard.java | ||
---|---|---|
22 | 22 |
import eu.etaxonomy.cdm.model.agent.Institution; |
23 | 23 |
import eu.etaxonomy.cdm.model.agent.Person; |
24 | 24 |
import eu.etaxonomy.cdm.model.agent.Team; |
25 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
|
25 |
import eu.etaxonomy.cdm.model.common.ICdmBase; |
|
26 |
import eu.etaxonomy.cdm.model.common.User; |
|
26 | 27 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
27 | 28 |
import eu.etaxonomy.cdm.model.occurrence.Collection; |
28 | 29 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase; |
... | ... | |
40 | 41 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventWizardPage; |
41 | 42 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeneralWizardPage; |
42 | 43 |
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceWizardPage; |
44 |
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailWizardPage; |
|
43 | 45 |
|
44 | 46 |
/** |
45 | 47 |
* <p> |
... | ... | |
75 | 77 |
public void addPages() { |
76 | 78 |
|
77 | 79 |
CdmFormFactory formFactory = selectionElement.getFormFactory(); |
78 |
IdentifiableEntity entity = (IdentifiableEntity) HibernateProxyHelper
|
|
80 |
ICdmBase entity = (ICdmBase) HibernateProxyHelper
|
|
79 | 81 |
.deproxy(selectionElement.getEntity()); |
80 | 82 |
|
81 | 83 |
if (entity instanceof Reference) { |
... | ... | |
120 | 122 |
addPage(new InstitutionWizardPage(formFactory, |
121 | 123 |
selectionElement.getConversationHolder(), |
122 | 124 |
(Institution) entity)); |
125 |
} else if (entity instanceof User) { |
|
126 |
addPage(new UserDetailWizardPage(formFactory, |
|
127 |
selectionElement.getConversationHolder(), |
|
128 |
(User) entity)); |
|
123 | 129 |
} else { |
124 | 130 |
StoreUtil.warningDialog("Missing interface", this, |
125 | 131 |
"No detail element for current selection"); |
126 |
} |
|
132 |
}
|
|
127 | 133 |
|
128 | 134 |
} |
129 | 135 |
|
Also available in: Unified diff
Fixes a couple of problems with user and group selection dialogs.