Search in sources :

Example 6 with TextColumn

use of com.google.gwt.user.cellview.client.TextColumn in project perun by CESNET.

the class FindExternalPublications method getEmptyTable.

/**
 * Returns table with publications
 * @return table
 */
public CellTable<Publication> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<Publication>(list);
    // Cell table
    table = new PerunTable<Publication>(list);
    table.removeRowCountChangeHandler();
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<Publication> columnSortHandler = new ListHandler<Publication>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Publication>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage.prepareToSearch("Please select external pub. system and year range to search for publications for import."));
    loaderImage.setEmptyResultMessage("No publications found in external system.");
    // show checkbox column
    if (this.checkable) {
        table.addCheckBoxColumn();
    }
    /*
		// CATEGORY COLUMN
		ArrayList<String> categories = new ArrayList<String>();
		categories.add("Bodované v RIVu");
		categories.add("Nebodované v RIVu");
		categories.add("Příspěvek do ročenky");
		categories.add("Výjimečné výsledky");
		categories.add("Jiné");

		Column<Publication, String> categoryColumn = new Column<Publication, String>(new SelectionCell(categories)){
		@Override
		public String getValue(Publication object) {
		// category ID as string, 0 if not set
		int id = object.getCategoryId();
		if (id == 0) {
		// set default == 21/Bodované v RIVu to object
		object.setCategoryId(21);
		}
		if (id == 21) {
		return "Bodované v RIVu";
		} else if (id == 22) {
		return "Nebodované v RIVu";
		} else if (id == 23) {
		return "Výjimečné výsledky";
		} else if (id == 24) {
		return "Příspěvek do ročenky";
		} else if (id == 25) {
		return "Jiné";
		} else {
		return String.valueOf(id); // return ID if no match
		}
		}
		};
		categoryColumn.setFieldUpdater(new FieldUpdater<Publication, String>() {
		public void update(int index, Publication object, String value) {

		int id = 0;
		if (value.equalsIgnoreCase("Bodované v RIVu")) {
		id = 21;
		} else if (value.equalsIgnoreCase("Nebodované v RIVu")) {
		id = 22;
		} else if (value.equalsIgnoreCase("Příspěvek do ročenky")) {
		id = 24;
		} else if (value.equalsIgnoreCase("Výjimečné výsledky")) {
		id = 23;
		} else if (value.equalsIgnoreCase("Jiné")) {
		id = 25;
		}
		object.setCategoryId(id);
		selectionModel.setSelected(object, true);

		}
		});
		table.addColumn(categoryColumn, "Category");

		// NOT USEFULL => DISABLED
		// EXTERNAL ID
		TextColumn<Publication> externalIdColumn = new TextColumn<Publication>() {
		public String getValue(Publication object) {
		return String.valueOf(object.getExternalId());
		};
		};
		externalIdColumn.setSortable(true);
		columnSortHandler.setComparator(externalIdColumn, new PublicationComparator(PublicationComparator.Column.EXTERNAL_ID));
		table.addColumn(externalIdColumn, "External Id");
		*/
    // TITLE COLUMN
    TextColumn<Publication> titleColumn = new TextColumn<Publication>() {

        public String getValue(Publication object) {
            return object.getTitle();
        }
    };
    titleColumn.setSortable(true);
    columnSortHandler.setComparator(titleColumn, new PublicationComparator(PublicationComparator.Column.TITLE));
    table.addColumn(titleColumn, "Title");
    // AUTHORS COLUMN
    TextColumn<Publication> authorColumn = new TextColumn<Publication>() {

        public String getValue(Publication object) {
            return object.getAuthorsFormatted();
        }
    };
    authorColumn.setSortable(true);
    columnSortHandler.setComparator(authorColumn, new PublicationComparator(PublicationComparator.Column.AUTHORS));
    table.addColumn(authorColumn, "Authors");
    // YEAR COLUMN
    TextColumn<Publication> yearColumn = new TextColumn<Publication>() {

        public String getValue(Publication object) {
            return String.valueOf(object.getYear());
        }
    };
    yearColumn.setSortable(true);
    columnSortHandler.setComparator(yearColumn, new PublicationComparator(PublicationComparator.Column.YEAR));
    table.addColumn(yearColumn, "Year");
    // ISBN COLUMN
    TextColumn<Publication> isbnColumn = new TextColumn<Publication>() {

        public String getValue(Publication object) {
            return object.getIsbn();
        }
    };
    isbnColumn.setSortable(true);
    columnSortHandler.setComparator(isbnColumn, new PublicationComparator(PublicationComparator.Column.ISBN));
    table.addColumn(isbnColumn, "ISBN");
    // CITE COLUMN
    Column<Publication, String> citaceColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {

        public String getValue(Publication object) {
            return "Cite";
        }
    }, new FieldUpdater<Publication, String>() {

        public void update(int index, Publication object, String value) {
            SimplePanel sp = new SimplePanel();
            sp.add(new HTML(object.getMain()));
            Confirm cf = new Confirm("Cite publication", sp, true);
            cf.show();
        }
    });
    table.addColumn(citaceColumn, "Cite");
    return table;
}
Also used : PublicationComparator(cz.metacentrum.perun.webgui.json.comparators.PublicationComparator) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) Publication(cz.metacentrum.perun.webgui.model.Publication) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) HTML(com.google.gwt.user.client.ui.HTML) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Example 7 with TextColumn

