1 |
4ff11da5
|
pplitzner
|
/**
|
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;
|
11 |
|
|
|
12 |
|
|
import java.util.ArrayList;
|
13 |
|
|
import java.util.HashSet;
|
14 |
|
|
import java.util.List;
|
15 |
|
|
import java.util.Set;
|
16 |
c799a32e
|
Katja Luther
|
import java.util.UUID;
|
17 |
4ff11da5
|
pplitzner
|
|
18 |
|
|
import javax.annotation.PostConstruct;
|
19 |
|
|
import javax.annotation.PreDestroy;
|
20 |
|
|
import javax.inject.Inject;
|
21 |
|
|
|
22 |
|
|
import org.apache.commons.lang.StringUtils;
|
23 |
|
|
import org.eclipse.core.commands.operations.IUndoContext;
|
24 |
65514c8c
|
Patrick Plitzner
|
import org.eclipse.core.commands.operations.UndoContext;
|
25 |
4ff11da5
|
pplitzner
|
import org.eclipse.core.runtime.IProgressMonitor;
|
26 |
|
|
import org.eclipse.core.runtime.OperationCanceledException;
|
27 |
b5b429af
|
Patrick Plitzner
|
import org.eclipse.e4.core.contexts.IEclipseContext;
|
28 |
eb6e490d
|
Katja Luther
|
import org.eclipse.e4.core.di.annotations.Optional;
|
29 |
e9fa67ee
|
Patrick Plitzner
|
import org.eclipse.e4.core.services.events.IEventBroker;
|
30 |
4ff11da5
|
pplitzner
|
import org.eclipse.e4.ui.di.Focus;
|
31 |
|
|
import org.eclipse.e4.ui.di.Persist;
|
32 |
eb6e490d
|
Katja Luther
|
import org.eclipse.e4.ui.di.UIEventTopic;
|
33 |
b2765124
|
Katja Luther
|
import org.eclipse.e4.ui.di.UISynchronize;
|
34 |
123796a3
|
Katja Luther
|
import org.eclipse.e4.ui.model.application.MApplication;
|
35 |
4ff11da5
|
pplitzner
|
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
|
36 |
e378d285
|
Patrick Plitzner
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
37 |
4ff11da5
|
pplitzner
|
import org.eclipse.e4.ui.services.EMenuService;
|
38 |
123796a3
|
Katja Luther
|
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
39 |
|
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
40 |
4ff11da5
|
pplitzner
|
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
|
41 |
65514c8c
|
Patrick Plitzner
|
import org.eclipse.jface.dialogs.MessageDialog;
|
42 |
4ff11da5
|
pplitzner
|
import org.eclipse.jface.viewers.ISelection;
|
43 |
|
|
import org.eclipse.jface.viewers.ISelectionProvider;
|
44 |
|
|
import org.eclipse.jface.viewers.StructuredSelection;
|
45 |
24b8f2f1
|
Patrick Plitzner
|
import org.eclipse.swt.dnd.DND;
|
46 |
|
|
import org.eclipse.swt.dnd.DropTarget;
|
47 |
|
|
import org.eclipse.swt.dnd.Transfer;
|
48 |
4ff11da5
|
pplitzner
|
import org.eclipse.swt.graphics.Color;
|
49 |
|
|
import org.eclipse.swt.widgets.Composite;
|
50 |
|
|
import org.eclipse.ui.ISelectionListener;
|
51 |
|
|
import org.eclipse.ui.IWorkbenchPart;
|
52 |
|
|
import org.eclipse.ui.IWorkbenchPartReference;
|
53 |
|
|
import org.eclipse.ui.forms.ManagedForm;
|
54 |
|
|
import org.eclipse.ui.forms.widgets.FormToolkit;
|
55 |
|
|
import org.eclipse.ui.forms.widgets.ScrolledForm;
|
56 |
|
|
import org.eclipse.ui.forms.widgets.TableWrapLayout;
|
57 |
|
|
|
58 |
|
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
59 |
|
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
60 |
159247e6
|
Patrick Plitzner
|
import eu.etaxonomy.cdm.api.service.DeleteResult;
|
61 |
4ff11da5
|
pplitzner
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
62 |
|
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
63 |
|
|
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
|
64 |
9e1446d2
|
Katja Luther
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
65 |
a797ba42
|
Patrick Plitzner
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
66 |
4ff11da5
|
pplitzner
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
67 |
|
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
68 |
|
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
69 |
c8cdc672
|
Patrick Plitzner
|
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
|
70 |
4ff11da5
|
pplitzner
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
|
71 |
24b8f2f1
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.editor.CdmDataTransfer;
|
72 |
159247e6
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
73 |
4ff11da5
|
pplitzner
|
import eu.etaxonomy.taxeditor.editor.ISecuredEditor;
|
74 |
e9fa67ee
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
|
75 |
4ff11da5
|
pplitzner
|
import eu.etaxonomy.taxeditor.editor.e4.TaxonEditorInputE4;
|
76 |
123796a3
|
Katja Luther
|
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
|
77 |
4ff11da5
|
pplitzner
|
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
|
78 |
|
|
import eu.etaxonomy.taxeditor.editor.name.e4.container.AbstractGroupE4;
|
79 |
|
|
import eu.etaxonomy.taxeditor.editor.name.e4.container.AbstractGroupedContainerE4;
|
80 |
|
|
import eu.etaxonomy.taxeditor.editor.name.e4.container.AcceptedGroupE4;
|
81 |
|
|
import eu.etaxonomy.taxeditor.editor.name.e4.container.AcceptedNameContainerE4;
|
82 |
670cfe16
|
Katja Luther
|
import eu.etaxonomy.taxeditor.editor.name.e4.container.ConceptContainerE4;
|
83 |
4ff11da5
|
pplitzner
|
import eu.etaxonomy.taxeditor.editor.name.e4.container.ContainerFactoryE4;
|
84 |
|
|
import eu.etaxonomy.taxeditor.editor.name.e4.container.HomotypicalSynonymGroupE4;
|
85 |
|
|
import eu.etaxonomy.taxeditor.editor.name.e4.container.MisappliedGroupE4;
|
86 |
24b8f2f1
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.editor.name.e4.dnd.NameEditorDropTargetListenerE4;
|
87 |
fae92bbd
|
Katja Luther
|
import eu.etaxonomy.taxeditor.event.EventUtility;
|
88 |
e9fa67ee
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
|
89 |
4ff11da5
|
pplitzner
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
90 |
|
|
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
|
91 |
|
|
import eu.etaxonomy.taxeditor.model.IPartChangeListener;
|
92 |
|
|
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
|
93 |
65514c8c
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
|
94 |
|
|
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
|
95 |
|
|
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
|
96 |
22f2d1a4
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
97 |
4ff11da5
|
pplitzner
|
import eu.etaxonomy.taxeditor.model.TaxeditorPartService;
|
98 |
|
|
import eu.etaxonomy.taxeditor.preference.Resources;
|
99 |
|
|
import eu.etaxonomy.taxeditor.security.RequiredPermissions;
|
100 |
|
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
101 |
c8cdc672
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
|
102 |
4ff11da5
|
pplitzner
|
|
103 |
|
|
/**
|
104 |
|
|
*
|
105 |
|
|
* @author pplitzner
|
106 |
|
|
* @date Aug 24, 2017
|
107 |
|
|
*
|
108 |
|
|
*/
|
109 |
65514c8c
|
Patrick Plitzner
|
public class TaxonNameEditorE4 implements IConversationEnabled, IDirtyMarkable, IPartContentHasDetails,
|
110 |
|
|
IPartContentHasSupplementalData, IPartContentHasMedia, IPartContentHasFactualData, IPartChangeListener,
|
111 |
b57b8fd1
|
Katja Luther
|
ISelectionListener, ISecuredEditor, IE4SavablePart, ITaxonEditor, IDropTargetableE4 {
|
112 |
4ff11da5
|
pplitzner
|
|
113 |
f18400be
|
Katja Luther
|
private Taxon taxon;
|
114 |
4ff11da5
|
pplitzner
|
|
115 |
f18400be
|
Katja Luther
|
private ManagedForm managedForm;
|
116 |
|
|
private ScrolledForm scrolledForm;
|
117 |
|
|
private Composite parent;
|
118 |
|
|
private ISelectionProvider simpleSelectionProvider;
|
119 |
4ff11da5
|
pplitzner
|
|
120 |
f18400be
|
Katja Luther
|
private TaxonBase selection;
|
121 |
4ff11da5
|
pplitzner
|
|
122 |
f18400be
|
Katja Luther
|
private ConversationHolder conversation;
|
123 |
4ff11da5
|
pplitzner
|
|
124 |
f18400be
|
Katja Luther
|
private AcceptedGroupE4 acceptedGroup;
|
125 |
|
|
private List<HomotypicalSynonymGroupE4> heterotypicSynonymGroups = new ArrayList<>();
|
126 |
|
|
private MisappliedGroupE4 misappliedGroup;
|
127 |
4ff11da5
|
pplitzner
|
|
128 |
f18400be
|
Katja Luther
|
private DropTarget target;
|
129 |
033ef209
|
Patrick Plitzner
|
|
130 |
f18400be
|
Katja Luther
|
@Inject
|
131 |
|
|
UISynchronize sync;
|
132 |
b2765124
|
Katja Luther
|
|
133 |
f18400be
|
Katja Luther
|
private TaxonBase objectAffectedByLastOperation;
|
134 |
4ff11da5
|
pplitzner
|
|
135 |
f18400be
|
Katja Luther
|
@Inject
|
136 |
|
|
private EMenuService menuService;
|
137 |
4ff11da5
|
pplitzner
|
|
138 |
f18400be
|
Katja Luther
|
@Inject
|
139 |
|
|
private ESelectionService selService;
|
140 |
4ff11da5
|
pplitzner
|
|
141 |
f18400be
|
Katja Luther
|
@Inject
|
142 |
|
|
private IEclipseContext context;
|
143 |
b5b429af
|
Patrick Plitzner
|
|
144 |
f18400be
|
Katja Luther
|
@Inject
|
145 |
|
|
private MDirtyable dirty;
|
146 |
4ff11da5
|
pplitzner
|
|
147 |
123796a3
|
Katja Luther
|
@Inject
|
148 |
|
|
private MApplication application;
|
149 |
|
|
|
150 |
f18400be
|
Katja Luther
|
private MPart thisPart;
|
151 |
e378d285
|
Patrick Plitzner
|
|
152 |
4ff11da5
|
pplitzner
|
private TaxonEditorInputE4 input;
|
153 |
|
|
|
154 |
65514c8c
|
Patrick Plitzner
|
private UndoContext undoContext;
|
155 |
|
|
|
156 |
e9fa67ee
|
Patrick Plitzner
|
@Inject
|
157 |
|
|
private IEventBroker eventBroker;
|
158 |
|
|
|
159 |
f18400be
|
Katja Luther
|
@Inject
|
160 |
|
|
public TaxonNameEditorE4() {
|
161 |
|
|
undoContext = new UndoContext();
|
162 |
|
|
}
|
163 |
4ff11da5
|
pplitzner
|
|
164 |
f18400be
|
Katja Luther
|
@PostConstruct
|
165 |
e378d285
|
Patrick Plitzner
|
public void createPartControl(Composite parent, MPart thisPart) {
|
166 |
f18400be
|
Katja Luther
|
this.thisPart = thisPart;
|
167 |
4ff11da5
|
pplitzner
|
|
168 |
033ef209
|
Patrick Plitzner
|
createManagedForm(parent);
|
169 |
4ff11da5
|
pplitzner
|
|
170 |
f18400be
|
Katja Luther
|
TaxeditorPartService.getInstance().addListener(TaxeditorPartService.PART_ACTIVATED, this);
|
171 |
4ff11da5
|
pplitzner
|
|
172 |
f18400be
|
Katja Luther
|
}
|
173 |
4ff11da5
|
pplitzner
|
|
174 |
f18400be
|
Katja Luther
|
protected void createManagedForm(Composite composite) {
|
175 |
4ff11da5
|
pplitzner
|
|
176 |
f18400be
|
Katja Luther
|
managedForm = new ManagedForm(composite) {
|
177 |
4ff11da5
|
pplitzner
|
|
178 |
f18400be
|
Katja Luther
|
@Override
|
179 |
|
|
public void dirtyStateChanged() {
|
180 |
|
|
dirty.setDirty(true);
|
181 |
|
|
}
|
182 |
4ff11da5
|
pplitzner
|
|
183 |
f18400be
|
Katja Luther
|
@Override
|
184 |
|
|
public boolean setInput(Object input) {
|
185 |
|
|
if (input instanceof AbstractGroupedContainerE4) {
|
186 |
|
|
TaxonBase newSelection = ((AbstractGroupedContainerE4) input).getData();
|
187 |
|
|
if (selection != newSelection || TaxonNameEditorE4.this.isDirty()) {
|
188 |
|
|
selection = newSelection;
|
189 |
|
|
selService.setSelection(new StructuredSelection(selection));
|
190 |
|
|
|
191 |
|
|
}
|
192 |
|
|
} else if (input == null) {
|
193 |
|
|
selection = null;
|
194 |
65514c8c
|
Patrick Plitzner
|
selService.setSelection(new StructuredSelection());
|
195 |
f18400be
|
Katja Luther
|
}
|
196 |
4ff11da5
|
pplitzner
|
|
197 |
f18400be
|
Katja Luther
|
return super.setInput(input);
|
198 |
|
|
}
|
199 |
|
|
};
|
200 |
4ff11da5
|
pplitzner
|
|
201 |
f18400be
|
Katja Luther
|
scrolledForm = managedForm.getForm();
|
202 |
|
|
parent = scrolledForm.getBody();
|
203 |
4ff11da5
|
pplitzner
|
|
204 |
f18400be
|
Katja Luther
|
parent.setData(taxon);
|
205 |
4ff11da5
|
pplitzner
|
|
206 |
f18400be
|
Katja Luther
|
TableWrapLayout layout = new TableWrapLayout();
|
207 |
|
|
layout.leftMargin = 0;
|
208 |
|
|
layout.rightMargin = 0;
|
209 |
|
|
layout.topMargin = 0;
|
210 |
|
|
layout.bottomMargin = 0;
|
211 |
4ff11da5
|
pplitzner
|
|
212 |
f18400be
|
Katja Luther
|
layout.verticalSpacing = 0;
|
213 |
|
|
layout.horizontalSpacing = 0;
|
214 |
4ff11da5
|
pplitzner
|
|
215 |
f18400be
|
Katja Luther
|
parent.setLayout(layout);
|
216 |
|
|
parent.setBackground(AbstractUtility.getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
|
217 |
|
|
}
|
218 |
7ccb7304
|
Katja Luther
|
|
219 |
f18400be
|
Katja Luther
|
public void createOrUpdateNameComposites(boolean accepted, boolean heterotypicGroups, boolean misappliedNames) {
|
220 |
7ccb7304
|
Katja Luther
|
|
221 |
f18400be
|
Katja Luther
|
if (accepted) {
|
222 |
7ccb7304
|
Katja Luther
|
ContainerFactoryE4.createOrUpdateAcceptedTaxonsHomotypicGroup(this);
|
223 |
|
|
}
|
224 |
f18400be
|
Katja Luther
|
if (heterotypicGroups) {
|
225 |
7ccb7304
|
Katja Luther
|
ContainerFactoryE4.createOrUpdateHeterotypicSynonymyGroups(this);
|
226 |
|
|
}
|
227 |
f18400be
|
Katja Luther
|
if (misappliedNames) {
|
228 |
7ccb7304
|
Katja Luther
|
ContainerFactoryE4.createOrUpdateMisapplicationsGroup(this);
|
229 |
|
|
}
|
230 |
|
|
ContainerFactoryE4.setMenuToAllContainers(this);
|
231 |
|
|
|
232 |
f18400be
|
Katja Luther
|
// Redraw composite
|
233 |
|
|
parent.pack();
|
234 |
|
|
managedForm.refresh();
|
235 |
|
|
managedForm.reflow(true);
|
236 |
4ff11da5
|
pplitzner
|
|
237 |
f18400be
|
Katja Luther
|
}
|
238 |
4ff11da5
|
pplitzner
|
|
239 |
f18400be
|
Katja Luther
|
@Override
|
240 |
e9fa67ee
|
Patrick Plitzner
|
public Taxon getTaxon() {
|
241 |
f18400be
|
Katja Luther
|
return HibernateProxyHelper.deproxy(taxon);
|
242 |
|
|
}
|
243 |
4ff11da5
|
pplitzner
|
|
244 |
f18400be
|
Katja Luther
|
public void setDirty() {
|
245 |
|
|
managedForm.dirtyStateChanged();
|
246 |
|
|
}
|
247 |
4ff11da5
|
pplitzner
|
|
248 |
f18400be
|
Katja Luther
|
@Focus
|
249 |
|
|
public void setFocus() {
|
250 |
|
|
// make sure to bind again if maybe in another view the conversation was
|
251 |
|
|
// unbound
|
252 |
|
|
if (conversation != null && !conversation.isBound()) {
|
253 |
65514c8c
|
Patrick Plitzner
|
conversation.bind();
|
254 |
|
|
}
|
255 |
40a8056b
|
Katja Luther
|
|
256 |
f18400be
|
Katja Luther
|
if (input != null) {
|
257 |
|
|
if (getSelectedContainer() == null) {
|
258 |
|
|
throw new IllegalStateException(Messages.TaxonNameEditor_THERE_SHOULD_ALWAYS_BE);
|
259 |
|
|
}
|
260 |
|
|
getSelectedContainer().setSelected();
|
261 |
d78bb89a
|
Katja Luther
|
|
262 |
f18400be
|
Katja Luther
|
if (!input.getCdmEntitySession().isActive()) {
|
263 |
|
|
input.bind();
|
264 |
|
|
}
|
265 |
|
|
|
266 |
|
|
// check permissions
|
267 |
|
|
boolean doEnable = permissionsSatisfied();
|
268 |
|
|
managedForm.getForm().setEnabled(doEnable);
|
269 |
|
|
}
|
270 |
a1cca9f8
|
Patrick Plitzner
|
if(selection!=null){
|
271 |
|
|
selService.setSelection(new StructuredSelection(selection));
|
272 |
|
|
}
|
273 |
e9fa67ee
|
Patrick Plitzner
|
eventBroker.post(WorkbenchEventConstants.CURRENT_ACTIVE_EDITOR, this);
|
274 |
f18400be
|
Katja Luther
|
}
|
275 |
4ff11da5
|
pplitzner
|
|
276 |
f18400be
|
Katja Luther
|
@Override
|
277 |
|
|
public boolean permissionsSatisfied() {
|
278 |
|
|
TaxonNode taxonNode = input.getTaxonNode();
|
279 |
|
|
boolean doEnable = CdmStore.currentAuthentiationHasPermission(taxonNode.getTaxon(),
|
280 |
|
|
RequiredPermissions.TAXON_EDIT);
|
281 |
|
|
return doEnable;
|
282 |
|
|
}
|
283 |
4ff11da5
|
pplitzner
|
|
284 |
f18400be
|
Katja Luther
|
@Override
|
285 |
4ff11da5
|
pplitzner
|
public ConversationHolder getConversationHolder() {
|
286 |
f18400be
|
Katja Luther
|
return conversation;
|
287 |
|
|
}
|
288 |
4ff11da5
|
pplitzner
|
|
289 |
f18400be
|
Katja Luther
|
/** {@inheritDoc} */
|
290 |
|
|
@Override
|
291 |
4ff11da5
|
pplitzner
|
public void update(CdmDataChangeMap events) {
|
292 |
f18400be
|
Katja Luther
|
// redraw();
|
293 |
|
|
}
|
294 |
|
|
|
295 |
|
|
/**
|
296 |
|
|
* Redraws this editor return true on success
|
297 |
|
|
*
|
298 |
|
|
* @return a boolean.
|
299 |
|
|
*/
|
300 |
4ff11da5
|
pplitzner
|
public boolean redraw() {
|
301 |
f18400be
|
Katja Luther
|
return redraw(true, true, true, true);
|
302 |
|
|
}
|
303 |
|
|
|
304 |
|
|
/**
|
305 |
|
|
* {@inheritDoc}
|
306 |
|
|
*
|
307 |
|
|
* Redraws the editor controls
|
308 |
|
|
*/
|
309 |
a0d81001
|
Katja Luther
|
public boolean redraw(boolean focus, boolean accepted, boolean heterotypic, boolean misappliedNames) {
|
310 |
4ff11da5
|
pplitzner
|
|
311 |
f18400be
|
Katja Luther
|
createOrUpdateNameComposites(accepted, heterotypic, misappliedNames);
|
312 |
4ff11da5
|
pplitzner
|
|
313 |
f18400be
|
Katja Luther
|
if (focus) {
|
314 |
|
|
setFocus();
|
315 |
|
|
}
|
316 |
4ff11da5
|
pplitzner
|
|
317 |
f18400be
|
Katja Luther
|
return true;
|
318 |
|
|
}
|
319 |
4ff11da5
|
pplitzner
|
|
320 |
f18400be
|
Katja Luther
|
@Override
|
321 |
a3c56b93
|
Patrick Plitzner
|
public boolean postOperation(Object objectAffectedByOperation) {
|
322 |
f18400be
|
Katja Luther
|
if (objectAffectedByOperation instanceof TaxonBase) {
|
323 |
|
|
objectAffectedByLastOperation = (TaxonBase) objectAffectedByOperation;
|
324 |
|
|
}
|
325 |
d78bb89a
|
Katja Luther
|
|
326 |
f18400be
|
Katja Luther
|
redraw(true, true, true, true);
|
327 |
|
|
changed(objectAffectedByOperation);
|
328 |
d78bb89a
|
Katja Luther
|
onComplete();
|
329 |
f18400be
|
Katja Luther
|
return true;
|
330 |
|
|
}
|
331 |
|
|
|
332 |
|
|
public ManagedForm getManagedForm() {
|
333 |
|
|
return managedForm;
|
334 |
|
|
}
|
335 |
|
|
|
336 |
|
|
/**
|
337 |
|
|
* <p>
|
338 |
|
|
* checkForEmptyNames
|
339 |
|
|
* </p>
|
340 |
|
|
*
|
341 |
|
|
* @return true if there are empty names
|
342 |
|
|
*/
|
343 |
|
|
public boolean checkForEmptyNames() {
|
344 |
|
|
for (AbstractGroupedContainerE4 container : getGroupedContainers()) {
|
345 |
|
|
if (container != null
|
346 |
|
|
&& (container.getName() == null || StringUtils.isEmpty(container.getName().getTitleCache()))) {
|
347 |
|
|
return true;
|
348 |
|
|
}
|
349 |
|
|
}
|
350 |
|
|
return false;
|
351 |
|
|
}
|
352 |
|
|
|
353 |
|
|
public Set<AbstractGroupedContainerE4> getEmptyContainers() {
|
354 |
|
|
Set<AbstractGroupedContainerE4> containersWithEmptyNames = new HashSet<>();
|
355 |
|
|
|
356 |
|
|
for (AbstractGroupedContainerE4 container : getGroupedContainers()) {
|
357 |
|
|
if (container.getName() == null || StringUtils.isEmpty(container.getName().getTitleCache())) {
|
358 |
|
|
containersWithEmptyNames.add(container);
|
359 |
|
|
}
|
360 |
|
|
}
|
361 |
|
|
|
362 |
|
|
return containersWithEmptyNames;
|
363 |
|
|
}
|
364 |
4ff11da5
|
pplitzner
|
|
365 |
f18400be
|
Katja Luther
|
/** {@inheritDoc} */
|
366 |
|
|
@Override
|
367 |
c8cdc672
|
Patrick Plitzner
|
@Persist
|
368 |
f18400be
|
Katja Luther
|
public void save(IProgressMonitor monitor) {
|
369 |
|
|
|
370 |
|
|
monitor.beginTask(Messages.TaxonNameEditor_SAVING_NAMES, getGroupedContainers().size());
|
371 |
|
|
if (!conversation.isBound()) {
|
372 |
|
|
conversation.bind();
|
373 |
|
|
|
374 |
|
|
}
|
375 |
a692bc7b
|
Katja Luther
|
conversation.commit(true);
|
376 |
f18400be
|
Katja Luther
|
monitor.worked(1);
|
377 |
|
|
|
378 |
|
|
// check for empty names
|
379 |
|
|
if (checkForEmptyNames()) {
|
380 |
|
|
MessageDialog.openWarning(AbstractUtility.getShell(), Messages.MultiPageTaxonEditor_NO_NAME_SPECIFIED,
|
381 |
|
|
Messages.MultiPageTaxonEditor_NO_NAME_SPECIFIED_MESSAGE);
|
382 |
|
|
return;
|
383 |
|
|
}
|
384 |
|
|
for (AbstractGroupedContainerE4 container : getGroupedContainers()) {
|
385 |
|
|
|
386 |
|
|
monitor.subTask(Messages.TaxonNameEditor_SAVING_COMPOSITES + container.getTaxonBase().getTitleCache());
|
387 |
|
|
container.persistName();
|
388 |
|
|
// because of missing cascading the concepts need to be saved
|
389 |
|
|
// separately
|
390 |
|
|
if (container instanceof ConceptContainerE4) {
|
391 |
|
|
input.addToSaveNewConcept((Taxon) container.getData());
|
392 |
|
|
}
|
393 |
|
|
// In case the progress monitor was canceled throw an exception.
|
394 |
|
|
if (monitor.isCanceled()) {
|
395 |
|
|
throw new OperationCanceledException();
|
396 |
|
|
}
|
397 |
a692bc7b
|
Katja Luther
|
|
398 |
f18400be
|
Katja Luther
|
// Otherwise declare this step as done.
|
399 |
|
|
monitor.worked(1);
|
400 |
|
|
|
401 |
|
|
}
|
402 |
|
|
input.setSync(sync);
|
403 |
|
|
input.merge();
|
404 |
|
|
// commit the conversation and start a new transaction immediately
|
405 |
|
|
conversation.commit(true);
|
406 |
a692bc7b
|
Katja Luther
|
|
407 |
|
|
dirty.setDirty(false);
|
408 |
fae92bbd
|
Katja Luther
|
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, true);
|
409 |
84f9c7fd
|
Patrick Plitzner
|
EventUtility.postEvent(WorkbenchEventConstants.SAVE_TAXON, true);
|
410 |
f18400be
|
Katja Luther
|
// Stop the progress monitor.
|
411 |
|
|
monitor.done();
|
412 |
|
|
}
|
413 |
|
|
|
414 |
|
|
public void init(TaxonEditorInputE4 input) {
|
415 |
|
|
if (this.input != null) {
|
416 |
|
|
this.input.dispose();
|
417 |
|
|
// this.acceptedGroup = null;
|
418 |
|
|
// this.heterotypicSynonymGroups.clear();
|
419 |
|
|
// this.misappliedGroup = null;
|
420 |
|
|
}
|
421 |
|
|
if (!(input != null)) {
|
422 |
22f2d1a4
|
Patrick Plitzner
|
MessagingUtils.error(this.getClass(), new Exception(Messages.TaxonNameEditor_INVALID_INPUT));
|
423 |
|
|
return;
|
424 |
4ff11da5
|
pplitzner
|
}
|
425 |
|
|
|
426 |
f18400be
|
Katja Luther
|
if (input.getAdapter(Taxon.class) != null) {
|
427 |
|
|
taxon = CdmBase.deproxy(input.getAdapter(Taxon.class), Taxon.class);
|
428 |
|
|
} else {
|
429 |
|
|
MessagingUtils.error(this.getClass(), new Exception(Messages.TaxonNameEditor_INVALID_INPUT_TAXON_NULL));
|
430 |
|
|
return;
|
431 |
|
|
}
|
432 |
4ff11da5
|
pplitzner
|
|
433 |
f18400be
|
Katja Luther
|
this.input = input;
|
434 |
|
|
conversation = input.getConversationHolder();
|
435 |
4ff11da5
|
pplitzner
|
|
436 |
a0d81001
|
Katja Luther
|
createOrUpdateNameComposites(true, true, true);
|
437 |
4ff11da5
|
pplitzner
|
|
438 |
24b8f2f1
|
Patrick Plitzner
|
createDragSupport();
|
439 |
|
|
|
440 |
e378d285
|
Patrick Plitzner
|
setPartName();
|
441 |
b4730c9a
|
Patrick Plitzner
|
|
442 |
f18400be
|
Katja Luther
|
// set initial selection
|
443 |
3fd7ed16
|
Patrick Plitzner
|
TaxonBase initiallySelectedTaxonBase = input.getInitiallySelectedTaxonBase();
|
444 |
f18400be
|
Katja Luther
|
if (initiallySelectedTaxonBase != null) {
|
445 |
3fd7ed16
|
Patrick Plitzner
|
selService.setSelection(new StructuredSelection(initiallySelectedTaxonBase));
|
446 |
|
|
getContainer(initiallySelectedTaxonBase).setSelected();
|
447 |
e34c0af1
|
Patrick Plitzner
|
}
|
448 |
f18400be
|
Katja Luther
|
}
|
449 |
|
|
|
450 |
|
|
private void createDragSupport() {
|
451 |
|
|
// Listen for names being dragged outside of existing homotypic groups -
|
452 |
|
|
// user wants to create a new group
|
453 |
|
|
Transfer[] types = new Transfer[] { CdmDataTransfer.getInstance() };
|
454 |
|
|
int operations = DND.DROP_MOVE;
|
455 |
|
|
if (target == null) {
|
456 |
|
|
target = new DropTarget(parent, operations);
|
457 |
|
|
target.setTransfer(types);
|
458 |
|
|
target.addDropListener(new NameEditorDropTargetListenerE4(this));
|
459 |
|
|
}
|
460 |
|
|
}
|
461 |
|
|
|
462 |
|
|
public AcceptedNameContainerE4 getAcceptedNameContainer() {
|
463 |
|
|
return getAcceptedGroup().getAcceptedNameContainer();
|
464 |
|
|
}
|
465 |
|
|
|
466 |
|
|
public HomotypicalSynonymGroupE4 getHomotypicalGroupContainer(HomotypicalGroup homotypicalGroup) {
|
467 |
|
|
for (HomotypicalSynonymGroupE4 group : getHeterotypicSynonymGroups()) {
|
468 |
|
|
if (group.getGroup().equals(homotypicalGroup)) {
|
469 |
|
|
return group;
|
470 |
|
|
}
|
471 |
|
|
}
|
472 |
|
|
|
473 |
|
|
return null;
|
474 |
|
|
}
|
475 |
|
|
|
476 |
|
|
/**
|
477 |
|
|
* <p>
|
478 |
|
|
* getDirtyNames
|
479 |
|
|
* </p>
|
480 |
|
|
*
|
481 |
|
|
* @return a Set containing all composites that have been edited
|
482 |
|
|
*/
|
483 |
|
|
public Set<AbstractGroupedContainerE4> getDirtyNames() {
|
484 |
|
|
Set<AbstractGroupedContainerE4> dirtyNames = new HashSet<>();
|
485 |
|
|
|
486 |
|
|
for (AbstractGroupedContainerE4 composite : getGroupedContainers()) {
|
487 |
|
|
if (composite.isDirty()) {
|
488 |
|
|
dirtyNames.add(composite);
|
489 |
|
|
}
|
490 |
|
|
}
|
491 |
|
|
|
492 |
|
|
return dirtyNames;
|
493 |
|
|
}
|
494 |
|
|
|
495 |
|
|
public List<AbstractGroupedContainerE4> getGroupedContainers() {
|
496 |
|
|
List<AbstractGroupedContainerE4> groupedComposites = new ArrayList<>();
|
497 |
|
|
|
498 |
|
|
for (AbstractGroupE4 group : getAllGroups()) {
|
499 |
|
|
if (group != null) {
|
500 |
|
|
groupedComposites.addAll(group.getGroupedContainers());
|
501 |
|
|
}
|
502 |
|
|
}
|
503 |
|
|
|
504 |
|
|
return groupedComposites;
|
505 |
|
|
}
|
506 |
|
|
|
507 |
|
|
public List<AbstractGroupE4> getAllGroups() {
|
508 |
|
|
List<AbstractGroupE4> allGroups = new ArrayList<>();
|
509 |
|
|
|
510 |
|
|
allGroups.add(getAcceptedGroup());
|
511 |
|
|
|
512 |
|
|
heterotypicSynonymGroups = getHeterotypicSynonymGroups();
|
513 |
|
|
|
514 |
|
|
if (heterotypicSynonymGroups != null) {
|
515 |
|
|
allGroups.addAll(heterotypicSynonymGroups);
|
516 |
|
|
}
|
517 |
|
|
|
518 |
|
|
if (misappliedGroup != null) {
|
519 |
|
|
allGroups.add(misappliedGroup);
|
520 |
|
|
}
|
521 |
|
|
|
522 |
|
|
return allGroups;
|
523 |
|
|
}
|
524 |
|
|
|
525 |
|
|
@Override
|
526 |
|
|
public IEclipseContext getContext() {
|
527 |
|
|
return context;
|
528 |
|
|
}
|
529 |
|
|
|
530 |
|
|
@Override
|
531 |
84f9c7fd
|
Patrick Plitzner
|
public boolean isDirty() {
|
532 |
f18400be
|
Katja Luther
|
return dirty.isDirty();
|
533 |
|
|
}
|
534 |
4ff11da5
|
pplitzner
|
|
535 |
f18400be
|
Katja Luther
|
@PreDestroy
|
536 |
|
|
public void dispose() {
|
537 |
|
|
if (conversation != null) {
|
538 |
65514c8c
|
Patrick Plitzner
|
conversation.unregisterForDataStoreChanges(this);
|
539 |
|
|
conversation.close();
|
540 |
|
|
}
|
541 |
f18400be
|
Katja Luther
|
if (input != null) {
|
542 |
06c9361e
|
Patrick Plitzner
|
input.dispose();
|
543 |
|
|
}
|
544 |
7d9a3913
|
Patrick Plitzner
|
dirty.setDirty(false);
|
545 |
d6d945d2
|
Patrick Plitzner
|
eventBroker.post(WorkbenchEventConstants.CURRENT_ACTIVE_EDITOR, null);
|
546 |
f18400be
|
Katja Luther
|
}
|
547 |
4ff11da5
|
pplitzner
|
|
548 |
f18400be
|
Katja Luther
|
/** {@inheritDoc} */
|
549 |
|
|
@Override
|
550 |
4ff11da5
|
pplitzner
|
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
|
551 |
f18400be
|
Katja Luther
|
System.err.println("Bla");
|
552 |
|
|
}
|
553 |
4ff11da5
|
pplitzner
|
|
554 |
f18400be
|
Katja Luther
|
public AbstractGroupedContainerE4 getSelectedContainer() {
|
555 |
|
|
return (selection != null) ? getContainer(selection) : getAcceptedNameContainer();
|
556 |
|
|
}
|
557 |
4ff11da5
|
pplitzner
|
|
558 |
24b8f2f1
|
Patrick Plitzner
|
@Override
|
559 |
|
|
public void dragEntered() {
|
560 |
|
|
// TODO change this
|
561 |
f18400be
|
Katja Luther
|
getControl().setBackground(AbstractUtility.getColor(Resources.COLOR_DRAG_ENTER));
|
562 |
24b8f2f1
|
Patrick Plitzner
|
}
|
563 |
|
|
|
564 |
|
|
@Override
|
565 |
|
|
public void dragLeft() {
|
566 |
f18400be
|
Katja Luther
|
getControl().setBackground(AbstractUtility.getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
|
567 |
24b8f2f1
|
Patrick Plitzner
|
}
|
568 |
033ef209
|
Patrick Plitzner
|
|
569 |
f18400be
|
Katja Luther
|
public void setMisapplicationsGroup(MisappliedGroupE4 misappliedGroup) {
|
570 |
|
|
this.misappliedGroup = misappliedGroup;
|
571 |
|
|
}
|
572 |
033ef209
|
Patrick Plitzner
|
|
573 |
f18400be
|
Katja Luther
|
public FormToolkit getToolkit() {
|
574 |
|
|
return managedForm.getToolkit();
|
575 |
|
|
}
|
576 |
4ff11da5
|
pplitzner
|
|
577 |
f18400be
|
Katja Luther
|
public List<HomotypicalSynonymGroupE4> getHeterotypicSynonymGroups() {
|
578 |
|
|
return heterotypicSynonymGroups;
|
579 |
|
|
}
|
580 |
4ff11da5
|
pplitzner
|
|
581 |
f18400be
|
Katja Luther
|
public void addHeterotypicSynonymGroup(HomotypicalSynonymGroupE4 group) {
|
582 |
|
|
heterotypicSynonymGroups.add(group);
|
583 |
|
|
}
|
584 |
4ff11da5
|
pplitzner
|
|
585 |
f18400be
|
Katja Luther
|
public AcceptedGroupE4 getAcceptedGroup() {
|
586 |
|
|
return acceptedGroup;
|
587 |
|
|
}
|
588 |
4ff11da5
|
pplitzner
|
|
589 |
f18400be
|
Katja Luther
|
public void setAcceptedGroup(AcceptedGroupE4 acceptedGroup) {
|
590 |
|
|
this.acceptedGroup = acceptedGroup;
|
591 |
|
|
}
|
592 |
4ff11da5
|
pplitzner
|
|
593 |
f18400be
|
Katja Luther
|
public MisappliedGroupE4 getMisappliedGroup() {
|
594 |
|
|
return misappliedGroup;
|
595 |
|
|
}
|
596 |
4ff11da5
|
pplitzner
|
|
597 |
f18400be
|
Katja Luther
|
public boolean isActive() {
|
598 |
|
|
return this.equals(AbstractUtility.getActivePart());
|
599 |
|
|
}
|
600 |
4ff11da5
|
pplitzner
|
|
601 |
|
|
@Override
|
602 |
|
|
public boolean onComplete() {
|
603 |
f18400be
|
Katja Luther
|
getContainer(objectAffectedByLastOperation).setSelected();
|
604 |
|
|
return true;
|
605 |
|
|
}
|
606 |
4ff11da5
|
pplitzner
|
|
607 |
f18400be
|
Katja Luther
|
/** {@inheritDoc} */
|
608 |
|
|
@Override
|
609 |
4ff11da5
|
pplitzner
|
public void partChanged(Integer eventType, IWorkbenchPartReference partRef) {
|
610 |
f18400be
|
Katja Luther
|
if (!partRef.getPart(false).equals(this)) {
|
611 |
|
|
// getSelectedObject().colorSelected(AbstractGroupedContainer.SELECTED_NO_FOCUS);
|
612 |
|
|
}
|
613 |
|
|
}
|
614 |
|
|
|
615 |
|
|
public void removeGroup(AbstractGroupE4 group) {
|
616 |
|
|
if (group != null) {
|
617 |
|
|
group.dispose();
|
618 |
|
|
|
619 |
|
|
// if (heterotypicSynonymGroups != null) {
|
620 |
|
|
heterotypicSynonymGroups.remove(group);
|
621 |
|
|
// }
|
622 |
|
|
}
|
623 |
|
|
}
|
624 |
|
|
|
625 |
|
|
public AbstractGroupedContainerE4 getContainer(TaxonBase taxonBase) {
|
626 |
|
|
@SuppressWarnings("rawtypes")
|
627 |
0c5520e0
|
Katja Luther
|
List<AbstractGroupedContainerE4> groupedContainers = getGroupedContainers();
|
628 |
f18400be
|
Katja Luther
|
for (AbstractGroupedContainerE4 container : groupedContainers) {
|
629 |
|
|
if (container.getData().equals(taxonBase) && container.getNameViewer().getTextWidget() != null) {
|
630 |
|
|
return container;
|
631 |
|
|
}
|
632 |
|
|
}
|
633 |
|
|
return getAcceptedNameContainer();
|
634 |
|
|
}
|
635 |
4ff11da5
|
pplitzner
|
|
636 |
|
|
public void setOnError() {
|
637 |
f18400be
|
Katja Luther
|
Color disabledColor = AbstractUtility.getColor(Resources.COLOR_EDITOR_ERROR);
|
638 |
|
|
setEnabled(false, disabledColor);
|
639 |
|
|
}
|
640 |
4ff11da5
|
pplitzner
|
|
641 |
f18400be
|
Katja Luther
|
public void setDisabled() {
|
642 |
|
|
Color disabledColor = AbstractUtility.getColor(Resources.COLOR_TEXT_DISABLED_BACKGROUND);
|
643 |
|
|
setEnabled(false, disabledColor);
|
644 |
|
|
}
|
645 |
4ff11da5
|
pplitzner
|
|
646 |
f18400be
|
Katja Luther
|
protected void setEnabled(boolean enabled, Color background) {
|
647 |
4ff11da5
|
pplitzner
|
|
648 |
f18400be
|
Katja Luther
|
for (AbstractGroupedContainerE4 groupedContainer : getGroupedContainers()) {
|
649 |
|
|
groupedContainer.setEnabled(enabled);
|
650 |
|
|
}
|
651 |
4ff11da5
|
pplitzner
|
|
652 |
f18400be
|
Katja Luther
|
// send an empty selection to the current provider - TODO only on error
|
653 |
|
|
// ???
|
654 |
|
|
if (!enabled) {
|
655 |
|
|
getManagedForm().setInput(null);
|
656 |
4ff11da5
|
pplitzner
|
|
657 |
f18400be
|
Katja Luther
|
for (AbstractGroupedContainerE4 groupedContainer : getGroupedContainers()) {
|
658 |
|
|
groupedContainer.setBackground(background);
|
659 |
|
|
}
|
660 |
|
|
}
|
661 |
|
|
getControl().setBackground(background);
|
662 |
|
|
}
|
663 |
4ff11da5
|
pplitzner
|
|
664 |
|
|
@Override
|
665 |
|
|
public void changed(Object element) {
|
666 |
c8cdc672
|
Patrick Plitzner
|
// setDirty(true);
|
667 |
f18400be
|
Katja Luther
|
// if the attribute is null then do not set the dirty flag -> hotfix for
|
668 |
|
|
// the problem that for tasks done in service methods the changes are
|
669 |
|
|
// saved automatically
|
670 |
|
|
if (element != null) {
|
671 |
c8cdc672
|
Patrick Plitzner
|
dirty.setDirty(true);
|
672 |
f18400be
|
Katja Luther
|
// refresh part title
|
673 |
|
|
// TODO: refresh taxon node in taxon navigator
|
674 |
e378d285
|
Patrick Plitzner
|
setPartName();
|
675 |
c8cdc672
|
Patrick Plitzner
|
}
|
676 |
4ff11da5
|
pplitzner
|
|
677 |
c8cdc672
|
Patrick Plitzner
|
if (element instanceof TaxonBase) {
|
678 |
|
|
AbstractGroupedContainerE4 container = getContainer((TaxonBase) element);
|
679 |
|
|
if (container != null) {
|
680 |
|
|
container.refresh();
|
681 |
|
|
}
|
682 |
|
|
}
|
683 |
7ccb7304
|
Katja Luther
|
|
684 |
c8cdc672
|
Patrick Plitzner
|
if (element instanceof TaxonRelationship) {
|
685 |
|
|
AbstractGroupedContainerE4 container = getContainer(((TaxonRelationship) element).getFromTaxon());
|
686 |
|
|
if (container != null) {
|
687 |
|
|
container.refresh();
|
688 |
|
|
}
|
689 |
|
|
}
|
690 |
e378d285
|
Patrick Plitzner
|
}
|
691 |
|
|
|
692 |
f18400be
|
Katja Luther
|
public void setPartName() {
|
693 |
|
|
// FIXME: temporary fix for #6437 to avoid outdated title caches
|
694 |
2a5271ca
|
Patrick Plitzner
|
thisPart.setLabel(this.taxon.getName().generateFullTitle());
|
695 |
f18400be
|
Katja Luther
|
// thisPart.setLabel(this.taxon.getName().getFullTitleCache());
|
696 |
4ff11da5
|
pplitzner
|
}
|
697 |
|
|
|
698 |
|
|
@Override
|
699 |
|
|
public void forceDirty() {
|
700 |
|
|
setDirty();
|
701 |
|
|
}
|
702 |
|
|
|
703 |
|
|
public IUndoContext getUndoContext() {
|
704 |
65514c8c
|
Patrick Plitzner
|
return undoContext;
|
705 |
4ff11da5
|
pplitzner
|
}
|
706 |
|
|
|
707 |
24b8f2f1
|
Patrick Plitzner
|
@Override
|
708 |
f18400be
|
Katja Luther
|
public Composite getControl() {
|
709 |
033ef209
|
Patrick Plitzner
|
return managedForm.getForm().getBody();
|
710 |
|
|
}
|
711 |
|
|
|
712 |
65514c8c
|
Patrick Plitzner
|
public EMenuService getMenuService() {
|
713 |
|
|
return menuService;
|
714 |
|
|
}
|
715 |
|
|
|
716 |
|
|
public ESelectionService getSelectionService() {
|
717 |
|
|
return selService;
|
718 |
|
|
}
|
719 |
|
|
|
720 |
|
|
/**
|
721 |
|
|
* {@inheritDoc}
|
722 |
|
|
*/
|
723 |
|
|
@Override
|
724 |
|
|
public boolean canAttachMedia() {
|
725 |
|
|
return true;
|
726 |
|
|
}
|
727 |
|
|
|
728 |
a7d1d751
|
Patrick Plitzner
|
public TaxonEditorInputE4 getEditorInput() {
|
729 |
|
|
return input;
|
730 |
|
|
}
|
731 |
|
|
|
732 |
24b8f2f1
|
Patrick Plitzner
|
/**
|
733 |
|
|
* {@inheritDoc}
|
734 |
|
|
*/
|
735 |
|
|
@Override
|
736 |
|
|
public TaxonNameEditorE4 getEditor() {
|
737 |
|
|
return this;
|
738 |
|
|
}
|
739 |
|
|
|
740 |
eb6e490d
|
Katja Luther
|
@Inject
|
741 |
|
|
@Optional
|
742 |
f18400be
|
Katja Luther
|
private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_NAME_EDITOR) CdmBase cdmbase) {
|
743 |
48efbc43
|
Katja Luther
|
|
744 |
f18400be
|
Katja Luther
|
if ((EventUtility.getTaxonEditor() != null && EventUtility.getTaxonEditor().equals(this))
|
745 |
|
|
|| (this.taxon != null && (this.taxon.equals(cdmbase)
|
746 |
|
|
|| (this.taxon.getName() != null && this.taxon.getName().equals(cdmbase))))) {
|
747 |
38ac93ba
|
Katja Luther
|
this.redraw(false, true, true, true);
|
748 |
48efbc43
|
Katja Luther
|
this.setDirty();
|
749 |
f18400be
|
Katja Luther
|
if (cdmbase instanceof TaxonBase) {
|
750 |
38ac93ba
|
Katja Luther
|
this.selection = (TaxonBase) cdmbase;
|
751 |
|
|
}
|
752 |
|
|
|
753 |
eb6e490d
|
Katja Luther
|
}
|
754 |
|
|
}
|
755 |
|
|
|
756 |
9e1446d2
|
Katja Luther
|
@Inject
|
757 |
|
|
@Optional
|
758 |
|
|
private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_NAME_EDITOR) List<CdmBase> cdmBases) {
|
759 |
|
|
|
760 |
|
|
for (CdmBase cdmBase: cdmBases){
|
761 |
|
|
if (cdmBase instanceof Taxon || cdmBase instanceof TaxonName){
|
762 |
|
|
if ((EventUtility.getTaxonEditor() != null && EventUtility.getTaxonEditor().equals(this))
|
763 |
|
|
|| (this.taxon != null && (this.taxon.equals(cdmBase)
|
764 |
|
|
|| (this.taxon.getName() != null && this.taxon.getName().equals(cdmBase))))) {
|
765 |
|
|
EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class);
|
766 |
|
|
EModelService modelService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EModelService.class);
|
767 |
|
|
EditorUtil.openTaxonBaseE4(this.getTaxon().getUuid(), modelService, partService, application);
|
768 |
|
|
|
769 |
|
|
}
|
770 |
|
|
}
|
771 |
|
|
}
|
772 |
|
|
}
|
773 |
|
|
|
774 |
c799a32e
|
Katja Luther
|
@Inject
|
775 |
|
|
@Optional
|
776 |
f18400be
|
Katja Luther
|
private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_NAME_EDITOR) UUID cdmbaseUuid) {
|
777 |
c799a32e
|
Katja Luther
|
|
778 |
f18400be
|
Katja Luther
|
if (this.taxon.getUuid().equals(cdmbaseUuid)) {
|
779 |
c799a32e
|
Katja Luther
|
TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstanceFromTaxonBase(cdmbaseUuid);
|
780 |
|
|
init(input);
|
781 |
|
|
}
|
782 |
|
|
}
|
783 |
|
|
|
784 |
159247e6
|
Patrick Plitzner
|
@Inject
|
785 |
|
|
@Optional
|
786 |
f18400be
|
Katja Luther
|
private void updatefromDelete(@UIEventTopic(WorkbenchEventConstants.DELETE_DERIVATIVE) DeleteResult result) {
|
787 |
|
|
if (taxon.getName() == null) {
|
788 |
a797ba42
|
Patrick Plitzner
|
return;
|
789 |
|
|
}
|
790 |
|
|
Set<DerivedUnit> typeDesignationSpecimens = new HashSet<>();
|
791 |
f18400be
|
Katja Luther
|
this.taxon.getName().getSpecimenTypeDesignations()
|
792 |
|
|
.forEach(designation -> typeDesignationSpecimens.add(designation.getTypeSpecimen()));
|
793 |
|
|
// check if any deleted object was a type specimen
|
794 |
|
|
if (result.getUpdatedObjects().stream()
|
795 |
|
|
// filter only DerivedUnits
|
796 |
|
|
.filter(cdmBase -> cdmBase.isInstanceOf(DerivedUnit.class))
|
797 |
|
|
// deproxy from CdmBase to DerivedUnit
|
798 |
|
|
.map(unit -> HibernateProxyHelper.deproxy(unit, DerivedUnit.class))
|
799 |
|
|
// check for match in type designations
|
800 |
|
|
.anyMatch(unit -> typeDesignationSpecimens.contains(unit))) {
|
801 |
|
|
EditorUtil.updateEditor(this.input.getTaxonNode(), this);
|
802 |
38ac93ba
|
Katja Luther
|
|
803 |
a797ba42
|
Patrick Plitzner
|
}
|
804 |
48efbc43
|
Katja Luther
|
|
805 |
159247e6
|
Patrick Plitzner
|
}
|
806 |
|
|
|
807 |
123796a3
|
Katja Luther
|
/**
|
808 |
|
|
* {@inheritDoc}
|
809 |
|
|
*/
|
810 |
|
|
@Override
|
811 |
|
|
public void update() {
|
812 |
|
|
EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class);
|
813 |
|
|
EModelService modelService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EModelService.class);
|
814 |
|
|
EditorUtil.openTaxonBaseE4(this.getTaxon().getUuid(), modelService, partService, application);
|
815 |
|
|
|
816 |
|
|
}
|
817 |
|
|
|
818 |
4ff11da5
|
pplitzner
|
}
|