Search in sources :

Example 1 with ItemClickEvent

use of com.vaadin.event.ItemClickEvent in project VaadinUtils by rlsutton1.

the class ComboBoxWithSearchFieldChooserWindow method getPopupContent2.

@SuppressWarnings("unchecked")
public Component getPopupContent2() {
    grid = new SearchableGrid<T, C>() {

        /**
         */
        private static final long serialVersionUID = 1L;

        @Override
        public GridHeadingPropertySetIfc<T> getHeadingPropertySet() {
            return headingProps;
        }

        @Override
        protected Filter getContainerFilter(String filterString, boolean advancedSearchActive) {
            List<Filter> filters = new ArrayList<>();
            if (baseFilters != null) {
                filters.add(baseFilters);
            }
            if (filterString.length() > 0) {
                filters.add(new SimpleStringFilter(sortColumns[0], filterString, true, false));
            }
            if (filters.size() == 0) {
                return null;
            }
            return new And(filters.toArray(new Filter[] {}));
        }

        @Override
        protected String getTitle() {
            return null;
        }

        @Override
        public C getContainer() {
            return localContainer;
        }

        @Override
        protected AbstractLayout getAdvancedSearchLayout() {
            if (advancedSearchProvider == null) {
                return null;
            }
            return advancedSearchProvider.getAdvancedSearchLayout();
        }

        @Override
        protected AdvancedSearchListener getAdvancedSearchListener() {
            return advancedSearchListener;
        }
    };
    grid.init(caption, (Class<T>) type);
    // grid.getGrid().removeHeaderRow(0);
    ItemClickListener itemClickListener = new ItemClickListener() {

        private static final long serialVersionUID = -4659382639878762429L;

        @Override
        public void itemClick(ItemClickEvent event) {
            listener.selected(event.getItemId());
        }
    };
    Sort sort = Sort.by(sortColumns[0]);
    for (int i = 1; i < sortColumns.length; i++) {
        sort.then(sortColumns[i]);
    }
    grid.sort(sort);
    grid.setSelectionMode(SelectionMode.SINGLE);
    grid.addItemClickListener(itemClickListener);
    grid.setSizeFull();
    holder = new VerticalLayout();
    holder.setWidth("100%");
    holder.setHeight("300");
    holder.addComponent(grid);
    return holder;
}
Also used : ItemClickListener(com.vaadin.event.ItemClickEvent.ItemClickListener) ItemClickEvent(com.vaadin.event.ItemClickEvent) AdvancedSearchListener(au.com.vaadinutils.crud.AdvancedSearchListener) Filter(com.vaadin.data.Container.Filter) SimpleStringFilter(com.vaadin.data.util.filter.SimpleStringFilter) And(com.vaadin.data.util.filter.And) Sort(com.vaadin.data.sort.Sort) VerticalLayout(com.vaadin.ui.VerticalLayout) ArrayList(java.util.ArrayList) List(java.util.List) AbstractLayout(com.vaadin.ui.AbstractLayout) GridHeadingPropertySetIfc(au.com.vaadinutils.crud.GridHeadingPropertySetIfc) SimpleStringFilter(com.vaadin.data.util.filter.SimpleStringFilter)

Example 2 with ItemClickEvent

use of com.vaadin.event.ItemClickEvent in project VaadinUtils by rlsutton1.

the class TableContextMenu method setAsTableContextMenu.

/**
 * Assigns this as the context menu of given table. Allows context menu to
 * appear only on certain parts of the table.
 *
 * @param table
 * @param onRow
 *            show context menu when row is clicked
 * @param onHeader
 *            show context menu when header is clicked
 * @param onFooter
 *            show context menu when footer is clicked
 */
