Project

General

Profile

« Previous | Next » 

Revision 5964be2c

Added by Patrick Plitzner over 4 years ago

ref #6925 Inject context into details and supplemental view

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
4 4
package eu.etaxonomy.taxeditor.ui.element;
5 5

  
6 6
import java.net.URI;
7

  
8 7
import java.util.ArrayList;
9 8
import java.util.Comparator;
10 9
import java.util.HashSet;
......
12 11
import java.util.Map;
13 12
import java.util.Set;
14 13

  
15
import org.eclipse.jface.layout.GridDataFactory;
16 14
import org.eclipse.jface.util.IPropertyChangeListener;
17 15
import org.eclipse.jface.viewers.ISelection;
18 16
import org.eclipse.jface.viewers.ISelectionProvider;
......
36 34
import org.eclipse.swt.widgets.Display;
37 35
import org.eclipse.swt.widgets.Event;
38 36
import org.eclipse.swt.widgets.Label;
39
import org.eclipse.swt.widgets.Text;
40 37
import org.eclipse.ui.forms.IFormColors;
41 38
import org.eclipse.ui.forms.widgets.ExpandableComposite;
42 39
import org.eclipse.ui.forms.widgets.FormToolkit;
......
44 41
import org.eclipse.ui.forms.widgets.TableWrapData;
45 42
import org.eclipse.ui.internal.forms.widgets.FormFonts;
46 43
import org.joda.time.DateTime;
47
import org.joda.time.LocalDateTime;
48

  
49 44
import org.joda.time.Partial;
50 45
import org.springframework.security.core.GrantedAuthority;
51 46

  
......
55 50
import eu.etaxonomy.cdm.model.agent.Person;
56 51
import eu.etaxonomy.cdm.model.agent.Team;
57 52
import eu.etaxonomy.cdm.model.common.Annotation;
58
import eu.etaxonomy.cdm.model.common.AnnotationType;
59 53
import eu.etaxonomy.cdm.model.common.CdmBase;
60 54
import eu.etaxonomy.cdm.model.common.Credit;
61 55
import eu.etaxonomy.cdm.model.common.DefinedTerm;
......
122 116
import eu.etaxonomy.taxeditor.ui.dialog.CloneClassificationDetailElement;
123 117
import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection.UnitType;
124 118
import eu.etaxonomy.taxeditor.ui.mvc.element.DateElement;
125

  
126 119
import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled;
127 120
import eu.etaxonomy.taxeditor.ui.openurl.OpenUrlSelectorElement;
128 121
import eu.etaxonomy.taxeditor.ui.password.EditPasswordElement;
......
437 430
     *            a {@link org.eclipse.swt.widgets.Display} object.
438 431
     */
439 432
    public CdmFormFactory(Display display) {
440
        super(display);
441
        init();
433
        this(display, null);
442 434
    }
443 435

  
444 436
    /**
......
518 510
    @Override
519 511
    public void adapt(Composite composite) {
520 512
        composite.addMouseListener(selectionMouseHandler);
521
       
513

  
522 514
        super.adapt(composite);
523 515
    }
524 516

  
......
925 917
            ICdmFormElement parentElement,
926 918
            String labelString,
927 919
            T selection,
928
            int style, 
920
            int style,
929 921
            Comparator<T> comparator) {
930 922
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false, comparator);
931 923
    }
......
939 931
			int style) {
940 932
        return this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, addEmptyElement, style, false, null);
941 933
	}
942
    
934

  
943 935
	public <T extends DefinedTermBase> TermComboElement<T> createDefinedTermComboElement(
944 936
			TermType termType,
945 937
			ICdmFormElement parentElement,
946 938
			String labelString,
947
			T selection, 
939
			T selection,
948 940
			int style) {
949 941
		return  this.createDefinedTermComboElement(termType, null, parentElement, labelString, selection, true, style, false, null);
950 942
	}
......
2146 2138
        addAndAdaptElement(parentElement, element);
2147 2139
        return element;
2148 2140
    }
2149
  
2141

  
2150 2142
    public NameDetailElement createNameDetailElement(ICdmFormElement parentElement, int style){
2151 2143
        NameDetailElement element = new NameDetailElement(this, parentElement, style);
2152 2144
        addAndAdaptElement(parentElement, element);
......
2912 2904
//        label.setText(labelText+" (yyyy-MM-dd)");
2913 2905
//        DateElementFormElement dateElement = new DateElementFormElement(this, dateTime, style, formElement.getLayoutComposite());
2914 2906
//        dateElement.initInternalController();
2915
//        
2907
//
2916 2908
//        return dateElement;
2917 2909
//    }
2918
    
2910

  
2919 2911
    public DateElement createDateElement(ICdmFormElement formElement, String labelText, DateTime dateTime, int style, boolean editableText){
2920 2912
    	 Label label = new Label(formElement.getLayoutComposite(), style);
2921 2913
         label.setText(labelText);
......
3029 3021
        return section;
3030 3022
    }
3031 3023

  
3032
	
3024

  
3033 3025
	public TaxonOfRelationshipElement createTaxonOfRelationshipDetailElement(
3034 3026
			ICdmFormElement parentElement, int style) {
3035 3027
		TaxonOfRelationshipElement section = new TaxonOfRelationshipElement(this, parentElement, style);
......
3054 3046
//	        return element;
3055 3047
//	}
3056 3048

  
3057
	
3049

  
3058 3050

  
3059 3051

  
3060 3052

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java
67 67
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
68 68
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
69 69
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
70

  
71 70
import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
72 71
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
73 72
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
......
142 141

  
143 142
    @Override
144 143
    public void setInput(Object input) {
145
    	
144

  
146 145
        if(input instanceof TreeNode){
147 146
            input = ((TreeNode) input).getValue();
148 147
        }
......
190 189
        // Too much type checking to decide which detail view to display.
191 190
        // Need to build in a mechanism where navigators / editors are 'aware'
192 191
        // of the corresponding detail viewer.
193
    	
192

  
194 193
        Object input = getInput();
195 194

  
196 195
        destroySections();
......
324 323
            createEmptySection(rootElement);
325 324
        }
326 325
        layout();
327
       
326

  
328 327
    }
329 328

  
330 329

  
......
357 356
    /** {@inheritDoc} */
