Project

General

Profile

« Previous | Next » 

Revision 187cb471

Added by Patrick Plitzner about 5 years ago

Add checkbox to result composite

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/search/facet/term/TermSearchResultComposite.java
17 17
import org.eclipse.swt.events.FocusListener;
18 18
import org.eclipse.swt.events.MouseEvent;
19 19
import org.eclipse.swt.events.MouseListener;
20
import org.eclipse.swt.graphics.Color;
21
import org.eclipse.swt.layout.FillLayout;
22 20
import org.eclipse.swt.layout.GridData;
23 21
import org.eclipse.swt.layout.GridLayout;
22
import org.eclipse.swt.widgets.Button;
24 23
import org.eclipse.swt.widgets.Composite;
25 24
import org.eclipse.swt.widgets.Label;
26 25

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

  
30 26
/**
31 27
 * @author pplitzner
32 28
 * @since Jan 23, 2019
......
37 33
    private Label label;
38 34
    private boolean isSelected;
39 35
    private TermSearchResult result;
40
    private Label lblItemDash;
36
    private Button btnCheck;
37
    private Composite composite_1;
41 38

  
42 39
    /**
43 40
     * Create the composite.
......
56 53
        setLayout(gridLayout);
57 54

  
58 55
        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));
56
        composite.setLayout(new GridLayout(1, false));
57
        composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
58

  
59
        btnCheck = new Button(composite, SWT.CHECK);
60
        btnCheck.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
61 61

  
62
        lblItemDash = new Label(composite, SWT.NONE);
63
        lblItemDash.setText("   -   ");
64
        label = new Label(this, SWT.NONE);
62
        composite_1 = new Composite(this, SWT.NONE);
63
        composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
64
        composite_1.setLayout(new GridLayout(1, false));
65
        label = new Label(composite_1, SWT.NONE);
66
        label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
65 67
        label.setText(result.getContent().getRepresentation_L10n());
66 68
        label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
67 69
        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 70
        label.addFocusListener(new FocusListener() {
72 71

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

  
99 97

  
......
106 104
                System.out.println("mouseDoubleClick");
107 105
            }
108 106
        });
107

  
108
        Label lblDescription = new Label(composite_1, SWT.NONE);
109
        lblDescription.setText("Some description of the term. This can be a longer text. Also images appear in this area if they are present.");
109 110
    }
110 111

  
111 112
    public boolean isSelected() {
......
116 117
        return result;
117 118
    }
118 119

  
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
    }
133 120
    @Override
134 121
    protected void checkSubclass() {
135 122
        // Disable the check that prevents subclassing of SWT components
136 123
    }
124
    public Button getBtnCheck() {
125
        return btnCheck;
126
    }
137 127
}

Also available in: Unified diff