use of com.google.gwt.user.cellview.client.TextColumn in project perun by CESNET.

the class GetEntitylessAttributes method getEmptyTable.

public CellTable<Attribute> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<>(list);
    // Cell table
    table = new PerunTable<>(list);
    // remove row count change handler
    table.removeRowCountChangeHandler();
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ColumnSortEvent.ListHandler<Attribute> columnSortHandler = new ColumnSortEvent.ListHandler<>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("No attributes found. Use 'Add' button to add new key=value.");
    // because of tab index
    table.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED);
    // checkbox column
    if (checkable) {
        // checkbox column column
        Column<Attribute, Attribute> checkBoxColumn = new Column<Attribute, Attribute>(new PerunCheckboxCell<>(true, false, false)) {

            @Override
            public Attribute getValue(Attribute object) {
                // Get the value from the selection model.
                GeneralObject go = object.cast();
                go.setChecked(selectionModel.isSelected(object));
                return go.cast();
            }
        };
        // updates the columns size
        table.setColumnWidth(checkBoxColumn, 40.0, Style.Unit.PX);
        // Add the columns
        // Checkbox column header
        CheckboxCell cb = new CheckboxCell();
        Header<Boolean> checkBoxHeader = new Header<Boolean>(cb) {

            public Boolean getValue() {
                // return true to see a checked checkbox.
                return false;
            }
        };
        checkBoxHeader.setUpdater(value -> {
            // sets selected to all, if value = true, unselect otherwise
            for (Attribute obj : list) {
                if (obj.isWritable()) {
                    selectionModel.setSelected(obj, value);
                }
            }
        });
        // table selection
        table.setSelectionModel(selectionModel, DefaultSelectionEventManager.createCheckboxManager(0));
        table.addColumn(checkBoxColumn, checkBoxHeader);
    }
    // Key column
    TextColumn<Attribute> keyColumn = new TextColumn<Attribute>() {

        @Override
        public String getValue(Attribute attribute) {
            return attribute.getKey();
        }
    };
    keyColumn.setSortable(true);
    table.addColumn(keyColumn, "Key");
    this.table.setColumnWidth(keyColumn, 200.0, Style.Unit.PX);
    // Value column
    Column<Attribute, Attribute> valueColumn = JsonUtils.addColumn(new PerunAttributeValueCell());
    valueColumn.setFieldUpdater((index, object, value) -> {
        object = value;
        selectionModel.setSelected(object, object.isAttributeValid());
    });
    // Add sorting
    this.table.addColumnSortHandler(columnSortHandler);
    // Add the columns.
    this.table.addColumn(valueColumn, "Value");
    return this.table;
}
Also used : PerunAttributeValueCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeValueCell) Attribute(cz.metacentrum.perun.webgui.model.Attribute) ColumnSortEvent(com.google.gwt.user.cellview.client.ColumnSortEvent) Header(com.google.gwt.user.cellview.client.Header) TextColumn(com.google.gwt.user.cellview.client.TextColumn) Column(com.google.gwt.user.cellview.client.Column) CheckboxCell(com.google.gwt.cell.client.CheckboxCell) PerunCheckboxCell(cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell) GeneralObject(cz.metacentrum.perun.webgui.model.GeneralObject) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Example 8 with TextColumn

use of com.google.gwt.user.cellview.client.TextColumn in project perun by CESNET.

the class GetServiceRequiredAttributes method getTable.

/**
 * Returns table widget with required attributes for service
 *
 * @return table widget
 */
