Example usage for com.vaadin.ui Label setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(float width, Unit unit) 

Source Link

Usage

From source file:com.klwork.explorer.ui.user.ProfilePanel.java

License:Apache License

protected void initUi() {

    //removeAllComponents();
    setContent(null);//from  ww  w.  j a  v  a 2 s. c om
    addStyleName(Reindeer.PANEL_LIGHT);
    addStyleName(ExplorerLayout.STYLE_PROFILE_LAYOUT);
    setSizeFull();

    // Profile page is a horizontal layout: left we have a panel with the picture, 
    // and one the right there is another panel the about, contact, etc information
    this.profilePanelLayout = new HorizontalLayout();
    profilePanelLayout.setSizeFull();
    setContent(profilePanelLayout);

    // init both panels
    initImagePanel();

    //
    Label emptySpace = new Label(" ", ContentMode.HTML);
    emptySpace.setWidth(50, Unit.PIXELS);
    profilePanelLayout.addComponent(emptySpace);
    //?
    initInformationPanel();
}

From source file:com.klwork.explorer.ui.user.ProfilePanel.java

License:Apache License

protected Label createProfileHeader(String headerName) {
    Label label = new Label(headerName);
    label.setWidth(100, UNITS_PERCENTAGE);
    label.addStyleName(ExplorerLayout.STYLE_H3);
    return label;
}

From source file:com.klwork.explorer.web.MyNavigationUI.java

License:Apache License

/**
 * Exception on action//w w w  .  j  av a  2s.co m
 */
@Override
public void error(com.vaadin.server.ErrorEvent event) {
    // connector event
    if (event.getThrowable().getCause() instanceof IllegalArgumentException) {
        IllegalArgumentException exception = (IllegalArgumentException) event.getThrowable().getCause();
        Notification.show(exception.getMessage(), Notification.Type.ERROR_MESSAGE);

        // Cleanup view. Now Vaadin ignores errors and always shows the view.  :-(
        // since beta10
        setContent(null);
        return;
    }

    // Error on page load. Now it doesn't work. User sees standard error page.
    if (event.getThrowable() instanceof IllegalArgumentException) {
        IllegalArgumentException exception = (IllegalArgumentException) event.getThrowable();

        Label label = new Label(exception.getMessage());
        label.setWidth(-1, Unit.PERCENTAGE);

        Link goToMain = new Link("Go to main", new ExternalResource("/"));

        VerticalLayout layout = new VerticalLayout();
        layout.addComponent(label);
        layout.addComponent(goToMain);
        layout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
        layout.setComponentAlignment(goToMain, Alignment.MIDDLE_CENTER);

        VerticalLayout mainLayout = new VerticalLayout();
        mainLayout.setSizeFull();
        mainLayout.addComponent(layout);
        mainLayout.setComponentAlignment(layout, Alignment.MIDDLE_CENTER);

        setContent(mainLayout);
        Notification.show(exception.getMessage(), Notification.Type.ERROR_MESSAGE);
        return;
    }

    DefaultErrorHandler.doDefault(event);
}

From source file:com.mcparland.john.MobileLayout.java

License:Apache License

public MobileLayout() {
    Label header = new Label("<h1>CSS layout</h1>", ContentMode.HTML);
    addComponent(header);/*  ww  w  .jav  a  2 s  .com*/

    Label content = new Label(LIPSUM);
    content.setWidth(70, Unit.PERCENTAGE);
    addComponent(content);

    addComponent(createMenu());
}

From source file:cz.zcu.pia.social.network.frontend.components.profile.profile.ComponentProfile.java

/**
 * Post Construct/*  w  ww .  j  a  v a2  s  .  c o m*/
 */
