com.google.gwt.user.cellview.client.Column Java Examples

The following examples show how to use com.google.gwt.user.cellview.client.Column. 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: ColumnSortHandler.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void onColumnSort(ColumnSortEvent event) {
    // Get the sorted column.
    Column<?, ?> column = event.getColumn();
    if (column == null) {
        return;
    }

    // Get the comparator.
    final Comparator<T> comparator = comparators.get(column);
    if (comparator == null) {
        return;
    }

    // Sort using the comparator.
    if (event.isSortAscending()) {
        Collections.sort(list, comparator);
    } else {
        Collections.sort(list, new Comparator<T>() {
            public int compare(T o1, T o2) {
                return -comparator.compare(o1, o2);
            }
        });
    }
}
 
Example #3
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 #4
Source File: MechanismProviderFilteringSaslServerFilterEditor.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private Column<ModelNode, String> createColumn(String attributeName) {
    return new TextColumn<ModelNode>() {
        @Override
        public String getValue(ModelNode node) {
            String val = "";
            if (node.hasDefined(attributeName)) {
                val = node.get(attributeName).asString();
            } else {
                ModelNode attributeDescription = resourceDescription.get(ATTRIBUTES).get("filters").get(VALUE_TYPE)
                        .get(attributeName);
                if (attributeDescription.hasDefined(DEFAULT)) {
                    val = attributeDescription.get(DEFAULT).asString();
                }
            }
            return val;
        }
    };
}
 
Example #5
Source File: ConstantPermissionMappingEditor.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> classNameColumn = createColumn("class-name");
    Column<ModelNode, String> moduleColumn = createColumn("module");
    Column<ModelNode, String> targetNameColumn = createColumn("target-name");
    Column<ModelNode, String> actionColumn = createColumn("action");
    classNameColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    moduleColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    targetNameColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    actionColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    table.addColumn(classNameColumn, "Class name");
    table.addColumn(moduleColumn, "Module");
    table.addColumn(targetNameColumn, "Target name");
    table.addColumn(actionColumn, "Action");
    table.setColumnWidth(classNameColumn, 40, Style.Unit.PCT);
    table.setColumnWidth(moduleColumn, 20, Style.Unit.PCT);
    table.setColumnWidth(targetNameColumn, 25, Style.Unit.PCT);
    table.setColumnWidth(actionColumn, 15, Style.Unit.PCT);
}
 
Example #6
Source File: SimplePermissionMappingEditor.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void setupPermissionsTable() {
    tablePermissions = new DefaultCellTable<>(5);

    Column<ModelNode, String> className = createColumn ("class-name");
    Column<ModelNode, String> module = createColumn ("module");
    Column<ModelNode, String> targetName = createColumn ("target-name");
    Column<ModelNode, String> action = createColumn ("action");
    tablePermissions.addColumn(className, "Class name");
    tablePermissions.addColumn(module, "Module");
    tablePermissions.addColumn(targetName, "Target name");
    tablePermissions.addColumn(action, "Action");
    dataProviderPermissions = new ListDataProvider<>();
    dataProviderPermissions.addDataDisplay(tablePermissions);

    popupDialogOptions.showCancel(false);
    permissionPopupLayout.setStyleName("window-content");
    permissionPopupLayout.add(tablePermissions);
}
 
Example #7
Source File: SimplePermissionMappingEditor.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Column<ModelNode, String> createColumn(String attribute) {
    return new TextColumn<ModelNode>() {
        @Override
        public String getValue(ModelNode node) {
            return node.hasDefined(attribute) ? node.get(attribute).asString().replaceAll("\\[|\"|\\]", ""): "";
        }
    };
}
 
Example #8
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 #9
Source File: ConstantPermissionMappingEditor.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Column<ModelNode, String> createColumn(String attributeName) {
    return new TextColumn<ModelNode>() {
        @Override
        public String getValue(ModelNode node) {
            return node.hasDefined(attributeName) ? node.get(attributeName).asString() : "";
        }
    };
}
 
