Example usage for com.vaadin.ui HorizontalLayout setComponentAlignment

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

Introduction

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

Prototype

@Override
    public void setComponentAlignment(Component childComponent, Alignment alignment) 

Source Link

Usage

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

License:Open Source License

@Override
public void initGui() {
    setWidth("988px"); // same width as included panel
    setHeight(BIGGESTWINDOW_HEIGHT_S); // try to handle making the popup miss the video

    Instrumentation.addInstrumentation(this);

    Game game = Game.getTL();/*from  w ww .  j a v  a  2 s.  c  o  m*/
    MovePhase phase = game.getCurrentMove().getCurrentMovePhase();

    HorizontalLayout outerLayout = new HorizontalLayout();
    outerLayout.setSpacing(true);
    addComponent(outerLayout);
    outerLayout.setWidth("988px");
    setExpandRatio(outerLayout, 1);
    Label spacer;

    outerLayout.addComponent(baseVLayout = new VerticalLayout());
    baseVLayout.setWidth("988px");
    outerLayout.setComponentAlignment(baseVLayout, Alignment.TOP_CENTER);
    baseVLayout.setSpacing(true);

    // This is just to give us a hidden widget to update to keep push channel alive through Akamai
    outerLayout.addComponent(pushPingLab = new HtmlLabel(""));
    pushPingLab.setWidth("5px");

    String headingStr = phase.getOrientationCallToActionText();
    String summaryStr = phase.getOrientationHeadline();
    String textStr = phase.getOrientationSummary();
    Media vid = phase.getOrientationVideo();

    vidPan = new VideoWithRightTextPanel(vid, headingStr, summaryStr, textStr, null);
    vidPan.setLargeText(true);
    baseVLayout.addComponent(vidPan);
    vidPan.initGui();

    HorizontalLayout bottomHLayout = new HorizontalLayout();
    bottomHLayout.addComponent(spacer = new Label()); // special spacer
    bottomHLayout.setExpandRatio(spacer, 1.0f);

    Label[] spacers = new Label[5];

    Label lab;
    int numButts = 0;

    // Email signup button
    //-----------------------
    if (phase.isSignupButtonShow()) {
        VerticalLayout signupVL = new VerticalLayout();
        signupVL.setHeight("50px");
        signupVL.setMargin(false);

        if (mockupOnly)
            signupVL.addComponent(signupButt = new NativeButton(null)); // no handler
        else
            signupVL.addComponent(signupButt = new NativeButton(null, this));
        signupButt.addStyleName("signupbutton");
        signupButt.setEnabled(phase.isSignupButtonEnabled());
        Mmowgli2UI.getGlobals().mediaLocator().decorateImageButton(signupButt, phase.getSignupButtonIcon());
        signupVL.setComponentAlignment(signupButt, Alignment.MIDDLE_CENTER);

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

        signupVL.addComponent(lab = new HtmlLabel(phase.getSignupButtonSubText()));
        lab.addStyleName("m-text-align-center");
        signupButt.setDescription(phase.getSignupButtonToolTip());
        lab.setDescription(phase.getSignupButtonToolTip());
        lab.setEnabled(phase.isSignupButtonEnabled());
        signupVL.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

        bottomHLayout.addComponent(signupVL);
        numButts++;
    }

    // New player reg button
    //----------------------
    if (phase.isNewButtonShow()) {
        if (numButts > 0)
            bottomHLayout.addComponent(spacers[numButts] = new Label());

        VerticalLayout newButtVL = new VerticalLayout();
        newButtVL.setHeight("50px");
        newButtVL.setMargin(false);

        if (mockupOnly)
            newButtVL.addComponent(imNewButt = new NativeButton(null)); // no handler
        else
            newButtVL.addComponent(imNewButt = new NativeButton(null, this));
        imNewButt.setEnabled(phase.isNewButtonEnabled());
        imNewButt.addStyleName("newuserbutton");
        Mmowgli2UI.getGlobals().mediaLocator().decorateImageButton(imNewButt, phase.getNewButtonIcon());
        newButtVL.setComponentAlignment(imNewButt, Alignment.MIDDLE_CENTER);

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

        /*
              boolean gameRO = game.isReadonly();
              boolean gameClamped = game.isRegisteredLogonsOnly();
              imNewButt.setEnabled(!gameRO & !gameClamped);
                
              // Label lab;
              if (gameRO) {
                newButtVL.addComponent(lab = new Label("No new player accounts, for now")); // "Player registration is currently closed"));
                                                                            // //"Sorry, no more new players"));
                String s;
                lab.setDescription(s = "New player accounts will open when game play starts");
                imNewButt.setDescription(s);
              }
              else if (gameClamped)
                newButtVL.addComponent(lab = new Label("The game is full, please retry later")); // "Sorry, no more new players"));
              else
                newButtVL.addComponent(lab = new Label("You can get started in 2 minutes..."));
        */
        newButtVL.addComponent(lab = new HtmlLabel(phase.getNewButtonSubText()));
        newButtVL.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);
        lab.addStyleName("m-text-align-center");
        lab.setEnabled(phase.isNewButtonEnabled());
        imNewButt.setDescription(phase.getNewButtonToolTip());
        lab.setDescription(phase.getNewButtonToolTip());

        newButtVL.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

        bottomHLayout.addComponent(newButtVL);
        numButts++;
    }

    // Existing player button
    //-----------------------
    if (phase.isLoginButtonShow()) {
        if (numButts > 0)
            bottomHLayout.addComponent(spacers[numButts] = new Label());

        VerticalLayout rightButtVL = new VerticalLayout();
        rightButtVL.setHeight("50px");
        rightButtVL.setMargin(false);

        if (mockupOnly)
            rightButtVL.addComponent(imRegisteredButt = new NativeButton(null)); // no handler
        else
            rightButtVL.addComponent(imRegisteredButt = new NativeButton(null, this));
        imRegisteredButt.addStyleName("loginbutton");
        imRegisteredButt.setEnabled(phase.isLoginButtonEnabled());

        Mmowgli2UI.getGlobals().mediaLocator().decorateImageButton(imRegisteredButt,
                phase.getLoginButtonIcon());
        rightButtVL.setComponentAlignment(imRegisteredButt, Alignment.MIDDLE_CENTER);

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

        rightButtVL.addComponent(lab = new HtmlLabel(phase.getLoginButtonSubText()));
        lab.addStyleName("m-text-align-center");
        lab.setEnabled(phase.isLoginButtonEnabled());
        rightButtVL.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

        imRegisteredButt.setDescription(phase.getLoginButtonToolTip());
        lab.setDescription(phase.getLoginButtonToolTip());

        bottomHLayout.addComponent(rightButtVL);
        numButts++;

        checkQuickCACLoginTL();
    }

    // Guest signup button
    //-----------------------
    if (phase.isGuestButtonShow()) {
        if (numButts > 0)
            bottomHLayout.addComponent(spacers[numButts] = new Label());

        VerticalLayout guestButtVL = new VerticalLayout();
        guestButtVL.setHeight("50px");
        guestButtVL.setMargin(false);

        if (mockupOnly)
            guestButtVL.addComponent(guestButt = new NativeButton(null));
        else
            guestButtVL.addComponent(guestButt = new NativeButton(null, this));
        guestButt.addStyleName("guestbutton");
        guestButt.setEnabled(phase.isGuestButtonEnabled());

        Mmowgli2UI.getGlobals().mediaLocator().decorateImageButton(guestButt, phase.getGuestButtonIcon());
        guestButtVL.setComponentAlignment(guestButt, Alignment.MIDDLE_CENTER);

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

        guestButtVL.addComponent(lab = new HtmlLabel(phase.getGuestButtonSubText()));
        lab.addStyleName("m-text-align-center");
        guestButtVL.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

        guestButt.setDescription(phase.getGuestButtonToolTip());
        lab.setDescription(phase.getGuestButtonToolTip());
        lab.setEnabled(phase.isGuestButtonEnabled());
        bottomHLayout.addComponent(guestButtVL);
        numButts++;
    }

    for (int i = 0; i < numButts; i++)
        if (spacers[i] != null)
            spacers[i].setWidth(BUTTON_SPACING[numButts]);

    bottomHLayout.addComponent(spacer = new Label()); // special spacer
    bottomHLayout.setExpandRatio(spacer, 1.0f);

    baseVLayout.addComponent(bottomHLayout);
    baseVLayout.setComponentAlignment(bottomHLayout, Alignment.TOP_CENTER);

    lab = new HtmlLabel(
            "<center>Each MMOWGLI game is independent.<br>&nbsp;You need a new account for every game.&nbsp;</center>");
    lab.setSizeUndefined();
    lab.addStyleName("m-margintop-20");
    lab.addStyleName("m-greyborder");
    lab.addStyleName("m-background-white");
    lab.addStyleName("m-opacity-75");
    baseVLayout.addComponent(lab);
    baseVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    String troubleUrl = GameLinks.getTL().getTroubleLink();
    Link lnk = new Link("Trouble signing in?", new ExternalResource(troubleUrl));
    baseVLayout.addComponent(lnk);
    lnk.setTargetName(PORTALTARGETWINDOWNAME);
    lnk.setTargetBorder(BorderStyle.DEFAULT);
    lnk.addStyleName("m-margin-top-20");
    baseVLayout.setComponentAlignment(lnk, Alignment.MIDDLE_CENTER);

    //checkUserLimits();  done from app entry point
}

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

