ref #9537: new label for ratio to
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / EditorUtil.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 package eu.etaxonomy.taxeditor.editor;
10
11 import java.util.Collection;
12 import java.util.HashSet;
13 import java.util.List;
14 import java.util.UUID;
15
16 import org.eclipse.core.commands.ExecutionEvent;
17 import org.eclipse.core.commands.operations.IOperationHistory;
18 import org.eclipse.core.commands.operations.IUndoContext;
19 import org.eclipse.e4.ui.model.application.MApplication;
20 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
21 import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
22 import org.eclipse.e4.ui.workbench.modeling.EModelService;
23 import org.eclipse.e4.ui.workbench.modeling.EPartService;
24 import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
25 import org.eclipse.jface.dialogs.MessageDialog;
26 import org.eclipse.jface.viewers.ISelection;
27 import org.eclipse.jface.viewers.IStructuredSelection;
28 import org.eclipse.jface.viewers.TreeNode;
29 import org.eclipse.swt.widgets.Shell;
30 import org.eclipse.ui.IEditorPart;
31 import org.eclipse.ui.handlers.HandlerUtil;
32
33 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
34 import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
35 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
36 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
37 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
38 import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
39 import eu.etaxonomy.cdm.model.taxon.Synonym;
40 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
41 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
42 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
43 import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
44 import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
45 import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput;
46 import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.DescriptiveDataSetEditor;
47 import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixPart;
48 import eu.etaxonomy.taxeditor.editor.e4.TaxonEditorInputE4;
49 import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditorInput;
50 import eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4;
51 import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
52 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
53 import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
54 import eu.etaxonomy.taxeditor.editor.view.checklist.e4.DistributionEditorPart;
55 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
56 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
57 import eu.etaxonomy.taxeditor.model.AbstractUtility;
58 import eu.etaxonomy.taxeditor.model.MessagingUtils;
59 import eu.etaxonomy.taxeditor.security.RequiredPermissions;
60 import eu.etaxonomy.taxeditor.store.CdmStore;
61 import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
62 import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
63
64 /**
65 * Utility for the editor package
66 *
67 * @author n.hoffmann
68 * @created 20.01.2009
69 */
70 public class EditorUtil extends AbstractUtility {
71
72 private static final String NAME_EDITOR_ID = "eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4";
73
74 private static boolean factsVisible = true;
75
76 private static boolean mediaVisible = true;
77
78 public static void openDescriptiveDataSetEditor(UUID descriptiveDataSetUuid, EModelService modelService, EPartService partService, MApplication application){
79 Collection<MPart> parts = partService.getParts();
80 for (MPart part : parts) {
81 if(part.getObject() instanceof DescriptiveDataSetEditor
82 && ((DescriptiveDataSetEditor) part.getObject()).getDescriptiveDataSet().getUuid().equals(descriptiveDataSetUuid)){
83 partService.showPart(part, PartState.ACTIVATE);
84 return;
85 }
86 }
87 String partId = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DESCRIPTIVEDATASET_DESCRIPTIVEDATASETEDITOR;
88 MPart part = showPart(partId, modelService, partService, application);
89 DescriptiveDataSetEditor editor = (DescriptiveDataSetEditor) part.getObject();
90 editor.init(descriptiveDataSetUuid);
91 }
92
93 public static void openCharacterMatrix(UUID descriptiveDataSetUuid, EModelService modelService, EPartService partService, MApplication application){
94 Collection<MPart> parts = partService.getParts();
95 for (MPart part : parts) {
96 if(part.getObject() instanceof CharacterMatrixPart
97 && ((CharacterMatrixPart) part.getObject()).getDescriptiveDataSet().getUuid().equals(descriptiveDataSetUuid)){
98 partService.showPart(part, PartState.ACTIVATE);
99 return;
100 }
101 }
102 String partId = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_DESCRIPTIVEDATASET_MATRIX_CHARACTERMATRIXPART;
103 MPart part = showPart(partId, modelService, partService, application);
104 CharacterMatrixPart editor = (CharacterMatrixPart) part.getObject();
105 editor.init(descriptiveDataSetUuid, true);
106 }
107
108 public static void openDistributionEditor(List<UuidAndTitleCache<ITaxonTreeNode>> parentTaxonUuidList, EModelService modelService, EPartService partService, MApplication application){
109 String partId = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CHECKLIST_E4_DISTRIBUTIONEDITORPART;
110 checkAndCloseFactsAndMediaParts(partService);
111 MPart part = showPart(partId, modelService, partService, application);
112 DistributionEditorPart editor = (DistributionEditorPart) part.getObject();
113 editor.init(parentTaxonUuidList);
114 }
115
116 public static void checkAndCloseFactsAndMediaParts(EPartService partService) {
117 String partIdFactualData = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DESCRIPTIVE_E4_FACTUALDATAPARTE4;
118 String partIdMedia = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_MEDIA_E4_MEDIAVIEWPARTE4;
119 MPart part1 = partService.findPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DESCRIPTIVE_E4_FACTUALDATAPARTE4);
120 if (factsVisible || (part1!=null && part1.getWidget() != null && partService.isPartVisible(part1))){
121 factsVisible = true;
122 }else{
123 factsVisible = false;
124 }
125 part1 = partService.findPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_MEDIA_E4_MEDIAVIEWPARTE4);
126 if (mediaVisible || (part1!=null && part1.getWidget() != null && partService.isPartVisible(part1))){
127 mediaVisible = true;
128 }else{
129 mediaVisible = false;
130 }
131 closePart(partIdMedia, partService);
132 closePart(partIdFactualData, partService);
133 }
134
135
136 public static void openSpecimenEditor(DerivateViewEditorInput input, EModelService modelService, EPartService partService, MApplication application){
137 String partId = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW;
138 MPart part = showPart(partId, modelService, partService, application);
139 DerivateView derivateView = (DerivateView) part.getObject();
140 derivateView.init(input);
141 }
142
143 public static void openRightsEditor(CdmAuthorityEditorInput input, EModelService modelService, EPartService partService, MApplication application){
144 Collection<MPart> parts = partService.getParts();
145 for (MPart part : parts) {
146 if(part.getObject() instanceof CdmAuthorityEditorE4
147 && ((CdmAuthorityEditorE4) part.getObject()).getInput().getGroup().equals(input.getGroup())){
148 partService.showPart(part, PartState.ACTIVATE);
149 return;
150 }
151 }
152 String partId = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_GROUP_AUTHORITY_E4_CDMAUTHORITYEDITORE4;
153 MPart part = showPart(partId, modelService, partService, application);
154 CdmAuthorityEditorE4 authorityView = (CdmAuthorityEditorE4) part.getObject();
155 authorityView.init(input);
156 }
157
158 public static MPart showPart(String partId, EModelService modelService, EPartService partService, MApplication application){
159 MPart part = partService.findPart(partId);
160 if(part==null || modelService.getPartDescriptor(partId).isAllowMultiple()){
161 part = partService.createPart(partId);
162 }
163 MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
164 if(editorAreaPartStack!=null){
165 editorAreaPartStack.getChildren().add(part);
166 }
167
168 return partService.showPart(part, PartState.ACTIVATE);
169
170 }
171
172 public static MPart showPart(String partId, EModelService modelService, EPartService partService){
173 MPart part = partService.findPart(partId);
174 if(part==null || modelService.getPartDescriptor(partId).isAllowMultiple()){
175 part = partService.createPart(partId);
176 partService.activate(part);
177 }else{
178 partService.activate(part);
179 }
180
181 return part;
182 }
183
184 public static void openTaxonNodeE4(UUID taxonNodeUuid, EModelService modelService, EPartService partService, MApplication application) {
185 TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstance(taxonNodeUuid);
186 openNameEditor_internal(input, modelService, partService, application);
187 }
188
189 public static void openTaxonBaseE4(UUID taxonBaseUuid, EModelService modelService, EPartService partService, MApplication application) {
190 TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstanceFromTaxonBase(taxonBaseUuid);
191 openNameEditor_internal(input, modelService, partService, application);
192 }
193
194 public static void openTaxonBaseE4(UUID taxonBaseUuid) {
195 //FIXME E4 this can probably be removed when fully migrated
196 TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstanceFromTaxonBase(taxonBaseUuid);
197
198 EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class);
199 EModelService modelService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EModelService.class);
200 openNameEditor_internal(input, modelService, partService, null);
201 }
202
203 private static void openNameEditor_internal(TaxonEditorInputE4 input, EModelService modelService, EPartService partService, MApplication application) {
204 TaxonBase<?> taxonBase = input.getTaxon();
205 TaxonNode node = input.getTaxonNode();
206 if(taxonBase==null){
207 return;
208 }
209 boolean hasPermission = false;
210 // if (node != null){
211 hasPermission = CdmStore.currentAuthentiationHasPermission(node, RequiredPermissions.TAXON_EDIT);
212 // }
213 // if (!hasPermission){
214 // MessagingUtils.warningDialog(Messages.EditorUtil_MISSING_PERMISSION, TaxonEditorInputE4.class, Messages.EditorUtil_MISSING_PERMISSION_MESSAGE);
215 // return;
216 // }
217 if (taxonBase.isOrphaned()) {
218 if(taxonBase.isInstanceOf(Synonym.class)){
219 MessagingUtils.warningDialog(Messages.EditorUtil_ORPHAN_ACCEPTED_TAXON, TaxonEditorInputE4.class, Messages.EditorUtil_ORPHAN_ACCEPTED_TAXON_MESSAGE);
220 return;
221 }
222 else{
223 MessagingUtils.warningDialog(Messages.EditorUtil_ORPHAN_TAXON, TaxonEditorInputE4.class, Messages.EditorUtil_ORPHAN_TAXON_MESSAGE);
224 return;
225 }
226 }
227
228 Collection<MPart> parts = partService.getParts();
229 //check if part is already opened
230 for (MPart part : parts) {
231 if(part.getObject() instanceof TaxonNameEditorE4
232 && ((TaxonNameEditorE4) part.getObject()).getTaxon()!=null
233 && ((TaxonNameEditorE4) part.getObject()).getTaxon().getUuid().equals(input.getTaxon().getUuid())){
234 if (part.isDirty()){
235 forceUserSaveE4Editor(((TaxonNameEditorE4) part.getObject()), getShell());
236 }
237 partService.hidePart(part);
238 break;
239 }
240 }
241 MPart part = showPart(NAME_EDITOR_ID, modelService, partService, application);
242
243 TaxonNameEditorE4 editor = (TaxonNameEditorE4) part.getObject();
244 // editor.setDisabled();
245 editor.init(input);
246 // editor.setEnabled();
247 editor.setFocus();
248 if (factsVisible){
249 showFacts(modelService, partService);
250 factsVisible = false;
251 }
252
253 if (mediaVisible){
254 showMedia(modelService, partService);
255 mediaVisible = false;
256 }
257 }
258
259 public static void showMedia(EModelService modelService, EPartService partService) {
260 String partIdFactualData = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_MEDIA_E4_MEDIAVIEWPARTE4;
261 showPart(partIdFactualData, modelService, partService);
262
263 }
264
265 public static void showFacts(EModelService modelService, EPartService partService) {
266 String partIdFactualData = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DESCRIPTIVE_E4_FACTUALDATAPARTE4;
267 showPart(partIdFactualData, modelService, partService);
268
269 }
270
271 public static Collection<MPart> checkForChanges(UUID taxonUUID, EPartService partService ){
272 Collection<MPart> parts = partService.getParts();
273 Collection<MPart> dirtyParts = new HashSet();
274 //check if part is already opened
275 boolean isDirty = false;
276 for (MPart part : parts) {
277 if(part.getObject() instanceof TaxonNameEditorE4
278 && ((TaxonNameEditorE4) part.getObject()).getTaxon()!=null
279 && ((TaxonNameEditorE4) part.getObject()).getTaxon().getUuid().equals(taxonUUID)){
280 if (part.isDirty()){
281 dirtyParts.add(part);
282 }
283
284 break;
285 }else if (taxonUUID == null){
286 if (part.isDirty()){
287 dirtyParts.add(part);
288 }
289 }
290 }
291 return dirtyParts;
292 }
293
294 public static Collection<IE4SavablePart> checkForTaxonChanges(UUID taxonUUID, EPartService partService ){
295 Collection<MPart> parts = partService.getParts();
296 Collection<IE4SavablePart> dirtyParts = new HashSet<>();
297 //check if part is already opened
298 for (MPart part : parts) {
299 if(part.getObject() instanceof TaxonNameEditorE4
300 && ((TaxonNameEditorE4) part.getObject()).getTaxon()!=null
301 && ((TaxonNameEditorE4) part.getObject()).getTaxon().getUuid().equals(taxonUUID)){
302 if (part.isDirty()){
303 dirtyParts.add((IE4SavablePart) part);
304 }
305
306 break;
307 }else if (taxonUUID == null){
308 if (part.isDirty() && (part.getObject() instanceof TaxonNameEditorE4 || (part.getObject() instanceof BulkEditorE4 && ((BulkEditorE4)part.getObject()).getEditorInput() instanceof TaxonEditorInput))){
309 dirtyParts.add((IE4SavablePart) part.getObject());
310 }
311 }
312 }
313 return dirtyParts;
314 }
315
316 /**
317 * An uninitialized taxon is one that hasn't been saved yet. As such, it
318 * should appear in neither the list of recent names nor in the taxonomic
319 * tree when opened.
320 *
321 * @param parentNodeUuid
322 * a {@link java.util.UUID} object.
323 */
324 public static void openEmptyE4(UUID parentNodeUuid) {
325 TaxonEditorInputE4 input = TaxonEditorInputE4
326 .NewEmptyInstance(parentNodeUuid);
327 EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class);
328 MPart part = partService.createPart(NAME_EDITOR_ID);
329 part = partService.showPart(part, PartState.ACTIVATE);
330 TaxonNameEditorE4 editor = (TaxonNameEditorE4) part.getObject();
331 editor.init(input);
332 }
333
334 /**
335 * <p>
336 * getUndoContext
337 * </p>
338 *
339 * @return a {@link org.eclipse.core.commands.operations.IUndoContext}
340 * object.
341 */
342 public static IUndoContext getUndoContext() {
343 return IOperationHistory.GLOBAL_UNDO_CONTEXT;
344 }
345
346 public static boolean isFactsVisible() {
347 return factsVisible;
348 }
349
350 public static void setFactsVisible(boolean factsVisible) {
351 EditorUtil.factsVisible = factsVisible;
352 }
353
354 public static boolean isMediaVisible() {
355 return mediaVisible;
356 }
357
358 public static void setMediaVisible(boolean mediaVisible) {
359 EditorUtil.mediaVisible = mediaVisible;
360 }
361
362 /**
363 * <p>
364 * forceUserSave
365 * </p>
366 *
367 * @param editor
368 * a {@link org.eclipse.ui.IEditorPart} object.
369 * @param shell
370 * a {@link org.eclipse.swt.widgets.Shell} object.
371 * @return a boolean.
372 */
373 public static boolean forceUserSave(IEditorPart editor, Shell shell) {
374 if (editor.isDirty()) {
375
376 boolean doSave = MessageDialog
377 .openConfirm(shell, Messages.EditorUtil_COMFIRM_SAVE,
378 Messages.EditorUtil_CONFIRM_SAVE_MESSAGE);
379
380 if (!doSave) {
381 return false;
382 }
383
384 editor.doSave(AbstractUtility.getMonitor());
385 }
386 return true;
387 }
388
389 public static boolean forceUserSaveE4Editor(IE4SavablePart editor, Shell shell) {
390 if (editor.isDirty()) {
391
392 boolean doSave = MessageDialog
393 .openConfirm(shell, Messages.EditorUtil_COMFIRM_SAVE,
394 Messages.EditorUtil_CONFIRM_SAVE_MESSAGE);
395
396 if (!doSave) {
397 return false;
398 }
399
400 editor.save(AbstractUtility.getMonitor());
401 }
402 return true;
403 }
404
405 /**
406 * <p>
407 * getSelection
408 * </p>
409 *
410 * @param event
411 * a {@link org.eclipse.core.commands.ExecutionEvent} object.
412 * @return a {@link org.eclipse.jface.viewers.IStructuredSelection} object.
413 */
414 public static IStructuredSelection getSelection(ExecutionEvent event) {
415 IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
416
417 return (IStructuredSelection) activeEditor.getSite()
418 .getSelectionProvider().getSelection();
419 }
420
421 /**
422 * <p>
423 * getPluginId
424 * </p>
425 *
426 * @return a {@link java.lang.String} object.
427 */
428 public static String getPluginId() {
429 return TaxeditorEditorPlugin.PLUGIN_ID;
430 }
431
432 /**
433 * Iterates recursively over all originals having the given specimen as a derivate.
434 * The first {@link DerivedUnit} with no more originals or the first {@link FieldUnit} is returned
435 * @param specimen the start element for which the originals are iterated recursively
436 * @return either a FieldUnit or a the topmost DerivedUnit (which can be itself)
437 */
438 public static SpecimenOrObservationBase<?> getTopMostDerivate(SpecimenOrObservationBase<?> specimen){
439 if(specimen==null){
440 return null;
441 }
442 if(specimen.isInstanceOf(FieldUnit.class)){
443 return specimen;
444 }
445 else if(specimen.isInstanceOf(DerivedUnit.class)){
446 DerivedUnit derivedUnit = HibernateProxyHelper.deproxy(specimen, DerivedUnit.class);
447 if(derivedUnit.getOriginals()!=null
448 && !(derivedUnit.getOriginals().isEmpty())){
449 for(SpecimenOrObservationBase<?> original:((DerivedUnit) specimen).getOriginals()){
450 return getTopMostDerivate(original);
451 }
452 }
453 }
454 return specimen;
455 }
456
457 /**
458 * If the current selection is a single {@link TreeNode} it will be returned.
459 * @param selection the selection to check
460 * @return the selected TreeNode or <code>null</code> if no TreeNode selected
461 */
462 public static TreeNode getTreeNodeOfSelection(ISelection selection){
463 if(selection instanceof IStructuredSelection
464 && ((IStructuredSelection) selection).size()==1
465 && ((IStructuredSelection) selection).getFirstElement() instanceof TreeNode){
466 return (TreeNode) ((IStructuredSelection) selection).getFirstElement();
467
468 }
469 return null;
470 }
471
472 public static void closeObsoleteEditor(TaxonNodeDto taxonNode, EPartService partService){
473 String treeIndex = taxonNode.getTreeIndex();
474 Collection<MPart> parts = partService.getParts();
475 for (MPart part : parts) {
476 Object object = part.getObject();
477 if(object instanceof TaxonNameEditorE4){
478 TaxonNameEditorE4 taxonEditor = (TaxonNameEditorE4)object;
479 TaxonNode node = taxonEditor.getEditorInput().getTaxonNode();
480 if (node.treeIndex()!= null){
481 if(node.treeIndex().startsWith(treeIndex)){
482 if (part.isDirty()){
483 forceUserSaveE4Editor(taxonEditor, getShell());
484 }
485 partService.hidePart(part);
486 }
487 }else{
488 logger.debug("The taxonnode of taxon " + node.getTaxon().getTitleCache() + " uuid: " + node.getUuid() + " has no treeindex");;
489 }
490 }
491 }
492 }
493
494 public static void closeObsoleteEditorWithChildren(TaxonNodeDto taxonNode, EPartService partService){
495 String treeIndex = taxonNode.getTreeIndex();
496 Collection<MPart> parts = partService.getParts();
497 for (MPart part : parts) {
498 Object object = part.getObject();
499 if(object instanceof TaxonNameEditorE4){
500 TaxonNameEditorE4 taxonEditor = (TaxonNameEditorE4)object;
501 TaxonNode node = taxonEditor.getEditorInput().getTaxonNode();
502 if (node.treeIndex()!= null){
503 if(node.treeIndex().startsWith(treeIndex)){
504 if (part.isDirty()){
505 forceUserSaveE4Editor(taxonEditor, getShell());
506 }
507 partService.hidePart(part);
508 }
509 }else{
510 logger.debug("The taxonnode of taxon " + node.getTaxon().getTitleCache() + " uuid: " + node.getUuid() + " has no treeindex");;
511 }
512 }
513 }
514 }
515
516 public static void closeObsoleteDescriptiveDatasetEditor(UUID datasetUuid, EPartService partService){
517
518 Collection<MPart> parts = partService.getParts();
519 for (MPart part : parts) {
520 Object object = part.getObject();
521 if(object instanceof DescriptiveDataSetEditor){
522 DescriptiveDataSetEditor editor = (DescriptiveDataSetEditor)object;
523 DescriptiveDataSet descDataSet = editor.getDescriptiveDataSet();
524 if(descDataSet.getUuid().equals(datasetUuid)){
525 if (part.isDirty()){
526 forceUserSaveE4Editor(editor, getShell());
527 }
528 partService.hidePart(part);
529 }
530
531 }
532 }
533 }
534
535 public static void closePart(String partID, EPartService partService){
536
537 Collection<MPart> parts = partService.getParts();
538 for (MPart part : parts) {
539 String elementId = part.getElementId();
540 if (elementId.equals(partID)){
541 partService.hidePart(part);
542 }
543 }
544 }
545
546 public static void updateEditor(TaxonNode taxonNode, TaxonNameEditorE4 editor){
547 String treeIndex = taxonNode.treeIndex();
548 TaxonNode node = editor.getEditorInput().getTaxonNode();
549 if(node.treeIndex().equals(treeIndex)){
550 TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstance(node.getUuid());
551 editor.init(input);
552 }
553 }
554 }