Example usage for com.vaadin.ui HorizontalLayout setExpandRatio

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

Introduction

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

Prototype

public void setExpandRatio(Component component, float ratio) 

Source Link

Document

This method is used to control how excess space in layout is distributed among components.

Usage

From source file:edu.nps.moves.mmowgli.export.BaseExporter.java

License:Open Source License

protected void getMetaStringOrCancel(final MetaListener lis, String title, final Map<String, String> params) {
    final Window dialog = new Window(title);
    final TextField[] parameterFields;

    dialog.setModal(true);//from w w  w.j a va2  s.  com

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

    final TextArea ta = new TextArea();
    ta.setWidth("100%");
    ta.setInputPrompt("Type a description of this data, or the game which generated this data (optional)");

    ta.setImmediate(true);
    layout.addComponent(ta);

    Set<String> keySet = params.keySet();
    parameterFields = new TextField[keySet.size()];
    int i = 0;
    GridLayout pGL = new GridLayout();
    pGL.addStyleName("m-greyborder");
    pGL.setColumns(2);
    Label hdr = new HtmlLabel("<b>Parameters</b>");
    hdr.addStyleName("m-textaligncenter");
    pGL.addComponent(hdr, 0, 0, 1, 0); // top row
    pGL.setComponentAlignment(hdr, Alignment.MIDDLE_CENTER);
    pGL.setSpacing(false);
    for (String key : keySet) {
        pGL.addComponent(new HtmlLabel("&nbsp;" + key + "&nbsp;&nbsp;"));
        pGL.addComponent(parameterFields[i] = new TextField());
        parameterFields[i++].setValue(params.get(key));
    }
    if (i > 0) {
        layout.addComponent(pGL);
        layout.setComponentAlignment(pGL, Alignment.TOP_CENTER);
    }

    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 exportButt = new Button("Export", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            dialog.close();

            Set<String> keySet = params.keySet();
            int i = 0;
            for (String key : keySet)
                params.put(key, parameterFields[i++].getValue().toString());

            lis.continueOrCancel(ta.getValue().toString());
        }
    });
    hl.addComponent(cancelButt);
    hl.addComponent(exportButt);
    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("385px");
    dialog.setHeight("310px");
    hl.setWidth("100%");
    ta.setWidth("100%");
    ta.setHeight("100%");
    layout.setExpandRatio(ta, 1.0f);

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

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();/*w  w  w. j av a 2s . c om*/

    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.MmowgliOuterFrame.java

License:Open Source License

