Revision 5cfc8708
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.bulkeditor/fragment.e4xmi | ||
---|---|---|
53 | 53 |
<handlers xmi:id="_vskBsJcOEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.annotatedlineeditor.e4.handler.DeleteObjectHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.annotatedlineeditor.e4.handler.DeleteObjectHandlerE4" command="_tLGKgJcOEeeM745tzuPNCQ"/> |
54 | 54 |
<menus xsi:type="menu:PopupMenu" xmi:id="_B6IFsJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.popupmenu.bulkeditor"> |
55 | 55 |
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_H83EMJcMEeeM745tzuPNCQ" coreExpressionId="isCdmStoreConnected"/> |
56 |
<children xsi:type="menu:Menu" xmi:id="_QNTQYJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.menu.new" label="%menu.label.1"> |
|
57 |
<children xsi:type="menu:DynamicMenuContribution" xmi:id="_TbcAUJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.dynamicmenucontribution.new"/> |
|
58 |
</children> |
|
59 |
<children xsi:type="menu:DynamicMenuContribution" xmi:id="_1xx-YJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.dynamicmenucontribution.bulkEditor.openInCdmViewer" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.CdmViewerContextMenuE4"/> |
|
56 |
<children xsi:type="menu:DynamicMenuContribution" xmi:id="_Y49vAJfHEeeUB5KN7hGpYQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.e4.command.DynamicNewObjectMenuE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.bulkeditor.e4.command.DynamicNewObjectMenuE4"/> |
|
60 | 57 |
<children xsi:type="menu:MenuSeparator" xmi:id="_VhML4JcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.menuseparator.1"/> |
61 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_WOzf0JcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.setMergeTarget" label="%command.label.0"/> |
|
62 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_c0pycJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.setMergeCandidate" label="%command.label.1"/> |
|
63 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_gx65QJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.removemergecandidate" label="%command.label.2"/> |
|
64 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_i2FJYJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.mergegroup" label="%command.label.3"/> |
|
58 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_WOzf0JcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.setMergeTarget" label="%command.label.0" command="_GAm9cJcNEeeM745tzuPNCQ"/>
|
|
59 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_c0pycJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.setMergeCandidate" label="%command.label.1" command="_Kkf_YJcNEeeM745tzuPNCQ"/>
|
|
60 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_gx65QJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.removemergecandidate" label="%command.label.2" command="_MNLNYJcNEeeM745tzuPNCQ"/>
|
|
61 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_i2FJYJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.mergegroup" label="%command.label.3" command="_N1zYEJcNEeeM745tzuPNCQ"/>
|
|
65 | 62 |
<children xsi:type="menu:MenuSeparator" xmi:id="_lFRk0JcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.menuseparator.2"/> |
66 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_l6dgYJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.convertTeam2Person" label="%command.label.5"/> |
|
67 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_oKqBYJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.convertPerson2Team" label="%command.label.6"/> |
|
63 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_l6dgYJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.convertTeam2Person" label="%command.label.5" command="_PtZy4JcNEeeM745tzuPNCQ"/>
|
|
64 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_oKqBYJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.convertPerson2Team" label="%command.label.6" command="_RFEJYJcNEeeM745tzuPNCQ"/>
|
|
68 | 65 |
<children xsi:type="menu:MenuSeparator" xmi:id="_p-7bYJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.menuseparator.3"/> |
69 |
<children xsi:type="menu:Menu" xmi:id="_saDaAJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.menu.chooseMarkerType" label="%menu.label.2"> |
|
70 |
<children xsi:type="menu:DynamicMenuContribution" xmi:id="_u0_LYJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.dynamicmenucontribution.markerType"/> |
|
71 |
</children> |
|
66 |
<children xsi:type="menu:Menu" xmi:id="_saDaAJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.menu.chooseMarkerType" label="%menu.label.2"/> |
|
72 | 67 |
<children xsi:type="menu:MenuSeparator" xmi:id="_x3rgUJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.menuseparator.4"/> |
73 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_yt2TUJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.delete" label="%command.label.4"/> |
|
68 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_yt2TUJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.delete" label="%command.label.4" command="_S8xR4JcNEeeM745tzuPNCQ"/>
|
|
74 | 69 |
</menus> |
75 | 70 |
</elements> |
76 | 71 |
</fragments> |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/e4/handler/NewObjectHandlerE4.java | ||
---|---|---|
1 | 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 |
*/ |
|
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 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.annotatedlineeditor.e4.handler; |
11 | 11 |
|
12 |
import org.eclipse.core.commands.AbstractHandler; |
|
13 |
import org.eclipse.core.commands.ExecutionEvent; |
|
14 |
import org.eclipse.core.commands.ExecutionException; |
|
15 |
import org.eclipse.jface.dialogs.IInputValidator; |
|
16 |
import org.eclipse.jface.dialogs.InputDialog; |
|
17 |
import org.eclipse.jface.window.Window; |
|
18 |
import org.eclipse.swt.widgets.Event; |
|
19 |
import org.eclipse.ui.IEditorInput; |
|
20 |
import org.eclipse.ui.IEditorPart; |
|
21 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
12 |
import javax.inject.Named; |
|
13 |
|
|
14 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
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; |
|
22 | 18 |
|
23 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType; |
|
24 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.AnnotatedLineEditor; |
|
25 |
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.GroupCreator; |
|
26 |
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.UserCreator; |
|
19 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator; |
|
20 |
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants; |
|
21 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
|
27 | 22 |
|
28 | 23 |
/** |
29 |
* <p>NewObjectHandler class.</p> |
|
30 | 24 |
* |
31 |
* @author p.ciardelli
|
|
32 |
* @created 14.08.2009
|
|
33 |
* @version 1.0
|
|
25 |
* @author pplitzner
|
|
26 |
* @date 12.09.2017
|
|
27 |
* |
|
34 | 28 |
*/ |
35 |
public class NewObjectHandlerE4 extends AbstractHandler { |
|
36 |
|
|
37 |
/* (non-Javadoc) |
|
38 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
39 |
*/ |
|
40 |
/** {@inheritDoc} */ |
|
41 |
@Override |
|
42 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
29 |
public class NewObjectHandlerE4 { |
|
43 | 30 |
|
44 |
IEditorPart editor = HandlerUtil.getActiveEditor(event); |
|
45 |
IEditorInput input = editor.getEditorInput(); |
|
31 |
@Execute |
|
32 |
public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
33 |
MHandledMenuItem menuItem) { |
|
46 | 34 |
|
47 |
if (editor instanceof AnnotatedLineEditor) {
|
|
35 |
Object key = menuItem.getTransientData().get(IBulkEditorConstants.DYNAMIC_OPEN_OBJECT_ID+".key");
|
|
48 | 36 |
|
49 |
Object key = ((Event)event.getTrigger()).data; |
|
50 |
if (key != null) { |
|
51 |
if(!(key instanceof SpecimenOrObservationType)) { |
|
52 |
String text = ((Event)event.getTrigger()).text; |
|
37 |
BulkEditorE4 bulkEditor = (BulkEditorE4) activePart.getObject(); |
|
53 | 38 |
|
54 |
//FIXME : This should probably go into some ValidatorFactory |
|
55 |
IInputValidator nonEmptyInputValidator = null; |
|
56 |
//FIXME : This is a workaround to not allow empty strings in the |
|
57 |
// input dialog for User and Group entities. |
|
58 |
// Normally this should be default |
|
59 |
// behaviour, so we need to discuss whether this handler |
|
60 |
// should be used to handle the creating new entities of |
|
61 |
// type other than User and Group. |
|
62 |
// Once #4348 is fixed this check can be removed. |
|
63 |
if(text.equals(UserCreator.USER) || text.equals(GroupCreator.GROUP)) { |
|
64 |
nonEmptyInputValidator = new IInputValidator() { |
|
65 |
@Override |
|
66 |
public String isValid(String text) { |
|
67 |
if(text == null || text.isEmpty()) { |
|
68 |
return "Input cannot be empty"; |
|
69 |
} |
|
70 |
return null; |
|
71 |
} |
|
72 |
}; |
|
73 |
} |
|
74 |
InputDialog dialog = new InputDialog(HandlerUtil.getActiveShell(event), |
|
75 |
String.format("Create %s", text), String.format("Enter new %s", text), "", |
|
76 |
nonEmptyInputValidator); |
|
77 | 39 |
|
78 |
if (dialog.open() != Window.CANCEL) {
|
|
79 |
((AnnotatedLineEditor) editor).createAnnotatedLineNewObject(key, dialog.getValue());
|
|
80 |
}
|
|
81 |
} else {
|
|
82 |
((AnnotatedLineEditor) editor).createAnnotatedLineNewObject(key, "Untitled");
|
|
83 |
}
|
|
40 |
if (key != null) {
|
|
41 |
IEntityCreator entityCreator = bulkEditor.getEditorInput().getEntityCreator();
|
|
42 |
String text = menuItem.getCommand().getCommandName();
|
|
43 |
Object createdEntity = entityCreator.createEntity(text);
|
|
44 |
bulkEditor.getEditorInput().getModel().add(createdEntity);
|
|
45 |
bulkEditor.refresh();
|
|
84 | 46 |
|
85 |
} else { |
|
86 |
((AnnotatedLineEditor) editor).createAnnotatedLineNewObject(); |
|
87 |
} |
|
88 |
} |
|
89 |
return null; |
|
90 |
} |
|
47 |
// if(!(key instanceof SpecimenOrObservationType)) { |
|
48 |
// |
|
49 |
// //FIXME : This should probably go into some ValidatorFactory |
|
50 |
// IInputValidator nonEmptyInputValidator = null; |
|
51 |
// //FIXME : This is a workaround to not allow empty strings in the |
|
52 |
// // input dialog for User and Group entities. |
|
53 |
// // Normally this should be default |
|
54 |
// // behaviour, so we need to discuss whether this handler |
|
55 |
// // should be used to handle the creating new entities of |
|
56 |
// // type other than User and Group. |
|
57 |
// // Once #4348 is fixed this check can be removed. |
|
58 |
// if(text.equals(UserCreator.USER) || text.equals(GroupCreator.GROUP)) { |
|
59 |
// nonEmptyInputValidator = new IInputValidator() { |
|
60 |
// @Override |
|
61 |
// public String isValid(String text) { |
|
62 |
// if(text == null || text.isEmpty()) { |
|
63 |
// return "Input cannot be empty"; |
|
64 |
// } |
|
65 |
// return null; |
|
66 |
// } |
|
67 |
// }; |
|
68 |
// } |
|
69 |
// InputDialog dialog = new InputDialog(shell, |
|
70 |
// String.format("Create %s", text), String.format("Enter new %s", text), "", |
|
71 |
// nonEmptyInputValidator); |
|
72 |
// |
|
73 |
// if (dialog.open() != Window.CANCEL) { |
|
74 |
// ((AnnotatedLineEditor) editor).createAnnotatedLineNewObject(key, dialog.getValue()); |
|
75 |
// } |
|
76 |
// } else { |
|
77 |
// ((AnnotatedLineEditor) editor).createAnnotatedLineNewObject(key, "Untitled"); |
|
78 |
// } |
|
79 |
// |
|
80 |
// } else { |
|
81 |
// ((AnnotatedLineEditor) editor).createAnnotatedLineNewObject(); |
|
82 |
// } |
|
83 |
} |
|
84 |
} |
|
91 | 85 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/AnnotatedTableItem.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2017 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.taxeditor.bulkeditor.e4; |
|
11 |
|
|
12 |
import eu.etaxonomy.cdm.model.common.ICdmBase; |
|
13 |
|
|
14 |
/** |
|
15 |
* @author pplitzner |
|
16 |
* @date 12.09.2017 |
|
17 |
* |
|
18 |
*/ |
|
19 |
public class AnnotatedTableItem <T extends ICdmBase> { |
|
20 |
|
|
21 |
private T element; |
|
22 |
private boolean isMergeCandidate = false; |
|
23 |
private boolean isMergeTarget = false; |
|
24 |
|
|
25 |
public AnnotatedTableItem(T element) { |
|
26 |
super(); |
|
27 |
this.element = element; |
|
28 |
} |
|
29 |
|
|
30 |
public T getElement() { |
|
31 |
return element; |
|
32 |
} |
|
33 |
|
|
34 |
public void setMergeCandidate(boolean isMergeCandidate) { |
|
35 |
this.isMergeCandidate = isMergeCandidate; |
|
36 |
} |
|
37 |
|
|
38 |
public void setMergeTarget(boolean isMergeTarget) { |
|
39 |
this.isMergeTarget = isMergeTarget; |
|
40 |
} |
|
41 |
|
|
42 |
public boolean isMergeCandidate() { |
|
43 |
return isMergeCandidate; |
|
44 |
} |
|
45 |
|
|
46 |
public boolean isMergeTarget() { |
|
47 |
return isMergeTarget; |
|
48 |
} |
|
49 |
|
|
50 |
@Override |
|
51 |
public String toString() { |
|
52 |
return element.toString(); |
|
53 |
} |
|
54 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.bulkeditor.e4; |
11 | 11 |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.List; |
|
14 |
|
|
12 | 15 |
import javax.annotation.PostConstruct; |
13 | 16 |
import javax.inject.Inject; |
14 | 17 |
|
... | ... | |
19 | 22 |
import org.eclipse.jface.dialogs.MessageDialog; |
20 | 23 |
import org.eclipse.jface.viewers.ArrayContentProvider; |
21 | 24 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
22 |
import org.eclipse.jface.viewers.LabelProvider; |
|
23 | 25 |
import org.eclipse.jface.viewers.TableViewer; |
24 | 26 |
import org.eclipse.swt.SWT; |
25 | 27 |
import org.eclipse.swt.layout.FillLayout; |
... | ... | |
108 | 110 |
bottomComposite.setLayout(new FillLayout()); |
109 | 111 |
viewer = new TableViewer(bottomComposite); |
110 | 112 |
viewer.setContentProvider(new ArrayContentProvider()); |
111 |
viewer.setLabelProvider(new LabelProvider()); |
|
113 |
viewer.setLabelProvider(new BulkEditorLabelProvider());
|
|
112 | 114 |
|
113 | 115 |
|
114 | 116 |
//propagate selection |
... | ... | |
146 | 148 |
|
147 | 149 |
getEditorInput().performSearch(query); |
148 | 150 |
|
151 |
viewer.setInput(getEditorInput().getWrappedModel()); |
|
149 | 152 |
refresh(); |
150 | 153 |
} |
151 | 154 |
} |
152 | 155 |
|
153 | 156 |
public void refresh() { |
154 |
viewer.setInput(getEditorInput().getModel()); |
|
155 | 157 |
viewer.refresh(); |
156 | 158 |
} |
157 | 159 |
|
... | ... | |
163 | 165 |
return input; |
164 | 166 |
} |
165 | 167 |
|
168 |
public List<AnnotatedTableItem> getMergeCandidates(){ |
|
169 |
List<AnnotatedTableItem> mergeCandidates = new ArrayList<>(); |
|
170 |
for(AnnotatedTableItem item: (List<AnnotatedTableItem>)viewer.getInput()){ |
|
171 |
if(item.isMergeCandidate()){ |
|
172 |
mergeCandidates.add(item); |
|
173 |
} |
|
174 |
} |
|
175 |
return mergeCandidates; |
|
176 |
} |
|
177 |
|
|
178 |
public AnnotatedTableItem getMergeTarget(){ |
|
179 |
for(AnnotatedTableItem item: (List<AnnotatedTableItem>)viewer.getInput()){ |
|
180 |
if(item.isMergeTarget()){ |
|
181 |
return item; |
|
182 |
} |
|
183 |
} |
|
184 |
return null; |
|
185 |
} |
|
186 |
|
|
187 |
public void removeAllAnnotations(){ |
|
188 |
for(AnnotatedTableItem item: (List<AnnotatedTableItem>)viewer.getInput()){ |
|
189 |
item.setMergeCandidate(false); |
|
190 |
item.setMergeTarget(false); |
|
191 |
} |
|
192 |
} |
|
193 |
|
|
166 | 194 |
/** |
167 | 195 |
* {@inheritDoc} |
168 | 196 |
*/ |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorLabelProvider.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2017 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.taxeditor.bulkeditor.e4; |
|
11 |
|
|
12 |
import java.net.URISyntaxException; |
|
13 |
import java.net.URL; |
|
14 |
|
|
15 |
import org.eclipse.core.runtime.FileLocator; |
|
16 |
import org.eclipse.core.runtime.IPath; |
|
17 |
import org.eclipse.core.runtime.Path; |
|
18 |
import org.eclipse.jface.viewers.LabelProvider; |
|
19 |
import org.eclipse.swt.graphics.Image; |
|
20 |
|
|
21 |
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin; |
|
22 |
import eu.etaxonomy.taxeditor.model.ImageResources; |
|
23 |
|
|
24 |
/** |
|
25 |
* @author pplitzner |
|
26 |
* @date 11.09.2017 |
|
27 |
* |
|
28 |
*/ |
|
29 |
public class BulkEditorLabelProvider extends LabelProvider { |
|
30 |
|
|
31 |
/** |
|
32 |
* {@inheritDoc} |
|
33 |
*/ |
|
34 |
@Override |
|
35 |
public Image getImage(Object element) { |
|
36 |
AnnotatedTableItem item = (AnnotatedTableItem)element; |
|
37 |
try { |
|
38 |
if(item.isMergeCandidate()){ |
|
39 |
IPath path = new Path("icons/merge_candidate.gif"); //$NON-NLS-1$ |
|
40 |
URL url = FileLocator.find(TaxeditorBulkeditorPlugin.getDefault().getBundle(), path, null); |
|
41 |
return ImageResources.getImage(url.toURI()); |
|
42 |
} |
|
43 |
else if(item.isMergeTarget()){ |
|
44 |
IPath path = new Path("icons/merge_target.gif"); //$NON-NLS-1$ |
|
45 |
URL url = FileLocator.find(TaxeditorBulkeditorPlugin.getDefault().getBundle(), path, null); |
|
46 |
return ImageResources.getImage(url.toURI()); |
|
47 |
} |
|
48 |
} catch (URISyntaxException e) { |
|
49 |
return null; |
|
50 |
} |
|
51 |
return null; |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* {@inheritDoc} |
|
56 |
*/ |
|
57 |
@Override |
|
58 |
public String getText(Object element) { |
|
59 |
return super.getText(element); |
|
60 |
} |
|
61 |
|
|
62 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/command/DynamicNewObjectMenuE4.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.bulkeditor.e4.command; |
|
11 |
|
|
12 |
import java.util.Collections; |
|
13 |
import java.util.List; |
|
14 |
import java.util.Map; |
|
15 |
|
|
16 |
import javax.inject.Named; |
|
17 |
|
|
18 |
import org.eclipse.e4.ui.di.AboutToShow; |
|
19 |
import org.eclipse.e4.ui.model.application.commands.MCommand; |
|
20 |
import org.eclipse.e4.ui.model.application.commands.MCommandsFactory; |
|
21 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
22 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
23 |
import org.eclipse.e4.ui.model.application.ui.menu.MMenu; |
|
24 |
import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement; |
|
25 |
import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory; |
|
26 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
27 |
import org.eclipse.ui.IEditorInput; |
|
28 |
|
|
29 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator; |
|
30 |
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants; |
|
31 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
|
32 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
|
33 |
|
|
34 |
/** |
|
35 |
* |
|
36 |
* @author pplitzner |
|
37 |
* @date 12.09.2017 |
|
38 |
* |
|
39 |
*/ |
|
40 |
public class DynamicNewObjectMenuE4 { |
|
41 |
|
|
42 |
private Map<? extends Object, String> classLabelPairs; |
|
43 |
private BulkEditorE4 editor; |
|
44 |
|
|
45 |
/** {@inheritDoc} */ |
|
46 |
@AboutToShow |
|
47 |
public void aboutToShow(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
48 |
List<MMenuElement> items) { |
|
49 |
|
|
50 |
editor = (BulkEditorE4) activePart.getObject(); |
|
51 |
|
|
52 |
classLabelPairs = getClassLabelPairs(); |
|
53 |
|
|
54 |
MMenu menu = MMenuFactory.INSTANCE.createMenu(); |
|
55 |
menu.setLabel("New"); |
|
56 |
items.add(menu); |
|
57 |
|
|
58 |
for(final Object key : classLabelPairs.keySet()){ |
|
59 |
createMenuItem(menu, key); |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
private void createMenuItem(MMenu menu, final Object key){ |
|
64 |
MHandledMenuItem menuItem = MMenuFactory.INSTANCE.createHandledMenuItem(); |
|
65 |
menuItem.setLabel(classLabelPairs.get(key)); |
|
66 |
MCommand mCommand = MCommandsFactory.INSTANCE.createCommand(); |
|
67 |
mCommand.setElementId(IBulkEditorConstants.DYNAMIC_OPEN_OBJECT_ID); |
|
68 |
mCommand.setCommandName(classLabelPairs.get(key)); |
|
69 |
//set params |
|
70 |
menuItem.getTransientData().put(IBulkEditorConstants.DYNAMIC_OPEN_OBJECT_ID+".key", key); |
|
71 |
|
|
72 |
menuItem.setCommand(mCommand); |
|
73 |
menu.getChildren().add(menuItem); |
|
74 |
|
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* Get class label pairs from Annotated Line Editor's entity creator. |
|
79 |
* @return |
|
80 |
*/ |
|
81 |
private Map<? extends Object, String> getClassLabelPairs() { |
|
82 |
if (editor != null){ |
|
83 |
IEditorInput input = editor.getEditorInput(); |
|
84 |
|
|
85 |
if(input instanceof AbstractBulkEditorInput){ |
|
86 |
IEntityCreator<?> entityCreator = ((AbstractBulkEditorInput) input).getEntityCreator(); |
|
87 |
if(entityCreator!=null){ |
|
88 |
return entityCreator.getKeyLabelPairs(); |
|
89 |
} |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
93 |
return Collections.EMPTY_MAP; |
|
94 |
} |
|
95 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/ConvertPerson2TeamHandlerE4.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import javax.inject.Named; |
12 | 12 |
|
13 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
|
13 | 14 |
import org.eclipse.e4.core.di.annotations.Execute; |
14 | 15 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
16 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
15 | 17 |
import org.eclipse.e4.ui.services.IServiceConstants; |
16 | 18 |
import org.eclipse.jface.dialogs.MessageDialog; |
17 | 19 |
|
... | ... | |
20 | 22 |
import eu.etaxonomy.cdm.model.agent.Person; |
21 | 23 |
import eu.etaxonomy.cdm.model.agent.Team; |
22 | 24 |
import eu.etaxonomy.cdm.strategy.merge.MergeException; |
25 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.AnnotatedTableItem; |
|
23 | 26 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
24 | 27 |
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin; |
25 | 28 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
... | ... | |
34 | 37 |
|
35 | 38 |
|
36 | 39 |
@Execute |
37 |
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)Person person,
|
|
40 |
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)AnnotatedTableItem item,
|
|
38 | 41 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart) { |
39 | 42 |
|
40 | 43 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
... | ... | |
52 | 55 |
Team team =null; |
53 | 56 |
UpdateResult result = null; |
54 | 57 |
try { |
55 |
result = CdmStore.getService(IAgentService.class).convertPerson2Team(person.getUuid());
|
|
58 |
result = CdmStore.getService(IAgentService.class).convertPerson2Team(item.getElement().getUuid());
|
|
56 | 59 |
} catch (IllegalArgumentException e) { |
57 | 60 |
MessagingUtils.errorDialog("Can not convert Person into a Team", null, e.getLocalizedMessage(), TaxeditorBulkeditorPlugin.PLUGIN_ID,e, true); |
58 | 61 |
} catch (MergeException e) { |
... | ... | |
66 | 69 |
} |
67 | 70 |
} |
68 | 71 |
|
72 |
@CanExecute |
|
73 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)AnnotatedTableItem selection, |
|
74 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
75 |
MHandledMenuItem menuItem){ |
|
76 |
boolean canExecute = false; |
|
77 |
canExecute = ((BulkEditorE4)activePart.getObject()).getEditorInput().isConvertingEnabled() && selection.getElement() instanceof Person; |
|
78 |
menuItem.setVisible(canExecute); |
|
79 |
return canExecute; |
|
80 |
} |
|
81 |
|
|
69 | 82 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/ConvertTeam2PersonHandlerE4.java | ||
---|---|---|
22 | 22 |
import eu.etaxonomy.cdm.model.agent.Person; |
23 | 23 |
import eu.etaxonomy.cdm.model.agent.Team; |
24 | 24 |
import eu.etaxonomy.cdm.strategy.merge.MergeException; |
25 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.AnnotatedTableItem; |
|
25 | 26 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
26 | 27 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
27 | 28 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
... | ... | |
34 | 35 |
public class ConvertTeam2PersonHandlerE4 { |
35 | 36 |
|
36 | 37 |
@Execute |
37 |
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)Team team,
|
|
38 |
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)AnnotatedTableItem item,
|
|
38 | 39 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart) { |
39 | 40 |
|
40 | 41 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
... | ... | |
53 | 54 |
UpdateResult result = null; |
54 | 55 |
|
55 | 56 |
try { |
56 |
result = CdmStore.getService(IAgentService.class).convertTeam2Person(team.getUuid());
|
|
57 |
result = CdmStore.getService(IAgentService.class).convertTeam2Person(item.getElement().getUuid());
|
|
57 | 58 |
} catch (IllegalArgumentException e) { |
58 | 59 |
MessagingUtils.informationDialog("Can not convert Team to Person", e.getMessage()); |
59 | 60 |
} catch (MergeException e) { |
... | ... | |
68 | 69 |
} |
69 | 70 |
|
70 | 71 |
@CanExecute |
71 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
|
|
72 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)AnnotatedTableItem selection,
|
|
72 | 73 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
73 | 74 |
MHandledMenuItem menuItem){ |
74 | 75 |
boolean canExecute = false; |
75 |
canExecute = ((BulkEditorE4)activePart.getObject()).getEditorInput().isConvertingEnabled() && selection instanceof Team; |
|
76 |
canExecute = ((BulkEditorE4)activePart.getObject()).getEditorInput().isConvertingEnabled() && selection.getElement() instanceof Team;
|
|
76 | 77 |
menuItem.setVisible(canExecute); |
77 | 78 |
return canExecute; |
78 | 79 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/DeleteHandlerE4.java | ||
---|---|---|
18 | 18 |
import org.eclipse.core.runtime.IStatus; |
19 | 19 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
20 | 20 |
import org.eclipse.e4.core.di.annotations.Execute; |
21 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
22 | 21 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
23 | 22 |
import org.eclipse.e4.ui.services.IServiceConstants; |
24 | 23 |
import org.eclipse.jface.dialogs.MessageDialog; |
... | ... | |
82 | 81 |
|
83 | 82 |
@Execute |
84 | 83 |
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)Object object, |
85 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
86 | 84 |
@Named(IServiceConstants.ACTIVE_SHELL)Shell shell) { |
87 | 85 |
|
88 | 86 |
DeleteConfiguratorBase config = null; |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/MergeGroupHandlerE4.java | ||
---|---|---|
1 | 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 |
*/ |
|
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 | 9 |
package eu.etaxonomy.taxeditor.bulkeditor.e4.handler; |
10 | 10 |
|
11 |
import java.util.List; |
|
12 |
|
|
11 | 13 |
import javax.inject.Named; |
12 | 14 |
|
13 | 15 |
import org.apache.log4j.Logger; |
14 | 16 |
import org.eclipse.e4.core.di.annotations.Execute; |
15 | 17 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
16 | 18 |
import org.eclipse.e4.ui.services.IServiceConstants; |
19 |
import org.eclipse.jface.dialogs.MessageDialog; |
|
17 | 20 |
import org.eclipse.swt.widgets.Shell; |
18 | 21 |
|
22 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
23 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
|
24 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
25 |
import eu.etaxonomy.cdm.strategy.merge.MergeException; |
|
26 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.AnnotatedTableItem; |
|
27 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
|
28 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
29 |
|
|
19 | 30 |
/** |
20 | 31 |
* |
21 | 32 |
* @author pplitzner |
... | ... | |
23 | 34 |
* |
24 | 35 |
*/ |
25 | 36 |
public class MergeGroupHandlerE4 { |
26 |
private static final Logger logger = Logger
|
|
27 |
.getLogger(MergeGroupHandlerE4.class);
|
|
37 |
private static final Logger logger = Logger
|
|
38 |
.getLogger(MergeGroupHandlerE4.class);
|
|
28 | 39 |
|
29 | 40 |
@Execute |
30 | 41 |
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)Object object, |
31 | 42 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
32 | 43 |
@Named(IServiceConstants.ACTIVE_SHELL)Shell shell) { |
33 | 44 |
|
34 |
//FIXME E4 migrate merge handler |
|
35 |
// BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
|
36 |
// |
|
37 |
// IDocumentProvider provider = ((BulkEditor) editor).getDocumentProvider(); |
|
38 |
// LineAnnotationModel model = |
|
39 |
// (LineAnnotationModel) provider.getAnnotationModel(input); |
|
40 |
// |
|
41 |
// // Check whether there are any group annotations |
|
42 |
// Set<LineAnnotation> candidateAnnotations = model.getAllAnnotationsOfType(IBulkEditorConstants.TYPE_MERGE_CANDIDATE); |
|
43 |
// if (candidateAnnotations.size() == 0) { |
|
44 |
// MessageDialog.openWarning(HandlerUtil.getActiveShell(event), |
|
45 |
// "No merge candidates", "No objects have been chosen for merging."); |
|
46 |
// return null; |
|
47 |
// } |
|
48 |
// |
|
49 |
// // Check whether group merge target has been set |
|
50 |
// Annotation targetAnnotation = model.getFirstAnnotationOfType(IBulkEditorConstants.TYPE_MERGE_TARGET); |
|
51 |
// if (targetAnnotation == null) { |
|
52 |
// MessageDialog.openWarning(HandlerUtil.getActiveShell(event), |
|
53 |
// "No group merge target set", "No group merge target has been set."); |
|
54 |
// return null; |
|
55 |
// } |
|
56 |
// Object targetEntity = ((IEntityContainer<?>) targetAnnotation).getEntity(); |
|
57 |
// |
|
58 |
// TeamOrPersonBase teamOrPerson = null; |
|
59 |
// Reference ref = null; |
|
60 |
// if (targetEntity instanceof TeamOrPersonBase){ |
|
61 |
// teamOrPerson = HibernateProxyHelper.deproxy(targetEntity, TeamOrPersonBase.class); |
|
62 |
// } else if(targetEntity instanceof Reference){ |
|
63 |
// ref = HibernateProxyHelper.deproxy(targetEntity, Reference.class); |
|
64 |
// } |
|
65 |
// logger.info("Merging group"); |
|
66 |
//// model.printAnnotations(); |
|
67 |
// for (LineAnnotation annotation : candidateAnnotations) { |
|
68 |
// //first check whether entities are mergeable |
|
69 |
// |
|
70 |
// |
|
71 |
// try{ |
|
72 |
// if (ref != null){ |
|
73 |
// Reference ref2 = HibernateProxyHelper.deproxy(annotation.getEntity(), Reference.class); |
|
74 |
// |
|
75 |
// if (!CdmStore.getCommonService().isMergeable(ref, ref2, null)){ |
|
76 |
// MessageDialog.openWarning(HandlerUtil.getActiveShell(event), |
|
77 |
// "No merge possible", "A merge of " + ref.getTitleCache() + " and " + ref2.getTitleCache() + " is not possible."); |
|
78 |
// return null; |
|
79 |
// } |
|
80 |
// } |
|
81 |
// if (teamOrPerson != null){ |
|
82 |
// TeamOrPersonBase teamOrPerson2 = HibernateProxyHelper.deproxy(annotation.getEntity(), TeamOrPersonBase.class); |
|
83 |
// |
|
84 |
// if (!CdmStore.getCommonService().isMergeable(teamOrPerson, teamOrPerson2, null)){ |
|
85 |
// MessageDialog.openWarning(HandlerUtil.getActiveShell(event), |
|
86 |
// "No merge possible", "A merge of " + teamOrPerson.getTitleCache() + " and " + teamOrPerson2.getTitleCache() + " is not possible."); |
|
87 |
// return null; |
|
88 |
// } |
|
89 |
// } |
|
90 |
// }catch(MergeException e){ |
|
91 |
// |
|
92 |
// } |
|
93 |
// ((BulkEditor) editor).removeAnnotatedLine(annotation); |
|
94 |
// |
|
95 |
// // Mark entity container for merging with target entity |
|
96 |
// ((IEntityContainer) annotation).markAsMerged(targetEntity); |
|
97 |
// logger.info("Merging " + annotation + " with " + targetAnnotation); |
|
98 |
// |
|
99 |
// // Remove annotation from model |
|
100 |
// model.removeAnnotation(annotation); |
|
101 |
// } |
|
102 |
// |
|
103 |
// model.removeTypeFromAllAnnotations(IBulkEditorConstants.TYPE_MERGE_CANDIDATE); |
|
104 |
// model.removeTypeFromAllAnnotations(IBulkEditorConstants.TYPE_MERGE_TARGET); |
|
105 |
} |
|
45 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
|
46 |
|
|
47 |
// Check whether there are any group annotations |
|
48 |
List<AnnotatedTableItem> mergeCandidates = editor.getMergeCandidates(); |
|
49 |
if (mergeCandidates.size() == 0) { |
|
50 |
MessageDialog.openWarning(shell, |
|
51 |
"No merge candidates", "No objects have been chosen for merging."); |
|
52 |
return; |
|
53 |
} |
|
54 |
|
|
55 |
// Check whether group merge target has been set |
|
56 |
AnnotatedTableItem mergeTarget = editor.getMergeTarget(); |
|
57 |
if (mergeTarget == null) { |
|
58 |
MessageDialog.openWarning(shell, |
|
59 |
"No group merge target set", "No group merge target has been set."); |
|
60 |
return; |
|
61 |
} |
|
62 |
Object targetEntity = mergeTarget.getElement(); |
|
63 |
|
|
64 |
TeamOrPersonBase teamOrPerson = null; |
|
65 |
Reference ref = null; |
|
66 |
if (targetEntity instanceof TeamOrPersonBase){ |
|
67 |
teamOrPerson = HibernateProxyHelper.deproxy(targetEntity, TeamOrPersonBase.class); |
|
68 |
} else if(targetEntity instanceof Reference){ |
|
69 |
ref = HibernateProxyHelper.deproxy(targetEntity, Reference.class); |
|
70 |
} |
|
71 |
for (AnnotatedTableItem item : mergeCandidates) { |
|
72 |
//first check whether entities are mergeable |
|
73 |
try{ |
|
74 |
if (ref != null){ |
|
75 |
Reference ref2 = HibernateProxyHelper.deproxy(item.getElement(), Reference.class); |
|
76 |
|
|
77 |
if (!CdmStore.getCommonService().isMergeable(ref, ref2, null)){ |
|
78 |
MessageDialog.openWarning(shell, |
|
79 |
"No merge possible", "A merge of " + ref.getTitleCache() + " and " + ref2.getTitleCache() + " is not possible."); |
|
80 |
return; |
|
81 |
} |
|
82 |
} |
|
83 |
if (teamOrPerson != null){ |
|
84 |
TeamOrPersonBase teamOrPerson2 = HibernateProxyHelper.deproxy(item.getElement(), TeamOrPersonBase.class); |
|
85 |
|
|
86 |
if (!CdmStore.getCommonService().isMergeable(teamOrPerson, teamOrPerson2, null)){ |
|
87 |
MessageDialog.openWarning(shell, |
|
88 |
"No merge possible", "A merge of " + teamOrPerson.getTitleCache() + " and " + teamOrPerson2.getTitleCache() + " is not possible."); |
|
89 |
return; |
|
90 |
} |
|
91 |
} |
|
92 |
}catch(MergeException e){ |
|
93 |
|
|
94 |
} |
|
95 |
editor.removeAllAnnotations(); |
|
96 |
editor.refresh(); |
|
97 |
// ((BulkEditor) editor).removeAnnotatedLine(item); |
|
98 |
// |
|
99 |
// // Mark entity container for merging with target entity |
|
100 |
// ((IEntityContainer) item).markAsMerged(targetEntity); |
|
101 |
// logger.info("Merging " + item + " with " + targetAnnotation); |
|
102 |
// |
|
103 |
// // Remove annotation from model |
|
104 |
// model.removeAnnotation(item); |
|
105 |
// } |
|
106 |
// |
|
107 |
// model.removeTypeFromAllAnnotations(IBulkEditorConstants.TYPE_MERGE_CANDIDATE); |
|
108 |
// model.removeTypeFromAllAnnotations(IBulkEditorConstants.TYPE_MERGE_TARGET); |
|
109 |
} |
|
110 |
} |
|
106 | 111 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/RemoveMergeCandidateHandlerE4.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.bulkeditor.e4.handler; |
10 | 10 |
|
11 |
import java.util.Iterator;
|
|
11 |
import javax.inject.Named;
|
|
12 | 12 |
|
13 |
import org.eclipse.core.commands.AbstractHandler; |
|
14 |
import org.eclipse.core.commands.ExecutionEvent; |
|
15 |
import org.eclipse.core.commands.ExecutionException; |
|
16 |
import org.eclipse.jface.text.TextSelection; |
|
17 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
13 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
14 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
15 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
18 | 16 |
|
19 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation; |
|
20 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel; |
|
21 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor; |
|
17 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.AnnotatedTableItem; |
|
18 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
|
22 | 19 |
|
23 | 20 |
/** |
24 |
* <p>RemoveMergeCandidateHandler class.</p> |
|
25 | 21 |
* |
26 |
* @author p.ciardelli
|
|
27 |
* @created 25.06.2009
|
|
28 |
* @version 1.0
|
|
22 |
* @author pplitzner
|
|
23 |
* @date 12.09.2017
|
|
24 |
* |
|
29 | 25 |
*/ |
30 |
public class RemoveMergeCandidateHandlerE4 extends AbstractHandler { |
|
26 |
public class RemoveMergeCandidateHandlerE4 { |
|
27 |
|
|
31 | 28 |
|
32 |
/* (non-Javadoc) |
|
33 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
34 |
*/ |
|
35 |
/** {@inheritDoc} */ |
|
36 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
37 |
|
|
38 |
if (HandlerUtil.getCurrentSelection(event) instanceof TextSelection |
|
39 |
&& HandlerUtil.getActiveEditor(event) instanceof BulkEditor) { |
|
40 |
TextSelection selection = (TextSelection) HandlerUtil.getCurrentSelection(event); |
|
41 |
BulkEditor editor = (BulkEditor) HandlerUtil.getActiveEditor(event); |
|
42 |
|
|
43 |
LineAnnotationModel model = (LineAnnotationModel) editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); |
|
44 |
if (model != null) { |
|
45 |
Iterator iter = model.getAnnotationIterator(selection.getOffset(), selection.getLength(), true, true); |
|
46 |
while (iter.hasNext()) { |
|
47 |
Object next = iter.next(); |
|
48 |
if (next instanceof LineAnnotation) { |
|
49 |
model.changeAnnotationType( |
|
50 |
(LineAnnotation) next, LineAnnotation.TYPE_GENERIC); |
|
51 |
} |
|
52 |
} |
|
53 |
} |
|
54 |
} |
|
55 |
return null; |
|
56 |
} |
|
29 |
@Execute |
|
30 |
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)AnnotatedTableItem item, |
|
31 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart) { |
|
32 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
|
33 |
item.setMergeCandidate(false); |
|
34 |
editor.refresh(); |
|
35 |
} |
|
57 | 36 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/SetMergeCandidateHandlerE4.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.bulkeditor.e4.handler; |
10 | 10 |
|
11 |
import java.util.Iterator;
|
|
11 |
import javax.inject.Named;
|
|
12 | 12 |
|
13 |
import org.eclipse.core.commands.AbstractHandler; |
|
14 |
import org.eclipse.core.commands.ExecutionEvent; |
|
15 |
import org.eclipse.core.commands.ExecutionException; |
|
16 |
import org.eclipse.jface.text.TextSelection; |
|
17 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
13 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
14 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
15 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
18 | 16 |
|
19 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation; |
|
20 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel; |
|
21 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor; |
|
22 |
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants; |
|
23 |
import eu.etaxonomy.taxeditor.model.LineSelection; |
|
17 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.AnnotatedTableItem; |
|
18 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
|
24 | 19 |
|
25 | 20 |
/** |
26 |
* <p>SetMergeCandidateHandler class.</p> |
|
27 | 21 |
* |
28 |
* @author p.ciardelli
|
|
29 |
* @created 25.06.2009
|
|
30 |
* @version 1.0
|
|
22 |
* @author pplitzner
|
|
23 |
* @date 12.09.2017
|
|
24 |
* |
|
31 | 25 |
*/ |
32 |
public class SetMergeCandidateHandlerE4 extends AbstractHandler {
|
|
26 |
public class SetMergeCandidateHandlerE4 { |
|
33 | 27 |
|
34 |
/* (non-Javadoc) |
|
35 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
36 |
*/ |
|
37 |
/** {@inheritDoc} */ |
|
38 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
39 |
|
|
40 |
if (HandlerUtil.getCurrentSelection(event) instanceof TextSelection |
|
41 |
&& HandlerUtil.getActiveEditor(event) instanceof BulkEditor) { |
|
42 |
TextSelection selection = (TextSelection) HandlerUtil.getCurrentSelection(event); |
|
43 |
BulkEditor editor = (BulkEditor) HandlerUtil.getActiveEditor(event); |
|
44 |
|
|
45 |
LineAnnotationModel model = (LineAnnotationModel) editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); |
|
46 |
if (model != null) { |
|
47 |
Iterator iter = model.getAnnotationIterator(selection.getOffset(), selection.getLength(), true, true); |
|
48 |
while (iter.hasNext()) { |
|
49 |
Object next = iter.next(); |
|
50 |
if (next instanceof LineAnnotation) { |
|
51 |
model.changeAnnotationType( |
|
52 |
(LineAnnotation) next, IBulkEditorConstants.TYPE_MERGE_CANDIDATE); |
|
53 |
} |
|
54 |
} |
|
55 |
} |
|
56 |
} |
|
57 |
return null; |
|
58 |
} |
|
28 |
@Execute |
|
29 |
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)AnnotatedTableItem item, |
|
30 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart) { |
|
31 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
|
32 |
item.setMergeCandidate(true); |
|
33 |
editor.refresh(); |
|
34 |
} |
|
59 | 35 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/SetMergeTargetHandlerE4.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.bulkeditor.e4.handler; |
10 | 10 |
|
11 |
import org.eclipse.core.commands.AbstractHandler; |
|
12 |
import org.eclipse.core.commands.ExecutionEvent; |
|
13 |
import org.eclipse.core.commands.ExecutionException; |
|
14 |
import org.eclipse.jface.text.IDocument; |
|
15 |
import org.eclipse.jface.text.TextSelection; |
|
16 |
import org.eclipse.jface.text.source.Annotation; |
|
17 |
import org.eclipse.jface.viewers.ISelection; |
|
18 |
import org.eclipse.ui.IEditorInput; |
|
19 |
import org.eclipse.ui.IEditorPart; |
|
20 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
21 |
import org.eclipse.ui.texteditor.IDocumentProvider; |
|
11 |
import javax.inject.Named; |
|
22 | 12 |
|
23 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.AnnotatedLineEditor; |
|
24 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel; |
|
25 |
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants; |
|
26 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
|
13 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
14 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
15 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
16 |
|
|
17 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.AnnotatedTableItem; |
|
18 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
|
27 | 19 |
|
28 | 20 |
/** |
29 |
* <p>SetMergeTargetHandler class.</p> |
|
30 | 21 |
* |
31 |
* @author p.ciardelli
|
|
32 |
* @created 25.06.2009
|
|
33 |
* @version 1.0
|
|
22 |
* @author pplitzner
|
|
23 |
* @date 12.09.2017
|
|
24 |
* |
|
34 | 25 |
*/ |
35 |
public class SetMergeTargetHandlerE4 extends AbstractHandler {
|
|
26 |
public class SetMergeTargetHandlerE4 { |
|
36 | 27 |
|
37 |
/* (non-Javadoc) |
|
38 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
39 |
*/ |
|
40 |
/** {@inheritDoc} */ |
|
41 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
42 |
|
|
43 |
IEditorPart editor = HandlerUtil.getActiveEditor(event); |
|
44 |
IEditorInput input = editor.getEditorInput(); |
|
45 |
|
|
46 |
if (editor instanceof AnnotatedLineEditor && input instanceof AbstractBulkEditorInput) { |
|
47 |
|
|
48 |
IDocumentProvider provider = ((AnnotatedLineEditor) editor).getDocumentProvider(); |
|
49 |
LineAnnotationModel model = |
|
50 |
(LineAnnotationModel) provider.getAnnotationModel(input); |
|
51 |
IDocument document = provider.getDocument(input); |
|
52 |
|
|
53 |
ISelection selection = HandlerUtil.getCurrentSelection(event); |
|
54 |
if (selection instanceof TextSelection) { |
|
55 |
Annotation annotation = null; |
|
56 |
|
|
57 |
// Get annotation in current line |
|
58 |
int line = ((TextSelection) selection).getStartLine(); |
|
59 |
annotation = model.getAnnotationAtLine(line, document); |
|
60 |
|
|
61 |
// Remove existing merge target |
|
62 |
model.removeTypeFromAllAnnotations(IBulkEditorConstants.TYPE_MERGE_TARGET); |
|
63 |
|
|
64 |
// Set annotation in current line to merge target |
|
65 |
if (annotation != null) { |
|
66 |
model.changeAnnotationType( |
|
67 |
annotation, IBulkEditorConstants.TYPE_MERGE_TARGET); |
|
68 |
} |
|
69 |
} |
|
70 |
} |
|
71 |
return null; |
|
28 |
@Execute |
|
29 |
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)AnnotatedTableItem item, |
|
30 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart) { |
|
31 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
|
32 |
item.setMergeTarget(true); |
|
33 |
editor.refresh(); |
|
72 | 34 |
} |
73 | 35 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java | ||
---|---|---|
32 | 32 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService; |
33 | 33 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorQuery; |
34 | 34 |
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider; |
35 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.AnnotatedTableItem; |
|
35 | 36 |
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.CdmBaseSortProvider; |
36 | 37 |
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.TitleCacheComparator; |
37 | 38 |
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin; |
... | ... | |
222 | 223 |
return model; |
223 | 224 |
} |
224 | 225 |
|
226 |
public List<AnnotatedTableItem<T>> getWrappedModel() { |
|
227 |
List<AnnotatedTableItem<T>> wrappetItems = new ArrayList<>(); |
|
228 |
for(T t:model){ |
|
229 |
wrappetItems.add(new AnnotatedTableItem<T>(t)); |
|
230 |
} |
|
231 |
return wrappetItems; |
|
232 |
} |
|
233 |
|
|
225 | 234 |
protected boolean replaceInModel(T entity) { |
226 | 235 |
int index = model.indexOf(entity); |
227 | 236 |
if(index >= 0) { |
Also available in: Unified diff
ref #6932 Migrate bulk editor handlers and add annotation merge support