License:Open Source License

@SuppressWarnings("serial")
public ChangeEmailDialog(EmailPacket pkt) {
    this.packet = pkt;
    // this.uid=uid;
    //User user = DBGet.getUser(uid);

    setCaption("Change Email");
    setModal(true);/*from  w w  w. j a v a  2s. c  o m*/
    setWidth("350px");
    //setHeight("200px");

    VerticalLayout vLay = new VerticalLayout();
    setContent(vLay);
    FormLayout fLay = new FormLayout();
    oldEmail = new TextField("Current Email", pkt.original);//user.getEmailAddresses().toString());
    //oldPw.setColumns(20);
    oldEmail.setWidth("99%");
    fLay.addComponent(oldEmail);
    newEmail = new TextField("New Email");
    newEmail.setWidth("99%");
    fLay.addComponent(newEmail);
    newEmail2 = new TextField("Confirm Email");
    newEmail2.setWidth("99%");
    fLay.addComponent(newEmail2);

    vLay.addComponent(fLay);

    HorizontalLayout buttLay = new HorizontalLayout();
    buttLay.setSpacing(true);
    vLay.addComponent(buttLay);
    vLay.setComponentAlignment(buttLay, Alignment.TOP_RIGHT);
    MediaLocator mLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    NativeButton cancelButt = new NativeButton();
    mLoc.decorateCancelButton(cancelButt);
    buttLay.addComponent(cancelButt);
    buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT);

    //    Label sp;
    //    buttLay.addComponent(sp = new Label());
    //    sp.setWidth("30px");

    saveButt = new NativeButton();
    //app.globs().mediaLocator().decorateSaveButton(saveButt);  //"save"
    mLoc.decorateOkButton(saveButt); //"ok"
    buttLay.addComponent(saveButt);
    buttLay.setComponentAlignment(saveButt, Alignment.BOTTOM_RIGHT);

    //    buttLay.addComponent(sp = new Label());
    //    sp.setWidth("5px");

    cancelButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(ChangeEmailDialog.this);
        }
    });
    saveButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String oldTry = oldEmail.getValue().toString();
            if (!packet.original.equals(oldTry)) {
                Notification.show("Error", "This should never show", Notification.Type.ERROR_MESSAGE);
                return;
            }

            String check = newEmail2.getValue().toString();
            String newStr = newEmail.getValue().toString();
            if (check == null || !newStr.trim().equals(check.trim())) {
                Notification.show("Error", "Emails do not match", Notification.Type.ERROR_MESSAGE);
                return;
            }

            EmailValidator v = new EmailValidator("");
            if (newStr == null || !v.isValid(newStr)) {
                Notification.show("Error", "Please enter a valid email", Notification.Type.ERROR_MESSAGE);
                return;
            }

            packet.updated = newStr.trim();
            if (saveListener != null)
                saveListener.buttonClick(event);
            UI.getCurrent().removeWindow(ChangeEmailDialog.this);
        }
    });
}

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

