Example usage for com.vaadin.ui Alignment TOP_RIGHT

List of usage examples for com.vaadin.ui Alignment TOP_RIGHT

Introduction

In this page you can find the example usage for com.vaadin.ui Alignment TOP_RIGHT.

Prototype

Alignment TOP_RIGHT

To view the source code for com.vaadin.ui Alignment TOP_RIGHT.

Click Source Link

Usage

From source file:edu.nps.moves.mmowgli.hibernate.SearchPopup.java

License:Open Source License

@SuppressWarnings("serial")
public SearchPopup(String startingText) {
    super("Search for Players, Action Plans, Idea Cards");
    //setModal(true);   better not to be model

    this.initialText = startingText;
    setWidth("635px");
    setHeight("600px");
    center();//from w  ww.java  2  s . com

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

    WordCloudPanel wcPan = new WordCloudPanel(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            WordButton wb = (WordButton) event.getButton();
            tf.setValue(wb.word.text);
            searchButt.fireClick();
        }
    });
    wcPan.setImmediate(true);

    TermInfo[] tinfo = SearchManager.getHighFrequencyTerms();
    List<Word> wdLis = new ArrayList<Word>(tinfo.length);

    for (TermInfo inf : tinfo) {
        String txt = inf.term.text();
        Word wd = new Word(txt, inf.docFreq);
        wdLis.add(wd);
    }

    // V7
    /*
    TermStats[] tstats = SearchManager.getHighFrequencyTerms();
    List<Word> wdLis = new ArrayList<Word>(tstats.length);
    for(TermStats ts : tstats) {
      String txt = new String(ts.termtext.utf8ToString());
      Word wd = new Word(txt,ts.docFreq);
      wdLis.add(wd);
    }
    */

    wdLis = finalFilter(wdLis);
    // dumpList(wLis);
    wcPan.setWordData(wdLis, WordOrder.ALPHA);
    wcPan.setWidth("590px"); // won't work in ie"100%");
    vLay.addComponent(wcPan);

    HorizontalLayout topHL = new HorizontalLayout();
    vLay.addComponent(topHL);
    topHL.setWidth("100%");
    topHL.setMargin(true);
    topHL.setSpacing(true);

    topHL.addComponent(tf = new TextField());
    tf.addValueChangeListener(new TextFieldChangeListener());
    tf.setWidth("100%");
    //tf.setInputPrompt("Enter search terms");
    tf.setImmediate(true);
    tf.setTextChangeTimeout(5000);
    topHL.setExpandRatio(tf, 1.0f);
    if (startingText != null)
        tf.setValue(startingText);

    searchButt = new FireableButton("Search", this);
    topHL.addComponent(searchButt);
    searchButt.setClickShortcut(KeyCode.ENTER);

    vLay.addComponent(statusLabel = new HtmlLabel("&nbsp;"));
    statusLabel.setImmediate(true);

    resultsTable = new Table();
    resultsTable.addStyleName("m-actiondashboard-table");
    resultsTable.setImmediate(true);
    vLay.addComponent(resultsTable);
    resultsTable.setHeight("100%");
    resultsTable.setWidth("99%");
    vLay.setExpandRatio(resultsTable, 1.0f);

    BeanItemContainer<SearchResult> bCont = new BeanItemContainer<SearchResult>(SearchResult.class);
    bCont.addBean(new SearchResult("", "", "")); // fix for 6.7.0 bug
    resultsTable.addGeneratedColumn("text", new ToolTipAdder());
    resetTable(bCont);

    resultsTable.setNewItemsAllowed(false);
    resultsTable.setSelectable(true);

    resultsTable.addItemClickListener(new ItemClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void itemClick(ItemClickEvent event) {
            HSess.init();
            @SuppressWarnings("unchecked")
            BeanItem<SearchResult> bi = (BeanItem<SearchResult>) event.getItem();
            SearchResult sr = bi.getBean();
            MmowgliController controller = Mmowgli2UI.getGlobals().getController();
            if (sr.getType().equals(USERTYPEKEY))
                controller.miscEventTL(new AppEvent(SHOWUSERPROFILECLICK, SearchPopup.this, sr.getHibId()));
            else if (sr.getType().equals(ACTIONPLANTYPEKEY))
                controller.miscEventTL(new AppEvent(ACTIONPLANSHOWCLICK, SearchPopup.this, sr.getHibId()));
            else
                controller.miscEventTL(new AppEvent(CARDCLICK, SearchPopup.this, sr.getHibId()));
            HSess.close();

            closeListener.buttonClick(null);
        }
    });

    vLay.addComponent(closeButt = new Button("Close"));
    vLay.setComponentAlignment(closeButt, Alignment.TOP_RIGHT);
    closeButt.addClickListener(closeListener = new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (searchThread != null)
                searcherObj.killed = true;
            //V7 SearchPopup.this.getParent().removeWindow(SearchPopup.this);
            SearchPopup.this.close();
        }
    });
}

