Example usage for com.vaadin.ui FormLayout FormLayout

List of usage examples for com.vaadin.ui FormLayout FormLayout

Introduction

In this page you can find the example usage for com.vaadin.ui FormLayout FormLayout.

Prototype

public FormLayout() 

Source Link

Usage

From source file:org.eclipse.hawkbit.ui.management.targettable.TargetAddUpdateWindowLayout.java

License:Open Source License

private void buildLayout() {
    setSizeUndefined();/*www .j ava2 s. c o m*/
    formLayout = new FormLayout();
    formLayout.addComponent(controllerIDTextField);
    formLayout.addComponent(nameTextField);
    formLayout.addComponent(descTextArea);

    controllerIDTextField.focus();
}

From source file:org.escidoc.browser.ui.role.RoleAssignView.java

License:Open Source License

private void initLayout() {
    panel = new Panel();
    setCompositionRoot(panel);/* ww  w.  jav  a 2s  .  c  o m*/
    panel.setStyleName(Runo.PANEL_LIGHT);
    panel.setSizeFull();
    setSizeFull();

    verticalLayout = new VerticalLayout();
    verticalLayout.setWidth("100%");

    mainLayout = new FormLayout();
    mainLayout.setWidth(400, UNITS_PIXELS);

    mainLayoutGroupRoles = new FormLayout();
    mainLayoutGroupRoles.setWidth(400, UNITS_PIXELS);

    panel.setContent(verticalLayout);

    // TODO how to make panel take the whole vertical screen, if it does not
    // contain any child component;
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true, false, false, true);
    verticalLayout.addComponent(selectionButton());
    verticalLayout.addComponent(mainLayout);
}

From source file:org.esn.esobase.view.tab.QuestsTab.java

public QuestsTab(DBService service) {
    this.service = service;
    actions = new HorizontalLayout();
    refreshButton = new Button("");
    refreshButton.addClickListener(new Button.ClickListener() {

        @Override/*from   w w  w  .j a  va2  s . co  m*/
        public void buttonClick(Button.ClickEvent event) {
            LoadTable();
            CloseForm();
        }
    });
    actions.addComponent(refreshButton);
    addButton = new Button("");
    addButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            AddItem();
        }
    });
    actions.addComponent(addButton);
    this.addComponent(actions);
    tableAndForm = new HorizontalLayout();
    tableAndForm.setSizeFull();
    table = new Table();
    table.setSizeFull();
    container = new BeanItemContainer<>(Quest.class);
    table.setContainerDataSource(container);

    table.setVisibleColumns(new Object[] { "name", "nameRu", "progress" });
    table.setColumnHeaders(new String[] { "?", " ?",
            "? " });
    table.setConverter("progress", new Converter<String, BigDecimal>() {

        @Override
        public BigDecimal convertToModel(String value, Class<? extends BigDecimal> targetType, Locale locale)
                throws Converter.ConversionException {
            return null;
        }

        @Override
        public String convertToPresentation(BigDecimal value, Class<? extends String> targetType, Locale locale)
                throws Converter.ConversionException {
            String r = "";
            if (value != null) {
                r = value.multiply(BigDecimal.valueOf(100L).setScale(2, RoundingMode.HALF_DOWN))
                        .setScale(0, RoundingMode.HALF_UP).toString() + "%";
            }
            return r;
        }

        @Override
        public Class<BigDecimal> getModelType() {
            return BigDecimal.class;
        }

        @Override
        public Class<String> getPresentationType() {
            return String.class;
        }

    });
    table.addItemClickListener(new TableClickListener());
    LoadTable();
    table.sort(new Object[] { "name" }, new boolean[] { true });
    tableAndForm.addComponent(table);
    tableAndForm.setExpandRatio(table, 0.2f);
    form = new FormLayout();
    form.setSizeFull();
    name = new TextField("?");
    name.setNullRepresentation("");
    name.setRequired(true);
    form.addComponent(name);
    nameRu = new TextField(" ?");
    nameRu.setNullRepresentation("");
    nameRu.setRequired(false);
    form.addComponent(nameRu);

    npcs = new TwinColSelect("NPC");
    npcsContainer = new BeanItemContainer<>(Npc.class);
    npcsContainer = service.loadBeanItems(npcsContainer);
    npcsContainer.sort(new Object[] { "name" }, new boolean[] { true });
    npcsContainer.addNestedContainerProperty("location.name");
    npcsContainer.addNestedContainerProperty("location.nameRu");
    npcs.setContainerDataSource(npcsContainer);
    npcs.setWidth(900f, Unit.PIXELS);
    Page.Styles styles = Page.getCurrent().getStyles();
    styles.add(".v-font-size {\n" + "    font-size: 11px;\n" + "}");
    npcs.addStyleName("v-font-size");
    npcFilter = new TextField(" ?? NPC");
    npcFilter.setNullRepresentation("");
    npcFilter.setImmediate(true);
    npcFilter.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.TIMEOUT);
    npcFilter.setTextChangeTimeout(500);
    npcFilter.addTextChangeListener(new FieldEvents.TextChangeListener() {

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            npcsContainer.removeAllContainerFilters();
            if (event.getText() != null && !event.getText().isEmpty()) {
                try {
                    npcsContainer
                            .addContainerFilter(new Or(new Like("name", "%" + event.getText() + "%", false),
                                    new Like("nameRu", "%" + event.getText() + "%", false),
                                    new Like("location.name", "%" + event.getText() + "%", false),
                                    new Like("location.nameRu", "%" + event.getText() + "%", false)));
                } catch (UnsupportedFilterException | PatternSyntaxException ex) {

                }
            }
        }
    });
    form.addComponent(npcFilter);
    form.addComponent(npcs);
    saveButton = new Button("");
    saveButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            SaveForm();
        }
    });
    cancelButton = new Button("");
    cancelButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            CloseForm();
            LoadTable();
        }
    });
    HorizontalLayout actions = new HorizontalLayout(cancelButton, saveButton);
    form.addComponent(actions);
    form.setVisible(false);
    tableAndForm.addComponent(form);
    tableAndForm.setExpandRatio(form, 0.75f);
    this.addComponent(tableAndForm);
}

