Revision 9d11084b
Added by Cherian Mathew almost 9 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/StatusComposite.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import java.sql.SQLException; |
13 | 13 |
import java.util.Arrays; |
14 |
import java.util.Set; |
|
15 | 14 |
import java.util.UUID; |
16 | 15 |
|
17 | 16 |
import org.apache.log4j.Logger; |
... | ... | |
102 | 101 |
private StatusComponentListener listener; |
103 | 102 |
|
104 | 103 |
|
105 |
private final boolean taxaTreeTableMultiSelectMode = true; |
|
104 |
|
|
106 | 105 |
|
107 | 106 |
private static final String SELECT_CLASSIFICATION = "Select classification ..."; |
108 | 107 |
|
109 | 108 |
|
110 |
private static final String CREATE_ACC_TAXON = "Create Accepted Taxon";
|
|
109 |
private static final String CREATE_NEW_TAXON = "Create New Taxon";
|
|
111 | 110 |
private static final String CHANGE_TO_ACC_TAXON = "Change to Accepted Taxon"; |
112 | 111 |
private static final String REPLACE_ACC_TAXON = "Replace Accepted Taxon"; |
113 | 112 |
private static final String CHANGE_TO_SYNONYM = "Change to Synonym"; |
... | ... | |
133 | 132 |
private boolean isFiltertableInitialised = false; |
134 | 133 |
|
135 | 134 |
|
136 |
|
|
137 |
ContextMenu taxaTableContextMenu; |
|
135 |
private NewTaxonBaseComposite currentNewTaxonBaseComponent; |
|
136 |
private ContextMenu taxaTableContextMenu;
|
|
138 | 137 |
|
139 | 138 |
|
140 | 139 |
/** |
... | ... | |
213 | 212 |
|
214 | 213 |
private void initTaxaTable() { |
215 | 214 |
taxaTreeTable.setSelectable(true); |
216 |
taxaTreeTable.setMultiSelect(taxaTreeTableMultiSelectMode); |
|
217 | 215 |
taxaTreeTable.setImmediate(true); |
218 | 216 |
taxaTreeTable.setDragMode(TableDragMode.ROW); |
219 | 217 |
|
... | ... | |
421 | 419 |
|
422 | 420 |
private void addTaxaTreeTableListener() { |
423 | 421 |
|
424 |
taxaTreeTable.addItemClickListener(new ItemClickListener() { |
|
422 |
taxaTreeTable.addValueChangeListener(new ValueChangeListener() { |
|
423 |
|
|
425 | 424 |
@Override |
426 |
public void itemClick(ItemClickEvent event) { |
|
427 |
Object itemId = event.getItemId(); |
|
428 |
if(taxaTreeTable.isSelectable()) { |
|
425 |
public void valueChange(ValueChangeEvent event) { |
|
426 |
Object itemId = taxaTreeTable.getValue(); |
|
427 |
Object taxonIun = null; |
|
428 |
if(taxaTreeTable.isSelectable() && itemId != null) { |
|
429 | 429 |
boolean isSynonym = listener.isSynonym(itemId); |
430 |
if(!CdmVaadinUtilities.isSelected(taxaTreeTable, itemId) && !isSynonym) {
|
|
430 |
if(!isSynonym) { |
|
431 | 431 |
UUID taxonUuid = listener.getCurrentLeafNodeTaxonContainer().getUuid(itemId); |
432 | 432 |
String taxonName = (String)listener.getCurrentLeafNodeTaxonContainer().getProperty(itemId, LeafNodeTaxonContainer.NAME_ID).getValue(); |
433 |
Object idUuidName = new IdUuidName(itemId, taxonUuid, taxonName); |
|
434 |
CdmVaadinSessionUtilities.getCurrentSelectionService() |
|
435 |
.fireSelectionEvent(new SelectionEvent(Arrays.asList(idUuidName, getSelectedClassificationUuid()), StatusComposite.class), true); |
|
436 |
} |
|
437 |
taxaTreeTable.setValue(Arrays.asList(itemId)); |
|
438 |
generateTaxaTreeTableContextMenu(isSynonym); |
|
433 |
taxonIun = new IdUuidName(itemId, taxonUuid, taxonName); |
|
439 | 434 |
|
435 |
} |
|
436 |
CdmVaadinSessionUtilities.getCurrentSelectionService() |
|
437 |
.fireSelectionEvent(new SelectionEvent(Arrays.asList(taxonIun, getSelectedClassificationUuid()), StatusComposite.class), true); |
|
440 | 438 |
} |
441 | 439 |
} |
442 | 440 |
}); |
443 | 441 |
|
444 |
//taxaTreeTable.add |
|
445 |
|
|
446 |
|
|
442 |
taxaTreeTable.addItemClickListener(new ItemClickListener() { |
|
443 |
@Override |
|
444 |
public void itemClick(ItemClickEvent event) { |
|
445 |
Object itemId = event.getItemId(); |
|
446 |
if(taxaTreeTable.isSelectable() && itemId != null) { |
|
447 |
boolean isSynonym = listener.isSynonym(itemId); |
|
448 |
taxaTreeTable.setValue(itemId); |
|
449 |
generateTaxaTreeTableContextMenu(isSynonym); |
|
450 |
} |
|
451 |
} |
|
452 |
}); |
|
447 | 453 |
} |
448 | 454 |
|
449 | 455 |
private void generateTaxaTreeTableContextMenu(boolean isSynonym) { |
... | ... | |
465 | 471 |
|
466 | 472 |
ContextMenuItem changeToSynMenuItem = taxaTableContextMenu.addItem(CHANGE_TO_SYNONYM); |
467 | 473 |
changeToSynMenuItem.setData(CHANGE_TO_SYNONYM); |
468 |
|
|
469 |
changeToSynMenuItem.setSeparatorVisible(true); |
|
470 | 474 |
} |
471 | 475 |
|
472 | 476 |
ContextMenuItem setDeletedMenuItem = taxaTableContextMenu.addItem(SET_AS_DELETED); |
... | ... | |
482 | 486 |
ContextMenuItem setOutOfScopeMenuItem = taxaTableContextMenu.addItem(SET_AS_OUT_OF_SCOPE); |
483 | 487 |
setOutOfScopeMenuItem.setData(SET_AS_OUT_OF_SCOPE); |
484 | 488 |
|
485 |
ContextMenuItem createAccTaxonMenuItem = taxaTableContextMenu.addItem(CREATE_ACC_TAXON); |
|
486 |
createAccTaxonMenuItem.setData(CREATE_ACC_TAXON); |
|
489 |
setOutOfScopeMenuItem.setSeparatorVisible(true); |
|
490 |
|
|
491 |
ContextMenuItem createAccTaxonMenuItem = taxaTableContextMenu.addItem(CREATE_NEW_TAXON); |
|
492 |
createAccTaxonMenuItem.setData(CREATE_NEW_TAXON); |
|
487 | 493 |
|
488 | 494 |
} |
489 | 495 |
|
... | ... | |
497 | 503 |
if(source instanceof ContextMenuItem) { |
498 | 504 |
ContextMenuItem menuItem = (ContextMenuItem) source; |
499 | 505 |
String action = (String)menuItem.getData(); |
500 |
if(CREATE_ACC_TAXON.equals(action) || CREATE_SYNONYM.equals(action)) {
|
|
506 |
if(CREATE_NEW_TAXON.equals(action) || CREATE_SYNONYM.equals(action)) {
|
|
501 | 507 |
showAddTaxonBaseWindow(action); |
502 | 508 |
} else { |
503 | 509 |
Notification.show(action + " to be implemented", Type.WARNING_MESSAGE); |
... | ... | |
517 | 523 |
IdUuidName accTaxonIdUuid = null; |
518 | 524 |
String accTaxonName = null; |
519 | 525 |
if(action.equals(CREATE_SYNONYM)) { |
520 |
Set<Object> selectedIds = (Set<Object>)taxaTreeTable.getValue(); |
|
521 |
// if zero or more than one items (taxa / synonyms) are selected |
|
522 |
// throw a warning |
|
523 |
if(selectedIds.size() != 1) { |
|
524 |
Notification.show("Multiple or No selection", "Please select a single Taxon", Type.WARNING_MESSAGE); |
|
525 |
return; |
|
526 |
} |
|
527 |
selectedItemId = selectedIds.iterator().next(); |
|
526 |
selectedItemId = taxaTreeTable.getValue(); |
|
527 |
|
|
528 | 528 |
// if a synonym is selected then throw warning |
529 | 529 |
if(listener.isSynonym(selectedItemId)) { |
530 | 530 |
Notification.show("Synonym selected", "Please choose a Taxon", Type.WARNING_MESSAGE); |
... | ... | |
550 | 550 |
IdUuidName classificationIdUuid = new IdUuidName(classificationComboBox.getValue(), |
551 | 551 |
classificationUuid, |
552 | 552 |
(String) listener.getClassificationContainer().getProperty(cId, StatusPresenter.C_TCACHE_ID).getValue()); |
553 |
NewTaxonBaseComposite newTaxonComponent = |
|
554 |
new NewTaxonBaseComposite(dialog, |
|
553 |
currentNewTaxonBaseComponent = new NewTaxonBaseComposite(dialog, |
|
555 | 554 |
new NewTaxonBasePresenter(), |
556 | 555 |
accTaxonIdUuid, |
557 | 556 |
accTaxonName, |
558 | 557 |
classificationIdUuid); |
559 |
dialog.setContent(newTaxonComponent);
|
|
558 |
dialog.setContent(currentNewTaxonBaseComponent);
|
|
560 | 559 |
} catch (SQLException e) { |
561 | 560 |
// TODO Auto-generated catch block |
562 | 561 |
e.printStackTrace(); |
... | ... | |
677 | 676 |
*/ |
678 | 677 |
@Override |
679 | 678 |
public void onCreate(CdmChangeEvent event) { |
680 |
if(event.getSourceType().equals(NewTaxonBaseComposite.class)) {
|
|
679 |
if(event.getSource() != null && event.getSource() == currentNewTaxonBaseComponent) {
|
|
681 | 680 |
Object itemId = event.getChangedObjects().get(0); |
682 |
try { |
|
683 |
taxaTreeTable.setMultiSelect(false); |
|
684 |
if(listener.getCurrentLeafNodeTaxonContainer().isSynonym(itemId)) { |
|
685 |
taxaTreeTable.setCollapsed(taxaTreeTable.getValue(), false); |
|
686 |
listener.refresh(); |
|
687 |
taxaTreeTable.setValue(itemId); |
|
688 |
} else { |
|
689 |
clearDynamicFilters(); |
|
690 |
listener.setIdFilter(itemId); |
|
691 |
taxaTreeTable.setValue(itemId); |
|
692 |
} |
|
693 |
} finally { |
|
694 |
taxaTreeTable.setMultiSelect(taxaTreeTableMultiSelectMode); |
|
681 |
boolean newTaxon= (Boolean) event.getChangedObjects().get(1); |
|
682 |
|
|
683 |
if(newTaxon) { |
|
684 |
// after creating a new taxon we clear all filters and |
|
685 |
// filter in only the newly created taxon and select it |
|
686 |
clearDynamicFilters(); |
|
687 |
listener.setIdFilter(itemId); |
|
688 |
taxaTreeTable.setValue(itemId); |
|
689 |
} else { |
|
690 |
// after creating a new synonym we expand the selected taxon |
|
691 |
// and select the newly created synonym |
|
692 |
taxaTreeTable.setCollapsed(taxaTreeTable.getValue(), false); |
|
693 |
listener.refresh(); |
|
694 |
taxaTreeTable.setValue(itemId); |
|
695 | 695 |
} |
696 |
|
|
696 | 697 |
} |
697 | 698 |
} |
698 | 699 |
|
Also available in: Unified diff
related to #4886
ConceptRelationshipComposite, D3ConceptRelationshipTree, ConceptRelationshipPresenter, IConceptRelationshipComponentListener, d3.conceptrelationshiptree_connector.js : added possibility to clear concept relationship tree
CdmChangeEvent : added new constructor with possibility to add source component
NewTaxonBaseComposite : passing source object and taxon / synonym creation flag to event
StatusComposite :