Example usage for com.vaadin.ui NativeButton setIcon

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

Introduction

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

Prototype

@Override
public void setIcon(Resource icon) 

Source Link

Document

Sets the component's icon.

Usage

From source file:ac.uk.icl.dell.vaadin.glycanbuilder.VaadinGlycanCanvas.java

License:Open Source License

public void appendGeneralToolBar(Panel theToolBarPanel) {
    HorizontalLayout toolBar = new HorizontalLayout();
    toolBar.setWidth("100%");

    toolBar.setStyleName("toolbar");

    NativeButton deleteButton = new NativeButton("Delete");
    deleteButton.setIcon(new ThemeResource("icons/deleteNew.png"));
    deleteButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 1289257412952359727L;

        @Override// w  w  w.j  a va 2 s.  c  om
        public void buttonClick(ClickEvent event) {
            theCanvas.delete();
        }
    });
    deleteButton.setEnabled(false);

    NativeButton copyButton = new NativeButton("Copy");
    final NativeButton pasteButton = new NativeButton("Paste");
    copyButton.setIcon(new ThemeResource("icons/editcopy.png"));
    copyButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -1740735587078805580L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.copy();
            pasteButton.setEnabled(true);
        }
    });
    copyButton.setEnabled(false);

    pasteButton.setIcon(new ThemeResource("icons/editpaste.png"));
    pasteButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -8732259244009686729L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.paste();
            pasteButton.setEnabled(false);
        }
    });
    pasteButton.setEnabled(false);

    final NativeButton bracketButton = new NativeButton("Bracket");
    bracketButton.setIcon(new ThemeResource("icons/bracket.png"));
    bracketButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 5201094306113759901L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.addBracket();
        }
    });
    bracketButton.setEnabled(false);

    final NativeButton repeatButton = new NativeButton("Repeat");
    repeatButton.setIcon(new ThemeResource("icons/repeat.png"));
    repeatButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -23302591439643695L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                theCanvas.addRepeat();
            } catch (Exception ex) {
                showMessage(ex.getMessage(), "400px", "100px", "Error creating repeat");
            }
        }
    });
    repeatButton.setEnabled(false);

    componentsWithResidueSelectionDependency.add(repeatButton);
    componentsWithResidueSelectionDependency.add(bracketButton);
    componentsWithResidueSelectionDependency.add(deleteButton);
    componentsWithResidueSelectionDependency.add(copyButton);

    final NativeButton orientationButton = new NativeButton("Orientation");

    orientationButton.setIcon(new ThemeResource("icons/" + theCanvas.getOrientationIcon()));
    orientationButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 6621021858668446143L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.changeOrientation();
            orientationButton.setIcon(new ThemeResource("icons/" + theCanvas.getOrientationIcon()));
        }
    });

    final NativeButton selectAllButton = new NativeButton("Select all");

    selectAllButton.setIcon(new ThemeResource("icons/selectall.png"));
    selectAllButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -5848923636575805154L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.selectAll();
            theCanvas.documentUpdated();
        }
    });

    final NativeButton deSelectAllButton = new NativeButton("Select none");

    deSelectAllButton.setIcon(new ThemeResource("icons/deselect.png"));
    deSelectAllButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 8339468775345706027L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.resetSelection();
            theCanvas.documentUpdated();
        }
    });

    final NativeButton moveCWButton = new NativeButton("Move CW");

    moveCWButton.setIcon(new ThemeResource("icons/rotatecw.png"));
    moveCWButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -6061975045440741204L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.onMoveCW();
        }
    });

    componentsWithResidueSelectionDependency.add(moveCWButton);

    final NativeButton moveCCWButton = new NativeButton("Move CCW");

    moveCCWButton.setIcon(new ThemeResource("icons/rotateccw.png"));
    moveCCWButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 3555726070782377309L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.onMoveCCW();
        }
    });

    componentsWithResidueSelectionDependency.add(moveCCWButton);

    toolBar.addComponent(deleteButton);
    toolBar.addComponent(copyButton);
    toolBar.addComponent(pasteButton);
    toolBar.addComponent(orientationButton);
    toolBar.addComponent(selectAllButton);
    toolBar.addComponent(deSelectAllButton);
    toolBar.addComponent(bracketButton);
    toolBar.addComponent(repeatButton);
    toolBar.addComponent(moveCWButton);
    toolBar.addComponent(moveCCWButton);

    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();

    toolBar.addComponent(layout);
    toolBar.setExpandRatio(layout, 1);

    theToolBarPanel.setContent(toolBar);
}

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  ww  w  .j a  va 2s . co m*/
            }
        });
    }
}

