Example usage for com.vaadin.ui HorizontalLayout setHeight

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

Introduction

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

Prototype

@Override
    public void setHeight(String height) 

Source Link

Usage

From source file:de.uni_tuebingen.qbic.qbicmainportlet.SampleView.java

License:Open Source License

VerticalLayout initTable() {
    this.table = this.buildFilterTable();
    VerticalLayout tableSection = new VerticalLayout();
    VerticalLayout tableSectionContent = new VerticalLayout();

    tableSection.setCaption("Experiments");
    // tableSectionContent.setCaption("Registered Experiments");
    // tableSectionContent.setIcon(FontAwesome.FLASK);
    tableSectionContent.addComponent(this.table);

    tableSectionContent.setMargin(new MarginInfo(true, false, false, true));
    tableSection.setMargin(new MarginInfo(true, false, false, true));
    this.table.setWidth("100%");
    // tableSection.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.8f, Unit.PIXELS);
    tableSectionContent.setWidth("100%");

    tableSection.addComponent(tableSectionContent);

    this.export = new Button("Export as TSV");
    buttonLayoutSection = new VerticalLayout();
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setHeight(null);
    buttonLayout.setWidth("100%");
    buttonLayout.addComponent(this.export);
    buttonLayout.setMargin(new MarginInfo(false, false, true, false));
    buttonLayoutSection.addComponent(buttonLayout);
    buttonLayoutSection.setSpacing(true);
    buttonLayoutSection.setMargin(new MarginInfo(false, false, true, true));

    tableSection.addComponent(buttonLayoutSection);

    return tableSection;
}

From source file:edu.kit.dama.ui.commons.util.PaginationLayout.java

License:Apache License

/**
 * Update the layout. This method is either called internally when scrolling
 * or//w w  w  . ja v a 2  s  .c  o  m
 */
