Revision 707b6237
Added by Niels Hoffmann over 12 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialogs/filteredSelection/TaxonNodeSelectionDialog.java | ||
---|---|---|
43 | 43 |
* @param node a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object. |
44 | 44 |
* @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object. |
45 | 45 |
*/ |
46 |
public static TaxonNode select(Shell shell, ConversationHolder conversation, String title, List<UUID> excludeTaxa, TaxonNode node) { |
|
46 |
public static TaxonNode select(Shell shell, ConversationHolder conversation, String title, List<UUID> excludeTaxa, TaxonNode node, Classification classification) {
|
|
47 | 47 |
TaxonNodeSelectionDialog dialog = new TaxonNodeSelectionDialog(shell, |
48 | 48 |
conversation, |
49 | 49 |
title, |
50 | 50 |
excludeTaxa, |
51 | 51 |
false, |
52 |
node); |
|
52 |
node, |
|
53 |
classification); |
|
53 | 54 |
return getSelectionFromDialog(dialog); |
54 | 55 |
} |
55 | 56 |
|
... | ... | |
58 | 59 |
private List<Classification> classifications; |
59 | 60 |
|
60 | 61 |
private Classification selectedClassification; |
62 |
|
|
63 |
private final Classification defaultClassification; |
|
61 | 64 |
|
62 | 65 |
|
63 | 66 |
/** |
... | ... | |
70 | 73 |
* @param multi a boolean. |
71 | 74 |
* @param node a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object. |
72 | 75 |
*/ |
73 |
protected TaxonNodeSelectionDialog(Shell shell, ConversationHolder conversation, String title, List<UUID> excludeTaxa, boolean multi, TaxonNode node) { |
|
76 |
protected TaxonNodeSelectionDialog(Shell shell, ConversationHolder conversation, String title, List<UUID> excludeTaxa, boolean multi, TaxonNode node, Classification classification) {
|
|
74 | 77 |
super(shell, conversation, title, multi, TaxonNodeSelectionDialog.class.getCanonicalName(), node); |
75 | 78 |
|
76 | 79 |
ILabelProvider labelProvider = new FilteredCdmResourceLabelProvider(); |
... | ... | |
78 | 81 |
setListLabelProvider(labelProvider); |
79 | 82 |
setDetailsLabelProvider(labelProvider); |
80 | 83 |
|
84 |
if(classification != null){ |
|
85 |
selectedClassification = classification; |
|
86 |
} |
|
87 |
defaultClassification = classification; |
|
81 | 88 |
} |
82 | 89 |
|
83 | 90 |
|
... | ... | |
87 | 94 |
/** {@inheritDoc} */ |
88 | 95 |
@Override |
89 | 96 |
protected Control createExtendedContentArea(Composite parent) { |
90 |
return createTreeSelectionCombo(parent);
|
|
97 |
return createClassificationSelectionCombo(parent);
|
|
91 | 98 |
} |
92 | 99 |
|
93 | 100 |
/* |
94 | 101 |
* currently disabled tree selection composite |
95 | 102 |
*/ |
96 |
private Control createTreeSelectionCombo(Composite parent){
|
|
103 |
private Control createClassificationSelectionCombo(Composite parent){
|
|
97 | 104 |
// classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null); |
98 | 105 |
|
99 | 106 |
Composite classificationSelection = new Composite(parent, SWT.NULL); |
... | ... | |
103 | 110 |
classificationSelection.setLayout(layout); |
104 | 111 |
|
105 | 112 |
Label label = new Label(classificationSelection, SWT.NULL); |
106 |
// TODO not working is not really true but leave it there to remind everyone that this is under construction
|
|
113 |
// TODO not working is not really true but leave it here to remind everyone that this is under construction |
|
107 | 114 |
label.setText("Select Classification (experimental)"); |
108 | 115 |
classificationSelectionCombo = new Combo(classificationSelection, SWT.BORDER | SWT.READ_ONLY); |
109 | 116 |
classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true)); |
... | ... | |
115 | 122 |
classificationSelectionCombo.select(classifications.indexOf(selectedClassification)); |
116 | 123 |
|
117 | 124 |
// TODO remember last selection |
118 |
|
|
119 | 125 |
classificationSelectionCombo.addSelectionListener(this); |
120 | 126 |
|
127 |
|
|
128 |
|
|
121 | 129 |
return classificationSelection; |
122 | 130 |
} |
123 | 131 |
|
124 | 132 |
/** {@inheritDoc} */ |
125 | 133 |
@Override |
126 | 134 |
protected String getTitle(TaxonNode taxonNode) { |
127 |
return taxonNode.getTaxon().getTitleCache(); |
|
135 |
if(taxonNode != null && taxonNode.getTaxon() != null){ |
|
136 |
return taxonNode.getTaxon().getTitleCache(); |
|
137 |
} |
|
138 |
|
|
139 |
return ""; |
|
128 | 140 |
} |
129 | 141 |
|
130 | 142 |
/* (non-Javadoc) |
... | ... | |
169 | 181 |
/** {@inheritDoc} */ |
170 | 182 |
public void widgetSelected(SelectionEvent e) { |
171 | 183 |
selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex()); |
172 |
refresh(); |
|
184 |
|
|
185 |
// refresh(); |
|
186 |
setPattern(null); |
|
173 | 187 |
} |
174 | 188 |
|
175 | 189 |
/** {@inheritDoc} */ |
Also available in: Unified diff
Merged with trunk