Project

General

Profile

Revision 73ad1ed3

ID73ad1ed3b5796aa724be6a957d4792767ece8109
Parent 9ba1b637
Child a82453b9

Added by Patrick Plitzner over 3 years ago

ref #7362 Improve GfBio UX

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportPresenter.java
21 21
import org.eclipse.swt.dnd.DragSourceAdapter;
22 22
import org.eclipse.swt.dnd.DragSourceEvent;
23 23
import org.eclipse.swt.dnd.Transfer;
24
import org.eclipse.swt.events.FocusEvent;
25
import org.eclipse.swt.events.FocusListener;
24 26
import org.eclipse.swt.events.KeyAdapter;
25 27
import org.eclipse.swt.events.KeyEvent;
26 28
import org.eclipse.swt.events.SelectionAdapter;
27 29
import org.eclipse.swt.events.SelectionEvent;
28 30

  
31
import eu.etaxonomy.cdm.common.CdmUtils;
29 32
import eu.etaxonomy.taxeditor.l10n.Messages;
33
import eu.etaxonomy.taxeditor.model.ColorResources;
30 34
import eu.etaxonomy.taxeditor.model.MessagingUtils;
35
import eu.etaxonomy.taxeditor.preference.Resources;
31 36
import eu.etaxonomy.taxeditor.view.webimport.termimport.parser.SuggestParser;
32 37
import eu.etaxonomy.taxeditor.view.webimport.termimport.parser.TerminologyParser;
33 38
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestSearch;
......
45 50

  
46 51
    private static final String NO_CONNECTION_TITLE = Messages.GfBioTerminologyImportPresenter_NO_CONNECTION_TITLE;
47 52
    private static final String NO_CONNECTION_MESSAGE = Messages.GfBioTerminologyImportPresenter_NO_CONNECTION_MESSAGE;
53
    private static final String TXT_SEARCH_DEFAULT = "Enter search term...";
48 54

  
49 55
    private GfBioTerminologyImportComposite composite;
50 56

  
51 57
    public GfBioTerminologyImportPresenter(GfBioTerminologyImportComposite composite) {
52 58
        super();
53 59
        this.composite = composite;
54
        //text search
55 60
        composite.getBtnSearch().addSelectionListener(new SelectionAdapter() {
56 61
            @Override
57 62
            public void widgetSelected(SelectionEvent e) {
......
60 65
                }
61 66
            }
62 67
        });
68

  
69
        //text search
63 70
        composite.getTxtSearch().addKeyListener(new KeyAdapter() {
64 71
            @Override
65 72
            public void keyPressed(KeyEvent e) {
......
68 75
                }
69 76
            }
70 77
        });
78
        composite.getTxtSearch().setText(TXT_SEARCH_DEFAULT);
79
        composite.getTxtSearch().setForeground(ColorResources.getColor(Resources.SEARCH_VIEW_FOREGROUND));
80
        composite.getTxtSearch().addFocusListener(new FocusListener() {
81

  
82
            @Override
83
            public void focusGained(FocusEvent e) {
84
                composite.getTxtSearch().setForeground(ColorResources.getColor(Resources.SEARCH_VIEW_FOCUS));
85
                if (TXT_SEARCH_DEFAULT.equals(composite.getTxtSearch().getText())) {
86
                    composite.getTxtSearch().setText(""); //$NON-NLS-1$
87
                }
88
            }
89

  
90
            @Override
91
            public void focusLost(FocusEvent e) {
92
                if (CdmUtils.isBlank(composite.getTxtSearch().getText())) {
93
                    composite.getTxtSearch().setForeground(ColorResources.getColor(Resources.SEARCH_VIEW_FOREGROUND));
94
                    composite.getTxtSearch().setText(TXT_SEARCH_DEFAULT);
95
                }
96
            }
97
        });
98

  
99
        //combo
71 100
        String response = new RequestTerminologies().request();
72 101
        if(response==null){
73 102
            MessagingUtils.informationDialog(NO_CONNECTION_TITLE, NO_CONNECTION_MESSAGE);
74 103
            return;
75 104
        }
76 105
        Collection<TerminologyWrapper> terminologies = TerminologyParser.parse(response);
77
        //combo
106
        String comboDefaultText = "All ontologies";
78 107
        ComboViewer comboOntologies = composite.getComboTerminologies();
79 108
        comboOntologies.setLabelProvider(new TerminologyLabelProvider());
80 109
        comboOntologies.setContentProvider(new ArrayContentProvider());
81 110
        comboOntologies.setInput(terminologies);
111
        comboOntologies.getCombo().setText(comboDefaultText);
112

  
82 113
        composite.getBtnRemoveTerminology().addSelectionListener(new SelectionAdapter() {
83 114
            @Override
84 115
            public void widgetSelected(SelectionEvent e) {
85 116
                composite.getComboTerminologies().setSelection(null);
117
                comboOntologies.getCombo().setText(comboDefaultText);
86 118
            }
87 119
        });
88 120

  
......
111 143

  
112 144
    private void search(){
113 145
        String searchString = composite.getTxtSearch().getText();
146
        if(searchString.equals(TXT_SEARCH_DEFAULT)){
147
            return;
148
        }
114 149
        ISelection selection = composite.getComboTerminologies().getSelection();
115 150
        Collection<OntologyTermWrapper> wrapperList = new ArrayList<>();
116 151
        if(selection instanceof IStructuredSelection && !selection.isEmpty()){
117 152
            //FIXME add support for mutliple terminology selection
118 153
            Object next = ((IStructuredSelection) selection).iterator().next();
119 154
            if(next instanceof TerminologyWrapper){
120
                String response = new RequestSearch(searchString, ((TerminologyWrapper) next).getName()).request();
155
                String response = new RequestSearch(searchString, ((TerminologyWrapper) next).getAcronym()).request();
121 156
                if(response==null){
122 157
                    MessagingUtils.informationDialog(NO_CONNECTION_TITLE, NO_CONNECTION_MESSAGE);
123 158
                    return;

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)