Project

General

Profile

« Previous | Next » 

Revision 17653afc

Added by Patrick Plitzner almost 7 years ago

Use wizard to create new specimen

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/create/NewSpecimenHandler.java
10 10

  
11 11
package eu.etaxonomy.taxeditor.editor.handler.create;
12 12

  
13
import java.util.Collections;
14

  
15 13
import org.apache.log4j.Logger;
16 14
import org.eclipse.core.commands.AbstractHandler;
17 15
import org.eclipse.core.commands.ExecutionEvent;
18 16
import org.eclipse.core.commands.ExecutionException;
19
import org.eclipse.ui.PartInitException;
17
import org.eclipse.jface.wizard.WizardDialog;
18
import org.eclipse.ui.handlers.HandlerUtil;
20 19

  
21
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
22
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeCacheStrategy;
23
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeFieldUnitCacheStrategy;
24
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
25
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
26
import eu.etaxonomy.cdm.model.occurrence.DerivationEventType;
27
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
28
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
29
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
30
import eu.etaxonomy.taxeditor.editor.EditorUtil;
31
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
32
import eu.etaxonomy.taxeditor.store.CdmStore;
20
import eu.etaxonomy.taxeditor.newWizard.NewDerivedUnitBaseWizard;
33 21

  
34 22
/**
35 23
 * @author n.hoffmann
......
43 31
	/** {@inheritDoc} */
44 32
	@Override
45 33
    public Object execute(ExecutionEvent event) throws ExecutionException {
46
	    ConversationHolder conversation = CdmStore.createConversation();
47
	    conversation.bind();
48
	    FieldUnit fieldUnit = FieldUnit.NewInstance();
49
	    DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
50
	    DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit, DerivationEventType.GATHERING_IN_SITU());
51
	    fieldUnit.setCacheStrategy(new DerivedUnitFacadeFieldUnitCacheStrategy());
52
	    derivedUnit.setCacheStrategy(new DerivedUnitFacadeCacheStrategy());
53
        CdmStore.getService(IOccurrenceService.class).save(fieldUnit);
54
        CdmStore.getService(IOccurrenceService.class).save(derivedUnit);
55
        conversation.commit();
56
        DerivateViewEditorInput input = new DerivateViewEditorInput(Collections.singleton(fieldUnit.getUuid()));
57
        try {
58
            EditorUtil.open(input);
59
        } catch (PartInitException e) {
60
            // TODO Auto-generated catch block
61
            e.printStackTrace();
62
        }
63
//		NewDerivedUnitBaseWizard wizard = new NewDerivedUnitBaseWizard();
64
//		wizard.init(null, null);
65
//		WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
66
//		dialog.open();
34
	    //TODO: we need to discuss how specimens should be created and handled #5244
35
//	    ConversationHolder conversation = CdmStore.createConversation();
36
//	    conversation.bind();
37
//	    FieldUnit fieldUnit = FieldUnit.NewInstance();
38
//	    DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
39
//	    DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit, DerivationEventType.GATHERING_IN_SITU());
40
//	    fieldUnit.setCacheStrategy(new DerivedUnitFacadeFieldUnitCacheStrategy());
41
//	    derivedUnit.setCacheStrategy(new DerivedUnitFacadeCacheStrategy());
42
//        CdmStore.getService(IOccurrenceService.class).save(fieldUnit);
43
//        CdmStore.getService(IOccurrenceService.class).save(derivedUnit);
44
//        conversation.commit();
45
//        DerivateViewEditorInput input = new DerivateViewEditorInput(Collections.singleton(fieldUnit.getUuid()));
46
//        try {
47
//            EditorUtil.open(input);
48
//        } catch (PartInitException e) {
49
//            // TODO Auto-generated catch block
50
//            e.printStackTrace();
51
//        }
52
		NewDerivedUnitBaseWizard wizard = new NewDerivedUnitBaseWizard();
53
		wizard.init(null, null);
54
		WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
55
		dialog.open();
67 56
		return null;
68 57
	}
69 58
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DerivedUnitGeneralDetailElement.java
45 45
		AbstractCdmDetailElement<DerivedUnitFacade> {
46 46

  
47 47
    boolean showOnlyDerivedUnitData = false;
48
    //TODO: flag to disable specimen type dropdown (#5244)
49
    boolean showSpecimenType = true;
48 50

  
49 51
	private ToggleableTextElement toggleableText_titleCache;
50 52
	private EnumComboElement<SpecimenOrObservationType> combo_specorobstype;
......
71 73
	    super(formFactory, formElement);
72 74
	}
73 75

  
74
	/*
75
	 * (non-Javadoc)
76
	 *
77
	 * @see
78
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
79
	 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
80
	 */
81 76
	@Override
82 77
	protected void createControls(ICdmFormElement formElement,
83 78
			DerivedUnitFacade entity, int style) {
......
91 86
		else{
92 87
		    combo_specorobstype = formFactory.createEnumComboElement(SpecimenOrObservationType.class, formElement, style);
93 88
		    combo_specorobstype.setSelection(entity.getType());
89
		    combo_specorobstype.setEnabled(showSpecimenType);
94 90
		    selection_country = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(),
95 91
		            formElement, "Country",
96 92
		            entity.getCountry(), EntitySelectionElement.NOTHING, style);
......
130 126

  
131 127
	}
132 128

  
133
	/*
134
	 * (non-Javadoc)
135
	 *
136
	 * @see
137
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
138
	 * .lang.Object)
139
	 */
140 129
	@Override
141 130
	public void handleEvent(Object eventSource) {
142 131
		if (eventSource == toggleableText_titleCache) {
......
177 166
        this.showOnlyDerivedUnitData = showOnlyDerivedUnitData;
178 167
    }
179 168

  
169
    public void setShowSpecimenType(boolean showSpecimenType) {
170
        this.showSpecimenType = showSpecimenType;
171
    }
172

  
180 173
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DerivedUnitGeneralWizardPage.java
38 38
	@Override
39 39
	public AbstractCdmDetailElement<DerivedUnitFacade> createElement(ICdmFormElement rootElement) {
40 40
		DerivedUnitGeneralDetailElement detailElement = formFactory.createDerivedUnitGeneralDetailElement(rootElement);
41
		detailElement.setShowSpecimenType(false);
41 42
		detailElement.setEntity(getEntity());
42 43
		checkComplete();
43 44
		return detailElement;

Also available in: Unified diff