Example usage for com.vaadin.ui HorizontalLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:edu.nps.moves.mmowgli.modules.administration.TopCardsGameDesignPanel.java

License:Open Source License

private Component renderFields(CardTypeFields fields, NativeSelect combo, String name, Label editWarningLab) {
    VerticalLayout topPan = new VerticalLayout();
    topPan.setWidth("98%");
    topPan.addStyleName("m-greyborder3");
    Label lab;// w w  w  .j a v  a2  s .co  m
    topPan.addComponent(lab = new Label());
    lab.setHeight("18px");

    HorizontalLayout topHL = new HorizontalLayout();
    topHL.setSpacing(true);
    ;
    topHL.addComponent(lab = new Label());
    lab.setWidth("1px");
    topHL.setExpandRatio(lab, 0.5f);
    topHL.addComponent(lab = new HtmlLabel("<b>" + name + "</b>"));
    lab.setSizeUndefined();

    topHL.addComponent(combo);

    Button newTypeButt;
    topHL.addComponent(newTypeButt = new NativeButton("Define new top-level type"));
    newTypeButt.addStyleName(Runo.BUTTON_SMALL);
    newTypeButt.setReadOnly(globals.readOnlyCheck(false));
    newTypeButt.setEnabled(!newTypeButt.isReadOnly());
    if (!newTypeButt.isReadOnly())
        newTypeButt.addClickListener(new NewCardClassListener(fields.cardClass));

    topHL.addComponent(lab = new Label());
    lab.setWidth("1px");
    topHL.setExpandRatio(lab, 0.5f);

    topPan.addComponent(topHL);
    topHL.setWidth("100%");

    addComponent(editWarningLab);

    topPan.addComponent(fields);
    fields.setWidth("100%");
    return topPan;
}

From source file:edu.nps.moves.mmowgli.modules.administration.VipListManager.java

License:Open Source License

private void showAddDialogOrCancel(final DoneListener lis) {
    dialog = new Window("Add to VIP list");
    dialog.setModal(true);/*w  w  w.j av a 2s .c  o m*/
    dialog.setWidth("400px");
    dialog.setHeight("350px");

    VerticalLayout layout = new VerticalLayout();
    dialog.setContent(layout);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();

    List<String> rtypes = Arrays.asList(new String[] { EMAILTYPE, DOMAINTYPE });
    radios = new OptionGroup("Select type", rtypes);

    radios.setNullSelectionAllowed(false); // user can not 'unselect'
    radios.select("Emails"); // select this by default
    radios.setImmediate(false); // don't send the change to the server at once
    layout.addComponent(radios);

    final TextArea ta = new TextArea();
    //ta.setColumns(40);
    ta.setSizeFull();
    ta.setInputPrompt(
            "Type or paste a tab-, comma- or space-separated list of emails or domains.  For domains, "
                    + "use forms such as \"army.mil\", \"nmci.navy.mil\", \"ucla.edu\", \"gov\", etc.");
    layout.addComponent(ta);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    @SuppressWarnings("serial")
    Button cancelButt = new Button("Cancel", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            dialog.close();
            lis.continueOrCancel(null);
        }
    });

    @SuppressWarnings("serial")
    Button addButt = new Button("Add", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            String[] returnArr = null;
            String result = ta.getValue().toString();
            if (result == null || result.length() <= 0)
                returnArr = null;
            else if ((returnArr = parseIt(result)) == null)
                return;

            dialog.close();
            lis.continueOrCancel(returnArr);
        }
    });

    hl.addComponent(cancelButt);
    hl.addComponent(addButt);
    hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT);
    hl.setExpandRatio(cancelButt, 1.0f);

    // The components added to the window are actually added to the window's
    // layout; you can use either. Alignments are set using the layout
    layout.addComponent(hl);

    hl.setWidth("100%");
    ta.setWidth("100%");
    ta.setHeight("100%");
    layout.setExpandRatio(ta, 1.0f);

    UI.getCurrent().addWindow(dialog);
    dialog.center();
}