From source file:org.esn.esobase.view.tab.SystemSettingsTab.java

public SystemSettingsTab(DBService service_) {
    this.service = service_;

    FormLayout fl = new FormLayout();
    isAutoSyncEnabledBox = new CheckBox("??? ");
    fl.addComponent(isAutoSyncEnabledBox);
    HorizontalLayout hl = new HorizontalLayout();
    Button saveButton = new Button("");
    saveButton.addClickListener(new Button.ClickListener() {

        @Override/*  w  w w .  ja  v  a  2s. c om*/
        public void buttonClick(Button.ClickEvent event) {
            service.setIsAutoSynchronizationEnabled(isAutoSyncEnabledBox.getValue());
            LoadData();
            Notification notification = new Notification("?? ? ?",
                    Notification.Type.HUMANIZED_MESSAGE);
            notification.setDelayMsec(2000);
            notification.show(isAutoSyncEnabledBox.getUI().getPage());
        }
    });
    Button cancelButton = new Button("");
    cancelButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            LoadData();
        }
    });
    hl.addComponent(cancelButton);
    hl.addComponent(saveButton);
    fl.addComponent(hl);
    this.addComponent(fl);
    LoadData();
}

From source file:org.esn.esobase.view.tab.UsersTab.java

public UsersTab(DBService service) {
    this.service = service;
    actions = new HorizontalLayout();
    refreshButton = new Button("");
    refreshButton.addClickListener(new Button.ClickListener() {

        @Override/*w w w.  j a v a 2 s. c  o m*/
        public void buttonClick(Button.ClickEvent event) {
            LoadTable();
        }
    });
    actions.addComponent(refreshButton);
    addButton = new Button("");
    addButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            AddUser();
        }
    });
    actions.addComponent(addButton);
    this.addComponent(actions);
    tableAndForm = new HorizontalLayout();
    tableAndForm.setSizeFull();
    table = new Table();
    table.setSizeFull();
    container = new BeanItemContainer<>(SysAccount.class);
    table.setContainerDataSource(container);
    table.setVisibleColumns(new Object[] { "login", "roles" });
    table.addItemClickListener(new TableClickListener());
    LoadTable();
    tableAndForm.addComponent(table);
    tableAndForm.setExpandRatio(table, 0.5f);
    form = new FormLayout();
    form.setSizeFull();
    login = new TextField("");
    login.setNullRepresentation("");
    login.setRequired(true);
    form.addComponent(login);
    password = new PasswordField("");
    form.addComponent(password);
    passwordRepeat = new PasswordField(" ?");
    passwordRepeat.addValidator(new PasswordValidator(password, passwordRepeat));
    form.addComponent(passwordRepeat);
    roles = new TwinColSelect("");
    BeanItemContainer<SysAccountRole> rolesContainer = new BeanItemContainer<>(SysAccountRole.class);
    rolesContainer = service.loadBeanItems(rolesContainer);
    roles.setContainerDataSource(rolesContainer);
    roles.setWidth(900f, Unit.PIXELS);
    Page.Styles styles = Page.getCurrent().getStyles();
    styles.add(".v-font-size {\n" + "    font-size: 11px;\n" + "}");
    roles.addStyleName("v-font-size");
    form.addComponent(roles);
    isBlocked = new CheckBox("");
    form.addComponent(isBlocked);
    saveButton = new Button("");
    saveButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            SaveForm();
        }
    });
    form.addComponent(saveButton);
    form.setVisible(false);
    tableAndForm.addComponent(form);
    tableAndForm.setExpandRatio(form, 0.5f);
    this.addComponent(tableAndForm);
}