public final void update() {
    //remove all components (old result page and navigation)
    removeAllComponents();

    //add current results
    renderPage();

    //build pagination
    int pages = overallEntries / entriesPerPage;
    if (overallEntries % entriesPerPage > 0) {
        pages++;
    }

    final int overallPages = pages;
    HorizontalLayout navigation = new HorizontalLayout();
    //add "JumpToFirstPage" button
    final NativeButton first = new NativeButton();
    first.setIcon(firstIcon);
    if (firstIcon == null) {
        first.setCaption("<<");
    }
    first.setDescription("First Page");
    first.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            currentPage = 0;
            update();
        }
    });
    //add "PreviousPage" button
    final NativeButton prev = new NativeButton();
    prev.setIcon(prevIcon);
    if (prevIcon == null) {
        prev.setCaption("<");
    }
    prev.setDescription("Previous Page");
    prev.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (currentPage > 0) {
                currentPage--;
                update();
            }
        }
    });
    //add "NextPage" button
    final NativeButton next = new NativeButton();
    next.setIcon(nextIcon);
    if (nextIcon == null) {
        next.setCaption(">");
    }
    next.setDescription("Next Page");
    next.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (currentPage + 1 < overallPages) {
                currentPage++;
                update();
            }
        }
    });
    //add "JumpToLastPage" button
    final NativeButton last = new NativeButton();
    last.setIcon(endIcon);
    if (endIcon == null) {
        next.setCaption(">>");
    }
    last.setDescription("Last Page");
    last.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            currentPage = overallPages - 1;
            update();
        }
    });

    //enable/disable buttons depending on the current page
    if (overallPages == 0) {
        first.setEnabled(false);
        prev.setEnabled(false);
        next.setEnabled(false);
        last.setEnabled(false);
    } else {
        first.setEnabled(!(currentPage == 0) || !(overallPages < 2));
        prev.setEnabled(!(currentPage == 0) || !(overallPages < 2));
        next.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2));
        last.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2));
    }

    //at first, put the page size selection box into the navigation
    final ComboBox entriesPerPageBox = new ComboBox();
    entriesPerPageBox.setItemCaptionPropertyId("name");
    entriesPerPageBox.addContainerProperty("name", String.class, null);
    entriesPerPageBox.addItem(5);
    entriesPerPageBox.getContainerProperty(5, "name").setValue("5 Entries / Page");
    entriesPerPageBox.addItem(10);
    entriesPerPageBox.getContainerProperty(10, "name").setValue("10 Entries / Page");
    entriesPerPageBox.addItem(15);
    entriesPerPageBox.getContainerProperty(15, "name").setValue("15 Entries / Page");
    entriesPerPageBox.addItem(20);
    entriesPerPageBox.getContainerProperty(20, "name").setValue("20 Entries / Page");

    entriesPerPageBox.setValue(entriesPerPage);
    entriesPerPageBox.setNullSelectionAllowed(false);
    entriesPerPageBox.setImmediate(true);

    entriesPerPageBox.addListener(new Property.ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            entriesPerPage = (Integer) entriesPerPageBox.getValue();
            update();
        }
    });

    navigation.addComponent(entriesPerPageBox);

    //filler labels are added to the beginning and to the end to keep the navigation in the middle
    Label leftFiller = new Label();
    leftFiller.setWidth("25px");
    navigation.addComponent(leftFiller);
    navigation.addComponent(first);
    navigation.addComponent(prev);

    //Show max. 10 pages at once for performance and layout reasons.
    //If there are more than 10 pages, "move" the to show 10 pages based on the current page.
    int start = currentPage - 5;
    start = (start < 0) ? 0 : start;
    int end = start + 10;
    end = (end > pages) ? pages : end;

    if (end - start < 10 && pages > 10) {
        start = end - 10;
    }

    if (overallPages == 0) {
        Label noEntryLabel = new Label("<i>No entries</i>", Label.CONTENT_XHTML);
        //noEntryLabel.setWidth("80px");
        noEntryLabel.setSizeUndefined();
        navigation.addComponent(noEntryLabel);
        navigation.setComponentAlignment(noEntryLabel, Alignment.MIDDLE_CENTER);
    }
    //build the actual page entries
    for (int i = start; i < end; i++) {
        if (i == currentPage) {
            //the current page is marked with a special style
            Label pageLink = new Label("<b>" + Integer.toString(i + 1) + "</b>", Label.CONTENT_XHTML);
            pageLink.setStyleName("currentpage");
            pageLink.setWidth("15px");
            navigation.addComponent(pageLink);
            navigation.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER);
        } else {
            //otherwise normal links are added, click-events are handled via LayoutClickListener 
            Link pageLink = new Link(Integer.toString(i + 1), null);
            navigation.addComponent(pageLink);
            navigation.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER);
        }
    }
    //add right navigation buttons
    navigation.addComponent(next);
    navigation.addComponent(last);
    //...and fill the remaining space 
    Label rightFiller = new Label();
    navigation.addComponent(rightFiller);
    //  navigation.setExpandRatio(leftFiller, 1.0f);
    navigation.setExpandRatio(rightFiller, 1.0f);
    navigation.setSpacing(true);

    //put everything ot the middle
    navigation.setComponentAlignment(first, Alignment.MIDDLE_CENTER);
    navigation.setComponentAlignment(prev, Alignment.MIDDLE_CENTER);
    navigation.setComponentAlignment(next, Alignment.MIDDLE_CENTER);
    navigation.setComponentAlignment(last, Alignment.MIDDLE_CENTER);

    //add layout click listener to be able to navigate by clicking the single pages
    navigation.addListener(new LayoutEvents.LayoutClickListener() {
        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {

            // Get the child component which was clicked
            Component child = event.getChildComponent();

            if (child == null) {
                // Not over any child component
            } else {
                // Over a child component
                if (child instanceof Link) {
                    // Over a valid child element
                    currentPage = Integer.parseInt(((Link) child).getCaption()) - 1;
                    update();
                }
            }
        }
    });

    //finalize
    navigation.setWidth("100%");
    navigation.setHeight("25px");

    //add navigation and align it right below the result page
    addComponent(page);
    setExpandRatio(page, 1f);
    if (overallEntries > 0) {
        addComponent(navigation);
        setComponentAlignment(navigation, Alignment.BOTTOM_CENTER);
        setExpandRatio(navigation, .05f);
    }
    requestRepaint();
}

From source file:edu.kit.dama.ui.repo.components.PaginationPanel.java

License:Apache License

