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(String width) 

Source Link

Usage

From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileMyIdeasPanel2.java

License:Open Source License

private void row(String s, int largest, int sz, CardType ct, GridLayout grid) {
    float pct = (float) sz / (float) largest;
    float wd = pct * MAXBARWIDTH;
    int width = Math.max(Math.round(wd), 1);

    Label lab;
    grid.addComponent(lab = new Label(s));
    lab.setWidth("160");
    lab.setDescription(s);/*from   w  ww.ja  v  a 2s.c  o m*/

    HorizontalLayout hLay = new HorizontalLayout();
    hLay.setSpacing(true);
    hLay.setMargin(false);

    hLay.addComponent(lab = new HtmlLabel(" "));
    ;
    lab.addStyleName(CardType.getColorStyle(ct)); //CardTypeManager.getColorStyle(ct));
    lab.setWidth("" + width + "px");
    hLay.addComponent(lab = new Label("" + sz));

    grid.addComponent(hLay);
}

From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileMyIdeasPanel2.java

License:Open Source License

private Component buildNoIdeasYet() {
    if (!userIsMe) {
        Label lab = new Label("No idea cards yet");
        lab.addStyleName("m-userprofile-tabpanel-font");
        return lab;
    }//from  w w w  .  ja v a  2s.c  o m
    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    hl.setMargin(true);
    hl.setWidth("100%");
    Label lab;
    hl.addComponent(lab = new Label("No idea cards yet"));
    lab.addStyleName("m-userprofile-tabpanel-font");
    lab.setSizeUndefined();
    hl.setExpandRatio(lab, 0.5f);
    hl.setComponentAlignment(lab, Alignment.TOP_RIGHT);
    hl.addComponent(lab = new Label());
    lab.setWidth("30px");
    IDNativeButton butt = new IDNativeButton("Play a card now", MmowgliEvent.PLAYIDEACLICK);
    butt.setStyleName(BaseTheme.BUTTON_LINK);
    butt.addStyleName("m-link-button-18");
    hl.addComponent(butt);
    hl.setExpandRatio(butt, 0.5f);
    hl.setComponentAlignment(butt, Alignment.TOP_LEFT);
    return hl;
}

From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileTabPanel.java

License:Open Source License

@Override
public void initGui() {
    setWidth("960px");
    setHeight("750px"); // must fill the background
    setSpacing(false);//from   www  .  j  a  va 2 s.c  om

    leftLay = new VerticalLayout();
    leftLay.addStyleName("m-userprofiletabpanel-left");
    leftLay.setWidth("245px");// plus 45 padding 
    leftLay.setMargin(false);

    Label sp;
    leftLay.addComponent(sp = new Label());
    sp.setHeight("45px");

    leftLabel = new HtmlLabel("placeholder");
    leftLay.addComponent(leftLabel);

    leftAddedVL = new VerticalLayout();
    leftLay.addComponent(leftAddedVL);
    leftAddedVL.setWidth("100%");

    leftLay.addComponent(sp = new Label());
    sp.setHeight("1px");
    leftLay.setExpandRatio(sp, 1.0f); // bottom filler

    rightLay = new VerticalLayout();
    rightLay.setSizeUndefined(); // will expand with content

    rightLay.addStyleName("m-tabpanel-right");
    rightLay.addStyleName("m-userprofile-tabpanel-font");

    addComponent(leftLay);

    addComponent(sp = new Label());
    sp.setWidth("15px");

    addComponent(rightLay);
    setComponentAlignment(rightLay, Alignment.TOP_CENTER); //del if no help
    this.setExpandRatio(rightLay, 1.0f);
}

From source file:edu.nps.moves.mmowgliMobile.ui.CardRenderer2.java

License:Open Source License