From source file:edu.nps.moves.mmowgli.modules.administration.VipListManager.java

License:Open Source License

@SuppressWarnings({ "unchecked", "serial" })
private void showViewOrDelete(final DeleteListener lis) {
    dialog = new Window("View / Delete VIPs");
    dialog.setModal(true);/*from w  w w  .  j  av  a  2 s.  c  o m*/

    VerticalLayout layout = new VerticalLayout();
    dialog.setContent(layout);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();

    List<VipPii> vLis = VHibPii.getAllVips();

    vipListSelect = new ListSelect("Select items to delete");
    StringBuffer sb = new StringBuffer(); // for popup
    vipListSelect.addStyleName("m-greyborder");
    String lf = System.getProperty("line.separator");
    for (int i = 0; i < vLis.size(); i++) {
        VipPii v;
        vipListSelect.addItem(v = vLis.get(i));
        sb.append(v.getEntry());
        sb.append(lf);
    }
    if (sb.length() > 0)
        sb.setLength(sb.length() - 1); // last space

    vipListSelect.setNullSelectionAllowed(true);
    vipListSelect.setMultiSelect(true);
    vipListSelect.setImmediate(true);
    vipListSelect.addValueChangeListener(new VipSelectListener());

    layout.addComponent(vipListSelect);

    Label copyPopupList = new HtmlLabel("<pre>" + sb.toString() + "</pre>");
    Panel p = new Panel();
    VerticalLayout lay = new VerticalLayout();
    p.setContent(lay);
    lay.addComponent(copyPopupList);
    p.setWidth("400px");
    p.setHeight("300px");
    PopupView popup = new PopupView("Display list as copyable text", p);
    popup.setHideOnMouseOut(false);
    if (sb.length() <= 0)
        popup.setEnabled(false);

    layout.addComponent(popup);
    layout.setComponentAlignment(popup, Alignment.MIDDLE_CENTER);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    Button cancelButt = new Button("Cancel", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            dialog.close();
            lis.continueOrCancel(null);
        }
    });

    deleteButt = new Button("Delete & Close", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            Set<VipPii> set = (Set<VipPii>) vipListSelect.getValue();
            if (set.size() <= 0)
                set = null;
            dialog.close();
            lis.continueOrCancel(set);
        }
    });
    deleteButt.setEnabled(false);
    hl.addComponent(cancelButt);
    hl.addComponent(deleteButt);
    hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT);
    hl.setExpandRatio(cancelButt, 1.0f);

    // The components added to the window are actually added to the window's
    // layout; you can use either. Alignments are set using the layout
    layout.addComponent(hl);
    dialog.setWidth("300px");
    dialog.setHeight("350px");
    hl.setWidth("100%");
    vipListSelect.setWidth("99%");
    vipListSelect.setHeight("99%");
    layout.setExpandRatio(vipListSelect, 1.0f);

    UI.getCurrent().addWindow(dialog);
    dialog.center();
}

