Search in sources :

Example 1 with TextInputCell

use of com.google.gwt.cell.client.TextInputCell in project ovirt-engine by oVirt.

the class MultipleHostsPopupView method initTableColumns.

private void initTableColumns() {
    Column<EntityModel, String> nameColumn = new Column<EntityModel, String>(new TextInputCell()) {

        @Override
        public String getValue(EntityModel object) {
            return ((HostDetailModel) object.getEntity()).getName();
        }
    };
    // $NON-NLS-1$
    hostsTable.addColumn(nameColumn, constants.nameHost(), "50px");
    nameColumn.setFieldUpdater((index, object, value) -> ((HostDetailModel) object.getEntity()).setName(value));
    hostsTable.addColumn(new AbstractEntityModelTextColumn<HostDetailModel>() {

        @Override
        public String getText(HostDetailModel hostModel) {
            return hostModel.getAddress();
        }
    }, constants.ipHost(), // $NON-NLS-1$
    "100px");
    Column<EntityModel, String> passwordColumn = new Column<EntityModel, String>(new PasswordTextInputCell()) {

        @Override
        public String getValue(EntityModel object) {
            return ((HostDetailModel) object.getEntity()).getPassword();
        }
    };
    // $NON-NLS-1$
    hostsTable.addColumn(passwordColumn, constants.hostPopupPasswordLabel(), "100px");
    passwordColumn.setFieldUpdater((index, object, value) -> ((HostDetailModel) object.getEntity()).setPassword(value));
    hostsTable.addColumn(new AbstractEntityModelTextColumn<HostDetailModel>() {

        @Override
        public String getText(HostDetailModel hostModel) {
            return hostModel.getFingerprint();
        }
    }, constants.hostsPopupFingerprint(), // $NON-NLS-1$
    "300px");
}
Also used : PasswordTextInputCell(org.ovirt.engine.ui.common.widget.table.cell.PasswordTextInputCell) HostDetailModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel) AbstractEntityModelTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEntityModelTextColumn) Column(com.google.gwt.user.cellview.client.Column) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) TextInputCell(com.google.gwt.cell.client.TextInputCell) PasswordTextInputCell(org.ovirt.engine.ui.common.widget.table.cell.PasswordTextInputCell)

Example 2 with TextInputCell

use of com.google.gwt.cell.client.TextInputCell in project perun by CESNET.

the class GetAttributesDefinition method getTable.

/**
 * Returns table widget with attributes definitions
 *
 * @return table widget
 */
