Revision 10cc0e5e
Added by Cherian Mathew almost 9 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/StatusComposite.java | ||
---|---|---|
47 | 47 |
import com.vaadin.ui.Label; |
48 | 48 |
import com.vaadin.ui.Notification; |
49 | 49 |
import com.vaadin.ui.Notification.Type; |
50 |
import com.vaadin.ui.TabSheet; |
|
50 | 51 |
import com.vaadin.ui.Table; |
51 | 52 |
import com.vaadin.ui.Table.ColumnHeaderMode; |
52 | 53 |
import com.vaadin.ui.Table.TableDragMode; |
... | ... | |
82 | 83 |
@AutoGenerated |
83 | 84 |
private Label inViewLabel; |
84 | 85 |
@AutoGenerated |
85 |
private TreeTable taxaTreeTable;
|
|
86 |
private TabSheet taxaTabSheet;
|
|
86 | 87 |
@AutoGenerated |
87 | 88 |
private HorizontalLayout searchHorizontalLayout; |
88 | 89 |
@AutoGenerated |
... | ... | |
100 | 101 |
private static final Logger logger = Logger.getLogger(StatusComposite.class); |
101 | 102 |
private StatusComponentListener listener; |
102 | 103 |
|
103 |
|
|
104 |
private TreeTable mainTaxaTreeTable, excludedTaxaTreeTable; |
|
104 | 105 |
|
105 | 106 |
|
106 | 107 |
private static final String SELECT_CLASSIFICATION = "Select classification ..."; |
... | ... | |
149 | 150 |
|
150 | 151 |
this.listener = new StatusPresenter(); |
151 | 152 |
CdmVaadinSessionUtilities.getCurrentCdmDataChangeService().register(this); |
152 |
addUIListeners(); |
|
153 | 153 |
|
154 |
initSearchTextField(); |
|
155 |
initClearSearchButton(); |
|
156 |
setEnabledAll(false); |
|
154 |
|
|
155 |
|
|
157 | 156 |
|
158 | 157 |
init(); |
158 |
|
|
159 |
addUIListeners(); |
|
159 | 160 |
} |
160 | 161 |
|
161 | 162 |
|
... | ... | |
174 | 175 |
} |
175 | 176 |
|
176 | 177 |
public void init() { |
178 |
initSearchTextField(); |
|
179 |
initClearSearchButton(); |
|
180 |
initTaxaTabSheet(); |
|
177 | 181 |
initClassificationComboBox(); |
182 |
|
|
183 |
setEnabledAll(false); |
|
178 | 184 |
setExpandRatios(); |
179 | 185 |
} |
180 | 186 |
|
... | ... | |
188 | 194 |
|
189 | 195 |
public void setEnabledAll(boolean enabled) { |
190 | 196 |
CdmVaadinUtilities.setEnabled(mainLayout, enabled, Arrays.asList(classificationComboBox)); |
197 |
taxaTabSheet.getTab(mainTaxaTreeTable).setEnabled(enabled); |
|
198 |
taxaTabSheet.getTab(excludedTaxaTreeTable).setEnabled(enabled); |
|
191 | 199 |
} |
192 | 200 |
|
193 | 201 |
|
194 | 202 |
public TreeTable getTaxaTreeTable() { |
195 |
return taxaTreeTable;
|
|
203 |
return mainTaxaTreeTable;
|
|
196 | 204 |
} |
197 | 205 |
|
198 | 206 |
public LeafNodeTaxonContainer getTaxonContainer() { |
... | ... | |
200 | 208 |
} |
201 | 209 |
|
202 | 210 |
public void clearTaxaTableSelections() { |
203 |
taxaTreeTable.setValue(null);
|
|
211 |
mainTaxaTreeTable.setValue(null);
|
|
204 | 212 |
} |
205 | 213 |
|
206 | 214 |
public UUID getSelectedClassificationUuid() { |
... | ... | |
210 | 218 |
return null; |
211 | 219 |
} |
212 | 220 |
|
213 |
private void initTaxaTable() { |
|
214 |
taxaTreeTable.setSelectable(true);
|
|
215 |
taxaTreeTable.setImmediate(true);
|
|
216 |
taxaTreeTable.setDragMode(TableDragMode.ROW);
|
|
221 |
private void initMainTaxaTable() {
|
|
222 |
mainTaxaTreeTable.setSelectable(true);
|
|
223 |
mainTaxaTreeTable.setImmediate(true);
|
|
224 |
mainTaxaTreeTable.setDragMode(TableDragMode.ROW);
|
|
217 | 225 |
|
218 |
taxaTreeTable.setColumnExpandRatio(LeafNodeTaxonContainer.NAME_ID, 1);
|
|
219 |
taxaTreeTable.setColumnWidth(LeafNodeTaxonContainer.PB_ID, 25);
|
|
226 |
mainTaxaTreeTable.setColumnExpandRatio(LeafNodeTaxonContainer.NAME_ID, 1);
|
|
227 |
mainTaxaTreeTable.setColumnWidth(LeafNodeTaxonContainer.PB_ID, 25);
|
|
220 | 228 |
|
221 | 229 |
|
222 |
taxaTreeTable.addGeneratedColumn(LeafNodeTaxonContainer.PB_ID, new TaxonTableCheckBoxGenerator());
|
|
230 |
mainTaxaTreeTable.addGeneratedColumn(LeafNodeTaxonContainer.PB_ID, new TaxonTableCheckBoxGenerator());
|
|
223 | 231 |
|
224 |
taxaTreeTable.setCellStyleGenerator(new Table.CellStyleGenerator() {
|
|
232 |
mainTaxaTreeTable.setCellStyleGenerator(new Table.CellStyleGenerator() {
|
|
225 | 233 |
|
226 | 234 |
@Override |
227 | 235 |
public String getStyle(Table source, Object itemId, Object propertyId) { |
... | ... | |
239 | 247 |
}); |
240 | 248 |
|
241 | 249 |
taxaTableContextMenu = new ContextMenu(); |
242 |
taxaTableContextMenu.setAsContextMenuOf(taxaTreeTable);
|
|
250 |
taxaTableContextMenu.setAsContextMenuOf(mainTaxaTreeTable);
|
|
243 | 251 |
addTaxaTreeContextMenuItemListener(); |
244 | 252 |
isTaxaTableInitialised = true; |
245 | 253 |
} |
246 | 254 |
|
247 | 255 |
private void refreshTaxaTable(int classificationId) { |
248 | 256 |
if(!isTaxaTableInitialised) { |
249 |
initTaxaTable(); |
|
257 |
initMainTaxaTable();
|
|
250 | 258 |
} |
251 | 259 |
|
252 | 260 |
try { |
... | ... | |
254 | 262 |
// second argument, since this method is taken from the Table class and |
255 | 263 |
// hence the container strategy is not set to null, implying that the old |
256 | 264 |
// preorder list is not cleaned up - potential bug in the tree table api ? |
257 |
taxaTreeTable.setContainerDataSource(listener.loadTaxa(classificationId));
|
|
258 |
taxaTreeTable.setVisibleColumns(LeafNodeTaxonContainer.NAME_ID, LeafNodeTaxonContainer.PB_ID);
|
|
265 |
mainTaxaTreeTable.setContainerDataSource(listener.loadTaxa(classificationId));
|
|
266 |
mainTaxaTreeTable.setVisibleColumns(LeafNodeTaxonContainer.NAME_ID, LeafNodeTaxonContainer.PB_ID);
|
|
259 | 267 |
} catch (SQLException e) { |
260 | 268 |
//TODO : throw up warning dialog |
261 | 269 |
e.printStackTrace(); |
... | ... | |
264 | 272 |
// reset it to the name column else the sort is not performed |
265 | 273 |
// since the sort property id has not changed - potential bug |
266 | 274 |
// in the tree table api ? |
267 |
taxaTreeTable.setSortContainerPropertyId(null);
|
|
268 |
taxaTreeTable.setSortContainerPropertyId(LeafNodeTaxonContainer.NAME_ID);
|
|
275 |
mainTaxaTreeTable.setSortContainerPropertyId(null);
|
|
276 |
mainTaxaTreeTable.setSortContainerPropertyId(LeafNodeTaxonContainer.NAME_ID);
|
|
269 | 277 |
updateInViewLabel(); |
270 | 278 |
|
271 | 279 |
} |
... | ... | |
287 | 295 |
} |
288 | 296 |
} |
289 | 297 |
|
298 |
private void initTaxaTabSheet() { |
|
299 |
mainTaxaTreeTable = buildTaxaTreeTable(); |
|
300 |
mainTaxaTreeTable.setCaption("Main"); |
|
301 |
|
|
302 |
excludedTaxaTreeTable = buildTaxaTreeTable(); |
|
303 |
excludedTaxaTreeTable.setCaption("Excluded"); |
|
304 |
|
|
305 |
taxaTabSheet.addComponent(mainTaxaTreeTable); |
|
306 |
taxaTabSheet.addComponent(excludedTaxaTreeTable); |
|
307 |
} |
|
308 |
|
|
290 | 309 |
private void initFilterTable() { |
291 | 310 |
filterTable.setNullSelectionAllowed(false); |
292 | 311 |
final IndexedContainer container = new IndexedContainer(); |
... | ... | |
391 | 410 |
|
392 | 411 |
setEnabledAll(false); |
393 | 412 |
filterTable.setReadOnly(true); |
394 |
taxaTreeTable.setSelectable(false);
|
|
413 |
mainTaxaTreeTable.setSelectable(false);
|
|
395 | 414 |
|
396 | 415 |
CdmVaadinUtilities.exec(new CdmVaadinOperation(100, null) { |
397 | 416 |
|
... | ... | |
407 | 426 |
initFilterTable(); |
408 | 427 |
setEnabledAll(true); |
409 | 428 |
filterTable.setReadOnly(false); |
410 |
taxaTreeTable.setSelectable(true);
|
|
429 |
mainTaxaTreeTable.setSelectable(true);
|
|
411 | 430 |
} |
412 | 431 |
}); |
413 | 432 |
|
... | ... | |
419 | 438 |
|
420 | 439 |
private void addTaxaTreeTableListener() { |
421 | 440 |
|
422 |
taxaTreeTable.addValueChangeListener(new ValueChangeListener() {
|
|
441 |
mainTaxaTreeTable.addValueChangeListener(new ValueChangeListener() {
|
|
423 | 442 |
|
424 | 443 |
@Override |
425 | 444 |
public void valueChange(ValueChangeEvent event) { |
426 |
Object itemId = taxaTreeTable.getValue();
|
|
445 |
Object itemId = mainTaxaTreeTable.getValue();
|
|
427 | 446 |
Object taxonIun = null; |
428 |
if(taxaTreeTable.isSelectable() && itemId != null) {
|
|
447 |
if(mainTaxaTreeTable.isSelectable() && itemId != null) {
|
|
429 | 448 |
boolean isSynonym = listener.isSynonym(itemId); |
430 | 449 |
if(!isSynonym) { |
431 | 450 |
UUID taxonUuid = listener.getCurrentLeafNodeTaxonContainer().getUuid(itemId); |
... | ... | |
439 | 458 |
} |
440 | 459 |
}); |
441 | 460 |
|
442 |
taxaTreeTable.addItemClickListener(new ItemClickListener() {
|
|
461 |
mainTaxaTreeTable.addItemClickListener(new ItemClickListener() {
|
|
443 | 462 |
@Override |
444 | 463 |
public void itemClick(ItemClickEvent event) { |
445 | 464 |
Object itemId = event.getItemId(); |
446 |
if(taxaTreeTable.isSelectable() && itemId != null) {
|
|
465 |
if(mainTaxaTreeTable.isSelectable() && itemId != null) {
|
|
447 | 466 |
boolean isSynonym = listener.isSynonym(itemId); |
448 |
taxaTreeTable.setValue(itemId);
|
|
467 |
mainTaxaTreeTable.setValue(itemId);
|
|
449 | 468 |
generateTaxaTreeTableContextMenu(isSynonym); |
450 | 469 |
} |
451 | 470 |
} |
... | ... | |
523 | 542 |
IdUuidName accTaxonIdUuid = null; |
524 | 543 |
String accTaxonName = null; |
525 | 544 |
if(action.equals(CREATE_SYNONYM)) { |
526 |
selectedItemId = taxaTreeTable.getValue();
|
|
545 |
selectedItemId = mainTaxaTreeTable.getValue();
|
|
527 | 546 |
|
528 | 547 |
// if a synonym is selected then throw warning |
529 | 548 |
if(listener.isSynonym(selectedItemId)) { |
... | ... | |
685 | 704 |
// filter in only the newly created taxon and select it |
686 | 705 |
clearDynamicFilters(); |
687 | 706 |
listener.setIdFilter(itemId); |
688 |
taxaTreeTable.setValue(itemId);
|
|
707 |
mainTaxaTreeTable.setValue(itemId);
|
|
689 | 708 |
} else { |
690 | 709 |
// after creating a new synonym we expand the selected taxon |
691 | 710 |
// and select the newly created synonym |
692 |
taxaTreeTable.setCollapsed(taxaTreeTable.getValue(), false);
|
|
711 |
mainTaxaTreeTable.setCollapsed(mainTaxaTreeTable.getValue(), false);
|
|
693 | 712 |
listener.refresh(); |
694 |
taxaTreeTable.setValue(itemId);
|
|
713 |
mainTaxaTreeTable.setValue(itemId);
|
|
695 | 714 |
} |
696 | 715 |
|
697 | 716 |
} |
... | ... | |
724 | 743 |
|
725 | 744 |
} |
726 | 745 |
|
746 |
private TreeTable buildTaxaTreeTable() { |
|
747 |
TreeTable taxaTreeTable = new TreeTable(); |
|
748 |
taxaTreeTable.setImmediate(false); |
|
749 |
taxaTreeTable.setWidth("100.0%"); |
|
750 |
taxaTreeTable.setHeight("100.0%"); |
|
751 |
return taxaTreeTable; |
|
752 |
} |
|
753 |
|
|
727 | 754 |
@AutoGenerated |
728 | 755 |
private GridLayout buildMainLayout() { |
729 | 756 |
// common part: create layout |
... | ... | |
756 | 783 |
mainLayout.addComponent(searchHorizontalLayout, 0, 2); |
757 | 784 |
mainLayout.setComponentAlignment(searchHorizontalLayout, new Alignment(48)); |
758 | 785 |
|
759 |
// taxaTreeTable
|
|
760 |
taxaTreeTable = new TreeTable();
|
|
761 |
taxaTreeTable.setImmediate(false);
|
|
762 |
taxaTreeTable.setWidth("100.0%");
|
|
763 |
taxaTreeTable.setHeight("100.0%");
|
|
764 |
mainLayout.addComponent(taxaTreeTable, 0, 3);
|
|
765 |
mainLayout.setComponentAlignment(taxaTreeTable, new Alignment(20));
|
|
786 |
// taxaTabSheet
|
|
787 |
taxaTabSheet = new TabSheet();
|
|
788 |
taxaTabSheet.setImmediate(false);
|
|
789 |
taxaTabSheet.setWidth("100.0%");
|
|
790 |
taxaTabSheet.setHeight("100.0%");
|
|
791 |
mainLayout.addComponent(taxaTabSheet, 0, 3);
|
|
792 |
mainLayout.setComponentAlignment(taxaTabSheet, new Alignment(20));
|
|
766 | 793 |
|
767 | 794 |
// inViewLabel |
768 | 795 |
inViewLabel = new Label(); |
... | ... | |
814 | 841 |
searchHorizontalLayout = new HorizontalLayout(); |
815 | 842 |
searchHorizontalLayout.setImmediate(false); |
816 | 843 |
searchHorizontalLayout.setWidth("100.0%"); |
817 |
searchHorizontalLayout.setHeight("100.0%");
|
|
844 |
searchHorizontalLayout.setHeight("-1px");
|
|
818 | 845 |
searchHorizontalLayout.setMargin(false); |
819 | 846 |
searchHorizontalLayout.setSpacing(true); |
820 | 847 |
|
Also available in: Unified diff
NewTaxonBaseComposite : add exception handling when name already exists
StatusComposite : added tab sheet with main / excluded tabs
CdmQueryFactory, LeafNodeTaxonContainer : added rank filter for ranks below species aggregate
NewTaxonBasePresenter : added check if name exists
NewTaxonBasePresenterTest (.xml) : corrected data for valid names and added test for name check
CdmVaadinOperation : added method to set exception