2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.definedterm
.operation
;
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
;
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
;
33 public class CreateTermVocabularyOperation
extends AbstractPostTaxonOperation
{
35 private final TermEditorInput definedEditorInput
;
40 * @param postOperationEnabled
42 public CreateTermVocabularyOperation(String label
,
43 IUndoContext undoContext
,
44 TermEditorInput definedEditorInput
,
45 IPostOperationEnabled postOperationEnabled
) {
46 super(label
, undoContext
, postOperationEnabled
);
47 this.definedEditorInput
= definedEditorInput
;
51 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
54 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
55 throws ExecutionException
{
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(),
68 if (termVocabulary
== null){
70 TermVocabulary
.NewInstance(definedEditorInput
.getTermType(),
77 termVocabulary
= CdmStore
.getService(IVocabularyService
.class).save(termVocabulary
);
78 definedEditorInput
.getVocabularies().add(termVocabulary
);
80 return postExecute(termVocabulary
);
84 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
87 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
88 throws ExecutionException
{
89 // TODO Auto-generated method stub
94 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
97 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
98 throws ExecutionException
{
99 // TODO Auto-generated method stub