Project

General

Profile

« Previous | Next » 

Revision 2a7820b7

Added by Patrick Plitzner over 9 years ago

  • added label to EmptyElement
    • added EmptyElement to NonViralNameDetailSection if taxon.getName() is null (fixes #4221)

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
1442 1442
     *            object.
1443 1443
     * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object.
1444 1444
     */
1445
    public EmptyElement createEmptyElement(ICdmFormElement parentElement) {
1446
        EmptyElement element = new EmptyElement(this, parentElement, null, SWT.NULL);
1445
    public EmptyElement createEmptyElement(ICdmFormElement parentElement, String emptyText) {
1446
        EmptyElement element = new EmptyElement(this, parentElement, emptyText, SWT.NULL);
1447 1447
        adapt(element);
1448 1448
        parentElement.addElement(element);
1449 1449
        return element;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/EmptyElement.java
10 10

  
11 11
package eu.etaxonomy.taxeditor.ui.section;
12 12

  
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.widgets.Label;
15

  
16
import eu.etaxonomy.cdm.model.common.VersionableEntity;
17 13
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
18 14
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
19 15

  
......
34 30
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
35 31
	 * @param entity a {@link eu.etaxonomy.cdm.model.common.VersionableEntity} object.
36 32
	 */
37
	public EmptyElement(CdmFormFactory toolkit, ICdmFormElement parentElement, VersionableEntity entity, int style) {
33
	public EmptyElement(CdmFormFactory toolkit, ICdmFormElement parentElement, String emptyText, int style) {
38 34
		super(toolkit, parentElement);
39
		addControl(new Label(getLayoutComposite(), SWT.HORIZONTAL));
35
		if(emptyText!=null){
36
		    formFactory.createLabel(parentElement, emptyText);
37
		}
40 38
	}
41 39

  
42 40
	/* (non-Javadoc)
......
44 42
	 */
45 43
	@Override
46 44
	protected void createControls(ICdmFormElement formElement, Object entity, int style) {
47
	    // TODO Auto-generated method stub
48

  
45
	    //empty
49 46
	}
50 47

  
51 48
    /* (non-Javadoc)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailElement.java
70 70
	/** {@inheritDoc} */
71 71
	@Override
72 72
    protected void createControls(ICdmFormElement formElement, final NonViralName entity, int style) {
73

  
74
        toggleable_cache = formFactory.createToggleableTextField(formElement, "Cache", entity.getTitleCache(), entity.isProtectedTitleCache() || entity.isProtectedFullTitleCache(), style);
75

  
76
       	combo_nomenclaturalCode = formFactory.createEnumComboElement(NomenclaturalCode.class, formElement, style);
77
       	combo_nomenclaturalCode.setSelection(entity.getNomenclaturalCode());
78
       	
79
        //TODO RL
80
       	if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
81
        	toggleable_cache.setVisible(false);
82
        	combo_nomenclaturalCode.setVisible(false);
83
        }
84
        
85
        section_name = formFactory.createNameDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
86
        section_name.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
87
        addControl(section_name);
88
        addElement(section_name);
89
        section_author = formFactory.createAuthorshipDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
90
        section_author.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
91
        addControl(section_author);
92
        addElement(section_author);
93

  
94
        //TODO RL
95
        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
96
	        section_hybrid = formFactory.createHybridDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
97
	        section_hybrid.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
98
	        addControl(section_hybrid);
99
	        addElement(section_hybrid);
100
        }       
73
	    //name can be null in rare cases. Temporary solution for #4221. May be obsolete when
74
	    //#4393 (Make changing name of a taxon possible in details view) is implemented.
75
	    if(entity==null){
76
	        formFactory.createEmptyElement(formElement, "No name associated with this taxon.");
77
	    }
78
	    else {
79
	        toggleable_cache = formFactory.createToggleableTextField(formElement, "Cache", entity.getTitleCache(), entity.isProtectedTitleCache() || entity.isProtectedFullTitleCache(), style);
80

  
81
	        combo_nomenclaturalCode = formFactory.createEnumComboElement(NomenclaturalCode.class, formElement, style);
82
	        combo_nomenclaturalCode.setSelection(entity.getNomenclaturalCode());
83

  
84
	        //TODO RL
85
	        if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
86
	            toggleable_cache.setVisible(false);
87
	            combo_nomenclaturalCode.setVisible(false);
88
	        }
89

  
90
	        section_name = formFactory.createNameDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
91
	        section_name.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
92
	        addControl(section_name);
93
	        addElement(section_name);
94
	        section_author = formFactory.createAuthorshipDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
95
	        section_author.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
96
	        addControl(section_author);
97
	        addElement(section_author);
98

  
99
	        //TODO RL
100
	        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
101
	            section_hybrid = formFactory.createHybridDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
102
	            section_hybrid.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
103
	            addControl(section_hybrid);
104
	            addElement(section_hybrid);
105
	        }
106
	    }
101 107
    }
102 108

  
103 109
	/** {@inheritDoc} */
......
107 113

  
108 114
		// disable nomenclatural code, because changing of nom.code is not
109 115
		// implemented on library side
110
		combo_nomenclaturalCode.setEnabled(false);
116
		if(combo_nomenclaturalCode!=null){
117
		    combo_nomenclaturalCode.setEnabled(false);
118
		}
111 119

  
112
		setIrrelevant(toggleable_cache.getState(),
113
				Arrays.asList(new Object[] { toggleable_cache }));
120
		if(toggleable_cache!=null){
121
		    setIrrelevant(toggleable_cache.getState(),
122
		            Arrays.asList(new Object[] { toggleable_cache }));
123
		}
114 124
	}
115 125

  
116 126
	/** {@inheritDoc} */
117 127
	@Override
118 128
	public void setEntity(NonViralName entity) {
119 129
		super.setEntity(entity);
120
		if (section_name!=null) section_name.setEntity(entity);
121
		if (section_author!=null) section_author.setEntity(entity);
122
		if (section_hybrid!=null) section_hybrid.setEntity(entity);
130
		if (section_name!=null) {
131
            section_name.setEntity(entity);
132
        }
133
		if (section_author!=null) {
134
            section_author.setEntity(entity);
135
        }
136
		if (section_hybrid!=null) {
137
            section_hybrid.setEntity(entity);
138
        }
123 139
	}
124 140

  
125 141
	/** {@inheritDoc} */
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/EmptySection.java
45 45
     */
46 46
    @Override
47 47
    protected AbstractCdmDetailElement<Object> createCdmDetailElement(AbstractCdmDetailSection<Object> parentElement, int style) {
48
        return formFactory.createEmptyElement(parentElement);
48
        return formFactory.createEmptyElement(parentElement, null);
49 49
    }
50 50
}

Also available in: Unified diff