Example usage for com.vaadin.ui Label setId

List of usage examples for com.vaadin.ui Label setId

Introduction

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

Prototype

@Override
    public void setId(String id) 

Source Link

Usage

From source file:com.cms.utils.InitDateTime.java

public InitDateTime() {
    date.setWidth("100.0%");
    date.setHeight("-1px");
    final PopupDateField popupDateField = new PopupDateField();
    float dateWidth = date.getWidth() - 14;
    popupDateField.setWidth(String.valueOf(dateWidth));
    popupDateField.setId("date");
    //        popupDateField.addStyleName("v-textfield v-widget v-textfield-required v-required v-has-width");
    popupDateField.setLocale(new Locale("vi"));
    popupDateField.setImmediate(false);/*from w ww .j a v a  2s  .  c  o m*/
    popupDateField.setValidationVisible(false);
    popupDateField.addBlurListener(new FieldEvents.BlurListener() {
        @Override
        public void blur(FieldEvents.BlurEvent event) {
            com.vaadin.ui.JavaScript.getCurrent().execute("setValueDate();");
        }
    });
    popupDateField.addFocusListener(new FieldEvents.FocusListener() {

        @Override
        public void focus(FieldEvents.FocusEvent event) {
            com.vaadin.ui.JavaScript.getCurrent().execute("focusDate();");
        }
    });
    Label label = new Label(
            "<div id=\"error-date\" class=\"v-errorindicator\" onmouseover=\"showError()\" onmouseout=\"hideError()\" aria-hidden=\"true\" style=\"display: none;\">&nbsp;</div>",
            ContentMode.HTML);
    label.setId("label");
    //        label.addStyleName("v-required-field-indicator");
    label.setWidth("14px");
    //        label.setWidth("10px");
    //        label.setHeight("10px");
    label.setDescription(
            "<span id=\"notification-date\" style=\" background:#fff;color:red;padding:0\">Ngy thng cha ng nh dng</span>");
    date.addComponent(popupDateField);
    //        Page.getCurrent().getJavaScript().execute("addCsstotip()");
    date.addComponent(label);
    date.setExpandRatio(popupDateField, 3);
    date.setExpandRatio(label, 1);
    //        layoutMain.addComponent(date);
}

From source file:com.example.vaadindemo.MenuPanel.java

public HorizontalLayout draw() {

    HorizontalLayout menu = new HorizontalLayout();
    addItemButton = new Button("Dodaj do listy");
    addListButton = new Button("Dodaj list");
    Label appTitle = new Label("Organizator zakupw");
    appTitle.setId("appTitle");

    menu.addComponent(appTitle);//w  w w .  j  a va 2s .  com
    menu.addComponent(addItemButton);
    menu.addComponent(addListButton);
    return menu;
}

From source file:com.mycompany.exodious.login.java

public login() {
    this.setId("loginPanel");
    this.setSpacing(true);
    Image logo = new Image();
    logo.setId("logo");
    logo.setSource(slikaLogo);/*from   w w  w. j  av a  2  s .  c  o  m*/
    logo.setHeight("18em");
    logo.setWidth("30em");
    Label welcome = new Label("Welcome, please login");
    welcome.setId("welcome");
    TextField username = new TextField("Your ID");
    PasswordField password = new PasswordField("Password");
    Button submit = new Button("Login");
    submit.setIcon(FontAwesome.SIGN_IN);
    submit.addStyleName(ValoTheme.BUTTON_PRIMARY);

    submit.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {

        }
    });

    addComponents(logo, welcome, username, password, submit);
    setComponentAlignment(logo, Alignment.MIDDLE_CENTER);
    setComponentAlignment(welcome, Alignment.MIDDLE_CENTER);
    setComponentAlignment(username, Alignment.MIDDLE_CENTER);
    setComponentAlignment(password, Alignment.MIDDLE_CENTER);
    setComponentAlignment(submit, Alignment.MIDDLE_CENTER);
}

From source file:com.mycompany.perfectphone.start.java

public start() {

    Label title = new Label("Find Your Perfect Smartphone");
    title.setId("title");
    Label welcome = new Label("Welcome to DaX's Perfect Smartphone Finder");
    welcome.setId("welcome");
    Button start = new Button("Start");

    start.setIcon(FontAwesome.SIGN_IN);//from  w ww .j av  a 2  s  .  c  o  m

    start.addStyleName(ValoTheme.BUTTON_PRIMARY);

    Label question1 = new Label("Do you like big screen?");
    OptionGroup answer1 = new OptionGroup();
    Button next = new Button("Continue");

    addComponents(title, question1, answer1, next);

    setComponentAlignment(question1, Alignment.TOP_CENTER);

    setComponentAlignment(answer1, Alignment.TOP_CENTER);

    setComponentAlignment(next, Alignment.TOP_CENTER);
}

