Example usage for com.vaadin.server FontAwesome CARET_UP

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

Introduction

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

Prototype

FontAwesome CARET_UP

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

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));
    }/*w w  w .  j  a v a2s. c o  m*/

    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 void toggleSortOrder() {
    this.isDesc = !this.isDesc;
    if (this.isDesc) {
        this.setIcon(FontAwesome.CARET_DOWN);
    } else {/*from  ww  w .j a  va 2 s  .  co 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);/*  w  w  w.j  a v a2  s  .c o m*/

    // 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.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  ww  w.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);
}