From source file:com.logicbomb.newschool.MyAppWidgetSet.core.HourWidget.java

public HourWidget(int aHourNumber, int aTotalHourNumber) {
    setWidth("500px");
    setHeight("500px");
    //setStyleName("backColorGrey");

    String[] classes = { "VI", "VII", "VIII", "IX", "X" };
    int index1 = new Random().nextInt(classes.length);
    String selectedClass = (classes[index1]);

    String[] sections = { "A", "B", "C", "D", "E" };
    int index2 = new Random().nextInt(classes.length);
    String selectedSection = (sections[index2]);

    String[] content = { "Gravitation", "Lab", "Electricity", "Force", "Motion" };
    int index3 = new Random().nextInt(classes.length);
    String selectedContent = (content[index3]);

    //Button b= new Button("2");
    //addComponent(b);
    //c.setSizeFull();
    Button iMinorText = new Button(selectedContent);
    double redOrGreen = Math.random();
    if (Math.random() > 0.5) {
        iMinorText.setStyleName("v-button-type1-red");
    } else {/*from  ww  w  . ja v a 2  s  .  c  o m*/
        iMinorText.setStyleName("v-button-type1-green");
    }
    iMinorText.setHeight("40px");
    iMinorText.setWidth("125px");
    //c.setCaptionAsHtml(true);  kkk

    addComponent(iMinorText);//,"top:10px;left:10px");

    Label iMajorText = new Label(selectedClass + " - " + selectedSection);
    iMajorText.setStyleName("v-label-type1");
    iMajorText.setHeight("15px");
    iMajorText.setWidth("50px");
    addComponent(iMajorText, "top:2px;left:1px");

    double numberOfMemos = Math.floor(Math.random() * 5);
    //Diplay if any memo present
    NativeButton memoButton;
    if (numberOfMemos > 0) {
        memoButton = new NativeButton();//String.valueOf(numberOfMemos).replace(".0", ""));
        memoButton.setStyleName("v-button-type2");
        //memoButton.setHeight("15px");
        //memoButton.setWidth("30px");
        memoButton.setIcon(FontAwesome.PENCIL);
        addComponent(memoButton, "top:2px;left:85px");
    }

    double numberOfNotifications = Math.floor(Math.random() * 5);
    NativeButton notificationButton;
    if (numberOfNotifications > 0) {
        notificationButton = new NativeButton();//String.valueOf(numberOfNotifications).replace(".0", ""));
        notificationButton.setStyleName("v-button-type2");
        //notificationButton.setHeight("15px");
        //notificationButton.setWidth("30px");
        notificationButton.setIcon(FontAwesome.BELL);
        addComponent(notificationButton, "top:2px;left:100px");
    }

}

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 ww w. j a  va  2s. co 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   www.  ja  va 2s  .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.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./*from  w  w w .j a  va 2  s  . c om*/
 */
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.modules.cards.CardChainTreeTablePopup.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
public CardChainTreeTablePopup(Object rootId, boolean modal, boolean wantSaveButton) {
    super(null);/*from ww  w .  j a v a2s. c om*/
    setWidth("600px");
    setHeight("400px");
    addStyleName("m-noborder"); // V7 difference

    super.initGui();
    selectedId = tempSelectedId = rootId;
    setModal(modal);
    setListener(this);
    setResizable(true);

    setTitleString("Card chain");
    saveClicked = false;

    contentVLayout.setSpacing(true);

    treeT = new CardChainTree(rootId, false, !modal);
    if (rootId == null) {
        setTitleString("Card chains");
        // instead, do some creative backgrounding to pseudo select children of a card, treeT.setMultiSelect(true);
    }
    //treeT.setSizeFull();
    treeT.setWidth("99%");
    treeT.setHeight("99%");
    treeT.addItemClickListener((ItemClickListener) this);
    treeT.addStyleName("m-greyborder");
    contentVLayout.addComponent(treeT);
    contentVLayout.setComponentAlignment(treeT, Alignment.MIDDLE_CENTER);
    contentVLayout.setExpandRatio(treeT, 1.0f);

    /* todo...the saved data was never being retrieved, should pass it back to create action plan panel */

    if (wantSaveButton) {
        // need a save button
        HorizontalLayout hl = new HorizontalLayout();
        hl.setWidth("100%");
        contentVLayout.addComponent(hl);
        Label lab;
        hl.addComponent(lab = new Label());
        hl.setExpandRatio(lab, 1.0f);

        NativeButton saveButt = new NativeButton();
        hl.addComponent(saveButt);
        saveButt.setIcon(Mmowgli2UI.getGlobals().getMediaLocator().getSaveButtonIcon());
        saveButt.setWidth("45px"); //38px");
        saveButt.setHeight("16px");
        saveButt.addStyleName("borderless");
        saveButt.addClickListener(saveListener = new SaveListener());
        saveButt.setClickShortcut(KeyCode.ENTER);
        hl.addComponent(lab = new Label());
        lab.setWidth("30px");
        contentVLayout.addComponent(hl);
    }
}

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

