Example usage for com.vaadin.ui FormLayout setCaption

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

Introduction

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

Prototype

@Override
    public void setCaption(String caption) 

Source Link

Usage

From source file:edu.kit.dama.ui.admin.ProfileView.java

License:Apache License

/**
 * Build the main layout.// w  ww  . j ava  2  s  .co  m
 */
private void buildMainLayout() {
    //information area
    screenName = new Label();
    screenName.setCaption("Screen Name:");
    screenName.setStyleName("form");
    firstName = new Label();
    firstName.setCaption("First Name:");
    firstName.setStyleName("form");
    lastName = new Label();
    lastName.setCaption("Last Name:");
    lastName.setStyleName("form");
    email = new Label();
    email.setCaption("Email:");
    email.setStyleName("form");
    FormLayout userInformationForm = new FormLayout(screenName, firstName, lastName, email);
    userInformationForm.setStyleName("form");
    userInformationForm.setCaption("User Information");
    tokenDialog = new ServiceAccessTokenDialog();
    //Credentials
    //table with serviceId, key, secret for logged in userId
    //---mainLogin and webdav are special (username = email), others can be configured in AuthenticatorFactory
    //---support for adding/regenerating new tokens (support for random secrets)
    //---support for blocking?
    //---'show secrets' button
    credentialTable = new Table("Credentials");
    credentialTable.setSelectable(true);
    credentialTable.setMultiSelect(false);
    credentialTable.addContainerProperty("ServiceId", String.class, null);
    credentialTable.addContainerProperty("Key", String.class, null);
    credentialTable.addContainerProperty("Secret", String.class, null);
    credentialTable.addStyleName("myboldcaption");
    credentialTable.setSizeFull();

    Button addCredential = new Button();
    addCredential.setIcon(new ThemeResource(IconContainer.ADD));
    Button modifyCredential = new Button();
    modifyCredential.setIcon(new ThemeResource(IconContainer.EDIT));
    Button removeCredential = new Button();
    removeCredential.setIcon(new ThemeResource(IconContainer.DELETE));
    Button reloadCredentialTable = new Button();
    reloadCredentialTable.setIcon(new ThemeResource(IconContainer.REFRESH));
    reloadCredentialTable.addClickListener(((event) -> {
        reload();
    }));

    CheckBox showPasswords = new CheckBox("Show Secrets");
    showPasswords.addValueChangeListener((Property.ValueChangeEvent event) -> {
        showSecrets(showPasswords.getValue());
    });

    removeCredential.addClickListener((event) -> {
        Long selection = (Long) credentialTable.getValue();
        if (selection != null) {
            ConfirmationWindow7.showConfirmation("Delete Credential",
                    "If you delete the selected credential, you won't be able to access the associated service any longer.<br/> "
                            + "Do you wish to proceed?",
                    ConfirmationWindow7.OPTION_TYPE.YES_NO_OPTION, ConfirmationWindow7.MESSAGE_TYPE.WARNING,
                    (ConfirmationWindow7.RESULT pResult) -> {
                        switch (pResult) {
                        case YES:
                            removeCredential(selection);
                            break;
                        default:
                            //do nothing
                        }
                    });
        }

    });

    modifyCredential.addClickListener((event) -> {
        Long selection = (Long) credentialTable.getValue();
        if (selection != null) {
            updateCredential(selection);
        }
    });

    addCredential.addClickListener((event) -> {
        createCredential();
    });

    VerticalLayout buttonLayout = new VerticalLayout(addCredential, modifyCredential, removeCredential,
            reloadCredentialTable);

    buttonLayout.setComponentAlignment(modifyCredential, Alignment.TOP_LEFT);
    buttonLayout.setComponentAlignment(removeCredential, Alignment.TOP_LEFT);
    buttonLayout.setComponentAlignment(reloadCredentialTable, Alignment.TOP_LEFT);
    buttonLayout.setMargin(true);

    UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(2, 3);

    builder.fillRow(userInformationForm, 0, 0, 1);
    builder.addComponent(credentialTable, 0, 1).addComponent(buttonLayout, 1, 1);
    builder.fillRow(showPasswords, 0, 2, 1);
    mainLayout = builder.getLayout();

    mainLayout.setSpacing(true);
    mainLayout.setMargin(true);
    mainLayout.setRowExpandRatio(1, 1.0f);
    mainLayout.setColumnExpandRatio(0, .9f);
    mainLayout.setColumnExpandRatio(1, .1f);
    mainLayout.setSizeFull();
    reload();
}

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);//ww  w. jav  a  2s .  c  o m
    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 ww w  . j a  v  a2s .  c  om
        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.ozkar.vaadinBootstrapp.login.LoginPage.java

public LoginPage() {

    final VerticalLayout root = new VerticalLayout();
    final FormLayout loginForm = new FormLayout();

    txtUsername.setRequired(true);//from   w  ww  . j a va  2  s  . c o m
    txtPassword.setRequired(true);
    btnOk.setClickShortcut(KeyCode.ENTER);

    root.addComponent(loginForm);
    root.setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER);
    root.setSizeFull();

    loginForm.addComponent(txtUsername);
    loginForm.addComponent(txtPassword);
    loginForm.addComponent(btnOk);

    loginForm.setSpacing(true);
    loginForm.setMargin(new MarginInfo(true, true, true, false));
    loginForm.setCaption(":::LOGIN:::");
    loginForm.setSizeUndefined();

    this.setSizeFull();
    this.setCompositionRoot(root);

    /* Event Handling */
    btnOk.addClickListener((Button.ClickEvent event) -> {

        User user = User.getUser(txtUsername.getValue());

        if (AuthUtils.validUser(user, txtPassword.getValue())) {
            Notification.show("Bienvenido...");
            AuthUtils.logIn(getUI(), user);
            getUI().getNavigator().navigateTo(HomePage.URL);
        } else {
            Notification.show("Usuario o Contrasea Incorrecto.");
        }
    });

}