From source file:edu.nps.moves.mmowgli.MmowgliMessageBroadcaster.java

License:Open Source License

private static void _postGameEvent(String title, final GameEvent.EventType typ, String buttName,
        boolean doWarning) {
    // Create the window...
    final Window bcastWindow = new Window(title);
    bcastWindow.setModal(true);// www  . j  a v  a2  s .  c  om

    VerticalLayout layout = new VerticalLayout();
    bcastWindow.setContent(layout);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("99%");

    layout.addComponent(new Label("Compose message (255 char limit):"));
    final TextArea ta = new TextArea();
    ta.setRows(5);
    ta.setWidth("99%");
    layout.addComponent(ta);

    HorizontalLayout buttHl = new HorizontalLayout();
    final Button bcancelButt = new Button("Cancel");
    buttHl.addComponent(bcancelButt);
    Button bokButt = new Button(buttName);
    buttHl.addComponent(bokButt);
    layout.addComponent(buttHl);
    layout.setComponentAlignment(buttHl, Alignment.TOP_RIGHT);

    if (doWarning)
        layout.addComponent(new Label("Use with great deliberation!"));

    bcastWindow.setWidth("320px");
    UI.getCurrent().addWindow(bcastWindow);
    bcastWindow.setPositionX(0);
    bcastWindow.setPositionY(0);

    ta.focus();

    @SuppressWarnings("serial")
    ClickListener lis = new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        @HibernateUserRead
        public void buttonClick(ClickEvent event) {
            if (event.getButton() == bcancelButt)
                ; // nothin
            else {
                // This check is now done in GameEvent.java, but should ideally prompt the user.
                HSess.init();
                String msg = ta.getValue().toString().trim();
                if (msg.length() > 0) {
                    if (msg.length() > 255) // clamp to 255 to avoid db exception
                        msg = msg.substring(0, 254);
                    Serializable uid = Mmowgli2UI.getGlobals().getUserID();
                    User u = User.getTL(uid);
                    if (typ == GameEvent.EventType.GAMEMASTERNOTE)
                        GameEventLogger.logGameMasterCommentTL(msg, u);
                    else
                        GameEventLogger.logGameMasterBroadcastTL(typ, msg, u); // GameEvent.save(new GameEvent(typ,msg));
                    HSess.close();
                }
            }
            bcastWindow.close();
        }
    };
    bcancelButt.addClickListener(lis);
    bokButt.addClickListener(lis);
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPage2.java

License:Open Source License