@PostConstruct
public void postConstruct() {
    if (!securityHelper.isAuthenticated()) {
        ((MyUI) UI.getCurrent().getUI()).getNavigator().navigateTo(ViewHome.NAME);
        return;
    }
    Users user = usersService.getUserByUsername(securityHelper.getLogedInUser().getUsername());
    if (user == null) {
        return;
    }

    this.addComponent(editProfile);
    editProfile.setUser(user);
    editProfile.setVisible(false);
    editProfile.setParentReference(this);

    setLabels(user);
    editButton = new Button(msgs.getMessage("edit"));
    editButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            buttonEditFunction(event);
        }
    });

    if (securityHelper.getLogedInUser().getUserImageName() != null) {
        reloadImage();

    } else {
        ImageUploader receiver = appContext.getBean(ImageUploader.class);
        receiver.setParentReference(this);
        Upload upload = new Upload(msgs.getMessage("upload.image"), receiver);
        upload.setButtonCaption(msgs.getMessage("upload"));
        upload.addSucceededListener(receiver);

        upload.addFailedListener(new Upload.FailedListener() {

            @Override
            public void uploadFailed(Upload.FailedEvent event) {
                Notification.show(msgs.getMessage("upload.not.ok"));
            }
        });
        layout.addComponent(upload, "picture");

    }

    fullname = new Label(user.getName() + " " + user.getSurname());
    layout.addComponent(fullname, "name");

    Label usernameLabel = new Label(msgs.getMessage("username") + ":");
    Label postsLabel = new Label(msgs.getMessage("number-of-posts") + ":");
    Label followersLabel = new Label(msgs.getMessage("number-of-followers") + ":");

    usernameLabel.setWidth(LABEL_WIDTH, Unit.PIXELS);
    postsLabel.setWidth(LABEL_WIDTH, Unit.PIXELS);
    followersLabel.setWidth(LABEL_WIDTH, Unit.PIXELS);

    layout.addComponent(usernameLabel, "usernameLabel");
    layout.addComponent(postsLabel, "numberPostsLabel");
    layout.addComponent(followersLabel, "numberFollowersLabel");

    layout.addComponent(username, "username");
    layout.addComponent(numberOfposts, "numberPosts");
    layout.addComponent(numberOfFollowers, "numberFollowers");
    layout.addComponent(editButton, "button");
}

From source file:cz.zcu.pia.social.network.frontend.components.profile.profile.ComponentProfilePost.java

/**
 * Post Construct/* w  ww .ja v  a 2  s. c o  m*/
 */
@PostConstruct
public void postConstruct() {

    setLabels(user);
    if (user.getUserImageName() != null) {
        image.setVisible(true);
        image.setSource(new FileResource(new File(Constants.BASE_PATH_RESIZED + user.getUserImageName())));
        layout.addComponent(image, "picture");
    }
    fullname = new Label(user.getFullname());
    layout.addComponent(fullname, "name");

    Label usernameLabel = new Label(msgs.getMessage("username") + ":");
    Label postsLabel = new Label(msgs.getMessage("number-of-posts") + ":");
    Label followersLabel = new Label(msgs.getMessage("number-of-followers") + ":");

    usernameLabel.setWidth(LABEL_WIDTH, Sizeable.Unit.PIXELS);
    postsLabel.setWidth(LABEL_WIDTH, Sizeable.Unit.PIXELS);
    followersLabel.setWidth(LABEL_WIDTH, Sizeable.Unit.PIXELS);

    layout.addComponent(usernameLabel, "usernameLabel");
    layout.addComponent(postsLabel, "numberPostsLabel");
    layout.addComponent(followersLabel, "numberFollowersLabel");

    layout.addComponent(username, "username");
    layout.addComponent(numberOfposts, "numberPosts");
    layout.addComponent(numberOfFollowers, "numberFollowers");
    layout.addComponent(createButtons(), "button");
}

From source file:de.datenhahn.vaadin.componentrenderer.demo.ComponentRendererDemoUI.java

License:Apache License

private void addHeader() {
    Label headerLabel = new Label("<h1>ComponentRenderer Demo</h1>", ContentMode.HTML);
    headerLabel.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(headerLabel);/*  www .  j av a2  s .  com*/
    layout.addComponent(new Label("Each grid contains 10000 rows"));
}