/**
 * Build the navigation layout including the appropriate buttons to navigate
 * through the pagination pages.//from   w  w w  .jav  a2  s . co m
 *
 * @return The navigation layout component.
 */
private HorizontalLayout buildNavigationComponent() {
    HorizontalLayout result = new HorizontalLayout();
    //add "JumpToFirstPage" button
    final NativeButton first = new NativeButton();
    first.setIcon(new ThemeResource("img/16x16/beginning.png"));
    first.setDescription("First Page");
    first.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            currentPage = 0;
            updatePage();
        }
    });
    //add "PreviousPage" button
    final NativeButton prev = new NativeButton();
    prev.setIcon(new ThemeResource("img/16x16/prev.png"));
    prev.setDescription("Previous Page");
    prev.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (currentPage > 0) {
                currentPage--;
                updatePage();
            }
        }
    });
    //add "NextPage" button
    final NativeButton next = new NativeButton();
    next.setDescription("Next Page");
    next.setIcon(new ThemeResource("img/16x16/next.png"));
    next.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (currentPage + 1 < overallPages) {
                currentPage++;
                updatePage();
            }
        }
    });
    //add "JumpToLastPage" button
    final NativeButton last = new NativeButton();
    last.setDescription("Last Page");
    last.setIcon(new ThemeResource("img/16x16/end.png"));
    last.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            currentPage = overallPages - 1;
            updatePage();
        }
    });

    //enable/disable buttons depending on the current page
    if (overallPages == 0) {
        first.setEnabled(false);
        prev.setEnabled(false);
        next.setEnabled(false);
        last.setEnabled(false);
    } else {
        first.setEnabled(!(currentPage == 0) || !(overallPages < 2));
        prev.setEnabled(!(currentPage == 0) || !(overallPages < 2));
        next.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2));
        last.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2));
    }

    Label leftFiller = new Label();
    result.addComponent(leftFiller);
    result.setExpandRatio(leftFiller, 1.0f);
    result.addComponent(first);
    result.addComponent(prev);
    int start = currentPage - 5;
    start = (start < 0) ? 0 : start;
    int end = start + 10;
    end = (end > overallPages) ? overallPages : end;

    if (end - start < 10 && overallPages > 10) {
        start = end - 10;
    }

    if (overallPages == 0) {
        Label noEntryLabel = new Label("<i>No entries</i>", ContentMode.HTML);
        //noEntryLabel.setWidth("80px");
        noEntryLabel.setSizeUndefined();
        result.addComponent(noEntryLabel);
        result.setComponentAlignment(noEntryLabel, Alignment.MIDDLE_CENTER);
    }
    //build the actual page entries
    for (int i = start; i < end; i++) {
        if (i == currentPage) {
            //the current page is marked with a special style
            Label pageLink = new Label("<b>" + Integer.toString(i + 1) + "</b>", ContentMode.HTML);
            pageLink.setStyleName("currentpage");
            pageLink.setWidth("15px");
            result.addComponent(pageLink);
            result.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER);
        } else {
            //otherwise normal links are added, click-events are handled via LayoutClickListener 
            Link pageLink = new Link(Integer.toString(i + 1), null);
            result.addComponent(pageLink);
            result.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER);
        }
    }
    //add right navigation buttons
    result.addComponent(next);
    result.addComponent(last);
    //...and fill the remaining space 
    Label rightFiller = new Label();
    result.addComponent(rightFiller);
    result.setExpandRatio(rightFiller, 1.0f);
    result.setSpacing(true);

    //put everything ot the middle
    result.setComponentAlignment(first, Alignment.MIDDLE_CENTER);
    result.setComponentAlignment(prev, Alignment.MIDDLE_CENTER);
    result.setComponentAlignment(next, Alignment.MIDDLE_CENTER);
    result.setComponentAlignment(last, Alignment.MIDDLE_CENTER);

    //add layout click listener to be able to navigate by clicking the single pages
    result.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {

            // Get the child component which was clicked
            Component child = event.getChildComponent();

            if (child == null) {
                // Not over any child component
            } else // Over a child component
            {
                if (child instanceof Link) {
                }
            }
        }
    });

    //finalize
    result.setWidth("100%");
    result.setHeight("25px");
    return result;
}

