ref #10221: code cleaning
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / AbstractVocabularySelectionPreference.java
1 /**
2 * Copyright (C) 2019 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;
10
11 import java.util.ArrayList;
12 import java.util.List;
13 import java.util.UUID;
14
15 import org.eclipse.swt.widgets.Composite;
16 import org.eclipse.swt.widgets.Control;
17 import org.eclipse.swt.widgets.Table;
18
19 import eu.etaxonomy.cdm.api.service.IVocabularyService;
20 import eu.etaxonomy.cdm.model.metadata.CdmPreference;
21 import eu.etaxonomy.cdm.model.term.TermType;
22 import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
23 import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
24 import eu.etaxonomy.taxeditor.store.CdmStore;
25
26 /**
27 * @author k.luther
28 * @since 30.08.2019
29 */
30 public abstract class AbstractVocabularySelectionPreference extends CdmPreferencePage {
31 protected Table table;
32
33 protected CdmPreference pref;
34 protected TermType type;
35 protected List<CdmPreference> prefsToDelete = new ArrayList<>();
36 protected List<TermVocabularyDto> vocabularies;
37 protected boolean override;
38
39 @Override
40 protected Control createContents(Composite parent) {
41 // TODO Auto-generated method stub
42 return null;
43 }
44
45 /**
46 *
47 */
48 protected void refresh() {
49 //getValues();
50 if (table != null){
51 table.removeAll();
52 if (pref != null){
53 createTableRow(pref);
54 }
55 table.redraw();
56 table.pack();
57
58 }
59
60 }
61
62 public abstract void createTableRow(CdmPreference pref) ;
63 // public abstract String getUUIDFromSubject(CdmPreference pref);
64
65 protected void fillVocabularies(CdmPreference vocPref){
66 List<UUID> uuids = null;
67 if (isAdminPreference){
68 uuids = PreferencesUtil.createUuidList(vocPref.getValue());
69 }else{
70 uuids = PreferencesUtil.createUUIDListFromStringPref(vocPref.getPredicate(), false);
71 }
72 if (uuids == null || uuids.isEmpty()){
73 vocabularies = new ArrayList();
74 vocabularies = CdmStore.getService(IVocabularyService.class).findVocabularyDtoByTermType(type);
75 }else{
76 vocabularies = CdmStore.getService(IVocabularyService.class).findVocabularyDtoByVocabularyUuids(uuids);
77 }
78 }
79
80 }