From source file:edu.nps.moves.mmowgli.modules.cards.CardChainTreeTablePopup.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
public CardChainTreeTablePopup(Object rootId, boolean modal, boolean wantSaveButton) {
    super(null);/*ww  w .  j a  va2s  . co m*/
    setWidth("600px");
    setHeight("400px");
    addStyleName("m-noborder"); // V7 difference

    super.initGui();
    selectedId = tempSelectedId = rootId;
    setModal(modal);
    setListener(this);
    setResizable(true);

    setTitleString("Card chain");
    saveClicked = false;

    contentVLayout.setSpacing(true);

    treeT = new CardChainTree(rootId, false, !modal);
    if (rootId == null) {
        setTitleString("Card chains");
        // instead, do some creative backgrounding to pseudo select children of a card, treeT.setMultiSelect(true);
    }
    //treeT.setSizeFull();
    treeT.setWidth("99%");
    treeT.setHeight("99%");
    treeT.addItemClickListener((ItemClickListener) this);
    treeT.addStyleName("m-greyborder");
    contentVLayout.addComponent(treeT);
    contentVLayout.setComponentAlignment(treeT, Alignment.MIDDLE_CENTER);
    contentVLayout.setExpandRatio(treeT, 1.0f);

    /* todo...the saved data was never being retrieved, should pass it back to create action plan panel */

    if (wantSaveButton) {
        // need a save button
        HorizontalLayout hl = new HorizontalLayout();
        hl.setWidth("100%");
        contentVLayout.addComponent(hl);
        Label lab;
        hl.addComponent(lab = new Label());
        hl.setExpandRatio(lab, 1.0f);

        NativeButton saveButt = new NativeButton();
        hl.addComponent(saveButt);
        saveButt.setIcon(Mmowgli2UI.getGlobals().getMediaLocator().getSaveButtonIcon());
        saveButt.setWidth("45px"); //38px");
        saveButt.setHeight("16px");
        saveButt.addStyleName("borderless");
        saveButt.addClickListener(saveListener = new SaveListener());
        saveButt.setClickShortcut(KeyCode.ENTER);
        hl.addComponent(lab = new Label());
        lab.setWidth("30px");
        contentVLayout.addComponent(hl);
    }
}

From source file:edu.nps.moves.mmowgli.modules.cards.IdeaDashboardTabPanel.java

License:Open Source License

protected HorizontalLayout makeTableHeaders() {
    HorizontalLayout titleHL = new HorizontalLayout();
    titleHL.setSpacing(true);/* w ww.  j av a  2 s . c  om*/
    titleHL.setWidth("100%");
    Label lab;
    lab = buildTitleLabel(titleHL, "<center>Creation<br/>Date</center>");
    lab.setWidth(4.0f, Unit.EM);
    lab = buildTitleLabel(titleHL, "<center>Card<br/>Type</center>");
    lab.setWidth(6.0f, Unit.EM);
    lab = buildTitleLabel(titleHL, "Text");
    titleHL.setExpandRatio(lab, 1.0f);
    lab = buildTitleLabel(titleHL, "Author");
    lab.setWidth(8.0f, Unit.EM);
    return titleHL;
}

From source file:edu.nps.moves.mmowgli.modules.cards.PlayAnIdeaPage2.java

License:Open Source License

private HorizontalLayout buildLabelPopupRow(String text, Label popup) {
    HorizontalLayout hLay = new HorizontalLayout();
    hLay.setHeight("25px");
    hLay.setWidth("980px");

    Label lab;//from   ww  w  .ja  va  2  s. c  o m
    hLay.addComponent(lab = new Label());
    lab.setWidth("25px");

    hLay.addComponent(lab = new HtmlLabel(text + "&nbsp;&nbsp;")); // to keep italics from clipping
    lab.setSizeUndefined();
    lab.addStyleName("m-playanidea-heading-text");
    hLay.setExpandRatio(lab, 0.5f);
    popup.addStyleName("m-newcardpopup");
    hLay.addComponent(popup);
    hLay.setExpandRatio(popup, 0.5f);
    popup.setImmediate(true);
    Animator.animate(popup, new Css().opacity(0.0d));
    hLay.addComponent(lab = new Label());
    lab.setWidth("20px");

    return hLay;
}

From source file:edu.nps.moves.mmowgli.modules.gamemaster.AddAuthorEventHandler.java

License:Open Source License

