Project

General

Profile

« Previous | Next » 

Revision eccc9d31

Added by Katja Luther over 3 years ago

ref #9116: layout issues and improve handling if no source exist

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java
16 16
import eu.etaxonomy.cdm.api.service.dto.CreateTaxonDTO;
17 17
import eu.etaxonomy.cdm.model.common.Language;
18 18
import eu.etaxonomy.cdm.model.common.LanguageString;
19
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
19 20
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
20 21
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
21 22
import eu.etaxonomy.cdm.model.taxon.TaxonNodeStatus;
......
64 65
             	TaxonNode parent = getParentEntity();
65 66

  
66 67
             	Map<Language, LanguageString> notes = ((TaxonNodeDetailElement)taxonNodePage.getDetailElement()).getMultiLanguageTextExcludedNotes();
67
             	UUID refUuid = parent.getReference() != null? parent.getReference().getUuid(): null;
68
             	DescriptionElementSource source = parent.getSource().checkEmpty()? null: parent.getSource();
69

  
68 70

  
69 71
             	TaxonNodeStatus status = ((TaxonNodeDetailElement)taxonNodePage.getDetailElement()).getTaxonNodeStatus();
70 72
             	if (status == null){
71 73
             	    notes = null;
72 74
             	}
73
            	result = CdmStore.getService(ITaxonNodeService.class).createNewTaxonNode(parent.getUuid(), taxon, refUuid, parent.getMicroReference(),
75
            	result = CdmStore.getService(ITaxonNodeService.class).createNewTaxonNode(parent.getUuid(), taxon, source, parent.getMicroReference(),
74 76
            	         status, notes);
75 77

  
76 78
            	if (result.isOk()){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/EditTaxonNodeWizard.java
56 56
    protected void saveEntity() {
57 57
        getConversationHolder().bind();
58 58
        TaxonNode node = getEntity();
59

  
59
        if (node.getSource().checkEmpty()){
60
            node.setSource(null);
61
        }
60 62
        MergeResult result = CdmStore.getService(ITaxonNodeService.class).merge(node, true);
61 63
        EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAME_EDITOR, node.getTaxon().getUuid());
62 64

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/TaxonNodeDetailElement.java
22 22
import org.eclipse.swt.widgets.Control;
23 23
import org.eclipse.swt.widgets.Label;
24 24
import org.eclipse.swt.widgets.Text;
25
import org.eclipse.ui.forms.widgets.TableWrapData;
26 25

  
27 26
import eu.etaxonomy.cdm.common.CdmUtils;
28 27
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
......
121 120
	protected void createControls(ICdmFormElement formElement,
122 121
	        TaxonNode entity, int style) {
123 122
//	    taxon = entity.getTaxon();
123

  
124 124
	    Label taxonTitle = new Label(getLayoutComposite(), SWT.NULL);
125
        taxonTitle.setText(Messages.TaxonNodeWizardPage_TAXON_INFORMATION);
126
        TableWrapData tableWrap = LayoutConstants.FILL_HORIZONTALLY(2, 2);
127
        tableWrap.valign = SWT.TOP;
128
        taxonTitle.setLayoutData(tableWrap);
129
        taxonTitle.setFont(FONT_BOLD);
125
	    taxonTitle.setText(Messages.TaxonNodeWizardPage_TAXON_INFORMATION);
126
	    taxonTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
127
	    taxonTitle.setFont(FONT_BOLD);
128

  
129

  
130 130

  
131 131
	    if (isCreateNew()){
132 132
	        textNewTaxonName = formFactory.createTextWithLabelElement(formElement,
......
156 156
                    Messages.TaxonNodeWizardPage_TAXON_IS_PUBLISH, true, style);
157 157

  
158 158
            checkbox_publish.setEnabled(isCreateNew());
159

  
159
            Label spacer = new Label(getLayoutComposite(), SWT.NULL);
160
            spacer.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 2));
160 161
            Label nodeTitle = new Label(getLayoutComposite(), SWT.NULL);
161
            nodeTitle.setText(Messages.TaxonNodeWizardPage_TAXON_NODE);
162
            nodeTitle.setText("Taxon Node");
162 163
            nodeTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
163 164
            nodeTitle.setFont(FONT_BOLD);
165
//            LabelElement nodeTitle = formFactory.createLabel(formElement, Messages.TaxonNodeWizardPage_TAXON_INFORMATION);
166
//            nodeTitle.setLayout(LayoutConstants.FILL_HORIZONTALLY(2, 1));
167
//            nodeTitle.setBackground(getPersistentBackground());
168
//            nodeTitle.setBold();
169

  
164 170
            selection_parentTaxonNode = formFactory
165 171
                    .createTaxonNodeSelectionElement(getConversationHolder(), formElement, Messages.TaxonNodeWizardPage_PARENT, parentNode,
166 172
                            EntitySelectionElement.DELETABLE, style, 100);
......
183 189
            }
184 190
            textTaxonSec.setEnabled(false);
185 191
            microReference.setEnabled(false);
192
            Label spacer = new Label(getLayoutComposite(), SWT.NULL);
193
            spacer.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 2));