From source file:de.escidoc.admintool.view.admintask.filter.FilterResourceView.java

License:Open Source License

private void addFilterQueryTexField() {
    rawFilterTextArea.setWidth(800, UNITS_PIXELS);

    final Label popUpContent = new Label(ViewConstants.FILTER_EXAMPLE_TOOLTIP_TEXT, Label.CONTENT_XHTML);
    popUpContent.setWidth(400, UNITS_PIXELS);
    final PopupView popup = new PopupView(ViewConstants.TIP, popUpContent);
    filterLayout.addComponent(popup);/*from w  w w .  ja v a 2 s .  com*/
    filterLayout.addComponent(rawFilterTextArea);
}

From source file:de.escidoc.admintool.view.util.LayoutHelper.java

License:Open Source License

/**
 * //from  ww  w .j a v  a  2 s .c  o  m
 * @param labelLeft
 * @param labelRight
 * @param compLeft
 * @param compRight
 * @param widthLeft
 * @param widthRight
 * @param required
 * @return the constructed result.
 */
public static synchronized HorizontalLayout create(final String labelLeft, final String labelRight,
        final Label compLeft, final Label compRight, final int widthLeft, final int widthRight,
        final boolean required) {

    final HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setHeight(Constants.DEFAULT_HEIGHT);

    hLayout.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));

    final Label leftLabel = new Label(Constants.P_ALIGN_RIGHT + labelLeft + Constants.P, Label.CONTENT_XHTML);
    leftLabel.setWidth(111, Sizeable.UNITS_PIXELS);
    hLayout.addComponent(leftLabel);

    hLayout.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));

    hLayout.addComponent(compLeft);
    hLayout.setComponentAlignment(compLeft, Alignment.BOTTOM_RIGHT);

    hLayout.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));

    final Label c = new Label(Constants.P_ALIGN_RIGHT + labelRight + Constants.P, Label.CONTENT_XHTML);
    hLayout.addComponent(c);

    hLayout.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));

    hLayout.addComponent(compRight);
    hLayout.setComponentAlignment(compRight, Alignment.BOTTOM_RIGHT);

    return hLayout;
}

From source file:de.kaiserpfalzEdv.office.ui.web.widgets.about.AboutPanel.java

License:Apache License

@PostConstruct
public void init() {
    Image logo = new Image(null, new ThemeResource("../images/lichti-wappen.png"));
    logo.setId("about-logo");
    logo.setAlternateText("Logo: Kaiserpfalz EDV-Service");
    logo.setWidth(150f, Unit.PIXELS);/*from   ww w .  j  a va 2  s .c om*/
    logo.setHeight(170f, Unit.PIXELS);
    logo.setCaption("Kaiserpfalz EDV-Service");

    addComponent(logo);
    setComponentAlignment(logo, Alignment.MIDDLE_CENTER);

    Label name = new Label(
            "<div style='text-align: center;'><b>" + application.get(ApplicationMetaData.APPLICATION_NAME)
                    + "</b>" + "<br/>" + "<i><small>Version "
                    + application.get(ApplicationMetaData.APPLICATION_VERSION) + "</small></i></div>",
            ContentMode.HTML);
    name.setWidth(200f, Unit.PIXELS);
    addComponent(name);
    setComponentAlignment(name, Alignment.MIDDLE_CENTER);

    addComponent(new Label(""));
    addComponent(new Label("License: " + license.getId()));
    addComponent(new Label("Licensee: " + license.getLicensee()));
    addComponent(new Label(""));
    addComponent(new Label("Issued: " + license.getIssueDate()));
    addComponent(new Label("Issuer: " + license.getIssuer()));
    addComponent(new Label(""));
    addComponent(new Label("Valid (Time): " + license.getStart() + " - " + license.getExpiry()));
    addComponent(new Label("Valid (Version): " + license.getVersionRange().getStart() + " - "
            + license.getVersionRange().getEnd()));

    LOG.trace("Initialized: {}", this);
    LOG.trace("  application: {}", application);
    LOG.trace("  license: {}", license);
}