Project

General

Profile

Download (2.65 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.operation;
11

    
12
import org.eclipse.core.commands.ExecutionException;
13
import org.eclipse.core.commands.operations.IUndoContext;
14
import org.eclipse.core.runtime.IAdaptable;
15
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.core.runtime.IStatus;
17

    
18
import eu.etaxonomy.cdm.api.service.IVocabularyService;
19
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
20
import eu.etaxonomy.cdm.model.common.TermVocabulary;
21
import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;
22
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24

    
25
/**
26
 * @author l.morris
27
 * @date 21 Dec 2011
28
 *
29
 */
30
public class CreateTermVocabularyOperation extends AbstractPostOperation {
31

    
32
	private DefinedTermEditor definedTermEditor;
33

    
34
	/**
35
	 * @param label
36
	 * @param undoContext
37
	 * @param postOperationEnabled
38
	 */
39
	public CreateTermVocabularyOperation(String label,
40
			IUndoContext undoContext, DefinedTermEditor definedTermEditor) {
41
		super(label, undoContext, definedTermEditor);
42
		this.definedTermEditor = definedTermEditor;
43
	}
44

    
45
	/* (non-Javadoc)
46
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
47
	 */
48
	@Override
49
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
50
			throws ExecutionException {
51

    
52
		TermVocabulary termVocabulary = OrderedTermVocabulary.NewInstance(null, "Untitled", null, null);
53
		CdmStore.getService(IVocabularyService.class).save(termVocabulary);
54
		definedTermEditor.getInMemoryVocabularies().add(termVocabulary);
55
		
56
		return postExecute(termVocabulary);
57
	}
58

    
59
	/* (non-Javadoc)
60
	 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
61
	 */
62
	@Override
63
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
64
			throws ExecutionException {
65
		// TODO Auto-generated method stub
66
		return null;
67
	}
68

    
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
71
	 */
72
	@Override
73
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
74
			throws ExecutionException {
75
		// TODO Auto-generated method stub
76
		return null;
77
	}
78

    
79
}
(2-2/4)