Revision 08a29cf3
Added by Katja Luther over 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalReferenceSelectionDialog.java | ||
---|---|---|
3 | 3 |
import java.text.Collator; |
4 | 4 |
import java.util.Comparator; |
5 | 5 |
|
6 |
import org.eclipse.core.runtime.Assert; |
|
7 |
import org.eclipse.core.runtime.ListenerList; |
|
8 |
import org.eclipse.jface.viewers.IColorProvider; |
|
9 |
import org.eclipse.jface.viewers.IFontProvider; |
|
10 |
import org.eclipse.jface.viewers.ILabelDecorator; |
|
11 | 6 |
import org.eclipse.jface.viewers.ILabelProvider; |
12 |
import org.eclipse.jface.viewers.ILabelProviderListener; |
|
13 | 7 |
import org.eclipse.jface.viewers.LabelProvider; |
14 |
import org.eclipse.jface.viewers.LabelProviderChangedEvent; |
|
15 |
import org.eclipse.jface.viewers.StyledCellLabelProvider; |
|
16 |
import org.eclipse.jface.viewers.StyledString; |
|
17 |
import org.eclipse.jface.viewers.ViewerCell; |
|
18 |
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; |
|
19 |
import org.eclipse.swt.SWT; |
|
20 |
import org.eclipse.swt.graphics.Color; |
|
21 |
import org.eclipse.swt.graphics.Font; |
|
22 |
import org.eclipse.swt.graphics.GC; |
|
23 |
import org.eclipse.swt.graphics.Image; |
|
24 |
import org.eclipse.swt.graphics.Rectangle; |
|
25 | 8 |
import org.eclipse.swt.widgets.Control; |
26 |
import org.eclipse.swt.widgets.Display; |
|
27 | 9 |
import org.eclipse.swt.widgets.Shell; |
28 | 10 |
import org.eclipse.swt.widgets.Text; |
29 |
import org.eclipse.ui.internal.IWorkbenchGraphicConstants; |
|
30 |
import org.eclipse.ui.internal.WorkbenchImages; |
|
31 | 11 |
|
32 | 12 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
33 | 13 |
import eu.etaxonomy.cdm.api.service.IReferenceService; |
... | ... | |
36 | 16 |
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys; |
37 | 17 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
38 | 18 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
39 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.CdmFilteredItemsSelectionDialog.ItemsFilter; |
|
40 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.CdmFilteredItemsSelectionDialog.ItemsListSeparator; |
|
41 | 19 |
|
42 | 20 |
public class NomenclaturalReferenceSelectionDialog extends |
43 | 21 |
ReferenceSelectionDialog { |
... | ... | |
48 | 26 |
super(shell, conversation, title, multi, reference); |
49 | 27 |
// TODO Auto-generated constructor stub |
50 | 28 |
} |
51 |
|
|
29 |
|
|
52 | 30 |
/* (non-Javadoc) |
53 | 31 |
* @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel() |
54 | 32 |
*/ |
... | ... | |
64 | 42 |
|
65 | 43 |
model = CdmStore.getService(IReferenceService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern); |
66 | 44 |
} |
67 |
|
|
45 |
|
|
68 | 46 |
/** |
69 | 47 |
* |
70 | 48 |
* @return |
... | ... | |
73 | 51 |
protected ILabelProvider createListLabelProvider() { |
74 | 52 |
return new FilteredCdmResourceAbbrevLabelProvider(); |
75 | 53 |
} |
76 |
|
|
54 |
|
|
77 | 55 |
/** |
78 | 56 |
* <p>select</p> |
79 | 57 |
* |
... | ... | |
82 | 60 |
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object. |
83 | 61 |
* @return a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object. |
84 | 62 |
*/ |
85 |
|
|
63 |
|
|
86 | 64 |
public static Reference select(Shell shell, ConversationHolder conversation, Reference reference) { |
87 | 65 |
NomenclaturalReferenceSelectionDialog dialog = new NomenclaturalReferenceSelectionDialog(shell, conversation, |
88 | 66 |
"Choose a reference", false, reference); |
89 | 67 |
return getSelectionFromDialog(dialog); |
90 | 68 |
} |
91 |
|
|
69 |
|
|
92 | 70 |
/* (non-Javadoc) |
93 | 71 |
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createFilter() |
94 | 72 |
*/ |
... | ... | |
128 | 106 |
|
129 | 107 |
}; |
130 | 108 |
} |
131 |
|
|
132 | 109 |
|
133 |
|
|
110 |
|
|
111 |
|
|
134 | 112 |
public class FilteredCdmResourceAbbrevLabelProvider extends LabelProvider { |
135 | 113 |
@Override |
136 | 114 |
public String getText(Object element) { |
... | ... | |
149 | 127 |
return abbrevTitleCache; |
150 | 128 |
} |
151 | 129 |
}; |
152 |
|
|
130 |
|
|
153 | 131 |
@Override |
154 | 132 |
protected Comparator getItemsComparator() { |
155 | 133 |
return new Comparator<UuidAndTitleCache>() { |
... | ... | |
176 | 154 |
}; |
177 | 155 |
} |
178 | 156 |
|
157 |
@Override |
|
158 |
protected String getTitle(Reference cdmObject) { |
|
159 |
if(cdmObject == null){ |
|
160 |
return ""; |
|
161 |
} |
|
162 |
if (cdmObject.getAbbrevTitle() != null){ |
|
163 |
return cdmObject.getAbbrevTitleCache(); |
|
164 |
}else{ |
|
165 |
return cdmObject.getTitleCache(); |
|
166 |
} |
|
167 |
|
|
168 |
|
|
169 |
|
|
170 |
} |
|
171 |
|
|
172 |
|
|
179 | 173 |
|
180 | 174 |
|
181 | 175 |
} |
Also available in: Unified diff
the pattern for new created nomenclatural references with nomenclatural title is the nomenclatural title not titlecache