public void setMessage(FullEntryView2 mView, ListEntry message, ListView2 messageList,
        AbstractOrderedLayout layout) {/* w  ww  .  j av  a 2s .c o m*/
    Object key = HSess.checkInit();
    CardListEntry wc = (CardListEntry) message;
    Card c = wc.getCard();
    CardType typ = c.getCardType();

    layout.removeAllComponents();
    layout.setSpacing(true);

    VerticalLayout cardLay = new VerticalLayout();
    cardLay.addStyleName("m-card-render");
    cardLay.setWidth("98%"); //100%");
    cardLay.setSpacing(true);
    layout.addComponent(cardLay);

    HorizontalLayout horl = new HorizontalLayout();
    horl.addStyleName("m-card-header");
    String stl = CardStyler.getCardBaseStyle(typ);
    horl.addStyleName(stl);
    horl.addStyleName(CardStyler.getCardTextColorOverBaseStyle(typ));
    horl.setMargin(true);
    horl.setWidth("100%");

    Label lbl = new Label(typ.getTitle());//c.getText());
    horl.addComponent(lbl);
    lbl = new Label("" + getPojoId(message));
    lbl.addStyleName("m-text-align-right");
    horl.addComponent(lbl);
    cardLay.addComponent(horl);

    horl = new HorizontalLayout();
    horl.setWidth("100%");
    horl.setMargin(true);
    cardLay.addComponent(horl);
    lbl = new Label(c.getText());
    horl.addComponent(lbl);

    horl = new HorizontalLayout();
    horl.addStyleName("m-card-footer");

    horl.setMargin(true);
    horl.setWidth("100%");
    horl.addComponent(lbl = new Label(""));
    lbl.setWidth("5px");

    Image img = new Image();
    img.setSource(mediaLocator.locate(c.getAuthor().getAvatar().getMedia()));
    img.setWidth("30px");
    img.setHeight("30px");
    horl.addComponent(img);

    //    horl.addComponent(lbl=new Label(c.getAuthorName()));
    //    lbl.setWidth("100%");
    //    lbl.addStyleName("m-text-align-center");
    //    horl.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER);
    //    horl.setExpandRatio(lbl, 1.0f);

    Button authButt = new MyButton(c.getAuthorName(), c, mView);
    authButt.setStyleName(BaseTheme.BUTTON_LINK);
    authButt.setWidth("100%");
    horl.addComponent(authButt);
    horl.setComponentAlignment(authButt, Alignment.MIDDLE_CENTER);
    horl.setExpandRatio(authButt, 1.0f);

    horl.addComponent(lbl = new HtmlLabel(formatter.format(message.getTimestamp())));
    lbl.setWidth("115px");
    ;
    lbl.addStyleName("m-text-align-right");
    horl.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER);

    cardLay.addComponent(horl);

    //    lbl = new Hr();   
    //    layout.addComponent(lbl);

    lbl = new Label("Child Cards");
    layout.addComponent(lbl);
    lbl.addStyleName("m-text-center");

    //    lbl = new Hr();
    //    layout.addComponent(lbl);

    horl = new HorizontalLayout();
    horl.setSpacing(true);
    horl.setMargin(true);
    horl.setWidth("100%");
    layout.addComponent(horl);

    horl.addComponent(
            makeChildGroupButton("Expand", (CardListEntry) message, CardType.getExpandTypeTL(), messageList));
    horl.addComponent(
            makeChildGroupButton("Counter", (CardListEntry) message, CardType.getCounterTypeTL(), messageList));
    horl.addComponent(
            makeChildGroupButton("Adapt", (CardListEntry) message, CardType.getAdaptTypeTL(), messageList));
    horl.addComponent(
            makeChildGroupButton("Explore", (CardListEntry) message, CardType.getExploreTypeTL(), messageList));

    HSess.checkClose(key);
}

From source file:edu.nps.moves.mmowgliMobile.ui.UserRenderer2.java

License:Open Source License

