Example usage for com.vaadin.server FontAwesome CARET_DOWN

List of usage examples for com.vaadin.server FontAwesome CARET_DOWN

Introduction

In this page you can find the example usage for com.vaadin.server FontAwesome CARET_DOWN.

Prototype

FontAwesome CARET_DOWN

To view the source code for com.vaadin.server FontAwesome CARET_DOWN.

Click Source Link

Usage

From source file:com.esofthead.mycollab.vaadin.ui.table.AbstractPagedBeanTable.java

License:Open Source License

private void createTable() {
    this.tableItem = new Table();
    this.tableItem.setWidth("100%");
    this.tableItem.addStyleName("striped");
    this.tableItem.setSortEnabled(false);

    // set column generator
    for (final Object propertyId : this.columnGenerators.keySet()) {
        this.tableItem.addGeneratedColumn(propertyId, this.columnGenerators.get(propertyId));
    }//  ww w. j a  v a 2 s .c  om

    if (StringUtils.isNotBlank((String) this.sortColumnId)) {
        this.tableItem.setColumnIcon(this.sortColumnId,
                this.isAscending ? FontAwesome.CARET_DOWN : FontAwesome.CARET_UP);
    }

    this.tableItem.addHeaderClickListener(new Table.HeaderClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void headerClick(final Table.HeaderClickEvent event) {
            final String propertyId = (String) event.getPropertyId();

            if (propertyId.equals("selected")) {
                return;
            }

            if (AbstractPagedBeanTable.this.searchRequest != null) {
                AbstractPagedBeanTable.this.sortColumnId = propertyId;

                final S searchCriteria = AbstractPagedBeanTable.this.searchRequest.getSearchCriteria();
                if (searchCriteria.getOrderByField() == null) {
                    searchCriteria.setOrderByField(propertyId);
                    searchCriteria.setSortDirection(SearchCriteria.DESC);
                    AbstractPagedBeanTable.this.isAscending = false;
                } else if (propertyId.equals(searchCriteria.getOrderByField())) {
                    AbstractPagedBeanTable.this.isAscending = !AbstractPagedBeanTable.this.isAscending;
                    searchCriteria.setSortDirection(
                            searchCriteria.getSortDirection().equals(SearchCriteria.ASC) ? SearchCriteria.DESC
                                    : SearchCriteria.ASC);
                } else {
                    searchCriteria.setOrderByField(propertyId);
                    searchCriteria.setSortDirection(SearchCriteria.DESC);
                    AbstractPagedBeanTable.this.isAscending = false;
                }

                AbstractPagedBeanTable.this.setSearchCriteria(searchCriteria);
            }
        }
    });

    final BeanItemContainer<B> container = new BeanItemContainer<>(this.type, this.currentListData);
    this.tableItem.setPageLength(0);
    this.tableItem.setContainerDataSource(container);
    displayTableColumns();
    this.tableItem.setWidth("100%");

    if (this.getComponentCount() > 0) {
        final Component component0 = this.getComponent(0);
        if (component0 instanceof Table) {
            this.replaceComponent(component0, tableItem);
        } else {
            this.addComponent(tableItem, 0);
        }
    } else {
        this.addComponent(tableItem, 0);
    }

}

From source file:com.esofthead.mycollab.vaadin.web.ui.SortButton.java

License:Open Source License

public SortButton() {
    super();/*from  w ww.j  av  a  2s. c o  m*/
    this.setIcon(FontAwesome.CARET_DOWN);
    this.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 4326727093112639245L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            SortButton.this.toggleSortOrder();
        }
    });
}

From source file:com.esofthead.mycollab.vaadin.web.ui.SortButton.java

License:Open Source License

public void toggleSortOrder() {
    this.isDesc = !this.isDesc;
    if (this.isDesc) {
        this.setIcon(FontAwesome.CARET_DOWN);
    } else {/*from w  w  w  . ja v a2s.  c o  m*/
        this.setIcon(FontAwesome.CARET_UP);
    }
}

From source file:com.esofthead.mycollab.vaadin.web.ui.table.AbstractPagedBeanTable.java

License:Open Source License

