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.TermVocabulary;
|
20
|
import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
|
21
|
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
|
22
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
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 AbstractPostTaxonOperation {
|
31
|
|
32
|
private final TermEditorInput definedEditorInput;
|
33
|
|
34
|
/**
|
35
|
* @param label
|
36
|
* @param undoContext
|
37
|
* @param postOperationEnabled
|
38
|
*/
|
39
|
public CreateTermVocabularyOperation(String label,
|
40
|
IUndoContext undoContext,
|
41
|
TermEditorInput definedEditorInput,
|
42
|
IPostOperationEnabled postOperationEnabled) {
|
43
|
super(label, undoContext, postOperationEnabled);
|
44
|
this.definedEditorInput = definedEditorInput;
|
45
|
}
|
46
|
|
47
|
/* (non-Javadoc)
|
48
|
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
49
|
*/
|
50
|
@Override
|
51
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
52
|
throws ExecutionException {
|
53
|
|
54
|
TermVocabulary termVocabulary =
|
55
|
TermVocabulary.NewInstance(definedEditorInput.getTermType(),
|
56
|
null,
|
57
|
"Untitled",
|
58
|
null,
|
59
|
null);
|
60
|
|
61
|
termVocabulary = CdmStore.getService(IVocabularyService.class).save(termVocabulary);
|
62
|
definedEditorInput.getVocabularies().add(termVocabulary);
|
63
|
|
64
|
return postExecute(termVocabulary);
|
65
|
}
|
66
|
|
67
|
/* (non-Javadoc)
|
68
|
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
69
|
*/
|
70
|
@Override
|
71
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
72
|
throws ExecutionException {
|
73
|
// TODO Auto-generated method stub
|
74
|
return null;
|
75
|
}
|
76
|
|
77
|
/* (non-Javadoc)
|
78
|
* @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
79
|
*/
|
80
|
@Override
|
81
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
82
|
throws ExecutionException {
|
83
|
// TODO Auto-generated method stub
|
84
|
return null;
|
85
|
}
|
86
|
|
87
|
}
|