public void setMessage(FullEntryView2 mView, ListEntry message, ListView2 messageList,
        AbstractOrderedLayout layout) {// w w w.jav a 2  s  . co m
    // messageList can be null if coming in from ActionPlan
    Object key = HSess.checkInit();
    UserListEntry wu = (UserListEntry) message;
    User u = wu.getUser();
    layout.removeAllComponents();

    HorizontalLayout hlay = new HorizontalLayout();
    layout.addComponent(hlay);
    hlay.addStyleName("m-userview-top");
    hlay.setWidth("100%");
    hlay.setMargin(true);
    hlay.setSpacing(true);

    Image img = new Image();
    img.addStyleName("m-ridgeborder");
    img.setSource(mediaLocator.locate(u.getAvatar().getMedia()));
    img.setWidth("90px");
    img.setHeight("90px");
    hlay.addComponent(img);
    hlay.setComponentAlignment(img, Alignment.MIDDLE_CENTER);

    Label lab;
    hlay.addComponent(lab = new Label());
    lab.setWidth("5px");

    VerticalLayout vlay = new VerticalLayout();
    vlay.setSpacing(true);
    hlay.addComponent(vlay);
    hlay.setComponentAlignment(vlay, Alignment.MIDDLE_LEFT);
    vlay.setWidth("100%");
    hlay.setExpandRatio(vlay, 1.0f);
    HorizontalLayout horl = new HorizontalLayout();
    horl.setSpacing(false);
    vlay.addComponent(horl);
    vlay.setComponentAlignment(horl, Alignment.BOTTOM_LEFT);
    horl.addComponent(lab = new Label("name"));
    lab.addStyleName("m-user-top-label"); //light-text");
    horl.addComponent(lab = new HtmlLabel("  " + u.getUserName()));
    lab.addStyleName("m-user-top-value");
    horl = new HorizontalLayout();
    horl.setSpacing(false);
    vlay.addComponent(horl);
    vlay.setComponentAlignment(horl, Alignment.TOP_LEFT);

    horl.addComponent(lab = new Label("level"));
    lab.addStyleName("m-user-top-label"); //light-text");
    Level lev = u.getLevel();
    if (u.isGameMaster()) {
        Level l = Level.getLevelByOrdinal(Level.GAME_MASTER_ORDINAL, HSess.get());
        if (l != null)
            lev = l;
    }
    horl.addComponent(lab = new HtmlLabel("   " + lev.getDescription()));
    lab.addStyleName("m-user-top-value");

    GridLayout gLay = new GridLayout();
    // gLay.setHeight("155px");  // won't size properly
    gLay.setMargin(true);
    gLay.addStyleName("m-userview-mid");
    gLay.setColumns(2);
    gLay.setRows(11);
    gLay.setSpacing(true);
    gLay.setWidth("100%");
    gLay.setColumnExpandRatio(1, 1.0f);
    layout.addComponent(gLay);

    addRow(gLay, "user ID:", "" + getPojoId(message));
    addRow(gLay, "location:", u.getLocation());
    addRow(gLay, "expertise:", u.getExpertise());
    addRow(gLay, "affiliation:", u.getAffiliation());
    addRow(gLay, "date registered:", formatter.format(u.getRegisterDate()));

    gLay.addComponent(new Hr(), 0, 5, 1, 5);

    Container cntr = new CardsByUserContainer<Card>(u); // expects ThreadLocal session to be setup
    numCards = cntr.size();
    addRow(gLay, "cards played:", "" + numCards);
    cntr = new ActionPlansByUserContainer<Card>(u); // expects ThreadLocal session to be setup
    numAps = cntr.size();
    addRow(gLay, "action plans:", "" + numAps);

    gLay.addComponent(new Hr(), 0, 8, 1, 8);

    addRow(gLay, "exploration points:", "" + u.getBasicScore());
    addRow(gLay, "innovation points:", "" + u.getInnovationScore());

    cardListener = new CardLis(u, mView);
    apListener = new AppLis(u, mView);

    layout.addComponent(makeButtons());

    HSess.checkClose(key);
}

From source file:eu.lod2.LOD2Demo.java

License:Apache License