public CellTable<AttributeDefinition> getTable() {
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<AttributeDefinition>(list);
    // Cell table
    table = new PerunTable<AttributeDefinition>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<AttributeDefinition> columnSortHandler = new ListHandler<AttributeDefinition>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<AttributeDefinition>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("No attribute defined in Perun.");
    // checkbox column column
    if (checkable) {
        table.addCheckBoxColumn();
    }
    // ID COLUMN
    table.addIdColumn("Attr ID", tableFieldUpdater, 100);
    // FRIENDLY NAME COLUMN
    final Column<AttributeDefinition, AttributeDefinition> friendlyNameColumn = JsonUtils.addColumn(new PerunAttributeFriendlyNameCell((tableFieldUpdater != null) ? "customClickableTextCell" : ""), new JsonUtils.GetValue<AttributeDefinition, AttributeDefinition>() {

        public AttributeDefinition getValue(AttributeDefinition object) {
            return object;
        }
    }, (tableFieldUpdater != null) ? new FieldUpdater<AttributeDefinition, AttributeDefinition>() {

        @Override
        public void update(int index, AttributeDefinition object, AttributeDefinition value) {
            // pass field updater to original one
            if (tableFieldUpdater != null)
                tableFieldUpdater.update(index, object, value.getFriendlyName());
        }
    } : null);
    // ENTITY COLUMN
    final Column<AttributeDefinition, String> entityColumn = JsonUtils.addColumn(new JsonUtils.GetValue<AttributeDefinition, String>() {

        public String getValue(AttributeDefinition object) {
            return object.getEntity();
        }
    }, tableFieldUpdater);
    // DEFINITION COLUMN
    final Column<AttributeDefinition, String> definitionColumn = JsonUtils.addColumn(new JsonUtils.GetValue<AttributeDefinition, String>() {

        public String getValue(AttributeDefinition object) {
            return object.getDefinition();
        }
    }, tableFieldUpdater);
    // TYPE COLUMN
    final Column<AttributeDefinition, String> typeColumn = JsonUtils.addColumn(new JsonUtils.GetValue<AttributeDefinition, String>() {

        public String getValue(AttributeDefinition object) {
            if (object.getType() != null) {
                return object.getType().substring(object.getType().lastIndexOf(".") + 1);
            }
            return "";
        }
    }, tableFieldUpdater);
    // UNIQUE COLUMN
    final Column<AttributeDefinition, String> uniqueColumn = JsonUtils.addColumn(new JsonUtils.GetValue<AttributeDefinition, String>() {

        public String getValue(AttributeDefinition object) {
            return String.valueOf(object.isUnique());
        }
    }, tableFieldUpdater);
    // DESCRIPTION COLUMN
    final Column<AttributeDefinition, String> descriptionColumn = new Column<AttributeDefinition, String>(new TextInputCell()) {

        public String getValue(AttributeDefinition attrDef) {
            if (attrDef.getDescription() == null) {
                return "";
            } else {
                return attrDef.getDescription();
            }
        }
    };
    descriptionColumn.setFieldUpdater(new FieldUpdater<AttributeDefinition, String>() {

        @Override
        public void update(int i, final AttributeDefinition attributeDefinition, final String s) {
            attributeDefinition.setDescription(s.trim());
            selectionModel.setSelected(attributeDefinition, true);
        }
    });
    // DISPLAY NAME COLUMN
    final Column<AttributeDefinition, String> displayNameColumn = new Column<AttributeDefinition, String>(new TextInputCell()) {

        public String getValue(AttributeDefinition attrDef) {
            return attrDef.getDisplayName();
        }
    };
    displayNameColumn.setFieldUpdater(new FieldUpdater<AttributeDefinition, String>() {

        @Override
        public void update(int i, final AttributeDefinition attributeDefinition, final String s) {
            attributeDefinition.setDisplayName(s.trim());
            selectionModel.setSelected(attributeDefinition, true);
        }
    });
    friendlyNameColumn.setSortable(true);
    columnSortHandler.setComparator(friendlyNameColumn, new Comparator<AttributeDefinition>() {

        public int compare(AttributeDefinition o1, AttributeDefinition o2) {
            return o1.getFriendlyName().compareToIgnoreCase(o2.getFriendlyName());
        }
    });
    entityColumn.setSortable(true);
    columnSortHandler.setComparator(entityColumn, new Comparator<AttributeDefinition>() {

        public int compare(AttributeDefinition o1, AttributeDefinition o2) {
            return o1.getEntity().compareToIgnoreCase(o2.getEntity());
        }
    });
    definitionColumn.setSortable(true);
    columnSortHandler.setComparator(definitionColumn, new Comparator<AttributeDefinition>() {

        public int compare(AttributeDefinition o1, AttributeDefinition o2) {
            return o1.getDefinition().compareToIgnoreCase(o2.getDefinition());
        }
    });
    typeColumn.setSortable(true);
    columnSortHandler.setComparator(typeColumn, new Comparator<AttributeDefinition>() {

        public int compare(AttributeDefinition o1, AttributeDefinition o2) {
            return o1.getType().compareToIgnoreCase(o2.getType());
        }
    });
    uniqueColumn.setSortable(true);
    columnSortHandler.setComparator(uniqueColumn, new Comparator<AttributeDefinition>() {

        public int compare(AttributeDefinition o1, AttributeDefinition o2) {
            return String.valueOf(o1.isUnique()).compareToIgnoreCase(String.valueOf(o2.isUnique()));
        }
    });
    // Add the column sort handler.
    table.setColumnWidth(friendlyNameColumn, 250.0, Unit.PX);
    table.setColumnWidth(entityColumn, 100.0, Unit.PX);
    table.setColumnWidth(definitionColumn, 100.0, Unit.PX);
    table.setColumnWidth(typeColumn, 100.0, Unit.PX);
    table.setColumnWidth(uniqueColumn, 100.0, Unit.PX);
    // Add the columns.
    table.addColumn(friendlyNameColumn, "Name");
    // attributesTable.addColumn(namespaceColumn, "Namespace");
    table.addColumn(entityColumn, "Entity");
    table.addColumn(definitionColumn, "Definition");
    table.addColumn(typeColumn, "Type");
    table.addColumn(uniqueColumn, "Unique");
    if (editable) {
        table.addColumn(displayNameColumn, "Display name");
        table.addColumn(descriptionColumn, "Description");
    }
    return table;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) TextInputCell(com.google.gwt.cell.client.TextInputCell) AttributeDefinition(cz.metacentrum.perun.webgui.model.AttributeDefinition) PerunAttributeFriendlyNameCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeFriendlyNameCell) Column(com.google.gwt.user.cellview.client.Column)

