Project

General

Profile

Download (2.07 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2016 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.ui.section.vocabulary;
10

    
11
import org.eclipse.jface.wizard.Wizard;
12

    
13
import eu.etaxonomy.cdm.common.CdmUtils;
14
import eu.etaxonomy.cdm.model.term.Representation;
15
import eu.etaxonomy.cdm.model.term.TermBase;
16
import eu.etaxonomy.taxeditor.ui.translation.TermTranslationWizardPage;
17

    
18
/**
19
 * @author k.luther
20
 * @date 22.06.2016
21
 *
22
 */
23
public class TermTranslationWizard extends Wizard {
24
    private TermTranslationWizardPage page;
25

    
26
    private final TermBase term;
27

    
28
    public TermTranslationWizard(TermBase term) {
29
        setWindowTitle("Translation Editor");
30
        this.term = term;
31
        setNeedsProgressMonitor(true);
32
    }
33

    
34
    @Override
35
    public void addPages() {
36
        page = new TermTranslationWizardPage(term);
37
        addPage(page);
38
    }
39

    
40
    @Override
41
    public boolean performFinish() {
42
        Representation representation = page.getTargetRepresentation();
43

    
44
        if (representation.getLanguage() == null){
45
        	return false;
46
        }
47
        if (CdmUtils.isNotBlank(representation.getText())
48
                || CdmUtils.isNotBlank(representation.getLabel())
49
                || CdmUtils.isNotBlank(representation.getAbbreviatedLabel())
50
                || CdmUtils.isNotBlank(representation.getPlural())){
51
            term.addRepresentation(representation);
52
        }
53

    
54
        return true;
55
    }
56

    
57
    @Override
58
    public boolean canFinish() {
59
        Representation representation = page.getTargetRepresentation();
60
        if (representation==null || representation.getLanguage() == null){
61
            return false;
62
        }
63
        return CdmUtils.isNotBlank(representation.getText())
64
                || CdmUtils.isNotBlank(representation.getLabel())
65
                || CdmUtils.isNotBlank(representation.getAbbreviatedLabel())
66
                || CdmUtils.isNotBlank(representation.getPlural());
67
    }
68
}
(17-17/19)