public void addMenuBarAndFouoRowTL(User me) {
    HorizontalLayout hlay = new MHorizontalLayout().withMargin(false).withSpacing(false).withFullHeight();
    addComponent(hlay);/*from w  w  w.j  a v  a  2  s.c  o  m*/

    if (me.isGameMaster() || me.isAdministrator() || me.isDesigner()) {
        menubar = new AppMenuBar(me.isGameMaster(), me.isAdministrator(), me.isDesigner());
        hlay.addComponent(menubar);
        hlay.setExpandRatio(menubar, 0.5f);
        hlay.setComponentAlignment(menubar, Alignment.TOP_LEFT);
    } else {
        Label lab = new Label();
        hlay.addComponent(lab);
        hlay.setExpandRatio(lab, 0.5f);
    }
    hlay.addComponent(fouoButton = makeFouoButtonTL());

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

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

License:Open Source License

public void initGuiTL() {
    setSizeUndefined();/* ww  w. j a  v a 2  s .c  o m*/
    setWidth(APPLICATION_SCREEN_WIDTH);
    //    setHeight("855px"); //ACTIONDASHBOARD_H);

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

    HorizontalLayout titleHL = new HorizontalLayout();
    titleHL.setWidth("95%");
    addComponent(titleHL);

    titleHL.addComponent(sp = new Label());
    sp.setWidth("20px");
    Component titleC;
    titleHL.addComponent(titleC = Mmowgli2UI.getGlobals().getMediaLocator().getActionDashboardTitle());
    titleHL.setComponentAlignment(titleC, Alignment.MIDDLE_LEFT);

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

    titleHL.addComponent(howToWinActionButt);
    howToWinActionButt.setDescription(howWinAction_tt);

    AbsoluteLayout absL = new AbsoluteLayout();
    addComponent(absL);

    absL.setWidth(APPLICATION_SCREEN_WIDTH);
    absL.setHeight(ACTIONDASHBOARD_H);

    MediaLocator medLoc = Mmowgli2UI.getGlobals().getMediaLocator();

    AbsoluteLayout mainAbsLay = new AbsoluteLayout(); // offset it from master
    mainAbsLay.setWidth(APPLICATION_SCREEN_WIDTH);
    mainAbsLay.setHeight(ACTIONDASHBOARD_H);
    absL.addComponent(mainAbsLay, ACTIONDASHBOARD_OFFSET_POS);

    // Now the background     
    Embedded backgroundImage = new Embedded(null, medLoc.getActionDashboardPlanBackground());
    backgroundImage.setWidth(ACTIONDASHBOARD_W);
    backgroundImage.setHeight(ACTIONDASHBOARD_H);
    mainAbsLay.addComponent(backgroundImage, "top:0px;left:0px");

    HorizontalLayout tabsHL = new HorizontalLayout();
    tabsHL.setStyleName("m-actionDashboardBlackTabs");
    tabsHL.setSpacing(false);

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

    TabClickHandler tabHndlr = new TabClickHandler();
    actionPlansTabButt.setStyleName("m-actionDashboardActionPlansTab");
    actionPlansTabButt.addClickListener(tabHndlr);
    actionPlansTabButt.setId(ACTION_DASHBOARD_ACTION_PLANS_TAB);
    tabsHL.addComponent(actionPlansTabButt);

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

    myPlansTabButt.setStyleName("m-actionDashboardMyPlansTab");
    myPlansTabButt.addClickListener(tabHndlr);
    myPlansTabButt.setId(ACTION_DASHBOARD_MY_ACTION_PLANS_TAB);
    tabsHL.addComponent(myPlansTabButt);
    myPlansTabButt.addStyleName("m-transparent-background"); // initially

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

    needAuthorsTabButt.setStyleName("m-actionDashboardNeedAuthorsTab");
    needAuthorsTabButt.addClickListener(tabHndlr);
    needAuthorsTabButt.setId(ACTION_DASHBOARD_NEED_AUTHORS_TAB);
    tabsHL.addComponent(needAuthorsTabButt);
    needAuthorsTabButt.addStyleName("m-transparent-background"); // initially

    absL.addComponent(tabsHL, "left:7px;top:8px");

    // stack the pages
    absL.addComponent(actionPlansTab, ACTIONDASHBOARD_TABCONTENT_POS);
    actionPlansTab.initGuiTL();

    absL.addComponent(myPlansTab, ACTIONDASHBOARD_TABCONTENT_POS);
    myPlansTab.initGuiTL();
    myPlansTab.setVisible(false);

    absL.addComponent(needAuthorsTab, ACTIONDASHBOARD_TABCONTENT_POS);
    needAuthorsTab.initGuiTL();
    needAuthorsTab.setVisible(false);

    User me = Mmowgli2UI.getGlobals().getUserTL();
    Set<ActionPlan> invitedSet = me.getActionPlansInvited();
    if (invitedSet != null && (invitedSet.size()) > 0) {
        Notification note = new Notification("<center>You're invited to an Action Plan!</center>",
                "<center> Look for the \"you're invited to join!\" notice.<br/>"
                        + "First, check out the plan.  Then, if you want to join,<br/>"
                        + "click the link to become an author." + "</center>",
                Type.HUMANIZED_MESSAGE, true); // allow html

        note.setPosition(Position.MIDDLE_CENTER);
        note.setDelayMsec(5000);// 5 secs
        note.show(Page.getCurrent());
    }
}

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;/*from w w  w .  ja v  a  2 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.ActionPlanPageTabImages.java

License:Open Source License

private void addOneImage(Media m) {
    MPanelWrapper wrap = new MPanelWrapper();
    wrap.setMargin(false);//from   w  w w  .j a va 2  s . co m
    wrap.setSpacing(false);
    wrap.ip = new MediaPanel(m, apId, 0, replaceLis);
    wrap.addComponent(wrap.ip);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth(MediaPanel.WIDTH);
    Label lab;
    hl.addComponent(lab = new Label());
    lab.setWidth("3px");
    hl.addComponent(lab = new Label(getDisplayedName(m)));
    lab.addStyleName("m-font-size-11");
    hl.setExpandRatio(lab, 1.0f);
    hl.addComponent(wrap.killButt = new NativeButton(null));
    hl.addComponent(lab = new Label());
    lab.setWidth("3px");

    wrap.addComponent(hl);
    wrap.killButt.setCaption("delete");
    wrap.killButt.setStyleName(BaseTheme.BUTTON_LINK);
    wrap.killButt.addStyleName("borderless");
    wrap.killButt.addStyleName("m-actionplan-nothumbs-button");
    wrap.killButt.addClickListener(new ImageRemover(m));
    ((AbstractLayout) imageScroller.getContent()).addComponent(wrap);
    wrap.ip.initGui();
}

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

License:Open Source License

@Override
public void initGui() {
    setSizeUndefined();/*  w  w  w . j a  va2  s. c  om*/
    VerticalLayout leftVL = this.getLeftLayout();

    leftVL.setSpacing(true);

    Label missionLab = new Label("Authors, this is your team space.");
    leftVL.addComponent(missionLab);
    leftVL.setComponentAlignment(missionLab, Alignment.TOP_LEFT);
    missionLab.addStyleName("m-actionplan-mission-title-text");

    ActionPlan ap = ActionPlan.getTL(apId);

    Label missionContentLab;
    Game g = Game.getTL();
    if (!isMockup)
        missionContentLab = new HtmlLabel(ap.getTalkItOverInstructions());
    else {
        missionContentLab = new HtmlLabel(g.getDefaultActionPlanTalkText());
    }

    leftVL.addComponent(missionContentLab);
    leftVL.setComponentAlignment(missionContentLab, Alignment.TOP_LEFT);
    leftVL.addStyleName("m-actionplan-mission-content-text");

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

    VerticalLayout rightVL = getRightLayout();
    rightVL.setSpacing(true);

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

    rightVL.addComponent(nonAuthorLabel = new Label("This is a space for plan authors to communicate."));
    nonAuthorLabel.setVisible(false);

    rightVL.addComponent(chatEntryComponent);
    chatEntryComponent.setWidth("100%");

    if (isGameMasterOrAdmin) {
        HorizontalLayout hl = new HorizontalLayout();
        rightVL.addComponent(hl);
        hl.setWidth("100%");

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

        viewAllButt = new ToggleLinkButton("View all", "View unhidden only", "m-actionplan-comment-text");
        viewAllButt.setToolTips("Temporarily show all messages, including those marked \"hidden\" (gm)",
                "Temporarily hide messages marked \"hidden\" (gm)");
        viewAllButt.addStyleName("m-actionplan-comments-button");
        viewAllButt.addOnListener(new ViewAllListener());
        viewAllButt.addOffListener(new ViewUnhiddenOnlyListener());
        hl.addComponent(viewAllButt);

        hl.addComponent(sp = new Label());
        sp.setWidth("8px");
    }
    Component comp = createChatScroller(rightVL);
    comp.setWidth("99%");
    rightVL.setExpandRatio(comp, 1.0f);
    comp.setHeight("99%");
    fillChatScrollerTL();
}

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

