Java tutorial
/** * Copyright (C) 2011 Michael Mosmann <michael@mosmann.de> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.flapdoodle.mongoui.ui; import com.vaadin.annotations.AutoGenerated; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; public class VaadinUIComp extends CustomComponent { @AutoGenerated private VerticalLayout mainLayout; @AutoGenerated private Button submit; @AutoGenerated private HorizontalLayout hLayout; @AutoGenerated private TextField port; @AutoGenerated private Label portLabel; @AutoGenerated private TextField name; @AutoGenerated private Label nameLabel; /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */ /** * The constructor should first build the main layout, set the * composition root and then do any custom initialization. * * The constructor will not be automatically regenerated by the * visual editor. */ public VaadinUIComp() { buildMainLayout(); setCompositionRoot(mainLayout); // TODO add user code here } @AutoGenerated private VerticalLayout buildMainLayout() { // common part: create layout mainLayout = new VerticalLayout(); mainLayout.setImmediate(false); mainLayout.setWidth("-1px"); mainLayout.setHeight("-1px"); mainLayout.setMargin(false); // top-level component properties setWidth("-1px"); setHeight("-1px"); // hLayout hLayout = buildHLayout(); mainLayout.addComponent(hLayout); // submit submit = new Button(); submit.setCaption("Connect"); submit.setImmediate(true); submit.setWidth("-1px"); submit.setHeight("-1px"); mainLayout.addComponent(submit); mainLayout.setComponentAlignment(submit, new Alignment(34)); return mainLayout; } @AutoGenerated private HorizontalLayout buildHLayout() { // common part: create layout hLayout = new HorizontalLayout(); hLayout.setImmediate(false); hLayout.setWidth("-1px"); hLayout.setHeight("-1px"); hLayout.setMargin(false); // nameLabel nameLabel = new Label(); nameLabel.setImmediate(false); nameLabel.setWidth("-1px"); nameLabel.setHeight("-1px"); nameLabel.setValue("Hostname"); hLayout.addComponent(nameLabel); hLayout.setComponentAlignment(nameLabel, new Alignment(33)); // name name = new TextField(); name.setImmediate(false); name.setWidth("-1px"); name.setHeight("-1px"); name.setRequired(true); name.setSecret(false); hLayout.addComponent(name); hLayout.setComponentAlignment(name, new Alignment(33)); // portLabel portLabel = new Label(); portLabel.setImmediate(false); portLabel.setWidth("-1px"); portLabel.setHeight("-1px"); portLabel.setValue("Port"); hLayout.addComponent(portLabel); hLayout.setComponentAlignment(portLabel, new Alignment(33)); // port port = new TextField(); port.setImmediate(false); port.setWidth("-1px"); port.setHeight("-1px"); port.setRequired(true); port.setMaxLength(6); port.setNullRepresentation("-1"); port.setSecret(false); hLayout.addComponent(port); hLayout.setComponentAlignment(port, new Alignment(33)); return hLayout; } }