--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.newWizard;
+
+import eu.etaxonomy.cdm.api.service.ITaxonService;
+import eu.etaxonomy.cdm.model.name.NonViralName;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameWizardPage;
+import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonWizardPage;
+
+/**
+ *
+ * @author pplitzner
+ * @date Jan 18, 2016
+ *
+ */
+public class NewTaxonWizard extends AbstractNewEntityWizard<Taxon> {
+
+ private TaxonWizardPage taxonWizardPage;
+
+ /** {@inheritDoc} */
+ @Override
+ public void addPages() {
+ addPage(new NonViralNameWizardPage(formFactory, getConversationHolder(), (NonViralName) getEntity().getName()));
+ taxonWizardPage = new TaxonWizardPage(formFactory, getConversationHolder(), getEntity());
+ addPage(taxonWizardPage);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected Taxon createNewEntity() {
+ return Taxon.NewInstance(NonViralName.NewInstance(null), null);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected void saveEntity() {
+ CdmStore.getService(ITaxonService.class).save(getEntity());
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void setEntity(Taxon entity) {
+ super.setEntity(entity);
+ }
+
+ @Override
+ protected String getEntityName() {
+ return "Taxon";
+ }
+}
@Override
public void widgetSelected(SelectionEvent e) {
- AbstractNewEntityWizard wizard = getNewEntityWizard(e.text);
-
- wizard.init(null, null);
- if(wizard.getEntity() != null) {
- WizardDialog dialog = new WizardDialog(getShell(), wizard);
- int status = dialog.open();
-
- if (status == IStatus.OK) {
-
- T entity = (T) wizard.getEntity();
- model.add(new UuidAndTitleCache<T>(entity.getUuid(),
- entity.getId(),
- getTitle(entity)));
- refresh();
- setPattern(entity);
- getConversationHolder().bind();
- }
- //FIXME : Need to make sure this is a stable fix (ticket 3822)
- getConversationHolder().commit();
- }
+ AbstractNewEntityWizard wizard = getNewEntityWizard(e.text);
+ if(wizard!=null){
+ wizard.init(null, null);
+ if(wizard.getEntity() != null) {
+ WizardDialog dialog = new WizardDialog(getShell(), wizard);
+ int status = dialog.open();
+
+ if (status == IStatus.OK) {
+
+ T entity = (T) wizard.getEntity();
+ model.add(new UuidAndTitleCache<T>(entity.getUuid(),
+ entity.getId(),
+ getTitle(entity)));
+ refresh();
+ setPattern(entity);
+ getConversationHolder().bind();
+ }
+ //FIXME : Need to make sure this is a stable fix (ticket 3822)
+ getConversationHolder().commit();
+ }
+ }
}
};
}
import java.util.UUID;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
+import eu.etaxonomy.taxeditor.newWizard.NewTaxonWizard;
import eu.etaxonomy.taxeditor.store.CdmStore;
/**
public static TaxonBase selectTaxonBase(Shell shell, ConversationHolder conversation) {
AbstractFilteredCdmResourceSelectionDialog<TaxonBase> dialog = new TaxonBaseSelectionDialog(TaxonBase.class, shell, conversation,
- "Choose a taxon", false, null, null);
+ "Choose a taxon/synonym", false, null, null);
return getSelectionFromDialog(dialog);
}
public static Synonym selectSynonym(Shell shell, ConversationHolder conversation) {
AbstractFilteredCdmResourceSelectionDialog<TaxonBase> dialog = new TaxonBaseSelectionDialog(Synonym.class, shell, conversation,
- "Choose a taxon", false, null, null);
+ "Choose a synonym", false, null, null);
return (Synonym) getSelectionFromDialog(dialog);
}
private final Class<? extends TaxonBase> clazz;
protected TaxonBaseSelectionDialog(Class<? extends TaxonBase> clazz, Shell shell, ConversationHolder conversation, String title, boolean multi, TaxonBase taxon, TaxonBase taxonToBeFiltered) {
- super(shell, conversation, title, multi, ReferenceSelectionDialog.class.getCanonicalName(), taxon);
+ super(shell, conversation, title, multi, TaxonBaseSelectionDialog.class.getCanonicalName(), taxon);
this.cdmBaseToBeFiltered = taxonToBeFiltered;
this.clazz = clazz;
initModel();
}
- /** {@inheritDoc} */
- @Override
- protected Control createExtendedContentArea(Composite parent) {
- return null;
- }
-
/** {@inheritDoc} */
@Override
protected TaxonBase getPersistentObject(UUID uuid) {
/** {@inheritDoc} */
@Override
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
- return null;
+ return new NewTaxonWizard();
}
/** {@inheritDoc} */
@Override
protected String getNewWizardLinkText() {
- return null;
+ return String.format("Create a new <a>%1s</a>", "Taxon ");
}
}
// $Id$
/**
* Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy
+ * European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
- *
+ *
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
* <p>
* Abstract AbstractCdmEntityWizardPage class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Jun 1, 2010
* @version 1.0
* <p>
* Constructor for AbstractCdmEntityWizardPage.
* </p>
- *
+ *
* @param formFactory
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
* object.
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
* .Composite)
* <p>
* Getter for the field <code>entity</code>.
* </p>
- *
+ *
* @return a T object.
*/
public T getEntity() {
/**
* Creates the detail element for this wizard page
- *
+ *
* @param rootElement
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
* object.
if (event.getSource() == getDetailElement()) {
checkComplete();
}
+ else if(event.getSource() instanceof AbstractCdmDetailElement){
+ //check if parent element is set as detail element
+ ICdmFormElement formElement = (ICdmFormElement) event.getSource();
+ while(formElement.getParentElement()!=null){
+ if(formElement.getParentElement() == getDetailElement()){
+ checkComplete();
+ return;
+ }
+ formElement = formElement.getParentElement();
+ }
+ }
}
/**
* <p>
* getConversationHolder
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
* object.
*/
* <p>
* Getter for the field <code>detailElement</code>.
* </p>
- *
+ *
* @return a
* {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement}
* object.
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.ui.section.taxon;
+
+import org.eclipse.swt.SWT;
+
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.taxeditor.ui.element.AbstractCdmEntityWizardPage;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
+
+/**
+ *
+ * @author pplitzner
+ * @date Jan 18, 2016
+ *
+ */
+public class TaxonWizardPage extends AbstractCdmEntityWizardPage<TaxonBase> {
+
+ public TaxonWizardPage(CdmFormFactory formFactory, ConversationHolder conversation,
+ TaxonBase entity) {
+ super(formFactory, conversation, entity);
+ setTitle("Taxon");
+ }
+
+
+ /** {@inheritDoc} */
+ @Override
+ public AbstractCdmDetailElement<TaxonBase> createElement(ICdmFormElement rootElement) {
+ TaxonBaseDetailElement taxonBaseDetailElement = formFactory.createTaxonBaseDetailElement(rootElement, SWT.NULL);
+ taxonBaseDetailElement.setEntity(entity);
+ return taxonBaseDetailElement;
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ return true;
+ }
+}