Example 3 with TextInputCell

use of com.google.gwt.cell.client.TextInputCell in project perun by CESNET.

the class GetServicesPackages method getEmptyTable.

/**
 * Returns empty table of ServicePackages
 *
 * @return empty table widget
 */
public CellTable<ServicesPackage> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<ServicesPackage>(list);
    // Cell table
    table = new PerunTable<ServicesPackage>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<ServicesPackage> columnSortHandler = new ListHandler<ServicesPackage>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<ServicesPackage>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("There are no services packages.");
    // checkbox column column
    if (checkable) {
        table.addCheckBoxColumn();
    }
    table.addIdColumn("ServicesPackage Id", tableFieldUpdater, 110);
    if (!editable) {
        table.addNameColumn(tableFieldUpdater);
        table.addDescriptionColumn(tableFieldUpdater);
    } else {
        // NAME COLUMN
        final Column<ServicesPackage, String> nameColumn = new Column<ServicesPackage, String>(new TextInputCell()) {

            public String getValue(ServicesPackage object) {
                return object.getName();
            }
        };
        nameColumn.setFieldUpdater(new FieldUpdater<ServicesPackage, String>() {

            @Override
            public void update(int i, final ServicesPackage object, final String s) {
                object.setName(s.trim());
                selectionModel.setSelected(object, true);
            }
        });
        nameColumn.setSortable(true);
        columnSortHandler.setComparator(nameColumn, new Comparator<ServicesPackage>() {

            public int compare(ServicesPackage o1, ServicesPackage o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });
        // DESCRIPTION COLUMN
        final Column<ServicesPackage, String> descriptionColumn = new Column<ServicesPackage, String>(new TextInputCell()) {

            public String getValue(ServicesPackage object) {
                return object.getDescription();
            }
        };
        descriptionColumn.setFieldUpdater(new FieldUpdater<ServicesPackage, String>() {

            @Override
            public void update(int i, final ServicesPackage object, final String s) {
                object.setDescription(s.trim());
                selectionModel.setSelected(object, true);
            }
        });
        descriptionColumn.setSortable(true);
        columnSortHandler.setComparator(descriptionColumn, new Comparator<ServicesPackage>() {

            public int compare(ServicesPackage o1, ServicesPackage o2) {
                return o1.getDescription().compareTo(o2.getDescription());
            }
        });
        // Link COLUMN
        final Column<ServicesPackage, String> linkColumn = new Column<ServicesPackage, String>(new CustomClickableTextCell()) {

            public String getValue(ServicesPackage object) {
                return "View services in package";
            }
        };
        linkColumn.setFieldUpdater(tableFieldUpdater);
        table.addColumn(nameColumn, "Name");
        table.setColumnWidth(nameColumn, "250px");
        table.addColumn(descriptionColumn, "Description");
        table.setColumnWidth(descriptionColumn, "250px");
        table.addColumn(linkColumn, "Manage services");
    }
    return table;
}
Also used : CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) TextInputCell(com.google.gwt.cell.client.TextInputCell) Column(com.google.gwt.user.cellview.client.Column) ServicesPackage(cz.metacentrum.perun.webgui.model.ServicesPackage)

Example 4 with TextInputCell

use of com.google.gwt.cell.client.TextInputCell in project perun by CESNET.

the class GetAllResourcesTags method getTable.

/**
 * Returns just the celltable
 * @return
 */