@SuppressWarnings("serial")
public void initGuiTL() {
    ActionPlan actPln = ActionPlan.getTL(apId);
    User me = Mmowgli2UI.getGlobals().getUserTL();
    addStyleName("m-cssleft-45");

    setWidth("1089px");
    setHeight("1821px");
    Label sp;/* w ww .  j a  v a2 s .  c  o  m*/

    VerticalLayout mainVL = new VerticalLayout();
    addComponent(mainVL, "top:0px;left:0px");
    mainVL.addStyleName("m-overflow-visible");
    mainVL.setWidth("1089px");
    mainVL.setHeight(null);
    mainVL.setSpacing(false);
    mainVL.setMargin(false);

    VerticalLayout mainVLayout = new VerticalLayout();

    mainVLayout.setSpacing(false);
    mainVLayout.setMargin(false);
    mainVLayout.addStyleName("m-actionplan-background2");
    mainVLayout.setWidth("1089px");
    mainVLayout.setHeight(null); //"1821px");
    mainVL.addComponent(mainVLayout);

    mainVLayout.addComponent(makeIdField(actPln));

    mainVLayout.addComponent(sp = new Label());
    sp.setHeight("5px");

    VerticalLayout leftTopVL = new VerticalLayout();
    leftTopVL.setWidth("820px");
    leftTopVL.setSpacing(false);
    leftTopVL.setMargin(false);
    mainVLayout.addComponent(leftTopVL);

    HorizontalLayout titleAndThumbsHL = new HorizontalLayout();
    titleAndThumbsHL.setSpacing(false);
    titleAndThumbsHL.setMargin(false);
    titleAndThumbsHL.setHeight("115px");
    titleAndThumbsHL.addStyleName("m-actionplan-header-container");
    leftTopVL.addComponent(titleAndThumbsHL);

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

    VerticalLayout vl = new VerticalLayout();
    vl.addComponent(titleUnion); //titleTA);
    titleUnion.initGui();

    titleHistoryButt = new NativeButton();
    titleHistoryButt.setCaption("history");
    titleHistoryButt.setStyleName(BaseTheme.BUTTON_LINK);
    titleHistoryButt.addStyleName("borderless");
    titleHistoryButt.addStyleName("m-actionplan-history-button");
    titleHistoryButt.addClickListener(new TitleHistoryListener());
    titleHistoryButt.setEnabled(!readonly);
    vl.addComponent(titleHistoryButt);
    vl.setComponentAlignment(titleHistoryButt, Alignment.TOP_RIGHT);
    titleAndThumbsHL.addComponent(vl); //titleTA);

    titleUnion.setWidth(ACTIONPLAN_TITLE_W);
    titleUnion.setValueTL(actPln.getTitle() == null ? "" : actPln.getTitle());

    titleUnion.addStyleName("m-lightgrey-border");
    // titleUnion.addStyleName("m-opacity-75");
    titleUnion.setHeight("95px"); // 120 px); must make it this way for alignment of r/o vs rw

    addComponent(saveCanPan, "top:0px;left:395px");
    saveCanPan.setVisible(false);

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

    VerticalLayout thumbVL = new VerticalLayout();
    titleAndThumbsHL.addComponent(thumbVL);
    thumbVL.addComponent(sp = new Label());
    sp.setHeight("50px");

    thumbPanel = new ThumbPanel();
    Map<User, Integer> map = actPln.getUserThumbs();
    Integer t = map.get(me);
    /*  if(t == null) {
        map.put(me, 0);
        ActionPlan.update(actPln);
        GameEventLogger.logActionPlanUpdate(actPln, "thumbs changed",me.getUserName());
        t = 0;
      } */
    thumbPanel.setNumUserThumbs(t == null ? 0 : t);
    thumbVL.addComponent(thumbPanel);

    HorizontalLayout commentAndViewChainHL = new HorizontalLayout();
    leftTopVL.addComponent(commentAndViewChainHL);
    commentAndViewChainHL.setSpacing(false);
    commentAndViewChainHL.setMargin(false);
    commentAndViewChainHL.addComponent(sp = new Label());
    sp.setWidth("55px");

    VerticalLayout commLeftVL = new VerticalLayout();
    commentAndViewChainHL.addComponent(commLeftVL);
    commLeftVL.setWidth("95px");
    commLeftVL.addComponent(commentsButt);
    commentsButt.setStyleName(BaseTheme.BUTTON_LINK);
    commentsButt.addStyleName("borderless");
    commentsButt.addStyleName("m-actionplan-comments-button");

    ClickListener commLis;
    commentsButt.addClickListener(commLis = new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().setScrollTop(1250); //commentsButt.getWindow().setScrollTop(1250);
        }
    });
    commLeftVL.addComponent(sp = new Label());
    sp.setHeight("65px"); //"50px");

    commLeftVL.addComponent(envelopeButt);
    envelopeButt.addStyleName("m-actionplan-envelope-button");
    envelopeButt.addClickListener(commLis); // same as the link button above

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

    VerticalLayout commMidVL = new VerticalLayout();
    commentAndViewChainHL.addComponent(commMidVL);
    commMidVL.setWidth("535px");
    commMidVL.addComponent(addCommentButt);
    addCommentButt.setCaption("Add Comment");
    addCommentButt.setStyleName(BaseTheme.BUTTON_LINK);
    addCommentButt.addStyleName("borderless");
    addCommentButt.addStyleName("m-actionplan-comments-button");
    addCommentButt.setId(ACTIONPLAN_ADD_COMMENT_LINK_BUTTON_TOP);

    addCommentButt.addClickListener(addCommentListener = new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().setScrollTop(1250); //addCommentButt.getWindow().setScrollTop(1250);
            commentPanel.AddCommentClicked(event);
        }
    });

    commMidVL.addComponent(sp = new Label());
    sp.setHeight("5px");

    commMidVL.addComponent(lastCommentLabel = new HtmlLabel());
    lastCommentLabel.setWidth("100%");
    lastCommentLabel.setHeight("94px");
    lastCommentLabel.addStyleName("m-actionplan-textentry");
    lastCommentLabel.addStyleName("m-opacity-75");

    addComponent(viewChainButt, "left:690px;top:140px");
    viewChainButt.setStyleName("m-viewCardChainButton");
    viewChainButt.addClickListener(new ViewCardChainHandler());
    viewChainButt.setId(ACTIONPLAN_VIEW_CARD_CHAIN_BUTTON);
    // This guy sits on the bottom naw, gets covered
    // author list and rfe
    VerticalLayout rightVL = new VerticalLayout();
    this.addComponent(rightVL, "left:830px;top:0px");
    rightVL.setSpacing(false);
    rightVL.setMargin(false);
    rightVL.setWidth(null);

    VerticalLayout listVL = new VerticalLayout();
    listVL.setSpacing(false);
    listVL.addStyleName("m-actionPlanAddAuthorList");
    listVL.addStyleName("m-actionplan-header-container");
    listVL.setHeight(null);
    listVL.setWidth("190px");

    listVL.addComponent(sp = new Label());
    sp.setHeight("35px");
    sp.setDescription("List of current authors and (invited authors)");

    Label subTitle;
    listVL.addComponent(subTitle = new Label("(invited in parentheses)"));
    subTitle.setWidth(null); // keep it from being 100% wide
    subTitle.setDescription("List of current authors and (invited authors)");
    subTitle.addStyleName("m-actionplan-authorlist-sublabel");
    listVL.setComponentAlignment(subTitle, Alignment.MIDDLE_CENTER);

    rightVL.addComponent(listVL);

    TreeSet<User> ts = new TreeSet<User>(new User.AlphabeticalComparator());
    ts.addAll(actPln.getAuthors());
    TreeSet<User> greyTs = new TreeSet<User>(new User.AlphabeticalComparator());
    greyTs.addAll(actPln.getInvitees());
    authorList = new UserList(null, ts, greyTs);

    listVL.addComponent(authorList);
    authorList.addStyleName("m-greyborder");
    listVL.setComponentAlignment(authorList, Alignment.TOP_CENTER);
    authorList.setWidth("150px");
    authorList.setHeight("95px");
    listVL.addComponent(sp = new Label());
    sp.setHeight("5px");
    listVL.addComponent(addAuthButton);
    listVL.setComponentAlignment(addAuthButton, Alignment.TOP_CENTER);
    addAuthButton.setStyleName("m-actionPlanAddAuthorButt");
    addAuthButton.addClickListener(new AddAuthorHandler());
    addAuthButton.setDescription("Invite players to be authors of this action plan");

    rightVL.addComponent(sp = new Label());
    sp.setHeight("5px");
    rightVL.addComponent(rfeButt);
    rightVL.setComponentAlignment(rfeButt, Alignment.TOP_CENTER);
    // done in handleDisabledments() rfeButt.setStyleName("m-rfeButton");

    // end authorList and rfe

    mainVLayout.addComponent(sp = new Label());
    sp.setHeight("5px");
    sp.setWidth("20px");
    // Tabs:
    AbsoluteLayout absL = new AbsoluteLayout();
    mainVLayout.addComponent(absL);
    absL.setHeight("60px");
    absL.setWidth("830px");
    HorizontalLayout tabsHL = new HorizontalLayout();
    tabsHL.setStyleName("m-actionPlanBlackTabs");
    tabsHL.setSpacing(false);

    absL.addComponent(tabsHL, "left:40px;top:0px");

    NewTabClickHandler ntabHndlr = new NewTabClickHandler();

    tabsHL.addComponent(sp = new Label());
    sp.setWidth("19px");
    thePlanTabButt.setStyleName("m-actionPlanThePlanTab");
    thePlanTabButt.addStyleName(ACTIONPLAN_TAB_THEPLAN); // debug
    thePlanTabButt.addClickListener(ntabHndlr);
    tabsHL.addComponent(thePlanTabButt);

    talkTabButt.setStyleName("m-actionPlanTalkItOverTab");
    //talkTabButt.addStyleName(ACTIONPLAN_TAB_TALK);
    talkTabButt.addClickListener(ntabHndlr);
    tabsHL.addComponent(talkTabButt);
    talkTabButt.addStyleName("m-transparent-background"); // initially

    imagesTabButt.setStyleName("m-actionPlanImagesTab");
    imagesTabButt.addStyleName(ACTIONPLAN_TAB_IMAGES);
    imagesTabButt.addClickListener(ntabHndlr);
    tabsHL.addComponent(imagesTabButt);
    imagesTabButt.addStyleName("m-transparent-background"); // initially

    videosTabButt.setStyleName("m-actionPlanVideosTab");
    videosTabButt.addStyleName(ACTIONPLAN_TAB_VIDEO);
    videosTabButt.addClickListener(ntabHndlr);
    tabsHL.addComponent(videosTabButt);
    videosTabButt.addStyleName("m-transparent-background"); // initially

    mapTabButt.setStyleName("m-actionPlanMapTab");
    mapTabButt.addStyleName(ACTIONPLAN_TAB_MAP);
    mapTabButt.addClickListener(ntabHndlr);
    tabsHL.addComponent(mapTabButt);
    mapTabButt.addStyleName("m-transparent-background"); // initially

    newChatLab.setStyleName("m-newChatLabel");
    absL.addComponent(newChatLab, "left:340px;top:15px");
    newChatLab.setVisible(false);

    // stack the pages
    HorizontalLayout hsp = new HorizontalLayout();
    hsp.setHeight("742px"); // allows for differing ghost box heights
    mainVLayout.addComponent(hsp);

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

    hsp.addComponent(thePlanTab);
    thePlanTab.initGui();

    hsp.addComponent(talkTab);
    talkTab.initGui();
    talkTab.setVisible(false);

    hsp.addComponent(imagesTab);
    imagesTab.initGui();
    imagesTab.setVisible(false);

    hsp.addComponent(videosTab);
    videosTab.initGui();
    videosTab.setVisible(false);

    hsp.addComponent(mapTab);
    mapTab.initGui();
    mapTab.setVisible(false);

    mainVLayout.addComponent(sp = new Label());
    sp.setHeight("90px");

    HorizontalLayout buttLay = new HorizontalLayout();
    buttLay.addStyleName("m-marginleft-60");
    mainVLayout.addComponent(buttLay);
    buttLay.setWidth(ActionPlanPageCommentPanel2.COMMENT_PANEL_WIDTH);
    addCommentButtBottom.setCaption("Add Comment");
    addCommentButtBottom.setStyleName(BaseTheme.BUTTON_LINK);
    addCommentButtBottom.addStyleName("borderless");
    addCommentButtBottom.addStyleName("m-actionplan-comments-button");
    addCommentButtBottom.setId(ACTIONPLAN_ADD_COMMENT_LINK_BUTTON_BOTTOM);
    addCommentButtBottom.addClickListener(addCommentListener);
    buttLay.addComponent(addCommentButtBottom);

    if (me.isAdministrator() || me.isGameMaster()) {

        buttLay.addComponent(sp = new Label());
        sp.setWidth("1px"); // "810px");
        buttLay.setExpandRatio(sp, 1.0f);
        ToggleLinkButton tlb = new ToggleLinkButton("View all", "View unhidden only",
                "m-actionplan-comment-text");
        tlb.setToolTips("Temporarily show all messages, including those marked \"hidden\" (gm)",
                "Temporarily hide messages marked \"hidden\" (gm)");
        tlb.addStyleName("m-actionplan-comments-button");
        tlb.addOnListener(new ViewAllListener());
        tlb.addOffListener(new ViewUnhiddenOnlyListener());
        buttLay.addComponent(tlb);
        buttLay.addComponent(sp = new Label());
        sp.setWidth("5px");
    }
    // And the comments
    hsp = new HorizontalLayout();
    mainVLayout.addComponent(hsp);
    mainVLayout.addComponent(sp = new Label());
    sp.setHeight("5px");
    hsp.addComponent(sp = new Label());
    sp.setWidth("56px");

    hsp.addComponent(commentPanel);
    commentPanel.initGui();

    // Set thumbs
    double thumbs = actPln.getAverageThumb();
    long round = Math.round(thumbs);
    int numApThumbs = (int) (Math.min(round, 3));
    thumbPanel.setNumApThumbs(numApThumbs);

    Integer myRating = actPln.getUserThumbs().get(me);
    if (myRating == null)
        myRating = 0;
    thumbPanel.setNumUserThumbs(myRating);

    helpWantedListener = new HelpWantedListener();
    interestedListener = new InterestedListener();

    handleDisablementsTL();
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.AddVideoDialog.java

