com.vaadin.v7.ui.Table Java Examples

The following examples show how to use com.vaadin.v7.ui.Table. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultiSelectTableWithStringCollection.java    From viritin with Apache License 2.0 6 votes vote down vote up
@Override
public Component getTestComponent() {
    
    strings.setOptions(Arrays.asList(options));
    strings.withColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
    strings.withRowHeaderMode(Table.RowHeaderMode.ID);
    strings.withProperties();
    
    final Beani beani = new Beani();
    
    MBeanFieldGroup.bindFieldsUnbuffered(beani, this);
    
    
    Button showValue = new Button("show value", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Notification.show(beani.toString());
        }
    });
    
    return new MVerticalLayout(strings, showValue);
}
 
Example #2
Source File: TableContextMenu.java    From cuba with Apache License 2.0 5 votes vote down vote up
/**
 * Sets this as a context menu of the component. You can set one menu to as
 * many components as you wish.
 *
 * @param component
 *            the component to set the context menu to
 */
@Override
public void setAsContextMenuOf(ContextClickNotifier component) {
    /*
     * Workaround for VScrollTable click handling, which prevents context
     * clicks from rows when ItemClickListener has been added. (#29)
     */
    if (component instanceof Table) {
        useTableSpecificContextClickListener((Table) component);
        // For context clicks outside rows (header, footer, body) we still
        // need the context click listener.
    }
    super.setAsContextMenuOf(component);
}
 
Example #3
Source File: TableContextMenu.java    From cuba with Apache License 2.0 5 votes vote down vote up
private void useTableSpecificContextClickListener(final Table table) {
    table.addItemClickListener(new ItemClickListener() {

        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.getButton() == MouseButton.RIGHT) {
                MouseEventDetails mouseEventDetails = new MouseEventDetails();
                mouseEventDetails.setAltKey(event.isAltKey());
                mouseEventDetails.setButton(event.getButton());
                mouseEventDetails.setClientX(event.getClientX());
                mouseEventDetails.setClientY(event.getClientY());
                mouseEventDetails.setCtrlKey(event.isCtrlKey());
                mouseEventDetails.setMetaKey(event.isMetaKey());
                mouseEventDetails.setRelativeX(event.getRelativeX());
                mouseEventDetails.setRelativeY(event.getRelativeY());
                mouseEventDetails.setShiftKey(event.isShiftKey());
                if (event.isDoubleClick()) {
                    mouseEventDetails.setType(0x00002);
                } else {
                    mouseEventDetails.setType(0x00001);
                }

                getContextClickListener().contextClick(
                        new ContextClickEvent(table, mouseEventDetails));
            }
        }
    });
}
 
Example #4
Source File: TableContextMenu.java    From context-menu with Apache License 2.0 5 votes vote down vote up
/**
 * Sets this as a context menu of the component. You can set one menu to as
 * many components as you wish.
 *
 * @param component
 *            the component to set the context menu to
 */
@Override
public void setAsContextMenuOf(ContextClickNotifier component) {
    /*
     * Workaround for VScrollTable click handling, which prevents context
     * clicks from rows when ItemClickListener has been added. (#29)
     */
    if (component instanceof Table) {
        useTableSpecificContextClickListener((Table) component);
        // For context clicks outside rows (header, footer, body) we still
        // need the context click listener.
    }
    super.setAsContextMenuOf(component);
}
 