Example #10
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 #11
Source File: SimplePermissionMappingEditor.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void setupTable() {
    table = new DefaultCellTable<>(5);
    table.setSelectionModel(selectionModel);

    // columns
    Column<ModelNode, String> matchAll = createColumn("match-all");
    Column<ModelNode, String> principals = createColumn("principals");
    Column<ModelNode, String> roles = createColumn(ROLES);
    Column<ModelNode, ModelNode> linkOpenDetailsColumn = new Column<ModelNode, ModelNode>(
            new ViewLinkCell<>(Console.CONSTANTS.common_label_view(), this::showDetailModal)) {
        @Override
        public ModelNode getValue(ModelNode node) {
            return node;
        }
    };

    matchAll.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    principals.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    roles.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    linkOpenDetailsColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    table.addColumn(matchAll, "Match All");
    table.addColumn(principals, "Principals");
    table.addColumn(roles, "Roles");
    table.addColumn(linkOpenDetailsColumn, "Permissions");
    table.setColumnWidth(matchAll, 20, Style.Unit.PCT);
    table.setColumnWidth(principals, 30, Style.Unit.PCT);
    table.setColumnWidth(roles, 30, Style.Unit.PCT);
    table.setColumnWidth(linkOpenDetailsColumn, 20, Style.Unit.PCT);
}
 
Example #12
Source File: IdentityAttributeMappingView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Column<ModelNode, String> createColumn(String attributeName) {
    Column<ModelNode, String> column = new TextColumn<ModelNode>() {
        @Override
        public String getValue(ModelNode node) {
            return node.hasDefined(attributeName) ? node.get(attributeName).asString() : "";
        }
    };
    column.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    return column;
}
 
Example #13
Source File: IdentityAttributeMappingView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SuppressWarnings("unchecked")
public Widget asWidget() {
    VerticalPanel panel = new VerticalPanel();
    panel.addStyleName("fill-layout-width");

    // table
    table = new DefaultCellTable<>(20);
    dataProvider = new ListDataProvider<>();
    dataProvider.addDataDisplay(table);
    table.setSelectionModel(selectionModel);

    // columns
    Column<ModelNode, String> fromColumn = createColumn("from");
    Column<ModelNode, String> toColumn = createColumn("to");
    Column<ModelNode, String> referenceColumn = createColumn("reference");
    Column<ModelNode, String> filterColumn = createColumn("filter");
    Column<ModelNode, String> filterBaseColumn = createColumn("filter-base-dn");
    Column<ModelNode, String> searchRecursiveColumn = createColumn("search-recursive");
    Column<ModelNode, String> roleRecursionColumn = createColumn("role-recursion");
    Column<ModelNode, String> roleRecursioNameColumn = createColumn("role-recursion-name");
    Column<ModelNode, String> extractDnColumn = createColumn("extract-rdn");
    table.addColumn(fromColumn, "From");
    table.addColumn(toColumn, "To");
    table.addColumn(referenceColumn, "Reference");
    table.addColumn(filterColumn, "Filter");
    table.addColumn(filterBaseColumn, "Filter Base DN");
    table.addColumn(searchRecursiveColumn, "Search Recursive");
    table.addColumn(roleRecursionColumn, "Role Recursion");
    table.addColumn(roleRecursioNameColumn, "Role Recursion Name");
    table.addColumn(extractDnColumn, "Extract RDN");

    panel.add(mainTableTools());
    panel.add(table);
    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);
    panel.add(pager);
    return panel;
}
 
Example #14
Source File: GenericListComplexAttribute.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Column<ModelNode, String> createColumn(String attributeName) {
    return new TextColumn<ModelNode>() {
        @Override
        public String getValue(ModelNode node) {
            return node.hasDefined(attributeName) ? node.get(attributeName).asString() : "";
        }
    };
}
 
Example #15
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 #16
Source File: SecurityDomainRealmEditor.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Column<ModelNode, String> createColumn(String attributeName) {
    return new TextColumn<ModelNode>() {
        @Override
        public String getValue(ModelNode node) {
            return node.hasDefined(attributeName) ? node.get(attributeName).asString() : "";
        }
    };
}
 
