@AutoGenerated
private GridLayout gridLayout;
@AutoGenerated
- private Label accTaxonNameValue;
+ private ComboBox synComboBox;
+ @AutoGenerated
+ private Label synSecLabel;
@AutoGenerated
- private ComboBox secComboBox;
+ private ComboBox accTaxonSecComboBox;
@AutoGenerated
- private Label secLabel;
+ private Label accTaxonSecLabel;
@AutoGenerated
private TextField nameTextField;
@AutoGenerated
private Label nameLabel;
@AutoGenerated
+ private Label accTaxonNameValue;
+ @AutoGenerated
private Label accTaxonLabel;
private INewTaxonBaseComponentListener listener;
addUIListeners();
if(accTaxonName == null || accTaxonName.isEmpty()) {
+ // this is the case where we create a new taxon
accTaxonLabel.setVisible(false);
accTaxonNameValue.setVisible(false);
+ synSecLabel.setVisible(false);
+ synComboBox.setVisible(false);
} else {
+ // this is the case where we create a new synonym
accTaxonNameValue.setValue(accTaxonName);
}
init();
}
public void init() {
- initSecComboBox();
+ initAccTaxonSecComboBox();
+ if(accTaxonIun != null) {
+ initSynSecComboBox();
+ }
}
- private void initSecComboBox() {
-
- secComboBox.setNullSelectionAllowed(false);
- secComboBox.setItemCaptionPropertyId("titleCache");
- secComboBox.setImmediate(true);
+ private void initAccTaxonSecComboBox() {
+ accTaxonSecComboBox.setNullSelectionAllowed(false);
+ accTaxonSecComboBox.setItemCaptionPropertyId("titleCache");
+ accTaxonSecComboBox.setImmediate(true);
if(listener != null) {
- secComboBox.setContainerDataSource(listener.getSecRefContainer());
- Object selectedSecItemId = null;
- // if accTaxonIun is null then we are creating a new taxon
- // else a new synonym
- if(accTaxonIun == null) {
- selectedSecItemId = listener.getClassificationRefId(classificationIun.getUuid());
+ accTaxonSecComboBox.setContainerDataSource(listener.getAccTaxonSecRefContainer());
+ Object selectedSecItemId = listener.getClassificationRefId(classificationIun.getUuid());
+ if(selectedSecItemId != null) {
+ accTaxonSecComboBox.setValue(selectedSecItemId);
} else {
- selectedSecItemId = listener.getAcceptedTaxonRefId(accTaxonIun.getUuid());
+ accTaxonSecComboBox.setInputPrompt(CHOOSE_SECUNDUM_PROMPT);
}
+ }
+ }
+ private void initSynSecComboBox() {
+ synComboBox.setNullSelectionAllowed(false);
+ synComboBox.setItemCaptionPropertyId("titleCache");
+ synComboBox.setImmediate(true);
+ if(listener != null) {
+ synComboBox.setContainerDataSource(listener.getSynSecRefContainer());
+ Object selectedSecItemId = listener.getClassificationRefId(classificationIun.getUuid());
if(selectedSecItemId != null) {
- secComboBox.setValue(selectedSecItemId);
+ synComboBox.setValue(selectedSecItemId);
} else {
- secComboBox.setInputPrompt(CHOOSE_SECUNDUM_PROMPT);
+ synComboBox.setInputPrompt(CHOOSE_SECUNDUM_PROMPT);
}
}
}
+
+
private void addUIListeners() {
addSaveButtonListener();
addCancelButtonListener();
public void buttonClick(ClickEvent event) {
try {
nameTextField.validate();
- secComboBox.validate();
+ accTaxonSecComboBox.validate();
+ if(accTaxonIun != null) {
+ synComboBox.validate();
+ }
} catch (EmptyValueException e) {
Notification notification = new Notification("Invalid input", "Neither Name or Secundum can be empty", Type.WARNING_MESSAGE);
notification.setDelayMsec(2000);
setProgress("Saving Taxon " + nameTextField.getValue());
IdUuidName taxonBaseIdUuid;
if(accTaxonIun == null) {
- taxonBaseIdUuid = listener.newTaxon(nameTextField.getValue(),secComboBox.getValue(), classificationIun.getUuid());
+ taxonBaseIdUuid = listener.newTaxon(nameTextField.getValue(),accTaxonSecComboBox.getValue(), classificationIun.getUuid());
} else {
- taxonBaseIdUuid = listener.newSynonym(nameTextField.getValue(),secComboBox.getValue(), accTaxonIun.getUuid());
+ taxonBaseIdUuid = listener.newSynonym(nameTextField.getValue(),
+ accTaxonSecComboBox.getValue(),
+ accTaxonSecComboBox.getValue(),
+ accTaxonIun.getUuid());
}
Object rowId = new RowId(taxonBaseIdUuid.getId());
registerDelayedEvent(new CdmChangeEvent(Action.Create, Arrays.asList(rowId), NewTaxonBaseComposite.class));
// common part: create layout
mainLayout = new VerticalLayout();
mainLayout.setImmediate(false);
- mainLayout.setWidth("340px");
- mainLayout.setHeight("200px");
+ mainLayout.setWidth("420px");
+ mainLayout.setHeight("240px");
mainLayout.setMargin(true);
// top-level component properties
- setWidth("340px");
- setHeight("200px");
+ setWidth("420px");
+ setHeight("240px");
// gridLayout
gridLayout = buildGridLayout();
gridLayout = new GridLayout();
gridLayout.setImmediate(false);
gridLayout.setWidth("-1px");
- gridLayout.setHeight("-1px");
+ gridLayout.setHeight("140px");
gridLayout.setMargin(false);
gridLayout.setSpacing(true);
gridLayout.setColumns(2);
gridLayout.addComponent(accTaxonLabel, 0, 0);
gridLayout.setComponentAlignment(accTaxonLabel, new Alignment(34));
+ // accTaxonNameValue
+ accTaxonNameValue = new Label();
+ accTaxonNameValue.setImmediate(false);
+ accTaxonNameValue.setWidth("-1px");
+ accTaxonNameValue.setHeight("-1px");
+ accTaxonNameValue.setValue("Taxon Name");
+ gridLayout.addComponent(accTaxonNameValue, 1, 0);
+ gridLayout.setComponentAlignment(accTaxonNameValue, new Alignment(33));
+
// nameLabel
nameLabel = new Label();
nameLabel.setImmediate(false);
gridLayout.addComponent(nameTextField, 1, 1);
gridLayout.setComponentAlignment(nameTextField, new Alignment(33));
- // secLabel
- secLabel = new Label();
- secLabel.setImmediate(false);
- secLabel.setWidth("-1px");
- secLabel.setHeight("-1px");
- secLabel.setValue("Secundum : ");
- gridLayout.addComponent(secLabel, 0, 2);
- gridLayout.setComponentAlignment(secLabel, new Alignment(34));
-
- // secComboBox
- secComboBox = new ComboBox();
- secComboBox.setImmediate(false);
- secComboBox.setWidth("190px");
- secComboBox.setHeight("-1px");
- secComboBox.setInvalidAllowed(false);
- secComboBox.setRequired(true);
- gridLayout.addComponent(secComboBox, 1, 2);
- gridLayout.setComponentAlignment(secComboBox, new Alignment(33));
-
- // accTaxonNameValue
- accTaxonNameValue = new Label();
- accTaxonNameValue.setImmediate(false);
- accTaxonNameValue.setWidth("-1px");
- accTaxonNameValue.setHeight("-1px");
- accTaxonNameValue.setValue("Taxon Name");
- gridLayout.addComponent(accTaxonNameValue, 1, 0);
- gridLayout.setComponentAlignment(accTaxonNameValue, new Alignment(33));
+ // accTaxonSecLabel
+ accTaxonSecLabel = new Label();
+ accTaxonSecLabel.setImmediate(false);
+ accTaxonSecLabel.setWidth("-1px");
+ accTaxonSecLabel.setHeight("-1px");
+ accTaxonSecLabel.setValue("Acc. Taxon Secundum : ");
+ gridLayout.addComponent(accTaxonSecLabel, 0, 2);
+ gridLayout.setComponentAlignment(accTaxonSecLabel, new Alignment(34));
+
+ // accTaxonSecComboBox
+ accTaxonSecComboBox = new ComboBox();
+ accTaxonSecComboBox.setImmediate(false);
+ accTaxonSecComboBox.setWidth("190px");
+ accTaxonSecComboBox.setHeight("-1px");
+ accTaxonSecComboBox.setInvalidAllowed(false);
+ accTaxonSecComboBox.setRequired(true);
+ gridLayout.addComponent(accTaxonSecComboBox, 1, 2);
+ gridLayout.setComponentAlignment(accTaxonSecComboBox, new Alignment(33));
+
+ // synSecLabel
+ synSecLabel = new Label();
+ synSecLabel.setImmediate(false);
+ synSecLabel.setWidth("-1px");
+ synSecLabel.setHeight("-1px");
+ synSecLabel.setValue("Synonym Secundum : ");
+ gridLayout.addComponent(synSecLabel, 0, 3);
+
+ // synComboBox
+ synComboBox = new ComboBox();
+ synComboBox.setImmediate(false);
+ synComboBox.setWidth("190px");
+ synComboBox.setHeight("-1px");
+ synComboBox.setInvalidAllowed(false);
+ synComboBox.setRequired(true);
+ gridLayout.addComponent(synComboBox, 1, 3);
return gridLayout;
}
private final boolean taxaTreeTableMultiSelectMode = true;
- private static final String SELECT_FILTER = "Select filter ...";
private static final String SELECT_CLASSIFICATION = "Select classification ...";
- private static final String ADD_TAXON_SYNONYM_INPUT = "Add ...";
+
private static final String CREATE_ACC_TAXON = "Create Accepted Taxon";
+ private static final String CHANGE_TO_ACC_TAXON = "Change to Accepted Taxon";
+ private static final String REPLACE_ACC_TAXON = "Replace Accepted Taxon";
+ private static final String CHANGE_TO_SYNONYM = "Change to Synonym";
private static final String CREATE_SYNONYM = "Create Synonym";
private static final String SET_AS_DELETED = "Set as Deleted";
private static final String SET_AS_EXCLUDED = "Set as Excluded";
container.addContainerProperty("filter", String.class, "");
container.addContainerProperty("selected", Boolean.class, "");
-// Item item = container.addItem(FILTER_NOT_RESOLVED);
-// item.getItemProperty(PROPERTY_FILTER_ID).setValue(FILTER_NOT_RESOLVED);
-// item.getItemProperty(PROPERTY_SELECTED_ID).setValue(false);
-//
-// item = container.addItem(FILTER_UNPLACED);
-// item.getItemProperty(PROPERTY_FILTER_ID).setValue(FILTER_UNPLACED);
-// item.getItemProperty(PROPERTY_SELECTED_ID).setValue(false);
-
Item item = container.addItem(FILTER_UNFINISHED);
item.getItemProperty(PROPERTY_FILTER_ID).setValue(FILTER_UNFINISHED);
item.getItemProperty(PROPERTY_SELECTED_ID).setValue(false);
.fireSelectionEvent(new SelectionEvent(Arrays.asList(idUuidName, getSelectedClassificationUuid()), StatusComposite.class), true);
}
taxaTreeTable.setValue(Arrays.asList(itemId));
- generateTaxaTreeTableContextMenu(!isSynonym);
+ generateTaxaTreeTableContextMenu(isSynonym);
}
}
taxaTableContextMenu.removeAllItems();
if(isSynonym) {
+
+
+ ContextMenuItem changeToAccTaxonMenuItem = taxaTableContextMenu.addItem(CHANGE_TO_ACC_TAXON);
+ changeToAccTaxonMenuItem.setData(CHANGE_TO_ACC_TAXON);
+
+ ContextMenuItem replaceAccTaxonMenuItem = taxaTableContextMenu.addItem(REPLACE_ACC_TAXON);
+ replaceAccTaxonMenuItem.setData(REPLACE_ACC_TAXON);
+
+ replaceAccTaxonMenuItem.setSeparatorVisible(true);
+ } else {
ContextMenuItem createSynMenuItem = taxaTableContextMenu.addItem(CREATE_SYNONYM);
createSynMenuItem.setData(CREATE_SYNONYM);
+
+ ContextMenuItem changeToSynMenuItem = taxaTableContextMenu.addItem(CHANGE_TO_SYNONYM);
+ changeToSynMenuItem.setData(CHANGE_TO_SYNONYM);
+
+ changeToSynMenuItem.setSeparatorVisible(true);
}
+
ContextMenuItem setDeletedMenuItem = taxaTableContextMenu.addItem(SET_AS_DELETED);
setDeletedMenuItem.setData(SET_AS_DELETED);
ContextMenuItem setOutOfScopeMenuItem = taxaTableContextMenu.addItem(SET_AS_OUT_OF_SCOPE);
setOutOfScopeMenuItem.setData(SET_AS_OUT_OF_SCOPE);
- setOutOfScopeMenuItem.setSeparatorVisible(true);
-
ContextMenuItem createAccTaxonMenuItem = taxaTableContextMenu.addItem(CREATE_ACC_TAXON);
createAccTaxonMenuItem.setData(CREATE_ACC_TAXON);
- private final CdmSQLContainer secRefContainer;
+ private final CdmSQLContainer accTaxonSecRefContainer;
+ private final CdmSQLContainer synSecRefContainer;
private final IReferenceService referenceService;
private final ITaxonNodeService taxonNodeService;
private final ICdmApplicationConfiguration app;
- /* (non-Javadoc)
- * @see eu.etaxonomy.cdm.vaadin.view.INewTaxonBaseComponentListener#getSecRefContainer()
- */
+
+ @Override
+ public CdmSQLContainer getAccTaxonSecRefContainer() {
+ return accTaxonSecRefContainer;
+ }
+
@Override
- public CdmSQLContainer getSecRefContainer() {
- return secRefContainer;
+ public CdmSQLContainer getSynSecRefContainer() {
+ return synSecRefContainer;
}
public NewTaxonBasePresenter() throws SQLException {
- secRefContainer = CdmSQLContainer.newInstance("Reference");
+ accTaxonSecRefContainer = CdmSQLContainer.newInstance("Reference");
+ synSecRefContainer = CdmSQLContainer.newInstance("Reference");
referenceService = CdmSpringContextHelper.getReferenceService();
taxonNodeService = CdmSpringContextHelper.getTaxonNodeService();
taxonService = CdmSpringContextHelper.getTaxonService();
@Override
public IdUuidName newTaxon(String scientificName, Object secRefItemId, UUID classificationUuid) {
TransactionStatus tx = app.startTransaction();
- UUID uuid = secRefContainer.getUuid(secRefItemId);
+ UUID uuid = accTaxonSecRefContainer.getUuid(secRefItemId);
Reference sec = CdmBase.deproxy(referenceService.load(uuid), Reference.class);
* @see eu.etaxonomy.cdm.vaadin.view.INewTaxonBaseComponentListener#newSynonym(java.lang.String, java.lang.Object, java.util.UUID)
*/
@Override
- public IdUuidName newSynonym(String scientificName, Object secRefItemId, UUID accTaxonUuid) {
+ public IdUuidName newSynonym(String scientificName, Object synSecRefItemId, Object accTaxonSecRefItemId, UUID accTaxonUuid) {
TransactionStatus tx = app.startTransaction();
List<String> ACC_TAXON_INIT_STRATEGY = Arrays.asList(new String []{
"synonymRelations"
});
- UUID refUuid = secRefContainer.getUuid(secRefItemId);
- Reference sec = CdmBase.deproxy(referenceService.load(refUuid), Reference.class);
+
+ UUID synRefUuid = synSecRefContainer.getUuid(synSecRefItemId);
+ Reference synSec = CdmBase.deproxy(referenceService.load(synRefUuid), Reference.class);
NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();
NonViralName name = parser.parseFullName(scientificName);
name.setTitleCache(scientificName, true);
+ Synonym newSynonym = Synonym.NewInstance(name, synSec);
+
+
+ UUID accTaxonRefUuid = accTaxonSecRefContainer.getUuid(accTaxonSecRefItemId);
+ Reference accTaxonSec = CdmBase.deproxy(referenceService.load(accTaxonRefUuid), Reference.class);
Taxon accTaxon = CdmBase.deproxy(taxonService.load(accTaxonUuid, ACC_TAXON_INIT_STRATEGY), Taxon.class);
- Synonym newSynonym = Synonym.NewInstance(name, sec);
+ accTaxon.setSec(accTaxonSec);
+
accTaxon.addSynonym(newSynonym, SynonymRelationshipType.SYNONYM_OF());
+
UUID newUuid = taxonService.save(newSynonym);
app.commitTransaction(tx);
return new IdUuidName(newSynonym.getId(), newUuid, newSynonym.getTitleCache());