Revision eaa9ba52
Added by Patrick Plitzner over 8 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonWizard.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.taxeditor.newWizard; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
|
14 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
|
15 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
16 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
17 |
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameWizardPage; |
|
18 |
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonWizardPage; |
|
19 |
|
|
20 |
/** |
|
21 |
* |
|
22 |
* @author pplitzner |
|
23 |
* @date Jan 18, 2016 |
|
24 |
* |
|
25 |
*/ |
|
26 |
public class NewTaxonWizard extends AbstractNewEntityWizard<Taxon> { |
|
27 |
|
|
28 |
private TaxonWizardPage taxonWizardPage; |
|
29 |
|
|
30 |
/** {@inheritDoc} */ |
|
31 |
@Override |
|
32 |
public void addPages() { |
|
33 |
addPage(new NonViralNameWizardPage(formFactory, getConversationHolder(), (NonViralName) getEntity().getName())); |
|
34 |
taxonWizardPage = new TaxonWizardPage(formFactory, getConversationHolder(), getEntity()); |
|
35 |
addPage(taxonWizardPage); |
|
36 |
} |
|
37 |
|
|
38 |
/** {@inheritDoc} */ |
|
39 |
@Override |
|
40 |
protected Taxon createNewEntity() { |
|
41 |
return Taxon.NewInstance(NonViralName.NewInstance(null), null); |
|
42 |
} |
|
43 |
|
|
44 |
/** {@inheritDoc} */ |
|
45 |
@Override |
|
46 |
protected void saveEntity() { |
|
47 |
CdmStore.getService(ITaxonService.class).save(getEntity()); |
|
48 |
} |
|
49 |
|
|
50 |
/** {@inheritDoc} */ |
|
51 |
@Override |
|
52 |
public void setEntity(Taxon entity) { |
|
53 |
super.setEntity(entity); |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
protected String getEntityName() { |
|
58 |
return "Taxon"; |
|
59 |
} |
|
60 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AbstractFilteredCdmResourceSelectionDialog.java | ||
---|---|---|
477 | 477 |
@Override |
478 | 478 |
public void widgetSelected(SelectionEvent e) { |
479 | 479 |
|
480 |
AbstractNewEntityWizard wizard = getNewEntityWizard(e.text); |
|
481 |
|
|
482 |
wizard.init(null, null); |
|
483 |
if(wizard.getEntity() != null) { |
|
484 |
WizardDialog dialog = new WizardDialog(getShell(), wizard); |
|
485 |
int status = dialog.open(); |
|
486 |
|
|
487 |
if (status == IStatus.OK) { |
|
488 |
|
|
489 |
T entity = (T) wizard.getEntity(); |
|
490 |
model.add(new UuidAndTitleCache<T>(entity.getUuid(), |
|
491 |
entity.getId(), |
|
492 |
getTitle(entity))); |
|
493 |
refresh(); |
|
494 |
setPattern(entity); |
|
495 |
getConversationHolder().bind(); |
|
496 |
} |
|
497 |
//FIXME : Need to make sure this is a stable fix (ticket 3822) |
|
498 |
getConversationHolder().commit(); |
|
499 |
} |
|
480 |
AbstractNewEntityWizard wizard = getNewEntityWizard(e.text); |
|
481 |
if(wizard!=null){ |
|
482 |
wizard.init(null, null); |
|
483 |
if(wizard.getEntity() != null) { |
|
484 |
WizardDialog dialog = new WizardDialog(getShell(), wizard); |
|
485 |
int status = dialog.open(); |
|
486 |
|
|
487 |
if (status == IStatus.OK) { |
|
488 |
|
|
489 |
T entity = (T) wizard.getEntity(); |
|
490 |
model.add(new UuidAndTitleCache<T>(entity.getUuid(), |
|
491 |
entity.getId(), |
|
492 |
getTitle(entity))); |
|
493 |
refresh(); |
|
494 |
setPattern(entity); |
|
495 |
getConversationHolder().bind(); |
|
496 |
} |
|
497 |
//FIXME : Need to make sure this is a stable fix (ticket 3822) |
|
498 |
getConversationHolder().commit(); |
|
499 |
} |
|
500 |
} |
|
500 | 501 |
} |
501 | 502 |
}; |
502 | 503 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TaxonBaseSelectionDialog.java | ||
---|---|---|
12 | 12 |
|
13 | 13 |
import java.util.UUID; |
14 | 14 |
|
15 |
import org.eclipse.swt.widgets.Composite; |
|
16 |
import org.eclipse.swt.widgets.Control; |
|
17 | 15 |
import org.eclipse.swt.widgets.Shell; |
18 | 16 |
|
19 | 17 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
... | ... | |
22 | 20 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
23 | 21 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
24 | 22 |
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard; |
23 |
import eu.etaxonomy.taxeditor.newWizard.NewTaxonWizard; |
|
25 | 24 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
26 | 25 |
|
27 | 26 |
/** |
... | ... | |
34 | 33 |
|
35 | 34 |
public static TaxonBase selectTaxonBase(Shell shell, ConversationHolder conversation) { |
36 | 35 |
AbstractFilteredCdmResourceSelectionDialog<TaxonBase> dialog = new TaxonBaseSelectionDialog(TaxonBase.class, shell, conversation, |
37 |
"Choose a taxon", false, null, null); |
|
36 |
"Choose a taxon/synonym", false, null, null);
|
|
38 | 37 |
return getSelectionFromDialog(dialog); |
39 | 38 |
} |
40 | 39 |
|
... | ... | |
48 | 47 |
|
49 | 48 |
public static Synonym selectSynonym(Shell shell, ConversationHolder conversation) { |
50 | 49 |
AbstractFilteredCdmResourceSelectionDialog<TaxonBase> dialog = new TaxonBaseSelectionDialog(Synonym.class, shell, conversation, |
51 |
"Choose a taxon", false, null, null);
|
|
50 |
"Choose a synonym", false, null, null);
|
|
52 | 51 |
return (Synonym) getSelectionFromDialog(dialog); |
53 | 52 |
} |
54 | 53 |
|
55 | 54 |
private final Class<? extends TaxonBase> clazz; |
56 | 55 |
|
57 | 56 |
protected TaxonBaseSelectionDialog(Class<? extends TaxonBase> clazz, Shell shell, ConversationHolder conversation, String title, boolean multi, TaxonBase taxon, TaxonBase taxonToBeFiltered) { |
58 |
super(shell, conversation, title, multi, ReferenceSelectionDialog.class.getCanonicalName(), taxon);
|
|
57 |
super(shell, conversation, title, multi, TaxonBaseSelectionDialog.class.getCanonicalName(), taxon);
|
|
59 | 58 |
this.cdmBaseToBeFiltered = taxonToBeFiltered; |
60 | 59 |
this.clazz = clazz; |
61 | 60 |
initModel(); |
62 | 61 |
} |
63 | 62 |
|
64 |
/** {@inheritDoc} */ |
|
65 |
@Override |
|
66 |
protected Control createExtendedContentArea(Composite parent) { |
|
67 |
return null; |
|
68 |
} |
|
69 |
|
|
70 | 63 |
/** {@inheritDoc} */ |
71 | 64 |
@Override |
72 | 65 |
protected TaxonBase getPersistentObject(UUID uuid) { |
... | ... | |
90 | 83 |
/** {@inheritDoc} */ |
91 | 84 |
@Override |
92 | 85 |
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) { |
93 |
return null;
|
|
86 |
return new NewTaxonWizard();
|
|
94 | 87 |
} |
95 | 88 |
|
96 | 89 |
/** {@inheritDoc} */ |
97 | 90 |
@Override |
98 | 91 |
protected String getNewWizardLinkText() { |
99 |
return null;
|
|
92 |
return String.format("Create a new <a>%1s</a>", "Taxon ");
|
|
100 | 93 |
} |
101 | 94 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractCdmEntityWizardPage.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
28 | 28 |
* <p> |
29 | 29 |
* Abstract AbstractCdmEntityWizardPage class. |
30 | 30 |
* </p> |
31 |
*
|
|
31 |
* |
|
32 | 32 |
* @author n.hoffmann |
33 | 33 |
* @created Jun 1, 2010 |
34 | 34 |
* @version 1.0 |
... | ... | |
46 | 46 |
* <p> |
47 | 47 |
* Constructor for AbstractCdmEntityWizardPage. |
48 | 48 |
* </p> |
49 |
*
|
|
49 |
* |
|
50 | 50 |
* @param formFactory |
51 | 51 |
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} |
52 | 52 |
* object. |
... | ... | |
82 | 82 |
|
83 | 83 |
/* |
84 | 84 |
* (non-Javadoc) |
85 |
*
|
|
85 |
* |
|
86 | 86 |
* @see |
87 | 87 |
* org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets |
88 | 88 |
* .Composite) |
... | ... | |
115 | 115 |
* <p> |
116 | 116 |
* Getter for the field <code>entity</code>. |
117 | 117 |
* </p> |
118 |
*
|
|
118 |
* |
|
119 | 119 |
* @return a T object. |
120 | 120 |
*/ |
121 | 121 |
public T getEntity() { |
... | ... | |
124 | 124 |
|
125 | 125 |
/** |
126 | 126 |
* Creates the detail element for this wizard page |
127 |
*
|
|
127 |
* |
|
128 | 128 |
* @param rootElement |
129 | 129 |
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} |
130 | 130 |
* object. |
... | ... | |
169 | 169 |
if (event.getSource() == getDetailElement()) { |
170 | 170 |
checkComplete(); |
171 | 171 |
} |
172 |
else if(event.getSource() instanceof AbstractCdmDetailElement){ |
|
173 |
//check if parent element is set as detail element |
|
174 |
ICdmFormElement formElement = (ICdmFormElement) event.getSource(); |
|
175 |
while(formElement.getParentElement()!=null){ |
|
176 |
if(formElement.getParentElement() == getDetailElement()){ |
|
177 |
checkComplete(); |
|
178 |
return; |
|
179 |
} |
|
180 |
formElement = formElement.getParentElement(); |
|
181 |
} |
|
182 |
} |
|
172 | 183 |
} |
173 | 184 |
|
174 | 185 |
/** |
... | ... | |
191 | 202 |
* <p> |
192 | 203 |
* getConversationHolder |
193 | 204 |
* </p> |
194 |
*
|
|
205 |
* |
|
195 | 206 |
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} |
196 | 207 |
* object. |
197 | 208 |
*/ |
... | ... | |
214 | 225 |
* <p> |
215 | 226 |
* Getter for the field <code>detailElement</code>. |
216 | 227 |
* </p> |
217 |
*
|
|
228 |
* |
|
218 | 229 |
* @return a |
219 | 230 |
* {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement} |
220 | 231 |
* object. |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonWizardPage.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.taxeditor.ui.section.taxon; |
|
12 |
|
|
13 |
import org.eclipse.swt.SWT; |
|
14 |
|
|
15 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
16 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
17 |
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmEntityWizardPage; |
|
18 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
|
19 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
|
20 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; |
|
21 |
|
|
22 |
/** |
|
23 |
* |
|
24 |
* @author pplitzner |
|
25 |
* @date Jan 18, 2016 |
|
26 |
* |
|
27 |
*/ |
|
28 |
public class TaxonWizardPage extends AbstractCdmEntityWizardPage<TaxonBase> { |
|
29 |
|
|
30 |
public TaxonWizardPage(CdmFormFactory formFactory, ConversationHolder conversation, |
|
31 |
TaxonBase entity) { |
|
32 |
super(formFactory, conversation, entity); |
|
33 |
setTitle("Taxon"); |
|
34 |
} |
|
35 |
|
|
36 |
|
|
37 |
/** {@inheritDoc} */ |
|
38 |
@Override |
|
39 |
public AbstractCdmDetailElement<TaxonBase> createElement(ICdmFormElement rootElement) { |
|
40 |
TaxonBaseDetailElement taxonBaseDetailElement = formFactory.createTaxonBaseDetailElement(rootElement, SWT.NULL); |
|
41 |
taxonBaseDetailElement.setEntity(entity); |
|
42 |
return taxonBaseDetailElement; |
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
46 |
public boolean isPageComplete() { |
|
47 |
return true; |
|
48 |
} |
|
49 |
} |
Also available in: Unified diff
Allow creating new taxa in taxon selection dialog #2402