Example #17
Source File: ConnectorServiceList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings("unchecked")
Widget asWidget() {
    serverName = new ContentHeaderLabel();

    table = new DefaultCellTable<>(10, ActivemqConnectorService::getName);

    provider = new ListDataProvider<>();
    provider.addDataDisplay(table);

    Column<ActivemqConnectorService, String> name = new Column<ActivemqConnectorService, String>(new TextCell()) {
        @Override
        public String getValue(ActivemqConnectorService object) {
            return object.getName();
        }
    };

    table.addColumn(name, "Name");

    ToolStrip tools = new ToolStrip();
    tools.addToolButtonRight(
            new ToolButton(Console.CONSTANTS.common_label_add(),
                    clickEvent -> presenter.launchNewConnectorServiceWizard()));

    tools.addToolButtonRight(
            new ToolButton(Console.CONSTANTS.common_label_remove(), clickEvent -> Feedback.confirm(
                    Console.MESSAGES.deleteTitle("ConnectorService"),
                    Console.MESSAGES.deleteConfirm("ConnectorService " + getSelectedEntity().getName()),
                    isConfirmed -> {
                        if (isConfirmed) {
                            presenter.onDeleteConnectorService(getSelectedEntity());
                        }
                    })));

    connectorServiceForm = new ConnectorServiceForm(presenter,
            new FormToolStrip.FormCallback<ActivemqConnectorService>() {
                @Override
                public void onSave(Map<String, Object> changeset) {
                    presenter.onSaveConnectorService(getSelectedEntity(), changeset);
                }

                @Override
                public void onDelete(ActivemqConnectorService entity) {
                }
            });

    properties = new PropertyEditor(presenter, true);

    MultipleToOneLayout layout = new MultipleToOneLayout()
            .setPlain(true)
            .setHeadlineWidget(serverName)
            .setDescription(Console.CONSTANTS.jmsConnectorServiceDescription())
            .setMaster(Console.MESSAGES.available("Services"), table)
            .setMasterTools(tools)
            .addDetail(Console.CONSTANTS.common_label_details(), connectorServiceForm.asWidget())
            .addDetail(Console.CONSTANTS.common_label_properties(), properties.asWidget());

    connectorServiceForm.getForm().bind(table);

    table.getSelectionModel().addSelectionChangeHandler(selectionChangeEvent -> {
        List<PropertyRecord> props = getSelectedEntity().getParameter();

        String tokens = "connector-service_#_" + getSelectedEntity().getName();
        properties.setProperties(tokens, props);
    });

    return layout.build();

}
 
Example #18
Source File: ConnectorList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings("unchecked")
Widget asWidget() {
    serverName = new ContentHeaderLabel();

    table = new DefaultCellTable<>(10, ActivemqConnector::getName);
    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);

    provider = new ListDataProvider<>();
    provider.addDataDisplay(table);

    Column<ActivemqConnector, String> name = new Column<ActivemqConnector, String>(new TextCell()) {
        @Override
        public String getValue(ActivemqConnector object) {
            return object.getName();
        }
    };

    table.addColumn(name, "Name");

    ToolStrip tools = new ToolStrip();
    tools.addToolButtonRight(
            new ToolButton(Console.CONSTANTS.common_label_add(),
                    clickEvent -> presenter.launchNewConnectorWizard(type)));

    tools.addToolButtonRight(
            new ToolButton(Console.CONSTANTS.common_label_remove(), clickEvent -> Feedback.confirm(
                    Console.MESSAGES.deleteTitle("Connector"),
                    Console.MESSAGES.deleteConfirm("Connector " + getSelectedEntity().getSocketBinding()),
                    isConfirmed -> {
                        if (isConfirmed) {
                            presenter.onDeleteConnector(getSelectedEntity());
                        }
                    })));

    connectorForm = new ConnectorForm(presenter, new FormToolStrip.FormCallback<ActivemqConnector>() {
        @Override
        public void onSave(Map<String, Object> changeset) {
            presenter.onSaveConnector(getSelectedEntity(), changeset);
        }

        @Override
        public void onDelete(ActivemqConnector entity) {}
    }, type);

    properties = new PropertyEditor(presenter, true);

    VerticalPanel layout = new VerticalPanel();
    layout.add(tools);
    layout.add(table);
    layout.add(pager);

    connectorForm.getForm().bind(table);

    TabPanel tabs = new TabPanel();
    tabs.setStyleName("default-tabpanel");
    tabs.getElement().setAttribute("style", "margin-top:15px;");
    tabs.addStyleName("master_detail-detail");

    tabs.add(connectorForm.asWidget(), Console.CONSTANTS.common_label_details());
    tabs.add(properties.asWidget(), Console.CONSTANTS.common_label_properties());

    layout.add(tabs);
    tabs.selectTab(0);

    table.getSelectionModel().addSelectionChangeHandler(selectionChangeEvent -> {
        List<PropertyRecord> props = getSelectedEntity().getParameter();
        String tokens = getSelectedEntity().getType().getResource() + "_#_" + getSelectedEntity().getName();
        properties.setProperties(tokens, props);
    });

    return layout;
}
 