private void createTable() {
    tableItem = new Table();
    tableItem.setWidth("100%");
    tableItem.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
    tableItem.addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
    tableItem.setSortEnabled(false);//from w  ww  .  ja va  2s.c  om

    // set column generator
    for (Map.Entry<Object, ColumnGenerator> entry : columnGenerators.entrySet()) {
        tableItem.addGeneratedColumn(entry.getKey(), entry.getValue());
    }

    if (StringUtils.isNotBlank((String) sortColumnId)) {
        tableItem.setColumnIcon(sortColumnId, isAscending ? FontAwesome.CARET_DOWN : FontAwesome.CARET_UP);
    }

    tableItem.addHeaderClickListener(new Table.HeaderClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void headerClick(final Table.HeaderClickEvent event) {
            String propertyId = (String) event.getPropertyId();

            if (propertyId.equals("selected")) {
                return;
            }

            if (searchRequest != null) {
                S searchCriteria = searchRequest.getSearchCriteria();
                if (sortColumnId == null) {
                    sortColumnId = propertyId;
                    searchCriteria.setOrderFields(Collections
                            .singletonList(new SearchCriteria.OrderField(propertyId, SearchCriteria.DESC)));
                    isAscending = false;
                } else if (propertyId.equals(sortColumnId)) {
                    isAscending = !isAscending;
                    String direction = (isAscending) ? SearchCriteria.ASC : SearchCriteria.DESC;
                    searchCriteria.setOrderFields(
                            Collections.singletonList(new SearchCriteria.OrderField(propertyId, direction)));
                } else {
                    sortColumnId = propertyId;
                    searchCriteria.setOrderFields(Collections
                            .singletonList(new SearchCriteria.OrderField(propertyId, SearchCriteria.DESC)));
                    isAscending = false;
                }

                setSearchCriteria(searchCriteria);
            }
        }
    });

    BeanItemContainer<B> container = new BeanItemContainer<>(type, currentListData);
    tableItem.setPageLength(0);
    tableItem.setContainerDataSource(container);
    displayTableColumns();

    if (this.getComponentCount() > 0) {
        final Component component0 = this.getComponent(0);
        if (component0 instanceof Table) {
            this.replaceComponent(component0, tableItem);
        } else {
            this.addComponent(tableItem, 0);
        }
    } else {
        this.addComponent(tableItem, 0);
    }
    this.setExpandRatio(tableItem, 1);
}

From source file:com.mycollab.vaadin.web.ui.SortButton.java

License:Open Source License

public SortButton() {
    super();
    this.setIcon(FontAwesome.CARET_DOWN);
    this.addClickListener(clickEvent -> toggleSortOrder());
}

From source file:com.mycollab.vaadin.web.ui.table.AbstractPagedBeanTable.java

License:Open Source License

private void createTable() {
    tableItem = new Table();
    tableItem.setWidth("100%");
    tableItem.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
    tableItem.addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
    tableItem.setSortEnabled(false);//from  w ww .  j a v a 2  s . c  om

    // set column generator
    for (Map.Entry<Object, ColumnGenerator> entry : columnGenerators.entrySet()) {
        tableItem.addGeneratedColumn(entry.getKey(), entry.getValue());
    }

    if (StringUtils.isNotBlank((String) sortColumnId)) {
        tableItem.setColumnIcon(sortColumnId, isAscending ? FontAwesome.CARET_DOWN : FontAwesome.CARET_UP);
    }

    tableItem.addHeaderClickListener(headerClickEvent -> {
        String propertyId = (String) headerClickEvent.getPropertyId();

        if (propertyId.equals("selected")) {
            return;
        }

        if (searchRequest != null) {
            S searchCriteria = searchRequest.getSearchCriteria();
            if (sortColumnId == null) {
                sortColumnId = propertyId;
                searchCriteria.setOrderFields(Collections
                        .singletonList(new SearchCriteria.OrderField(propertyId, SearchCriteria.DESC)));
                isAscending = false;
            } else if (propertyId.equals(sortColumnId)) {
                isAscending = !isAscending;
                String direction = (isAscending) ? SearchCriteria.ASC : SearchCriteria.DESC;
                searchCriteria.setOrderFields(
                        Collections.singletonList(new SearchCriteria.OrderField(propertyId, direction)));
            } else {
                sortColumnId = propertyId;
                searchCriteria.setOrderFields(Collections
                        .singletonList(new SearchCriteria.OrderField(propertyId, SearchCriteria.DESC)));
                isAscending = false;
            }

            setSearchCriteria(searchCriteria);
        }
    });

    BeanItemContainer<B> container = new BeanItemContainer<>(type, currentListData);
    tableItem.setPageLength(0);
    tableItem.setContainerDataSource(container);
    displayTableColumns();

    if (this.getComponentCount() > 0) {
        final Component component0 = this.getComponent(0);
        if (component0 instanceof Table) {
            this.replaceComponent(component0, tableItem);
        } else {
            this.addComponent(tableItem, 0);
        }
    } else {
        this.addComponent(tableItem, 0);
    }
    this.setExpandRatio(tableItem, 1);
}