License:Open Source License

@SuppressWarnings("serial")
public ChangePasswordDialog(PasswordPacket pkt) {
    this.packet = pkt;

    setCaption("Change Password");
    setModal(true);/*from   ww w  .j ava 2s. c  o  m*/
    setWidth("350px");

    VerticalLayout vLay = new VerticalLayout();
    setContent(vLay);
    FormLayout fLay = new FormLayout();
    oldPw = new PasswordField("Current");
    //oldPw.setColumns(20);
    oldPw.setWidth("99%");
    fLay.addComponent(oldPw);
    newPw = new PasswordField("New");
    newPw.setWidth("99%");
    fLay.addComponent(newPw);
    newPw2 = new PasswordField("New again");
    newPw2.setWidth("99%");
    fLay.addComponent(newPw2);

    vLay.addComponent(fLay);

    HorizontalLayout buttLay = new HorizontalLayout();
    buttLay.setSpacing(true);
    vLay.addComponent(buttLay);
    vLay.setComponentAlignment(buttLay, Alignment.TOP_RIGHT);

    MediaLocator mLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    NativeButton cancelButt = new NativeButton();
    mLoc.decorateCancelButton(cancelButt);
    buttLay.addComponent(cancelButt);
    buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT);

    //    Label sp;
    //    buttLay.addComponent(sp = new Label());
    //    sp.setWidth("30px");

    saveButt = new NativeButton();
    //app.globs().mediaLocator().decorateSaveButton(saveButt);  //"save"
    mLoc.decorateOkButton(saveButt); //"ok"
    buttLay.addComponent(saveButt);
    buttLay.setComponentAlignment(saveButt, Alignment.BOTTOM_RIGHT);

    //    buttLay.addComponent(sp = new Label());
    //    sp.setWidth("5px");

    cancelButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(ChangePasswordDialog.this);
        }
    });
    saveButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String oldTry = oldPw.getValue().toString();
            StrongPasswordEncryptor spe = new StrongPasswordEncryptor();
            if (!spe.checkPassword(oldTry, packet.original)) {
                Notification.show("Error", "Existing password incorrect", Notification.Type.ERROR_MESSAGE);
                return;
            }

            String newStr = newPw.getValue().toString();
            if (newStr == null || newStr.length() < 6) {
                Notification.show("Error", "Enter a password of at least six characters",
                        Notification.Type.ERROR_MESSAGE);
                return;
            }
            String check = newPw2.getValue().toString();
            if (check == null || !newStr.trim().equals(check.trim())) {
                Notification.show("Error", "Passwords do not match", Notification.Type.ERROR_MESSAGE);
                return;
            }

            packet.updated = newStr.trim();
            if (saveListener != null)
                saveListener.buttonClick(event);
            UI.getCurrent().removeWindow(ChangePasswordDialog.this);
        }
    });
}

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;
    }/* w  w  w.j a va2 s  .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.utility.HistoryDialog.java

License:Open Source License

public HistoryDialog(SortedSet<Edits> set, String windowTitle, String tableTitle, String columnTitle,
        DoneListener dLis) {/*from w  w  w. ja va  2s .  co  m*/
    this.set = set;
    this.doneListener = dLis;

    setCaption(windowTitle);
    setModal(true);
    setWidth("500px");
    setHeight("400px");

    VerticalLayout vLay = new VerticalLayout();
    setContent(vLay);
    vLay.setSizeFull();
    table = new Table(tableTitle);
    table.setSelectable(true);
    table.setContainerDataSource(makeContainer());
    table.addValueChangeListener(new TableListener());
    table.setVisibleColumns(new Object[] { "label", "string" });
    table.setColumnHeaders(new String[] { "", columnTitle });
    table.setImmediate(true);

    table.setSizeFull();
    table.setItemDescriptionGenerator(new ItemDescriptionGenerator() {
        private static final long serialVersionUID = 1L;

        public String generateDescription(Component source, Object itemId, Object propertyId) {
            return ((StringBean) itemId).string;
        }
    });

    vLay.addComponent(table);
    vLay.setExpandRatio(table, 1.0f);
    MediaLocator mLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    HorizontalLayout buttLay = new HorizontalLayout();
    vLay.addComponent(buttLay);
    vLay.setComponentAlignment(buttLay, Alignment.TOP_RIGHT);
    cancelButt = new NativeButton();
    mLoc.decorateCancelButton(cancelButt);
    buttLay.addComponent(cancelButt);
    buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT);

    okButt = new NativeButton();
    mLoc.decorateOkButton(okButt);
    buttLay.addComponent(okButt);
    buttLay.setComponentAlignment(okButt, Alignment.BOTTOM_RIGHT);
    okButt.setEnabled(false);

    cancelButt.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            HSess.init();
            UI.getCurrent().removeWindow(HistoryDialog.this);
            if (doneListener != null)
                doneListener.doneTL(null, -1);
            HSess.close();
        }
    });
    okButt.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            HSess.init();
            UI.getCurrent().removeWindow(HistoryDialog.this);
            StringBean obj = (StringBean) table.getValue();
            if (doneListener != null) {
                if (obj != null) {
                    int idx = obj.getOrder();
                    doneListener.doneTL(obj.getString(), idx);
                } else
                    doneListener.doneTL(null, -1);
            }
            HSess.close();
        }
    });
}

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) {/* ww w . j a  va  2 s . 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) {//from  ww  w . j  av  a2  s  .c om
    // 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("&nbsp;&nbsp;" + 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("&nbsp;&nbsp;&nbsp;" + 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:edu.nps.moves.security.PasswordResetUI.java

License:Open Source License

private void handleChangeTL(User user) {
    this.user = user;
    Game g = Game.getTL();//from w  ww.  j  a v  a2  s . com

    String brand = g.getCurrentMove().getTitle();
    Page.getCurrent().setTitle("Password reset for " + brand + " mmowgli");

    HorizontalLayout hLay = new HorizontalLayout();
    hLay.setMargin(true);
    hLay.setWidth("100%");
    setContent(hLay);

    GameLinks gl = GameLinks.getTL();
    String blog = gl.getBlogLink();
    Label lab;
    hLay.addComponent(lab = new Label());
    hLay.setExpandRatio(lab, 0.5f);

    VerticalLayout vl = new VerticalLayout();
    hLay.addComponent(vl);
    vl.setWidth(bannerWidthPx);

    hLay.addComponent(lab = new Label());
    hLay.setExpandRatio(lab, 0.5f);

    vl.addStyleName("m-greyborder");
    vl.setMargin(true);
    vl.setSpacing(true);

    vl.addComponent(lab = new HtmlLabel(""));
    lab.addStyleName("m-font-21-bold");
    lab.setSizeUndefined();
    vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);
    StringBuilder sb = new StringBuilder();
    sb.append(thanksHdr1);
    sb.append(blog);
    sb.append(thanksHdr2);
    sb.append(brand);
    sb.append(thanksHdr3);
    lab.setValue(sb.toString());

    vl.addComponent(lab = new HtmlLabel(""));
    lab.setHeight("15px");
    vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    FormLayout fLay = new FormLayout();
    fLay.setSizeUndefined();
    fLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield)
    vl.addComponent(fLay);
    vl.setComponentAlignment(fLay, Alignment.MIDDLE_CENTER);

    newPw = new PasswordField("New Password");
    newPw.setWidth("99%");
    fLay.addComponent(newPw);

    newPw2 = new PasswordField("Again, please");
    newPw2.setWidth("99%");
    fLay.addComponent(newPw2);

    HorizontalLayout buttLay = new HorizontalLayout();
    buttLay.setSpacing(true);
    vl.addComponent(buttLay);
    vl.setComponentAlignment(buttLay, Alignment.TOP_CENTER);

    NativeButton cancelButt = new NativeButton();
    cancelButt.setStyleName("m-cancelButton");
    buttLay.addComponent(cancelButt);
    buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT);

    saveButt = new NativeButton();
    saveButt.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    saveButt.setStyleName("m-continueButton"); //m-saveChangesButton");
    buttLay.addComponent(saveButt);
    buttLay.setComponentAlignment(saveButt, Alignment.BOTTOM_RIGHT);

    cancelButt.addClickListener(this);
    saveButt.addClickListener(this);
}

From source file:edu.vcu.csbc.vahmpexplorer.main.VaHMPExplorer.java

public Component createToolBar(boolean loggedIn) {
    HorizontalLayout h = new HorizontalLayout();
    h.setMargin(true);/*from   ww  w .  j a  v  a2 s.  c o m*/
    h.setWidth("100%");

    Embedded headerImg = new Embedded(null, new ThemeResource("../vahmpexplorer/img/header.png"));
    headerImg.setWidth(311, Embedded.UNITS_PIXELS);
    headerImg.setHeight(45, Embedded.UNITS_PIXELS);
    headerImg.setType(Embedded.TYPE_IMAGE);
    headerImg.setStyleName(BaseTheme.BUTTON_LINK);
    headerImg.setDescription("Version " + HelpMessages.VERSION);
    h.addComponent(headerImg);

    if (loggedIn) {
        Panel panel = new Panel();
        Label loggedInUser = new Label(
                "Welcome: " + user.getFirstName() + " " + user.getLastName() + " (" + user.getLogin() + ")");
        changePassword = new Button("Change Password");
        changePassword.setStyleName(BaseTheme.BUTTON_LINK);
        changePassword.addListener((Button.ClickListener) this);

        logout = new Button("Logout");
        logout.setStyleName(BaseTheme.BUTTON_LINK);
        logout.addListener((Button.ClickListener) this);

        HorizontalLayout hl = new HorizontalLayout();
        hl.setSpacing(true);
        hl.addComponent(changePassword);
        hl.addComponent(logout);

        panel.addComponent(loggedInUser);
        panel.addComponent(hl);
        h.addComponent(panel);
        h.setComponentAlignment(panel, Alignment.MIDDLE_RIGHT);
    }
    PopupView help = new PopupView(new MainHelpPopup());
    h.addComponent(help);
    h.setComponentAlignment(help, Alignment.MIDDLE_RIGHT);
    h.setComponentAlignment(headerImg, Alignment.MIDDLE_LEFT);
    return h;
}

