Java Code Examples for com.google.gwt.user.cellview.client.Column#setSortable()

The following examples show how to use com.google.gwt.user.cellview.client.Column#setSortable() . 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: SecurityDomainRealmEditor.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void setupTable() {
    table = new DefaultCellTable<>(5);
    table.setSelectionModel(selectionModel);

    // columns
    Column<ModelNode, String> realmColumn = createColumn("realm");
    Column<ModelNode, String> principalTransformColumn = createColumn("principal-transformer");
    Column<ModelNode, String> roleDecoderColumn = createColumn("role-decoder");
    Column<ModelNode, String> roleMapperColumn = createColumn("role-mapper");
    realmColumn.setSortable(true);
    realmColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    principalTransformColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    roleDecoderColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    roleMapperColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    table.addColumn(realmColumn, "Realm");
    table.addColumn(principalTransformColumn, "Principal Transform");
    table.addColumn(roleDecoderColumn, "Role Decoder");
    table.addColumn(roleMapperColumn, "Role Mapper");
    table.setColumnWidth(realmColumn, 30, Style.Unit.PCT);
    table.setColumnWidth(principalTransformColumn, 30, Style.Unit.PCT);
    table.setColumnWidth(roleDecoderColumn, 20, Style.Unit.PCT);
    table.setColumnWidth(roleMapperColumn, 20, Style.Unit.PCT);
}
 
Example 2
Source File: MechanismProviderFilteringSaslServerFilterEditor.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void setupTable() {
    table = new DefaultCellTable<>(5, nameProvider);
    table.setSelectionModel(selectionModel);

    // columns
    Column<ModelNode, String> providerNameColumn = createColumn("provider-name");
    Column<ModelNode, String> mechanismNameColumn = createColumn("mechanism-name");
    Column<ModelNode, String> providerVersionColumn = createColumn("provider-version");
    Column<ModelNode, String> versionComparisonColumn = createColumn("version-comparison");
    providerNameColumn.setSortable(true);
    providerNameColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    mechanismNameColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    providerVersionColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    versionComparisonColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    table.addColumn(providerNameColumn, "Provider Name");
    table.addColumn(mechanismNameColumn, "Mechanism Name");
    table.addColumn(providerVersionColumn, "Provider Version");
    table.addColumn(versionComparisonColumn, "Version Comparison");
    table.setColumnWidth(providerNameColumn, 30, Style.Unit.PCT);
    table.setColumnWidth(mechanismNameColumn, 30, Style.Unit.PCT);
    table.setColumnWidth(providerVersionColumn, 20, Style.Unit.PCT);
    table.setColumnWidth(versionComparisonColumn, 20, Style.Unit.PCT);
}
 
Example 3
Source File: TableDisplayerView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
@Override
public void addColumn(ColumnType columnType, String columnId, String columnName, int index, boolean selectEnabled, boolean sortEnabled) {
    Column<Integer,?> column = createColumn(columnType, columnId, selectEnabled, index);
    if (column != null) {
        column.setSortable(sortEnabled);
        table.addColumn(column, columnName);
    }
}
 
Example 4
Source File: GenericListComplexAttribute.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void setupTable() {
    table = new DefaultCellTable<>(10);
    table.setSelectionModel(selectionModel);

    // columns
    for (Property propDescription: resourceDescription.get(ATTRIBUTES).asPropertyList()) {
        Column<ModelNode, String> column = createColumn(propDescription.getName());
        column.setSortable(true);
        column.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
        table.addColumn(column, label(propDescription.getName()));
    };
}
 
Example 5
Source File: GenericAliasEditor.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void setupTable() {
    table = new DefaultCellTable<>(10);
    table.setSelectionModel(selectionModel);

    Column<ModelNode, String> realmColumn = new TextColumn<ModelNode>() {
        @Override
        public String getValue(ModelNode prop) {
            return prop.asString();
        }
    };
    realmColumn.setSortable(true);
    table.addColumn(realmColumn, "Alias");
}
 
Example 6
Source File: PropertyEditor.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings("unchecked")
public Widget asWidget() {
    VerticalPanel panel = new VerticalPanel();
    panel.addStyleName("fill-layout-width");

    // table
    table = new DefaultCellTable<>(numRows, keyProvider);
    dataProvider = new ListDataProvider<>(keyProvider);
    dataProvider.addDataDisplay(table);
    final SingleSelectionModel<Property> selectionModel = new SingleSelectionModel<>(keyProvider);
    table.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(event -> {
        Property selection = selectionModel.getSelectedObject();
        if (selection == null) {
            propertyManager.onDeselect();
        } else {
            propertyManager.onSelect(selection);
        }
    });

    // columns
    Column<Property, String> keyColumn = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            return property.getName();
        }
    };
    keyColumn.setSortable(true);
    Column<Property, String> valueColumn;
    if (inlineEditing) {
        valueColumn = new Column<Property, String>(new DefaultEditTextCell()) { {
                setFieldUpdater((index, property, value) -> getPropertyValue(property).set(value));
            }

            @Override
            public String getValue(Property property) {
                return property.getValue().get(VALUE).asString();
            }
        };
    } else {
        valueColumn = new TextColumn<Property>() {
            @Override
            public String getValue(Property property) {
                return getPropertyValue(property).asString();
            }
        };
    }
    ColumnSortEvent.ListHandler<Property> sortHandler = new ColumnSortEvent.ListHandler<>(dataProvider.getList());
    sortHandler.setComparator(keyColumn, new Comparator<Property>() {
        @Override
        public int compare(Property o1, Property o2) {
            return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase());
        }
    });
    table.addColumn(keyColumn, Console.CONSTANTS.common_label_key());
    table.addColumn(valueColumn, Console.CONSTANTS.common_label_value());
    table.setColumnWidth(keyColumn, 40, Style.Unit.PCT);
    table.setColumnWidth(valueColumn, 60, Style.Unit.PCT);
    table.addColumnSortHandler(sortHandler);
    table.getColumnSortList().push(keyColumn);

    // tools
    if (!hideTools) {
        ToolStrip tools = new ToolStrip();
        addButton = new ToolButton(addLabel, event -> {
            addDialog.clearValues();
            propertyManager.openAddDialog(addDialog);
        });
        removeButton = new ToolButton(removeLabel, event -> {
            final Property selection = selectionModel.getSelectedObject();
            if (selection != null) {
                Feedback.confirm(Console.MESSAGES.removeProperty(),
                        Console.MESSAGES.removePropertyConfirm(selection.getName()),
                        new Feedback.ConfirmationHandler() {
                            @Override
                            public void onConfirmation(boolean isConfirmed) {
                                if (isConfirmed) {
                                    propertyManager.onRemove(selection);
                                }
                            }
                        });
            }
        });
        AddressTemplate effectiveAddress = operationAddress != null ? operationAddress : propertyManager
                .getAddress();
        if (effectiveAddress != null) {
            addButton.setOperationAddress(effectiveAddress.getTemplate(), propertyManager.getAddOperationName());
            removeButton
                    .setOperationAddress(effectiveAddress.getTemplate(), propertyManager.getRemoveOperationName());
        }
        tools.addToolButtonRight(addButton);
        tools.addToolButtonRight(removeButton);
        panel.add(tools);
    }

    panel.add(table);
    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);
    panel.add(pager);
    return panel;
}