License:Open Source License

@SuppressWarnings("serial")
public AddVideoDialog() {
    super("Add a Video");
    addStyleName("m-greybackground");

    setClosable(false); // no x in corner
    setWidth("530px");
    setHeight("400px");

    VerticalLayout mainVL = new VerticalLayout();
    mainVL.setSpacing(true);// w ww  .  j av a 2 s  .c om
    mainVL.setMargin(true);
    mainVL.setSizeUndefined(); // auto size
    mainVL.setWidth("100%");
    setContent(mainVL);

    Label helpLab = new HtmlLabel("Add YouTube videos to your Action Plan this way:"
            + "<OL><LI>Find the video you want at <a href=\"https://www.youtube.com\" target=\""
            + PORTALTARGETWINDOWNAME + "\">www.youtube.com</a>.</LI>"
            + "<LI>Click the \"share\" button below the video screen.</LI>"
            + "<LI>Copy the URL under \"Link to this video:\"</LI>"
            + "<LI>Paste the URL into the field below.</LI>" + "</OL>" + "If you have media that "
            + "has not been uploaded to YouTube, see <a href=\"https://www.youtube.com\" target=\""
            + PORTALTARGETWINDOWNAME + "\">www.youtube.com</a> "
            + "for help with establishing a free account.<br/>");
    helpLab.setWidth("100%");
    mainVL.addComponent(helpLab);

    HorizontalLayout mainHL = new HorizontalLayout();
    mainHL.setMargin(false);
    mainHL.setSpacing(true);
    mainVL.addComponent(mainHL);

    holder = new AbsoluteLayout();
    mainHL.addComponent(holder);
    holder.addStyleName("m-darkgreyborder");
    holder.setWidth("150px");
    holder.setHeight("150px");
    holder.addComponent(new Label("Test video display"), "top:0px;left:0px;");
    VerticalLayout rightVL = new VerticalLayout();
    mainHL.addComponent(rightVL);
    rightVL.setMargin(false);
    rightVL.setSpacing(true);
    rightVL.addComponent(new Label("YouTube video address"));

    HorizontalLayout tfHL = new HorizontalLayout();
    tfHL.setSpacing(true);
    rightVL.addComponent(tfHL);
    addrTf = new TextField();
    tfHL.addComponent(addrTf);
    addrTf.setColumns(21);
    tfHL.addComponent(testButt = new Button("Test"));

    rightVL.addComponent(new Label("Using the test button will set the"));
    rightVL.addComponent(new Label("default title and description."));

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

    HorizontalLayout bottomHL = new HorizontalLayout();
    rightVL.addComponent(bottomHL);
    rightVL.setComponentAlignment(bottomHL, Alignment.TOP_RIGHT);
    bottomHL.setSpacing(true);
    bottomHL.setWidth("100%");
    Label spacer;
    bottomHL.addComponent(spacer = new Label());
    spacer.setWidth("100%");
    bottomHL.setExpandRatio(spacer, 1.0f);

    bottomHL.addComponent(cancelButt = new Button("Cancel"));
    bottomHL.addComponent(submitButt = new Button("Add"));
    testButt.addClickListener(new TestVidHandler());

    submitButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(AddVideoDialog.this);
            if (closer != null)
                closer.windowClose(null);
        }
    });

    cancelButt.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            media = null;
            UI.getCurrent().removeWindow(AddVideoDialog.this);
            if (closer != null)
                closer.windowClose(null);
        }
    });
}

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