public CellTable<ResourceTag> getTable() {
    // retrieve data
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<ResourceTag>(list);
    // Cell table
    table = new PerunTable<ResourceTag>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<ResourceTag> columnSortHandler = new ListHandler<ResourceTag>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<ResourceTag>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity)) {
        loaderImage.setEmptyResultMessage("VO has no resource tags defined.");
    } else if (PerunEntity.RESOURCE.equals(entity)) {
        loaderImage.setEmptyResultMessage("Resource has no tags assigned.");
    }
    // columns
    if (checkable) {
        table.addCheckBoxColumn();
    }
    table.addIdColumn("Tag ID", tableFieldUpdater);
    if (editable) {
        // DISPLAY NAME COLUMN
        final Column<ResourceTag, String> nameColumn = new Column<ResourceTag, String>(new TextInputCell()) {

            public String getValue(ResourceTag tag) {
                return tag.getName();
            }
        };
        nameColumn.setFieldUpdater(new FieldUpdater<ResourceTag, String>() {

            @Override
            public void update(int i, final ResourceTag tag, final String s) {
                tag.setName(s.trim());
                selectionModel.setSelected(tag, true);
            }
        });
        nameColumn.setSortable(true);
        columnSortHandler.setComparator(nameColumn, new Comparator<ResourceTag>() {

            public int compare(ResourceTag arg0, ResourceTag arg1) {
                return (arg0.getName().compareToIgnoreCase(arg1.getName()));
            }
        });
        table.addColumn(nameColumn, "Tag name");
    } else {
        // name column
        Column<ResourceTag, String> nameColumn = JsonUtils.addColumn(new JsonUtils.GetValue<ResourceTag, String>() {

            public String getValue(ResourceTag object) {
                return object.getName();
            }
        }, tableFieldUpdater);
        nameColumn.setSortable(true);
        columnSortHandler.setComparator(nameColumn, new Comparator<ResourceTag>() {

            public int compare(ResourceTag arg0, ResourceTag arg1) {
                return (arg0.getName().compareToIgnoreCase(arg1.getName()));
            }
        });
        table.addColumn(nameColumn, "Tag name");
    }
    return table;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) TextInputCell(com.google.gwt.cell.client.TextInputCell) ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag) Column(com.google.gwt.user.cellview.client.Column)

Example 5 with TextInputCell

use of com.google.gwt.cell.client.TextInputCell in project ovirt-engine by oVirt.

the class GlusterClusterSnapshotConfigureOptionsPopupView method initEditors.

private void initEditors() {
    clusterEditor = new ListModelListBoxEditor<>(new NameRenderer<Cluster>());
    configsTable = new EntityModelCellTable<>(false, true);
    configsTable.setSelectionModel(new NoSelectionModel());
    configsTable.addColumn(new AbstractEntityModelTextColumn<GlusterVolumeSnapshotConfig>() {

        @Override
        public String getText(GlusterVolumeSnapshotConfig object) {
            return object.getParamName();
        }
    }, constants.volumeSnapshotConfigName(), // $NON-NLS-1$
    "200px");
    Column<EntityModel<GlusterVolumeSnapshotConfig>, String> valueColumn = new Column<EntityModel<GlusterVolumeSnapshotConfig>, String>(new TextInputCell()) {

        @Override
        public String getValue(EntityModel<GlusterVolumeSnapshotConfig> object) {
            return object.getEntity().getParamValue();
        }
    };
    // $NON-NLS-1$
    configsTable.addColumn(valueColumn, constants.volumeSnapshotConfigValue(), "100px");
    valueColumn.setFieldUpdater((index, object, value) -> object.getEntity().setParamValue(value));
}
Also used : GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig) AbstractEntityModelTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEntityModelTextColumn) Column(com.google.gwt.user.cellview.client.Column) NameRenderer(org.ovirt.engine.ui.common.widget.renderer.NameRenderer) NoSelectionModel(com.google.gwt.view.client.NoSelectionModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) TextInputCell(com.google.gwt.cell.client.TextInputCell)

Aggregations

TextInputCell (com.google.gwt.cell.client.TextInputCell)6 Column (com.google.gwt.user.cellview.client.Column)6 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)3 AbstractEntityModelTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractEntityModelTextColumn)3 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)3 NoSelectionModel (com.google.gwt.view.client.NoSelectionModel)2 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)1 AttributeDefinition (cz.metacentrum.perun.webgui.model.AttributeDefinition)1 ResourceTag (cz.metacentrum.perun.webgui.model.ResourceTag)1 ServicesPackage (cz.metacentrum.perun.webgui.model.ServicesPackage)1 CustomClickableTextCell (cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell)1 PerunAttributeFriendlyNameCell (cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeFriendlyNameCell)1 GlusterVolumeSnapshotConfig (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig)1 NameRenderer (org.ovirt.engine.ui.common.widget.renderer.NameRenderer)1 PasswordTextInputCell (org.ovirt.engine.ui.common.widget.table.cell.PasswordTextInputCell)1 VolumeSnapshotOptionModel (org.ovirt.engine.ui.uicommonweb.models.gluster.VolumeSnapshotOptionModel)1 HostDetailModel (org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel)1