Project

General

Profile

Revision 75caa576

ID75caa5760d2f5bbbf4a3d1701a00c50a31e23a1e
Parent 8785bad2
Child 6c58d852

Added by Patrick Plitzner almost 3 years ago

ref #8011 Add method workflow skeleton to TermSearch

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/search/term/TermFilter.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.view.search.term;
10

  
11
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
12

  
13
/**
14
 * @author pplitzner
15
 * @since Jan 22, 2019
16
 *
17
 */
18
public class TermFilter {
19

  
20
    private TermVocabularyDto vocabulary;
21

  
22
    /**
23
     * @param vocabulary
24
     */
25
    public TermFilter(TermVocabularyDto vocabulary) {
26
        super();
27
        this.vocabulary = vocabulary;
28
    }
29

  
30
    /**
31
     * @return the vocabulary
32
     */
33
    public TermVocabularyDto getVocabulary() {
34
        return vocabulary;
35
    }
36

  
37
    /**
38
     * @param vocabulary the vocabulary to set
39
     */
40
    public void setVocabulary(TermVocabularyDto vocabulary) {
41
        this.vocabulary = vocabulary;
42
    }
43

  
44

  
45

  
46
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/search/term/TermSearch.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.view.search.term;
10

  
11
import javax.annotation.PostConstruct;
12
import javax.inject.Named;
13

  
14
import org.eclipse.e4.core.contexts.IEclipseContext;
15
import org.eclipse.e4.ui.services.EMenuService;
16
import org.eclipse.e4.ui.services.IServiceConstants;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Shell;
20

  
21
/**
22
 * @author pplitzner
23
 * @since Jan 22, 2019
24
 *
25
 */
26
public class TermSearch {
27

  
28
    @PostConstruct
29
    public void create(Composite parent, IEclipseContext context, @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
30
            EMenuService menuService){
31
        new TermSearchController(new TermSearchComposite(parent, SWT.NONE));
32
    }
33
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/search/term/TermSearchComposite.java
14 14
import org.eclipse.swt.layout.GridData;
15 15
import org.eclipse.swt.layout.GridLayout;
16 16
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.ExpandBar;
18
import org.eclipse.swt.widgets.ExpandItem;
19
import org.eclipse.swt.widgets.Label;
17 20
import org.eclipse.swt.widgets.Text;
18 21

  
19 22
/**
......
22 25
 *
23 26
 */
24 27
public class TermSearchComposite extends Composite {
25
    private Text text;
28
    private Text txtSearch;
29
    private Composite searchResultComposite;
26 30

  
27 31
    /**
28 32
     * Create the composite.
......
38 42
        filterComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
39 43
        filterComposite.setBounds(0, 0, 64, 64);
40 44

  
41
        text = new Text(filterComposite, SWT.BORDER);
42
        text.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
45
        txtSearch = new Text(filterComposite, SWT.BORDER);
46
        txtSearch.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
43 47

  
44 48
        ScrolledComposite scrolledComposite = new ScrolledComposite(filterComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
45 49
        scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
46 50
        scrolledComposite.setExpandHorizontal(true);
47 51
        scrolledComposite.setExpandVertical(true);
48 52

  
49
        Composite searchResultComposite = new Composite(this, SWT.NONE);
53
        searchResultComposite = new Composite(this, SWT.NONE);
54
        searchResultComposite.setLayout(new GridLayout(1, false));
50 55
        searchResultComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
51 56
        searchResultComposite.setBounds(0, 0, 64, 64);
52 57

  
58
        ScrolledComposite resultComposite = new ScrolledComposite(searchResultComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
59
        resultComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
60
        resultComposite.setExpandHorizontal(true);
61
        resultComposite.setExpandVertical(true);
62

  
63
        ExpandBar expandBar = new ExpandBar(resultComposite, SWT.NONE);
64

  
65
        ExpandItem xpndtmNewExpanditem = new ExpandItem(expandBar, SWT.NONE);
66
        xpndtmNewExpanditem.setExpanded(true);
67
        xpndtmNewExpanditem.setText("New ExpandItem");
68

  
69
        Label lblNewLabel = new Label(expandBar, SWT.NONE);
70
        xpndtmNewExpanditem.setControl(lblNewLabel);
71
        lblNewLabel.setText("New Label");
72
        xpndtmNewExpanditem.setHeight(xpndtmNewExpanditem.getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
73

  
74
        ExpandItem xpndtmNewExpanditem_1 = new ExpandItem(expandBar, SWT.NONE);
75
        xpndtmNewExpanditem_1.setText("New ExpandItem");
76
        resultComposite.setContent(expandBar);
77
        resultComposite.setMinSize(expandBar.computeSize(SWT.DEFAULT, SWT.DEFAULT));
78

  
53 79
    }
54 80

  
55 81
    @Override
56 82
    protected void checkSubclass() {
57 83
        // Disable the check that prevents subclassing of SWT components
58 84
    }
85
    public Text getTxtSearch() {
86
        return txtSearch;
87
    }
88
    public Composite getSearchResultComposite() {
89
        return searchResultComposite;
90
    }
59 91
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/search/term/TermSearchController.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.view.search.term;
10

  
11
import java.util.ArrayList;
12
import java.util.List;
13

  
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.events.KeyEvent;
16
import org.eclipse.swt.events.KeyListener;
17
import org.eclipse.swt.widgets.Label;
18

  
19
import eu.etaxonomy.cdm.model.common.Language;
20
import eu.etaxonomy.cdm.model.description.Feature;
21
import eu.etaxonomy.cdm.model.location.Country;
22
import eu.etaxonomy.cdm.persistence.dto.TermDto;
23
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
24
import eu.etaxonomy.cdm.remote.l10n.TermRepresentation_L10n;
25

  
26
/**
27
 * @author pplitzner
28
 * @since Jan 22, 2019
29
 *
30
 */
31
public class TermSearchController implements KeyListener{
32

  
33
    private TermSearchComposite composite;
34

  
35
    public TermSearchController(TermSearchComposite composite) {
36
        this.composite = composite;
37
        composite.getTxtSearch().addKeyListener(this);
38
    }
39

  
40
    private void search(String searchString){
41
        //search terms via term service
42
        List<TermDto> terms = new ArrayList<>();
43
        terms.add(TermDto.fromTerm(Feature.ANATOMY()));
44
        terms.add(TermDto.fromTerm(Feature.BIOLOGY_ECOLOGY()));
45
        terms.add(TermDto.fromTerm(Country.AFGHANISTAN()));
46
        terms.add(TermDto.fromTerm(Country.DENMARKKINGDOMOF()));
47
        terms.add(TermDto.fromTerm(Language.ENGLISH()));
48
        terms.add(TermDto.fromTerm(Language.SUKUMA()));
49

  
50
        List<TermFilter> filters = createResultsAndFilters(terms);
51

  
52
        createFilterButtons(filters);
53

  
54
    }
55

  
56
    private void createFilterButtons(List<TermFilter> filters) {
57

  
58
    }
59

  
60
    private void extractFilters(List<TermDto> terms) {
61
    }
62

  
63
    private List<TermFilter> createResultsAndFilters(List<TermDto> terms) {
64
        List<TermVocabularyDto> vocabularyDtos = new ArrayList<>();
65
        for (TermDto term : terms) {
66
            term.localize(new TermRepresentation_L10n());
67
            createResultComposite(term);
68
            if(!vocabularyDtos.contains(term.getVocabularyUuid())){
69
                vocabularyDtos.add(term.getVocabularyDto());
70
            }
71
        }
72
        List<TermFilter> filters = new ArrayList<>();
73
        for (TermVocabularyDto termVocabularyDto : vocabularyDtos) {
74
            filters.add(new TermFilter(termVocabularyDto));
75
        }
76
        return filters;
77
    }
78

  
79
    private void createResultComposite(TermDto term) {
80
        Label label = new Label(composite.getSearchResultComposite(), SWT.NONE);
81
        label.setText(term.getRepresentation_L10n());
82
    }
83

  
84
    @Override
85
    public void keyPressed(KeyEvent e) {
86
        if(e.widget==composite.getTxtSearch()){
87
            search(composite.getTxtSearch().getText());
88
        }
89
    }
90

  
91
    @Override
92
    public void keyReleased(KeyEvent e) {
93
    }
94

  
95
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)