package eu.etaxonomy.taxeditor.ui.section;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Label;
-
-import eu.etaxonomy.cdm.model.common.VersionableEntity;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
* @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
* @param entity a {@link eu.etaxonomy.cdm.model.common.VersionableEntity} object.
*/
- public EmptyElement(CdmFormFactory toolkit, ICdmFormElement parentElement, VersionableEntity entity, int style) {
+ public EmptyElement(CdmFormFactory toolkit, ICdmFormElement parentElement, String emptyText, int style) {
super(toolkit, parentElement);
- addControl(new Label(getLayoutComposite(), SWT.HORIZONTAL));
+ if(emptyText!=null){
+ formFactory.createLabel(parentElement, emptyText);
+ }
}
/* (non-Javadoc)
*/
@Override
protected void createControls(ICdmFormElement formElement, Object entity, int style) {
- // TODO Auto-generated method stub
-
+ //empty
}
/* (non-Javadoc)
/** {@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 = formFactory.createEnumComboElement(NomenclaturalCode.class, formElement, style);
- combo_nomenclaturalCode.setSelection(entity.getNomenclaturalCode());
-
- //TODO RL
- if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
- toggleable_cache.setVisible(false);
- combo_nomenclaturalCode.setVisible(false);
- }
-
- section_name = formFactory.createNameDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
- section_name.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
- addControl(section_name);
- addElement(section_name);
- section_author = formFactory.createAuthorshipDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
- section_author.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
- addControl(section_author);
- addElement(section_author);
-
- //TODO RL
- if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
- section_hybrid = formFactory.createHybridDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
- section_hybrid.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
- addControl(section_hybrid);
- addElement(section_hybrid);
- }
+ //name can be null in rare cases. Temporary solution for #4221. May be obsolete when
+ //#4393 (Make changing name of a taxon possible in details view) is implemented.
+ if(entity==null){
+ formFactory.createEmptyElement(formElement, "No name associated with this taxon.");
+ }
+ else {
+ toggleable_cache = formFactory.createToggleableTextField(formElement, "Cache", entity.getTitleCache(), entity.isProtectedTitleCache() || entity.isProtectedFullTitleCache(), style);
+
+ combo_nomenclaturalCode = formFactory.createEnumComboElement(NomenclaturalCode.class, formElement, style);
+ combo_nomenclaturalCode.setSelection(entity.getNomenclaturalCode());
+
+ //TODO RL
+ if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
+ toggleable_cache.setVisible(false);
+ combo_nomenclaturalCode.setVisible(false);
+ }
+
+ section_name = formFactory.createNameDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+ section_name.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ addControl(section_name);
+ addElement(section_name);
+ section_author = formFactory.createAuthorshipDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+ section_author.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ addControl(section_author);
+ addElement(section_author);
+
+ //TODO RL
+ if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
+ section_hybrid = formFactory.createHybridDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
+ section_hybrid.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ addControl(section_hybrid);
+ addElement(section_hybrid);
+ }
+ }
}
/** {@inheritDoc} */
// disable nomenclatural code, because changing of nom.code is not
// implemented on library side
- combo_nomenclaturalCode.setEnabled(false);
+ if(combo_nomenclaturalCode!=null){
+ combo_nomenclaturalCode.setEnabled(false);
+ }
- setIrrelevant(toggleable_cache.getState(),
- Arrays.asList(new Object[] { toggleable_cache }));
+ if(toggleable_cache!=null){
+ setIrrelevant(toggleable_cache.getState(),
+ Arrays.asList(new Object[] { toggleable_cache }));
+ }
}
/** {@inheritDoc} */
@Override
public void setEntity(NonViralName entity) {
super.setEntity(entity);
- if (section_name!=null) section_name.setEntity(entity);
- if (section_author!=null) section_author.setEntity(entity);
- if (section_hybrid!=null) section_hybrid.setEntity(entity);
+ if (section_name!=null) {
+ section_name.setEntity(entity);
+ }
+ if (section_author!=null) {
+ section_author.setEntity(entity);
+ }
+ if (section_hybrid!=null) {
+ section_hybrid.setEntity(entity);
+ }
}
/** {@inheritDoc} */