Revision 103f7f4a
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableAreaVocabulariesPage.java | ||
---|---|---|
17 | 17 |
import java.util.UUID; |
18 | 18 |
|
19 | 19 |
import org.apache.commons.lang.StringUtils; |
20 |
import org.eclipse.jface.viewers.CheckStateChangedEvent; |
|
21 |
import org.eclipse.jface.viewers.CheckboxTableViewer; |
|
22 |
import org.eclipse.jface.viewers.ICheckStateListener; |
|
23 |
import org.eclipse.jface.viewers.StyledString.Styler; |
|
24 |
import org.eclipse.jface.viewers.ViewerComparator; |
|
25 |
import org.eclipse.swt.SWT; |
|
26 |
import org.eclipse.swt.graphics.TextStyle; |
|
27 |
import org.eclipse.swt.layout.GridData; |
|
28 |
import org.eclipse.swt.layout.GridLayout; |
|
29 | 20 |
import org.eclipse.swt.widgets.Composite; |
30 |
import org.eclipse.swt.widgets.Display; |
|
31 | 21 |
|
32 | 22 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
33 | 23 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
34 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
35 | 24 |
import eu.etaxonomy.cdm.model.common.TermType; |
36 | 25 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
37 | 26 |
import eu.etaxonomy.cdm.model.metadata.CdmPreference; |
38 | 27 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; |
39 |
import eu.etaxonomy.taxeditor.editor.definedterm.VocabularyContentProvider; |
|
40 |
import eu.etaxonomy.taxeditor.editor.definedterm.VocabularyLabelProvider; |
|
28 |
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto; |
|
41 | 29 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
42 | 30 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
43 | 31 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySession; |
... | ... | |
69 | 57 |
*/ |
70 | 58 |
@Override |
71 | 59 |
public void createControl(Composite parent) { |
60 |
|
|
61 |
setTitle(String.format(Messages.AvailableAreaVocabulariesPage_PAGE_TITLE, featureTitle)); |
|
62 |
setDescription(String.format(Messages.AvailableAreaVocabulariesPage_PAGE_DESCRIPTION, featureTitle)); |
|
63 |
|
|
64 |
super.createControl(parent); |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* {@inheritDoc} |
|
69 |
*/ |
|
70 |
@Override |
|
71 |
protected String getCheckedValuesFromPreferences() { |
|
72 | 72 |
String vocString = null; |
73 | 73 |
if (localPref){ |
74 | 74 |
vocString = PreferencesUtil.getPreferredVocabulariesForDistributionEditor(localPref); |
75 | 75 |
}else if (pref != null){ |
76 | 76 |
vocString = pref.getValue(); |
77 | 77 |
} |
78 |
setTitle(String.format(Messages.AvailableAreaVocabulariesPage_PAGE_TITLE, featureTitle)); |
|
79 |
setDescription(String.format(Messages.AvailableAreaVocabulariesPage_PAGE_DESCRIPTION, featureTitle)); |
|
80 |
Composite composite = new Composite(parent, SWT.NULL); |
|
81 |
composite.setLayout(new GridLayout()); |
|
82 |
setViewer(CheckboxTableViewer.newCheckList(composite, SWT.NULL)); |
|
83 |
((CheckboxTableViewer)getViewer()).getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
|
84 |
|
|
85 |
Styler styler = new Styler() { |
|
86 |
@Override |
|
87 |
public void applyStyles(TextStyle textStyle) { |
|
88 |
textStyle.foreground = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK); |
|
89 |
} |
|
90 |
}; |
|
91 |
getViewer().setContentProvider(new VocabularyContentProvider()); |
|
92 |
getViewer().setLabelProvider(new VocabularyLabelProvider(styler)); |
|
93 |
getViewer().setComparator(new ViewerComparator()); |
|
94 |
((CheckboxTableViewer)getViewer()).addCheckStateListener(new ICheckStateListener() { |
|
95 |
|
|
96 |
private boolean ignoreCheckEvent = false; |
|
97 |
|
|
98 |
@Override |
|
99 |
public void checkStateChanged(CheckStateChangedEvent event) { |
|
100 |
|
|
101 |
|
|
102 |
if (ignoreCheckEvent ) { |
|
103 |
return; |
|
104 |
} |
|
105 |
|
|
106 |
ignoreCheckEvent = true; |
|
107 |
|
|
108 |
try { |
|
109 |
|
|
110 |
|
|
111 |
} |
|
112 |
finally { |
|
113 |
ignoreCheckEvent = false; |
|
114 |
} |
|
115 |
|
|
116 |
} |
|
117 |
}); |
|
118 |
rememberCheckedValues(vocString, null); |
|
119 |
((CheckboxTableViewer)getViewer()).setCheckedElements(listCheckedTerms.toArray()); |
|
120 |
setControl(composite); |
|
78 |
return vocString; |
|
79 |
} |
|
121 | 80 |
|
81 |
/** |
|
82 |
* {@inheritDoc} |
|
83 |
*/ |
|
84 |
@Override |
|
85 |
protected String getGrayedValuesFromPreferences() { |
|
86 |
// TODO Auto-generated method stub |
|
87 |
return null; |
|
122 | 88 |
} |
123 | 89 |
|
124 | 90 |
/** |
... | ... | |
146 | 112 |
} |
147 | 113 |
|
148 | 114 |
@Override |
149 |
protected List<TermVocabulary<DefinedTermBase>> getVocabulariesFromPreference(){
|
|
150 |
List<TermVocabulary<DefinedTermBase>> vocs = new ArrayList();
|
|
115 |
protected List<TermVocabularyDto> getVocabulariesFromPreference(){
|
|
116 |
List<TermVocabularyDto> vocs = new ArrayList<>();
|
|
151 | 117 |
|
152 | 118 |
if (PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies) == null ){ |
153 |
vocs = CdmStore.getService(IVocabularyService.class).findByTermType( |
|
154 |
type, null); |
|
119 |
vocs = CdmStore.getService(IVocabularyService.class).findVocabularyDtoByTermType(type); |
|
155 | 120 |
}else{ |
156 | 121 |
String vocString = PreferencesUtil.getStringValue(PreferencesUtil.DISTRIBUTION_VOCABULARIES); |
157 | 122 |
|
... | ... | |
165 | 130 |
} |
166 | 131 |
List<TermVocabulary> tempVocs = CdmStore.getService(IVocabularyService.class).find(uuidVocs); |
167 | 132 |
for (TermVocabulary voc: tempVocs){ |
168 |
vocs.add(voc);
|
|
133 |
vocs.add(new TermVocabularyDto(voc.getUuid(), voc.getRepresentations()));
|
|
169 | 134 |
} |
170 | 135 |
|
171 | 136 |
} |
Also available in: Unified diff
ref #7887 Use term DTOs for distribution wizards