1
|
/**
|
2
|
* Copyright (C) 2018 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.preference.wizard;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import org.apache.commons.lang.StringUtils;
|
15
|
import org.eclipse.jface.preference.IPreferenceStore;
|
16
|
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
17
|
import org.eclipse.jface.wizard.IWizardPage;
|
18
|
import org.eclipse.jface.wizard.Wizard;
|
19
|
|
20
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
21
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
22
|
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
|
23
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
|
24
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
25
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
26
|
|
27
|
/**
|
28
|
* @author k.luther
|
29
|
* @since 04.06.2018
|
30
|
*
|
31
|
*/
|
32
|
public class AvailableVocabularyWizard extends Wizard implements IConversationEnabled {
|
33
|
|
34
|
private ConversationHolder conversation;
|
35
|
private final AvailableAreaVocabulariesPage aPage;
|
36
|
|
37
|
public AvailableVocabularyWizard() {
|
38
|
setWindowTitle("Vocabulary Selection Wizard");
|
39
|
// TODO if preferenceStore has elements checked load elements in wizard
|
40
|
aPage = new AvailableAreaVocabulariesPage("AvailableDistributionPage");
|
41
|
}
|
42
|
|
43
|
@Override
|
44
|
public void addPages() {
|
45
|
addPage(aPage);
|
46
|
}
|
47
|
|
48
|
|
49
|
|
50
|
|
51
|
/**
|
52
|
* {@inheritDoc}
|
53
|
*/
|
54
|
@Override
|
55
|
public IWizardPage getPage(String pageName) {
|
56
|
|
57
|
return aPage;
|
58
|
}
|
59
|
|
60
|
/**
|
61
|
* {@inheritDoc}
|
62
|
*/
|
63
|
@Override
|
64
|
public int getPageCount() {
|
65
|
return 1;
|
66
|
}
|
67
|
|
68
|
/**
|
69
|
* {@inheritDoc}
|
70
|
*/
|
71
|
@Override
|
72
|
public IWizardPage[] getPages() {
|
73
|
IWizardPage[] pages = new IWizardPage[1];
|
74
|
pages [0] = aPage;
|
75
|
return pages;
|
76
|
}
|
77
|
|
78
|
|
79
|
|
80
|
|
81
|
|
82
|
/**
|
83
|
* {@inheritDoc}
|
84
|
*/
|
85
|
@Override
|
86
|
public String getWindowTitle() {
|
87
|
|
88
|
return "Vocabulary Selection Wizard";
|
89
|
}
|
90
|
|
91
|
|
92
|
|
93
|
|
94
|
|
95
|
|
96
|
|
97
|
/**
|
98
|
* {@inheritDoc}
|
99
|
*/
|
100
|
@Override
|
101
|
public boolean performCancel() {
|
102
|
// TODO Auto-generated method stub
|
103
|
return true;
|
104
|
}
|
105
|
|
106
|
/**
|
107
|
* {@inheritDoc}
|
108
|
*/
|
109
|
@Override
|
110
|
public boolean performFinish() {
|
111
|
Object[] checkedElements = ((CheckboxTableViewer)aPage.getViewer()).getCheckedElements();
|
112
|
|
113
|
ArrayList<UUID> listUIIDChecked = new ArrayList<UUID>();
|
114
|
for (Object o : checkedElements) {
|
115
|
if(o instanceof OrderedTermVocabulary){
|
116
|
OrderedTermVocabulary otb = (OrderedTermVocabulary) o;
|
117
|
listUIIDChecked.add(otb.getUuid());
|
118
|
}
|
119
|
}
|
120
|
String saveCheckedElements = StringUtils.join(listUIIDChecked, ",");
|
121
|
IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
|
122
|
PreferencesUtil.setPreferredVocabulariesForDistributionEditor(saveCheckedElements, false);
|
123
|
preferenceStore.setValue(PreferencesUtil.DISTRIBUTION_VOCABULARIES, saveCheckedElements);
|
124
|
return true;
|
125
|
}
|
126
|
|
127
|
|
128
|
|
129
|
|
130
|
/**
|
131
|
* {@inheritDoc}
|
132
|
*/
|
133
|
@Override
|
134
|
public void update(CdmDataChangeMap changeEvents) {
|
135
|
// TODO Auto-generated method stub
|
136
|
|
137
|
}
|
138
|
|
139
|
|
140
|
/**
|
141
|
* {@inheritDoc}
|
142
|
*/
|
143
|
@Override
|
144
|
public ConversationHolder getConversationHolder() {
|
145
|
if (conversation == null) {
|
146
|
conversation = CdmStore.createConversation();
|
147
|
}
|
148
|
return conversation;
|
149
|
}
|
150
|
|
151
|
}
|