Project

General

Profile

« Previous | Next » 

Revision d794dfd4

Added by Patrick Plitzner about 5 years ago

ref #8011 Add selection of search results

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/ColorResources.java
47 47
	}
48 48

  
49 49
	protected void initializeColorRegistry(ColorRegistry registry) {
50
	    registerColor(registry, Resources.COLOR_SWT_BG_DEFAULT, 214, 214, 214);
50 51
	    registerColor(registry, Resources.COLOR_MATRIX_SUMMARY_BG, 255, 255, 153);
51 52
	    registerColor(registry, Resources.COLOR_BULK_EDITOR_CANDIDATE, 243, 240, 165);
52 53
	    registerColor(registry, Resources.COLOR_BULK_EDITOR_TARGET, 135, 255, 135);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/Resources.java
50 50
	public static final String COLOR_CONTROL_SELECTED = "eu.etaxonomy.taxeditor.preferences.colorDefinition.nameEditor.colorContainerSelected";
51 51
	/** Constant <code>COLOR_CONTROL_SELECTED_FOCUS="eu.etaxonomy.taxeditor.preferences.colo"{trunked}</code> */
52 52
	public static final String COLOR_CONTROL_SELECTED_FOCUS = "eu.etaxonomy.taxeditor.preferences.colorDefinition.nameEditor.colorContainerSelectedFocus";
53
	public static final String COLOR_SWT_BG_DEFAULT = "eu.etaxonomy.taxeditor.preferences.colorDefinition.swtBGDefault";
53 54

  
54 55
	public static final String COLOR_BULK_EDITOR_CANDIDATE = "eu.etaxonomy.taxeditor.preferences.colorDefinition.bulkEditor.colorCandidate";
55 56

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/search/facet/term/TermSearchResultComposite.java
9 9
package eu.etaxonomy.taxeditor.view.search.facet.term;
10 10

  
11 11
import org.eclipse.jface.layout.GridDataFactory;
12
import org.eclipse.jface.resource.JFaceResources;
12 13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.events.DragDetectEvent;
15
import org.eclipse.swt.events.DragDetectListener;
16
import org.eclipse.swt.events.FocusEvent;
17
import org.eclipse.swt.events.FocusListener;
18
import org.eclipse.swt.events.MouseEvent;
19
import org.eclipse.swt.events.MouseListener;
20
import org.eclipse.swt.graphics.Color;
21
import org.eclipse.swt.layout.FillLayout;
13 22
import org.eclipse.swt.layout.GridData;
14 23
import org.eclipse.swt.layout.GridLayout;
15 24
import org.eclipse.swt.widgets.Composite;
16 25
import org.eclipse.swt.widgets.Label;
17 26

  
27
import eu.etaxonomy.taxeditor.model.ColorResources;
28
import eu.etaxonomy.taxeditor.preference.Resources;
29

  
18 30
/**
19 31
 * @author pplitzner
20 32
 * @since Jan 23, 2019
......
22 34
 */
23 35
public class TermSearchResultComposite extends Composite {
24 36

  
37
    private Label label;
38
    private boolean isSelected;
39
    private TermSearchResult result;
40
    private Label lblItemDash;
41

  
25 42
    /**
26 43
     * Create the composite.
27 44
     * @param result
......
30 47
     */
31 48
    public TermSearchResultComposite(TermSearchResult result, Composite parent, int style) {
32 49
        super(parent, style);
33
        setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
34
        setLayout(new GridLayout());
35
        Label label = new Label(parent, SWT.NONE);
50
        this.result = result;
51
        setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
52
        GridLayout gridLayout = new GridLayout();
53
        gridLayout.marginWidth = 0;
54
        gridLayout.horizontalSpacing = 0;
55
        gridLayout.numColumns = 2;
56
        setLayout(gridLayout);
57

  
58
        Composite composite = new Composite(this, SWT.NONE);
59
        composite.setLayout(new FillLayout(SWT.HORIZONTAL));
60
        composite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 2));
61

  
62
        lblItemDash = new Label(composite, SWT.NONE);
63
        lblItemDash.setText("   -   ");
64
        label = new Label(this, SWT.NONE);
36 65
        label.setText(result.getContent().getRepresentation_L10n());
66
        label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
37 67
        GridDataFactory.fillDefaults().applyTo(label);
68

  
69
        Label lblDescription = new Label(this, SWT.NONE);
70
        lblDescription.setText("Some description of the term. This can be a longer text. Also images appear in this area if they are present.");
71
        label.addFocusListener(new FocusListener() {
72

  
73
            @Override
74
            public void focusLost(FocusEvent e) {
75
                System.out.println("focusLost");
76
            }
77

  
78
            @Override
79
            public void focusGained(FocusEvent e) {
80
                System.out.println("focusGained");
81
            }
82
        });
83
        label.addDragDetectListener(new DragDetectListener() {
84

  
85
            @Override
86
            public void dragDetected(DragDetectEvent e) {
87
                System.out.println("dragDetected");
88
            }
89
        });
90
        label.addMouseListener(new MouseListener() {
91

  
92
            @Override
93
            public void mouseUp(MouseEvent e) {
94
                System.out.println("mouseUp");
95
                isSelected = !isSelected;
96
                setBgColor();
97
            }
98

  
99

  
100
            @Override
101
            public void mouseDown(MouseEvent e) {
102
            }
103

  
104
            @Override
105
            public void mouseDoubleClick(MouseEvent e) {
106
                System.out.println("mouseDoubleClick");
107
            }
108
        });
109
    }
110

  
111
    public boolean isSelected() {
112
        return isSelected;
38 113
    }
39 114

  
115
    public TermSearchResult getResult() {
116
        return result;
117
    }
118

  
119
    private void setBgColor() {
120
        if(isSelected){
121
            Color colorSelected = ColorResources.getColor(Resources.COLOR_LIST_EVEN);
122
            TermSearchResultComposite.this.setBackground(colorSelected);
123
            label.setBackground(colorSelected);
124
            lblItemDash.setBackground(colorSelected);
125
        }
126
        else{
127
            Color colorControlBackground = ColorResources.getColor(Resources.COLOR_SWT_BG_DEFAULT);
128
            TermSearchResultComposite.this.setBackground(colorControlBackground);
129
            label.setBackground(colorControlBackground);
130
            lblItemDash.setBackground(colorControlBackground);
131
        }
132
    }
40 133
    @Override
41 134
    protected void checkSubclass() {
42 135
        // Disable the check that prevents subclassing of SWT components
43 136
    }
44

  
45 137
}

Also available in: Unified diff