From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java

License:Open Source License

/**
 * Build login view/*from ww  w  .  j  av a 2  s.co  m*/
 *
 * @param exit
 */
private void buildLoginView(final boolean exit) {
    if (exit) {
        root.removeAllComponents();
    }
    notifierService.closeAll();

    addStyleName("login");

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setId("webconsole_loginlayout_id");
    loginLayout.setSizeFull();
    loginLayout.addStyleName("login-layout");
    root.addComponent(loginLayout);

    final CssLayout loginPanel = new CssLayout();
    loginPanel.addStyleName("login-panel");

    HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth(MAX_WIDTH);
    labels.setMargin(true);
    loginPanel.addComponent(labels);

    Label welcome = new Label("Welcome");
    welcome.addStyleName("h4");
    labels.addComponent(welcome);
    labels.setComponentAlignment(welcome, Alignment.MIDDLE_LEFT);

    Label title = new Label(consoleName);
    //title.setSizeUndefined();
    title.addStyleName("h2");
    title.addStyleName("light");
    labels.addComponent(title);
    labels.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);

    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.setMargin(true);
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.focus();
    username.setId("webconsole_login_username");
    fields.addComponent(username);

    final PasswordField password = new PasswordField("Password");
    password.setId("webconsole_login_password");
    fields.addComponent(password);

    final Button signin = new Button("Sign In");
    signin.setId("webconsole_login_signin");
    signin.addStyleName("default");
    fields.addComponent(signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    final ShortcutListener enter = new ShortcutListener("Sign In", ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            signin.click();
        }
    };

    signin.addShortcutListener(enter);
    loginPanel.addComponent(fields);

    HorizontalLayout bottomRow = new HorizontalLayout();
    bottomRow.setWidth(MAX_WIDTH);
    bottomRow.setMargin(new MarginInfo(false, true, false, true));
    final CheckBox keepLoggedIn = new CheckBox("Keep me logged in");
    bottomRow.addComponent(keepLoggedIn);
    bottomRow.setComponentAlignment(keepLoggedIn, Alignment.MIDDLE_LEFT);
    // Add new error message
    final Label error = new Label("Wrong username or password.", ContentMode.HTML);
    error.setId("webconsole_login_error");
    error.addStyleName("error");
    error.setSizeUndefined();
    error.addStyleName("light");
    // Add animation
    error.addStyleName("v-animate-reveal");
    error.setVisible(false);
    bottomRow.addComponent(error);
    bottomRow.setComponentAlignment(error, Alignment.MIDDLE_RIGHT);
    loginPanel.addComponent(bottomRow);

    signin.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (authenticate(username.getValue(), password.getValue())) {
                //                    if (keepLoggedIn.getValue()) {
                //                        //Cookie userCookie = getCookieByName(PEERGREEN_USER_COOKIE_NAME);
                //                       if (getCookieByName(PEERGREEN_USER_COOKIE_NAME) == null) {
                //                            // Get a token for this user and create a cooki
                //                            Page.getCurrent().getJavaScript().execute( String.format("document.cookie = '%s=%s; path=%s'",
                //                                    PEERGREEN_USER_COOKIE_NAME, token, VaadinService.getCurrentRequest().getContextPath()));
                //                        } else {
                //                            // update token
                //                            userCookie.setValue(token);
                //                            userCookie.setPath(VaadinService.getCurrentRequest().getContextPath());
                //                        }
                //                    }

                buildMainView();
            } else {
                error.setVisible(true);
            }
        }
    });

    loginLayout.addComponent(loginPanel);
    loginLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
}

From source file:com.snowy.Login.java