From source file:org.ikasan.dashboard.ui.framework.window.IkasanMessageDialog.java

License:BSD License

/**
 * Helper method to initialise this object.
 * // w  ww .  j  a va2 s  .c om
 * @param message
 */
protected void init(String message) {
    super.setModal(true);
    super.setResizable(false);
    super.center();

    FormLayout layout = new FormLayout();
    layout.setMargin(true);
    layout.addComponent(new Label(message));

    Button okButton = new Button("OK");
    okButton.setStyleName(ValoTheme.BUTTON_SMALL);

    okButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            action.exectuteAction();
            close();
        }
    });

    Button cancelButton = new Button("Cancel");
    cancelButton.setStyleName(ValoTheme.BUTTON_SMALL);

    cancelButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            action.ignoreAction();
            close();
        }
    });

    HorizontalLayout wrapper = new HorizontalLayout();
    wrapper.setWidth(100, Unit.PERCENTAGE);
    HorizontalLayout hlayout = new HorizontalLayout();
    wrapper.addComponent(hlayout);
    wrapper.setComponentAlignment(hlayout, Alignment.MIDDLE_CENTER);
    hlayout.addComponent(okButton);
    hlayout.addComponent(cancelButton);

    layout.addComponent(wrapper);

    super.setContent(layout);
}

From source file:org.investovator.ui.dataplayback.admin.DataPlaybackEngineAdminDashboard.java

License:Open Source License

public Component setupGameConfigBox() {
    FormLayout layout = new FormLayout();
    layout.setCaption("Game Configuration");
    layout.addStyleName("center-caption");

    GameTypes config = DataPlaybackEngineStates.gameConfig;

    //show the game description
    Label gameDescription = new Label(config.getDescription());
    layout.addComponent(gameDescription);
    gameDescription.setContentMode(ContentMode.HTML);
    gameDescription.setWidth(320, Unit.PIXELS);
    gameDescription.setCaption("Game: ");

    //add the player type
    Label playerType = new Label();
    layout.addComponent(playerType);/*from www .j ava 2 s  .c  om*/
    playerType.setCaption("Player Type: ");
    playerType.setValue(player.getName());

    //show the attributes
    Label attributes = new Label(config.getInterestedAttributes().toString());
    layout.addComponent(attributes);
    attributes.setContentMode(ContentMode.HTML);
    attributes.setCaption("Attributes: ");

    //matching attribute
    Label matchingAttr = new Label(config.getAttributeToMatch().toString());
    layout.addComponent(matchingAttr);
    matchingAttr.setContentMode(ContentMode.HTML);
    matchingAttr.setCaption("Played On: ");

    return layout;

}

From source file:org.investovator.ui.dataplayback.admin.DataPlaybackEngineAdminDashboard.java

License:Open Source License

