- fixed saving problem due to cloning of FieldUnit
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / editor / definedterm / operation / CreateTermVocabularyOperation.java
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 java.net.URI;
13
14 import org.eclipse.core.commands.ExecutionException;
15 import org.eclipse.core.commands.operations.IUndoContext;
16 import org.eclipse.core.runtime.IAdaptable;
17 import org.eclipse.core.runtime.IProgressMonitor;
18 import org.eclipse.core.runtime.IStatus;
19
20 import eu.etaxonomy.cdm.api.service.IVocabularyService;
21 import eu.etaxonomy.cdm.model.common.DefinedTerm;
22 import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
23 import eu.etaxonomy.cdm.model.common.TermType;
24 import eu.etaxonomy.cdm.model.common.TermVocabulary;
25 import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;
26 import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
27 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
28 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
29 import eu.etaxonomy.taxeditor.store.CdmStore;
30
31 /**
32 * @author l.morris
33 * @date 21 Dec 2011
34 *
35 */
36 public class CreateTermVocabularyOperation extends AbstractPostOperation {
37
38 private TermEditorInput definedEditorInput;
39
40 /**
41 * @param label
42 * @param undoContext
43 * @param postOperationEnabled
44 */
45 public CreateTermVocabularyOperation(String label,
46 IUndoContext undoContext,
47 TermEditorInput definedEditorInput,
48 IPostOperationEnabled postOperationEnabled) {
49 super(label, undoContext, postOperationEnabled);
50 this.definedEditorInput = definedEditorInput;
51 }
52
53 /* (non-Javadoc)
54 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
55 */
56 @Override
57 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
58 throws ExecutionException {
59
60 TermVocabulary termVocabulary =
61 TermVocabulary.NewInstance(definedEditorInput.getTermType(),
62 null,
63 "Untitled",
64 null,
65 null);
66
67 CdmStore.getService(IVocabularyService.class).save(termVocabulary);
68 definedEditorInput.getVocabularies().add(termVocabulary);
69
70 return postExecute(termVocabulary);
71 }
72
73 /* (non-Javadoc)
74 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
75 */
76 @Override
77 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
78 throws ExecutionException {
79 // TODO Auto-generated method stub
80 return null;
81 }
82
83 /* (non-Javadoc)
84 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
85 */
86 @Override
87 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
88 throws ExecutionException {
89 // TODO Auto-generated method stub
90 return null;
91 }
92
93 }