Revision cf3d9f76
Added by Patrick Plitzner over 4 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/AbstractEntityCollectionElementWizardPage.java | ||
---|---|---|
13 | 13 |
import org.eclipse.swt.widgets.Composite; |
14 | 14 |
import org.eclipse.ui.forms.widgets.TableWrapLayout; |
15 | 15 |
|
16 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySession; |
|
17 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; |
|
18 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
19 | 16 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
20 | 17 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
21 | 18 |
import eu.etaxonomy.taxeditor.ui.element.RootElement; |
22 |
import eu.etaxonomy.taxeditor.webapp.ICDMServerError; |
|
23 | 19 |
|
24 | 20 |
/** |
25 | 21 |
* @author pplitzner |
26 | 22 |
* @date Mar 30, 2016 |
27 | 23 |
* |
28 | 24 |
*/ |
29 |
public abstract class AbstractEntityCollectionElementWizardPage extends WizardPage implements
|
|
25 |
public abstract class AbstractEntityCollectionElementWizardPage extends WizardPage implements |
|
30 | 26 |
IPropertyChangeListener { |
31 | 27 |
|
32 | 28 |
protected CdmFormFactory formFactory; |
33 |
|
|
29 |
|
|
34 | 30 |
|
35 | 31 |
protected RootElement rootElement; |
36 | 32 |
|
37 |
protected AbstractEntityCollectionElementWizardPage(String pageName) { |
|
33 |
protected AbstractEntityCollectionElementWizardPage(String pageName, CdmFormFactory formFactory) {
|
|
38 | 34 |
super(pageName); |
39 |
|
|
35 |
this.formFactory = formFactory; |
|
40 | 36 |
} |
41 | 37 |
|
42 | 38 |
/** |
... | ... | |
64 | 60 |
public void dispose() { |
65 | 61 |
rootElement.removeElements(); |
66 | 62 |
formFactory.removePropertyChangeListener(this); |
67 |
|
|
63 |
|
|
68 | 64 |
super.dispose(); |
69 | 65 |
} |
70 | 66 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/AbstractApplicableElement.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.ui.section.feature; |
10 | 10 |
|
11 |
import java.util.ArrayList; |
|
12 | 11 |
import java.util.Collections; |
13 |
import java.util.List; |
|
14 |
import java.util.Set; |
|
15 | 12 |
|
16 | 13 |
import org.eclipse.swt.SWT; |
17 | 14 |
import org.eclipse.swt.events.SelectionListener; |
... | ... | |
20 | 17 |
import eu.etaxonomy.cdm.model.description.Feature; |
21 | 18 |
import eu.etaxonomy.cdm.model.description.FeatureState; |
22 | 19 |
import eu.etaxonomy.cdm.model.description.State; |
23 |
import eu.etaxonomy.cdm.model.term.TermNode; |
|
24 |
import eu.etaxonomy.cdm.model.term.TermVocabulary; |
|
25 | 20 |
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement; |
26 | 21 |
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection; |
27 | 22 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
... | ... | |
50 | 45 |
selectFeature = formFactory.createSelectionElement(Feature.class, element, "Feature", null, EntitySelectionElement.SELECTABLE, SWT.NONE); |
51 | 46 |
comboState = formFactory.createDefinedTermComboElement(Collections.EMPTY_LIST, element, getComboLabel(), null, style); |
52 | 47 |
comboState.setEnabled(false); |
48 |
selectFeature.setEnabled(false); |
|
53 | 49 |
} |
54 | 50 |
|
55 | 51 |
protected abstract String getComboLabel(); |
... | ... | |
57 | 53 |
@Override |
58 | 54 |
public void setEntity(FeatureState entity) { |
59 | 55 |
this.entity = entity; |
60 |
Feature feature = entity.getFeature(); |
|
61 |
selectFeature.setEntity(feature); |
|
62 |
if(feature!=null){ |
|
63 |
updateCombo(feature); |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
private void updateCombo(Feature feature){ |
|
68 |
comboState.setEnabled(true); |
|
69 |
List<State> stateTerms = new ArrayList<State>(); |
|
70 |
Set<TermVocabulary<State>> stateVocabularies = feature.getSupportedCategoricalEnumerations(); |
|
71 |
for (TermVocabulary<State> termVocabulary : stateVocabularies) { |
|
72 |
stateTerms.addAll(termVocabulary.getTerms()); |
|
73 |
} |
|
74 |
comboState.setTerms(stateTerms); |
|
56 |
selectFeature.setEntity(entity.getFeature()); |
|
75 | 57 |
comboState.setSelection(entity.getState()); |
76 |
if(getEntity().getId()>0){ |
|
77 |
comboState.removeEmptyElement(); |
|
78 |
} |
|
79 | 58 |
} |
80 | 59 |
|
81 | 60 |
@Override |
82 | 61 |
public void handleEvent(Object eventSource) { |
83 |
if(eventSource==selectFeature){ |
|
84 |
Feature feature = selectFeature.getSelection(); |
|
85 |
entity.setFeature(feature); |
|
86 |
updateCombo(feature); |
|
87 |
} |
|
88 |
else if(eventSource==comboState && comboState.getSelection()!=null){ |
|
89 |
if(getParentElement() instanceof OnlyApplicableIfEntityCollectionSection){ |
|
90 |
OnlyApplicableIfEntityCollectionSection parentElement = (OnlyApplicableIfEntityCollectionSection) getParentElement(); |
|
91 |
TermNode node = parentElement.getEntity(); |
|
92 |
node.removeApplicableState(entity); |
|
93 |
State state = comboState.getSelection(); |
|
94 |
entity.setState(state); |
|
95 |
node.addApplicableState(entity); |
|
96 |
parentElement.removeElementAndUpdate(null); |
|
97 |
} |
|
98 |
} |
|
99 | 62 |
} |
100 | 63 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/FeatureStateWizard.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2019 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.ui.section.feature; |
|
10 |
|
|
11 |
import org.eclipse.jface.wizard.Wizard; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.model.description.FeatureState; |
|
14 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
|
15 |
|
|
16 |
/** |
|
17 |
* @author pplitzner |
|
18 |
* @since Aug 16, 2019 |
|
19 |
* |
|
20 |
*/ |
|
21 |
public class FeatureStateWizard extends Wizard { |
|
22 |
|
|
23 |
private FeatureStateWizardPage page; |
|
24 |
private CdmFormFactory formFactory; |
|
25 |
private String comboLabel; |
|
26 |
|
|
27 |
public FeatureStateWizard(CdmFormFactory formFactory, String comboLabel) { |
|
28 |
super(); |
|
29 |
this.formFactory = formFactory; |
|
30 |
this.comboLabel = comboLabel; |
|
31 |
setWindowTitle("Create Feature State"); |
|
32 |
} |
|
33 |
|
|
34 |
@Override |
|
35 |
public void addPages() { |
|
36 |
page = new FeatureStateWizardPage("Create Feature State", comboLabel, formFactory); |
|
37 |
addPage(page); |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
public boolean performFinish() { |
|
42 |
return page.isPageComplete(); |
|
43 |
} |
|
44 |
|
|
45 |
FeatureState getFeatureState(){ |
|
46 |
return page.getFeatureState(); |
|
47 |
} |
|
48 |
|
|
49 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/FeatureStateWizardPage.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2019 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.ui.section.feature; |
|
10 |
|
|
11 |
import java.util.ArrayList; |
|
12 |
import java.util.Collections; |
|
13 |
import java.util.List; |
|
14 |
import java.util.Set; |
|
15 |
|
|
16 |
import org.eclipse.jface.util.PropertyChangeEvent; |
|
17 |
import org.eclipse.swt.SWT; |
|
18 |
import org.eclipse.swt.widgets.Composite; |
|
19 |
|
|
20 |
import eu.etaxonomy.cdm.model.description.Feature; |
|
21 |
import eu.etaxonomy.cdm.model.description.FeatureState; |
|
22 |
import eu.etaxonomy.cdm.model.description.State; |
|
23 |
import eu.etaxonomy.cdm.model.term.TermVocabulary; |
|
24 |
import eu.etaxonomy.taxeditor.ui.AbstractEntityCollectionElementWizardPage; |
|
25 |
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement; |
|
26 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
|
27 |
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement; |
|
28 |
|
|
29 |
/** |
|
30 |
* @author pplitzner |
|
31 |
* @since Aug 16, 2019 |
|
32 |
* |
|
33 |
*/ |
|
34 |
public class FeatureStateWizardPage extends AbstractEntityCollectionElementWizardPage { |
|
35 |
|
|
36 |
private TermComboElement<State> comboState; |
|
37 |
private EntitySelectionElement<Feature> selectFeature; |
|
38 |
private String comboLabel; |
|
39 |
|
|
40 |
protected FeatureStateWizardPage(String pageName, String comboLabel, CdmFormFactory formFactory) { |
|
41 |
super(pageName, formFactory); |
|
42 |
this.comboLabel = comboLabel; |
|
43 |
setTitle("Create Feature State"); |
|
44 |
setDescription("Select Feature and State"); |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
public void createControl(Composite parent) { |
|
49 |
super.createControl(parent); |
|
50 |
|
|
51 |
selectFeature = formFactory.createSelectionElement(Feature.class, rootElement, "Feature", null, EntitySelectionElement.SELECTABLE, SWT.NONE); |
|
52 |
comboState = formFactory.createDefinedTermComboElement(Collections.EMPTY_LIST, rootElement, comboLabel, null, SWT.NONE); |
|
53 |
comboState.setEnabled(false); |
|
54 |
|
|
55 |
formFactory.addPropertyChangeListener(this); |
|
56 |
} |
|
57 |
|
|
58 |
FeatureState getFeatureState(){ |
|
59 |
return FeatureState.NewInstance(selectFeature.getSelection(), comboState.getSelection()); |
|
60 |
} |
|
61 |
|
|
62 |
private void updateCombo(Feature feature){ |
|
63 |
comboState.setEnabled(true); |
|
64 |
List<State> stateTerms = new ArrayList<State>(); |
|
65 |
Set<TermVocabulary<State>> stateVocabularies = feature.getSupportedCategoricalEnumerations(); |
|
66 |
for (TermVocabulary<State> termVocabulary : stateVocabularies) { |
|
67 |
stateTerms.addAll(termVocabulary.getTerms()); |
|
68 |
} |
|
69 |
comboState.setTerms(stateTerms); |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public boolean isPageComplete() { |
|
74 |
return selectFeature.getSelection()!=null && comboState.getSelection()!=null; |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public void propertyChange(PropertyChangeEvent event) { |
|
79 |
if(event.getSource()==selectFeature){ |
|
80 |
Feature feature = selectFeature.getSelection(); |
|
81 |
updateCombo(feature); |
|
82 |
} |
|
83 |
getWizard().getContainer().updateButtons(); |
|
84 |
} |
|
85 |
|
|
86 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/InapplicableIfEntityCollectionSection.java | ||
---|---|---|
12 | 12 |
import java.util.Collection; |
13 | 13 |
import java.util.Comparator; |
14 | 14 |
|
15 |
import org.eclipse.core.runtime.IStatus; |
|
16 |
import org.eclipse.jface.wizard.WizardDialog; |
|
17 |
|
|
15 | 18 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
16 | 19 |
import eu.etaxonomy.cdm.model.description.FeatureState; |
17 | 20 |
import eu.etaxonomy.cdm.model.term.TermNode; |
... | ... | |
54 | 57 |
*/ |
55 | 58 |
@Override |
56 | 59 |
public FeatureState createNewElement() { |
57 |
return FeatureState.NewInstance(); |
|
60 |
FeatureStateWizard wizard = new FeatureStateWizard(formFactory, "Inapplicable If"); |
|
61 |
WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard); |
|
62 |
int status = dialog.open(); |
|
63 |
if(status == IStatus.OK) { |
|
64 |
return wizard.getFeatureState(); |
|
65 |
} |
|
66 |
return null; |
|
58 | 67 |
} |
59 | 68 |
|
60 | 69 |
/** |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/OnlyApplicableIfEntityCollectionSection.java | ||
---|---|---|
12 | 12 |
import java.util.Collection; |
13 | 13 |
import java.util.Comparator; |
14 | 14 |
|
15 |
import org.eclipse.core.runtime.IStatus; |
|
16 |
import org.eclipse.jface.wizard.WizardDialog; |
|
17 |
|
|
15 | 18 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
16 | 19 |
import eu.etaxonomy.cdm.model.description.FeatureState; |
17 | 20 |
import eu.etaxonomy.cdm.model.term.TermNode; |
... | ... | |
53 | 56 |
*/ |
54 | 57 |
@Override |
55 | 58 |
public FeatureState createNewElement() { |
56 |
return FeatureState.NewInstance(); |
|
59 |
FeatureStateWizard wizard = new FeatureStateWizard(formFactory, "Only applicable if"); |
|
60 |
WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard); |
|
61 |
int status = dialog.open(); |
|
62 |
if(status == IStatus.OK) { |
|
63 |
return wizard.getFeatureState(); |
|
64 |
} |
|
65 |
return null; |
|
57 | 66 |
} |
58 | 67 |
|
59 | 68 |
/** |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameRelationshipWizard.java | ||
---|---|---|
48 | 48 |
/** {@inheritDoc} */ |
49 | 49 |
@Override |
50 | 50 |
public void addPages() { |
51 |
page = new NameRelationshipWizardPage(callingSection); |
|
51 |
page = new NameRelationshipWizardPage(callingSection, callingSection.getFormFactory());
|
|
52 | 52 |
|
53 | 53 |
addPage(page); |
54 | 54 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameRelationshipWizardPage.java | ||
---|---|---|
20 | 20 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
21 | 21 |
import eu.etaxonomy.taxeditor.ui.AbstractEntityCollectionElementWizardPage; |
22 | 22 |
import eu.etaxonomy.taxeditor.ui.combo.NameRelationshipTypeCombo; |
23 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
|
23 | 24 |
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement; |
24 | 25 |
|
25 | 26 |
/** |
... | ... | |
56 | 57 |
* object. |
57 | 58 |
*/ |
58 | 59 |
protected NameRelationshipWizardPage( |
59 |
NameRelationshipDetailSection callingSection) { |
|
60 |
super("NameRelationshipWizardPage"); //$NON-NLS-1$ |
|
60 |
NameRelationshipDetailSection callingSection, CdmFormFactory formFactory) {
|
|
61 |
super("NameRelationshipWizardPage", formFactory); //$NON-NLS-1$
|
|
61 | 62 |
setTitle("New Name Relationship"); //$NON-NLS-1$ |
62 | 63 |
//setDescription(callingSection.getEntity().getTitleCache()); |
63 | 64 |
setDescription(Messages.NameRelationshipWizardPage_description); |
64 | 65 |
this.entity = callingSection.getEntity(); |
65 |
this.formFactory = callingSection.getFormFactory(); |
|
66 | 66 |
|
67 | 67 |
formFactory.addPropertyChangeListener(this); |
68 | 68 |
} |
Also available in: Unified diff
ref #8475 Create FeatureState in wizard dialog