Example usage for com.vaadin.ui NativeButton addClickListener

List of usage examples for com.vaadin.ui NativeButton addClickListener

Introduction

In this page you can find the example usage for com.vaadin.ui NativeButton addClickListener.

Prototype

public Registration addClickListener(ClickListener listener) 

Source Link

Document

Adds the button click listener.

Usage

From source file:com.example.mmowgli_2_0.RootCards.java

/**
 * Add Default Click Listener for the Add Card Button
 *//*from  w  w w .j  av  a2 s.  co m*/
private void setAddCardButtonListener(PopupView popup, NativeButton root_button) {
    root_button.addClickListener(new NativeButton.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            //TODO add a popup window to add a card.
            popup.setPopupVisible(true);
        }

    });

}

From source file:com.foc.vaadin.FocWebVaadinWindow.java

License:Apache License

public void addUnitTestingButtonIfAllowed() {
    // Auto-Testing Header Icon
    if (ConfigInfo.isUnitAllowed()) {
        NativeButton autoTestingIcon = newButtonInHeaderBar("", true);
        menuBarIcons_Add("_UNIT_", autoTestingIcon);
        autoTestingIcon.setIcon(FontAwesome.EXCLAMATION_TRIANGLE);
        autoTestingIcon.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                try {
                    executeAutomatedTesting();
                } catch (Exception e) {
                    Globals.logException(e);
                }/*from w ww .  j  a  v  a  2 s .co m*/
            }
        });
    }
}

From source file:com.foc.vaadin.gui.layouts.validationLayout.FVOptionMobileLayout.java

License:Apache License

private void addMoreItemsAsButtons(FVMenuBar menuBar) {
    List<MenuItem> munItemList = menuBar.getItems();

    if (munItemList.size() > 0) {
        MenuItem moreItem = munItemList.get(0);
        if (moreItem != null) {
            List<MenuItem> children = moreItem.getChildren();
            for (int i = 0; i < children.size(); i++) {
                MenuItem menuItem = children.get(i);
                if (menuItem != null) {
                    String title = menuItem.getText();
                    FVMenuBarCommand menuBarCommand = (FVMenuBarCommand) menuItem.getCommand();
                    if (menuBarCommand != null) {
                        NativeButton button = new NativeButton(title);
                        button.setWidth("100%");
                        button.setHeight("40px");
                        button.addStyleName("focBannerButton");
                        addComponent(button);
                        button.addClickListener(new MenuItemButtonClickListener(menuItem, menuBarCommand));
                    }/*  w ww  .j a v a2  s  .co  m*/
                }
            }
        }
    }

}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.tagging.components.SearchEngineMetaDescription.java

License:Open Source License

private Component createSEOProgressBar() {
    ProgressBar seoProgressBar = new ProgressBar();
    seoProgressBar.setWidth("250px");
    seoProgressBar.setValue(0.5f);/*from w w w .j  a v  a 2s .c  om*/

    HorizontalLayout layout = new HorizontalLayout();
    layout.addComponent(new Label("SEO Rating:"));
    layout.addComponent(seoProgressBar);
    layout.setSpacing(true);
    layout.setMargin(new MarginInfo(false, false, true, false));

    NativeButton addUpdateButton = new NativeButton("", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            // do nothing
        }
    });
    addUpdateButton.addStyleName("update-button");
    addUpdateButton.setHeight("28px");
    addUpdateButton.setCaption("Update");
    addUpdateButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            updateMetaDescriptionPreview(textArea.getValue());
        }
    });
    layout.addComponent(addUpdateButton);

    return layout;
}

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/*from w w w.j  a  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 .  ja va  2 s.  c o 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.kit.dama.ui.repo.components.ShareObjectComponent.java

/**
 * Build the main layout of the component.
 *///from   w w w.  ja  v a2  s.co  m
