import org.eclipse.core.runtime.IAdaptable;\r
import org.eclipse.core.runtime.IProgressMonitor;\r
import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.ui.IEditorInput;\r
+import org.eclipse.core.runtime.Status;\r
\r
import eu.etaxonomy.cdm.model.common.DefinedTermBase;\r
import eu.etaxonomy.cdm.model.common.TermBase;\r
import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
-import eu.etaxonomy.cdm.model.location.NamedArea;\r
-import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;\r
-import eu.etaxonomy.taxeditor.editor.definedterm.input.AbstractDefinedTermEditorInput;\r
-import eu.etaxonomy.taxeditor.editor.definedterm.input.NamedAreaEditorInput;\r
+import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;\r
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;\r
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
+import eu.etaxonomy.taxeditor.store.StoreUtil;\r
\r
/**\r
* @author l.morris\r
\r
\r
private TermBase parentTermBase;\r
- private AbstractDefinedTermEditorInput editorInput; \r
+ private TermEditorInput definedTermInput;\r
\r
/**\r
* @param label\r
* @param postOperationEnabled\r
*/\r
public CreateDefinedTermOperation(String label,\r
- IUndoContext undoContext, TermBase termBase, IPostOperationEnabled postOperationEnabled) {\r
+ IUndoContext undoContext, \r
+ TermBase termBase,\r
+ TermEditorInput definedTermInput,\r
+ IPostOperationEnabled postOperationEnabled) {\r
super(label, undoContext, postOperationEnabled);\r
this.parentTermBase = termBase;\r
- editorInput = ((DefinedTermEditor)postOperationEnabled).getDefinedTermEditorInput();\r
+ this.definedTermInput = definedTermInput;\r
}\r
\r
/* (non-Javadoc)\r
public IStatus execute(IProgressMonitor monitor, IAdaptable info)\r
throws ExecutionException {\r
\r
- DefinedTermBase newTerm = editorInput.createTermInstance(); \r
- \r
- newTerm.setLabel("Untitled");\r
+ DefinedTermBase newTerm = definedTermInput.getTermType().getEmptyDefinedTermBase();\r
+ if (newTerm == null) {\r
+ IStatus status = \r
+ new Status(IStatus.CANCEL, \r
+ StoreUtil.getPluginId(), \r
+ "Creation of term corresponding to type '" + definedTermInput.getTermType().getMessage() + "' is not yet supported");\r
+ StoreUtil.warningDialog("Cannot create term", newTerm, status);\r
+ return status;\r
+ }\r
\r
if (parentTermBase instanceof TermVocabulary){\r
TermVocabulary vocabulary = (TermVocabulary) parentTermBase;\r
vocabulary.addTerm(newTerm);\r
} else if (parentTermBase instanceof DefinedTermBase) {\r
- DefinedTermBase parent = (DefinedTermBase) parentTermBase;\r
- parent.addIncludes(newTerm);\r
+ DefinedTermBase parent = (DefinedTermBase) parentTermBase; \r
+ parent.addIncludes(newTerm); \r
TermVocabulary vocabulary = parent.getVocabulary();\r
vocabulary.addTerm(newTerm);\r
}\r
*/\r
package eu.etaxonomy.taxeditor.editor.definedterm.operation;\r
\r
+import java.net.URI;\r
+\r
import org.eclipse.core.commands.ExecutionException;\r
import org.eclipse.core.commands.operations.IUndoContext;\r
import org.eclipse.core.runtime.IAdaptable;\r
import org.eclipse.core.runtime.IStatus;\r
\r
import eu.etaxonomy.cdm.api.service.IVocabularyService;\r
+import eu.etaxonomy.cdm.model.common.DefinedTerm;\r
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;\r
+import eu.etaxonomy.cdm.model.common.TermType;\r
import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;\r
+import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;\r
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;\r
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
import eu.etaxonomy.taxeditor.store.CdmStore;\r
\r
/**\r
*/\r
public class CreateTermVocabularyOperation extends AbstractPostOperation {\r
\r
- private DefinedTermEditor definedTermEditor;\r
-\r
+ private TermEditorInput definedEditorInput;\r
+ \r
/**\r
* @param label\r
* @param undoContext\r
* @param postOperationEnabled\r
*/\r
public CreateTermVocabularyOperation(String label,\r
- IUndoContext undoContext, DefinedTermEditor definedTermEditor) {\r
- super(label, undoContext, definedTermEditor);\r
- this.definedTermEditor = definedTermEditor;\r
+ IUndoContext undoContext, \r
+ TermEditorInput definedEditorInput, \r
+ IPostOperationEnabled postOperationEnabled) {\r
+ super(label, undoContext, postOperationEnabled);\r
+ this.definedEditorInput = definedEditorInput;\r
}\r
\r
/* (non-Javadoc)\r
@Override\r
public IStatus execute(IProgressMonitor monitor, IAdaptable info)\r
throws ExecutionException {\r
-\r
- TermVocabulary termVocabulary = OrderedTermVocabulary.NewInstance(null, "Untitled", null, null);\r
+ \r
+ TermVocabulary termVocabulary = \r
+ TermVocabulary.NewInstance(definedEditorInput.getTermType(),\r
+ null, \r
+ "Untitled", \r
+ null, \r
+ null); \r
+ \r
CdmStore.getService(IVocabularyService.class).save(termVocabulary);\r
- definedTermEditor.getInMemoryVocabularies().add(termVocabulary);\r
+ definedEditorInput.getVocabularies().add(termVocabulary);\r
\r
return postExecute(termVocabulary);\r
}\r
\r
import eu.etaxonomy.cdm.api.service.ITermService;\r
import eu.etaxonomy.cdm.api.service.IVocabularyService;\r
+import eu.etaxonomy.cdm.model.common.DefinedTerm;\r
import eu.etaxonomy.cdm.model.common.DefinedTermBase;\r
import eu.etaxonomy.cdm.model.common.TermBase;\r
import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;\r
+import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;\r
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;\r
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
import eu.etaxonomy.taxeditor.store.CdmStore;\r
import eu.etaxonomy.taxeditor.store.StoreUtil;\r
\r
*/\r
public class DeleteTermBaseOperation extends AbstractPostOperation {\r
\r
+ private TermEditorInput definedEditorInput;\r
private TermBase termBase;\r
private DefinedTermEditor definedTermEditor;\r
/**\r
* @param undoContext\r
* @param postOperationEnabled\r
*/\r
- public DeleteTermBaseOperation(String label, IUndoContext undoContext, TermBase termBase,\r
- DefinedTermEditor definedTermEditor) {\r
- super(label, undoContext, definedTermEditor);\r
+ public DeleteTermBaseOperation(String label, \r
+ IUndoContext undoContext, \r
+ TermBase termBase,\r
+ TermEditorInput definedEditorInput,\r
+ IPostOperationEnabled postOperationEnabled) {\r
+ super(label, undoContext, postOperationEnabled);\r
this.termBase = termBase;\r
- this.definedTermEditor = definedTermEditor;\r
+ this.definedEditorInput = definedEditorInput; \r
}\r
\r
/* (non-Javadoc)\r
\r
\r
if (termBase instanceof TermVocabulary) {\r
+ if (((TermVocabulary)termBase).getCreatedBy() == null) {\r
+ IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), "This is a CDM system vocabulary");\r
+ StoreUtil.warningDialog("Cannot delete vocabulary", termBase, status);\r
+ return status;\r
+ }\r
\r
if (!((TermVocabulary)termBase).getTerms().isEmpty()) {\r
IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), "Delete all terms from this vocaulary before deleting the vocabulary.");\r
StoreUtil.warningDialog("Vocabulary not empty", termBase, status);\r
return status;\r
- }\r
- definedTermEditor.getInMemoryVocabularies().remove(termBase); \r
+ } \r
+\r
+ definedEditorInput.getVocabularies().remove((TermVocabulary)termBase); \r
CdmStore.getService(IVocabularyService.class).delete((TermVocabulary)termBase);\r
\r
+ \r
} else if (termBase instanceof DefinedTermBase) {\r
\r
\r
DefinedTermBase definedTermBase = (DefinedTermBase) termBase;\r
+ \r
+ if (((DefinedTermBase)termBase).getCreatedBy() == null) {\r
+ IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), "This is a CDM system defined term");\r
+ StoreUtil.warningDialog("Cannot delete defined term", termBase, status);\r
+ return status;\r
+ }\r
if(!definedTermBase.getIncludes().isEmpty()){\r
IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), "This term includes other terms. Please delete the included terms before deleting this term."); \r
StoreUtil.warningDialog("Term has included terms", termBase, status);\r
return status;\r
} \r
\r
+\r
DefinedTermBase partOf = definedTermBase.getPartOf();\r
if(partOf != null){\r
partOf.removeIncludes(definedTermBase);\r