public CellTable<AttributeDefinition> getTable() {
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<AttributeDefinition>(list);
    // Cell table
    table = new PerunTable<AttributeDefinition>(list);
    // remove row count change handler
    table.removeRowCountChangeHandler();
    // 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("Service has no required attribute.");
    // checkbox column column
    table.addCheckBoxColumn();
    // ID COLUMN
    table.addIdColumn("Attribute ID");
    // FRIENDLY NAME COLUMN
    final Column<AttributeDefinition, AttributeDefinition> friendlyNameColumn = JsonUtils.addColumn(new PerunAttributeFriendlyNameCell(), new JsonUtils.GetValue<AttributeDefinition, AttributeDefinition>() {

        public AttributeDefinition getValue(AttributeDefinition object) {
            return object;
        }
    }, null);
    /*
		// NAMESPACE COLUMN
		TextColumn<AttributeDefinition> namespaceColumn = new TextColumn<AttributeDefinition>() {
		public String getValue(AttributeDefinition attrDef) {
		return String.valueOf(attrDef.getNamespace());
		}
		};
		*/
    // ENTITY COLUMN
    TextColumn<AttributeDefinition> entityColumn = new TextColumn<AttributeDefinition>() {

        public String getValue(AttributeDefinition attrDef) {
            return attrDef.getEntity();
        }
    };
    // DEFINITION COLUMN
    TextColumn<AttributeDefinition> definitionColumn = new TextColumn<AttributeDefinition>() {

        public String getValue(AttributeDefinition attrDef) {
            return attrDef.getDefinition();
        }
    };
    // TYPE COLUMN
    TextColumn<AttributeDefinition> typeColumn = new TextColumn<AttributeDefinition>() {

        public String getValue(AttributeDefinition attrDef) {
            return String.valueOf(renameContent(attrDef.getType()));
        }
    };
    // SORTING
    /*
			 namespaceColumn.setSortable(true);
			 columnSortHandler.setComparator(namespaceColumn, new Comparator<AttributeDefinition>() {
			 public int compare(AttributeDefinition o1, AttributeDefinition o2) {
			 return o1.getNamespace().compareToIgnoreCase(o2.getNamespace());
			 }
			 });
			 */
    friendlyNameColumn.setSortable(true);
    columnSortHandler.setComparator(friendlyNameColumn, new Comparator<AttributeDefinition>() {

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

        public int compare(AttributeDefinition o1, AttributeDefinition o2) {
            return o1.getEntity().compareToIgnoreCase(o2.getEntity());
        }
    });
    // Sorting value column
    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());
        }
    });
    table.setColumnWidth(friendlyNameColumn, 250.0, Unit.PX);
    table.setColumnWidth(entityColumn, 120.0, Unit.PX);
    table.setColumnWidth(definitionColumn, 120.0, Unit.PX);
    table.setColumnWidth(typeColumn, 120.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, "Value type");
    table.addDescriptionColumn();
    return table;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) AttributeDefinition(cz.metacentrum.perun.webgui.model.AttributeDefinition) PerunAttributeFriendlyNameCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeFriendlyNameCell) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Example 9 with TextColumn

use of com.google.gwt.user.cellview.client.TextColumn in project perun by CESNET.

the class GetAuditMessagesByCount method getTable.

public CellTable<AuditMessage> getTable() {
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<AuditMessage>(list);
    // Cell table
    table = new PerunTable<AuditMessage>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<AuditMessage> columnSortHandler = new ListHandler<AuditMessage>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<AuditMessage>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("No audit messages found.");
    if (checkable) {
        // checkbox column column
        table.addCheckBoxColumn();
    }
    table.addIdColumn("Message ID", null, 120);
    // Event name column
    Column<AuditMessage, String> eventNameColumn = JsonUtils.addColumn(new CustomTextCell(), this::getAuditEventName, null);
    eventNameColumn.setSortable(true);
    columnSortHandler.setComparator(eventNameColumn, (o1, o2) -> (getAuditEventName(o1)).compareToIgnoreCase(getAuditEventName(o2)));
    // Event objects column
    Column<AuditMessage, String> objectsColumn = JsonUtils.addColumn(new CustomTextCell(), AuditMessage::getAuditEventObjectsMessage, null);
    eventNameColumn.setSortable(true);
    columnSortHandler.setComparator(eventNameColumn, (o1, o2) -> (o1.getAuditEventObjectsMessage()).compareToIgnoreCase(o2.getAuditEventObjectsMessage()));
    // Actor column
    Column<AuditMessage, String> actorColumn = JsonUtils.addColumn(new CustomTextCell(), AuditMessage::getActor, null);
    eventNameColumn.setSortable(true);
    columnSortHandler.setComparator(eventNameColumn, (o1, o2) -> (o1.getActor()).compareToIgnoreCase(o2.getActor()));
    // TIME COLUMN
    TextColumn<AuditMessage> timeColumn = new TextColumn<AuditMessage>() {

        public String getValue(AuditMessage msg) {
            if (msg.getCreatedAt().contains(".")) {
                return msg.getCreatedAt().substring(0, msg.getCreatedAt().indexOf("."));
            } else {
                // oracle timestamp doesn't have ending ".12345" in "2020-01-01 12:00:00.12345"
                return msg.getCreatedAt();
            }
        }
    };
    timeColumn.setSortable(true);
    columnSortHandler.setComparator(timeColumn, new Comparator<AuditMessage>() {

        public int compare(AuditMessage o1, AuditMessage o2) {
            return o1.getCreatedAt().compareToIgnoreCase(o2.getCreatedAt());
        }
    });
    table.addColumn(timeColumn, "Created at");
    table.setColumnWidth(timeColumn, "180px");
    table.addColumn(eventNameColumn, "Event name");
    table.setColumnWidth(eventNameColumn, "250px");
    table.addColumn(actorColumn, "Actor");
    table.setColumnWidth(actorColumn, "150px");
    table.addColumn(objectsColumn, "Related objects");
    return table;
}
Also used : AuditMessage(cz.metacentrum.perun.webgui.model.AuditMessage) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) CustomTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomTextCell) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Example 10 with TextColumn

