Project

General

Profile

Download (3.57 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 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
package eu.etaxonomy.taxeditor.editor.definedterm.operation;
10

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

    
17
import eu.etaxonomy.cdm.api.service.IVocabularyService;
18
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
19
import eu.etaxonomy.cdm.model.common.OrderedTermBase;
20
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
21
import eu.etaxonomy.cdm.model.common.TermType;
22
import eu.etaxonomy.cdm.model.common.TermVocabulary;
23
import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
24
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
25
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
26
import eu.etaxonomy.taxeditor.store.CdmStore;
27

    
28
/**
29
 * @author l.morris
30
 * @date 21 Dec 2011
31
 *
32
 */
33
public class CreateTermVocabularyOperation extends AbstractPostTaxonOperation {
34

    
35
	private final TermEditorInput definedEditorInput;
36

    
37
	/**
38
	 * @param label
39
	 * @param undoContext
40
	 * @param postOperationEnabled
41
	 */
42
	public CreateTermVocabularyOperation(String label,
43
			IUndoContext undoContext,
44
			TermEditorInput definedEditorInput,
45
			IPostOperationEnabled postOperationEnabled) {
46
		super(label, undoContext, postOperationEnabled);
47
		this.definedEditorInput = definedEditorInput;
48
	}
49

    
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
52
	 */
53
	@Override
54
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
55
			throws ExecutionException {
56

    
57
	   TermType type= definedEditorInput.getTermType();
58
	   DefinedTermBase test = type.getEmptyDefinedTermBase();
59
	   TermVocabulary termVocabulary = null;
60
	   if (test instanceof OrderedTermBase){
61
	      termVocabulary = OrderedTermVocabulary.NewInstance(definedEditorInput.getTermType(),
62
                       null,
63
                       "Untitled",
64
                       null,
65
                       null);
66
	   }
67

    
68
	   if (termVocabulary == null){
69
	    termVocabulary =
70
                TermVocabulary.NewInstance(definedEditorInput.getTermType(),
71
                    null,
72
                    "Untitled",
73
                    null,
74
                    null);
75
	   }
76

    
77
		termVocabulary = CdmStore.getService(IVocabularyService.class).save(termVocabulary);
78
		//FIXME: implement creation of term vocabularies
79
//		definedEditorInput.getVocabularies().add(termVocabulary);
80

    
81
		return postExecute(termVocabulary);
82
	}
83

    
84
	/* (non-Javadoc)
85
	 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
86
	 */
87
	@Override
88
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
89
			throws ExecutionException {
90
		// TODO Auto-generated method stub
91
		return null;
92
	}
93

    
94
	/* (non-Javadoc)
95
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
96
	 */
97
	@Override
98
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
99
			throws ExecutionException {
100
		// TODO Auto-generated method stub
101
		return null;
102
	}
103

    
104
}
(2-2/4)