public Component setupGameStatsBox() {
    FormLayout layout = new FormLayout();
    layout.setCaption("Game Stats");
    layout.addStyleName("center-caption");

    //show game runtime
    final Label runTime = new Label();
    //push the changes
    UI.getCurrent().access(new Runnable() {
        @Override/*from  w w  w  . j  a v a2  s .  c o m*/
        public void run() {
            TimeZone defaultTz = TimeZone.getDefault();
            TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
            SimpleDateFormat sDate = new SimpleDateFormat("HH:mm:ss");
            runTime.setValue(sDate.format(new Date(player.getGameRuntime())));
            TimeZone.setDefault(defaultTz);
            getUI().push();

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    });

    runTime.setCaption("Up Time: ");
    layout.addComponent(runTime);
    //start the time updating thread
    new Thread() {
        public void run() {
            //update forever
            while (true) {
                UI.getCurrent().access(new Runnable() {
                    @Override
                    public void run() {
                        TimeZone defaultTz = TimeZone.getDefault();
                        TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
                        SimpleDateFormat sDate = new SimpleDateFormat("HH:mm:ss");
                        runTime.setValue(sDate.format(new Date(player.getGameRuntime())));
                        TimeZone.setDefault(defaultTz);
                        getUI().push();
                    }
                });

                //wait before updating
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }
    }.start();

    //show market turnover
    Label turnover = new Label(Float.toString(player.getMarketTurnover()));
    turnover.setCaption("Market Turnover: ");
    layout.addComponent(turnover);

    //show total trades
    Label totalTrades = new Label(Integer.toString(player.getTotalTrades()));
    totalTrades.setCaption("Total Trades: ");
    layout.addComponent(totalTrades);

    return layout;
}

From source file:org.investovator.ui.dataplayback.user.dashboard.dailysummary.DailySummaryMultiPlayerMainView.java

License:Open Source License

public Component setUpAccountInfoForm() {
    FormLayout form = new FormLayout();

    try {//from w w  w  . j  a  va 2 s.  c  om
        if (this.userName == null) {

            int bal = player.getInitialCredit();
            Label accountBalance = new Label(Integer.toString(bal));
            this.accBalance = accountBalance;
            accountBalance.setCaption("Account Balance");
            form.addComponent(accountBalance);

            int max = player.getMaxOrderSize();
            Label maxOrderSize = new Label(Integer.toString(max));
            maxOrderSize.setCaption("Max. Order Size");
            form.addComponent(maxOrderSize);
        } else {
            Double bal = player.getMyPortfolio(this.userName).getCashBalance();
            Label accountBalance = new Label(bal.toString());
            this.accBalance = accountBalance;
            accountBalance.setCaption("Account Balance");
            form.addComponent(accountBalance);

            int max = player.getMaxOrderSize();
            Label maxOrderSize = new Label(Integer.toString(max));
            maxOrderSize.setCaption("Max. Order Size");
            form.addComponent(maxOrderSize);
        }
    } catch (UserJoinException e) {
        e.printStackTrace();
    }

    return form;
}

From source file:org.investovator.ui.dataplayback.user.dashboard.dailysummary.DailySummarySinglePlayerMainView.java

License:Open Source License

public Component setUpAccountInfoForm() {
    FormLayout form = new FormLayout();

    try {/*from w w  w .  ja v a2  s .  c o m*/
        if (this.userName == null) {

            int bal = this.player.getInitialCredit();
            Label accountBalance = new Label(Integer.toString(bal));
            this.accBalance = accountBalance;
            accountBalance.setCaption("Account Balance");
            form.addComponent(accountBalance);

            int max = this.player.getMaxOrderSize();
            Label maxOrderSize = new Label(Integer.toString(max));
            maxOrderSize.setCaption("Max. Order Size");
            form.addComponent(maxOrderSize);
        } else {
            Double bal = this.player.getMyPortfolio(this.userName).getCashBalance();
            Label accountBalance = new Label(bal.toString());
            this.accBalance = accountBalance;
            accountBalance.setCaption("Account Balance");
            form.addComponent(accountBalance);

            int max = this.player.getMaxOrderSize();
            Label maxOrderSize = new Label(Integer.toString(max));
            maxOrderSize.setCaption("Max. Order Size");
            form.addComponent(maxOrderSize);
        }
    } catch (UserJoinException e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    }

    return form;
}