Project

General

Profile

Revision 5b5a7e10

ID5b5a7e1040ae3ed2eb3ee748a2ab9e9dd66a96ea
Parent 5e0fb4cb
Child 0fe2112f

Added by Patrick Plitzner over 4 years ago

Refactored setting window to work on taxon nodes #5458

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/ConfigWindow.java
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 com.vaadin.annotations.AutoGenerated;
13
import com.vaadin.data.Container;
14
import com.vaadin.ui.AbsoluteLayout;
15
import com.vaadin.ui.Button;
16
import com.vaadin.ui.ComboBox;
17
import com.vaadin.ui.CustomComponent;
18
import com.vaadin.ui.Label;
19
import com.vaadin.ui.TwinColSelect;
20
import com.vaadin.ui.Window;
21

  
22
import eu.etaxonomy.cdm.model.common.TermVocabulary;
23
import eu.etaxonomy.cdm.vaadin.presenter.dbstatus.settings.SettingsPresenter;
24

  
25
/**
26
 * @author alex
27
 * @date 22.04.2015
28
 *
29
 */
30
public class ConfigWindow extends CustomComponent {
31

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

  
34
    @AutoGenerated
35
    private AbsoluteLayout mainLayout;
36
    @AutoGenerated
37
    private Label label_4;
38
    @AutoGenerated
39
    private TwinColSelect distStatusSelect;
40
    @AutoGenerated
41
    private Label label_3;
42
    @AutoGenerated
43
    private Label label_2;
44
    @AutoGenerated
45
    private ComboBox distAreaBox;
46
    @AutoGenerated
47
    private ComboBox classificationBox;
48
    @AutoGenerated
49
    private Button okButton;
50
    @AutoGenerated
51
    private Button cancelButton;
52
    @AutoGenerated
53
    private Label label_1;
54
    private final SettingsPresenter presenter;
55
    /**
56
     * The constructor should first build the main layout, set the
57
     * composition root and then do any custom initialization.
58
     *
59
     * The constructor will not be automatically regenerated by the
60
     * visual editor.
61
     */
62
    public ConfigWindow() {
63
        buildMainLayout();
64
//        setCompositionRoot(mainLayout);
65
        presenter = new SettingsPresenter();
66
        init();
67
    }
68

  
69
    /**
70
     *
71
     */
72
    private void init() {
73
        Container classificationContainer = presenter.getClassificationContainer();
74
        Container distributionContainer = presenter.getDistributionContainer();
75
        TermVocabulary chosenArea = presenter.getChosenArea();
76
        classificationBox.setContainerDataSource(classificationContainer);
77
        classificationBox.setValue(presenter.getChosenClassification());
78
        distAreaBox.setContainerDataSource(distributionContainer);
79
        distAreaBox.setValue(chosenArea);
80
        distStatusSelect.setContainerDataSource(presenter.getDistributionStatusContainer());
81
    }
82

  
83
    public Window createWindow(){
84
        Window window = new Window();
85
        window.setModal(true);
86
        window.setHeight("600px");
87
        window.setWidth("500px");
88
        window.setCaption("Settings");
89
        window.setContent(mainLayout);
90
        return window;
91
    }
92

  
93
    @AutoGenerated
94
    private AbsoluteLayout buildMainLayout() {
95
        // common part: create layout
96
        mainLayout = new AbsoluteLayout();
97
        mainLayout.setImmediate(false);
98
        mainLayout.setWidth("100%");
99
        mainLayout.setHeight("100%");
100

  
101
        // top-level component properties
102
        setWidth("100.0%");
103
        setHeight("100.0%");
104

  
105
        // label_1
106
        label_1 = new Label();
107
        label_1.setImmediate(false);
108
        label_1.setWidth("100.0%");
109
        label_1.setHeight("40px");
110
        label_1.setValue("This is a description box for my settings");
111
        mainLayout.addComponent(label_1, "top:0.0px;left:0.0px;");
112

  
113
        // cancelButton
114
        cancelButton = new Button();
115
        cancelButton.setCaption("Cancel");
116
        cancelButton.setImmediate(true);
117
        cancelButton.setWidth("-1px");
118
        cancelButton.setHeight("-1px");
119
        mainLayout.addComponent(cancelButton, "top:380.0px;left:273.0px;");
120

  
121
        // okButton
122
        okButton = new Button();
123
        okButton.setCaption("OK");
124
        okButton.setImmediate(true);
125
        okButton.setWidth("67px");
126
        okButton.setHeight("-1px");
127
        mainLayout.addComponent(okButton, "top:380.0px;left:364.0px;");
128

  
129
        // classificationBox
130
        classificationBox = new ComboBox();
131
        classificationBox.setImmediate(false);
132
        classificationBox.setWidth("-1px");
133
        classificationBox.setHeight("-1px");
134
        mainLayout.addComponent(classificationBox, "top:97.0px;left:258.0px;");
135

  
136
        // distAreaBox
137
        distAreaBox = new ComboBox();
138
        distAreaBox.setImmediate(false);
139
        distAreaBox.setWidth("-1px");
140
        distAreaBox.setHeight("-1px");
141
        mainLayout.addComponent(distAreaBox, "top:141.0px;left:258.0px;");
142

  
143
        // label_2
144
        label_2 = new Label();
145
        label_2.setImmediate(false);
146
        label_2.setWidth("-1px");
147
        label_2.setHeight("-1px");
148
        label_2.setValue("Classification:");
149
        mainLayout.addComponent(label_2, "top:97.0px;left:24.0px;");
150

  
151
        // label_3
152
        label_3 = new Label();
153
        label_3.setImmediate(false);
154
        label_3.setWidth("-1px");
155
        label_3.setHeight("-1px");
156
        label_3.setValue("Distribution Area:");
157
        mainLayout.addComponent(label_3, "top:141.0px;left:24.0px;");
158

  
159
        // distStatusSelect
160
        distStatusSelect = new TwinColSelect();
161
        distStatusSelect.setImmediate(false);
162
        distStatusSelect.setWidth("-1px");
163
        distStatusSelect.setHeight("-1px");
164
        mainLayout.addComponent(distStatusSelect, "top:188.0px;left:152.0px;");
165

  
166
        // label_4
167
        label_4 = new Label();
168
        label_4.setImmediate(false);
169
        label_4.setWidth("-1px");
170
        label_4.setHeight("-1px");
171
        label_4.setValue("Distribution Status:");
172
        mainLayout.addComponent(label_4, "top:202.0px;left:20.0px;");
173

  
174
        return mainLayout;
175
    }
176

  
177
}
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/settings/SettingsPresenter.java
17 17
import com.vaadin.data.util.IndexedContainer;
18 18
import com.vaadin.server.VaadinSession;
19 19

  
20
import eu.etaxonomy.cdm.api.service.IClassificationService;
20
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
21 21
import eu.etaxonomy.cdm.api.service.ITermService;
22 22
import eu.etaxonomy.cdm.api.service.IVocabularyService;
23 23
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
24 24
import eu.etaxonomy.cdm.model.common.TermType;
25 25
import eu.etaxonomy.cdm.model.common.TermVocabulary;
26
import eu.etaxonomy.cdm.model.taxon.Classification;
26
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
27 27
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
28 28

  
29 29
/**
......
38 38
    private Container distributionStatusContainer;
39 39
    private IVocabularyService vocabularyService;
40 40
    private ITermService termService;
41
    private IClassificationService classificationService;
42
    private UUID clUUID;
41
    private ITaxonNodeService taxonNodeService;
42
    private UUID taxonNodeUuid;
43 43
    private UUID termUUID;
44 44

  
45 45

  
......
49 49

  
50 50
    }
51 51

  
52
    /**
53
     *
54
     */