From source file:edu.nps.moves.mmowgli.components.CardSummary.java

License:Open Source License

@SuppressWarnings("serial")
public void initGui(Session sess) {
    setHeight(heightStr);/*from w  w w  . j  a  va 2  s  .  c  om*/
    setWidth(widthStr);
    addStyleName("m-cursor-pointer"); // pointer when over me, because I'm clickable

    if (bckgrndResource != null) {
        backImg = new Embedded(null, bckgrndResource);
        addComponent(backImg, "top:0px;left:0px");
    }

    if (!isFactCard) {
        String hdrTxt = card.getCardType().getSummaryHeader();
        header.setDescription(hdrTxt);
        if (hdrTxt != null && hdrTxt.length() > 0) {
            //if(hdrTxt.length()>=15) {
            //   hdrTxt = hdrTxt.substring(0, 15).trim()+"...";
            // }
            header.setValue(hdrTxt);
            header.setWidth(headerWidthStr);
            header.setHeight(headerHeightStr);
            addComponent(header, headerPositionStr);
            header.addStyleName(headerStyleStr);
            header.addStyleName(textColorStyleStr);
            header.addStyleName("m-cursor-pointer");
        }

        if (starGreyResource != null && starRedResource != null) {
            Set<Card> favs = me.getFavoriteCards();
            if (favs != null && favs.contains(card)) {
                star.setIcon(starRedResource);
            } else {
                star.setIcon(starGreyResource);
            }
            addComponent(star, starPositionStr);
            if (!mockupOnly)
                star.addClickListener(new StarClick());
            star.addStyleName("borderless");
            star.setDescription("Mark or unmark as a favorite of yours");
        }
    }
    idLab.setWidth(idLabWidthStr);
    idLab.setHeight(idLabHeightStr);
    idLab.setValue("" + card.getId());
    idLab.addStyleName(idLabStyleStr);
    idLab.addStyleName("m-text-align-right");
    addComponent(idLab, idLabPositionStr);

    content.setWidth(contentWidthStr);
    content.setHeight(contentHeightStr);
    addComponent(content, contentPositionStr);
    content.addStyleName(contentStyle);
    if (card.isHidden())
        content.addStyleName(hiddenStyle); // red "HIDDEN" text background

    content.setValue(formatText(card.getText()));
    content.addStyleName("m-cursor-pointer");
    content.setDescription(card.getText());

    if (!isFactCard) {
        /* We shouldn't have to be setting widths on the components within this horizontal layout.  The
         * fact that we do is, I think, related to the absolutelayout parent.  Get rid of that and we might
         * be able to yank the .setwidth, setheight stuff.
         */
        HorizontalLayout hLay = new HorizontalLayout();
        hLay.setMargin(false);
        hLay.setHeight(userHeightStr);
        hLay.setWidth(userDateWidthStr);
        addComponent(hLay, userDatePositionStr);

        user.setValue(card.getAuthorName()); //.getAuthor().getUserName());
        hLay.addComponent(user);
        user.setWidth(userWidthStr);
        user.setHeight(userHeightStr);
        user.addStyleName(userStyle);
        user.addStyleName("m-cursor-pointer");

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

        dateLab.setValue(dateFormatter.format(card.getCreationDate()));
        hLay.addComponent(dateLab);
        dateLab.setHeight(userHeightStr);
        dateLab.setWidth(null); //dateWidthStr);
        dateLab.addStyleName(userStyle);
    }

    if (card.getCreatedInMove().getId() != Move.getCurrentMove(sess).getId()) {
        Label lab = new Label(card.getCreatedInMove().getName());
        lab.addStyleName(moveStyleStr);
        lab.setWidth(moveWidthStr);
        lab.setHeight(moveHeightStr);
        addComponent(lab, movePositionStr);
    }

    // Listen for layout click events
    if (!mockupOnly)
        this.addLayoutClickListener(new LayoutClickListener() {
            @MmowgliCodeEntry
            @HibernateOpened
            @HibernateRead
            public void layoutClick(LayoutClickEvent event) {
                HSess.init();
                Component c = event.getChildComponent();
                Card card = Card.getTL(cardId);
                if (c == star) {
                    //Let the starlistener below handle it
                } else if (c == user) {
                    AppEvent evt = new AppEvent(CARDAUTHORCLICK, CardSummary.this, card.getAuthor().getId());
                    Mmowgli2UI.getGlobals().getController().miscEventTL(evt);
                } else { //if (c == content) {
                    AppEvent evt = new AppEvent(CARDCLICK, CardSummary.this, card.getId());
                    Mmowgli2UI.getGlobals().getController().miscEventTL(evt);
                }
                HSess.close();
            }
        });
}