private void buildMainLayout() {
    shareList = new TwinColSelect();
    shareList.setRows(10);
    shareList.setMultiSelect(true);
    shareList.setImmediate(true);
    shareList.setLeftColumnCaption("Not accessible by");
    shareList.setRightColumnCaption("Accessible by");

    shareList.setWidth("500px");
    shareList.setHeight("400px");

    final NativeButton shareButton = new NativeButton("Share");
    final NativeButton cancelButton = new NativeButton("Cancel");

    Button.ClickListener listener = new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (shareButton.equals(event.getButton())) {
                syncShares();
            }
            sharePopup.setPopupVisible(false);
        }
    };

    shareButton.addClickListener(listener);
    cancelButton.addClickListener(listener);

    HorizontalLayout buttonLayout = new HorizontalLayout(cancelButton, shareButton);
    mainLayout = new VerticalLayout(shareList, buttonLayout);
    mainLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);
    mainLayout.setExpandRatio(shareList, .9f);
    mainLayout.setExpandRatio(buttonLayout, .1f);
}

From source file:edu.kit.dama.ui.repo.MyVaadinUI.java

License:Apache License

/**
 * Build the search view and execute the provided query immediately.
 *
 * @param pQuery The query to execute or null if an empty view should be
 * shown.// w  w  w.j  a  va  2s . co m
 */
private void buildSearchView(String pQuery) {
    loginButton.setWidth("70px");
    loginButton.setStyleName(BaseTheme.BUTTON_LINK);
    logoutButton.setWidth("70px");
    logoutButton.setStyleName(BaseTheme.BUTTON_LINK);
    adminButton.setWidth("70px");
    adminButton.setStyleName(BaseTheme.BUTTON_LINK);

    logoutButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            loggedInUser = UserData.NO_USER;
            refreshMainLayout();
        }
    });

    adminButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Page.getCurrent()
                    .open(DataManagerSettings.getSingleton().getStringProperty(
                            DataManagerSettings.GENERAL_BASE_URL_ID, "http://localhost:8889/BaReDemo")
                            + "/admin", "_blank");
        }
    });

    searchField = UIUtils7.factoryTextField(null, "Search for...");
    searchField.setWidth("920px");
    searchField.setHeight("60px");
    searchField.addStyleName("searchField");

    paginationPanel = new PaginationPanel(this);
    paginationPanel.setSizeFull();
    paginationPanel.setAllEntries(new LinkedList<DigitalObjectId>());

    searchProvider = new FulltextElasticSearchProvider(
            DataManagerSettings.getSingleton()
                    .getStringProperty(DataManagerSettings.ELASTIC_SEARCH_DEFAULT_CLUSTER_ID, "KITDataManager"),
            DataManagerSettings.getSingleton()
                    .getStringProperty(DataManagerSettings.ELASTIC_SEARCH_DEFAULT_HOST_ID, "localhost"),
            DataManagerSettings.getSingleton().getStringProperty(
                    DataManagerSettings.ELASTIC_SEARCH_DEFAULT_INDEX_ID,
                    ElasticsearchHelper.ELASTICSEARCH_TYPE),
            ElasticsearchHelper.ELASTICSEARCH_TYPE);
    NativeButton goButton = new NativeButton();
    goButton.setIcon(new ThemeResource("img/24x24/search.png"));
    goButton.setWidth("60px");
    goButton.setHeight("60px");
    goButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            doSearch();
        }
    });
    goButton.setClickShortcut(KeyCode.ENTER);

    setupLoginForm();
    loginForm.setWidth("320px");
    loginForm.setHeight("150px");
    final PopupView loginPopup = new PopupView(null, loginForm);
    loginPopup.setHideOnMouseOut(false);
    loginButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            //mainLayout.replaceComponent(searchLayout, loginForm);
            loginPopup.setPopupVisible(true);
        }
    });

    Label filler = new Label();
    memberLayout = new HorizontalLayout(filler, adminButton, loginButton, loginPopup);
    memberLayout.setComponentAlignment(loginButton, Alignment.TOP_RIGHT);
    memberLayout.setComponentAlignment(adminButton, Alignment.TOP_RIGHT);
    memberLayout.setComponentAlignment(loginPopup, Alignment.TOP_RIGHT);

    memberLayout.setExpandRatio(filler, 1.0f);
    memberLayout.setMargin(false);
    memberLayout.setSpacing(false);
    memberLayout.setWidth("100%");
    memberLayout.setHeight("30px");

    Label spacer = new Label("<hr/>", ContentMode.HTML);
    spacer.setHeight("20px");

    searchLayout = new UIUtils7.GridLayoutBuilder(3, 4)
            .addComponent(searchField, Alignment.TOP_LEFT, 0, 0, 2, 1)
            .addComponent(goButton, Alignment.TOP_RIGHT, 2, 0, 1, 1).fillRow(spacer, 0, 1, 1)
            .addComponent(paginationPanel, Alignment.MIDDLE_CENTER, 0, 2, 3, 2).getLayout();
    searchLayout.addStyleName("paper");
    searchLayout.setSpacing(true);
    searchLayout.setMargin(true);
    paginationPanel.setWidth("980px");
    //wrapper
    Label icon8Link = new Label("<a href=\"http://icons8.com\">Icons by icon8.com</a>", ContentMode.HTML);
    mainLayout = new VerticalLayout(memberLayout, searchLayout, icon8Link);
    mainLayout.setComponentAlignment(memberLayout, Alignment.TOP_CENTER);
    mainLayout.setComponentAlignment(searchLayout, Alignment.TOP_CENTER);
    mainLayout.setComponentAlignment(icon8Link, Alignment.BOTTOM_RIGHT);
    mainLayout.setExpandRatio(memberLayout, .05f);
    mainLayout.setExpandRatio(searchLayout, .93f);
    mainLayout.setExpandRatio(icon8Link, .02f);

    VerticalLayout fullscreen = new VerticalLayout(mainLayout);
    fullscreen.setComponentAlignment(mainLayout, Alignment.TOP_CENTER);
    fullscreen.setSizeFull();
    setContent(fullscreen);

    mainLayout.setWidth("1024px");
    mainLayout.setHeight("768px");

    if (pQuery != null) {
        searchField.setValue(pQuery);
        doSearch();
    }
}

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

