Project

General

Profile

Download (2.08 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2009 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.editor.definedterm.handler;
11

    
12
import java.util.Iterator;
13

    
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.core.commands.common.NotDefinedException;
18
import org.eclipse.jface.viewers.IStructuredSelection;
19
import org.eclipse.ui.handlers.HandlerUtil;
20

    
21
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
22
import eu.etaxonomy.cdm.model.common.TermBase;
23
import eu.etaxonomy.cdm.model.common.TermVocabulary;
24
import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;
25
import eu.etaxonomy.taxeditor.editor.definedterm.operation.DeleteTermBaseOperation;
26
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
27
import eu.etaxonomy.taxeditor.store.StoreUtil;
28

    
29
/**
30
 * @author l.morris
31
 * @date 22 Dec 2011
32
 *
33
 */
34
public class DeleteTermBaseHandler extends AbstractHandler {
35

    
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
38
	 */
39
	@Override
40
	public Object execute(ExecutionEvent event) throws ExecutionException {
41
		DefinedTermEditor editor = (DefinedTermEditor) HandlerUtil
42
				.getActiveEditor(event);
43

    
44
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil
45
				.getCurrentSelection(event);
46

    
47
		Iterator<TermBase> selectionIterator = selection.iterator();
48

    
49
		while (selectionIterator.hasNext()){
50
			
51
			TermBase term = selectionIterator.next();
52
			
53
			try {
54
				AbstractPostOperation operation = new DeleteTermBaseOperation(
55
						event.getCommand().getName(), StoreUtil.getUndoContext(),
56
						term, editor);
57
				StoreUtil.executeOperation(operation);
58
	
59
			} catch (NotDefinedException e) {
60
				StoreUtil.error(getClass(), e);
61
			}
62
		}
63

    
64
		return null;
65
	}
66

    
67
}
(3-3/5)