License:Open Source License

private void displayBadgesAndAwards(Object uid, Session sess) {
    MediaLocator loc = Mmowgli2UI.getGlobals().getMediaLocator();

    ClickListener lis = new BadgeListener();
    Game g = Game.get(sess);/* w w w .j a  v  a2 s.  co m*/

    MSysOut.println(DEBUG_LOGS, "User.get(sess) from UserProfile3Top.displayBadgesAndAwards(sess)");
    User u = User.get(uid, sess);
    Set<Badge> badges = u.getBadges();

    badgeLayout.removeAllComponents();

    @SuppressWarnings("unchecked")
    List<Badge> list = (List<Badge>) sess.createCriteria(Badge.class).addOrder(Order.asc("badge_pk")).list();
    int nDefinedBadges = list.size();

    for (int b = 0; b < nDefinedBadges; b++) {
        Badge bd = getBadgeById(badges, b + 1);
        badgeButts[b] = new NativeButton();
        badgeButts[b].addStyleName("m-badgeButton");
        badgeLayout.addComponent(badgeButts[b]);

        if (bd != null) {
            badgeButts[b].setIcon(loc.locate(bd.getMedia()));
            badgeButts[b].setDescription(getBadgeDescription(g, bd)); // check for undesired action plan mention
            badgeButts[b].addClickListener(lis);
        } else {
            badgeButts[b].setIcon(loc.getEmptyBadgeImage());
            if (!((b + 1) == BADGE_EIGHT_ID))
                badgeButts[b].setDescription(getBadgeDescription(g, list.get(b))); // check for undesired action plan mention
        }
    }

    List<AwardButton> ablis = getAwardButtons(u, sess);
    Iterator<AwardButton> bItr = ablis.iterator();

    for (int i = 0; i < 4; i++) {
        NativeButton awb = bItr.hasNext() ? bItr.next() : null;
        if (awb == null) {

            awb = new NativeButton();
            awb.addStyleName("m-badgeButton");
            awb.setDescription("Game-specific awards");
            awb.setIcon(loc.getEmptyBadgeImage());
        }
        badgeLayout.addComponent(awb);
    }

}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

