-
Notifications
You must be signed in to change notification settings - Fork 4
/
QS3169_ComboTree.java
56 lines (46 loc) · 2.16 KB
/
QS3169_ComboTree.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.xored.q7.quality.mockups.issues.parts;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import com.xored.q7.quality.mockups.combotree.ComboTree;
import com.xored.q7.quality.mockups.issues.BaseMockupPart;
import com.xored.q7.quality.mockups.ui.treeviewer.model.TreeViewerModel;
import com.xored.q7.quality.mockups.ui.treeviewer.provider.CategoryProvider;
import com.xored.q7.quality.mockups.ui.treeviewer.provider.TreeLabelProvider;
public class QS3169_ComboTree extends BaseMockupPart {
@Override
public Control construct(Composite parent) {
Composite content = new Composite(parent, SWT.NONE);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(content);
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(content);
GridDataFactory labelData = GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.CENTER).grab(false, false);
GridDataFactory comboData = GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false);
Label firstComboLabel = new Label(content, SWT.NONE);
firstComboLabel.setText("First combo:");
ComboTree firstCombo = new ComboTree(content, SWT.NONE);
setProviders(firstCombo);
Label secondComboLabel = new Label(content, SWT.NONE);
secondComboLabel.setText("Second combo:");
ComboTree secondCombo = new ComboTree(content, SWT.NONE);
setProviders(secondCombo);
labelData.applyTo(firstComboLabel);
labelData.applyTo(secondComboLabel);
comboData.applyTo(firstCombo);
comboData.applyTo(secondCombo);
return content;
}
private void setProviders(ComboTree combo) {
// fake instance of the same model, as used by mockups UI on the left
TreeViewerModel input = new TreeViewerModel();
IContentProvider content = new CategoryProvider();
ILabelProvider label = new TreeLabelProvider();
combo.setContentProvider(content);
combo.setLabelProvider(label);
combo.setInput(input);
}
}