Example #19
Source File: AcceptorList.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings("unchecked")
Widget asWidget() {
    serverName = new ContentHeaderLabel();
    table = new DefaultCellTable<>(10, ActivemqAcceptor::getName);
    DefaultPager pager = new DefaultPager();
    pager.setDisplay(table);

    provider = new ListDataProvider<>();
    provider.addDataDisplay(table);

    Column<ActivemqAcceptor, String> name = new Column<ActivemqAcceptor, String>(new TextCell()) {
        @Override
        public String getValue(ActivemqAcceptor object) {
            return object.getName();
        }
    };
    table.addColumn(name, "Name");

    ToolStrip tools = new ToolStrip();
    tools.addToolButtonRight(
            new ToolButton(Console.CONSTANTS.common_label_add(),
                    clickEvent -> presenter.launchNewAcceptorWizard(type)));

    tools.addToolButtonRight(
            new ToolButton(Console.CONSTANTS.common_label_remove(), clickEvent -> Feedback.confirm(
                    Console.MESSAGES.deleteTitle("Acceptor"),
                    Console.MESSAGES.deleteConfirm("Acceptor " + getSelectedEntity().getSocketBinding()),
                    isConfirmed -> {
                        if (isConfirmed) {
                            presenter.onDeleteAcceptor(getSelectedEntity());
                        }
                    })));

    acceptorForm = new AcceptorForm(presenter, new FormToolStrip.FormCallback<ActivemqAcceptor>() {
        @Override
        public void onSave(Map<String, Object> changeset) {
            presenter.onSaveAcceptor(getSelectedEntity(), changeset);
        }

        @Override
        public void onDelete(ActivemqAcceptor entity) {}
    }, type);

    properties = new PropertyEditor(presenter, true);

    VerticalPanel layout = new VerticalPanel();
    layout.add(tools);
    layout.add(table);
    layout.add(pager);

    acceptorForm.getForm().bind(table);

    TabPanel tabs = new TabPanel();
    tabs.setStyleName("default-tabpanel");
    tabs.addStyleName("master_detail-detail");
    tabs.getElement().setAttribute("style", "margin-top:15px;");

    tabs.add(acceptorForm.asWidget(), Console.CONSTANTS.common_label_details());
    tabs.add(properties.asWidget(), Console.CONSTANTS.common_label_properties());

    layout.add(tabs);
    tabs.selectTab(0);

    table.getSelectionModel().addSelectionChangeHandler(selectionChangeEvent -> {
        List<PropertyRecord> props = getSelectedEntity().getParameter();
        String tokens = getSelectedEntity().getType().getResource() + "_#_" + getSelectedEntity().getName();
        properties.setProperties(tokens, props);
    });

    return layout;
}
 
Example #20
Source File: AddressingDetails.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SuppressWarnings("unchecked")
Widget asWidget() {
    addrTable = new DefaultCellTable<>(8, ActivemqAddressingPattern::getPattern);
    addrProvider = new ListDataProvider<>();
    addrProvider.addDataDisplay(addrTable);

    Column<ActivemqAddressingPattern, String> patternColumn = new Column<ActivemqAddressingPattern, String>(new TextCell()) {
        @Override
        public String getValue(ActivemqAddressingPattern object) {
            return object.getPattern();
        }
    };

    addrTable.addColumn(patternColumn, "Pattern");

    form = new Form<>(ActivemqAddressingPattern.class,
            "{selected.profile}/subsystem=messaging-activemq/server=*/address-setting=*");
    form.setNumColumns(2);
    form.bind(addrTable);

    TextBoxItem dlQ = new TextBoxItem("deadLetterQueue", "Dead Letter Address");
    TextBoxItem expQ = new TextBoxItem("expiryQueue", "Expiry Address");
    NumberBoxItem redelivery = new NumberBoxItem("redeliveryDelay", "Redelivery Delay");
    NumberBoxItem maxDelivery = new NumberBoxItem("maxDelivery", "Max Delivery Attempts", -1, Integer.MAX_VALUE);

    form.setFields(dlQ, expQ, redelivery, maxDelivery);

    FormHelpPanel helpPanel = new FormHelpPanel(() -> {
        ModelNode address = Baseadress.get();
        address.add("subsystem", "messaging-activemq");
        address.add("server", presenter.getCurrentServer());
        address.add("address-setting", "*");
        return address;
    }, form);

    FormToolStrip<ActivemqAddressingPattern> formTools = new FormToolStrip<>(
            form,
            new FormToolStrip.FormCallback<ActivemqAddressingPattern>() {
                @Override
                public void onSave(Map<String, Object> changeset) {
                    presenter.onSaveAddressDetails(form.getEditedEntity(), changeset);
                }

                @Override
                public void onDelete(ActivemqAddressingPattern entity) {}
            }
    );
    ToolStrip tableTools = new ToolStrip();
    ToolButton addBtn = new ToolButton(Console.CONSTANTS.common_label_add(),
            event -> presenter.launchNewAddrDialogue());
    addBtn.ensureDebugId(Console.DEBUG_CONSTANTS.debug_label_add_addressingDetails());
    tableTools.addToolButtonRight(addBtn);

    ToolButton removeBtn = new ToolButton(Console.CONSTANTS.common_label_delete(), event -> Feedback.confirm(
            Console.MESSAGES.deleteTitle("Addressing Config"),
            Console.MESSAGES.deleteConfirm("Addressing Config"),
            isConfirmed -> {
                if (isConfirmed) { presenter.onDeleteAddressDetails(form.getEditedEntity()); }
            }));

    tableTools.addToolButtonRight(removeBtn);

    VerticalPanel formPanel = new VerticalPanel();
    formPanel.addStyleName("fill-layout-width");

    formPanel.add(helpPanel.asWidget());
    formPanel.add(formTools.asWidget());
    formPanel.add(form.asWidget());

    serverName = new ContentHeaderLabel();

    MultipleToOneLayout layout = new MultipleToOneLayout()
            .setPlain(true)
            .setHeadlineWidget(serverName)
            .setDescription(
                    Console.CONSTANTS.addressingDescription())
            .setMaster(Console.MESSAGES.available("Address Settings"), addrTable)
            .setMasterTools(tableTools.asWidget())
            .setDetail(Console.CONSTANTS.common_label_details(), formPanel);

    return layout.build();

}
 
