import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
-import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
-import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
-import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
import eu.etaxonomy.taxeditor.ui.element.RootElement;
-import eu.etaxonomy.taxeditor.webapp.ICDMServerError;
/**
* @author pplitzner
* @date Mar 30, 2016
*
*/
-public abstract class AbstractEntityCollectionElementWizardPage extends WizardPage implements
+public abstract class AbstractEntityCollectionElementWizardPage extends WizardPage implements
IPropertyChangeListener {
protected CdmFormFactory formFactory;
-
+
protected RootElement rootElement;
- protected AbstractEntityCollectionElementWizardPage(String pageName) {
+ protected AbstractEntityCollectionElementWizardPage(String pageName, CdmFormFactory formFactory) {
super(pageName);
-
+ this.formFactory = formFactory;
}
/**
public void dispose() {
rootElement.removeElements();
formFactory.removePropertyChangeListener(this);
-
+
super.dispose();
}
*/
package eu.etaxonomy.taxeditor.ui.section.feature;
-import java.util.ArrayList;
import java.util.Collections;
-import java.util.List;
-import java.util.Set;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionListener;
import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.FeatureState;
import eu.etaxonomy.cdm.model.description.State;
-import eu.etaxonomy.cdm.model.term.TermNode;
-import eu.etaxonomy.cdm.model.term.TermVocabulary;
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
selectFeature = formFactory.createSelectionElement(Feature.class, element, "Feature", null, EntitySelectionElement.SELECTABLE, SWT.NONE);
comboState = formFactory.createDefinedTermComboElement(Collections.EMPTY_LIST, element, getComboLabel(), null, style);
comboState.setEnabled(false);
+ selectFeature.setEnabled(false);
}
protected abstract String getComboLabel();
@Override
public void setEntity(FeatureState entity) {
this.entity = entity;
- Feature feature = entity.getFeature();
- selectFeature.setEntity(feature);
- if(feature!=null){
- updateCombo(feature);
- }
- }
-
- private void updateCombo(Feature feature){
- comboState.setEnabled(true);
- List<State> stateTerms = new ArrayList<State>();
- Set<TermVocabulary<State>> stateVocabularies = feature.getSupportedCategoricalEnumerations();
- for (TermVocabulary<State> termVocabulary : stateVocabularies) {
- stateTerms.addAll(termVocabulary.getTerms());
- }
- comboState.setTerms(stateTerms);
+ selectFeature.setEntity(entity.getFeature());
comboState.setSelection(entity.getState());
- if(getEntity().getId()>0){
- comboState.removeEmptyElement();
- }
}
@Override
public void handleEvent(Object eventSource) {
- if(eventSource==selectFeature){
- Feature feature = selectFeature.getSelection();
- entity.setFeature(feature);
- updateCombo(feature);
- }
- else if(eventSource==comboState && comboState.getSelection()!=null){
- if(getParentElement() instanceof OnlyApplicableIfEntityCollectionSection){
- OnlyApplicableIfEntityCollectionSection parentElement = (OnlyApplicableIfEntityCollectionSection) getParentElement();
- TermNode node = parentElement.getEntity();
- node.removeApplicableState(entity);
- State state = comboState.getSelection();
- entity.setState(state);
- node.addApplicableState(entity);
- parentElement.removeElementAndUpdate(null);
- }
- }
}
}
--- /dev/null
+/**
+* Copyright (C) 2019 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.feature;
+
+import org.eclipse.jface.wizard.Wizard;
+
+import eu.etaxonomy.cdm.model.description.FeatureState;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+
+/**
+ * @author pplitzner
+ * @since Aug 16, 2019
+ *
+ */
+public class FeatureStateWizard extends Wizard {
+
+ private FeatureStateWizardPage page;
+ private CdmFormFactory formFactory;
+ private String comboLabel;
+
+ public FeatureStateWizard(CdmFormFactory formFactory, String comboLabel) {
+ super();
+ this.formFactory = formFactory;
+ this.comboLabel = comboLabel;
+ setWindowTitle("Create Feature State");
+ }
+
+ @Override
+ public void addPages() {
+ page = new FeatureStateWizardPage("Create Feature State", comboLabel, formFactory);
+ addPage(page);
+ }
+
+ @Override
+ public boolean performFinish() {
+ return page.isPageComplete();
+ }
+
+ FeatureState getFeatureState(){
+ return page.getFeatureState();
+ }
+
+}
--- /dev/null
+/**
+* Copyright (C) 2019 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.feature;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.description.FeatureState;
+import eu.etaxonomy.cdm.model.description.State;
+import eu.etaxonomy.cdm.model.term.TermVocabulary;
+import eu.etaxonomy.taxeditor.ui.AbstractEntityCollectionElementWizardPage;
+import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
+
+/**
+ * @author pplitzner
+ * @since Aug 16, 2019
+ *
+ */
+public class FeatureStateWizardPage extends AbstractEntityCollectionElementWizardPage {
+
+ private TermComboElement<State> comboState;
+ private EntitySelectionElement<Feature> selectFeature;
+ private String comboLabel;
+
+ protected FeatureStateWizardPage(String pageName, String comboLabel, CdmFormFactory formFactory) {
+ super(pageName, formFactory);
+ this.comboLabel = comboLabel;
+ setTitle("Create Feature State");
+ setDescription("Select Feature and State");
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+
+ selectFeature = formFactory.createSelectionElement(Feature.class, rootElement, "Feature", null, EntitySelectionElement.SELECTABLE, SWT.NONE);
+ comboState = formFactory.createDefinedTermComboElement(Collections.EMPTY_LIST, rootElement, comboLabel, null, SWT.NONE);
+ comboState.setEnabled(false);
+
+ formFactory.addPropertyChangeListener(this);
+ }
+
+ FeatureState getFeatureState(){
+ return FeatureState.NewInstance(selectFeature.getSelection(), comboState.getSelection());
+ }
+
+ private void updateCombo(Feature feature){
+ comboState.setEnabled(true);
+ List<State> stateTerms = new ArrayList<State>();
+ Set<TermVocabulary<State>> stateVocabularies = feature.getSupportedCategoricalEnumerations();
+ for (TermVocabulary<State> termVocabulary : stateVocabularies) {
+ stateTerms.addAll(termVocabulary.getTerms());
+ }
+ comboState.setTerms(stateTerms);
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ return selectFeature.getSelection()!=null && comboState.getSelection()!=null;
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if(event.getSource()==selectFeature){
+ Feature feature = selectFeature.getSelection();
+ updateCombo(feature);
+ }
+ getWizard().getContainer().updateButtons();
+ }
+
+}
import java.util.Collection;
import java.util.Comparator;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.wizard.WizardDialog;
+
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.model.description.FeatureState;
import eu.etaxonomy.cdm.model.term.TermNode;
*/
@Override
public FeatureState createNewElement() {
- return FeatureState.NewInstance();
+ FeatureStateWizard wizard = new FeatureStateWizard(formFactory, "Inapplicable If");
+ WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
+ int status = dialog.open();
+ if(status == IStatus.OK) {
+ return wizard.getFeatureState();
+ }
+ return null;
}
/**
import java.util.Collection;
import java.util.Comparator;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.wizard.WizardDialog;
+
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.model.description.FeatureState;
import eu.etaxonomy.cdm.model.term.TermNode;
*/
@Override
public FeatureState createNewElement() {
- return FeatureState.NewInstance();
+ FeatureStateWizard wizard = new FeatureStateWizard(formFactory, "Only applicable if");
+ WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
+ int status = dialog.open();
+ if(status == IStatus.OK) {
+ return wizard.getFeatureState();
+ }
+ return null;
}
/**
/** {@inheritDoc} */
@Override
public void addPages() {
- page = new NameRelationshipWizardPage(callingSection);
+ page = new NameRelationshipWizardPage(callingSection, callingSection.getFormFactory());
addPage(page);
}
import eu.etaxonomy.taxeditor.l10n.Messages;
import eu.etaxonomy.taxeditor.ui.AbstractEntityCollectionElementWizardPage;
import eu.etaxonomy.taxeditor.ui.combo.NameRelationshipTypeCombo;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
/**
* object.
*/
protected NameRelationshipWizardPage(
- NameRelationshipDetailSection callingSection) {
- super("NameRelationshipWizardPage"); //$NON-NLS-1$
+ NameRelationshipDetailSection callingSection, CdmFormFactory formFactory) {
+ super("NameRelationshipWizardPage", formFactory); //$NON-NLS-1$
setTitle("New Name Relationship"); //$NON-NLS-1$
//setDescription(callingSection.getEntity().getTitleCache());
setDescription(Messages.NameRelationshipWizardPage_description);
this.entity = callingSection.getEntity();
- this.formFactory = callingSection.getFormFactory();
formFactory.addPropertyChangeListener(this);
}