186 194

  
187 195
            Label nodeTitle = new Label(getLayoutComposite(), SWT.NULL);
188 196
            nodeTitle.setText("Taxon Node");
189 197
            nodeTitle.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
190 198
            nodeTitle.setFont(FONT_BOLD);
191 199

  
200
//            LabelElement nodeTitle = formFactory.createLabel(formElement, "Taxon Node");
201
//            nodeTitle.setLayout(LayoutConstants.FILL_HORIZONTALLY(2, 1));
202
//            nodeTitle.setBackground(getPersistentBackground());
203
//            nodeTitle.setBold();
204

  
205

  
192 206
            if (entity.getParent().getTaxon() == null){
193 207
                TextWithLabelElement textParent = formFactory.createTextWithLabelElement(
194 208
                        formElement,CLASSIFICATION_STR, entity.getClassification().getTitleCache(), style);
......
199 213
                textParent.setEnabled(false);
200 214
            }
201 215
	    }
202
	    Label spacer = new Label(getLayoutComposite(), SWT.NULL);
203
	    spacer.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
216

  
217

  
204 218
        combo_status = formFactory.createEnumComboElement(TaxonNodeStatus.class, formElement, style, true);
205 219
        if (!isCreateNew()){
206 220
            combo_status.setSelection(entity.getStatus());
......
235 249
	        multiLanguageTextStatusNotes.setEnabled(entity.getStatus() != null);
236 250
	    }
237 251

  
238
		if (!isCreateNew()){
239
		    selectionNodeAgentRelation = formFactory.createTaxonNodeAgentRelationCollectionSection(formElement, getConversationHolder(), StoreUtil.getSectionStyle(TaxonNodeAgentRelationCollectionSection.class, entity.getClass().getCanonicalName()));
240 252

  
241
		    selectionNodeAgentRelation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
242
		    selectionNodeAgentRelation.setEntity(entity);
243
		}
244 253

  
245 254
		sourceSection = formFactory.createOriginalSourceElement(formElement, entity);
246
		if (isCreateNew()){
247
		    sourceSection.setEntity(null);
255
		if (isCreateNew() || entity.getSource() == null){
256
		    DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(null, null);
257
		    entity.setSource(source);
258
		    sourceSection.setEntity(source);
248 259
		}else{
249 260
		    sourceSection.setEntity(entity.getSource());
261

  
250 262
		}
251 263

  
264
		selectionNodeAgentRelation = formFactory.createTaxonNodeAgentRelationCollectionSection(formElement, getConversationHolder(), StoreUtil.getSectionStyle(TaxonNodeAgentRelationCollectionSection.class, entity.getClass().getCanonicalName()));
265
		selectionNodeAgentRelation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
266
        selectionNodeAgentRelation.setEntity(entity);
267
        setBackground(getPersistentBackground());
252 268

  
253 269
	}
254 270

  
......
323 339
		}
