Project

General

Profile

« Previous | Next » 

Revision 97e6a2a3

Added by Patrick Plitzner over 7 years ago

ref #5458 Split classification and taxa in two separate combo boxes

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionSelectionView.java
5 5

  
6 6
import com.vaadin.annotations.AutoGenerated;
7 7
import com.vaadin.data.Container;
8
import com.vaadin.data.Property.ValueChangeEvent;
9
import com.vaadin.data.Property.ValueChangeListener;
8 10
import com.vaadin.data.util.IndexedContainer;
9 11
import com.vaadin.event.ShortcutAction.KeyCode;
10 12
import com.vaadin.navigator.View;
......
26 28

  
27 29
public class DistributionSelectionView extends CustomComponent implements IDistributionSelectionComponent, View, ClickListener{
28 30

  
29
	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
30

  
31
	@AutoGenerated
32 31
    private VerticalLayout mainLayout;
33
    @AutoGenerated
34 32
    private Panel panel_1;
35
    @AutoGenerated
36 33
    private VerticalLayout verticalLayout_2;
37
    @AutoGenerated
38 34
    private Button button_proceed;
39
    @AutoGenerated
40 35
    private ComboBox distributionAreaBox;
41
    @AutoGenerated
42
    private ComboBox taxonNodeBox;
43
    @AutoGenerated
36
    private ComboBox classificationBox;
37
    private ComboBox taxonBox;
44 38
    private Label label_1;
45
    /**
46
	 *
47
	 */
48
	private static final long serialVersionUID = 1L;
39

  
40
    private static final long serialVersionUID = 1L;
49 41
	private DistributionSelectionComponentListener distListener;
50 42
	/**
51 43
	 * The constructor should first build the main layout, set the
......
70 62

  
71 63
	@Override
72 64
	public void buttonClick(ClickEvent event) {
73
		if(taxonNodeBox != null && distributionAreaBox != null){
74
			TaxonNode classification = (TaxonNode) taxonNodeBox.getValue();
75
			TermVocabulary<DefinedTermBase> term = (TermVocabulary<DefinedTermBase>)distributionAreaBox.getValue();
76
			try {
77
				distListener.buttonClick(classification, term);
78
			} catch (SQLException e) {
79
				// TODO Auto-generated catch block
80
				e.printStackTrace();
81
			}
65
		TaxonNode taxonNode = (TaxonNode) taxonBox.getValue();
66
		if(taxonNode==null){
67
			taxonNode = (TaxonNode) classificationBox.getValue();
68
		}
69
		TermVocabulary<DefinedTermBase> term = (TermVocabulary<DefinedTermBase>)distributionAreaBox.getValue();
70
		try {
71
			distListener.buttonClick(taxonNode, term);
72
		} catch (SQLException e) {
73
			e.printStackTrace();
82 74
		}
83 75
	}
84 76

  
85 77
	public void dataBinding(){
78
		classificationBox.setItemCaptionPropertyId(TaxonNodeContainer.LABEL);
79
		classificationBox.setContainerDataSource(new TaxonNodeContainer(null));
80
		classificationBox.setImmediate(true);
81
		classificationBox.addValueChangeListener(new ValueChangeListener() {
82
			@Override
83
			public void valueChange(ValueChangeEvent event) {
84
				TaxonNode parentNode = (TaxonNode) event.getProperty().getValue();
85
				taxonBox.setContainerDataSource(new TaxonNodeContainer(parentNode));
86
			}
87
		});
88
		
89
		taxonBox.setItemCaptionPropertyId(TaxonNodeContainer.LABEL);
86 90
		List<TermVocabulary<DefinedTermBase>> namedAreaList = distListener.getNamedAreaList();
87
		Container c = new TaxonNodeContainer();
88
		taxonNodeBox.setItemCaptionPropertyId(TaxonNodeContainer.LABEL);
89
		taxonNodeBox.setContainerDataSource(c);
90
//		classificationSelection.setContainerDataSource(c);
91 91
		Container d = new IndexedContainer(namedAreaList);
92 92
		distributionAreaBox.setContainerDataSource(d);
93
//		distributionSelection.setContainerDataSource(d);
94 93
	}
95 94

  
96 95
	@Override
......
150 149
        label_1.setImmediate(false);
151 150
        label_1.setWidth("213px");
152 151
        label_1.setHeight("-1px");
153
        label_1.setValue("Please choose a Classification or taxon and a distribution area to proceed.");
152
        label_1.setValue("Please choose a Classification and/or taxon and a distribution area to proceed.");
154 153
        verticalLayout_2.addComponent(label_1);
155 154

  
156 155
        // classificationBox
157
        taxonNodeBox = new ComboBox();
158
        taxonNodeBox.setCaption("Classification/Taxon: ");
159
        taxonNodeBox.setImmediate(false);
160
        taxonNodeBox.setWidth("200px");
161
        taxonNodeBox.setHeight("-1px");
162
        verticalLayout_2.addComponent(taxonNodeBox);
156
        classificationBox = new ComboBox();
157
        classificationBox.setCaption("Classification: ");
158
        classificationBox.setImmediate(false);
159
        classificationBox.setWidth("200px");
160
        classificationBox.setHeight("-1px");
161
        verticalLayout_2.addComponent(classificationBox);
162

  
163
        // taxonBox
164
        taxonBox = new ComboBox();
165
        taxonBox.setCaption("Taxon: ");
166
        taxonBox.setImmediate(false);
167
        taxonBox.setWidth("200px");
168
        taxonBox.setHeight("-1px");
169
        verticalLayout_2.addComponent(taxonBox);
163 170

  
164 171
        // distributionAreaBox
165 172
        distributionAreaBox = new ComboBox();

Also available in: Unified diff