From source file:edu.nps.moves.mmowgli.components.Header.java

License:Open Source License

@SuppressWarnings("serial")
@Override/* w ww . j ava2  s  . co  m*/
public void initGui() {
    setWidth(HEADER_W);
    setHeight(HEADER_H);
    Game g = Game.getTL();
    GameLinks gl = GameLinks.getTL();

    Embedded embedded = new Embedded(null, mediaLoc.getHeaderBackground());
    addComponent(embedded, "top:0px;left:0px");

    if (g.isActionPlansEnabled()) {
        embedded = new Embedded(null, mediaLoc.getImage("scoretext200w50h.png"));
        addComponent(embedded, "top:52px;left:63px");
        addComponent(explorPtsLab, "top:55px;left:260px");
        addComponent(implPtsLab, "top:79px;left:247px");
    } else {
        embedded = new Embedded(null, mediaLoc.getImage("scoretextoneline200w50h.png"));
        addComponent(embedded, "top:52px;left:73px");
        addComponent(explorPtsLab, "top:65px;left:205px");
    }

    Resource res = mediaLoc.getHeaderBanner(g);
    if (res != null) {
        embedded = new Embedded(null, res);
        addComponent(embedded, pos_banner);
    }
    HorizontalLayout buttHL = new HorizontalLayout();
    buttHL.setSpacing(false);
    buttHL.setMargin(false);
    buttHL.setWidth("291px");
    buttHL.setHeight("45px");
    addComponent(buttHL, "top:1px;left:687px");

    Label lab;
    boolean armyHack = gl.getFixesLink().toLowerCase().contains("armyscitech")
            || gl.getGlossaryLink().toLowerCase().contains("armyscitech");
    if (armyHack)
        buttonChars = buttonChars - 3 + 9; // Replace "Map" with "Resources
    buttHL.addComponent(lab = new Label());
    lab.setWidth("1px");
    buttHL.setExpandRatio(lab, 0.5f);
    buttHL.addComponent(leaderBoardButt);
    buttHL.setComponentAlignment(leaderBoardButt, Alignment.MIDDLE_CENTER);
    addDivider(buttHL, buttonChars);

    // Hack
    if (armyHack) { //Hack
        Link resourceLink = makeSmallLink("Resources", "", "http://futures.armyscitech.com/resources/");
        buttHL.addComponent(resourceLink);
        buttHL.setComponentAlignment(resourceLink, Alignment.MIDDLE_CENTER);
    } else {
        buttHL.addComponent(mapButt);
        buttHL.setComponentAlignment(mapButt, Alignment.MIDDLE_CENTER);
    }
    addDivider(buttHL, buttonChars);
    buttHL.addComponent(liveBlogButt);
    buttHL.setComponentAlignment(liveBlogButt, Alignment.MIDDLE_CENTER);
    addDivider(buttHL, buttonChars);
    buttHL.addComponent(learnMoreButt);
    buttHL.setComponentAlignment(learnMoreButt, Alignment.MIDDLE_CENTER);

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

    addComponent(playIdeaButt, pos_playIdeaButt);

    if (g.isActionPlansEnabled()) {
        addComponent(takeActionButt, pos_takeActionButt);
        toggleTakeActionButt(true); // everbody can click it me.isGameMaster());
    } else if (armyHack) {
        embedded = new Embedded(null, mediaLoc.getImage("armylogoxpntbg80w80h.png"));
        addComponent(embedded, "top:54px;left:864px");
    }

    Serializable uid = Mmowgli2UI.getGlobals().getUserID();
    refreshUser(uid, HSess.get()); // assume in vaadin transaction here

    avatar.setWidth(HEADER_AVATAR_W);
    avatar.setHeight(HEADER_AVATAR_H);
    avatar.setDescription(user_profile_tt);
    avatar.addClickListener(new MouseEvents.ClickListener() {
        @Override
        public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
            userNameButt.buttonClick(new ClickEvent(userNameButt));
        }
    });
    userNameButt.setDescription(user_profile_tt);
    addComponent(userNameButt, HEADER_USERNAME_POS);
    addComponent(avatar, "top:13px;left:6px"); //HEADER_AVATAR_POS);

    searchField.setWidth("240px");
    //  searchField.setHeight("18px");    // this causes a text _area_ to be used, giving me two lines, default height is good, style removes borders
    searchField.setInputPrompt("Search");
    searchField.setImmediate(true);
    searchField.setTextChangeEventMode(TextChangeEventMode.LAZY);
    searchField.setTextChangeTimeout(5000); // ms
    searchField.addStyleName("m-header-searchfield");
    searchField.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void valueChange(ValueChangeEvent event) {
            HSess.init();
            handleSearchClickTL();
            HSess.close();
            /*
            searchButt.focus();  // make the white go away
            String s = event.getProperty().getValue().toString();
            if (s.length() > 0) {
              MmowgliController controller = Mmowgli2UI.getGlobals().getController();
              controller.handleEvent(SEARCHCLICK, s, searchField);
            } */
        }
    });
    searchButt.enableAction(false); // want a local listener
    searchButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            HSess.init();
            handleSearchClickTL();
            HSess.close();
        }
    });
    addComponent(searchField, "top:107px;left:74px"); //"top:110px;left:74px");
    addComponent(signOutButt, "top:25px;left:250px"); //"top:18px;left:250px");
    addComponent(searchButt, "top:105px;left:30px"); //"top:100px;left:180px");

    MessageUrl mu = MessageUrl.getLastTL();
    if (mu != null)
        decorateBlogHeadlinesLink(mu);
    addBlogHeadlinesLink("top:147px;left:20px");

    String headline = blogHeadlinesLink.getCaption();
    if (headline != null && headline.length() > 0) {
        // Add Window.Notification relaying the same info as the BlogHeadLinesLink
        Notification note = new Notification("Today's News", "<br/>" + headline,
                Notification.Type.WARNING_MESSAGE, true);
        note.setPosition(Position.TOP_CENTER);
        note.setDelayMsec(5 * 1000);
        // Yellow is more an attention getter
        note.setStyleName("m-blue");
        note.show(Page.getCurrent());
    }

    addComponent(callToActionButt, "top:0px;left:333px");
    /* The css has a height, width and even a background, but stupid IE will only properly size the button if an image is
     * used.  Therefore we use an a transparent png of the proper size */
    MediaLocator medLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    callToActionButt.setIcon(medLoc.getEmpty353w135h());

    Move move = g.getCurrentMove();
    if (g.isShowHeaderBranding()) {
        Media brand = g.getHeaderBranding();
        if (brand != null) {
            Embedded bremb = new Embedded(null, mediaLoc.locate(brand));
            addComponent(bremb, "top:0px;left:333px");
        } else {
            brandingLab.setHeight("30px");
            setBrandingLabelText(move, g);
            addComponent(brandingLab, "top:0px;left:333px"); //HEADER_MOVETITLE_POS);  //"top:151px;left:476px";      
        }
    }
    if (move.isShowMoveBranding()) {
        moveNumLab.setValue(move.getName());
        addComponent(moveNumLab, "top:103px;left:333px");
    }
    /*    if(user != null && (user.isAdministrator() || user.isGameMaster() || user.isDesigner() )) { // has a menu
          //  fouoLink.addStyleName("m-absolutePositioning");
            addComponent(fouoLink,"top:-10px;left:400px");
        }
        else
          addComponent(fouoLink,"top:0px;left:400px");
                
        fouoLink.setVisible(g.isShowFouo());
        */
}