@PostConstruct
void init() {/*from  ww  w  . j  a  v  a2s . c  o  m*/
    d = ((MyVaadinUI) UI.getCurrent()).getDataObject();
    //Logger.getLogger(Login.class.getName()).info(d);
    this.setSizeFull();
    this.setSpacing(false);
    this.setMargin(true);
    Label MainL = new Label("<h1>Connect 4</h1?>", ContentMode.HTML);
    //layout.addComponent(MainL);
    MainL.setSizeUndefined();
    VerticalLayout lay = new VerticalLayout();
    lay.setMargin(false);
    lay.addComponent(MainL);
    lay.setComponentAlignment(MainL, Alignment.TOP_CENTER);
    HorizontalLayout hz = new HorizontalLayout();
    hz.setMargin(false);
    hz.setSpacing(false);
    LoginForm lf = new LoginForm();
    lf.addLoginListener((e) -> {
        String token = d.genToken(e.getLoginParameter("username"), e.getLoginParameter("password"));
        //String token="true";
        if (!token.equals("false")) {

            Cookie c = new Cookie("token", token);
            VaadinService.getCurrentResponse().addCookie(c);
            //https://vaadin.com/wiki/-/wiki/Main/Setting+and+reading+Cookies
            //Notification.show(VaadinService.getCurrentRequest().getCookies()[1].getValue(),Notification.Type.ERROR_MESSAGE);
            //this.getNavigator().navigateTo("main");
            //this.getUI().get
            this.getUI().getNavigator().navigateTo("main");
        } else {
            Label l = new Label("<h4 style=\"color:red\">Invalid Username or Password</h4>", ContentMode.HTML);
            l.setId("created");

            if (lay.getComponent(lay.getComponentIndex(lf) + 1).getId() == null) {
                //lay.addComponent(new Label(String.valueOf(lay.getComponentIndex(l))));
                lay.addComponent(l, lay.getComponentIndex(lf) + 1);
                l.setSizeUndefined();
                lay.setComponentAlignment(l, Alignment.TOP_CENTER);
            }

        }

    });

    lay.addComponent(lf);
    Button newUser = new Button("New User");
    newUser.addClickListener((e) -> {

        this.getUI().addWindow(new NewUserSubWindow(d));
    });
    //newUser.setWidth((float)5.5, Unit.EM);
    Button forgotPass = new Button("Forgot Password");
    //temp
    forgotPass.addClickListener((e) -> {
        //Notification.show(, Notification.Type.ERROR_MESSAGE);
    });
    forgotPass.setEnabled(false);
    forgotPass.setDescription("Feature Disabled, Contact Administrator for Assistance");
    //forgotPass.setWidth((float) 8.5,Unit.EM);
    forgotPass.setStyleName(ValoTheme.BUTTON_LINK);
    newUser.setStyleName(ValoTheme.BUTTON_LINK);

    hz.addComponent(newUser);
    hz.addComponent(forgotPass);
    lay.addComponent(hz);
    lay.setComponentAlignment(lf, Alignment.TOP_CENTER);
    lay.setComponentAlignment(hz, Alignment.MIDDLE_CENTER);
    this.addComponent(lay);
    this.setComponentAlignment(lay, Alignment.MIDDLE_CENTER);
}

From source file:de.metas.ui.web.vaadin.window.view.WindowRecordIndicators.java

License:Open Source License

private Component createIndicatorComp(final String label, final String color) {
    final String indicatorId = STYLE_Indicator + "-" + (nextIndicatorId++);

    final Label comp = new Label();
    comp.setId(indicatorId);
    comp.setPrimaryStyleName(STYLE_Indicator);
    comp.setValue(label);/*from  w  w w .j  a  v a 2s  .  co  m*/

    indicatorId2color.put(indicatorId, color);

    return comp;
}

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

License:Apache License

/**
 * Add a help entry to the provided layout.
 *
 * @param pId The id of the item to which the help belongs.
 * @param pHelpText The help text./*w  w w.  j  av a 2 s .c o m*/
 * @param pTargetLayout The layout where the help will be added to.
 */
private void addHelpItem(String pId, String pHelpText, AbsoluteLayout pTargetLayout) {
    Label item = new Label(pHelpText, ContentMode.HTML);
    item.setId(pId + "_help");
    item.setHeight("48px");
    item.addStyleName("invisible");
    item.addStyleName("help-left");
    pTargetLayout.addComponent(item);
}

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

License:Apache License

/**
 * Create a new cell for the UI. Each cell contains an image located in the
 * provided resource and a help label for the cell adverse to it.
 * Furthermore, a style is provided which can be 'help-left' or 'help-right'
 * depending on which side the help text should be aligned (help in left col
 * -> align right).//  w ww  .j a va  2 s . c om
 *
 * @param pResourceString The image resource string.
 * @param The alignment of the image (TOP_LEFT or TOP_RIGHT, depending on
 * the column)
 * @param cellNumber The cell number (0-3) counting from top left to bottom
 * right
 * @param pHelp The help string which may contain HTML tags.
 * @param pStyle The help label style ('help-left' or 'help-right').
 *
 * @return The cell layout.
 */