public void home() {
    workspace.removeAllComponents();/*w  w w  . j  av  a2s.c o  m*/
    workspace.setHeight("80%");

    HorizontalLayout introH = new HorizontalLayout();
    Embedded lod2cycle = new Embedded("", new ThemeResource("app_images/lod-lifecycle-small.png"));
    lod2cycle.setMimeType("image/png");
    introH.addComponent(lod2cycle);
    introH.setComponentAlignment(lod2cycle, Alignment.MIDDLE_LEFT);

    VerticalLayout introV = new VerticalLayout();
    introH.addComponent(introV);

    Label introtextl = new Label(introtext, Label.CONTENT_XHTML);
    introV.addComponent(introtextl);
    introtextl.setWidth("400px");

    HorizontalLayout introVH = new HorizontalLayout();
    introV.addComponent(introVH);

    Embedded euflag = new Embedded("", new ThemeResource("app_images/eu-flag.gif"));
    euflag.setMimeType("image/gif");
    introVH.addComponent(euflag);
    euflag.addStyleName("eugif");
    euflag.setHeight("50px");
    Embedded fp7 = new Embedded("", new ThemeResource("app_images/fp7-gen-rgb_small.gif"));
    fp7.setMimeType("image/gif");
    fp7.addStyleName("eugif");
    fp7.setHeight("50px");
    introVH.addComponent(fp7);

    workspace.addComponent(introH);

}

From source file:eu.lod2.stat.StatLOD2Demo.java

License:Apache License

public void home() {
    workspace.removeAllComponents();/*from  ww  w.j  a  v a 2s .  co m*/
    workspace.setHeight("80%");

    HorizontalLayout introH = new HorizontalLayout();
    Embedded lod2cycle = new Embedded("", new ThemeResource("app_images/lod-lifecycle-cube.jpg"));
    lod2cycle.setMimeType("image/png");
    introH.addComponent(lod2cycle);
    introH.setComponentAlignment(lod2cycle, Alignment.MIDDLE_LEFT);

    VerticalLayout introV = new VerticalLayout();
    introH.addComponent(introV);

    Label introtextl = new Label(introtext, Label.CONTENT_XHTML);
    introV.addComponent(introtextl);
    introtextl.setWidth("400px");

    HorizontalLayout introVH = new HorizontalLayout();
    introV.addComponent(introVH);

    Embedded euflag = new Embedded("", new ThemeResource("app_images/eu-flag.gif"));
    euflag.setMimeType("image/gif");
    introVH.addComponent(euflag);
    euflag.addStyleName("eugif");
    euflag.setHeight("50px");
    Embedded fp7 = new Embedded("", new ThemeResource("app_images/fp7-gen-rgb_small.gif"));
    fp7.setMimeType("image/gif");
    fp7.addStyleName("eugif");
    fp7.setHeight("50px");
    introVH.addComponent(fp7);

    workspace.addComponent(introH);

}

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropDragGrabFilterDemo.java

License:Apache License

@Override
public Component getLayout() {
    // start-source
    // Create an absolute layout
    DDAbsoluteLayout layout = new DDAbsoluteLayout();
    layout.setSizeFull();/*from  ww  w  .j  a  va2  s.c  om*/

    // Enable dragging (of all) components
    layout.setDragMode(LayoutDragMode.CLONE);

    // Limit dragging to only buttons
    layout.setDragGrabFilter((DragGrabFilter) component -> {
        // Button/TextField inside of draggable Panel cannot be used/grabbed for Drag-n-Drop.
        return !(component instanceof Button) && !(component instanceof TextField);
    });

    // Enable dropping components
    layout.setDropHandler(new DefaultAbsoluteLayoutDropHandler());

    // Add some components to layout
    Label label = new Label("DragGrabFilter enable you to control which nested components of draggable "
            + "child can be used/grabbed. All components in this example are composite and draggable, "
            + "but you cannot drag Panel using Button/TextField children");
    label.setWidth("650px");
    layout.addComponent(label);

    layout.addComponent(createCompositeChild("1"), "left:50px;top:100px");
    layout.addComponent(createCompositeChild("3"), "left:280px;top:100px");
    layout.addComponent(createCompositeChild("3"), "left:510px;top:100px");

    // end-source
    return layout;
}

From source file:fi.semantum.strategia.Utils.java

License:Open Source License