From source file:org.sensorhub.ui.GenericConfigFormBuilder.java

License:Mozilla Public License

@SuppressWarnings("serial")
@Override/*from w w w .j  a v  a2  s . c o m*/
public FormLayout buildForm(final FieldGroup fieldGroup) {
    reset();
    FormLayout form = new FormLayout();

    // add widget for each visible attribute
    for (Object propId : fieldGroup.getUnboundPropertyIds()) {
        Property<?> prop = fieldGroup.getItemDataSource().getItemProperty(propId);

        if (prop instanceof ContainerProperty) {
            String label = ((ContainerProperty) prop).getLabel();
            if (label == null)
                label = getPrettyName((String) propId);

            /*Table table = new Table();
            table.setCaption(label);
            table.setSizeFull();
            table.setPageLength(5);
            table.setHeight(50, Unit.POINTS);
            table.setSelectable(true);
            table.setEditable(true);
            table.setColumnReorderingAllowed(false);
            table.setContainerDataSource(((ContainerProperty)prop).getValue());
            table.setBuffered(true);
            table.setStyleName(Runo.TABLE_SMALL);
            otherWidgets.add(table);*/

            if (!((ContainerProperty) prop).getValue().getItemIds().isEmpty()) {
                Object firstItemId = ((ContainerProperty) prop).getValue().getItemIds().iterator().next();
                FieldGroup newFieldGroup = new FieldGroup(
                        ((ContainerProperty) prop).getValue().getItem(firstItemId));
                FormLayout subform = new GenericConfigFormBuilder().buildForm(newFieldGroup);
                subform.setCaption(label);
                otherWidgets.add(subform);
            }
        } else {
            Field<?> field = null;

            try {
                String label = null;
                if (prop instanceof FieldProperty)
                    label = ((FieldProperty) prop).getLabel();
                if (label == null)
                    label = getPrettyName((String) propId);
                field = fieldGroup.buildAndBind(label, propId);
            } catch (Exception e) {
                System.err.println("No UI generator for field " + propId);
                continue;
            }

            //Property<?> prop = field.getPropertyDataSource();            
            customizeField((String) propId, prop, field);

            if (field instanceof Label)
                labels.add(field);
            else if (field instanceof TextField)
                textBoxes.add(field);
            else if (field instanceof CheckBox)
                checkBoxes.add(field);
            else
                otherWidgets.add(field);
        }
    }

    // add all widgets
    for (Field<?> w : labels)
        form.addComponent(w);
    for (Field<?> w : textBoxes)
        form.addComponent(w);
    for (Field<?> w : checkBoxes)
        form.addComponent(w);
    for (Component w : otherWidgets)
        form.addComponent(w);

    // add save button
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100.0f, Unit.PERCENTAGE);
    //buttonsLayout.setSizeFull();
    buttonsLayout.setMargin(true);
    buttonsLayout.setSpacing(true);
    form.addComponent(buttonsLayout);

    Button saveButton = new Button("Save");
    saveButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                fieldGroup.commit();
            } catch (CommitException e) {
                e.printStackTrace();
            }
        }
    });
    buttonsLayout.addComponent(saveButton);
    //buttonsLayout.setComponentAlignment(saveButton, Alignment.MIDDLE_CENTER);

    // add cancel button
    Button cancelButton = new Button("Cancel");
    cancelButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            fieldGroup.discard();
        }
    });
    buttonsLayout.addComponent(cancelButton);
    //buttonsLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);

    return form;
}

From source file:qbic.vaadincomponents.MaxQuantComponent.java

License:Open Source License

/**
 * creates the global parameter component
 * /*from ww  w .  jav  a  2 s  .  c om*/
 * @return
 */
private Component globalParameters() {
    FormLayout globalparameters = new FormLayout();
    globalparameters.setCaption("Global parameters");
    fastaFiles = new SelectFileComponent("", FASTA_FILES_INFO, AVAILABLE_FASTAS_CAPTION,
            SELECTED_FASTAS_CAPTION, model.getFastaBeans(), model.getSelectedFastaBeans());
    globalparameters.addComponent(fastaFiles);
    // fixed modifications
    // fixedModifications = new TwinColSelect("fixed modifications");
    fixedModifications = new TwinColSelect();

    Label fixedInfo = new Label("Fixed Modifications");
    fixedInfo.addStyleName(ValoTheme.LABEL_COLORED);

    globalparameters.addComponent(fixedInfo);
    fixedModifications.addItems("Acetyl (Protein N-term)", "Acetyl (K)", "Oxidation (M)", "Ala->Arg",
            "Carbamidomethyl (C)");
    globalparameters.addComponent(fixedModifications);
    reQuantify = new CheckBox("Requantify");
    globalparameters.addComponent(reQuantify);
    matchBetweenRuns = new CheckBox("Match Between Runs");
    globalparameters.addComponent(matchBetweenRuns);
    return globalparameters;
}