Project

General

Profile

« Previous | Next » 

Revision cc26e350

Added by Cherian Mathew almost 11 years ago

updated operations to use the new TermEditorInput and also added pop-up warnings when,

  • user tries to delete a CDM system vocabulary / term
  • user tries to add a defined term base object to a vocabulary / term if the corresponding term class is not available (via the getEmptyDefinedTermBase() method in TermType)

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/operation/CreateDefinedTermOperation.java
14 14
import org.eclipse.core.runtime.IAdaptable;
15 15
import org.eclipse.core.runtime.IProgressMonitor;
16 16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.ui.IEditorInput;
17
import org.eclipse.core.runtime.Status;
18 18

  
19 19
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
20 20
import eu.etaxonomy.cdm.model.common.TermBase;
21 21
import eu.etaxonomy.cdm.model.common.TermVocabulary;
22
import eu.etaxonomy.cdm.model.location.NamedArea;
23
import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;
24
import eu.etaxonomy.taxeditor.editor.definedterm.input.AbstractDefinedTermEditorInput;
25
import eu.etaxonomy.taxeditor.editor.definedterm.input.NamedAreaEditorInput;
22
import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
26 23
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
27 24
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
25
import eu.etaxonomy.taxeditor.store.StoreUtil;
28 26

  
29 27
/**
30 28
 * @author l.morris
......
36 34
	
37 35

  
38 36
	private TermBase parentTermBase;
39
	private AbstractDefinedTermEditorInput editorInput; 
37
	private TermEditorInput definedTermInput;
40 38

  
41 39
	/**
42 40
	 * @param label
......
44 42
	 * @param postOperationEnabled
45 43
	 */
46 44
	public CreateDefinedTermOperation(String label,
47
			IUndoContext undoContext, TermBase termBase, IPostOperationEnabled postOperationEnabled) {
45
			IUndoContext undoContext, 
46
			TermBase termBase,
47
			TermEditorInput definedTermInput,
48
			IPostOperationEnabled postOperationEnabled) {
48 49
		super(label, undoContext, postOperationEnabled);
49 50
		this.parentTermBase = termBase;
50
		editorInput = ((DefinedTermEditor)postOperationEnabled).getDefinedTermEditorInput();
51
		this.definedTermInput = definedTermInput;
51 52
	}
52 53

  
53 54
	/* (non-Javadoc)
......
57 58
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
58 59
			throws ExecutionException {
59 60
		
60
		DefinedTermBase newTerm = editorInput.createTermInstance();		 		
61
		
62
		newTerm.setLabel("Untitled");
61
		DefinedTermBase newTerm = definedTermInput.getTermType().getEmptyDefinedTermBase();
62
		if (newTerm == null) {
63
			IStatus status = 
64
					new Status(IStatus.CANCEL, 
65
							StoreUtil.getPluginId(), 
66
							"Creation of term corresponding to type '" + definedTermInput.getTermType().getMessage() + "' is not yet supported");
67
			StoreUtil.warningDialog("Cannot create term", newTerm, status);
68
			return status;
69
		}
63 70
		
64 71
		if (parentTermBase instanceof TermVocabulary){
65 72
			TermVocabulary vocabulary = (TermVocabulary) parentTermBase;
66 73
			vocabulary.addTerm(newTerm);
67 74
		} else if (parentTermBase instanceof DefinedTermBase) {
68
			DefinedTermBase parent = (DefinedTermBase) parentTermBase;
69
			parent.addIncludes(newTerm);
75
			DefinedTermBase parent = (DefinedTermBase) parentTermBase;			
76
			parent.addIncludes(newTerm);			
70 77
			TermVocabulary vocabulary = parent.getVocabulary();
71 78
			vocabulary.addTerm(newTerm);
72 79
		}

Also available in: Unified diff