private VerticalLayout createCell(String pResourceString, Alignment pAlignment, int cellNumber, String pHelp,
        String pStyle) {
    final String cellHeight = "132px";
    //create the cell image
    Image cellImage = new Image(null, new ThemeResource(pResourceString));
    cellImage.addStyleName("border");

    //create the cell image wrapper, which provides the shadow and this show/hide functionality
    VerticalLayout imageWrapper = new VerticalLayout(cellImage);
    imageWrapper.addComponent(cellImage);
    imageWrapper.setComponentAlignment(cellImage, Alignment.MIDDLE_CENTER);
    imageWrapper.setWidth(cellHeight);
    imageWrapper.setHeight(cellHeight);
    imageWrapper.addStyleName("shadow");
    imageWrapper.addStyleName("visible");

    //help label for the cell adverse to the current cell
    Label oppositeCellHelp = new Label(pHelp, ContentMode.HTML);
    oppositeCellHelp.addStyleName(pStyle);
    oppositeCellHelp.setSizeFull();
    oppositeCellHelp.addStyleName("invisible");
    oppositeCellHelp.setHeight(cellHeight);

    //the cell layout containing image and help label
    VerticalLayout cell = new VerticalLayout();
    cell.addComponent(imageWrapper);
    cell.setComponentAlignment(imageWrapper, pAlignment);
    cell.setMargin(true);
    cell.addComponent(oppositeCellHelp);
    cell.setComponentAlignment(oppositeCellHelp, Alignment.MIDDLE_CENTER);

    //define component ids depending on the provided cell number
    //---------
    //| 0 | 1 |
    //| 2 | 3 |
    //---------
    //Each cell gets the id 'image<cellNumber>'
    //The currently created wrapper and help label are getting the cellId of the adverse cell (0 -> 1, 1 -> 0, 2 -> 3, 3 -> 2).
    //These ids are used then by edu.kit.dama.ui.admin.client.HelpConnector to show/hide elements on mouse over.
    switch (cellNumber) {
    case 0:
        cellImage.setId("image0");
        //this cell contains the help for cell 1
        imageWrapper.setId("image1_wrapper");
        oppositeCellHelp.setId("image1_help");
        break;
    case 1:
        cellImage.setId("image1");
        //this cell contains the help for cell 0
        imageWrapper.setId("image0_wrapper");
        oppositeCellHelp.setId("image0_help");
        break;
    case 2:
        cellImage.setId("image2");
        //this cell contains the help for cell 3
        imageWrapper.setId("image3_wrapper");
        oppositeCellHelp.setId("image3_help");
        break;
    case 3:
        cellImage.setId("image3");
        //this cell contains the help for cell 2
        imageWrapper.setId("image2_wrapper");
        oppositeCellHelp.setId("image2_help");
        break;
    }
    //link the HelpExtension to the image
    new HelpExtension().extend(cellImage);
    return cell;
}

From source file:io.subutai.plugin.accumulo.ui.manager.Manager.java

private void populateMastersTable(final Table table, Set<EnvironmentContainerHost> containerHosts,
        final boolean masters) {
    table.removeAllItems();/* w ww . j  ava  2s  .c o  m*/
    for (final EnvironmentContainerHost containerHost : containerHosts) {
        List<NodeType> rolesOfNode = accumuloClusterConfig.getMasterNodeRoles(containerHost.getId());
        for (final NodeType role : rolesOfNode) {
            final Button checkBtn = new Button(CHECK_BUTTON_CAPTION);
            checkBtn.setId(containerHost.getIpByInterfaceName("eth0") + "-accumuloCheck");

            final Button destroyBtn = new Button(DESTROY_BUTTON_CAPTION);
            destroyBtn.setId(containerHost.getIpByInterfaceName("eth0") + "-accumuloDestroy");

            final Label resultHolder = new Label();
            resultHolder.setId(containerHost.getIpByInterfaceName("eth0") + "accumuloResult");

            HorizontalLayout availableOperations = new HorizontalLayout();
            availableOperations.setSpacing(true);

            addGivenComponents(availableOperations, checkBtn);
            addStyleName(checkBtn, destroyBtn, availableOperations);

            table.addItem(
                    new Object[] { containerHost.getHostname(), containerHost.getIpByInterfaceName("eth0"),
                            filterNodeRole(role.name()), resultHolder, availableOperations },
                    null);

            checkBtn.addClickListener(new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    PROGRESS_ICON.setVisible(true);
                    disableButtons(checkBtn, destroyBtn);
                    executorService
                            .execute(new CheckTask(accumulo, tracker, accumuloClusterConfig.getClusterName(),
                                    containerHost.getHostname(), new CompleteEvent() {
                                        public void onComplete(String result) {
                                            synchronized (PROGRESS_ICON) {
                                                resultHolder.setValue(parseStatus(result, role));
                                                enableButtons(destroyBtn, checkBtn);
                                                PROGRESS_ICON.setVisible(false);
                                            }
                                        }
                                    }));
                }
            });
        }
    }
}