Project

General

Profile

Revision e208e523

IDe208e523086fabfa0e294f9c592da5a19c887729
Parent 7cc9bfd1
Child 460cc149

Added by Patrick Plitzner over 2 years ago

ref #7362 Add drag support

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportPresenter.java
10 10

  
11 11
import java.util.Collection;
12 12

  
13
import org.eclipse.jface.util.LocalSelectionTransfer;
13 14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.dnd.DND;
16
import org.eclipse.swt.dnd.DragSourceAdapter;
17
import org.eclipse.swt.dnd.Transfer;
18
import org.eclipse.swt.events.KeyAdapter;
14 19
import org.eclipse.swt.events.KeyEvent;
15
import org.eclipse.swt.events.KeyListener;
20
import org.eclipse.swt.events.SelectionAdapter;
16 21
import org.eclipse.swt.events.SelectionEvent;
17
import org.eclipse.swt.events.SelectionListener;
18 22

  
19 23
import eu.etaxonomy.taxeditor.model.MessagingUtils;
20 24
import eu.etaxonomy.taxeditor.view.webimport.termimport.parser.SuggestParser;
......
26 30
 * @since Apr 23, 2018
27 31
 *
28 32
 */
29
public class GfBioTerminologyImportPresenter implements SelectionListener, KeyListener  {
33
public class GfBioTerminologyImportPresenter {
30 34

  
31 35
    private GfBioTerminologyImportComposite composite;
32 36

  
......
34 38
        super();
35 39
        this.composite = composite;
36 40
        //text search
37
        composite.getBtnSearch().addSelectionListener(this);
38
        composite.getTxtSearch().addKeyListener(this);
41
        composite.getBtnSearch().addSelectionListener(new SelectionAdapter() {
42
            @Override
43
            public void widgetSelected(SelectionEvent e) {
44
                if(e.widget==composite.getBtnSearch()){
45
                    search();
46
                }
47
            }
48
        });
49
        composite.getTxtSearch().addKeyListener(new KeyAdapter() {
50
            @Override
51
            public void keyPressed(KeyEvent e) {
52
                if(e.keyCode==SWT.CR){
53
                    search();
54
                }
55
            }
56
        });
39 57
        //tree results
40 58
        composite.getTreeTermHierarchy().setContentProvider(new OntologyTermContentProvider());
41 59
        composite.getTreeTermHierarchy().setLabelProvider(new OntologyTermLabelProvider());
60
        Transfer[] transfers = new Transfer[] {LocalSelectionTransfer.getTransfer(),};
61
        composite.getTreeTermHierarchy().addDragSupport(DND.DROP_COPY,
62
                transfers, new DragSourceAdapter() {
63
            @Override
64
            public void dragSetData(org.eclipse.swt.dnd.DragSourceEvent event) {
65
                if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
66
                    LocalSelectionTransfer.getTransfer().setSelection(composite.getTreeTermHierarchy().getSelection());
67
                }
68
            }
69
        });
42 70
    }
43 71

  
44 72
    private void search(){
......
52 80
        composite.getTreeTermHierarchy().setInput(wrapperList);
53 81
    }
54 82

  
55
    @Override
56
    public void widgetSelected(SelectionEvent e) {
57
        if(e.widget==composite.getBtnSearch()){
58
            search();
59
        }
60
    }
61

  
62
    @Override
63
    public void widgetDefaultSelected(SelectionEvent e) {
64
    }
65

  
66
    @Override
67
    public void keyPressed(KeyEvent e) {
68
        if(e.keyCode==SWT.CR){
69
            search();
70
        }
71
    }
72

  
73
    @Override
74
    public void keyReleased(KeyEvent e) {
75

  
76
    }
77

  
78 83
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)