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.cdm.persistence.dto.AbstractTermDto;
|
17
|
import eu.etaxonomy.taxeditor.ui.translation.TermTranslationWizardPage;
|
18
|
|
19
|
/**
|
20
|
* @author k.luther
|
21
|
* @date 22.06.2016
|
22
|
*
|
23
|
*/
|
24
|
public class TermTranslationWizard extends Wizard {
|
25
|
private TermTranslationWizardPage page;
|
26
|
|
27
|
private TermBase term;
|
28
|
private AbstractTermDto termDto;
|
29
|
|
30
|
public TermTranslationWizard(TermBase term) {
|
31
|
setWindowTitle("Translation Editor");
|
32
|
this.term = term;
|
33
|
setNeedsProgressMonitor(true);
|
34
|
}
|
35
|
|
36
|
public TermTranslationWizard(AbstractTermDto termDto) {
|
37
|
setWindowTitle("Translation Editor");
|
38
|
this.termDto = termDto;
|
39
|
setNeedsProgressMonitor(true);
|
40
|
}
|
41
|
|
42
|
@Override
|
43
|
public void addPages() {
|
44
|
if (term != null) {
|
45
|
page = new TermTranslationWizardPage(term);
|
46
|
}else {
|
47
|
page = new TermTranslationWizardPage(termDto);
|
48
|
}
|
49
|
addPage(page);
|
50
|
}
|
51
|
|
52
|
@Override
|
53
|
public boolean performFinish() {
|
54
|
Representation representation = page.getTargetRepresentation();
|
55
|
|
56
|
if (representation.getLanguage() == null){
|
57
|
return false;
|
58
|
}
|
59
|
if (CdmUtils.isNotBlank(representation.getText())
|
60
|
|| CdmUtils.isNotBlank(representation.getLabel())
|
61
|
|| CdmUtils.isNotBlank(representation.getAbbreviatedLabel())
|
62
|
|| CdmUtils.isNotBlank(representation.getPlural())){
|
63
|
if (term != null) {
|
64
|
term.addRepresentation(representation);
|
65
|
}else if (termDto != null){
|
66
|
termDto.addRepresentation(representation);
|
67
|
}
|
68
|
}
|
69
|
|
70
|
return true;
|
71
|
}
|
72
|
|
73
|
@Override
|
74
|
public boolean canFinish() {
|
75
|
Representation representation = page.getTargetRepresentation();
|
76
|
if (representation==null || representation.getLanguage() == null){
|
77
|
return false;
|
78
|
}
|
79
|
return CdmUtils.isNotBlank(representation.getText())
|
80
|
|| CdmUtils.isNotBlank(representation.getLabel())
|
81
|
|| CdmUtils.isNotBlank(representation.getAbbreviatedLabel())
|
82
|
|| CdmUtils.isNotBlank(representation.getPlural());
|
83
|
}
|
84
|
}
|