Revision 235fd63d
Added by Katja Luther over 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalAuthorSelectionDialog.java | ||
---|---|---|
13 | 13 |
import java.text.Collator; |
14 | 14 |
import java.util.Comparator; |
15 | 15 |
|
16 |
import org.eclipse.core.runtime.Assert; |
|
17 |
import org.eclipse.core.runtime.ListenerList; |
|
18 |
import org.eclipse.jface.viewers.IColorProvider; |
|
19 |
import org.eclipse.jface.viewers.IFontProvider; |
|
20 |
import org.eclipse.jface.viewers.ILabelDecorator; |
|
21 | 16 |
import org.eclipse.jface.viewers.ILabelProvider; |
22 |
import org.eclipse.jface.viewers.ILabelProviderListener; |
|
23 | 17 |
import org.eclipse.jface.viewers.LabelProvider; |
24 |
import org.eclipse.jface.viewers.LabelProviderChangedEvent; |
|
25 |
import org.eclipse.jface.viewers.StyledCellLabelProvider; |
|
26 |
import org.eclipse.jface.viewers.StyledString; |
|
27 |
import org.eclipse.jface.viewers.ViewerCell; |
|
28 |
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; |
|
29 |
import org.eclipse.swt.SWT; |
|
30 |
import org.eclipse.swt.graphics.Color; |
|
31 |
import org.eclipse.swt.graphics.Font; |
|
32 |
import org.eclipse.swt.graphics.GC; |
|
33 |
import org.eclipse.swt.graphics.Image; |
|
34 |
import org.eclipse.swt.graphics.Rectangle; |
|
35 | 18 |
import org.eclipse.swt.widgets.Control; |
36 |
import org.eclipse.swt.widgets.Display; |
|
37 | 19 |
import org.eclipse.swt.widgets.Shell; |
38 | 20 |
import org.eclipse.swt.widgets.Text; |
39 |
import org.eclipse.ui.internal.IWorkbenchGraphicConstants; |
|
40 |
import org.eclipse.ui.internal.WorkbenchImages; |
|
41 | 21 |
|
42 | 22 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
43 | 23 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
... | ... | |
50 | 30 |
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys; |
51 | 31 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
52 | 32 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
53 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.AbstractFilteredCdmResourceSelectionDialog.FilteredCdmResourceLabelProvider; |
|
54 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.CdmFilteredItemsSelectionDialog.ItemsFilter; |
|
55 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.CdmFilteredItemsSelectionDialog.ItemsListSeparator; |
|
56 | 33 |
|
57 | 34 |
/** |
58 | 35 |
* @author k.luther |
... | ... | |
83 | 60 |
if (control != null){ |
84 | 61 |
pattern = ((Text)control).getText(); |
85 | 62 |
} |
86 |
|
|
87 |
model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern, null); |
|
63 |
if (pattern == null || pattern.equals("?")){ |
|
64 |
model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(null, null, null); |
|
65 |
}else{ |
|
66 |
model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern, null); |
|
67 |
} |
|
88 | 68 |
} |
89 | 69 |
|
90 | 70 |
/** {@inheritDoc} */ |
... | ... | |
145 | 125 |
" supports cdmObject of type IIdentifiableEntity." + |
146 | 126 |
" Please implement specific method in subclass."); |
147 | 127 |
} |
148 |
|
|
149 |
|
|
150 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
151 | 131 |
public class FilteredCdmResourceAbbrevLabelProvider extends LabelProvider { |
152 | 132 |
@Override |
153 | 133 |
public String getText(Object element) { |
... | ... | |
166 | 146 |
return abbrevTitleCache; |
167 | 147 |
} |
168 | 148 |
}; |
169 |
|
|
149 |
|
|
170 | 150 |
/** {@inheritDoc} */ |
171 | 151 |
@Override |
172 | 152 |
protected ItemsFilter createFilter() { |
... | ... | |
192 | 172 |
if(item instanceof UuidAndTitleCache){ |
193 | 173 |
if (((UuidAndTitleCache) item).getAbbrevTitleCache() != null){ |
194 | 174 |
abbrevTitleCache = ((UuidAndTitleCache) item).getAbbrevTitleCache(); |
195 |
}
|
|
175 |
} |
|
196 | 176 |
if (((UuidAndTitleCache) item).getTitleCache() != null ){ |
197 | 177 |
textTitleCache = ((UuidAndTitleCache) item).getTitleCache(); |
198 | 178 |
} |
199 | 179 |
}else if(item instanceof String){ |
200 | 180 |
textTitleCache = (String) item; |
201 | 181 |
} |
202 |
|
|
182 |
|
|
203 | 183 |
return (matches(textTitleCache) || matches(abbrevTitleCache)) ; |
204 |
|
|
184 |
|
|
205 | 185 |
} |
206 | 186 |
|
207 | 187 |
}; |
208 | 188 |
} |
209 |
|
|
189 |
|
|
210 | 190 |
@Override |
211 | 191 |
protected Comparator getItemsComparator() { |
212 | 192 |
return new Comparator<UuidAndTitleCache>() { |
... | ... | |
221 | 201 |
if (entity1.getTitleCache() != null){ |
222 | 202 |
compareString1 += entity1.getTitleCache(); |
223 | 203 |
} |
224 |
|
|
225 |
|
|
204 |
|
|
205 |
|
|
226 | 206 |
String compareString2 = ""; |
227 | 207 |
if (entity2.getAbbrevTitleCache() != null){ |
228 | 208 |
compareString2 = entity2.getAbbrevTitleCache(); |
... | ... | |
230 | 210 |
if (entity2.getTitleCache() != null){ |
231 | 211 |
compareString2 += entity2.getTitleCache(); |
232 | 212 |
} |
233 |
|
|
234 |
|
|
213 |
|
|
214 |
|
|
235 | 215 |
return collator.compare(compareString1, compareString2); |
236 | 216 |
} |
237 | 217 |
}; |
Also available in: Unified diff
fix #6342: fix exception when using ? in selection dialog