with the move to term types in model change 3.3 we no longer need term specific edito...
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / editor / definedterm / input / TermEditorInput.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.input;
11
12 import java.util.Arrays;
13 import java.util.HashSet;
14 import java.util.List;
15 import java.util.Set;
16
17 import eu.etaxonomy.cdm.api.service.IVocabularyService;
18 import eu.etaxonomy.cdm.model.common.DefinedTerm;
19 import eu.etaxonomy.cdm.model.common.DefinedTermBase;
20 import eu.etaxonomy.cdm.model.common.TermType;
21 import eu.etaxonomy.cdm.model.common.TermVocabulary;
22 import eu.etaxonomy.taxeditor.store.CdmStore;
23
24
25
26 /**
27 * @author n.hoffmann
28 * @date Jan 24, 2012
29 *
30 */
31 public class TermEditorInput extends AbstractDefinedTermEditorInput<DefinedTerm> {
32
33 private TermType termType;
34 private Set<TermVocabulary<DefinedTermBase>> vocabularies;
35 private List<String> termClasses = Arrays.asList(new String[]{
36 DefinedTerm.class.getName()
37 });
38
39 public TermEditorInput(TermType termType) {
40 this.termType = termType;
41 vocabularies = new HashSet<TermVocabulary<DefinedTermBase>>();
42 initialiseVocabularies();
43 }
44 /* (non-Javadoc)
45 * @see org.eclipse.ui.IEditorInput#getName()
46 */
47 @Override
48 public String getName() {
49 return termType.getMessage();
50 }
51
52 /* (non-Javadoc)
53 * @see eu.etaxonomy.taxeditor.editor.definedterm.input.AbstractDefinedTermEditorInput#getTermClasses()
54 */
55 @Override
56 public List<String> getTermClasses() {
57 return termClasses;
58 }
59
60 public TermType getTermType() {
61 return termType;
62 }
63
64 public void initialiseVocabularies() {
65 if(vocabularies != null) {
66 vocabularies.clear();
67 }
68 List<TermVocabulary<DefinedTermBase>> vocs = CdmStore.getService(IVocabularyService.class).findByTermType(termType);
69 vocabularies.addAll(vocs);
70 }
71
72 public Set<TermVocabulary<DefinedTermBase>> getVocabularies() {
73 return vocabularies;
74 }
75
76 }