Example #5
Source File: TableContextMenu.java    From context-menu with Apache License 2.0 5 votes vote down vote up
private void useTableSpecificContextClickListener(final Table table) {
    table.addItemClickListener(new ItemClickListener() {

        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.getButton() == MouseButton.RIGHT) {
                MouseEventDetails mouseEventDetails = new MouseEventDetails();
                mouseEventDetails.setAltKey(event.isAltKey());
                mouseEventDetails.setButton(event.getButton());
                mouseEventDetails.setClientX(event.getClientX());
                mouseEventDetails.setClientY(event.getClientY());
                mouseEventDetails.setCtrlKey(event.isCtrlKey());
                mouseEventDetails.setMetaKey(event.isMetaKey());
                mouseEventDetails.setRelativeX(event.getRelativeX());
                mouseEventDetails.setRelativeY(event.getRelativeY());
                mouseEventDetails.setShiftKey(event.isShiftKey());
                if (event.isDoubleClick()) {
                    mouseEventDetails.setType(0x00002);
                } else {
                    mouseEventDetails.setType(0x00001);
                }

                getContextClickListener().contextClick(
                        new ContextClickEvent(table, mouseEventDetails));
            }
        }
    });
}
 
Example #6
Source File: AbstractPagedBeanTable.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public Table getTable() {
    return tableItem;
}
 
Example #7
Source File: AbstractPagedBeanTable.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
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);

    // 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 ? VaadinIcons.CARET_DOWN : VaadinIcons.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);
}
 
Example #8
Source File: MultiSelectTable.java    From viritin with Apache License 2.0 4 votes vote down vote up
public void withRowHeaderMode(Table.RowHeaderMode rowHeaderMode) {
    getUnderlayingTable().setRowHeaderMode(rowHeaderMode);
}
 
Example #9
Source File: MultiSelectTable.java    From viritin with Apache License 2.0 4 votes vote down vote up
public MultiSelectTable<ET> withColumnHeaderMode(Table.ColumnHeaderMode mode) {
    getUnderlayingTable().setColumnHeaderMode(mode);
    return this;
}
 
Example #10
Source File: MultiSelectTable.java    From viritin with Apache License 2.0 4 votes vote down vote up
/**
 * @return the underlaying Table
 * @deprecated use getTable() instead.
 */
@Deprecated
protected Table getUnderlayingTable() {
    return table;
}
 
Example #11
Source File: FluentTable.java    From viritin with Apache License 2.0 2 votes vote down vote up
/**
 * Assigns a row generator to the table. The row generator will be able to
 * replace rows in the table when it is rendered.
 *
 * @param generator the new row generator
 * @return this (for method chaining)
 * @see Table#setRowGenerator(Table.RowGenerator)
 */
public S withRowGenerator(Table.RowGenerator generator);
 
Example #12
Source File: TableContextMenu.java    From cuba with Apache License 2.0 2 votes vote down vote up
/**
 * Constructs a context menu and sets it for the given table.
 *
 * @param table
 *            the table to set the context menu to
 */
public TableContextMenu(Table table) {
    super(table, true);
}
 
Example #13
Source File: TableContextMenu.java    From context-menu with Apache License 2.0 2 votes vote down vote up
/**
 * Constructs a context menu and sets it for the given table.
 *
 * @param table
 *            the table to set the context menu to
 */
public TableContextMenu(Table table) {
    super(table, true);
}
 