358 357
    @Override
359 358
    public void setSelection(ISelection selection, boolean reveal) {
360
    	
359

  
361 360
    		this.selection = selection;
362
	      
361

  
363 362
	        if(this.selection!=null){
364 363
	            SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(this, selection);
365 364
	            fireSelectionChanged(selectionChangedEvent);
366 365
	        }
367
    	
366

  
368 367
    }
369 368

  
370 369
    private void createTaxonSections(RootElement parent) {
......
495 494
        destroySections();
496 495

  
497 496
        DescriptionElementDetailSection descriptionElementDetailSection = formFactory.createDescriptionElementDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
498
        
497

  
499 498
      //  IntextReferenceSection intextReferenceSection = formFactory.createIntextReferenceSection(getConversationHolder(), parent,  ExpandableComposite.TWISTIE);
500
        
499

  
501 500
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
502 501

  
503 502
        DescriptionElementSourceSection descriptionElementSourceSection = formFactory.createDescriptionElementSourceSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
......
585 584

  
586 585
        DerivedUnitGeneralDetailSection derivedUnitGeneralDetailSection = formFactory.createDerivedUnitGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
587 586
        //TODO for DerivateEditor do not use facade anymore to avoid this special case handling #4539
588
        if(!(AbstractUtility.getActiveE4Part() instanceof IDerivedUnitFacadePart)){
589
            derivedUnitGeneralDetailSection.setShowOnlyDerivedUnitData(true);
590
        }
587
//        if(!(AbstractUtility.getActiveE4Part() instanceof IDerivedUnitFacadePart)){
588
//            derivedUnitGeneralDetailSection.setShowOnlyDerivedUnitData(true);
589
//        }
591 590
        addPart(derivedUnitGeneralDetailSection);
592 591

  
593 592
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
......
786 785
       // ReferencedEntityDetailSection referencedEntityBaseDetailSection = formFactory.createReferencedEntityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
787 786
        addPart(taxonRelationshipDetailSection);
788 787
        //addPart(referencedEntityBaseDetailSection);
789
       
788

  
790 789
        NonViralNameDetailSection nonViralNameSection = formFactory
791 790
                .createNonViralNameDetailSection(getConversationHolder(), parent, this, true,
792 791
                        ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
......
823 822
		addPart(nameRelationshipSection);
824 823
	//}
825 824

  
826
        
825

  
827 826
        //}
828 827
    }
829 828

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmDataViewerE4.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.view.e4;
11 11

  
12
import javax.inject.Inject;
13

  
14
import org.eclipse.e4.core.contexts.IEclipseContext;
12 15
import org.eclipse.jface.viewers.StructuredSelection;
13 16
import org.eclipse.jface.viewers.Viewer;
14 17
import org.eclipse.swt.SWT;
......
43 46

  
44 47
	protected ScrolledForm scrolledForm;
45 48

  
46
	private final Composite body;
49
	private Composite body;
47 50

  
48 51
	protected RootElement rootElement;
49 52

  
53
	@Inject
54
	protected IEclipseContext context;
55

  
50 56
	//TODO: create a super class for this?
51 57
	private Object input;
52 58

  
53
	protected final IDirtyMarkable part;
59
	protected IDirtyMarkable part;
54 60

  
61
	@Inject
62
	public AbstractCdmDataViewerE4() {
63

  
64
	}
55 65

  
56
	public AbstractCdmDataViewerE4(Composite parent, IDirtyMarkable part) {
66
	public void init(Composite parent, IDirtyMarkable part) {
57 67
	    this.part = part;
58 68

  
59 69
		managedForm = new ManagedForm(parent){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java
12 12
import javax.annotation.PostConstruct;
13 13
import javax.inject.Inject;
14 14

  
15
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
16
import org.eclipse.e4.core.contexts.IEclipseContext;
15 17
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
16 18
import org.eclipse.jface.viewers.IStructuredSelection;
17 19
import org.eclipse.swt.widgets.Composite;
......
38 40
    }
39 41

  
40 42
    @PostConstruct
41
    public void create(Composite parent, MPart thisPart) {
43
    public void create(Composite parent, MPart thisPart, IEclipseContext context) {
42 44

  
43 45
        this.thisPart = thisPart;
44 46

  
45
        viewer = new DetailsViewerE4(parent, this);
47
        viewer = ContextInjectionFactory.make(DetailsViewerE4.class, context);
48
        ((DetailsViewerE4)viewer).init(parent, this);
46 49

  
47 50
        // Propagate selection from viewer
48 51
        selectionChangedListener = (event -> selService.setSelection(AbstractUtility.getElementsFromSelectionChangedEvent(event)));
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java
17 17
import org.eclipse.jface.viewers.SelectionChangedEvent;
18 18
import org.eclipse.jface.viewers.TreeNode;
19 19
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.widgets.Composite;
21 20
import org.eclipse.ui.forms.widgets.ExpandableComposite;
22 21

  
23 22
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
......
55 54
import eu.etaxonomy.taxeditor.model.AbstractUtility;
56 55
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
57 56
import eu.etaxonomy.taxeditor.model.IDerivedUnitFacadePart;
58
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
59 57
import eu.etaxonomy.taxeditor.model.MessagingUtils;
60 58
import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship;
61 59
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
......
135 133
    private ISelection selection;
136 134
    private boolean detailsEnabled = true;
137 135

  
138
    public DetailsViewerE4(Composite parent, IDirtyMarkable part) {
139
        super(parent, part);
140

  
141
    }
142 136
    public void setInput(Object input, Object activePart) {
143 137
        if (activePart instanceof IDistributionEditor){
144 138
            detailsEnabled = false;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/supplementaldata/SupplementalDataPartE4.java
14 14
import javax.annotation.PostConstruct;
15 15
import javax.inject.Inject;
16 16

  
17
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
18
import org.eclipse.e4.core.contexts.IEclipseContext;
17 19
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
18 20
import org.eclipse.jface.viewers.IStructuredSelection;
19 21
import org.eclipse.jface.viewers.StructuredSelection;
......
46 48
    }
47 49

  
48 50
	@PostConstruct
49
	public void create(Composite parent, MPart thisPart) {
51
	public void create(Composite parent, MPart thisPart, IEclipseContext context) {
50 52

  
51 53
	    this.thisPart = thisPart;
52 54

  
53
	    viewer = new SupplementalDataViewerE4(parent, this);
55
	    viewer = ContextInjectionFactory.make(SupplementalDataViewerE4.class, context);
56
	    ((SupplementalDataViewerE4)viewer).init(parent, this);
54 57
	}
55 58

  
56 59
    @Override
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/supplementaldata/SupplementalDataViewerE4.java
11 11

  
12 12
import org.eclipse.jface.viewers.ISelection;
13 13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.widgets.Composite;
15 14
import org.eclipse.ui.forms.widgets.ExpandableComposite;
16 15

  
17 16
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
......
19 18
import eu.etaxonomy.cdm.model.common.VersionableEntity;
20 19
import eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity;
21 20
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
22
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
23 21
import eu.etaxonomy.taxeditor.model.IElementHasDetails;
24 22
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
25 23
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
......
47 45

  
48 46
	private boolean showDebug;
49 47

  
50
	public SupplementalDataViewerE4(Composite parent, IDirtyMarkable viewPart) {
51
		super(parent, viewPart);
52
	}
53

  
54 48
	/** {@inheritDoc} */
55 49
	@Override
56 50
	public ISelection getSelection() {

Also available in: Unified diff