From source file:eu.eco2clouds.portal.component.apwizard.APText.java

License:Apache License

private void render() {
    this.removeAllComponents();
    this.setMargin(true);
    this.setSpacing(true);
    this.setSizeFull();
    this.setWidth("400px");

    textArea.setSizeFull();/*w w w  .  j  a v  a 2s. com*/
    textArea.setImmediate(true);

    ApplicationProfileParserManager apm = new ApplicationProfileParserManager();
    try {
        //textArea.setValue(apm.deserialize(((E2CPortal) UI.getCurrent()).getSessionStatus().getApplicationProfile()));
        textArea.setValue(Parser.getJSONApplicationProfile(
                ((E2CPortal) UI.getCurrent()).getSessionStatus().getApplicationProfile()));
    } catch (JsonMappingException ex) {
        Logger.getLogger(APText.class.getName()).log(Level.SEVERE, null, ex);
        textArea.setValue("error in creating the application profile");
    } catch (IOException ex) {
        Logger.getLogger(APText.class.getName()).log(Level.SEVERE, null, ex);
        textArea.setValue("error in creating the application profile");
    }
    this.addComponent(textArea);

    HorizontalLayout btnLayout = new HorizontalLayout();
    btnLayout.setSpacing(true);
    btnLayout.setMargin(true);

    Button btnRefresh = new Button("Refresh");
    btnRefresh.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            update();
        }
    });

    btnLayout.addComponent(btnRefresh);

    Button btnSubmit = new Button("Submit");
    btnSubmit.addClickListener(this);

    btnLayout.addComponent(btnSubmit);

    btnLayout.setComponentAlignment(btnSubmit, Alignment.BOTTOM_RIGHT);
    btnLayout.setComponentAlignment(btnRefresh, Alignment.BOTTOM_RIGHT);

    this.addComponent(btnLayout);

    this.setExpandRatio(textArea, 1.0f);
}