From source file:edu.nps.moves.mmowgli.components.MmowgliDialog.java

License:Open Source License

@Override
public void initGui() {
    outerLayout = new VerticalLayout();
    outerLayout.setSpacing(false);/*w  w  w  .j  av  a  2s . c  o  m*/
    outerLayout.setSizeUndefined();
    outerLayout.addStyleName("m-transparent");
    setContent(outerLayout);

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

    HorizontalLayout headerWrapper2 = new HorizontalLayout();
    outerLayout.addComponent(headerWrapper2); // at the top
    headerWrapper2.addStyleName("m-dialog-header");
    headerWrapper2.setHeight("75px");
    headerWrapper2.setWidth("592px");
    headerWrapper2.setSpacing(false);
    headerWrapper2.setMargin(false);
    headerWrapper2.addComponent(sp = new Label()); // indent from left
    sp.setWidth("45px");

    headerHL2 = new HorizontalLayout(); // Where the title gets written
    headerHL2.setSpacing(false);
    headerHL2.setMargin(false);
    headerHL2.setHeight("75px");
    headerWrapper2.addComponent(headerHL2);
    headerWrapper2.setExpandRatio(headerHL2, 1.0f);

    cancelButt = makeCancelButton();
    cancelButt.addClickListener(new MyCancelListener());
    cancelButt.setClickShortcut(KeyCode.ESCAPE);
    headerWrapper2.addComponent(cancelButt);
    headerWrapper2.setComponentAlignment(cancelButt, Alignment.MIDDLE_CENTER);

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

    contentVLayout = new VerticalLayout();
    contentVLayout.addStyleName("m-dialog-content");
    contentVLayout.setSizeUndefined();
    contentVLayout.setWidth("592px"); // but do the width explicitly

    outerLayout.addComponent(contentVLayout);

    Image footer = new Image(null, Mmowgli2UI.getGlobals().mediaLocator().getDialogFooterBackground());
    footer.setWidth("592px");
    footer.setHeight("36px");
    outerLayout.addComponent(footer);
}