public void setAsTableContextMenu(final Table table, final boolean onRow, final boolean onHeader, final boolean onFooter) {
    extend(table);
    setOpenAutomatically(false);
    if (onRow) {
        table.addItemClickListener(new ItemClickEvent.ItemClickListener() {

            private static final long serialVersionUID = -348059189217149508L;

            @Override
            public void itemClick(ItemClickEvent event) {
                if (event.getButton() == MouseButton.RIGHT) {
                    for (TableContextMenuEvents events : eventsList) events.preContextMenuOpen();
                    fireEvent(new ContextMenuOpenedOnTableRowEvent(TableContextMenu.this, table, event.getItemId(), event.getPropertyId()));
                    open(event.getClientX(), event.getClientY());
                }
            }
        });
    }
    if (onHeader) {
        table.addHeaderClickListener(new HeaderClickListener() {

            private static final long serialVersionUID = -5880755689414670581L;

            @Override
            public void headerClick(HeaderClickEvent event) {
                if (event.getButton() == MouseButton.RIGHT) {
                    for (TableContextMenuEvents events : eventsList) events.preContextMenuOpen();
                    fireEvent(new ContextMenuOpenedOnTableHeaderEvent(TableContextMenu.this, table, event.getPropertyId()));
                    open(event.getClientX(), event.getClientY());
                }
            }
        });
    }
    if (onFooter) {
        table.addFooterClickListener(new FooterClickListener() {

            private static final long serialVersionUID = 2884227013964132482L;

            @Override
            public void footerClick(FooterClickEvent event) {
                if (event.getButton() == MouseButton.RIGHT) {
                    for (TableContextMenuEvents events : eventsList) events.preContextMenuOpen();
                    fireEvent(new ContextMenuOpenedOnTableHeaderEvent(TableContextMenu.this, table, event.getPropertyId()));
                    open(event.getClientX(), event.getClientY());
                }
            }
        });
    }
}
Also used : HeaderClickListener(com.vaadin.ui.Table.HeaderClickListener) ItemClickEvent(com.vaadin.event.ItemClickEvent) HeaderClickEvent(com.vaadin.ui.Table.HeaderClickEvent) FooterClickListener(com.vaadin.ui.Table.FooterClickListener) FooterClickEvent(com.vaadin.ui.Table.FooterClickEvent)

Example 3 with ItemClickEvent

use of com.vaadin.event.ItemClickEvent in project VaadinUtils by rlsutton1.

the class TwinColumnSearchableSelect method createAvailableTable.

private void createAvailableTable() {
    availableTable = new SearchableSelectableEntityTable<C>(this.getClass().getSimpleName()) {

        private static final long serialVersionUID = 1L;

        @Override
        public HeadingPropertySet getHeadingPropertySet() {
            return new HeadingPropertySet.Builder<C>().addColumn(availableColumnHeader, itemLabel).build();
        }

        @Override
        public Filterable getContainer() {
            return availableContainer;
        }

        @Override
        protected Filter getContainerFilter(String filterString, boolean advancedSearchActive) {
            Filter searchFilter = null;
            if (filterString != null && filterString.length() > 0) {
                searchFilter = getSearchFilter(filterString);
            }
            return NullFilter.and(baselineFilter, selectedFilter, searchFilter);
        }

        @Override
        protected String getTitle() {
            return "";
        }
    };
    availableTable.addItemClickListener(new ItemClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
                addButton.click();
            }
        }
    });
    availableTable.disableSelectable();
    availableTable.setWidth(200, Unit.PIXELS);
    availableTable.setHeight(300, Unit.PIXELS);
}
Also used : HeadingPropertySet(au.com.vaadinutils.crud.HeadingPropertySet) ItemClickListener(com.vaadin.event.ItemClickEvent.ItemClickListener) Filter(com.vaadin.data.Container.Filter) NullFilter(au.com.vaadinutils.dao.NullFilter) SimpleStringFilter(com.vaadin.data.util.filter.SimpleStringFilter) Filterable(com.vaadin.data.Container.Filterable) ItemClickEvent(com.vaadin.event.ItemClickEvent)

Example 4 with ItemClickEvent

use of com.vaadin.event.ItemClickEvent in project VaadinUtils by rlsutton1.

the class TwinColumnSelect method createAvailableGrid.

