132 |
132 |
private static final String IN_VIEW_PREFIX = "in view : ";
|
133 |
133 |
|
134 |
134 |
private boolean isTaxaTableInitialised = false;
|
|
135 |
|
135 |
136 |
private boolean isFiltertableInitialised = false;
|
136 |
137 |
|
137 |
138 |
private String selectedTaxaTableMenuItem = null;
|
138 |
139 |
|
139 |
140 |
ContextMenu taxaTableContextMenu;
|
140 |
141 |
|
|
142 |
private List<String> columnIds;
|
|
143 |
|
141 |
144 |
/**
|
142 |
145 |
* The constructor should first build the main layout, set the
|
143 |
146 |
* composition root and then do any custom initialization.
|
... | ... | |
204 |
207 |
return null;
|
205 |
208 |
}
|
206 |
209 |
|
207 |
|
private void initTaxaTable(int classificationId) {
|
|
210 |
private void initTaxaTable() {
|
208 |
211 |
taxaTreeTable.setMultiSelect(taxaTreeTableMultiSelectMode);
|
209 |
212 |
taxaTreeTable.setImmediate(false);
|
210 |
213 |
taxaTreeTable.setDragMode(TableDragMode.ROW);
|
211 |
|
if(listener != null) {
|
212 |
|
List<String> columnIds = new ArrayList<String>();
|
213 |
|
columnIds.add(LeafNodeTaxonContainer.NAME_ID);
|
214 |
|
taxaTreeTable.setColumnExpandRatio(LeafNodeTaxonContainer.NAME_ID, 1);
|
215 |
|
columnIds.add(LeafNodeTaxonContainer.PB_ID);
|
216 |
|
taxaTreeTable.setColumnWidth(LeafNodeTaxonContainer.PB_ID, 25);
|
217 |
|
|
218 |
|
if(!isTaxaTableInitialised) {
|
219 |
|
taxaTreeTable.addGeneratedColumn(LeafNodeTaxonContainer.PB_ID, new TaxonTableCheckBoxGenerator());
|
220 |
|
}
|
|
214 |
columnIds = new ArrayList<String>();
|
|
215 |
columnIds.add(LeafNodeTaxonContainer.NAME_ID);
|
|
216 |
taxaTreeTable.setColumnExpandRatio(LeafNodeTaxonContainer.NAME_ID, 1);
|
|
217 |
columnIds.add(LeafNodeTaxonContainer.PB_ID);
|
|
218 |
taxaTreeTable.setColumnWidth(LeafNodeTaxonContainer.PB_ID, 25);
|
221 |
219 |
|
222 |
|
try {
|
223 |
|
taxaTreeTable.setContainerDataSource(listener.loadTaxa(classificationId), columnIds);
|
224 |
|
} catch (SQLException e) {
|
225 |
|
//TODO : throw up warning dialog
|
226 |
|
e.printStackTrace();
|
227 |
|
}
|
228 |
220 |
|
|
221 |
taxaTreeTable.addGeneratedColumn(LeafNodeTaxonContainer.PB_ID, new TaxonTableCheckBoxGenerator());
|
229 |
222 |
|
230 |
|
taxaTreeTable.setCellStyleGenerator(new Table.CellStyleGenerator() {
|
231 |
|
|
232 |
|
@Override
|
233 |
|
public String getStyle(Table source, Object itemId, Object propertyId) {
|
234 |
|
if(source.getItem(itemId) == null) {
|
235 |
|
return null;
|
236 |
|
}
|
237 |
|
if(listener.isSynonym(itemId)) {
|
238 |
|
// this is a synonym, so we activate the corresponding css class
|
239 |
|
return "synonym";
|
240 |
|
} else {
|
241 |
|
return "taxon";
|
242 |
|
}
|
|
223 |
taxaTreeTable.setCellStyleGenerator(new Table.CellStyleGenerator() {
|
243 |
224 |
|
|
225 |
@Override
|
|
226 |
public String getStyle(Table source, Object itemId, Object propertyId) {
|
|
227 |
if(source.getItem(itemId) == null) {
|
|
228 |
return null;
|
|
229 |
}
|
|
230 |
if(listener.isSynonym(itemId)) {
|
|
231 |
// this is a synonym, so we activate the corresponding css class
|
|
232 |
return "synonym";
|
|
233 |
} else {
|
|
234 |
return "taxon";
|
244 |
235 |
}
|
245 |
|
});
|
246 |
|
|
247 |
|
taxaTreeTable.setSortContainerPropertyId(LeafNodeTaxonContainer.NAME_ID);
|
248 |
236 |
|
249 |
|
// NOTE : Not really sure why we need to refresh the container here.
|
250 |
|
// in the case of 'Table' this is not required
|
251 |
|
listener.refresh();
|
252 |
|
updateInViewLabel();
|
253 |
|
isTaxaTableInitialised = true;
|
254 |
|
}
|
|
237 |
}
|
|
238 |
});
|
255 |
239 |
|
256 |
240 |
taxaTableContextMenu = new ContextMenu();
|
257 |
241 |
taxaTableContextMenu.setAsContextMenuOf(taxaTreeTable);
|
258 |
242 |
addTaxaTreeContextMenuItemListener();
|
|
243 |
isTaxaTableInitialised = true;
|
|
244 |
}
|
259 |
245 |
|
|
246 |
private void refreshTaxaTable(int classificationId) {
|
|
247 |
if(!isTaxaTableInitialised) {
|
|
248 |
initTaxaTable();
|
|
249 |
}
|
|
250 |
|
|
251 |
try {
|
|
252 |
// Cannot use the setContainerDataSource method which has the column ids as
|
|
253 |
// second argument, since this method is taken from the Table class and
|
|
254 |
// hence the container strategy is not set to null, implying that the old
|
|
255 |
// preorder list is not cleaned up - potential bug in the tree table api ?
|
|
256 |
taxaTreeTable.setContainerDataSource(listener.loadTaxa(classificationId));
|
|
257 |
taxaTreeTable.setVisibleColumns(LeafNodeTaxonContainer.NAME_ID, LeafNodeTaxonContainer.PB_ID);
|
|
258 |
} catch (SQLException e) {
|
|
259 |
//TODO : throw up warning dialog
|
|
260 |
e.printStackTrace();
|
|
261 |
}
|
|
262 |
// We need to set the sort property id to null and then
|
|
263 |
// reset it to the name column else the sort is not performed
|
|
264 |
// since the sort property id has not changed - potential bug
|
|
265 |
// in the tree table api ?
|
|
266 |
taxaTreeTable.setSortContainerPropertyId(null);
|
|
267 |
taxaTreeTable.setSortContainerPropertyId(LeafNodeTaxonContainer.NAME_ID);
|
|
268 |
updateInViewLabel();
|
260 |
269 |
|
261 |
270 |
}
|
262 |
271 |
|
... | ... | |
277 |
286 |
}
|
278 |
287 |
}
|
279 |
288 |
|
280 |
|
|
281 |
|
|
282 |
289 |
private void initFilterTable() {
|
283 |
290 |
filterTable.setNullSelectionAllowed(false);
|
284 |
291 |
final IndexedContainer container = new IndexedContainer();
|
... | ... | |
380 |
387 |
if (classificationComboBox.getValue() != null) {
|
381 |
388 |
Object selected = classificationComboBox.getValue();
|
382 |
389 |
int classificationId = (Integer)((RowId)selected).getId()[0];
|
383 |
|
initTaxaTable(classificationId);
|
|
390 |
refreshTaxaTable(classificationId);
|
384 |
391 |
initFilterTable();
|
385 |
392 |
setEnabledAll(true);
|
386 |
393 |
}
|
StatusComposite : seperated init and refresh methods for the txa table, using seperate method to set visible comun ids
LeafNodeTaxonContainer : corrected isSynonym method