License:Open Source License

@Override
public void initGui() {
    setWidth("950px");
    addStyleName("m-greyborder");
    addStyleName("m-background-lightgrey");
    addStyleName("m-marginleft-25");
    setMargin(true);/*from www.j  a  v  a 2 s. c  o  m*/
    setSpacing(false);

    buildTopInfo(this);

    pan = new Panel();
    addComponent(pan);
    pan.setWidth("99%");
    pan.setHeight(PANEL_HEIGHT);
    vLay = new VerticalLayout();
    vLay.setMargin(true);
    pan.setContent(vLay);

    setComponentAlignment(pan, Alignment.TOP_CENTER);
    pan.addStyleName("m-greyborder");

    NativeButton moreButt = new NativeButton("Get another page of prior events", this);
    addComponent(moreButt);
    setComponentAlignment(moreButt, Alignment.TOP_RIGHT);

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

    addComponent(new Label("Broadcast message to game masters"));

    messageTA = new TextArea();
    messageTA.setRows(2);
    messageTA.setWidth("100%");

    addComponent(messageTA);

    NativeButton sendButt = new NativeButton("Send", new SendListener());
    addComponent(sendButt);

    loadEvents();
}

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

License:Open Source License

@Override
public void attach() {
    Panel p = new Panel();
    setContent(p);//from   ww w  .  j  av  a2 s  . com
    p.setSizeFull();

    VerticalLayout layout = new VerticalLayout();
    layout.addStyleName("m-blogheadline");
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();
    p.setContent(layout);

    layout.addComponent(infoLab = new Label(
            "Game masters can communicate with players throughout the game.  Add a new headling, tooltip and link here."));

    layout.addComponent(textLab = new Label("Enter headline:"));
    textTF = new TextField();
    textTF.setInputPrompt("Enter new headline or choose from previous ones below");
    textTF.setWidth("100%");
    textTF.addStyleName("m-blogtextfield");
    layout.addComponent(textTF);

    layout.addComponent(toolTipLab = new Label("Enter headline tooltip:"));
    toolTipTF = new TextField();
    toolTipTF.setWidth("100%");
    layout.addComponent(toolTipTF);

    layout.addComponent(urlLab = new Label("Enter blog entry url:"));
    urlTF = new TextField();
    urlTF.setWidth("100%");
    layout.addComponent(urlTF);

    table = new Table("Previous headlines");
    table.setSizeFull();
    table.setImmediate(true);
    table.setColumnExpandRatio("date", 1);
    table.setColumnExpandRatio("text", 1);
    table.setColumnExpandRatio("tooltip", 1);
    table.setColumnExpandRatio("url", 1);
    table.setSelectable(true);
    table.setMultiSelect(true); // return whole pojo
    table.addItemClickListener(this);
    table.setContainerDataSource(MessageUrl.getContainer());
    layout.addComponent(table);

    layout.addComponent(nullCheckBox);
    nullCheckBox.addValueChangeListener(new CBListener());
    HorizontalLayout buttHl = new HorizontalLayout();
    buttHl.setSpacing(true);
    buttHl.addComponent(cancelButt);
    buttHl.addComponent(okButt);
    layout.addComponent(buttHl);
    layout.setComponentAlignment(buttHl, Alignment.TOP_RIGHT);
    layout.setExpandRatio(table, 1.0f); // gets all
    setWidth("675px");
    setHeight("455px");
}

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);// ww  w.j  a v  a  2  s  .  co 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);// w ww . j  a v  a2s . 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;
    }/*from   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) {//  w ww . jav  a 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();
        }
    });
}