Project

General

Profile

Download (19.7 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9

    
10
package eu.etaxonomy.taxeditor.editor.name.e4;
11

    
12
import java.util.ArrayList;
13
import java.util.HashSet;
14
import java.util.List;
15
import java.util.Set;
16

    
17
import javax.annotation.PostConstruct;
18
import javax.annotation.PreDestroy;
19
import javax.inject.Inject;
20

    
21
import org.apache.commons.lang.StringUtils;
22
import org.eclipse.core.commands.operations.IUndoContext;
23
import org.eclipse.core.commands.operations.UndoContext;
24
import org.eclipse.core.runtime.IProgressMonitor;
25
import org.eclipse.core.runtime.OperationCanceledException;
26
import org.eclipse.e4.core.contexts.IEclipseContext;
27
import org.eclipse.e4.core.di.annotations.Optional;
28
import org.eclipse.e4.core.services.events.IEventBroker;
29
import org.eclipse.e4.ui.di.Focus;
30
import org.eclipse.e4.ui.di.Persist;
31
import org.eclipse.e4.ui.di.UIEventTopic;
32
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
33
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
34
import org.eclipse.e4.ui.services.EMenuService;
35
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
36
import org.eclipse.jface.dialogs.MessageDialog;
37
import org.eclipse.jface.viewers.ISelection;
38
import org.eclipse.jface.viewers.ISelectionProvider;
39
import org.eclipse.jface.viewers.StructuredSelection;
40
import org.eclipse.swt.dnd.DND;
41
import org.eclipse.swt.dnd.DropTarget;
42
import org.eclipse.swt.dnd.Transfer;
43
import org.eclipse.swt.graphics.Color;
44
import org.eclipse.swt.widgets.Composite;
45
import org.eclipse.ui.ISelectionListener;
46
import org.eclipse.ui.IWorkbenchPart;
47
import org.eclipse.ui.IWorkbenchPartReference;
48
import org.eclipse.ui.forms.ManagedForm;
49
import org.eclipse.ui.forms.widgets.FormToolkit;
50
import org.eclipse.ui.forms.widgets.ScrolledForm;
51
import org.eclipse.ui.forms.widgets.TableWrapLayout;
52

    
53
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
54
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
55
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
56
import eu.etaxonomy.cdm.model.common.CdmBase;
57
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
58
import eu.etaxonomy.cdm.model.taxon.Taxon;
59
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
60
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
61
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
62
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
63
import eu.etaxonomy.taxeditor.editor.CdmDataTransfer;
64
import eu.etaxonomy.taxeditor.editor.ISecuredEditor;
65
import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
66
import eu.etaxonomy.taxeditor.editor.e4.TaxonEditorInputE4;
67
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
68
import eu.etaxonomy.taxeditor.editor.name.e4.container.AbstractGroupE4;
69
import eu.etaxonomy.taxeditor.editor.name.e4.container.AbstractGroupedContainerE4;
70
import eu.etaxonomy.taxeditor.editor.name.e4.container.AcceptedGroupE4;
71
import eu.etaxonomy.taxeditor.editor.name.e4.container.AcceptedNameContainerE4;
72
import eu.etaxonomy.taxeditor.editor.name.e4.container.ContainerFactoryE4;
73
import eu.etaxonomy.taxeditor.editor.name.e4.container.HomotypicalSynonymGroupE4;
74
import eu.etaxonomy.taxeditor.editor.name.e4.container.MisappliedGroupE4;
75
import eu.etaxonomy.taxeditor.editor.name.e4.dnd.NameEditorDropTargetListenerE4;
76
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
77
import eu.etaxonomy.taxeditor.model.AbstractUtility;
78
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
79
import eu.etaxonomy.taxeditor.model.IPartChangeListener;
80
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
81
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
82
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
83
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
84
import eu.etaxonomy.taxeditor.model.MessagingUtils;
85
import eu.etaxonomy.taxeditor.model.TaxeditorPartService;
86
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
87
import eu.etaxonomy.taxeditor.preference.Resources;
88
import eu.etaxonomy.taxeditor.security.RequiredPermissions;
89
import eu.etaxonomy.taxeditor.store.CdmStore;
90
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
91

    
92
/**
93
 *
94
 * @author pplitzner
95
 * @date Aug 24, 2017
96
 *
97
 */
98
public class TaxonNameEditorE4 implements IConversationEnabled, IDirtyMarkable, IPartContentHasDetails,
99
        IPartContentHasSupplementalData, IPartContentHasMedia, IPartContentHasFactualData, IPartChangeListener,
100
        ISelectionListener, ISecuredEditor, IPostOperationEnabled, IE4SavablePart, ITaxonEditor, IDropTargetableE4 {
101

    
102
	private Taxon taxon;
103

    
104
	private ManagedForm managedForm;
105
	private ScrolledForm scrolledForm;
106
	private Composite parent;
107
	private ISelectionProvider simpleSelectionProvider;
108

    
109
	private TaxonBase selection;
110

    
111
	private ConversationHolder conversation;
112

    
113
	private AcceptedGroupE4 acceptedGroup;
114
	private List<HomotypicalSynonymGroupE4> heterotypicSynonymGroups = new ArrayList<>();
115
	private MisappliedGroupE4 misappliedGroup;
116

    
117
	private DropTarget target;
118

    
119
	private TaxonBase objectAffectedByLastOperation;
120

    
121
	@Inject
122
	private EMenuService menuService;
123

    
124
	@Inject
125
	private ESelectionService selService;
126

    
127
	@Inject
128
	private IEclipseContext context;
129

    
130
	@Inject
131
	private MDirtyable dirty;
132

    
133
	private MPart thisPart;
134

    
135
    private TaxonEditorInputE4 input;
136

    
137
    private UndoContext undoContext;
138

    
139
    @Inject
140
    private IEventBroker eventBroker;
141

    
142
	@Inject
143
	public TaxonNameEditorE4() {
144
	    undoContext = new UndoContext();
145
	}
146

    
147

    
148
	@PostConstruct
149
    public void createPartControl(Composite parent, MPart thisPart) {
150
	    this.thisPart = thisPart;
151

    
152
        createManagedForm(parent);
153

    
154
		TaxeditorPartService.getInstance().addListener(
155
				TaxeditorPartService.PART_ACTIVATED, this);
156

    
157
	}
158

    
159
	protected void createManagedForm(Composite composite) {
160

    
161
		managedForm = new ManagedForm(composite) {
162

    
163
			@Override
164
			public void dirtyStateChanged() {
165
			    dirty.setDirty(true);
166
			}
167

    
168
			@Override
169
			public boolean setInput(Object input) {
170
				if (input instanceof AbstractGroupedContainerE4) {
171
				    TaxonBase newSelection = ((AbstractGroupedContainerE4) input).getData();
172
				    if(selection!=newSelection || TaxonNameEditorE4.this.isDirty()){
173
				        selection = newSelection;
174
				        selService.setSelection(new StructuredSelection(selection));
175
				    }
176
				}else if(input == null){
177
					selection = null;
178
                    selService.setSelection(new StructuredSelection());
179
				}
180

    
181

    
182
				return super.setInput(input);
183
			}
184
		};
185

    
186
		scrolledForm = managedForm.getForm();
187
		parent = scrolledForm.getBody();
188

    
189
		parent.setData(taxon);
190

    
191
		TableWrapLayout layout = new TableWrapLayout();
192
		layout.leftMargin = 0;
193
		layout.rightMargin = 0;
194
		layout.topMargin = 0;
195
		layout.bottomMargin = 0;
196

    
197
		layout.verticalSpacing = 0;
198
		layout.horizontalSpacing = 0;
199

    
200
		parent.setLayout(layout);
201
		parent.setBackground(AbstractUtility
202
				.getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
203
	}
204

    
205
	public void createOrUpdateNameComposites() {
206
		ContainerFactoryE4.createOrUpdateAcceptedTaxonsHomotypicGroup(this);
207
		ContainerFactoryE4.createOrUpdateHeterotypicSynonymyGroups(this);
208
		ContainerFactoryE4.createOrUpdateMisapplicationsGroup(this);
209

    
210

    
211
		// Redraw composite
212
//		managedForm.reflow(true);
213
		managedForm.refresh();
214
	}
215

    
216
	@Override
217
    public Taxon getTaxon() {
218
		return HibernateProxyHelper.deproxy(taxon);
219
	}
220

    
221
	public void setDirty() {
222
		managedForm.dirtyStateChanged();
223
	}
224

    
225
	@Focus
226
	public void setFocus() {
227
	    //make sure to bind again if maybe in another view the conversation was unbound
228
        if(conversation!=null && !conversation.isBound()){
229
            conversation.bind();
230
        }
231

    
232
	    if(input!=null){
233
	        if (getSelectedContainer() == null) {
234
	            throw new IllegalStateException(
235
	                    Messages.TaxonNameEditor_THERE_SHOULD_ALWAYS_BE);
236
	        }
237
	        getSelectedContainer().setSelected();
238
	        if (!input.getCdmEntitySession().isActive()){
239
	            input.bind();
240
	        }
241

    
242
	        // check permissions
243
	        boolean doEnable = permissionsSatisfied();
244
	        managedForm.getForm().setEnabled(doEnable);
245
	    }
246
        eventBroker.post(WorkbenchEventConstants.CURRENT_ACTIVE_EDITOR, this);
247
	}
248

    
249
	@Override
250
	public boolean permissionsSatisfied() {
251
		TaxonNode taxonNode = input.getTaxonNode();
252
		boolean doEnable = CdmStore.currentAuthentiationHasPermission(taxonNode, RequiredPermissions.TAXONNODE_EDIT);
253
		return doEnable;
254
	}
255

    
256
	@Override
257
    public ConversationHolder getConversationHolder() {
258
		return conversation;
259
	}
260

    
261
	/** {@inheritDoc} */
262
	@Override
263
    public void update(CdmDataChangeMap events) {
264
		// redraw();
265
	}
266

    
267
	/**
268
	 * Redraws this editor return true on success
269
	 *
270
	 * @return a boolean.
271
	 */
272
    public boolean redraw() {
273
		return redraw(true);
274
	}
275

    
276
	/**
277
	 * {@inheritDoc}
278
	 *
279
	 * Redraws the editor controls
280
	 */
281
    public boolean redraw(boolean focus) {
282

    
283
		createOrUpdateNameComposites();
284

    
285
		if (focus) {
286
			setFocus();
287
		}
288

    
289
		return true;
290
	}
291

    
292
	@Override
293
    public boolean postOperation(CdmBase objectAffectedByOperation) {
294

    
295
		changed(objectAffectedByOperation);
296

    
297
		redraw(false);
298

    
299
		if (objectAffectedByOperation instanceof TaxonBase) {
300
			objectAffectedByLastOperation = (TaxonBase) objectAffectedByOperation;
301
		}
302

    
303
		return true;
304
	}
305

    
306
	public ManagedForm getManagedForm() {
307
		return managedForm;
308
	}
309

    
310

    
311
	/**
312
	 * <p>
313
	 * checkForEmptyNames
314
	 * </p>
315
	 *
316
	 * @return true if there are empty names
317
	 */
318
	public boolean checkForEmptyNames() {
319
		for (AbstractGroupedContainerE4 container : getGroupedContainers()) {
320
			if (container.getName() == null
321
					|| StringUtils.isEmpty(container.getName().getTitleCache())) {
322
				return true;
323
			}
324
		}
325
		return false;
326
	}
327

    
328
	public Set<AbstractGroupedContainerE4> getEmptyContainers() {
329
		Set<AbstractGroupedContainerE4> containersWithEmptyNames = new HashSet<>();
330

    
331
		for (AbstractGroupedContainerE4 container : getGroupedContainers()) {
332
			if (container.getName() == null
333
					|| StringUtils.isEmpty(container.getName().getTitleCache())) {
334
				containersWithEmptyNames.add(container);
335
			}
336
		}
337

    
338
		return containersWithEmptyNames;
339
	}
340

    
341
	/** {@inheritDoc} */
342
	@Override
343
    @Persist
344
	public void save(IProgressMonitor monitor) {
345

    
346
	    monitor.beginTask(Messages.TaxonNameEditor_SAVING_NAMES, getGroupedContainers().size());
347
	    if (!conversation.isBound()) {
348
	        conversation.bind();
349

    
350
	    }
351
	    conversation.commit(true);
352
	    monitor.worked(1);
353

    
354
	    // check for empty names
355
	    if (checkForEmptyNames()) {
356
	        MessageDialog.openWarning(AbstractUtility.getShell(), Messages.MultiPageTaxonEditor_NO_NAME_SPECIFIED,
357
	                Messages.MultiPageTaxonEditor_NO_NAME_SPECIFIED_MESSAGE);
358
	        return;
359
	    }
360
	    for (AbstractGroupedContainerE4 container : getGroupedContainers()) {
361

    
362
	        monitor.subTask(Messages.TaxonNameEditor_SAVING_COMPOSITES
363
	                + container.getTaxonBase().getTitleCache());
364
	        container.persistName();
365

    
366
	        // In case the progress monitor was canceled throw an exception.
367
	        if (monitor.isCanceled()) {
368
	            throw new OperationCanceledException();
369
	        }
370

    
371
	     // Otherwise declare this step as done.
372
	        monitor.worked(1);
373

    
374
	    }
375
	    input.merge();
376
	    // commit the conversation and start a new transaction immediately
377
        conversation.commit(true);
378

    
379

    
380
        dirty.setDirty(false);
381

    
382
	    // Stop the progress monitor.
383
	    monitor.done();
384
	}
385

    
386
	public void init(TaxonEditorInputE4 input) {
387
		if (this.input != null){
388
			this.input.dispose();
389
		}
390
		if (!(input != null)) {
391
            MessagingUtils.error(this.getClass(), new Exception(Messages.TaxonNameEditor_INVALID_INPUT));
392
            return;
393
        }
394

    
395
		if (input.getAdapter(Taxon.class) != null) {
396
			taxon = CdmBase.deproxy(input.getAdapter(Taxon.class), Taxon.class);
397
		} else {
398
		    MessagingUtils.error(this.getClass(), new Exception(Messages.TaxonNameEditor_INVALID_INPUT_TAXON_NULL));
399
		    return;
400
		}
401

    
402
		this.input = input;
403
		conversation = input.getConversationHolder();
404

    
405
        createOrUpdateNameComposites();
406

    
407
        createDragSupport();
408

    
409
        setPartName();
410

    
411
        //set initial selection
412
        TaxonBase initiallySelectedTaxonBase = input.getInitiallySelectedTaxonBase();
413
        if(initiallySelectedTaxonBase!=null){
414
            selService.setSelection(new StructuredSelection(initiallySelectedTaxonBase));
415
            getContainer(initiallySelectedTaxonBase).setSelected();
416
        }
417
	}
418

    
419
   private void createDragSupport() {
420
       // Listen for names being dragged outside of existing homotypic groups -
421
       // user wants to create a new group
422
       Transfer[] types = new Transfer[] { CdmDataTransfer.getInstance() };
423
       int operations = DND.DROP_MOVE;
424
       if (target == null) {
425
           target = new DropTarget(parent, operations);
426
           target.setTransfer(types);
427
           target.addDropListener(new NameEditorDropTargetListenerE4(this));
428
       }
429
   }
430

    
431
	public AcceptedNameContainerE4 getAcceptedNameContainer() {
432
		return getAcceptedGroup().getAcceptedNameContainer();
433
	}
434

    
435
	public HomotypicalSynonymGroupE4 getHomotypicalGroupContainer(
436
			HomotypicalGroup homotypicalGroup) {
437
		for (HomotypicalSynonymGroupE4 group : getHeterotypicSynonymGroups()) {
438
			if (group.getGroup().equals(homotypicalGroup)) {
439
				return group;
440
			}
441
		}
442

    
443
		return null;
444
	}
445

    
446
	/**
447
	 * <p>
448
	 * getDirtyNames
449
	 * </p>
450
	 *
451
	 * @return a Set containing all composites that have been edited
452
	 */
453
	public Set<AbstractGroupedContainerE4> getDirtyNames() {
454
		Set<AbstractGroupedContainerE4> dirtyNames = new HashSet<>();
455

    
456
		for (AbstractGroupedContainerE4 composite : getGroupedContainers()) {
457
			if (composite.isDirty()) {
458
				dirtyNames.add(composite);
459
			}
460
		}
461

    
462
		return dirtyNames;
463
	}
464

    
465
	public List<AbstractGroupedContainerE4> getGroupedContainers() {
466
		List<AbstractGroupedContainerE4> groupedComposites = new ArrayList<>();
467

    
468
		for (AbstractGroupE4 group : getAllGroups()) {
469
		    if (group!= null){
470
		        groupedComposites.addAll(group.getGroupedContainers());
471
		    }
472
		}
473

    
474
		return groupedComposites;
475
	}
476

    
477
	public List<AbstractGroupE4> getAllGroups() {
478
		List<AbstractGroupE4> allGroups = new ArrayList<>();
479

    
480
		allGroups.add(getAcceptedGroup());
481

    
482
		heterotypicSynonymGroups = getHeterotypicSynonymGroups();
483

    
484
		if (heterotypicSynonymGroups != null) {
485
			allGroups.addAll(heterotypicSynonymGroups);
486
		}
487

    
488
		if (misappliedGroup != null) {
489
			allGroups.add(misappliedGroup);
490
		}
491

    
492
		return allGroups;
493
	}
494

    
495
	@Override
496
	public IEclipseContext getContext() {
497
	    return context;
498
	}
499

    
500
	public boolean isDirty() {
501
		return dirty.isDirty();
502
	}
503

    
504
	@PreDestroy
505
	public void dispose() {
506
        if(conversation!=null){
507
            conversation.unregisterForDataStoreChanges(this);
508
            conversation.close();
509
        }
510
        if(input!=null){
511
            input.dispose();
512
        }
513
        eventBroker.post(WorkbenchEventConstants.CURRENT_ACTIVE_EDITOR, null);
514
	}
515

    
516
	/** {@inheritDoc} */
517
	@Override
518
    public void selectionChanged(IWorkbenchPart part, ISelection selection) {
519

    
520
	}
521

    
522
	public AbstractGroupedContainerE4 getSelectedContainer() {
523
		return (selection != null) ? getContainer(selection)
524
				: getAcceptedNameContainer();
525
	}
526

    
527
    @Override
528
    public void dragEntered() {
529
        // TODO change this
530
        getControl().setBackground(
531
                AbstractUtility.getColor(Resources.COLOR_DRAG_ENTER));
532
    }
533

    
534
    @Override
535
    public void dragLeft() {
536
        getControl().setBackground(
537
                AbstractUtility.getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
538
    }
539

    
540

    
541
	public void setMisapplicationsGroup(MisappliedGroupE4 misappliedGroup) {
542
		this.misappliedGroup = misappliedGroup;
543
	}
544

    
545
	public FormToolkit getToolkit() {
546
		return managedForm.getToolkit();
547
	}
548

    
549
	public List<HomotypicalSynonymGroupE4> getHeterotypicSynonymGroups() {
550
		return heterotypicSynonymGroups;
551
	}
552

    
553
	public void addHeterotypicSynonymGroup(HomotypicalSynonymGroupE4 group) {
554
		heterotypicSynonymGroups.add(group);
555
	}
556

    
557
	public AcceptedGroupE4 getAcceptedGroup() {
558
		return acceptedGroup;
559
	}
560

    
561
	public void setAcceptedGroup(AcceptedGroupE4 acceptedGroup) {
562
		this.acceptedGroup = acceptedGroup;
563
	}
564

    
565
	public MisappliedGroupE4 getMisappliedGroup() {
566
		return misappliedGroup;
567
	}
568

    
569
	public boolean isActive() {
570
		return this.equals(AbstractUtility.getActivePart());
571
	}
572

    
573
    @Override
574
    public boolean onComplete() {
575
		getContainer(objectAffectedByLastOperation).setSelected();
576
		return true;
577
	}
578

    
579
	/** {@inheritDoc} */
580
	@Override
581
    public void partChanged(Integer eventType, IWorkbenchPartReference partRef) {
582
		if (!partRef.getPart(false).equals(this)) {
583
			// getSelectedObject().colorSelected(AbstractGroupedContainer.SELECTED_NO_FOCUS);
584
		}
585
	}
586

    
587
	public void removeGroup(AbstractGroupE4 group) {
588
		if (group != null) {
589
			group.dispose();
590

    
591
			//if (heterotypicSynonymGroups != null) {
592
			heterotypicSynonymGroups.remove(group);
593
			//}
594
		}
595
	}
596

    
597
	public AbstractGroupedContainerE4 getContainer(TaxonBase taxonBase) {
598
		List<AbstractGroupedContainerE4> groupedContainers = getGroupedContainers();
599
		for (AbstractGroupedContainerE4 container : groupedContainers) {
600
			if (container.getData().equals(taxonBase)
601
					&& container.getNameViewer().getTextWidget() != null) {
602
				return container;
603
			}
604
		}
605
		return getAcceptedNameContainer();
606
	}
607

    
608
    public void setOnError() {
609
		Color disabledColor =  AbstractUtility.getColor(Resources.COLOR_EDITOR_ERROR);
610
		setEnabled(false, disabledColor);
611
	}
612

    
613
	public void setDisabled(){
614
		Color disabledColor =  AbstractUtility.getColor(Resources.COLOR_TEXT_DISABLED_BACKGROUND);
615
		setEnabled(false, disabledColor);
616
	}
617

    
618
	protected void setEnabled(boolean enabled, Color background) {
619

    
620
		for(AbstractGroupedContainerE4 groupedContainer : getGroupedContainers()){
621
			groupedContainer.setEnabled(enabled);
622
		}
623

    
624
		// send an empty selection to the current provider - TODO only on error ???
625
		if (!enabled) {
626
			getManagedForm().setInput(null);
627

    
628
			for (AbstractGroupedContainerE4 groupedContainer : getGroupedContainers()) {
629
				groupedContainer.setBackground(background);
630
			}
631
		}
632
		getControl().setBackground(background);
633
	}
634

    
635
    @Override
636
    public void changed(Object element) {
637
        // setDirty(true);
638
        // if the attribute is null then do not set the dirty flag -> hotfix for the problem that for tasks done in service methods the changes are saved automatically
639
        if (element != null){
640
            dirty.setDirty(true);
641
            //refresh part title
642
            //TODO: refresh taxon node in taxon navigator
643
            setPartName();
644
        }
645

    
646
        if (element instanceof TaxonBase) {
647
            AbstractGroupedContainerE4 container = getContainer((TaxonBase) element);
648
            if (container != null) {
649
                container.refresh();
650
            }
651
        }
652
        if (element instanceof TaxonRelationship) {
653
            AbstractGroupedContainerE4 container = getContainer(((TaxonRelationship) element).getFromTaxon());
654
            if (container != null) {
655
                container.refresh();
656
            }
657
        }
658
    }
659

    
660
    public void setPartName(){
661
        thisPart.setLabel(this.taxon.getName().getFullTitleCache());
662
    }
663

    
664
    @Override
665
    public void forceDirty() {
666
        setDirty();
667
    }
668

    
669

    
670
    public IUndoContext getUndoContext() {
671
        return undoContext;
672
    }
673

    
674
    @Override
675
    public Composite getControl(){
676
        return managedForm.getForm().getBody();
677
    }
678

    
679
    public EMenuService getMenuService() {
680
        return menuService;
681
    }
682

    
683
    public ESelectionService getSelectionService() {
684
        return selService;
685
    }
686

    
687

    
688
    /**
689
     * {@inheritDoc}
690
     */
691
    @Override
692
    public boolean canAttachMedia() {
693
        return true;
694
    }
695

    
696
    public TaxonEditorInputE4 getEditorInput() {
697
        return input;
698
    }
699

    
700
    /**
701
     * {@inheritDoc}
702
     */
703
    @Override
704
    public TaxonNameEditorE4 getEditor() {
705
        return this;
706
    }
707

    
708
    @Inject
709
    @Optional
710
    private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_NAME_EDITOR)boolean refresh){
711
        if(refresh){
712
            this.redraw();
713
            setDirty();
714
        }
715
    }
716

    
717
}
(2-2/2)