License:Open Source License

private Component createChatEntryField() {
    HorizontalLayout hl = new HorizontalLayout();
    chatTextField = new TextArea();
    chatTextField.setRows(3);//from  w ww .j  av a  2 s  .c o  m
    chatTextField.setWordwrap(true);
    chatTextField.setInputPrompt("Type here to chat, RETURN submits");
    chatTextField.setId(ACTIONPLAN_TALK_IT_OVER_TEXT_BOX);
    hl.addComponent(chatTextField);
    chatTextField.setWidth("99%");
    hl.setExpandRatio(chatTextField, 1.0f);
    chatTextField.setReadOnly(isReadOnly);

    chatSubmitButt = new NativeButton();
    chatSubmitButt.setStyleName("m-submitButton");
    hl.addComponent(chatSubmitButt);
    chatSubmitButt.addClickListener(new ChatButtonListener());
    chatSubmitButt.setEnabled(!isReadOnly);
    chatSubmitButt.setId(ACTIONPLAN_TALK_IT_OVER_SUBMIT_BUTTON);
    return hl;
}

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

License:Open Source License

private void addOneVideo(Media m) {
    VMPanelWrapper vl = new VMPanelWrapper();
    vl.setMargin(false);//from   ww w . ja v  a2 s.  c o m
    vl.setSpacing(false);
    vl.ip = new MediaPanel(m, apId, 0, replaceLis);
    vl.addComponent(vl.ip);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth(MediaPanel.WIDTH);
    Label lab;
    hl.addComponent(lab = new Label());
    lab.setWidth("3px");

    if (m.getType() != MediaType.YOUTUBE) {
        hl.addComponent(lab = new Label(getDisplayedName(m))); // label
        lab.addStyleName("m-font-size-11");
        hl.setExpandRatio(lab, 1.0f);
    } else {
        NativeButton linkButt;
        hl.addComponent(linkButt = new NativeButton(null)); // link
        linkButt.setCaption(getDisplayedName(m));
        linkButt.setStyleName(BaseTheme.BUTTON_LINK);
        linkButt.addStyleName("borderless");
        linkButt.addStyleName("m-actionplan-nothumbs-button");
        linkButt.addClickListener(new LinkVisitor(m));

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

    hl.addComponent(vl.killButt = new NativeButton(null));
    vl.killButt.setCaption("delete");
    vl.killButt.setStyleName(BaseTheme.BUTTON_LINK);
    vl.killButt.addStyleName("borderless");
    vl.killButt.addStyleName("m-actionplan-nothumbs-button");
    vl.killButt.addClickListener(new VideoRemover(m));

    hl.addComponent(lab = new Label());
    lab.setWidth("3px");

    vl.addComponent(hl);

    ((AbstractLayout) rightScroller.getContent()).addComponent(vl);
    vl.ip.initGui();
}

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

License:Open Source License

@SuppressWarnings("serial")
@HibernateSessionThreadLocalConstructor/*from  ww w . j  a va 2  s.  c o m*/
public AddImageDialog(Object apId) {
    super("Add an Image");

    addStyleName("m-greybackground");

    setClosable(false); // no x in corner

    VerticalLayout mainVL = new VerticalLayout();
    mainVL.setSpacing(true);
    mainVL.setMargin(true);
    mainVL.setSizeUndefined(); // auto size
    setContent(mainVL);

    mainHL = new HorizontalLayout();
    mainVL.addComponent(mainHL);

    mainHL.setSpacing(true);

    holder = new AbsoluteLayout();
    mainHL.addComponent(holder);
    holder.setWidth("150px");
    holder.setHeight("150px");
    holder.addStyleName("m-darkgreyborder");

    VerticalLayout rightVL = new VerticalLayout();
    mainHL.addComponent(rightVL);

    fromWebCheck = new CheckBox();
    fromWebCheck.addStyleName("v-radiobutton");
    fromWebCheck.setValue(true);
    fromWebCheck.setImmediate(true);
    fromWebCheck.addValueChangeListener(new RadioListener(fromWebCheck));

    HorizontalLayout frWebHL = new HorizontalLayout();
    rightVL.addComponent(frWebHL);
    frWebHL.addComponent(fromWebCheck);
    VerticalLayout frWebVL = new VerticalLayout();
    frWebVL.setMargin(true);
    frWebVL.addStyleName("m-greyborder");
    frWebHL.addComponent(frWebVL);
    frWebVL.setWidth("370px");

    frWebVL.addComponent(new Label("From the web:"));
    HorizontalLayout webHL = new HorizontalLayout();
    webHL.setSpacing(true);
    frWebVL.addComponent(webHL);
    webHL.addComponent(webUrl = new TextField());
    webUrl.setColumns(21);
    webHL.addComponent(testButt = new Button("Test"));
    Label sp;
    webHL.addComponent(sp = new Label());
    sp.setWidth("1px");
    webHL.setExpandRatio(sp, 1.0f);

    fromDeskCheck = new CheckBox();
    fromDeskCheck.addStyleName("v-radiobutton");
    fromDeskCheck.setValue(false);
    fromDeskCheck.addValueChangeListener(new RadioListener(fromDeskCheck));
    fromDeskCheck.setImmediate(true);
    HorizontalLayout dtHL = new HorizontalLayout();
    rightVL.addComponent(dtHL);
    dtHL.addComponent(fromDeskCheck);

    VerticalLayout dtopVL = new VerticalLayout();
    dtopVL.setMargin(true);
    dtopVL.addStyleName("m-greyborder");
    dtHL.addComponent(dtopVL);
    dtopVL.setWidth("370px");
    dtopVL.addComponent(new Label("From your desktop:"));
    HorizontalLayout localHL = new HorizontalLayout();
    localHL.setSpacing(true);
    dtopVL.addComponent(localHL);
    localHL.addComponent(localTF = new TextField());
    localTF.setColumns(21);
    localHL.addComponent(uploadWidget = new Upload());
    panel = new UploadStatus(uploadWidget);
    uploadWidget.setButtonCaption("Browse");

    File tempDir = Files.createTempDir();
    tempDir.deleteOnExit();
    handler = new UploadHandler(uploadWidget, panel, tempDir.getAbsolutePath());
    uploadWidget.setReceiver(handler);
    uploadWidget.setImmediate(true);
    panel.setWidth("100%");
    dtopVL.addComponent(panel);
    dtopVL.setComponentAlignment(panel, Alignment.TOP_CENTER);

    HorizontalLayout bottomHL = new HorizontalLayout();
    mainVL.addComponent(bottomHL);
    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"));
    setDisabledFields();

    uploadWidget.addFinishedListener(new FinishedListener() {
        @Override
        public void uploadFinished(FinishedEvent event) {
            Object key = HSess.checkInit();
            System.out.println("AddImageDialog.uploadFinished()");
            String fpath = handler.getFullUploadedPath();
            if (fpath != null) { // error of some kind if null 
                if (!MalwareChecker.isFileVirusFree(fpath)) {
                    panel.state.setValue("<span style='color:red;'>Failed malware check</span>");
                    fpath = null;
                    localTF.setValue("");
                    HSess.checkClose(key);
                    return;
                }

                File f = new File(fpath);
                f.deleteOnExit();

                try {
                    MediaImage mediaImage = InstallImageDialog.putFileImageIntoDbTL(f, f.getName(),
                            event.getMIMEType());
                    f.delete();
                    media = mediaImage.media;
                    image = mediaImage.image;
                    media.setCaption(null);
                    Resource res = Mmowgli2UI.getGlobals().getMediaLocator().locate(media);
                    setupEmbeddedImageThumbnail(res, media);
                    localTF.setValue(event.getFilename());
                } catch (IOException ex) {
                    Notification.show("Error loading image", Notification.Type.ERROR_MESSAGE);
                    MSysOut.println(ERROR_LOGS, "Error in AddImageDialog loading image: "
                            + ex.getClass().getSimpleName() + ": " + ex.getLocalizedMessage());
                }
            }
            HSess.checkClose(key);
        }
    });

    testButt.addClickListener(new testWebImageHandler());

    submitButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (fromWebCheck.getValue()) {
                if (checkBadUrl(webUrl.getValue(), event.getButton()))
                    return;
            }
            UI.getCurrent().removeWindow(AddImageDialog.this);
            if (closer != null)
                closer.windowClose(null);
        }
    });
    cancelButt.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            Object key = HSess.checkInit();
            if (media != null) {
                Media.deleteTL(media);
                media = null;
            }
            if (image != null) {
                Image.deleteTL(image);
                image = null;
            }
            uploadWidget.interruptUpload();
            UI.getCurrent().removeWindow(AddImageDialog.this);
            if (closer != null)
                closer.windowClose(null);

            HSess.checkClose(key);
        }
    });

    webUrl.focus();
}