55 52
    private void init() {
56
        clUUID = UUID.fromString(VaadinSession.getCurrent().getAttribute("taxonNodeUUID").toString());
53
        taxonNodeService = CdmSpringContextHelper.getTaxonNodeService();
54
        taxonNodeUuid = UUID.fromString(VaadinSession.getCurrent().getAttribute("taxonNodeUUID").toString());
57 55
        termUUID = UUID.fromString(VaadinSession.getCurrent().getAttribute("selectedTerm").toString());
58 56
        classificationContainer = new IndexedContainer(getClassificationList());
59 57
        distributionContainer = new IndexedContainer(getNamedAreaList());
60 58
        distributionStatusContainer = new IndexedContainer(getPresenceAbsenceVocabulary());
61 59
    }
62 60

  
63
    public Classification getChosenClassification(){
64
        return classificationService.load(clUUID);
61
    public TaxonNode getChosenClassification(){
62
        return taxonNodeService.load(taxonNodeUuid);
65 63
    }
66 64

  
67 65
    public TermVocabulary getChosenArea(){
......
87 85
        this.distributionStatusContainer = distributionStatusContainer;
88 86
    }
89 87

  
90

  
91

  
92
    private List<Classification> getClassificationList() {
93
        classificationService = CdmSpringContextHelper.getClassificationService();
94
        List<Classification> classificationList = classificationService.listClassifications(null, null, null, NODE_INIT_STRATEGY());
88
    private List<TaxonNode> getClassificationList() {
89
        List<TaxonNode> classificationList = taxonNodeService.loadChildNodesOfTaxonNode(getChosenClassification(), null, true, null);
90
        classificationList.add(getChosenClassification());
95 91
        return classificationList;
96 92
    }
97 93

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionTableView.java
42 42
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
43 43
import eu.etaxonomy.cdm.model.taxon.Taxon;
44 44
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
45
import eu.etaxonomy.cdm.vaadin.component.ConfigWindow;
46 45
import eu.etaxonomy.cdm.vaadin.component.DetailWindow;
47 46
import eu.etaxonomy.cdm.vaadin.component.HorizontalToolbar;
48 47
import eu.etaxonomy.cdm.vaadin.container.CdmSQLContainer;
......
176 175

  
177 176
            @Override
178 177
            public void buttonClick(ClickEvent event) {
179
                ConfigWindow cw = new ConfigWindow();
178
                SettingsConfigWindow cw = new SettingsConfigWindow();
180 179
                Window window  = cw.createWindow();
181 180
                getUI().addWindow(window);
182 181
            }
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/SettingsConfigWindow.java
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.view.dbstatus;
11

  
12
import com.vaadin.annotations.AutoGenerated;
13
import com.vaadin.data.Container;
14
import com.vaadin.ui.AbsoluteLayout;
15
import com.vaadin.ui.Button;
16
import com.vaadin.ui.ComboBox;
17
import com.vaadin.ui.CustomComponent;
18
import com.vaadin.ui.Label;
19
import com.vaadin.ui.TwinColSelect;
20
import com.vaadin.ui.Window;
21

  
22
import eu.etaxonomy.cdm.model.common.TermVocabulary;
23
import eu.etaxonomy.cdm.vaadin.presenter.dbstatus.settings.SettingsPresenter;
24

  
25
/**
26
 * @author alex
27
 * @date 22.04.2015
28
 *
29
 */
30
public class SettingsConfigWindow extends CustomComponent {
31

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

  
34
    @AutoGenerated
35
    private AbsoluteLayout mainLayout;
36
    @AutoGenerated
37
    private Label label_4;
38
    @AutoGenerated
39
    private TwinColSelect distStatusSelect;
40
    @AutoGenerated
41
    private Label label_3;
42
    @AutoGenerated
43
    private Label label_2;
44
    @AutoGenerated
45
    private ComboBox distAreaBox;
46
    @AutoGenerated
47
    private ComboBox classificationBox;
48
    @AutoGenerated
49
    private Button okButton;
50
    @AutoGenerated
51
    private Button cancelButton;
52
    @AutoGenerated
53
    private Label label_1;
54
    private final SettingsPresenter presenter;
55
    /**
56
     * The constructor should first build the main layout, set the
57
     * composition root and then do any custom initialization.
58
     *
59
     * The constructor will not be automatically regenerated by the
60
     * visual editor.
61
     */
62
    public SettingsConfigWindow() {
63
        buildMainLayout();
64
//        setCompositionRoot(mainLayout);
65
        presenter = new SettingsPresenter();
66
        init();
67
    }
68

  
69
    /**
70
     *
71
     */
72
    private void init() {
73
        Container classificationContainer = presenter.getClassificationContainer();
74
        Container distributionContainer = presenter.getDistributionContainer();
75
        TermVocabulary chosenArea = presenter.getChosenArea();
76
        classificationBox.setContainerDataSource(classificationContainer);
77
        classificationBox.setValue(presenter.getChosenClassification());
78
        distAreaBox.setContainerDataSource(distributionContainer);
79
        distAreaBox.setValue(chosenArea);
80
        distStatusSelect.setContainerDataSource(presenter.getDistributionStatusContainer());
81
    }
82

  
83
    public Window createWindow(){
84
        Window window = new Window();
85
        window.setModal(true);
86
        window.setHeight("600px");
87
        window.setWidth("500px");
88
        window.setCaption("Settings");
89
        window.setContent(mainLayout);
90
        return window;
91
    }
92

  
93
    @AutoGenerated
94
    private AbsoluteLayout buildMainLayout() {
95
        // common part: create layout
96
        mainLayout = new AbsoluteLayout();
97
        mainLayout.setImmediate(false);
98
        mainLayout.setWidth("100%");
99
        mainLayout.setHeight("100%");
100

  
101
        // top-level component properties
102
        setWidth("100.0%");
103
        setHeight("100.0%");
104

  
105
        // label_1
106
        label_1 = new Label();
107
        label_1.setImmediate(false);
108
        label_1.setWidth("100.0%");
109
        label_1.setHeight("40px");
110
        label_1.setValue("This is a description box for my settings");
111
        mainLayout.addComponent(label_1, "top:0.0px;left:0.0px;");
112

  
113
        // cancelButton
114
        cancelButton = new Button();
115
        cancelButton.setCaption("Cancel");
116
        cancelButton.setImmediate(true);
117
        cancelButton.setWidth("-1px");
118
        cancelButton.setHeight("-1px");
119
        mainLayout.addComponent(cancelButton, "top:380.0px;left:273.0px;");
120

  
121
        // okButton
122
        okButton = new Button();
123
        okButton.setCaption("OK");
124
        okButton.setImmediate(true);
125
        okButton.setWidth("67px");
126
        okButton.setHeight("-1px");
127
        mainLayout.addComponent(okButton, "top:380.0px;left:364.0px;");
128

  
129
        // classificationBox
130
        classificationBox = new ComboBox();
131
        classificationBox.setImmediate(false);
132
        classificationBox.setWidth("-1px");
133
        classificationBox.setHeight("-1px");
134
        mainLayout.addComponent(classificationBox, "top:97.0px;left:258.0px;");
135

  
136
        // distAreaBox
137
        distAreaBox = new ComboBox();
138
        distAreaBox.setImmediate(false);
139
        distAreaBox.setWidth("-1px");
140
        distAreaBox.setHeight("-1px");
141
        mainLayout.addComponent(distAreaBox, "top:141.0px;left:258.0px;");
142

  
143
        // label_2
144
        label_2 = new Label();
145
        label_2.setImmediate(false);
146
        label_2.setWidth("-1px");
147
        label_2.setHeight("-1px");
148
        label_2.setValue("Classification:");
149
        mainLayout.addComponent(label_2, "top:97.0px;left:24.0px;");
150

  
151
        // label_3
152
        label_3 = new Label();
153
        label_3.setImmediate(false);
154
        label_3.setWidth("-1px");
155
        label_3.setHeight("-1px");
156
        label_3.setValue("Distribution Area:");
157
        mainLayout.addComponent(label_3, "top:141.0px;left:24.0px;");
158

  
159
        // distStatusSelect
160
        distStatusSelect = new TwinColSelect();
161
        distStatusSelect.setImmediate(false);
162
        distStatusSelect.setWidth("-1px");
163
        distStatusSelect.setHeight("-1px");
164
        mainLayout.addComponent(distStatusSelect, "top:188.0px;left:152.0px;");
165

  
166
        // label_4
167
        label_4 = new Label();
168
        label_4.setImmediate(false);
169
        label_4.setWidth("-1px");
170
        label_4.setHeight("-1px");
171
        label_4.setValue("Distribution Status:");
172
        mainLayout.addComponent(label_4, "top:202.0px;left:20.0px;");
173

  
174
        return mainLayout;
175
    }
176

  
177
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)