From: n.hoffmann
Date: Mon, 4 Apr 2011 16:34:09 +0000 (+0000)
Subject: New wizards are not finishable when no data was entered
X-Git-Tag: rcp.ss-first-working-version~130
X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/86d5831412bfff375d15de069081c38c70cfad22
New wizards are not finishable when no data was entered
---
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/AbstractCdmEntityWizardPage.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/AbstractCdmEntityWizardPage.java
index 0d5643a9d..7ed3808a8 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/AbstractCdmEntityWizardPage.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/AbstractCdmEntityWizardPage.java
@@ -1,15 +1,18 @@
// $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.
-*/
+ * 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.forms;
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
@@ -22,41 +25,56 @@ import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
/**
- * Abstract AbstractCdmEntityWizardPage class.
- *
+ *
+ * Abstract AbstractCdmEntityWizardPage class.
+ *
+ *
* @author n.hoffmann
* @created Jun 1, 2010
* @version 1.0
*/
-public abstract class AbstractCdmEntityWizardPage extends WizardPage implements IConversationEnabled {
+public abstract class AbstractCdmEntityWizardPage extends WizardPage
+ implements IConversationEnabled, IPropertyChangeListener {
protected CdmFormFactory formFactory;
protected T entity;
AbstractCdmDetailElement detailElement;
- private ConversationHolder conversation;
-
+ private final ConversationHolder conversation;
+
/**
- * Constructor for AbstractCdmEntityWizardPage.
- *
- * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
- * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
- * @param entity a T object.
- * @param a T object.
+ *
+ * Constructor for AbstractCdmEntityWizardPage.
+ *
+ *
+ * @param formFactory
+ * a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
+ * object.
+ * @param conversation
+ * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+ * object.
+ * @param entity
+ * a T object.
+ * @param
+ * a T object.
*/
- protected AbstractCdmEntityWizardPage(CdmFormFactory formFactory, ConversationHolder conversation, T entity) {
+ protected AbstractCdmEntityWizardPage(CdmFormFactory formFactory,
+ ConversationHolder conversation, T entity) {
super("page");
this.formFactory = formFactory;
this.entity = entity;
this.conversation = conversation;
setDescription(getEntityTitle());
+
+ formFactory.addPropertyChangeListener(this);
+ setPageComplete(false);
}
-
+
/**
* @return
*/
private String getEntityTitle() {
- if(entity instanceof IIdentifiableEntity){
+ if (entity instanceof IIdentifiableEntity) {
((IIdentifiableEntity) entity).getTitleCache();
}
return "";
@@ -64,57 +82,70 @@ public abstract class AbstractCdmEntityWizardPage extends WizardPage implemen
/*
* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ *
+ * @see
+ * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+ * .Composite)
*/
/** {@inheritDoc} */
+ @Override
public void createControl(Composite parent) {
- ScrolledForm scrolledForm = formFactory.createScrolledForm(parent);
+ ScrolledForm scrolledForm = formFactory.createScrolledForm(parent);
scrolledForm.getBody().setLayout(CdmFormFactory.LAYOUT());
-
+
Composite control = formFactory.createComposite(scrolledForm.getBody());
control.setLayoutData(CdmFormFactory.FILL());
-
+
control.setLayout(CdmFormFactory.LAYOUT(2, false));
- WizardPageRootElement rootElement = new WizardPageRootElement(formFactory, control, getConversationHolder());
-
+ WizardPageRootElement rootElement = new WizardPageRootElement(
+ formFactory, control, getConversationHolder());
+
Color bgColor = getShell().getBackground();
-
+
detailElement = createElement(rootElement);
-
+
rootElement.setBackground(bgColor);
control.setBackground(bgColor);
scrolledForm.setBackground(bgColor);
-
+
setControl(scrolledForm);
}
-
+
/**
- * Getter for the field entity
.
- *
+ *
+ * Getter for the field entity
.
+ *
+ *
* @return a T object.
*/
public T getEntity() {
return entity;
}
-
+
/**
* Creates the detail element for this wizard page
- *
- * @param rootElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
- * @return a {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement} object.
+ *
+ * @param rootElement
+ * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
+ * object.
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement}
+ * object.
*/
- public abstract AbstractCdmDetailElement createElement(ICdmFormElement rootElement);
-
- protected class WizardPageRootElement extends RootElement implements IConversationEnabled{
+ public abstract AbstractCdmDetailElement createElement(
+ ICdmFormElement rootElement);
+
+ protected class WizardPageRootElement extends RootElement implements
+ IConversationEnabled {
+
+ private final ConversationHolder conversation;
- private ConversationHolder conversation;
-
- public WizardPageRootElement(CdmFormFactory formFactory,
+ public WizardPageRootElement(CdmFormFactory formFactory,
Composite layoutComposite, ConversationHolder conversation) {
super(formFactory, layoutComposite);
this.conversation = conversation;
}
-
+
@Override
public void refresh() {
super.refresh();
@@ -122,41 +153,78 @@ public abstract class AbstractCdmEntityWizardPage extends WizardPage implemen
detailElement = createElement(this);
((Composite) getControl()).layout();
}
-
+
+ @Override
public ConversationHolder getConversationHolder() {
return conversation;
}
-
- public void update(CdmDataChangeMap changeEvents) {}
+
+ @Override
+ public void update(CdmDataChangeMap changeEvents) {
+ }
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getSource() == getDetailElement()) {
+ checkComplete();
+ }
}
-
+
/**
- * getConversationHolder
- *
- * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+ * Should check whether the wizard is complete in a sense that it contains
+ * sane data. Should setPageComplete to true if that is the case.
*/
+ protected void checkComplete() {
+ setPageComplete(titleCacheIsNotEmpty());
+ }
+
+ private boolean titleCacheIsNotEmpty() {
+ if (getEntity() instanceof IIdentifiableEntity) {
+ IIdentifiableEntity entity = (IIdentifiableEntity) getEntity();
+ return !StringUtils.isEmpty(entity.getTitleCache());
+ }
+ return true;
+ }
+
+ /**
+ *
+ * getConversationHolder
+ *
+ *
+ * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+ * object.
+ */
+ @Override
public ConversationHolder getConversationHolder() {
return conversation;
}
-
+
/** {@inheritDoc} */
@Override
public void dispose() {
- if(detailElement != null){
+ if (detailElement != null) {
detailElement.removeElements();
}
+ formFactory.removePropertyChangeListener(this);
super.dispose();
}
-
+
/**
- * Getter for the field detailElement
.
- *
- * @return a {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement} object.
+ *
+ * Getter for the field detailElement
.
+ *
+ *
+ * @return a
+ * {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement}
+ * object.
*/
public AbstractCdmDetailElement getDetailElement() {
return detailElement;
}
-
+
/** {@inheritDoc} */
- public void update(CdmDataChangeMap changeEvents) {}
+ @Override
+ public void update(CdmDataChangeMap changeEvents) {
+ }
}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/InstitutionWizardPage.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/InstitutionWizardPage.java
index 4b6a3058d..f3a8a0007 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/InstitutionWizardPage.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/InstitutionWizardPage.java
@@ -1,12 +1,12 @@
// $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.
-*/
+ * 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.agent;
@@ -16,8 +16,8 @@ import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.model.agent.Institution;
import eu.etaxonomy.taxeditor.ui.forms.AbstractCdmEntityWizardPage;
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
-import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType;
+import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
/**
@@ -25,7 +25,8 @@ import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
* @created Dec 15, 2010
* @version 1.0
*/
-public class InstitutionWizardPage extends AbstractCdmEntityWizardPage {
+public class InstitutionWizardPage extends
+ AbstractCdmEntityWizardPage {
/**
* @param formFactory
@@ -37,14 +38,19 @@ public class InstitutionWizardPage extends AbstractCdmEntityWizardPagePersonDetailElement class.
- *
+ *
+ * PersonDetailElement class.
+ *
+ *
* @author n.hoffmann
* @created Mar 8, 2010
* @version 1.0
@@ -37,73 +40,89 @@ public class PersonDetailElement extends AbstractCdmDetailElement {
private TextWithLabelElement text_lastname;
private TextWithLabelElement text_prefix;
private TextWithLabelElement text_suffix;
-
+
private Collection excludeFromIrrelevantToggleableObjects;
-
+
/**
- * Constructor for PersonDetailElement.
- *
- * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
- * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
- * @param style a int.
+ *
+ * Constructor for PersonDetailElement.
+ *
+ *
+ * @param cdmFormFactory
+ * a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
+ * object.
+ * @param formElement
+ * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
+ * object.
+ * @param style
+ * a int.
*/
- public PersonDetailElement(CdmFormFactory cdmFormFactory, ICdmFormElement formElement,
- int style) {
+ public PersonDetailElement(CdmFormFactory cdmFormFactory,
+ ICdmFormElement formElement, int style) {
super(cdmFormFactory, formElement);
}
-
+
/** {@inheritDoc} */
@Override
- protected void createControls(ICdmFormElement formElement, Person entity, int style) {
- toggleable_cache = formFactory.createToggleableTextField(formElement, "Title Cache", entity.getTitleCache(), entity.isProtectedTitleCache(), SWT.NULL);
-
- text_nomenclaturalTitle = formFactory.createTextWithLabelElement(formElement, "Nom. Title", entity.getNomenclaturalTitle(), SWT.NULL);
+ protected void createControls(ICdmFormElement formElement, Person entity,
+ int style) {
+ toggleable_cache = formFactory.createToggleableTextField(formElement,
+ "Title Cache", entity.getTitleCache(),
+ entity.isProtectedTitleCache(), SWT.NULL);
+
+ text_nomenclaturalTitle = formFactory.createTextWithLabelElement(
+ formElement, "Nom. Title", entity.getNomenclaturalTitle(),
+ SWT.NULL);
-
- text_firstname = formFactory.createTextWithLabelElement(formElement, "Firstname", entity.getFirstname(), SWT.NULL);
- text_lastname = formFactory.createTextWithLabelElement(formElement, "Lastname", entity.getLastname(), SWT.NULL);
+ text_firstname = formFactory.createTextWithLabelElement(formElement,
+ "Firstname", entity.getFirstname(), SWT.NULL);
+ text_lastname = formFactory.createTextWithLabelElement(formElement,
+ "Lastname", entity.getLastname(), SWT.NULL);
- text_prefix = formFactory.createTextWithLabelElement(formElement, "Prefix", entity.getPrefix(), SWT.NULL);
- text_suffix = formFactory.createTextWithLabelElement(formElement, "Suffix", entity.getSuffix(), SWT.NULL);
+ text_prefix = formFactory.createTextWithLabelElement(formElement,
+ "Prefix", entity.getPrefix(), SWT.NULL);
+ text_suffix = formFactory.createTextWithLabelElement(formElement,
+ "Suffix", entity.getSuffix(), SWT.NULL);
}
-
+
/** {@inheritDoc} */
@Override
protected void updateContent() {
super.updateContent();
-
- excludeFromIrrelevantToggleableObjects = Arrays.asList(new Object[]{toggleable_cache, text_nomenclaturalTitle});
-
+
+ excludeFromIrrelevantToggleableObjects = Arrays.asList(new Object[] {
+ toggleable_cache, text_nomenclaturalTitle });
+
toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
- setIrrelevant(toggleable_cache.getState(), excludeFromIrrelevantToggleableObjects);
+ setIrrelevant(toggleable_cache.getState(),
+ excludeFromIrrelevantToggleableObjects);
}
-
-
+
/** {@inheritDoc} */
@Override
public void handleEvent(Object eventSource) {
- if(eventSource == toggleable_cache){
- getEntity().setTitleCache(toggleable_cache.getText(), toggleable_cache.getState());
- setIrrelevant(toggleable_cache.getState(), excludeFromIrrelevantToggleableObjects);
- }
- else if(eventSource == text_nomenclaturalTitle){
- getEntity().setNomenclaturalTitle(text_nomenclaturalTitle.getText());
- }
- else if(eventSource == text_firstname){
+ if (eventSource == toggleable_cache) {
+ getEntity().setTitleCache(toggleable_cache.getText(),
+ toggleable_cache.getState());
+ setIrrelevant(toggleable_cache.getState(),
+ excludeFromIrrelevantToggleableObjects);
+ } else if (eventSource == text_nomenclaturalTitle) {
+ getEntity()
+ .setNomenclaturalTitle(text_nomenclaturalTitle.getText());
+ } else if (eventSource == text_firstname) {
getEntity().setFirstname(text_firstname.getText());
- }
- else if(eventSource == text_lastname){
+ } else if (eventSource == text_lastname) {
getEntity().setLastname(text_lastname.getText());
- }
- else if(eventSource == text_prefix){
+ } else if (eventSource == text_prefix) {
getEntity().setPrefix(text_prefix.getText());
- }
- else if(eventSource == text_suffix){
+ } else if (eventSource == text_suffix) {
getEntity().setSuffix(text_suffix.getText());
}
-
- if(eventSource != toggleable_cache){
+
+ if (eventSource != toggleable_cache) {
toggleable_cache.setText(getEntity().getTitleCache());
}
+
+ firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
}
}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/TeamDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/TeamDetailElement.java
index 2a5a774f9..3edb63963 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/TeamDetailElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/TeamDetailElement.java
@@ -1,12 +1,12 @@
// $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.
-*/
+ * 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.agent;
@@ -16,14 +16,17 @@ import org.eclipse.ui.forms.widgets.Section;
import eu.etaxonomy.cdm.model.agent.Team;
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType;
+import eu.etaxonomy.taxeditor.ui.forms.CdmPropertyChangeEvent;
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
/**
- * TeamDetailElement class.
- *
+ *
+ * TeamDetailElement class.
+ *
+ *
* @author n.hoffmann
* @created Apr 26, 2010
* @version 1.0
@@ -35,59 +38,87 @@ public class TeamDetailElement extends AbstractCdmDetailElement {
private ToggleableTextElement toggleable_nomenclaturalTitleCache;
private TeamMemberSection section_teamMembers;
-
+
/**
- * Constructor for TeamDetailElement.
- *
- * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
- * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
- * @param style a int.
+ *
+ * Constructor for TeamDetailElement.
+ *
+ *
+ * @param cdmFormFactory
+ * a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
+ * object.
+ * @param formElement
+ * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
+ * object.
+ * @param style
+ * a int.
*/
public TeamDetailElement(CdmFormFactory cdmFormFactory,
ICdmFormElement formElement, int style) {
super(cdmFormFactory, formElement);
}
-
/** {@inheritDoc} */
@Override
- protected void createControls(
- ICdmFormElement formElement,
- Team entity, int style) {
-
- toggleable_cache = formFactory.createToggleableTextField(formElement, "Title Cache", entity.getTitleCache(), entity.isProtectedTitleCache(), style);
- toggleable_nomenclaturalTitleCache = formFactory.createToggleableTextField(formElement, "Nom. Title", entity.getNomenclaturalTitle(), entity.isProtectedNomenclaturalTitleCache(), style);
- section_teamMembers = (TeamMemberSection) formFactory.createEntityDetailSection(EntityDetailType.TEAMMEMBER, getConversationHolder(), formElement, Section.EXPANDED);
- section_teamMembers.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
+ protected void createControls(ICdmFormElement formElement, Team entity,
+ int style) {
+
+ toggleable_cache = formFactory.createToggleableTextField(formElement,
+ "Title Cache", entity.getTitleCache(),
+ entity.isProtectedTitleCache(), style);
+ toggleable_nomenclaturalTitleCache = formFactory
+ .createToggleableTextField(formElement, "Nom. Title",
+ entity.getNomenclaturalTitle(),
+ entity.isProtectedNomenclaturalTitleCache(), style);
+ section_teamMembers = (TeamMemberSection) formFactory
+ .createEntityDetailSection(EntityDetailType.TEAMMEMBER,
+ getConversationHolder(), formElement, Section.EXPANDED);
+ section_teamMembers.setLayoutData(CdmFormFactory
+ .FILL_HORIZONTALLY(2, 1));
}
-
+
/** {@inheritDoc} */
@Override
protected void updateContent() {
super.updateContent();
-
+
toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
- toggleable_nomenclaturalTitleCache.setEnabled(getEntity().isProtectedNomenclaturalTitleCache());
- setIrrelevant(toggleable_cache.getState(), Arrays.asList(new Object[]{toggleable_cache, toggleable_nomenclaturalTitleCache}));
-
+ toggleable_nomenclaturalTitleCache.setEnabled(getEntity()
+ .isProtectedNomenclaturalTitleCache());
+ setIrrelevant(
+ toggleable_cache.getState(),
+ Arrays.asList(new Object[] { toggleable_cache,
+ toggleable_nomenclaturalTitleCache }));
+
section_teamMembers.setEntity(getEntity());
-
+
}
-
+
/** {@inheritDoc} */
@Override
public void handleEvent(Object eventSource) {
- if(eventSource == toggleable_cache){
- getEntity().setTitleCache(toggleable_cache.getText(), toggleable_cache.getState());
-// setEnabled(! toggleable_cache.getState(), Arrays.asList(new Object[]{toggleable_cache}));
- setIrrelevant(toggleable_cache.getState(), Arrays.asList(new Object[]{toggleable_cache}));
- }else if(eventSource == toggleable_nomenclaturalTitleCache){
- getEntity().setNomenclaturalTitle(toggleable_nomenclaturalTitleCache.getText(), toggleable_nomenclaturalTitleCache.getState());
-// setEnabled(! toggleable_nomenclaturalTitleCache.getState(), Arrays.asList(new Object[]{toggleable_nomenclaturalTitleCache}));
- setIrrelevant(toggleable_nomenclaturalTitleCache.getState(), Arrays.asList(new Object[]{toggleable_nomenclaturalTitleCache}));
- }else if(eventSource == section_teamMembers){
+ if (eventSource == toggleable_cache) {
+ getEntity().setTitleCache(toggleable_cache.getText(),
+ toggleable_cache.getState());
+ // setEnabled(! toggleable_cache.getState(), Arrays.asList(new
+ // Object[]{toggleable_cache}));
+ setIrrelevant(toggleable_cache.getState(),
+ Arrays.asList(new Object[] { toggleable_cache }));
+ } else if (eventSource == toggleable_nomenclaturalTitleCache) {
+ getEntity().setNomenclaturalTitle(
+ toggleable_nomenclaturalTitleCache.getText(),
+ toggleable_nomenclaturalTitleCache.getState());
+ // setEnabled(! toggleable_nomenclaturalTitleCache.getState(),
+ // Arrays.asList(new Object[]{toggleable_nomenclaturalTitleCache}));
+ setIrrelevant(
+ toggleable_nomenclaturalTitleCache.getState(),
+ Arrays.asList(new Object[] { toggleable_nomenclaturalTitleCache }));
+ } else if (eventSource == section_teamMembers) {
toggleable_cache.setText(getEntity().getTitleCache());
- toggleable_nomenclaturalTitleCache.setText(getEntity().getNomenclaturalTitle());
+ toggleable_nomenclaturalTitleCache.setText(getEntity()
+ .getNomenclaturalTitle());
}
+
+ firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
}
}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/ClassificationDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/ClassificationDetailElement.java
index 1db065f33..05c499996 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/ClassificationDetailElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/ClassificationDetailElement.java
@@ -18,6 +18,7 @@ import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
+import eu.etaxonomy.taxeditor.ui.forms.CdmPropertyChangeEvent;
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
@@ -105,5 +106,7 @@ public class ClassificationDetailElement extends
} else if (eventSource == text_microReference) {
getEntity().setMicroReference(text_microReference.getText());
}
+
+ firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
}
}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/ClassificationWizardPage.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/ClassificationWizardPage.java
index 1982f872f..6817beb2b 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/ClassificationWizardPage.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/ClassificationWizardPage.java
@@ -1,16 +1,15 @@
// $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.
-*/
+ * 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.classification;
-
import org.eclipse.swt.SWT;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
@@ -21,35 +20,52 @@ import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType;
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
/**
- * ClassificationWizardPage class.
- *
+ *
+ * ClassificationWizardPage class.
+ *
+ *
* @author n.hoffmann
* @created 23.06.2009
* @version 1.0
*/
-public class ClassificationWizardPage extends AbstractCdmEntityWizardPage{
-
+public class ClassificationWizardPage extends
+ AbstractCdmEntityWizardPage {
+
/**
- * Constructor for ClassificationWizardPage.
- *
- * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
- * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
- * @param entity a {@link eu.etaxonomy.cdm.model.taxon.TaxonomicTree} object.
+ *
+ * Constructor for ClassificationWizardPage.
+ *
+ *
+ * @param formFactory
+ * a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
+ * object.
+ * @param conversation
+ * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+ * object.
+ * @param entity
+ * a {@link eu.etaxonomy.cdm.model.taxon.TaxonomicTree} object.
*/
- public ClassificationWizardPage(CdmFormFactory formFactory, ConversationHolder conversation, Classification entity){
+ public ClassificationWizardPage(CdmFormFactory formFactory,
+ ConversationHolder conversation, Classification entity) {
super(formFactory, conversation, entity);
setTitle("Classification");
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.forms.AbstractCdmEntityWizardPage#createElement(eu.etaxonomy.taxeditor.forms.ICdmFormElement)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * eu.etaxonomy.taxeditor.forms.AbstractCdmEntityWizardPage#createElement
+ * (eu.etaxonomy.taxeditor.forms.ICdmFormElement)
*/
/** {@inheritDoc} */
@Override
public ClassificationDetailElement createElement(ICdmFormElement rootElement) {
- ClassificationDetailElement detailElement = (ClassificationDetailElement) formFactory.createCdmDetailElement(DetailType.CLASSIFICATION, rootElement, SWT.NULL);
+ ClassificationDetailElement detailElement = (ClassificationDetailElement) formFactory
+ .createCdmDetailElement(DetailType.CLASSIFICATION, rootElement,
+ SWT.NULL);
detailElement.setEntity(getEntity());
-
+
return detailElement;
}
}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/TaxonNodeWizardPage.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/TaxonNodeWizardPage.java
index f33b2014a..5e5614d8b 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/TaxonNodeWizardPage.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/TaxonNodeWizardPage.java
@@ -1,17 +1,15 @@
// $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.
-*/
+ * 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.classification;
-
-import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
@@ -24,20 +22,29 @@ import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType;
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
/**
- * TaxonNodeWizardPage class.
- *
+ *
+ * TaxonNodeWizardPage class.
+ *
+ *
* @author n.hoffmann
* @created Sep 15, 2009
* @version 1.0
*/
-public class TaxonNodeWizardPage extends AbstractCdmEntityWizardPage implements IPropertyChangeListener{
+public class TaxonNodeWizardPage extends AbstractCdmEntityWizardPage {
/**
- * Constructor for TaxonNodeWizardPage.
- *
- * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
- * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
- * @param entity a {@link eu.etaxonomy.cdm.model.taxon.ITreeNode} object.
+ *
+ * Constructor for TaxonNodeWizardPage.
+ *
+ *
+ * @param formFactory
+ * a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
+ * object.
+ * @param conversation
+ * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+ * object.
+ * @param entity
+ * a {@link eu.etaxonomy.cdm.model.taxon.ITreeNode} object.
*/
public TaxonNodeWizardPage(CdmFormFactory formFactory,
ConversationHolder conversation, ITreeNode entity) {
@@ -45,71 +52,88 @@ public class TaxonNodeWizardPage extends AbstractCdmEntityWizardPage
setTitle("Create a new Taxon");
}
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.forms.AbstractCdmEntityWizardPage#createElement(eu.etaxonomy.taxeditor.forms.ICdmFormElement)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * eu.etaxonomy.taxeditor.forms.AbstractCdmEntityWizardPage#createElement
+ * (eu.etaxonomy.taxeditor.forms.ICdmFormElement)
*/
/** {@inheritDoc} */
@Override
public TaxonNodeDetailElement createElement(ICdmFormElement rootElement) {
-
- TaxonNodeDetailElement detailElement = (TaxonNodeDetailElement) formFactory.createCdmDetailElement(DetailType.TAXON_NODE, rootElement, SWT.NULL);
+
+ TaxonNodeDetailElement detailElement = (TaxonNodeDetailElement) formFactory
+ .createCdmDetailElement(DetailType.TAXON_NODE, rootElement,
+ SWT.NULL);
detailElement.setEntity(entity);
formFactory.addPropertyChangeListener(this);
return detailElement;
}
/**
- * openInEditor
- *
+ *
+ * openInEditor
+ *
+ *
* @return a boolean.
*/
- public boolean openInEditor(){
+ public boolean openInEditor() {
return ((TaxonNodeDetailElement) getDetailElement()).isOpenInEditor();
- }
-
+ }
- /* (non-Javadoc)
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse
+ * .jface.util.PropertyChangeEvent)
*/
/** {@inheritDoc} */
@Override
public void propertyChange(PropertyChangeEvent event) {
- if(event.getSource() == getDetailElement()){
- setPageComplete(checkComplete());
+ if (event.getSource() == getDetailElement()) {
+ checkComplete();
}
}
/**
*
*/
- private boolean checkComplete() {
+ @Override
+ protected void checkComplete() {
TaxonNodeDetailElement detailElement = (TaxonNodeDetailElement) getDetailElement();
-
- if(detailElement.getClassification() == null){
+
+ if (detailElement.getClassification() == null) {
setMessage("No classification", WARNING);
- }else{
+ } else {
setMessage(null);
- return true;
+ setPageComplete(true);
+ return;
}
-
- return false;
+
+ setPageComplete(false);
}
-
+
/**
- * Getter for the field parentTreeNode
.
- *
+ *
+ * Getter for the field parentTreeNode
.
+ *
+ *
* @return a {@link eu.etaxonomy.cdm.model.taxon.ITreeNode} object.
*/
public ITreeNode getParentTreeNode() {
- return ((TaxonNodeDetailElement) getDetailElement()).getParentTreeNode();
+ return ((TaxonNodeDetailElement) getDetailElement())
+ .getParentTreeNode();
}
-
- public Taxon getTaxon(){
+
+ public Taxon getTaxon() {
return ((TaxonNodeDetailElement) getDetailElement()).getTaxon();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see eu.etaxonomy.taxeditor.forms.AbstractCdmEntityWizardPage#dispose()
*/
/** {@inheritDoc} */
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailElement.java
index 5381a12dc..17b19a994 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailElement.java
@@ -1,12 +1,12 @@
// $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.
-*/
+ * 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.name;
@@ -17,22 +17,26 @@ import org.eclipse.ui.forms.widgets.Section;
import eu.etaxonomy.cdm.model.name.NonViralName;
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
-import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
-import eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement;
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType;
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EnumComboType;
+import eu.etaxonomy.taxeditor.ui.forms.CdmPropertyChangeEvent;
+import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
import eu.etaxonomy.taxeditor.ui.term.NomenclaturalCodeComboElement;
/**
- * NonViralNameDetailElement class.
- *
+ *
+ * NonViralNameDetailElement class.
+ *
+ *
* @author n.hoffmann
* @created May 20, 2010
* @version 1.0
*/
-public class NonViralNameDetailElement extends AbstractCdmDetailElement {
+public class NonViralNameDetailElement extends
+ AbstractCdmDetailElement {
private NameDetailSection section_name;
private AuthorshipDetailSection section_author;
@@ -40,51 +44,72 @@ public class NonViralNameDetailElement extends AbstractCdmDetailElementConstructor for NonViralNameDetailElement.
- *
- * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
- * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
+ *
+ * Constructor for NonViralNameDetailElement.
+ *
+ *
+ * @param formFactory
+ * a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
+ * object.
+ * @param formElement
+ * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
+ * object.
*/
public NonViralNameDetailElement(CdmFormFactory formFactory,
ICdmFormElement formElement) {
super(formFactory, formElement);
}
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls(eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement, eu.etaxonomy.cdm.model.common.AnnotatableEntity, int)
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
+ * (eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement,
+ * eu.etaxonomy.cdm.model.common.AnnotatableEntity, int)
*/
/** {@inheritDoc} */
@Override
protected void createControls(ICdmFormElement formElement,
final NonViralName entity, int style) {
-
- toggleable_cache = formFactory.createToggleableTextField(formElement, "Cache", entity.getTitleCache(), entity.isProtectedTitleCache() || entity.isProtectedFullTitleCache(), style);
-
- combo_nomenclaturalCode = (NomenclaturalCodeComboElement) formFactory.createEnumComboElement(EnumComboType.NOMENCLATURALCODE, formElement, style);
+
+ toggleable_cache = formFactory.createToggleableTextField(formElement,
+ "Cache", entity.getTitleCache(), entity.isProtectedTitleCache()
+ || entity.isProtectedFullTitleCache(), style);
+
+ combo_nomenclaturalCode = (NomenclaturalCodeComboElement) formFactory
+ .createEnumComboElement(EnumComboType.NOMENCLATURALCODE,
+ formElement, style);
combo_nomenclaturalCode.setSelection(entity.getNomenclaturalCode());
-
- section_name = (NameDetailSection) formFactory.createCdmDetailSection(DetailType.SCIENTIFICNAME, getConversationHolder(), formElement, null, Section.TWISTIE | Section.EXPANDED);
+
+ section_name = (NameDetailSection) formFactory.createCdmDetailSection(
+ DetailType.SCIENTIFICNAME, getConversationHolder(),
+ formElement, null, Section.TWISTIE | Section.EXPANDED);
section_name.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
addControl(section_name);
addElement(section_name);
- section_author = (AuthorshipDetailSection) formFactory.createCdmDetailSection(DetailType.AUTHORSHIP, getConversationHolder(), formElement, null, Section.TWISTIE | Section.EXPANDED);
+ section_author = (AuthorshipDetailSection) formFactory
+ .createCdmDetailSection(DetailType.AUTHORSHIP,
+ getConversationHolder(), formElement, null,
+ Section.TWISTIE | Section.EXPANDED);
section_author.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
addControl(section_author);
addElement(section_author);
}
-
/** {@inheritDoc} */
@Override
protected void updateContent() {
super.updateContent();
-
- // disable nomenclatural code, because changing of nom.code is not implemented on library side
+
+ // disable nomenclatural code, because changing of nom.code is not
+ // implemented on library side
combo_nomenclaturalCode.setEnabled(false);
-
- setIrrelevant(toggleable_cache.getState(), Arrays.asList(new Object[]{toggleable_cache}));
+
+ setIrrelevant(toggleable_cache.getState(),
+ Arrays.asList(new Object[] { toggleable_cache }));
}
-
+
/** {@inheritDoc} */
@Override
public void setEntity(NonViralName entity) {
@@ -92,50 +117,58 @@ public class NonViralNameDetailElement extends AbstractCdmDetailElement except = Arrays.asList(new Object[]{toggleable_cache});
+ List except = Arrays
+ .asList(new Object[] { toggleable_cache });
setIrrelevant(irrelevant, except);
- }
- else if(eventSource == section_name || eventSource == section_author){
- if(getParentElement() instanceof AbstractCdmDetailSection)
+ } else if (eventSource == section_name || eventSource == section_author) {
+ if (getParentElement() instanceof AbstractCdmDetailSection)
((AbstractCdmDetailSection) getParentElement()).updateTitle();
- if(! toggleable_cache.getState()){
+ if (!toggleable_cache.getState()) {
toggleable_cache.setText(getEntity().getTitleCache());
}
}
- if(eventSource == section_name){
+ if (eventSource == section_name) {
section_name.setEntity(getEntity());
getLayoutComposite().layout();
}
+
+ firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
}
}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java
index 570a8f3ce..80f99ebcc 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java
@@ -448,6 +448,8 @@ public class ReferenceDetailElement extends AbstractCdmDetailElement
else if (eventSource != toggleable_cache) {
toggleable_cache.setText(getEntity().getTitleCache());
}
+
+ firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
}
/*