Layout getCompoundMenus() {
    Layout grid = getPreviewLayout("Compound Menus");

    Label title = new Label("Sidebar Menu");
    title.setStyleName("h1");
    grid.addComponent(title);/*from w  ww  .ja v  a2  s  . c o m*/
    ((GridLayout) grid).newLine();

    Label menus = new Label(
            "<strong>The sidebar menu</strong> control is just a set of labels and buttons inside a CssLayout or a VerticalLayout. Use the structure shown on the right, <strong>and remember that you need to implement all logic yourself</strong>. This theme just provides suitable stylenames for you to use.<br><br>You can also use the <a href=\"http://vaadin.com/forum/-/message_boards/message/119172\">DetachedTabs add-on</a> inside the sidebar-menu, it will style automatically.<br><br><strong>Note: only NativeButtons are styled inside the menu, normal buttons are left untouched.</strong>",
            Label.CONTENT_XHTML);
    grid.addComponent(menus);
    menus = new Label(
            "CssLayout.setStyleName(\"sidebar-menu\")\n  +  Label\n  +  NativeButton\n  +  NativeButton\n\t...\n  +  Label\n  +  DetachedTabs\n\t...",
            Label.CONTENT_PREFORMATTED);
    grid.addComponent(menus);

    SidebarMenu sidebar = new SidebarMenu();
    sidebar.setWidth("200px");
    sidebar.addComponent(new Label("Fruits"));
    NativeButton b = new NativeButton("Apples");
    b.setIcon(new ThemeResource("../runo/icons/16/note.png"));
    sidebar.addButton(b);
    sidebar.setSelected(b);
    sidebar.addButton(new NativeButton("Oranges"));
    sidebar.addButton(new NativeButton("Bananas"));
    sidebar.addButton(new NativeButton("Grapes"));
    sidebar.addComponent(new Label("Vegetables"));
    sidebar.addButton(new NativeButton("Tomatoes"));
    sidebar.addButton(new NativeButton("Cabbages"));
    sidebar.addButton(new NativeButton("Potatoes"));
    sidebar.addButton(new NativeButton("Carrots"));
    grid.addComponent(sidebar);
    ((GridLayout) grid).setColumnExpandRatio(0, 1);
    ((GridLayout) grid).setColumnExpandRatio(1, 1);

    title = new Label("Toolbar");
    title.setStyleName("h1");
    grid.addComponent(title);
    ((GridLayout) grid).newLine();

    CssLayout toolbars = new CssLayout();

    menus = new Label(
            "<strong>Toolbar</strong> is a simple CssLayout with a stylename. It provides the background and a little padding for its contents. Normally you will want to put buttons inside it, but segment controls fit in nicely as well.",
            Label.CONTENT_XHTML);
    grid.addComponent(menus);
    menus = new Label("CssLayout.setStyleName(\"toolbar\")", Label.CONTENT_PREFORMATTED);
    grid.addComponent(menus);

    CssLayout toolbar = new CssLayout();
    toolbar.setStyleName("toolbar");
    toolbar.setWidth("300px");

    Button b2 = new Button("Action");
    b2.setStyleName("small");
    toolbar.addComponent(b2);

    Segment segment = new Segment();
    segment.addStyleName("segment-alternate");
    b2 = new Button("Apples");
    b2.setStyleName("small");
    b2.addStyleName("down");
    segment.addButton(b2);
    b2 = new Button("Oranges");
    b2.setStyleName("small");
    segment.addButton(b2);
    toolbar.addComponent(segment);

    b2 = new Button("Notes");
    b2.setStyleName("small borderless");
    b2.setIcon(new ThemeResource("../runo/icons/16/note.png"));
    toolbar.addComponent(b2);
    toolbars.addComponent(toolbar);

    toolbar = new CssLayout();
    toolbar.setStyleName("toolbar");
    toolbar.setWidth("300px");

    b2 = new Button("Action");
    b2.setIcon(new ThemeResource("../runo/icons/32/document.png"));
    b2.setStyleName("borderless");
    toolbar.addComponent(b2);

    b2 = new Button("Action 2");
    b2.setStyleName("borderless");
    b2.setIcon(new ThemeResource("../runo/icons/32/user.png"));
    toolbar.addComponent(b2);

    b2 = new Button("Action 3");
    b2.setStyleName("borderless");
    b2.setIcon(new ThemeResource("../runo/icons/32/note.png"));
    toolbar.addComponent(b2);
    toolbars.addComponent(toolbar);

    grid.addComponent(toolbars);

    return grid;
}

From source file:org.jdal.vaadin.ui.FormUtils.java

License:Apache License

/**
 * Create a new {@link NativeButton} from an {@link ButtonListener}
 * @param action button listener//www .j av a  2  s.  co m
 * @return a new native button.
 */
public static NativeButton newNativeButton(ButtonListener action) {
    NativeButton b = new NativeButton(action.getCaption(), action);
    b.setIcon(action.getIcon());
    b.setDescription(action.getDescription());

    return b;
}