Project

General

Profile

« Previous | Next » 

Revision c87fb375

Added by Katja Luther almost 6 years ago

adapt editor to proParte synonyms

View differences:

eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin.properties
128 128
command.label.48 = Datasource
129 129
command.label.49 = Misapplication
130 130
command.label.50 = Use Existing Image
131
command.label.60 = Pro Parte Synonym
131 132
command.name.36 = Create Misapplication
133
command.name.60 = Create Pro Parte Synonym
132 134
command.name.37 = Use Existing Image
133 135
command.name.38 = Open Distribution Editor
134 136
command.name.39 = New Datasource
eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_de.properties
127 127
command.label.47 = Referenz
128 128
command.label.48 = Datenquelle
129 129
command.label.49 = Misapplication
130
command.label.60 = Pro Parte Synonym
130 131
command.label.50 = Benutze vorhandenes Bild
131 132
command.name.36 = Erstelle Misapplication
133
command.name.60 = Erstelle Pro Parte Synonym
132 134
command.name.37 = Benutze vorhandenes Bild
133 135
command.name.38 = \u00d6ffne Verbreitungs-Editor
134 136
command.name.39 = Neue Datenquelle
eu.etaxonomy.taxeditor.editor/fragment.e4xmi
151 151
      <handlers xmi:id="_WWqoMIvQEee7R4eqeQiXZg" elementId="eu.etaxonomy.taxeditor.editor.name.e4.handler.SwapSynonymAndAcceptedHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.name.e4.handler.SwapSynonymAndAcceptedHandlerE4" command="_UFDx8IvQEee7R4eqeQiXZg"/>
152 152
      <handlers xmi:id="_edkd4IvQEee7R4eqeQiXZg" elementId="eu.etaxonomy.taxeditor.editor.name.e4.handler.SetBasionymHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.name.e4.handler.SetBasionymHandlerE4" command="_b2nCsIvQEee7R4eqeQiXZg"/>
153 153
      <handlers xmi:id="_lv9GYIvQEee7R4eqeQiXZg" elementId="eu.etaxonomy.taxeditor.editor.name.e4.handler.MoveSynonymToAnotherAcceptedTaxonHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.name.e4.handler.MoveSynonymToAnotherAcceptedTaxonHandlerE4" command="_jNvBQIvQEee7R4eqeQiXZg"/>
154
      <handlers xmi:id="_g8QScFgWEeiQk_eTMvMviQ" elementId="eu.etaxonomy.taxeditor.editor.name.e4.handler.CreateProParteSynonymHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.name.e4.handler.CreateProParteSynonymHandlerE4" command="_HSKdYFgXEeiQk_eTMvMviQ"/>
154 155
      <menus xsi:type="menu:PopupMenu" xmi:id="_tLceQYl4Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.nameeditor">
155 156
        <children xsi:type="menu:Menu" xmi:id="_R6buoIl5Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menu.new" label="%menu.label">
156 157
          <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_X1lWsEoREeiEhr9v9h_MoA" coreExpressionId="isNotMisapplication"/>
......
167 168
          <children xsi:type="menu:HandledMenuItem" xmi:id="_MCsX0Il8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.newMisapplication" label="%command.label.49" command="_c0byUIvPEee7R4eqeQiXZg">
168 169
            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_G1zjMEoOEeiEhr9v9h_MoA" coreExpressionId="isAcceptedTaxon"/>
169 170
          </children>
171
          <children xsi:type="menu:HandledMenuItem" xmi:id="_2S-_cFgWEeiQk_eTMvMviQ" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.newProParteSynonym" label="%command.label.60" command="_HSKdYFgXEeiQk_eTMvMviQ">
172
            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_9tgQQFgWEeiQk_eTMvMviQ" coreExpressionId="isAcceptedTaxon"/>
173
          </children>
170 174
        </children>
171 175
        <children xsi:type="menu:MenuSeparator" xmi:id="_bxjbgE3LEeiplYSgvvNXRQ" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.23"/>