@SuppressWarnings("deprecation")
protected void createAvailableGrid() {
    createAvailableContainer();
    // TODO: Add proper uniqueId
    availableGrid = new SearchableGrid<C, JPAContainer<C>>(this.getClass().getSimpleName(), itemClass) {

        private static final long serialVersionUID = 1L;

        @Override
        public GridHeadingPropertySet<C> getHeadingPropertySet() {
            return createAvailableHeadings();
        }

        @Override
        public JPAContainer<C> getContainer() {
            return availableContainer;
        }

        @Override
        protected Filter getContainerFilter(String filterString, boolean advancedSearchActive) {
            Filter searchFilter = null;
            if (filterString != null && filterString.length() > 0) {
                searchFilter = getSearchFilter(filterString);
            }
            return NullFilter.and(baselineFilter, selectedFilter, searchFilter);
        }

        @Override
        protected String getTitle() {
            return null;
        }
    };
    // Needs to be here after availableContainer creation,
    // otherwise sorting goes away
    sortAvailableContainer();
    availableGrid.addItemClickListener(new ItemClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
                addButton.click();
            }
        }
    });
    availableGrid.setWidth(DEFAULT_COLUMN_WIDTH, Unit.PIXELS);
    availableGrid.setHeight(DEFAULT_COLUMN_HEIGHT, Unit.PIXELS);
}
Also used : ItemClickListener(com.vaadin.event.ItemClickEvent.ItemClickListener) Filter(com.vaadin.data.Container.Filter) NullFilter(au.com.vaadinutils.dao.NullFilter) SimpleStringFilter(com.vaadin.data.util.filter.SimpleStringFilter) JPAContainer(com.vaadin.addon.jpacontainer.JPAContainer) ItemClickEvent(com.vaadin.event.ItemClickEvent) GridHeadingPropertySet(au.com.vaadinutils.crud.GridHeadingPropertySet)

Example 5 with ItemClickEvent

use of com.vaadin.event.ItemClickEvent in project VaadinUtils by rlsutton1.

the class TwinColumnSelect method createSelectedGrid.

private void createSelectedGrid() {
    selectedGrid = new Grid();
    selectedGrid.setContainerDataSource(createSelectedContainer());
    selectedGrid.setWidth(DEFAULT_COLUMN_WIDTH, Unit.PIXELS);
    selectedGrid.setHeight(DEFAULT_COLUMN_HEIGHT, Unit.PIXELS);
    selectedGrid.addItemClickListener(new ItemClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
                removeButton.click();
            }
        }
    });
    createSelectedHeadings().applyToGrid(selectedGrid);
// initialised = true;
}
Also used : ItemClickListener(com.vaadin.event.ItemClickEvent.ItemClickListener) SearchableGrid(au.com.vaadinutils.crud.SearchableGrid) Grid(com.vaadin.ui.Grid) ItemClickEvent(com.vaadin.event.ItemClickEvent)

Aggregations

ItemClickEvent (com.vaadin.event.ItemClickEvent)5 ItemClickListener (com.vaadin.event.ItemClickEvent.ItemClickListener)4 Filter (com.vaadin.data.Container.Filter)3 SimpleStringFilter (com.vaadin.data.util.filter.SimpleStringFilter)3 NullFilter (au.com.vaadinutils.dao.NullFilter)2 AdvancedSearchListener (au.com.vaadinutils.crud.AdvancedSearchListener)1 GridHeadingPropertySet (au.com.vaadinutils.crud.GridHeadingPropertySet)1 GridHeadingPropertySetIfc (au.com.vaadinutils.crud.GridHeadingPropertySetIfc)1 HeadingPropertySet (au.com.vaadinutils.crud.HeadingPropertySet)1 SearchableGrid (au.com.vaadinutils.crud.SearchableGrid)1 JPAContainer (com.vaadin.addon.jpacontainer.JPAContainer)1 Filterable (com.vaadin.data.Container.Filterable)1 Sort (com.vaadin.data.sort.Sort)1 And (com.vaadin.data.util.filter.And)1 AbstractLayout (com.vaadin.ui.AbstractLayout)1 Grid (com.vaadin.ui.Grid)1 FooterClickEvent (com.vaadin.ui.Table.FooterClickEvent)1 FooterClickListener (com.vaadin.ui.Table.FooterClickListener)1 HeaderClickEvent (com.vaadin.ui.Table.HeaderClickEvent)1 HeaderClickListener (com.vaadin.ui.Table.HeaderClickListener)1