Project

General

Profile

Download (2.1 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.editor.definedterm.handler;
2
import java.util.UUID;
3

    
4
import org.eclipse.core.commands.AbstractHandler;
5
import org.eclipse.core.commands.ExecutionEvent;
6
import org.eclipse.core.commands.ExecutionException;
7
import org.eclipse.core.commands.IHandler;
8
import org.eclipse.core.runtime.IStatus;
9
import org.eclipse.core.runtime.MultiStatus;
10
import org.eclipse.core.runtime.Status;
11
import org.eclipse.ui.IWorkbenchPage;
12
import org.eclipse.ui.PartInitException;
13

    
14
import eu.etaxonomy.cdm.model.common.TermType;
15
import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;
16
import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
17
import eu.etaxonomy.taxeditor.model.MessagingUtils;
18
import eu.etaxonomy.taxeditor.store.StoreUtil;
19

    
20
// $Id$
21
/**
22
 * Copyright (C) 2009 EDIT
23
 * European Distributed Institute of Taxonomy
24
 * http://www.e-taxonomy.eu
25
 *
26
 * The contents of this file are subject to the Mozilla Public License Version 1.1
27
 * See LICENSE.TXT at the top of this package for the full license terms.
28
 */
29

    
30
/**
31
 * @author l.morris
32
 * @date 8 Dec 2011
33
 *
34
 */
35
public class OpenDefinedTermEditorHandler extends AbstractHandler implements IHandler {
36

    
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
39
	 */
40
	@Override
41
	public Object execute(ExecutionEvent event) throws ExecutionException {
42

    
43
		String termTypeUuid = event.getParameter("eu.etaxonomy.taxeditor.store.openDefinedTermEditor.termTypeUuid");
44
		IWorkbenchPage activePage = StoreUtil.getActivePage();
45
		try {
46
			activePage.openEditor(new TermEditorInput(TermType.getByUuid(UUID.fromString(termTypeUuid))), DefinedTermEditor.ID);
47
		} catch (PartInitException e) {
48

    
49
			String PID = "eu.etaxonomy.taxeditor.application";
50
			MultiStatus info = new MultiStatus(PID, 1, "You might be missing sufficient permissions to open the Defined Term Editor", null);
51
			info.add(new Status(IStatus.WARNING, PID, 1, e.getMessage(), null));
52
			MessagingUtils.warningDialog("Cannot open Defined Term Editor", getClass(), info);
53
		}
54

    
55
		return null;
56
	}
57

    
58
}
(4-4/4)