Project

General

Profile

« Previous | Next » 

Revision bd3e8f2b

Added by Katja Luther about 8 years ago

fix #5641

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeToMisapplicationHandler.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
16 16
import org.eclipse.core.commands.ExecutionException;
17 17
import org.eclipse.core.commands.IHandler;
18 18
import org.eclipse.core.commands.common.NotDefinedException;
19
import org.eclipse.swt.widgets.Shell;
20
import org.eclipse.ui.handlers.HandlerUtil;
19 21

  
20 22
import eu.etaxonomy.cdm.model.taxon.Synonym;
21 23
import eu.etaxonomy.cdm.model.taxon.Taxon;
......
43 45
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
44 46
	 */
45 47
	/** {@inheritDoc} */
46
	public Object execute(ExecutionEvent event) throws ExecutionException {
48
	@Override
49
    public Object execute(ExecutionEvent event) throws ExecutionException {
47 50
		TaxonNameEditor editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(
48 51
				Page.NAME);
49

  
52
		Shell shell = HandlerUtil.getActiveShell(event);
53
		if (!EditorUtil.forceUserSave(editor, shell)) {
54
            return null;
55
        }
50 56
		Object selectedElement = EditorUtil.getSelection(event).getFirstElement();
51
		
57

  
52 58
		AbstractPostOperation operation = null;
53 59
		try {
54 60
			if(selectedElement instanceof Taxon){
55
				operation = new ChangeConceptRelationshipTypeOperation(event.getCommand().getName(), 
61
				operation = new ChangeConceptRelationshipTypeOperation(event.getCommand().getName(),
56 62
										editor.getUndoContext(), editor.getTaxon(), (Taxon) selectedElement, TaxonRelationshipType.MISAPPLIED_NAME_FOR(), editor);
57 63
			}
58 64
			if(selectedElement instanceof Synonym){
59
				operation = new ChangeSynonymToMisapplicationOperation(event.getCommand().getName(), 
65
				operation = new ChangeSynonymToMisapplicationOperation(event.getCommand().getName(),
60 66
						editor.getUndoContext(), editor.getTaxon(), (Synonym) selectedElement, editor);
61 67
			}
62
			
68

  
63 69
			EditorUtil.executeOperation(operation);
64 70
		} catch (NotDefinedException e) {
65 71
			logger.warn("Command name not set");
66 72
		}
67
		
73

  
68 74
		return null;
69 75
	}
70 76
}

Also available in: Unified diff