Example #14
Source File: FluentTable.java    From viritin with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the column alignments.
 *
 * <p>
 * The amount of items in the array must match the amount of properties
 * identified by {@link Table#getVisibleColumns()}. The possible values for the
 * alignments include:
 * </p>
 * <ul>
 * <li>{@link Align#LEFT}: Left alignment</li>
 * <li>{@link Align#CENTER}: Centered</li>
 * <li>{@link Align#RIGHT}: Right alignment</li>
 * </ul>
 * <p>
 * The alignments default to {@link Align#LEFT}
 * </p>
 *
 * @param columnAlignments the Column alignments array.
 * @return this (for method chaining)
 * @see Table#setColumnAlignments(Table.Align...)
 */
public S withColumnAlignments(Table.Align... columnAlignments);
 
Example #15
Source File: FluentTable.java    From viritin with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the specified column's alignment.
 *
 * <p>
 * Throws IllegalArgumentException if the alignment is not one of the
 * following: {@link Align#LEFT}, {@link Align#CENTER} or
 * {@link Align#RIGHT}
 * </p>
 *
 * @param propertyId the propertyID identifying the column.
 * @param alignment the desired alignment.
 * @return this (for method chaining)
 * @see Table#setColumnAlignment(java.lang.Object, Table.Align)
 */
public S withColumnAlignment(Object propertyId, Table.Align alignment);
 
Example #16
Source File: FluentTable.java    From viritin with Apache License 2.0 2 votes vote down vote up
/**
 * Setter for property columnHeaderMode.
 *
 * @param columnHeaderMode the New value of property columnHeaderMode.
 * @return this (for method chaining)
 * @see Table#setColumnHeaderMode(Table.ColumnHeaderMode)
 */
public S withColumnHeaderMode(Table.ColumnHeaderMode columnHeaderMode);
 
Example #17
Source File: MultiSelectTable.java    From viritin with Apache License 2.0 2 votes vote down vote up
/**
 * @return the underlaying table implementation. Note that the component
 * heavily relies on some features so changing some of the configuration
 * options in Table is unsafe.
 */
public Table getTable() {
    return table;
}
 
Example #18
Source File: FluentTable.java    From viritin with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the row header mode.
 * <p>
 * The mode can be one of the following ones:
 * </p>
 * <ul>
 * <li>{@link Table#ROW_HEADER_MODE_HIDDEN}: The row captions are hidden.</li>
 * <li>{@link Table#ROW_HEADER_MODE_ID}: Items Id-objects <code>toString()</code>
 * is used as row caption.
 * <li>{@link Table#ROW_HEADER_MODE_ITEM}: Item-objects <code>toString()</code>
 * is used as row caption.
 * <li>{@link Table#ROW_HEADER_MODE_PROPERTY}: Property set with
 * {@link Table#setItemCaptionPropertyId(Object)} is used as row header.
 * <li>{@link Table#ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID}: Items Id-objects
 * <code>toString()</code> is used as row header. If caption is explicitly
 * specified, it overrides the id-caption.
 * <li>{@link Table#ROW_HEADER_MODE_EXPLICIT}: The row headers must be explicitly
 * specified.</li>
 * <li>{@link Table#ROW_HEADER_MODE_INDEX}: The index of the item is used as row
 * caption. The index mode can only be used with the containers implementing
 * <code>Container.Indexed</code> interface.</li>
 * </ul>
 * <p>
 * The default value is {@link Table#ROW_HEADER_MODE_HIDDEN}
 * </p>
 *
 * @param mode the One of the modes listed above.
 * @return this (for method chaining)
 * @see Table#setRowHeaderMode(Table.RowHeaderMode)
 */
public S withRowHeaderMode(Table.RowHeaderMode mode);
 
Example #19
Source File: FluentTable.java    From viritin with Apache License 2.0 2 votes vote down vote up
/**
 * Adds a new property to the table and show it as a visible column.
 *
 * @param propertyId the Id of the property
 * @param type the class of the property
 * @param defaultValue the default value given for all existing items
 * @param columnHeader the Explicit header of the column. If explicit header
 * is not needed, this should be set null.
 * @param columnIcon the Icon of the column. If icon is not needed, this
 * should be set null.
 * @param columnAlignment the Alignment of the column. Null implies align
 * left.
 * @return this (for method chaining)
 * @throws UnsupportedOperationException if the operation is not supported.
 * @see Container#addContainerProperty(Object, Class,
 * Object)
 * @see Table#addContainerProperty(java.lang.Object, java.lang.Class,
 * java.lang.Object, java.lang.String, Resource,
 * Table.Align)
 */
public S withContainerProperty(Object propertyId, Class<?> type,
        Object defaultValue, String columnHeader, Resource columnIcon,
        Table.Align columnAlignment);
 
Example #20
Source File: FluentTable.java    From viritin with Apache License 2.0 2 votes vote down vote up
/**
 * Adds a column collapse listener to the Table. A column collapse listener
 * is called when the collapsed state of a column changes.
 *
 * @param listener The listener to attach
 * @return this (for method chaining)
 * @see
 * Table#addColumnCollapseListener(Table.ColumnCollapseListener)
 */
public S withColumnCollapseListener(Table.ColumnCollapseListener listener);
 
Example #21
Source File: FluentTable.java    From viritin with Apache License 2.0 2 votes vote down vote up
/**
 * Adds a column reorder listener to the Table. A column reorder listener is
 * called when a user reorders columns.
 *
 * @param listener The listener to attach to the Table
 * @return this (for method chaining)
 * @see
 * Table#addColumnReorderListener(Table.ColumnReorderListener)
 */
public S withColumnReorderListener(Table.ColumnReorderListener listener);
 
Example #22
Source File: FluentTable.java    From viritin with Apache License 2.0 2 votes vote down vote up
/**
 * Adds a column resize listener to the Table. A column resize listener is
 * called when a user resizes a columns width.
 *
 * @param listener The listener to attach to the Table
 * @return this (for method chaining)
 * @see
 * Table#addColumnResizeListener(Table.ColumnResizeListener)
 */
public S withColumnResizeListener(Table.ColumnResizeListener listener);
 
Example #23
Source File: FluentTable.java    From viritin with Apache License 2.0 2 votes vote down vote up
/**
 * Adds a header click listener which handles the click events when the user
 * clicks on a column header cell in the Table.
 * <p>
 * The listener will receive events which contain information about which
 * column was clicked and some details about the mouse event.
 * </p>
 *
 * @param listener The handler which should handle the header click events.
 * @return this (for method chaining)
 * @see
 * Table#addHeaderClickListener(Table.HeaderClickListener)
 */
public S withHeaderClickListener(Table.HeaderClickListener listener);
 
Example #24
Source File: FluentTable.java    From viritin with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the drag start mode of the Table. Drag start mode controls how Table
 * behaves as a drag source.
 *
 * @param newDragMode The drag mode
 * @return this (for method chaining)
 * @see Table#setDragMode(Table.TableDragMode)
 */
public S withDragMode(Table.TableDragMode newDragMode);
 
Example #25
Source File: FluentTable.java    From viritin with Apache License 2.0 2 votes vote down vote up
/**
 * Set cell style generator for Table.
 *
 * @param cellStyleGenerator New cell style generator or null to remove
 * generator.
 * @return this (for method chaining)
 * @see Table#setCellStyleGenerator(Table.CellStyleGenerator)
 */
public S withCellStyleGenerator(Table.CellStyleGenerator cellStyleGenerator);
 
Example #26
Source File: FluentTable.java    From viritin with Apache License 2.0 2 votes vote down vote up
/**
 * Adds a generated column to the Table.
 * <p>
 * A generated column is a column that exists only in the Table, not as a
 * property in the underlying Container. It shows up just as a regular
 * column.
 * </p>
 * <p>
 * A generated column will override a property with the same id, so that the
 * generated column is shown instead of the column representing the
 * property. Note that getContainerProperty() will still get the real
 * property.
 * </p>
 * <p>
 * Table will not listen to value change events from properties overridden
 * by generated columns. If the content of your generated column depends on
 * properties that are not directly visible in the table, attach value
 * change listener to update the content on all depended properties.
 * Otherwise your UI might not get updated as expected.
 * </p>
 * <p>
 * Also note that getVisibleColumns() will return the generated columns,
 * while getContainerPropertyIds() will not.
 * </p>
 *
 * @param id the id of the column to be added
 * @param generatedColumn the {@link ColumnGenerator} to use for this column
 * @return this (for method chaining)
 * @see Table#addGeneratedColumn(java.lang.Object,
 * Table.ColumnGenerator)
 */
public S withGeneratedColumn(Object id, Table.ColumnGenerator generatedColumn);
 
Example #27
Source File: IPagedTable.java    From mycollab with GNU Affero General Public License v3.0 votes vote down vote up
void addGeneratedColumn(Object id, Table.ColumnGenerator generatedColumn);