use of com.google.gwt.user.cellview.client.TextColumn in project perun by CESNET.

the class GetBlacklistWithDescription method getTable.

/**
 * Returns the table widget with VOs.
 * @return The table Widget
 */
public CellTable<Pair<User, String>> getTable() {
    // retrieve data
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<Pair<User, String>>(list);
    // Cell table
    table = new PerunTable<Pair<User, String>>(list);
    // prevent double loading when clicked on vo name
    table.setHyperlinksAllowed(false);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<Pair<User, String>> columnSortHandler = new ListHandler<Pair<User, String>>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Pair<User, String>>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("Blacklist is empty.");
    // columns
    if (checkable) {
        table.addCheckBoxColumn();
    }
    Column<Pair<User, String>, String> idColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Pair<User, String>, String>() {

        public String getValue(Pair<User, String> object) {
            return String.valueOf(object.getLeft().getId());
        }
    }, tableFieldUpdater);
    idColumn.setSortable(true);
    // comparator
    columnSortHandler.setComparator(idColumn, new Comparator<Pair<User, String>>() {

        @Override
        public int compare(Pair<User, String> o1, Pair<User, String> o2) {
            return o1.getLeft().getId() - o2.getLeft().getId();
        }
    });
    // adding columns
    table.addColumn(idColumn, "User ID");
    table.setColumnWidth(idColumn, "150px");
    Column<Pair<User, String>, String> nameColumn = JsonUtils.addColumn(new CustomClickableTextCell(), new JsonUtils.GetValue<Pair<User, String>, String>() {

        @Override
        public String getValue(Pair<User, String> object) {
            return object.getLeft().getFullNameWithTitles();
        }
    }, tableFieldUpdater);
    nameColumn.setSortable(true);
    columnSortHandler.setComparator(nameColumn, new Comparator<Pair<User, String>>() {

        public int compare(Pair<User, String> o1, Pair<User, String> o2) {
            return o1.getLeft().getFullName().compareToIgnoreCase(o2.getLeft().getFullName());
        }
    });
    table.addColumn(nameColumn, "Name");
    table.setColumnWidth(nameColumn, "40%");
    // Type column
    TextColumn<Pair<User, String>> reasonColumn = new TextColumn<Pair<User, String>>() {

        @Override
        public String getValue(Pair<User, String> pair) {
            return pair.getRight();
        }
    };
    // sort type column
    reasonColumn.setSortable(true);
    columnSortHandler.setComparator(reasonColumn, new Comparator<Pair<User, String>>() {

        public int compare(Pair<User, String> o1, Pair<User, String> o2) {
            return o1.getRight().compareToIgnoreCase(o2.getRight());
        }
    });
    // Add columns to table
    table.addColumn(reasonColumn, "Reason");
    table.setColumnWidth(reasonColumn, "50%");
    return table;
}
Also used : CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Aggregations

TextColumn (com.google.gwt.user.cellview.client.TextColumn)20 Column (com.google.gwt.user.cellview.client.Column)8 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)7 TextHeader (com.google.gwt.user.cellview.client.TextHeader)4 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)3 ListDataProvider (com.google.gwt.view.client.ListDataProvider)3 CheckboxCell (com.google.gwt.cell.client.CheckboxCell)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 CellTable (com.google.gwt.user.cellview.client.CellTable)2 ColumnSortEvent (com.google.gwt.user.cellview.client.ColumnSortEvent)2 Header (com.google.gwt.user.cellview.client.Header)2 GeneralObject (cz.metacentrum.perun.webgui.model.GeneralObject)2 Confirm (cz.metacentrum.perun.webgui.widgets.Confirm)2 Column (org.gwtbootstrap3.client.ui.Column)2 Container (org.gwtbootstrap3.client.ui.Container)2 Row (org.gwtbootstrap3.client.ui.Row)2 ImageButtonColumn (org.rstudio.core.client.cellview.ImageButtonColumn)2 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)2 TableCellElement (com.google.gwt.dom.client.TableCellElement)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1