@SuppressWarnings("serial")
public static void inviteAuthorsToActionPlan() {
    final Window win = new Window("Choose Action Plan");
    win.setWidth("600px");
    win.setHeight("500px");

    VerticalLayout layout = new VerticalLayout();
    win.setContent(layout);//  w w  w.  j a v  a  2 s.  c o m
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();

    final ActionPlanTable apt = new ActionPlanTable() {
        @Override
        public ItemClickListener getItemClickListener() {
            return new ItemClickListener() {
                public void itemClick(ItemClickEvent event) {
                }
            }; // null listener
        }
    };
    apt.setMultiSelect(false);
    apt.setPageLength(10);
    apt.setSizeFull();
    layout.addComponent(apt);
    layout.setExpandRatio(apt, 1.0f);

    HorizontalLayout buttHL = new HorizontalLayout();
    layout.addComponent(buttHL);
    buttHL.setWidth("100%");
    buttHL.setSpacing(true);
    Label sp;
    buttHL.addComponent(sp = new Label());
    sp.setWidth("1px");
    buttHL.setExpandRatio(sp, 1.0f);

    Button selectButton = new Button("Select");
    buttHL.addComponent(selectButton);
    Button cancelButton = new Button("Cancel");
    buttHL.addComponent(cancelButton);

    UI.getCurrent().addWindow(win);
    win.center();

    selectButton.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            win.close();
            Object o = apt.getValue();
            if (o != null) {
                HSess.init();
                inviteAuthorsToActionPlanTL(o);
                HSess.close();
            }
        }
    });
    cancelButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            win.close();
        }
    });
}

From source file:edu.nps.moves.mmowgli.modules.gamemaster.EventMonitorPanel.java

License:Open Source License

private void buildTopInfo(VerticalLayout vertL) {
    captionLabel = new HtmlLabel("dummy");
    vertL.addComponent(captionLabel);//from   w w w  .  ja v a 2 s .com

    HorizontalLayout bottomHL = new HorizontalLayout();
    bottomHL.setMargin(false);
    bottomHL.setWidth("100%");
    vertL.addComponent(bottomHL);

    statsLabel = new HtmlLabel("dummy");
    statsLabel.setSizeUndefined();
    bottomHL.addComponent(statsLabel);

    Label lab;
    bottomHL.addComponent(lab = new Label());
    lab.setWidth("1px");
    bottomHL.setExpandRatio(lab, 1.0f);

    newEventLabel = new HtmlLabel("new event&nbsp;&nbsp;"); // safari cuts off tail
    newEventLabel.setSizeUndefined();
    newEventLabel.addStyleName("m-newcardpopup");
    newEventLabel.setImmediate(true);
    bottomHL.addComponent(newEventLabel);
    Animator.animate(newEventLabel, new Css().opacity(0.0d)); // hide it
}

From source file:edu.nps.moves.mmowgli.modules.maps.LeafletMap.java

License:Open Source License

public void initGuiTL() {
    setSpacing(true);//from   w w  w  .  j  av  a  2 s.c o m
    setSizeUndefined();
    setWidth("950px");
    addStyleName("m-marginleft-20");
    Label lab;

    HorizontalLayout hLay = new HorizontalLayout();
    hLay.setMargin(false);
    hLay.setSpacing(false);
    hLay.setWidth("100%");
    NativeButton butt;
    hLay.addComponent(butt = new NativeButton("go to default game location", new MyDefaultLocationListener()));
    hLay.setExpandRatio(butt, 0.5f);
    hLay.setComponentAlignment(butt, Alignment.BOTTOM_LEFT);

    hLay.addComponent(lab = new HtmlLabel(title));
    lab.setWidth(null);

    makeLayerPopups();
    HorizontalLayout popLay = new HorizontalLayout();
    popLay.setMargin(false);
    popLay.setSpacing(false);
    popLay.setWidth("100%");

    popLay.addComponent(lab = new Label());
    lab.setWidth("1px");
    popLay.setExpandRatio(lab, 1.0f);
    popLay.addComponent(baseLayerPopup);
    popLay.addComponent(overlayPopup);

    hLay.addComponent(popLay);
    hLay.setComponentAlignment(popLay, Alignment.BOTTOM_RIGHT);
    hLay.setExpandRatio(popLay, 0.5f);

    addComponent(hLay);

    User me = Mmowgli2UI.getGlobals().getUserTL();
    this.imAGuest = me.isViewOnly() || me.isAccountDisabled();

    map.setAttributionPrefix("Powered by Leaflet with v-leaflet");
    map.addStyleName("m-greyborder");
    map.removeAllComponents();
    // map.addControl(new LScale());
    layerMap = installAllLayers(map);

    fillLayerPopupsTL(); // build the widgets

    setDefaultMapValuesTL(me); // set default zoom, center, layers

    if (!imAGuest)
        setUserMapValuesTL(me); // set zoom, center and layers from userID pref.

    setOptionGroupWidgetsFromLayerMap();// syncs up the widgets to match the active layers

    Collection<Extension> exts = map.getExtensions();
    LLayers llayers = null;
    for (Extension ex : exts)
        if (ex instanceof LLayers) {
            llayers = (LLayers) ex;
            break;
        }
    if (llayers != null)
        map.removeExtension(llayers);

    addComponent(map);

    setExpandRatio(map, 1);
    map.setHeight("600px");
    map.setWidth("100%");
    map.addMoveEndListener(new MyMoveEndListener());
}