License:Open Source License

@SuppressWarnings("serial")
@Override/*from   w w  w.jav  a 2s  . c  o m*/
public void initGui() {
    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();
    mainLayout.setMargin(true); //test
    mainLayout.setSpacing(true);
    MediaLocator medLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    Label sp;
    setContent(mainLayout);

    Panel p = new Panel(imgLay = new HorizontalLayout());
    imgLay.setSpacing(true);

    p.setWidth("100%");
    mainLayout.addComponent(p);

    Collection<?> lis = Avatar.getContainer().getItemIds();
    avIdArr = new Object[lis.size()];

    int idx = 0;

    for (Object id : lis) {
        avIdArr[idx++] = id;
        if (initSelectedID == null)
            initSelectedID = id; // sets first one
        Avatar a = Avatar.getTL(id);
        Image em = new Image(null, medLoc.locate(a.getMedia()));
        em.setWidth("95px");
        em.setHeight("95px");
        em.addClickListener(new ImageClicked());

        if (id.equals(initSelectedID)) {
            em.addStyleName("m-orangeborder5");
            lastSel = em;
        } else
            em.addStyleName("m-greyborder5");
        imgLay.addComponent(em);
    }

    butts = new HorizontalLayout();
    butts.setWidth("100%");
    butts.setSpacing(true);
    mainLayout.addComponent(butts);

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

    NativeButton cancelButt = new NativeButton();
    medLoc.decorateCancelButton(cancelButt);
    butts.addComponent(cancelButt);

    NativeButton selectButt = new NativeButton();
    medLoc.decorateSelectButton(selectButt);
    butts.addComponent(selectButt);

    butts.addComponent(sp = new Label(""));
    sp.setWidth("20px");

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

    cancelButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        public void buttonClick(ClickEvent event) {
            cancelClick();
        }
    });
    selectButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        public void buttonClick(ClickEvent event) {
            selectClick();
        }
    });
}

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);//www.  java  2s.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();
}