public static void modifyAccount(final Main main) {

    final Database database = main.getDatabase();

    FormLayout content = new FormLayout();
    content.setSizeFull();// ww  w .  j  a v a2s .c  o m

    final Label l = new Label(main.account.getId(database));
    l.setCaption("Kyttjn nimi:");
    l.setWidth("100%");
    content.addComponent(l);

    final TextField tf = new TextField();
    tf.setWidth("100%");
    tf.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    tf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    tf.setCaption("Kyttjn nimi:");
    tf.setId("loginUsernameField");
    tf.setValue(main.account.getText(database));
    content.addComponent(tf);

    final TextField tf2 = new TextField();
    tf2.setWidth("100%");
    tf2.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    tf2.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    tf2.setCaption("Shkpostiosoite:");
    tf2.setId("loginUsernameField");
    tf2.setValue(main.account.getEmail());
    content.addComponent(tf2);

    final PasswordField pf = new PasswordField();
    pf.setCaption("Vanha salasana:");
    pf.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    pf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    pf.setWidth("100%");
    pf.setId("loginPasswordField");
    content.addComponent(pf);

    final PasswordField pf2 = new PasswordField();
    pf2.setCaption("Uusi salasana:");
    pf2.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    pf2.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    pf2.setWidth("100%");
    pf2.setId("loginPasswordField");
    content.addComponent(pf2);

    final PasswordField pf3 = new PasswordField();
    pf3.setCaption("Uusi salasana uudestaan:");
    pf3.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    pf3.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    pf3.setWidth("100%");
    pf3.setId("loginPasswordField");
    content.addComponent(pf3);

    final Label err = new Label("Vr kyttjtunnus tai salasana");
    err.addStyleName(ValoTheme.LABEL_FAILURE);
    err.addStyleName(ValoTheme.LABEL_TINY);
    err.setVisible(false);
    content.addComponent(err);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(false);

    Button apply = new Button("Tee muutokset");

    buttons.addComponent(apply);

    final Window dialog = Dialogs.makeDialog(main, "450px", "480px", "Kyttjtilin asetukset", "Poistu",
            content, buttons);
    apply.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 1992235622970234624L;

        public void buttonClick(ClickEvent event) {

            String valueHash = Utils.hash(pf.getValue());
            if (!valueHash.equals(main.account.getHash())) {
                err.setValue("Vr salasana");
                err.setVisible(true);
                return;
            }

            if (pf2.isEmpty()) {
                err.setValue("Tyhj salasana ei kelpaa");
                err.setVisible(true);
                return;
            }

            if (!pf2.getValue().equals(pf3.getValue())) {
                err.setValue("Uudet salasanat eivt tsm");
                err.setVisible(true);
                return;
            }

            main.account.text = tf.getValue();
            main.account.email = tf2.getValue();
            main.account.hash = Utils.hash(pf2.getValue());

            Updates.update(main, true);

            main.removeWindow(dialog);

        }

    });

}

From source file:fi.semantum.strategia.Utils.java

License:Open Source License

public static void updateYears(final Database database, final VerticalLayout vl) {

    vl.removeAllComponents();/*from  ww w  .  j  a v a2 s.  c o m*/

    final TimeConfiguration tc = TimeConfiguration.getInstance(database);
    TimeInterval ti = TimeInterval.parse(tc.getRange());
    for (int i = ti.startYear; i <= ti.endYear; i++) {
        final int year = i;
        HorizontalLayout hl = new HorizontalLayout();
        hl.setSpacing(true);
        String caption = Integer.toString(i) + (tc.isFrozen(i) ? " Muutokset estetty" : " Muokattavissa");
        Label l = new Label(caption);
        l.setWidth("250px");
        l.setHeight("100%");
        hl.addComponent(l);
        Button b = new Button(tc.isFrozen(i) ? "Avaa muokattavaksi" : "Est muutokset");
        b.addStyleName(ValoTheme.BUTTON_SMALL);
        b.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 556680407448842136L;

            @Override
            public void buttonClick(ClickEvent event) {
                if (tc.isFrozen(year)) {
                    tc.unfreeze(year);
                } else {
                    tc.freeze(year);
                }
                updateYears(database, vl);
            }

        });
        b.setWidth("200px");
        hl.addComponent(b);
        //hl.setWidth("100%");
        vl.addComponent(hl);
    }

}