Project

General

Profile

« Previous | Next » 

Revision e3895566

Added by Katja Luther over 3 years ago

ref #9065: derivedUnit wizard should contain media section but without loading the image

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/ImageElement.java
78 78
        @Override
79 79
        public void run() {
80 80
            try{
81
                EPartService partService = getFormFactory().getContext().get(EPartService.class);
82
                DetailsPartE4 detailsView = AbstractUtility.getDetailsView(partService);
83
                if(detailsView!=null){
84
                    AbstractCdmDataViewerE4 viewer = (AbstractCdmDataViewerE4) detailsView.getViewer();
85
                    if(viewer!=null){
86
                        viewer.reflow();
81
                if (getFormFactory() != null && getFormFactory().getContext() != null){
82
                    EPartService partService = getFormFactory().getContext().get(EPartService.class);
83
                    DetailsPartE4 detailsView = AbstractUtility.getDetailsView(partService);
84
                    if(detailsView!=null){
85
                        AbstractCdmDataViewerE4 viewer = (AbstractCdmDataViewerE4) detailsView.getViewer();
86
                        if(viewer!=null){
87
                            viewer.reflow();
88
                        }
87 89
                    }
88
                }
89 90

  
90
                MPart mPartSupplemental = partService.findPart("eu.etaxonomy.taxeditor.view.e4.supplementaldata.SupplementalDataPartE4");
91
                if(mPartSupplemental!=null){
92
                    SupplementalDataPartE4 supplementalPart = (SupplementalDataPartE4)mPartSupplemental.getObject();
93
                    if(supplementalPart!=null){
94
                        AbstractCdmDataViewerE4 viewer = (AbstractCdmDataViewerE4) (supplementalPart).getViewer();
95
                        if(viewer!=null){
96
                            viewer.refresh();
91
                    MPart mPartSupplemental = partService.findPart("eu.etaxonomy.taxeditor.view.e4.supplementaldata.SupplementalDataPartE4");
92
                    if(mPartSupplemental!=null){
93
                        SupplementalDataPartE4 supplementalPart = (SupplementalDataPartE4)mPartSupplemental.getObject();
94
                        if(supplementalPart!=null){
95
                            AbstractCdmDataViewerE4 viewer = (AbstractCdmDataViewerE4) (supplementalPart).getViewer();
96
                            if(viewer!=null){
97
                                viewer.refresh();
98
                            }
97 99
                        }
98 100
                    }
99 101
                }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/MediaDetailElement.java
13 13
import java.util.List;
14 14
import java.util.Set;
15 15

  
16
import org.apache.commons.imaging.ImageReadException;
16 17
import org.apache.http.HttpException;
17 18
import org.eclipse.core.runtime.IProgressMonitor;
18 19
import org.eclipse.core.runtime.IStatus;
......
20 21
import org.eclipse.core.runtime.jobs.Job;
21 22
import org.eclipse.swt.SWT;
22 23
import org.eclipse.swt.widgets.Label;
23
import org.apache.commons.imaging.ImageReadException;
24 24

  
25 25
import eu.etaxonomy.cdm.common.UriUtils;
26 26
import eu.etaxonomy.cdm.common.media.CdmImageInfo;
......
50 50

  
51 51
    private static final String LOAD_IMAGE = Messages.MediaDetailElement_LOAD_IMAGE;
52 52

  
53
    private boolean isShowImage = true;
54

  
53 55
    /**
54 56
     * @author pplitzner
55 57
     * @since Jul 11, 2019
......
66 68
        protected IStatus run(IProgressMonitor monitor) {
67 69
            try {
68 70
                //first check if uri refers to an actual (non-image) file
71

  
69 72
                UriUtils.getInputStream(uri);// will fail with a FileNotFoundException if not
73

  
70 74
                CdmImageInfo imageInfo = CdmImageInfo.NewInstance(uri, 10000);//will fail when it is no image file
71 75
                MediaDetailElement.this.getLayoutComposite().getDisplay().asyncExec(()->{
72 76
                    singleMediaRepresentationPart.setSize((int) imageInfo.getLength());
......
136 140
        showAdvancedView();
137 141
    }
138 142

  
143
    public boolean isShowImage() {
144
        return isShowImage;
145
    }
146

  
147
    public void setShowImage(boolean isShowImage) {
148
        this.isShowImage = isShowImage;
149
    }
150

  
139 151
    @Override
140 152
    public void handleEvent(Object eventSource){
141 153
        if(eventSource==textUri){
......
146 158
                uriBuffer=textUri.getText();
147 159
            }
148 160
            else{
149
                new LoadImageJob(uri, LOAD_IMAGE).schedule();
161
                if (isShowImage){
162
                    LoadImageJob job = new LoadImageJob(uri, LOAD_IMAGE);
163
                    job.schedule();
164
                }
150 165
            }
151 166
        }
152 167
    }
......
232 247
                textUri.parseText();
233 248
            }
234 249
            textUri.getLayoutComposite().layout();
235

  
236
            new LoadImageJob(singleMediaRepresentationPart.getUri(), LOAD_IMAGE).schedule();
250
            if (isShowImage){
251
                LoadImageJob job = new LoadImageJob(singleMediaRepresentationPart.getUri(), LOAD_IMAGE);
252
                job.schedule();
253
            }
237 254
        }
238 255
    }
239 256

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/MediaMetaElement.java
82 82

  
83 83

  
84 84
        mediaDetailElement = formFactory.createMediaDetailElement(element);
85

  
86
        ICdmFormElement grandGrandParent = getParentElement().getParentElement().getParentElement();
87
        Class clazz = grandGrandParent.getClass();
88
        //TODO: find a nicer solution
89
        if (grandGrandParent != null && clazz.getName().equals("eu.etaxonomy.taxeditor.ui.element.AbstractCdmEntityWizardPage$WizardPageRootElement")){
90
            mediaDetailElement.setShowImage(false);
91
        }
85 92
        addElement(mediaDetailElement);
86 93
    }
87 94

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DerivedUnitBaseDetailElement.java
40 40
public class DerivedUnitBaseDetailElement extends
41 41
		AbstractSpecimenOrObservationDetailElement {
42 42

  
43
    boolean showOnlyDerivedUnitData = true;
44

  
43 45
	private TextWithLabelElement text_derivedUnitDefinitions;
44 46

  
45 47
	private TextWithLabelElement text_barcode;
......
79 81
		super(formFactory, formElement);
80 82
	}
81 83

  
82
	/** {@inheritDoc} */
84
	public boolean isShowOnlyDerivedUnitData() {
85
        return showOnlyDerivedUnitData;
86
    }
87

  
88
    public void setShowOnlyDerivedUnitData(boolean showOnlyDerivedUnitData) {
89
        this.showOnlyDerivedUnitData = showOnlyDerivedUnitData;
90
    }
91

  
92
    /** {@inheritDoc} */
83 93
	@Override
84 94
    protected void createControls(ICdmFormElement formElement, DerivedUnitFacade entity, int style) {
85 95
		// Disable for now
......
128 138
		section_source.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
129 139
		section_source.setEntity(entity);
130 140

  
131
		if(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart){
141
		if(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart || !showOnlyDerivedUnitData){
132 142
            mediaDetailElement = formFactory.createDerivedUnitMediaSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(DerivedUnitMediaSection.class, entity.getClass().getCanonicalName()));
133 143
            mediaDetailElement.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
134 144
            mediaDetailElement.setEntity(getEntity());
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DerivedUnitBaseWizardPage.java
38 38
	@Override
39 39
	public AbstractCdmDetailElement<DerivedUnitFacade> createElement(ICdmFormElement rootElement) {
40 40
		DerivedUnitBaseDetailElement detailElement = formFactory.createDerivedUnitBaseDetailElement(rootElement);
41
		detailElement.setShowOnlyDerivedUnitData(false);
41 42
		detailElement.setEntity(getEntity());
43

  
42 44
		return detailElement;
43 45
	}
44 46

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

Also available in: Unified diff