Project

General

Profile

Revision aa95aad0

IDaa95aad0606b24de8df073a2f2614e86ab91718b
Parent c2527228
Child fb259956

Added by Patrick Plitzner 10 months ago

fix #7868 Allow creating a new vocabulary in vocabulary selection dialog

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewVocabularyWizard.java
1
/**
2
* Copyright (C) 2014 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9
package eu.etaxonomy.taxeditor.newWizard;
10

  
11
import eu.etaxonomy.cdm.api.service.IVocabularyService;
12
import eu.etaxonomy.cdm.model.common.TermType;
13
import eu.etaxonomy.cdm.model.common.TermVocabulary;
14
import eu.etaxonomy.taxeditor.store.CdmStore;
15

  
16
/**
17
 * @author pplitzner
18
 * @date 11.03.2014
19
 *
20
 */
21
public class NewVocabularyWizard  extends AbstractNewEntityWizard<TermVocabulary> {
22

  
23
    private VocabularyWizardPage vocabularyPage;
24

  
25
    @Override
26
    public void addPages() {
27
        vocabularyPage = new VocabularyWizardPage(formFactory, getConversationHolder(), getEntity());
28
        addPage(vocabularyPage);
29
    }
30

  
31
    @Override
32
    protected TermVocabulary createNewEntity() {
33
        return TermVocabulary.NewInstance(TermType.Feature);
34
    }
35

  
36
    @Override
37
    protected void saveEntity() {
38
       CdmStore.getService(IVocabularyService.class).merge(getEntity(),true);
39

  
40
    }
41

  
42
    @Override
43
    public void setEntity(TermVocabulary entity) {
44
        super.setEntity(entity);
45
        vocabularyPage.getDetailElement().setEntity(entity);
46
    }
47

  
48
    @Override
49
    protected String getEntityName() {
50
        return "Vocabulary";
51
    }
52
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/VocabularyWizardPage.java
1
/**
2
 * Copyright (C) 2014 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
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.
8
 */
9
package eu.etaxonomy.taxeditor.newWizard;
10

  
11
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
12
import eu.etaxonomy.cdm.model.common.TermVocabulary;
13
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmEntityWizardPage;
14
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
15
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
16
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
17
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailElement;
18

  
19
/**
20
 * @author pplitzner
21
 * @date 11.03.2014
22
 *
23
 */
24
public class VocabularyWizardPage extends AbstractCdmEntityWizardPage<TermVocabulary> {
25

  
26
    public VocabularyWizardPage(CdmFormFactory formFactory,
27
            ConversationHolder conversation, TermVocabulary entity) {
28
        super(formFactory, conversation, entity);
29
        setTitle("General Vocabulary Data");
30
    }
31

  
32
    @Override
33
    protected void checkComplete() {
34
        setPageComplete(true);
35
    }
36

  
37
    @Override
38
    public AbstractCdmDetailElement<TermVocabulary> createElement(ICdmFormElement rootElement) {
39
        TermVocabularyDetailElement detailElement = formFactory.createTermVocabularyDetailElement(rootElement);
40
        detailElement.setEntity(getEntity());
41
        checkComplete();
42
        return detailElement;
43
    }
44

  
45
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TermVocabularySelectionDialog.java
19 19
import eu.etaxonomy.cdm.model.common.TermVocabulary;
20 20
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
21 21
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
22
import eu.etaxonomy.taxeditor.newWizard.NewVocabularyWizard;
22 23
import eu.etaxonomy.taxeditor.store.CdmStore;
23 24

  
24 25
/**
......
75 76

  
76 77
	@Override
77 78
	protected String[] getNewWizardText() {
78
		return null;
79
        return new String[]{ "New Vocabulary"};
79 80
	}
80 81

  
81 82
	@Override
82 83
	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
83
		return null;
84
        return new NewVocabularyWizard();
84 85
	}
85 86

  
86 87
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/AbstractTermBaseDetailElement.java
10 10

  
11 11
import org.eclipse.swt.widgets.Button;
12 12

  
13
import eu.etaxonomy.cdm.model.common.Language;
13 14
import eu.etaxonomy.cdm.model.common.Representation;
14 15
import eu.etaxonomy.cdm.model.common.TermBase;
15 16
import eu.etaxonomy.cdm.model.common.TermVocabulary;
......
59 60
        else if (eventSource == element_Representation) {
60 61
            Representation selectedRepresentation = element_Representation.getSelectedRepresentation();
61 62
            if(selectedRepresentation!=null){
62
                getEntity().setLabel(selectedRepresentation.getLabel(),  selectedRepresentation.getLanguage());
63
                getEntity().getRepresentation(selectedRepresentation.getLanguage()).setAbbreviatedLabel(selectedRepresentation.getAbbreviatedLabel());
64
                getEntity().getRepresentation(selectedRepresentation.getLanguage()).setText(selectedRepresentation.getDescription());
63
                Language representationLanguage = selectedRepresentation.getLanguage();
64
                if(representationLanguage==null){
65
                    representationLanguage = Language.getDefaultLanguage();
66
                }
67
                getEntity().setLabel(selectedRepresentation.getLabel(),  representationLanguage);
68
                getEntity().getRepresentation(representationLanguage).setAbbreviatedLabel(selectedRepresentation.getAbbreviatedLabel());
69
                getEntity().getRepresentation(representationLanguage).setText(selectedRepresentation.getDescription());
65 70
            }
66 71
            getEntity().setTitleCache(null);
67 72
        }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)