324 340

  
325 341
        if (eventSource == sourceSection) {
326
            if(!isCreateNew()){
327
                getEntity().setSource((DescriptionElementSource)sourceSection.getEntity());
328
            }
342
//            getEntity().setSource((DescriptionElementSource)sourceSection.getEntity());
343

  
329 344
        }else if (eventSource == selection_SecRef) {
330 345
            if (taxon != null){
331 346
                taxon.setSec(selection_SecRef.getEntity());
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/TaxonNodeWizardPage.java
75 75
	@Override
76 76
	public TaxonNodeDetailElement createElement(ICdmFormElement rootElement) {
77 77
	    TaxonNodeDetailElement detailElement = formFactory.createTaxonNodeDetailElement(rootElement, this.isCreateNew);
78
		if (isCreateNew){
78

  
79
	    if (isCreateNew){
79 80
		    detailElement.setParentTreeNode(((NewTaxonNodeWizard)getWizard()).getParentEntity());
80 81
		}else{
81 82
		    detailElement.setEntity(entity);
82 83
		}
84
//	    detailElement.setPersistentBackground(Abstrac);;
83 85

  
84 86
		formFactory.addPropertyChangeListener(this);
85 87
//		if (isCreateNew){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/AdvancedSourceElement.java
69 69
        text_originaleNameString.setBackground(background);
70 70

  
71 71
        select_nameUsedInSource = formFactory.createSelectionElement(TaxonName.class, formElement, "Name in Source", entity != null? ((DescriptionElementSource)entity).getNameUsedInSource(): null, EntitySelectionElement.DELETABLE, style);
72
        select_nameUsedInSource.setBackground(background);
73

  
72 74
        externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
73 75
        externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3));
74 76
        externalLinks.setEntity( ((OriginalSourceBase)entity));
77
        externalLinks.setBackground(background);
75 78
        addControl(externalLinks);
76 79
        addElement(externalLinks);
77 80

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/OriginalSourceElement.java
16 16
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
17 17
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
18 18
import eu.etaxonomy.cdm.model.reference.Reference;
19
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
20 19
import eu.etaxonomy.taxeditor.l10n.Messages;
21 20
import eu.etaxonomy.taxeditor.store.StoreUtil;
22 21
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
......
57 56
        }
58 57
        selection_Ref.setBackground(this.getPersistentBackground());
59 58
        microReference = formFactory.createTextWithLabelElement(formElement, "Details", entity != null? entity.getCitationMicroReference(): "", style);
59

  
60

  
60 61
        for (ICdmFormElement element: selection_Ref.getElements()){
61 62
            element.setBackground(getPersistentBackground());
62 63
        }
63 64

  
64 65
        advancedSection = formFactory.createOriginalSourceAdvancedSection(getConversationHolder(), formElement, null, StoreUtil.getSectionStyle(OriginalSourceAdvancedSection.class, INomenclaturalReference.class.getCanonicalName()));
65 66
        TableWrapData layoutData = LayoutConstants.FILL_HORIZONTALLY(2, 1);
66

  
67
        layoutData.indent = 10;
67 68

  
68 69
        advancedSection.setLayoutData(layoutData);
69 70

  
......
71 72
        addElement(advancedSection);
72 73
        advancedSection.setBackground(this.getPersistentBackground());
73 74
        advancedSection.setEntity(entity);
75
        if (!((DescriptionElementSource)entity).checkEmpty()){
76
            advancedSection.setExpanded(true);
77
        }else{
78
            advancedSection.setExpanded(false);
79
        }
74 80

  
75 81
    }
76 82

  
77 83
    @Override
78 84
    public void handleEvent(Object eventSource) {
79 85
        if (eventSource.equals(selection_Ref)){
80

  
81
            if (getEntity() == null){
82
                Reference ref = selection_Ref.getEntity();
83
                DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(null, null);
84
                setEntity(source);
85
                selection_Ref.setEntity(ref);
86
                if (cdmEntity != null && cdmEntity instanceof TaxonNode){
87
                    ((TaxonNode)cdmEntity).setSource(source);
88
                }
89
            }
90
            //TODO: why is this null????ß
91 86
            getEntity().setCitation(selection_Ref.getEntity());
92

  
93 87
        }else if (eventSource.equals(microReference)){
94

  
95
            if (getEntity() == null){
96
                DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(null, null);
97
                setEntity(source);
98
                if (cdmEntity != null && cdmEntity instanceof TaxonNode){
99
                    ((TaxonNode)cdmEntity).setSource(source);
100
                }
101
            }
102
            //TODO: why is this null????ß
103 88
            getEntity().setCitationMicroReference(microReference.getText());
104 89

  
105 90
        }

Also available in: Unified diff