Merge branch 'develop' into wset
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / workingSet / WorkingSetComposite.java
1 /**
2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.taxeditor.editor.workingSet;
10
11 import java.util.List;
12
13 import org.eclipse.jface.viewers.TreeViewer;
14 import org.eclipse.swt.SWT;
15 import org.eclipse.swt.events.SelectionEvent;
16 import org.eclipse.swt.events.SelectionListener;
17 import org.eclipse.swt.layout.FillLayout;
18 import org.eclipse.swt.layout.GridData;
19 import org.eclipse.swt.layout.GridLayout;
20 import org.eclipse.swt.widgets.Button;
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.swt.widgets.Label;
23 import org.eclipse.swt.widgets.Text;
24 import org.eclipse.swt.widgets.Tree;
25
26 import eu.etaxonomy.cdm.api.service.IClassificationService;
27 import eu.etaxonomy.cdm.model.common.TermType;
28 import eu.etaxonomy.cdm.model.location.NamedArea;
29 import eu.etaxonomy.cdm.model.taxon.Classification;
30 import eu.etaxonomy.taxeditor.store.CdmStore;
31 import eu.etaxonomy.taxeditor.ui.combo.TermUuidComboViewer;
32 import eu.etaxonomy.taxeditor.ui.dialog.selection.NamedAreaSelectionDialog;
33 import eu.etaxonomy.taxeditor.util.TaxonTreeNodeContentProvider;
34 import eu.etaxonomy.taxeditor.util.TaxonTreeNodeLabelProvider;
35
36 /**
37 * @author pplitzner
38 * @since Nov 21, 2017
39 *
40 */
41 public class WorkingSetComposite extends Composite {
42 private Text txt_label;
43
44 public WorkingSetComposite(Composite parent, int style) {
45 super(parent, style);
46 setLayout(new GridLayout(3, false));
47
48 Label lblNewLabel = new Label(this, SWT.NONE);
49 lblNewLabel.setText("Working set label");
50
51 txt_label = new Text(this, SWT.BORDER);
52 txt_label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
53
54 Label lblNewLabel_1 = new Label(this, SWT.NONE);
55 lblNewLabel_1.setText("Taxon filter");
56
57 Label lblNewLabel_2 = new Label(this, SWT.NONE);
58 lblNewLabel_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
59 lblNewLabel_2.setText("Rank min");
60
61 TermUuidComboViewer combo = new TermUuidComboViewer(this, SWT.NONE);
62 combo.setInput(TermType.Rank);
63 combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
64
65 Composite composite = new Composite(this, SWT.NONE);
66 composite.setLayout(new FillLayout(SWT.HORIZONTAL));
67 composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
68
69 TreeViewer viewer = new TreeViewer(new Tree(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
70
71 viewer.setContentProvider(new TaxonTreeNodeContentProvider());
72 viewer.setLabelProvider(new TaxonTreeNodeLabelProvider());
73 List<Classification> list = CdmStore.getService(IClassificationService.class).list(Classification.class, null, null, null, null);
74 viewer.setInput(list);
75
76 Label lblNewLabel_3 = new Label(this, SWT.NONE);
77 lblNewLabel_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
78 lblNewLabel_3.setText("Rank max");
79
80 TermUuidComboViewer combo_1 = new TermUuidComboViewer(this, SWT.NONE);
81 combo_1.setInput(TermType.Rank);
82 combo_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
83
84 Label lblNewLabel_4 = new Label(this, SWT.NONE);
85 lblNewLabel_4.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
86 lblNewLabel_4.setText("Area");
87
88 Composite composite_1 = new Composite(this, SWT.NONE);
89 composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
90 composite_1.setLayout(new GridLayout(2, false));
91
92 Label lblNewLabel_5 = new Label(composite_1, SWT.NONE);
93 lblNewLabel_5.setText("New Label");
94
95
96 Button btnNewButton = new Button(composite_1, SWT.NONE);
97 btnNewButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
98 btnNewButton.setText("Choose");
99 btnNewButton.addSelectionListener(new SelectionListener() {
100
101 @Override
102 public void widgetSelected(SelectionEvent e) {
103 NamedArea area = NamedAreaSelectionDialog.select(parent.getShell(), null, null, null);
104 lblNewLabel_5.setText(area.getLabel());
105 }
106
107 @Override
108 public void widgetDefaultSelected(SelectionEvent e) {
109 }
110 });
111
112
113 }
114
115 @Override
116 protected void checkSubclass() {
117 // Disable the check that prevents subclassing of SWT components
118 }
119 public Text getTxt_label() {
120 return txt_label;
121 }
122 }