Project

General

Profile

« Previous | Next » 

Revision d196eb4d

Added by Patrick Plitzner over 6 years ago

ref #5458 Usability and UI tweaks

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionSettingsConfigWindow.java
19 19
import com.vaadin.data.util.sqlcontainer.RowId;
20 20
import com.vaadin.server.VaadinSession;
21 21
import com.vaadin.ui.AbstractLayout;
22
import com.vaadin.ui.AbstractOrderedLayout;
22 23
import com.vaadin.ui.Alignment;
23 24
import com.vaadin.ui.Button;
24 25
import com.vaadin.ui.Button.ClickEvent;
......
26 27
import com.vaadin.ui.ComboBox;
27 28
import com.vaadin.ui.CustomComponent;
28 29
import com.vaadin.ui.HorizontalLayout;
29
import com.vaadin.ui.Label;
30 30
import com.vaadin.ui.ListSelect;
31 31
import com.vaadin.ui.Notification;
32 32
import com.vaadin.ui.Table.ColumnHeaderMode;
......
60 60
    private Button cancelButton;
61 61
    private final SettingsPresenter presenter;
62 62
	private Window window;
63
	private HorizontalLayout mainLayout;
63
	private AbstractOrderedLayout mainLayout;
64 64

  
65 65
    /**
66 66
     * The constructor should first build the main layout, set the
......
80 80
        Container distributionContainer = presenter.getDistributionContainer();
81 81
        TermVocabulary<NamedArea> chosenArea = presenter.getChosenArea();
82 82

  
83
        classificationBox.setItemCaptionPropertyId(TaxonNodeContainer.LABEL);
84 83
        classificationBox.setContainerDataSource(new TaxonNodeContainer(null));
85
		classificationBox.setImmediate(true);
84
		if(classificationBox.getItemIds().size()==1){
85
		    classificationBox.setValue(classificationBox.getItemIds().iterator().next());
86
		}
86 87
        TaxonNode chosenTaxonNode = presenter.getChosenTaxonNode();
87
		classificationBox.addValueChangeListener(this);
88 88
        if(chosenTaxonNode!=null){
89 89
        	classificationBox.setValue(chosenTaxonNode.getClassification().getRootNode());
90 90
        	try {
......
96 96
        	taxonTree.select(new RowId(chosenTaxonNode.getId()));
97 97
            taxonTree.setVisibleColumns("Name");
98 98
        }
99
        classificationBox.addValueChangeListener(this);
99 100
        distAreaBox.setContainerDataSource(distributionContainer);
100 101
        distAreaBox.setValue(chosenArea);
101 102
        distAreaBox.addValueChangeListener(this);
......
123 124

  
124 125
    private AbstractLayout buildMainLayout() {
125 126

  
126
    	mainLayout = new HorizontalLayout();
127
        mainLayout.setImmediate(false);
127
        mainLayout = new VerticalLayout();
128 128
        mainLayout.setSizeFull();
129
        mainLayout.setMargin(true);
130
        mainLayout.setSpacing(true);
129

  
130
    	HorizontalLayout leftAndRightContainer = new HorizontalLayout();
131
        leftAndRightContainer.setImmediate(false);
132
        leftAndRightContainer.setSizeFull();
133
        leftAndRightContainer.setMargin(true);
134
        leftAndRightContainer.setSpacing(true);
131 135

  
132 136
        VerticalLayout leftContainer = new VerticalLayout();
133 137
        leftContainer.setImmediate(false);
......
141 145

  
142 146
        //classification and term
143 147
        classificationBox = new ComboBox("Classification");
148
        classificationBox.setItemCaptionPropertyId(TaxonNodeContainer.LABEL);
149
        classificationBox.setInputPrompt("Please select a classification...");
144 150
        classificationBox.setImmediate(true);
151
        classificationBox.setNewItemsAllowed(false);
152
        classificationBox.setNullSelectionAllowed(false);
145 153
        classificationBox.setSizeFull();
146 154
        classificationBox.setWidth("100%");
147 155

  
148 156
        //distribution area box
149 157
        distAreaBox = new ComboBox("Distribution Area:");
158
        distAreaBox.setInputPrompt("Please select a distribution area...");
150 159
        distAreaBox.setImmediate(true);
160
        distAreaBox.setNullSelectionAllowed(false);
161
        distAreaBox.setNewItemsAllowed(false);
162
        distAreaBox.setSizeFull();
151 163
        distAreaBox.setWidth("100%");
152 164

  
153 165
        // named areas
......
161 173
        taxonTree.setSelectable(true);
162 174
        taxonTree.setSizeFull();
163 175
        taxonTree.setImmediate(true);
164
        taxonTree.setPageLength(20);
165 176
        taxonTree.setCacheRate(20);
166 177
        taxonTree.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
167 178

  
168 179
        leftContainer.addComponent(distAreaBox);
169
        leftContainer.setExpandRatio(distAreaBox, 0.1f);
170 180
        leftContainer.addComponent(namedAreaList);
181
        leftContainer.setExpandRatio(distAreaBox, 0.1f);
171 182
        leftContainer.setExpandRatio(namedAreaList, 0.9f);
172 183
        leftContainer.setSizeFull();
173 184

  
174 185
        rightContainer.addComponent(classificationBox);
175
        rightContainer.setExpandRatio(classificationBox, 0.1f);
176 186
        rightContainer.addComponent(taxonTree);
177
        rightContainer.setExpandRatio(taxonTree, 1f);
187
        rightContainer.setExpandRatio(classificationBox, 0.1f);
188
        rightContainer.setExpandRatio(taxonTree, 0.9f);
178 189

  
179
        mainLayout.addComponent(leftContainer);
180
        mainLayout.addComponent(rightContainer);
190
        leftAndRightContainer.addComponent(leftContainer);
191
        leftAndRightContainer.addComponent(rightContainer);
181 192

  
182 193
        //button toolbar
183 194
        HorizontalLayout buttonToolBar = new HorizontalLayout();
......
193 204
        okButton.setImmediate(true);
194 205
        buttonToolBar.addComponent(okButton);
195 206

  
196
        mainLayout.addComponent(rightContainer);
207
        mainLayout.addComponent(leftAndRightContainer);
197 208
        mainLayout.addComponent(buttonToolBar);
209
        mainLayout.setExpandRatio(leftAndRightContainer, 0.9f);
210
        mainLayout.setExpandRatio(buttonToolBar, 0.1f);
198 211
        mainLayout.setComponentAlignment(buttonToolBar, Alignment.BOTTOM_RIGHT);
199 212

  
200
        return mainLayout;
213
        return leftAndRightContainer;
201 214
    }
202 215

  
203 216
	@Override
......
230 243
	public void buttonClick(ClickEvent event) {
231 244
		Object source = event.getSource();
232 245
		if(source==okButton){
233
			TaxonNode taxonNode;
246
			TaxonNode taxonNode = null;
234 247
			TermVocabulary<NamedArea> term = null;
235 248
			//TODO use field converter
236
			taxonNode = CdmSpringContextHelper.getTaxonNodeService().find((Integer)((RowId) taxonTree.getValue()).getId()[0]);
249
			if(taxonTree.getValue()!=null){
250
			    taxonNode = CdmSpringContextHelper.getTaxonNodeService().find((Integer)((RowId) taxonTree.getValue()).getId()[0]);
251
			}
237 252
			if(taxonNode==null){
238 253
				taxonNode = (TaxonNode) classificationBox.getValue();
239 254
			}

Also available in: Unified diff