2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.io
.wizard
;
11 import java
.util
.List
;
12 import java
.util
.UUID
;
14 import org
.eclipse
.swt
.SWT
;
15 import org
.eclipse
.swt
.events
.SelectionAdapter
;
16 import org
.eclipse
.swt
.events
.SelectionEvent
;
17 import org
.eclipse
.swt
.layout
.GridData
;
18 import org
.eclipse
.swt
.widgets
.Combo
;
19 import org
.eclipse
.swt
.widgets
.Composite
;
20 import org
.eclipse
.swt
.widgets
.Label
;
22 import eu
.etaxonomy
.cdm
.api
.service
.IVocabularyService
;
23 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
24 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
25 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
26 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
27 import eu
.etaxonomy
.taxeditor
.l10n
.Messages
;
28 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
35 public class ImportFromFileAndChooseVocIdWizardOage
extends ImportFromFileDataSourceWizardPage
{
37 private Combo vocabularyCombo
;
39 String
[][] labelAndValues
;
45 protected ImportFromFileAndChooseVocIdWizardOage(String title
, String description
, String
[] extensions
) {
46 super(title
, description
, extensions
);
51 public void createControl(Composite parent
) {
52 super.createControl(parent
);
53 Composite composite
= (Composite
)getControl();
54 // final Composite composite = new Composite(parent, SWT.NULL);
55 GridData gridData
= new GridData(SWT
.FILL
, SWT
.TOP
, true, false);
56 composite
.setLayoutData(gridData
);
57 Label label
= new Label(composite
, SWT
.NONE
);
58 label
.setText(Messages
.ImportFromFileAndChooseVocIdWizardPage_AreaVoc
);
59 label
.setToolTipText(Messages
.ImportFromFileAndChooseVocIdWizardOage_AreaVoc_toolTip
);
60 vocabularyCombo
= new Combo(composite
, SWT
.DROP_DOWN
);
61 List
<TermVocabulary
<DefinedTermBase
>> vocs
= CdmStore
.getService(IVocabularyService
.class).findByTermType(TermType
.NamedArea
);
62 for(TermVocabulary voc
: vocs
){
63 vocabularyCombo
.add(voc
.getLabel());
65 getLabelAndValues(vocs
);
66 vocabularyCombo
.select(0);
67 vocabularyCombo
.addSelectionListener(new SelectionAdapter(){
70 public void widgetSelected(SelectionEvent e
) {
71 String name
= vocabularyCombo
.getText();
73 for (String
[] labelAndValue
: labelAndValues
){
74 if (labelAndValue
[0].equals(name
)){
75 String uuidString
= labelAndValue
[1];
76 vocUuid
= UUID
.fromString(uuidString
);
77 setPageComplete(isPageComplete());
84 //setControl(composite);
87 public UUID
getVocUuid() {
91 public void setVocUuid(UUID vocUuid
) {
92 this.vocUuid
= vocUuid
;
98 private String
[][] getLabelAndValues(List
<TermVocabulary
<DefinedTermBase
>> vocs
) {
100 labelAndValues
= new String
[vocs
.size()][2];
101 for (int i
= 0; i
< vocs
.size(); i
++) {
102 labelAndValues
[i
][0] = vocs
.get(i
).getLabel();
103 labelAndValues
[i
][1] = vocs
.get(i
).getUuid().toString();
105 return labelAndValues
;
109 public boolean isPageComplete() {
110 boolean result
= CdmUtils
.isNotBlank(text_source
.getText()) && vocUuid
!= null;