From source file:edu.nps.moves.mmowgli.modules.registrationlogin.LoginPopup.java

License:Open Source License

public LoginPopup(Button.ClickListener listener, boolean guest) {
    super(listener);
    super.initGui();
    if (guest) {//from w  w  w. j  a v  a 2  s .  co m
        @SuppressWarnings("unchecked")
        List<User> lis = (List<User>) HSess.get().createCriteria(User.class)
                .add(Restrictions.eq("viewOnly", true)).add(Restrictions.eq("accountDisabled", false)).list();
        if (lis.size() > 0) {
            for (User u : lis) {
                if (u.getUserName().toLowerCase().equals("guest")) {
                    userID = u.getId();
                    return;
                }
            }
        }
        // If here, the guest logon is enabled, but no userID named guest is marked "viewOnly", continue and let
        // caller realize what happened
    }
    setTitleString("Sign in please.");

    contentVLayout.setSpacing(true);
    Label lab = new Label();
    lab.setHeight("20px");
    contentVLayout.addComponent(lab);

    VerticalLayout lay = new VerticalLayout();
    contentVLayout.addComponent(lay);
    contentVLayout.setComponentAlignment(lay, Alignment.TOP_CENTER);

    lay.addComponent(lab = new Label("Player name:"));
    lab.addStyleName("m-dialog-label");

    lay.addComponent(userIDTf = new TextField());
    userIDTf.setColumns(35);
    userIDTf.setTabIndex(100);
    userIDTf.setId(USER_NAME_TEXTBOX);
    userIDTf.addStyleName("m-dialog-entryfield");

    lay.addComponent(lab = new Label());
    lab.setHeight("15px");

    lay.addComponent(lab = new Label("Password:"));
    lab.addStyleName("m-dialog-label");

    lay.addComponent(passwordTf = new PasswordField());
    passwordTf.setColumns(35);
    passwordTf.setTabIndex(101);
    passwordTf.setId(USER_PASSWORD_TEXTBOX);
    passwordTf.addStyleName("m-dialog-entryfield");

    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth("100%");
    contentVLayout.addComponent(hl);

    hl.addComponent(lab = new Label());
    hl.setExpandRatio(lab, 1.0f);

    continueButt = new NativeButton();
    continueButt.setId(LOGIN_CONTINUE_BUTTON);
    hl.addComponent(continueButt);
    Mmowgli2UI.getGlobals().mediaLocator().decorateDialogContinueButton(continueButt);

    continueButt.addClickListener(new MyContinueListener());
    continueButt.setClickShortcut(KeyCode.ENTER);

    // Password reset
    HorizontalLayout h2 = new HorizontalLayout();
    h2.setWidth("100%");
    contentVLayout.addComponent(h2);

    h2.addComponent(lab = new Label());
    h2.setExpandRatio(lab, 01.0f);
    pwResetButt = new NativeButton("Forgot password or player name?");
    pwResetButt.addStyleName("m-signin-forgotButton");
    h2.addComponent(pwResetButt);

    pwResetButt.addClickListener(new MyForgotLoginInfoListener());

    userIDTf.focus(); // won't do it
    FocusHack.focus(userIDTf); // will do it
}