Project

General

Profile

Download (5.62 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2015 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.vaadin.component;
11

    
12
import java.sql.SQLException;
13

    
14
import com.vaadin.annotations.AutoGenerated;
15
import com.vaadin.ui.Alignment;
16
import com.vaadin.ui.Button;
17
import com.vaadin.ui.ComboBox;
18
import com.vaadin.ui.CustomComponent;
19
import com.vaadin.ui.HorizontalLayout;
20
import com.vaadin.ui.Label;
21
import com.vaadin.ui.Table;
22
import com.vaadin.ui.Table.ColumnHeaderMode;
23
import com.vaadin.ui.VerticalLayout;
24

    
25
import eu.etaxonomy.cdm.vaadin.presenter.EditConceptRelationshipPresenter;
26

    
27
/**
28
 * @author cmathew
29
 * @date 13 Apr 2015
30
 *
31
 */
32
public class EditConceptRelationshipComposite extends CustomComponent {
33

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

    
36
    @AutoGenerated
37
    private VerticalLayout mainLayout;
38
    @AutoGenerated
39
    private HorizontalLayout saveCancelHLayout;
40
    @AutoGenerated
41
    private Button cancelButton;
42
    @AutoGenerated
43
    private Button saveButton;
44
    @AutoGenerated
45
    private Table toTaxaTable;
46
    @AutoGenerated
47
    private ComboBox conceptRComboBox;
48
    @AutoGenerated
49
    private Label fromTaxonLabel;
50

    
51
    private final EditConceptRelationshipPresenter presenter;
52

    
53
    private final Object fromTaxonId, taxonRTypeId;
54

    
55
    private final String fromTaxonName;
56
    /**
57
     * The constructor should first build the main layout, set the
58
     * composition root and then do any custom initialization.
59
     *
60
     * The constructor will not be automatically regenerated by the
61
     * visual editor.
62
     */
63
    public EditConceptRelationshipComposite(Object fromTaxonId, String fromTaxonName, Object taxonRTypeId) {
64
        buildMainLayout();
65
        setCompositionRoot(mainLayout);
66

    
67
        this.presenter = new EditConceptRelationshipPresenter();
68
        this.fromTaxonId = fromTaxonId;
69
        this.fromTaxonName = fromTaxonName;
70
        this.taxonRTypeId = taxonRTypeId;
71
        init();
72
    }
73

    
74
    private void init() {
75
        initConceptRComboBox();
76
    }
77

    
78
    private void initConceptRComboBox() {
79
        conceptRComboBox.setImmediate(true);
80
        try {
81
            conceptRComboBox.setContainerDataSource(presenter.loadTaxonRelationshipTypeContainer());
82
        } catch (SQLException e) {
83
            // TODO Auto-generated catch block
84
            e.printStackTrace();
85
        }
86
        conceptRComboBox.setValue(taxonRTypeId);
87
    }
88

    
89
    private void initToTaxaTable() {
90
        toTaxaTable.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
91
        try {
92
            toTaxaTable.setContainerDataSource(presenter.loadTaxonRelationshipContainer(fromTaxonId));
93
        } catch (SQLException e) {
94
            // TODO Auto-generated catch block
95
            e.printStackTrace();
96
        }
97
    }
98

    
99
    @AutoGenerated
100
    private VerticalLayout buildMainLayout() {
101
        // common part: create layout
102
        mainLayout = new VerticalLayout();
103
        mainLayout.setImmediate(false);
104
        mainLayout.setWidth("260px");
105
        mainLayout.setHeight("252px");
106
        mainLayout.setMargin(true);
107
        mainLayout.setSpacing(true);
108

    
109
        // top-level component properties
110
        setWidth("260px");
111
        setHeight("252px");
112

    
113
        // fromTaxonLabel
114
        fromTaxonLabel = new Label();
115
        fromTaxonLabel.setImmediate(false);
116
        fromTaxonLabel.setWidth("-1px");
117
        fromTaxonLabel.setHeight("-1px");
118
        fromTaxonLabel.setValue("From Taxon");
119
        mainLayout.addComponent(fromTaxonLabel);
120
        mainLayout.setComponentAlignment(fromTaxonLabel, new Alignment(20));
121

    
122
        // conceptRcomboBox
123
        conceptRComboBox = new ComboBox();
124
        conceptRComboBox.setImmediate(false);
125
        conceptRComboBox.setWidth("-1px");
126
        conceptRComboBox.setHeight("-1px");
127
        mainLayout.addComponent(conceptRComboBox);
128
        mainLayout.setComponentAlignment(conceptRComboBox, new Alignment(20));
129

    
130
        // toTaxaTable
131
        toTaxaTable = new Table();
132
        toTaxaTable.setImmediate(false);
133
        toTaxaTable.setWidth("199px");
134
        toTaxaTable.setHeight("124px");
135
        mainLayout.addComponent(toTaxaTable);
136
        mainLayout.setExpandRatio(toTaxaTable, 1.0f);
137
        mainLayout.setComponentAlignment(toTaxaTable, new Alignment(20));
138

    
139
        // saveCancelHLayout
140
        saveCancelHLayout = buildSaveCancelHLayout();
141
        mainLayout.addComponent(saveCancelHLayout);
142
        mainLayout.setComponentAlignment(saveCancelHLayout, new Alignment(20));
143

    
144
        return mainLayout;
145
    }
146

    
147
    @AutoGenerated
148
    private HorizontalLayout buildSaveCancelHLayout() {
149
        // common part: create layout
150
        saveCancelHLayout = new HorizontalLayout();
151
        saveCancelHLayout.setImmediate(false);
152
        saveCancelHLayout.setWidth("-1px");
153
        saveCancelHLayout.setHeight("-1px");
154
        saveCancelHLayout.setMargin(false);
155
        saveCancelHLayout.setSpacing(true);
156

    
157
        // saveButton
158
        saveButton = new Button();
159
        saveButton.setCaption("save");
160
        saveButton.setImmediate(false);
161
        saveButton.setWidth("-1px");
162
        saveButton.setHeight("-1px");
163
        saveCancelHLayout.addComponent(saveButton);
164

    
165
        // cancelButton
166
        cancelButton = new Button();
167
        cancelButton.setCaption("cancel");
168
        cancelButton.setImmediate(false);
169
        cancelButton.setWidth("-1px");
170
        cancelButton.setHeight("-1px");
171
        saveCancelHLayout.addComponent(cancelButton);
172

    
173
        return saveCancelHLayout;
174
    }
175

    
176
}
(2-2/5)