172 176
        <children xsi:type="menu:DynamicMenuContribution" xmi:id="_drYq8E3LEeiplYSgvvNXRQ" elementId="eu.etaxonomy.taxeditor.editor.dynamicmenucontribution.nameEditor.openInCdmViewer" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.CdmViewerContextMenuE4"/>
......
358 362
    <elements xsi:type="commands:Command" xmi:id="_j2cfsJMmEeeR4YRjNqCKeA" elementId="eu.etaxonomy.taxeditor.editor.openSpecimenEditorForIndividualsAssociation" commandName="%command.name.OPEN_DERIVATIVE_EDITOR"/>
359 363
    <elements xsi:type="commands:Command" xmi:id="_0DKb4E3kEeivZbtHG8C6kA" elementId="eu.etaxonomy.taxeditor.editor.openSpecimenEditorForSpecimenOrObservation" commandName="%command.name.OPEN_DERIVATIVE_EDITOR"/>
360 364
    <elements xsi:type="commands:Command" xmi:id="_c3wW8FeBEeiJAP3GTkE0aQ" elementId="eu.etaxonomy.taxeditor.editor.command.descriptivedataseteditor.removeTaxon" commandName="%command.commandname.21"/>
365
    <elements xsi:type="commands:Command" xmi:id="_HSKdYFgXEeiQk_eTMvMviQ" elementId="eu.etaxonomy.taxeditor.editor.name.createProParteSynonym" commandName="%command.name.60"/>
361 366
  </fragments>
362 367
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_pZmusEalEeeXMc6kSYO7Xg" featurename="children" parentElementId="eu.etaxonomy.taxeditor.menu.showView" positionInList="after:eu.etaxonomy.taxeditor.workbench.menuseparator.navigation">
363 368
    <elements xsi:type="menu:HandledMenuItem" xmi:id="_FPIHQKNwEeebGZ23ERGMGw" elementId="eu.etaxonomy.taxeditor.editor.showViewMenu.conceptGraph" label="%view.name.3" iconURI="" tooltip="%view.name.3" command="_WPjpoDSnEeek0dKsFNy--Q">
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/AppModelId.java
187 187
	public static final String HANDLER_EU_ETAXONOMY_TAXEDITOR_EDITOR_NAME_E4_HANDLER_CREATEHETEROTYPICSYNONYMHANDLERE4 = "eu.etaxonomy.taxeditor.editor.name.e4.handler.CreateHeterotypicSynonymHandlerE4";
188 188
	public static final String HANDLER_EU_ETAXONOMY_TAXEDITOR_EDITOR_NAME_E4_HANDLER_CREATEHOMOTYPICSYNONYMHANDLERE4 = "eu.etaxonomy.taxeditor.editor.name.e4.handler.CreateHomotypicSynonymHandlerE4";
189 189
	public static final String HANDLER_EU_ETAXONOMY_TAXEDITOR_EDITOR_NAME_E4_HANDLER_CREATEMISAPPLICATIONHANDLERE4 = "eu.etaxonomy.taxeditor.editor.name.e4.handler.CreateMisapplicationHandlerE4";
190
	public static final String HANDLER_EU_ETAXONOMY_TAXEDITOR_EDITOR_NAME_E4_HANDLER_CREATEPROPARTESYNONYMHANDLERE4 = "eu.etaxonomy.taxeditor.editor.name.e4.handler.CreateProParteSynonymHandlerE4";
190 191
	public static final String HANDLER_EU_ETAXONOMY_TAXEDITOR_EDITOR_NAME_E4_HANDLER_CREATESYNONYMINHOMOTYPICALGROUPHANDLERE4 = "eu.etaxonomy.taxeditor.editor.name.e4.handler.CreateSynonymInHomotypicalGroupHandlerE4";
191 192
	public static final String HANDLER_EU_ETAXONOMY_TAXEDITOR_EDITOR_NAME_E4_HANDLER_DELETEALLEMPTYNAMESHANDLERE4 = "eu.etaxonomy.taxeditor.editor.name.e4.handler.DeleteAllEmptyNamesHandlerE4";
