Project

General

Profile

Revision 8b6ed3fc

ID8b6ed3fcc9218b2e1a80774cb3608f73bf1d1589
Parent 98349912
Child f0e89021

Added by Patrick Plitzner over 2 years ago

ref #8135 Implement TextualTypeDesignation detail element

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/ImageResources.java
54 54
	public static final String COPY_ICON = "copy_icon";
55 55
	public static final String PASTE_ICON = "paste_icon";
56 56
	public static final String ADD_ICON = "add_icon";
57
	public static final String ADD_DOUBLE = "add_double";
58
	public static final String ADD_TEXT = "add_text";
57 59
	public static final String ADD_ICON_GREEN = "add_icon_green";
58 60
	public static final String MIN_ICON = "min_icon";
59 61
	public static final String ADD_EDIT = "add_edit";
......
293 295
	            "paste_edit.png");
294 296
		registerImage(registry, ADD_ICON,
295 297
				"add_no_bg.gif");
298
		registerImage(registry, ADD_DOUBLE,
299
		        "add_double.png");
300
		registerImage(registry, ADD_TEXT,
301
		        "add_text.png");
296 302
		registerImage(registry, ADD_ICON_GREEN,
297 303
		        "add.gif");
298 304
		registerImage(registry, MIN_ICON,
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
102 102
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
103 103
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
104 104
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
105
import eu.etaxonomy.cdm.model.name.TextualTypeDesignation;
105 106
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
106 107
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
107 108
import eu.etaxonomy.cdm.model.reference.Reference;
......
233 234
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueElement;
234 235
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
235 236
import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
237
import eu.etaxonomy.taxeditor.ui.section.name.TextTypeDesignationElement;
236 238
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
237 239
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreaDetailElement;
238 240
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
......
2773 2775
        } else if (entity instanceof NameTypeDesignation) {
2774 2776
            element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener,
2775 2777
                    style);
2778
        } else if (entity instanceof TextualTypeDesignation) {
2779
            element = new TextTypeDesignationElement(this, parentElement, (TextualTypeDesignation) entity, removeListener,
2780
                    style);
2776 2781
        } else if (entity instanceof NameRelationship) {
2777 2782
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2778 2783
                    style);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/TextTypeDesignationElement.java
1
/**
2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9

  
10
package eu.etaxonomy.taxeditor.ui.section.name;
11

  
12
import org.eclipse.jface.util.PropertyChangeEvent;
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.events.SelectionListener;
15

  
16
import eu.etaxonomy.cdm.model.name.TextualTypeDesignation;
17
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
18
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
20
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
21
import eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement;
22

  
23
/**
24
 *
25
 * @author pplitzner
26
 * @since May 15, 2019
27
 *
28
 */
29
public class TextTypeDesignationElement extends
30
		AbstractTypeDesignationElement<TextualTypeDesignation> {
31

  
32
    private MultilanguageTextElement multilanguageTextElement;
33
    private CheckboxElement checkIsVerbatim;
34

  
35
	public TextTypeDesignationElement(CdmFormFactory formFactory,
36
			AbstractFormSection section, TextualTypeDesignation entity,
37
			SelectionListener removeListener, int style) {
38
		super(formFactory, section, entity, removeListener, style);
39
	}
40

  
41
	@Override
42
	public void createControls(ICdmFormElement formElement, int style) {
43
        multilanguageTextElement = formFactory.createMultiLanguageTextElement(this, null, entity.getText(), 200, SWT.WRAP);
44
        checkIsVerbatim = formFactory.createCheckbox(formElement, "Is Verbatim", getEntity().isVerbatim(), style);
45
		super.createControls(formElement, style);
46
	}
47

  
48
    @Override
49
    public void propertyChange(PropertyChangeEvent event) {
50
        if(event.getSource()==multilanguageTextElement){
51
            multilanguageTextElement.getMultilanguageText().values()
52
                    .forEach(languageString -> getEntity().putText(languageString));
53
        }
54
        super.propertyChange(event);
55
    }
56

  
57
	@Override
58
	public void setEntity(TextualTypeDesignation entity) {
59
	    super.setEntity(entity);
60
	}
61

  
62
	@Override
63
	public void handleEvent(Object eventSource) {
64
	    super.handleEvent(eventSource);
65
	    if(eventSource==checkIsVerbatim){
66
	        getEntity().setVerbatim(checkIsVerbatim.getSelection());
67
	    }
68
	}
69
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/TypeDesignationSection.java
31 31
import eu.etaxonomy.cdm.model.name.Rank;
32 32
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
33 33
import eu.etaxonomy.cdm.model.name.TaxonName;
34
import eu.etaxonomy.cdm.model.name.TextualTypeDesignation;
34 35
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
35 36
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
36 37
import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
......
67 68

  
68 69
	@Override
69 70
	protected void addAction(ToolBarManager toolBarManager) {
71
	    if(PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES)){
72
	        // add textual type designation button
73
	        Action addTextualTypeDesignationAction = new Action("Add", IAction.AS_PUSH_BUTTON){
74
	            @Override
75
	            public void run() {
76
	                TextualTypeDesignation textualTypeDesignation = TextualTypeDesignation.NewInstance();
77
	                addElement(textualTypeDesignation);
78
	                if(! getSection().isExpanded()) {
79
	                    getSection().setExpanded(true);
80
	                }
81
	                internalUpdateSection(true);
82
	            }
83
	        };
84
	        addTextualTypeDesignationAction.setImageDescriptor(new ImageDescriptor() {
85

  
86
	            @Override
87
	            public ImageData getImageData() {
88
	                return ImageResources.getImage(ImageResources.ADD_TEXT).getImageData();
89
	            }
90
	        });
91
	        addTextualTypeDesignationAction.setToolTipText("Add textual type designation");
92
	        toolBarManager.add(addTextualTypeDesignationAction);
93
	    }
94

  
95
        // clone button
70 96
	    if(!isSpecimenType() ||
71 97
	            getEntity().getTypeDesignations().isEmpty()
72 98
	            || getEntity().getTypeDesignations().stream().noneMatch(designation->designation instanceof SpecimenTypeDesignation)){
......
106 132

  
107 133
            @Override
108 134
            public ImageData getImageData() {
109
                return ImageResources.getImage(ImageResources.COPY_ICON).getImageData();
135
                return ImageResources.getImage(ImageResources.ADD_DOUBLE).getImageData();
110 136
            }
111 137
        });
112 138
        cloneAction.setToolTipText(Messages.TypeDesignationSection_CREATE_DUPLICATE);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)