Example #21
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;
}
 
Example #22
Source File: ListEditor.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Widget asWidget() {
        VerticalPanel panel = new VerticalPanel();
        panel.addStyleName("fill-layout-width");

        listTable = new DefaultCellTable<T>(numRows);
        listTable.getElement().setAttribute("style", "margin-top:5px;");
        listProvider = new ListDataProvider<T>();
        listProvider.addDataDisplay(listTable);

        ToolStrip itemTools = new ToolStrip();

        addItem = new ToolButton(Console.CONSTANTS.common_label_add());

        addItem.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                if(ListEditor.this.enabled)
                    listManager.launchNewItemDialoge();
            }
        });
        addItem.ensureDebugId(Console.DEBUG_CONSTANTS.debug_label_add_listEditor());
        itemTools.addToolButtonRight(addItem);

        panel.add(itemTools);

        //       ColumnSortEvent.ListHandler<T> sortHandler =
        //               new ColumnSortEvent.ListHandler<T>(listProvider.getList());

        // Create columns
        Column<T, String> valueColumn = new Column<T, String>(new TextCell()) {

            @Override
            public String getValue(T object) {
                return object.toString();
            }

        };
        //      valueColumn.setSortable(true);

        Column<T, T> removeCol = new Column<T, T>(
                new TextLinkCell<T>(I18n.CONSTANTS.common_label_delete(), new ActionCell.Delegate<T>() {
                    @Override
                    public void execute(final T o) {
                        Feedback.confirm(
                                Console.MESSAGES.deleteTitle(Console.CONSTANTS.common_label_item()),
                                Console.MESSAGES.deleteConfirm(Console.CONSTANTS.common_label_item())
                                , new Feedback.ConfirmationHandler() {
                            @Override
                            public void onConfirmation(boolean isConfirmed) {
                                if (isConfirmed)
                                     listManager.onDeleteItem(o);
                            }
                        });


                    }
                })
        ) {
            @Override
            public T getValue(T item) {
                return item;
            }
        };

        // Add the columns.
        listTable.addColumn(valueColumn, this.headerLabel);

        listTable.addColumn(removeCol, Console.CONSTANTS.common_label_option());


        listTable.setColumnWidth(valueColumn, 30, Style.Unit.PCT);

        listTable.setColumnWidth(removeCol, 20, Style.Unit.PCT);

//        listTable.addColumnSortHandler(sortHandler);
        listTable.getColumnSortList().push(valueColumn);

        if(helpText!=null)
        {
            StaticHelpPanel helpPanel = new StaticHelpPanel(helpText);
            panel.add(helpPanel.asWidget());
        }

        panel.add(listTable);

        DefaultPager pager = new DefaultPager();
        pager.setDisplay(listTable);

        panel.add(pager);

        return panel;
    }
 
Example #23
Source File: ColumnSortHandler.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void setComparator(Column<T, ?> column, Comparator<T> comparator) {
    comparators.put(column, comparator);
}