192 193
	public static final String HANDLER_EU_ETAXONOMY_TAXEDITOR_EDITOR_NAME_E4_HANDLER_DELETETAXONBASEHANDLERE4 = "eu.etaxonomy.taxeditor.editor.name.e4.handler.DeleteTaxonBaseHandlerE4";
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/container/ConceptContainerE4.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.editor.name.e4.container;
11

  
12
import org.apache.commons.lang.StringUtils;
13
import org.eclipse.swt.graphics.Font;
14

  
15
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
16
import eu.etaxonomy.cdm.model.name.TaxonName;
17
import eu.etaxonomy.cdm.model.taxon.Taxon;
18
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
19
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
20
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
21
import eu.etaxonomy.taxeditor.editor.name.container.EditorAnnotation;
22
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
23
import eu.etaxonomy.taxeditor.model.AbstractUtility;
24
import eu.etaxonomy.taxeditor.model.NameHelper;
25
import eu.etaxonomy.taxeditor.preference.Resources;
26

  
27
/**
28
 *
29
 * @author pplitzner
30
 * @date Aug 24, 2017
31
 *
32
 */
33
public class ConceptContainerE4 extends AbstractGroupedContainerE4<Taxon> {
34
	TaxonRelationship relationship;
35
	private boolean isMisapplication;
36

  
37
	public ConceptContainerE4(AbstractGroupE4 group, Taxon misappliedName, boolean isMisapplication) {
38
		super(group, misappliedName);
39
		this.isMisapplication = isMisapplication;
40

  
41
	}
42

  
43
	/** {@inheritDoc} */
44
	@Override
45
	protected void initializeComposite() {
46
		setIsDraggable(true);
47
		setFont(getViewerFont());
48
		TaxonNameEditorE4 editor = getEditor();
49
		Taxon taxon = editor.getTaxon();
50
		for (TaxonRelationship rel: taxon.getTaxonRelations(getMisappliedName())){
51
			if (rel.getType().isAnyMisappliedName() && isMisapplication){
52
			    relationship = rel;
53
				break;
54
			}else if (rel.getType().equals(TaxonRelationshipType.PRO_PARTE_SYNONYM_FOR()) && !isMisapplication){
55
			    relationship = rel;
56
                break;
57
			}
58
		}
59
		showSec();
60

  
61
		initTextViewer();
62
	}
63

  
64
	@Override
65
	protected void updateIcon() {
66
	    if (isMisapplication){
67
	        setIcon(MISAPPLIEDNAME_ICON);
68
	    }else{
69
	        setIcon(CONCEPT_ICON);
70
	    }
71
	}
72

  
73
	private void showSec() {
74
		if (getMisappliedName() == null) {
75
			return;
76
		}
77
		String title = "";
78
		String author = "";
79
		TaxonName conceptName = HibernateProxyHelper.deproxy(getMisappliedName().getName());
80
		if (isMisapplication && StringUtils.isNotBlank(conceptName.getAuthorshipCache())){
81
			author = ", non " + conceptName.getAuthorshipCache();
82
		}else if (!isMisapplication && StringUtils.isNotBlank(conceptName.getAuthorshipCache())){
83
		    author = conceptName.getAuthorshipCache();
84
		}
85
		if (getMisappliedName().getSec() == null) {
86
		    if (getMisappliedName().getAppendedPhrase() != null ){
87
		        title = getMisappliedName().getAppendedPhrase();
88
		    }else if (isMisapplication){
89
		        title = "auct.";
90

  
91
		    }
92

  
93
		} else {
94
			String sec = " sensu ";
95
			if (getMisappliedName().getAppendedPhrase() != null ){
96
			    sec = getMisappliedName().getAppendedPhrase() + " " + sec;
97
			}
98

  
99
			title += sec + getMisappliedName().getSec().getCacheStrategy().getCitation(getMisappliedName().getSec());
100
		}
101
		if (relationship.getType().equals(TaxonRelationshipType.PRO_PARTE_MISAPPLIED_NAME_FOR()) || relationship.getType().equals(TaxonRelationshipType.PRO_PARTE_SYNONYM_FOR())){
102
		    title += " p.p. ";
103
        }
104
		title += author;
105
		title = title.replace("&", "&&");
106
		setNonEditableInfo(title, false);
107
	}
108

  
109
	public Taxon getMisappliedName() {
110
		return getTaxonBase();
111
	}
112

  
113
	/** {@inheritDoc} */
114
	@Override
115
	protected Font getViewerFont() {
116
		return AbstractUtility.getFont(Resources.MISAPPLIEDNAME_FONT);
117
	}
118

  
119
	@Override
120
	public void showAnnotations() {
121
		if(getData().getSec() == null){
122
			getNameViewer().addAnnotation(
123
					new EditorAnnotation(0, Messages.MisapplicationContainer_SEC_REF_REQUIRED));
124
		}
125
		super.showAnnotations();
126
	}
127

  
128

  
129
	/** {@inheritDoc} */
130
	@Override
131
	protected void updateNonEditableInfo() {
132
		showSec();
133
	}
134

  
135
	@Override
136
	protected void updateIndent() {
137
		setIndent(MISAPPLIEDNAME_INDENT);
138
	}
139

  
140
	@Override
141
	protected void initTextViewer() {
142

  
143
		// showNameRelations();
144

  
145
		updateIndent();
146

  
147
		updateIcon();
148

  
149
		String text = NameHelper.getDisplayNameCache(getData());
150

  
151
		if (text.length() == 0) {
152
			initEmptyText();
153
		} else {
154
			getNameViewer().setText(text);
155
			placeCursor();
156
		}
157
		calculateAnnotations();
158
	}
159

  
160
	@Override
161
    public void refresh() {
162
		// showNameRelations();
163

  
164
		String text = NameHelper.getDisplayNameCache(getData());
165

  
166
		if (getNameViewer().getTextWidget() == null) {
167
			// we might get here via dnd. Look slike it can be ignored
168
			return;
169
		}
170

  
171
		if (text.length() == 0) {
172
			initEmptyText();
173
		} else if (!getNameViewer().getTextWidget().getText().equals(text)) {
174
			removeListener();
175
			getNameViewer().getTextWidget().setText(text);
176
			addListener();
177
		}
178

  
179
		updateNonEditableInfo();
180

  
181
		updateIcon();
182
		// placeCursor();
183
		updateIndent();
184

  
185
		enableFreeText();
186
	}
187

  
188
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/container/MisapplicationContainerE4.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.editor.name.e4.container;
11

  
12
import org.apache.commons.lang.StringUtils;
13
import org.eclipse.swt.graphics.Font;
14

  
15
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
16
import eu.etaxonomy.cdm.model.name.TaxonName;
17
import eu.etaxonomy.cdm.model.taxon.Taxon;
18
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
19
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
20
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
21
import eu.etaxonomy.taxeditor.editor.name.container.EditorAnnotation;
22
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
23
import eu.etaxonomy.taxeditor.model.AbstractUtility;
24
import eu.etaxonomy.taxeditor.model.NameHelper;
25
import eu.etaxonomy.taxeditor.preference.Resources;
26

  
27
/**
28
 *
29
 * @author pplitzner
30
 * @date Aug 24, 2017
31
 *
32
 */
33
public class MisapplicationContainerE4 extends AbstractGroupedContainerE4<Taxon> {
34
	TaxonRelationship misapplication;
35

  
36
	public MisapplicationContainerE4(AbstractGroupE4 group, Taxon misappliedName) {
37
		super(group, misappliedName);
38

  
39
	}
40

  
41
	/** {@inheritDoc} */
42
	@Override
43
	protected void initializeComposite() {
44
		setIsDraggable(true);
45
		setFont(getViewerFont());
46
		TaxonNameEditorE4 editor = getEditor();
47
		Taxon taxon = editor.getTaxon();
48
		for (TaxonRelationship rel: taxon.getTaxonRelations(getMisappliedName())){
49
			if (rel.getType().isAnyMisappliedName()){
50
				misapplication = rel;
51
				break;
52
			}
53
		}
54
		showSec();
55

  
56
		initTextViewer();
57
	}
58

  
59
	@Override
60
	protected void updateIcon() {
61
		setIcon(MISAPPLIEDNAME_ICON);
62
	}
63

  
64
	private void showSec() {
65
		if (getMisappliedName() == null) {
66
			return;
67
		}
68
		String title = "";
69
		String author = "";
70
		TaxonName misappliedNameName = HibernateProxyHelper.deproxy(getMisappliedName().getName());
71
		if (StringUtils.isNotBlank(misappliedNameName.getAuthorshipCache())){
72
			author = ", non " + misappliedNameName.getAuthorshipCache();
73
		}
74
		if (getMisappliedName().getSec() == null) {
75
		    if (getMisappliedName().getAppendedPhrase() != null ){
76
		        title = getMisappliedName().getAppendedPhrase();
77
		    }else{
78
		        title = "auct.";
79

  
80
		    }
81

  
82
		} else {
83
			String sec = " sensu ";
84
			if (getMisappliedName().getAppendedPhrase() != null ){
85
			    sec = getMisappliedName().getAppendedPhrase() + " " + sec;
86
			}
87

  
88
			title += sec + getMisappliedName().getSec().getCacheStrategy().getCitation(getMisappliedName().getSec());
89
		}
90
		if (misapplication.getType().equals(TaxonRelationshipType.PRO_PARTE_MISAPPLIED_NAME_FOR()) ){
91
		    title += " p.p. ";
92
        }
93
		title += author;
94
		title = title.replace("&", "&&");
95
		setNonEditableInfo(title, false);
96
	}
97

  
98
	public Taxon getMisappliedName() {
99
		return getTaxonBase();
100
	}
101

  
102
	/** {@inheritDoc} */
103
	@Override
104
	protected Font getViewerFont() {
105
		return AbstractUtility.getFont(Resources.MISAPPLIEDNAME_FONT);
106
	}
107

  
108
	@Override
109
	public void showAnnotations() {
110
		if(getData().getSec() == null){
111
			getNameViewer().addAnnotation(
112
					new EditorAnnotation(0, Messages.MisapplicationContainer_SEC_REF_REQUIRED));
113
		}
114
		super.showAnnotations();
115
	}
116

  
117

  
118
	/** {@inheritDoc} */
119
	@Override
120
	protected void updateNonEditableInfo() {
121
		showSec();
122
	}
123

  
124
	@Override
125
	protected void updateIndent() {
126
		setIndent(MISAPPLIEDNAME_INDENT);
127
	}
128

  
129
	@Override
130
	protected void initTextViewer() {
131

  
132
		// showNameRelations();
133

  
134
		updateIndent();
135

  
136
		updateIcon();
137

  
138
		String text = NameHelper.getDisplayNameCache(getData());
139

  
140
		if (text.length() == 0) {
141
			initEmptyText();
142
		} else {
143
			getNameViewer().setText(text);
144
			placeCursor();
145
		}
146
		calculateAnnotations();
147
	}
148

  
149
	@Override
150
    public void refresh() {
151
		// showNameRelations();
152

  
153
		String text = NameHelper.getDisplayNameCache(getData());
154

  
155
		if (getNameViewer().getTextWidget() == null) {
156
			// we might get here via dnd. Look slike it can be ignored
157
			return;
158
		}
159

  
160
		if (text.length() == 0) {
161
			initEmptyText();
162
		} else if (!getNameViewer().getTextWidget().getText().equals(text)) {
163
			removeListener();
164
			getNameViewer().getTextWidget().setText(text);
165
			addListener();
166
		}
167

  
168
		updateNonEditableInfo();
169

  
170
		updateIcon();
171
		// placeCursor();
172
		updateIndent();
173

  
174
		enableFreeText();
175
	}
176

  
177
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/container/MisappliedGroupE4.java
32 32
	@Override
33 33
	protected void createContainers() {
34 34
		for(Taxon misapplication : getEditor().getTaxon().getMisappliedNames(true)){
35
		    MisapplicationContainerE4 container = new MisapplicationContainerE4(this, misapplication);
35

  
36
		    ConceptContainerE4 container = new ConceptContainerE4(this, misapplication, true);
36 37
			this.add(container);
37 38
			container.createContent();
38 39
		}
40
		for(Taxon misapplication : getEditor().getTaxon().getProParteSynonyms()){
41
            ConceptContainerE4 container = new ConceptContainerE4(this, misapplication, false);
42
            this.add(container);
43
            container.createContent();
44
        }
39 45
	}
40 46

  
41 47
	@Override
......
47 53

  
48 54
	private boolean redrawNeeded() {
49 55
		Set<Taxon> misapplications = getEditor().getTaxon().getMisappliedNames(true);
56
		misapplications.addAll(getEditor().getTaxon().getProParteSynonyms());
50 57

  
51 58
		Set<Taxon> presentMisapplication = new HashSet<Taxon>();
52 59

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateProParteSynonymHandlerE4.java
1
/**
2
* Copyright (C) 2018 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
package eu.etaxonomy.taxeditor.editor.name.e4.handler;
10
import javax.inject.Named;
11

  
12
import org.eclipse.e4.core.di.annotations.CanExecute;
13
import org.eclipse.e4.core.di.annotations.Execute;
14
import org.eclipse.e4.ui.di.UISynchronize;
15
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
16
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
17
import org.eclipse.e4.ui.services.IServiceConstants;
18
import org.eclipse.jface.viewers.IStructuredSelection;
19

  
20
import eu.etaxonomy.cdm.model.name.TaxonName;
21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
23
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
24
import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester;
25
import eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation;
26
import eu.etaxonomy.taxeditor.model.AbstractUtility;
27
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
28
import eu.etaxonomy.taxeditor.parser.ParseHandler;
29

  
30
/**
31
 * @author k.luther
32
 * @since 15.05.2018
33
 *
34
 */
35
public class CreateProParteSynonymHandlerE4 {
36

  
37

  
38
        @Execute
39
        public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
40
                MHandledMenuItem menuItem,
41
                UISynchronize sync) {
42

  
43
            TaxonNameEditorE4 editor = (TaxonNameEditorE4) activePart.getObject();
44

  
45
            TaxonName conceptName = ParseHandler.createEmptyName();
46
            Taxon concept = Taxon.NewInstance(conceptName, null);
47

  
48
            TaxonRelationshipType type = TaxonRelationshipType.PRO_PARTE_SYNONYM_FOR();
49

  
50
            AbstractPostOperation<?> operation;
51
            operation = new CreateConceptRelationOperation(menuItem.getLocalizedLabel(),
52
                    editor.getUndoContext(), editor.getTaxon(), concept, type, editor);
53
            AbstractUtility.executeOperation(operation, sync);
54
        }
55

  
56

  
57
        @CanExecute
58
        public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
59
                MHandledMenuItem menuItem){
60
            boolean canExecute = false;
61
            Object selectedElement = selection.getFirstElement();
62
            canExecute = NameEditorMenuPropertyTester.isAccepted(selectedElement)
63
                    && !NameEditorMenuPropertyTester.isProParteSynonym(selectedElement);
64
            return canExecute;
65
        }
66

  
67

  
68
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/NameEditorMenuPropertyTester.java
190 190
	    }
191 191
	    return false;
192 192
	}