From source file:edu.nps.moves.mmowgli.components.MmowgliDialogContent.java

License:Open Source License

public void initGui() {
    addComponent(leftVL);/* w w  w.j a  v a  2s  .  co m*/
    leftVL.setSizeFull();

    setExpandRatio(leftVL, 1.0f);

    leftVL.addComponent(headerWrapper);
    headerWrapper.addStyleName("m-mmowglidialog2-header");
    headerWrapper.setHeight("75px");
    headerWrapper.setWidth("100%");

    doHeaderWrapper();

    HorizontalLayout midHL = new HorizontalLayout();
    leftVL.addComponent(midHL);
    leftVL.setExpandRatio(midHL, 1.0f);
    midHL.setHeight("100%");
    midHL.setWidth("100%");
    midHL.addComponent(leftEdge);
    leftEdge.setHeight("100%");
    leftEdge.setWidth("10px");
    midHL.addComponent(contentVLayout);
    contentVLayout.addStyleName("m-mmowglidialog2-middle");
    contentVLayout.setSizeFull();
    midHL.setExpandRatio(contentVLayout, 1.0f); // gets it all
    leftVL.addComponent(footer);
    footer.setWidth("100%");
    footer.setHeight("36px");

    addComponent(rightShadowVL);
    rightShadowVL.setHeight("100%");
    rightShadowVL.setWidth("28px");
    rightShadowVL.addComponent(rightEdge);
    rightEdge.setHeight("100%");
    rightEdge.setWidth("28px");
    // rightEdge.addStyleName("m-clip-overflow");
    rightShadowVL.setExpandRatio(rightEdge, 1.0f);
    rightShadowVL.addComponent(corner);
}

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 ww . j a  v a 2s .  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.ActionPlanPage2.java

License:Open Source License

private Component makeIdField(ActionPlan ap) {
    HorizontalLayout hl = new HorizontalLayout();
    hl.setMargin(false);//from   w w w. ja  va2s . c  o  m
    hl.setSpacing(false);
    hl.setHeight("22px");

    Label lab;
    hl.addComponent(lab = new Label());
    lab.setWidth("270px");
    hl.addComponent(lab = new Label("ID " + ap.getId()));
    hl.setComponentAlignment(lab, Alignment.BOTTOM_LEFT);

    maybeAddHiddenCheckBoxTL(hl, ap);
    return hl;
}

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

License:Open Source License

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

    Label lab;/* w  ww  .j  av  a 2  s. c om*/
    hLay.addComponent(lab = new Label());
    lab.setWidth("25px");

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

    return hLay;
}