193

  
194
    /**
195
     * @param selectedElement
196
     * @return
197
     */
198
    public static boolean isProParteSynonym(Object selectedElement) {
199
        if(selectedElement instanceof Taxon && ((Taxon) selectedElement).isMisapplication()){
200
            return true;
201
        }
202
        return false;
203
    }
193 204
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptionElementDropAdapter.java
58 58
		Collection<DescriptionElementBase> descriptionElements = new ArrayList<DescriptionElementBase>();
59 59

  
60 60
		boolean isCopy = getCurrentOperation() == DND.DROP_COPY ? true : false;
61

  
61
		DescriptionBase<?> description = null;
62 62
		// cannot drop a feature node onto itself
63 63
		if (droppedElements != null){
64 64
			for (Object droppedElement : droppedElements) {
......
74 74
					if (descriptionElement.getInDescription().equals(target)) {
75 75
						return false;
76 76
					}
77
					DescriptionBase<?> description = descriptionElement.getInDescription();
77
					description = descriptionElement.getInDescription();
78 78
					description.removeElement(descriptionElement);
79 79
					target.addElement(descriptionElement);
80 80

  
......
87 87
			TaxonNameEditorE4 editor = null;
88 88
			Object activePart = EditorUtil.getActivePart();
89 89
			if (activePart instanceof FactualDataPartE4){
90
			    MPart selectionProvidingPart =(MPart) ((FactualDataPartE4)activePart).getSelectionProvidingPart();
90
			    MPart selectionProvidingPart =((FactualDataPartE4)activePart).getSelectionProvidingPart();
91 91
			    Object obj = selectionProvidingPart.getObject();
92 92
			    if (obj instanceof TaxonNameEditorE4){
93 93
			        editor = (TaxonNameEditorE4) obj;
94 94
			    }
95 95
			}
96
			AbstractPostTaxonOperation operation = new MoveDescriptionElementsOperation(Messages.DescriptionElementDropAdapter_MOVE_DESC, EditorUtil.getUndoContext(), target, descriptionElements, isCopy, null, sync);
96
			AbstractPostTaxonOperation operation = new MoveDescriptionElementsOperation(Messages.DescriptionElementDropAdapter_MOVE_DESC, EditorUtil.getUndoContext(), target, description, descriptionElements, isCopy, null, sync);
97 97

  
98 98
			editor.getEditorInput().addOperation(operation);
99 99
			editor.setDirty();
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/MoveDescriptionElementsOperation.java
38 38

  
39 39
	private Collection<DescriptionElementBase> descriptionElements;
40 40
	private DescriptionBase targetDescription;
41
	private DescriptionBase sourceDescription;
41 42
	private IDescriptionService service;
42 43
	private UUID targetTaxonUuid;
44

  
43 45
	private String moveMessage;
44 46
	private boolean isCopy;
45 47
	private UISynchronize sync;
......
54 56
	 * @param postOperationEnabled
55 57
	 */
56 58
	public MoveDescriptionElementsOperation(String label,
57
			IUndoContext undoContext, DescriptionBase targetDescription,
59
			IUndoContext undoContext, DescriptionBase targetDescription, DescriptionBase sourceDescription,
58 60
			Collection<DescriptionElementBase> descriptionElements, boolean isCopy,
59 61
			IPostOperationEnabled postOperationEnabled, UISynchronize sync) {
60 62
		super(label, undoContext, postOperationEnabled);
61 63
		this.targetDescription = targetDescription;
64
		this.sourceDescription = sourceDescription;
62 65
		this.descriptionElements = descriptionElements;
63 66
		this.isCopy = isCopy;
64 67
		this.sync = sync;
......
66 69
	}
67 70

  
68 71
	public MoveDescriptionElementsOperation(String label,
69
	        IUndoContext undoContext, UUID targetTaxonUuid,String moveMessage,
72
	        IUndoContext undoContext, UUID targetTaxonUuid, String moveMessage,
70 73
	        Collection<DescriptionElementBase> descriptionElements, boolean isCopy,
71 74
	        IPostOperationEnabled postOperationEnabled, UISynchronize sync) {
72 75
	    super(label, undoContext, postOperationEnabled);
......
95 98

  
96 99
		} else {
97 100
		    UUID targetDescriptionUuid = targetDescription.getUuid();
101
		    UUID sourceDescriptionUuid = sourceDescription.getUuid();
98 102
		    result = service.moveDescriptionElementsToDescription(descriptionElementsUuid, targetDescriptionUuid, isCopy);
99 103

  
100 104
		}

Also available in: Unified diff