() {
+ @Override
+ public String getValue(T object) {
+ if (object == null)
+ return "";
+ return ((CatalogueDataset) object).getName();
+ }
+
+ // ADDING TOOLTIP
+ @Override
+ public void render(com.google.gwt.cell.client.Cell.Context context, T object, SafeHtmlBuilder sb) {
+ if (object == null)
+ return;
+ sb.appendHtmlConstant("");
+ super.render(context, object, sb);
+ sb.appendHtmlConstant("
");
+ };
+ };
+
+ sortedCellTable.addColumn(name, "Name", true);
+
+ if (!isAsyncronusTable) {
+ Comparator c = new Comparator() {
+ @Override
+ public int compare(T o1, T o2) {
+ return ((CatalogueDataset) o1).getName().compareTo(((CatalogueDataset) o2).getName());
+ }
+ };
+
+ sortedCellTable.setComparator(name, c);
+ }
+
+ }
+
+ if (this.displayFields.contains(DISPLAY_FIELD.TITLE)) {
+
+ title = new TextColumn() {
+ @Override
+ public String getValue(T object) {
+ if (object == null)
+ return "";
+ return ((CatalogueDataset) object).getTitle() != null ? ((CatalogueDataset) object).getTitle() : "";
+ }
+ };
+
+ sortedCellTable.addColumn(title, "Title", true);
+
+ if (!isAsyncronusTable) {
+ Comparator c = new Comparator() {
+ @Override
+ public int compare(T o1, T o2) {
+ return ((CatalogueDataset) o1).getTitle().compareTo(((CatalogueDataset) o2).getTitle());
+ }
+ };
+ sortedCellTable.setComparator(title, c);
+ }
+
+ }
+
+ if (this.displayFields.contains(DISPLAY_FIELD.AUTHOR)) {
+
+ author = new TextColumn() {
+ @Override
+ public String getValue(T object) {
+ if (object == null)
+ return "";
+ return ((CatalogueDataset) object).getAuthor() != null ? ((CatalogueDataset) object).getAuthor()
+ : "";
+ }
+ };
+
+ sortedCellTable.addColumn(author, "Author", true);
+
+ if (!isAsyncronusTable) {
+ Comparator c = new Comparator() {
+ @Override
+ public int compare(T o1, T o2) {
+ return ((CatalogueDataset) o1).getAuthor().compareTo(((CatalogueDataset) o2).getAuthor());
+ }
+ };
+ sortedCellTable.setComparator(author, c);
+ }
+
+ }
+
+ if (this.displayFields.contains(DISPLAY_FIELD.CREATED)) {
+
+ DateCell date = new DateCell(dtformat);
+ createdColumn = new Column(date) {
+
+ @Override
+ public Date getValue(T object) {
+ if (object == null)
+ return null;
+
+ return new Date(((CatalogueDataset) object).getCreated());
+ }
+ };
+ sortedCellTable.addColumn(createdColumn, "Created", true);
+
+ if (!isAsyncronusTable) {
+ Comparator c = new Comparator() {
+ @Override
+ public int compare(T o1, T o2) {
+ if (o1 == null || o1.getCreated() == 0)
+ return -1;
+
+ if (o2 == null || o2.getCreated() == 0)
+ return 1;
+
+ Date d1 = new Date(((CatalogueDataset) o1).getCreated());
+ Date d2 = new Date(((CatalogueDataset) o2).getCreated());
+
+ // GWT.log(d1.toString() + "is after "+d2.toString() +" ? "+d2.after(d1));
+
+ if (d1.after(d2))
+ return 1;
+ else
+ return -1;
+ }
+ };
+ GWT.log("date colum sortable");
+ sortedCellTable.setComparator(createdColumn, c);
+ }
+
+ }
+
+ if (this.displayFields.contains(DISPLAY_FIELD.LAST_UPDATE)) {
+
+ DateCell date = new DateCell(dtformat);
+ lastUpdateColumn = new Column(date) {
+
+ @Override
+ public Date getValue(T object) {
+ if (object == null)
+ return null;
+
+ return new Date(((CatalogueDataset) object).getLastUpdate());
+ }
+ };
+ sortedCellTable.addColumn(lastUpdateColumn, "Last Update", true);
+
+ if (!isAsyncronusTable) {
+ Comparator c = new Comparator() {
+ @Override
+ public int compare(T o1, T o2) {
+ if (o1 == null || o1.getCreated() == 0)
+ return -1;
+
+ if (o2 == null || o2.getCreated() == 0)
+ return 1;
+
+ Date d1 = new Date(((CatalogueDataset) o1).getLastUpdate());
+ Date d2 = new Date(((CatalogueDataset) o2).getLastUpdate());
+
+ // GWT.log(d1.toString() + "is after "+d2.toString() +" ? "+d2.after(d1));
+
+ if (d1.after(d2))
+ return 1;
+ else
+ return -1;
+ }
+ };
+ GWT.log("date colum sortable");
+ sortedCellTable.setComparator(lastUpdateColumn, c);
+ }
+
+ }
+
+ if (this.displayFields.contains(DISPLAY_FIELD.TYPE)) {
+
+ // NAME
+ type = new TextColumn() {
+ @Override
+ public String getValue(T object) {
+ if (object == null)
+ return "";
+
+ String type = ((CatalogueDataset) object).getExtra_SystemType();
+
+ if (type == null)
+ return "";
+ return type;
+ }
+
+ // ADDING TOOLTIP
+ @Override
+ public void render(com.google.gwt.cell.client.Cell.Context context, T object, SafeHtmlBuilder sb) {
+ if (object == null)
+ return;
+ String type = ((CatalogueDataset) object).getExtra_SystemType();
+ if (type == null)
+ type = "";
+ sb.appendHtmlConstant("");
+ super.render(context, object, sb);
+ sb.appendHtmlConstant("
");
+ };
+ };
+
+ sortedCellTable.addColumn(type, "Type", true);
+
+ if (!isAsyncronusTable) {
+ Comparator c = new Comparator() {
+ @Override
+ public int compare(T o1, T o2) {
+ if (o1 == null || o1.getExtra_SystemType() == null)
+ return -1;
+
+ if (o2 == null || o2.getExtra_SystemType() == null)
+ return 1;
+ return ((CatalogueDataset) o1).getExtra_SystemType()
+ .compareTo(((CatalogueDataset) o2).getExtra_SystemType());
+ }
+ };
+
+ sortedCellTable.setComparator(type, c);
+ }
+
+ }
+
+ GWT.log("startSortByColumn: " + startSortByColumn);
+
+ if (startSortByColumn != null)
+ switch (startSortByColumn) {
+ case NAME:
+ if (this.displayFields.contains(DISPLAY_FIELD.NAME)) {
+ sortedCellTable.setInitialSortColumn(name);
+ }
+ break;
+ case TITLE:
+ if (this.displayFields.contains(DISPLAY_FIELD.TITLE)) {
+ sortedCellTable.setInitialSortColumn(title);
+ }
+ break;
+ case AUTHOR:
+ if (this.displayFields.contains(DISPLAY_FIELD.AUTHOR)) {
+ sortedCellTable.setInitialSortColumn(author);
+ }
+ break;
+ case TYPE:
+ if (this.displayFields.contains(DISPLAY_FIELD.TYPE)) {
+ sortedCellTable.setInitialSortColumn(type);
+ }
+ break;
+ case CREATED:
+ if (this.displayFields.contains(DISPLAY_FIELD.CREATED)) {
+ sortedCellTable.setDefaultSortOrder(createdColumn, false); // sorts ascending on first click
+ sortedCellTable.setInitialSortColumn(createdColumn);
+ GWT.log("sortedCellTable: " + sortedCellTable);
+ }
+ break;
+ case LAST_UPDATE:
+ if (this.displayFields.contains(DISPLAY_FIELD.LAST_UPDATE)) {
+ sortedCellTable.setDefaultSortOrder(lastUpdateColumn, false); // sorts ascending on first click
+ sortedCellTable.setInitialSortColumn(lastUpdateColumn);
+ GWT.log("sortedCellTable: " + sortedCellTable);
+ }
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ /**
+ * Displays the appropriate sorted icon in the header of the column for the
+ * given index.
+ *
+ * @param columnIndex of the column to mark as sorted
+ * @param ascending true
for ascending icon, false
+ * for descending icon
+ */
+ public void setSortedColumn(int columnIndex, boolean ascending) {
+ GWT.log("Column index: " + columnIndex);
+ GWT.log("ascending: " + ascending);
+ Column column = sortedCellTable.getColumn(columnIndex);
+ if (column != null && column.isSortable()) {
+ ColumnSortInfo info = sortedCellTable.getColumnSortList().push(column);
+// ColumnSortEvent.fire(cellTable, cellTable.getColumnSortList());
+ GWT.log("info.isAscending(): " + info.isAscending());
+ if (info.isAscending() != ascending) {
+ sortedCellTable.getColumnSortList().push(column);
+ ColumnSortEvent.fire(sortedCellTable, sortedCellTable.getColumnSortList());
+ }
+ }
+ }
+
+ /**
+ * Sets the display fields.
+ *
+ * @param fields the new display fields
+ */
+ public void setDisplayFields(DISPLAY_FIELD[] fields) {
+ this.displayFields = fields != null && fields.length > 0 ? Arrays.asList(fields)
+ : Arrays.asList(DISPLAY_FIELD.values());
+ }
+
+ /**
+ * Reset columns table.
+ */
+ public void reInitColumnsTable() {
+ int count = sortedCellTable.getColumnCount();
+ for (int i = 0; i < count; i++) {
+ sortedCellTable.removeColumn(0);
+ }
+ initTable(null, null, dataProvider);
+ }
+
+ /**
+ * Gets the display fields.
+ *
+ * @return the displayFields
+ */
+ public List getDisplayFields() {
+ return displayFields;
+ }
+
+ /**
+ * The Class ButtonImageCell.
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016
+ */
+ public class ButtonImageCell extends ButtonCell {
+
+ /**
+ * Render.
+ *
+ * @param context the context
+ * @param value the value
+ * @param sb the sb
+ */
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.google.gwt.cell.client.AbstractSafeHtmlCell#render(com.google.gwt.cell.
+ * client.Cell.Context, java.lang.Object,
+ * com.google.gwt.safehtml.shared.SafeHtmlBuilder)
+ */
+ @Override
+ public void render(com.google.gwt.cell.client.Cell.Context context, String value, SafeHtmlBuilder sb) {
+ SafeHtml html = SafeHtmlUtils.fromTrustedString(new Image(value).toString());
+ sb.append(html);
+ }
+ }
+
+ /**
+ * Gets the selected item.
+ *
+ * @return the selected item
+ */
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.gcube.portlets.widgets.wsexplorer.client.notification.
+ * SelectionItemHandler#getSelectionItem()
+ */
+ @Override
+ public List getSelectedItems() {
+ if (theSelectionModel instanceof SingleSelectionModel) {
+ T selected = ((SingleSelectionModel) theSelectionModel).getSelectedObject();
+ if (selected != null) {
+ return Arrays.asList(selected);
+ }
+
+ } else if (theSelectionModel instanceof MultiSelectionModel) {
+ Set selected = ((MultiSelectionModel) theSelectionModel).getSelectedSet();
+ if (selected != null) {
+ return new ArrayList(selected);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Sets the empty table message.
+ *
+ * @param msg the new empty table message
+ */
+ public void setEmptyTableMessage(String msg) {
+ msg = msg != null ? msg : ContentModeratorWidgetConstants.NO_DATA;
+ if (sortedCellTable != null)
+ sortedCellTable.setEmptyTableWidget(new Label(msg));
+ }
+
+ /**
+ * Gets the selection model.
+ *
+ * @return the selection model
+ */
+ public SelectionModel getSelectionModel() {
+ return theSelectionModel;
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/table/MyToolTipColumn.java b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/table/MyToolTipColumn.java
new file mode 100644
index 0000000..5080d11
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/table/MyToolTipColumn.java
@@ -0,0 +1,83 @@
+/**
+ *
+ */
+
+package org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table;
+
+import com.google.gwt.cell.client.Cell;
+import com.google.gwt.cell.client.Cell.Context;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.safehtml.client.SafeHtmlTemplates;
+import com.google.gwt.safehtml.shared.SafeHtml;
+import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
+import com.google.gwt.user.cellview.client.Column;
+
+
+/**
+ * The Class MyToolTipColumn.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+ *
+ * Jun 15, 2021
+ * @param the generic type
+ * @param the generic type
+ */
+public abstract class MyToolTipColumn extends Column {
+
+ /**
+ * The Interface Templates.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+ *
+ * Jun 15, 2021
+ */
+ interface Templates extends SafeHtmlTemplates {
+
+ /**
+ * Start tool tip.
+ *
+ * @param toolTipText the tool tip text
+ * @return the safe html
+ */
+ @Template("")
+ SafeHtml startToolTip(String toolTipText);
+
+ /**
+ * End tool tip.
+ *
+ * @return the safe html
+ */
+ @Template("
")
+ SafeHtml endToolTip();
+ }
+
+ private static final Templates TEMPLATES = GWT.create(Templates.class);
+ private final String toolTipText;
+
+ /**
+ * Instantiates a new my tool tip column.
+ *
+ * @param cell the cell
+ * @param toolTipText the tool tip text
+ */
+ public MyToolTipColumn(final Cell cell, final String toolTipText) {
+
+ super(cell);
+ this.toolTipText = toolTipText;
+ }
+
+ /**
+ * Render.
+ *
+ * @param context the context
+ * @param object the object
+ * @param sb the sb
+ */
+ @Override
+ public void render(final Context context, final T object, final SafeHtmlBuilder sb) {
+
+ sb.append(TEMPLATES.startToolTip(toolTipText));
+ super.render(context, object, sb);
+ sb.append(TEMPLATES.endToolTip());
+ }
+}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/table/SortedCellTable.java b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/table/SortedCellTable.java
new file mode 100644
index 0000000..c18d579
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/table/SortedCellTable.java
@@ -0,0 +1,302 @@
+/**
+ *
+ */
+
+package org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.CellTableResources;
+
+import com.github.gwtbootstrap.client.ui.CellTable;
+import com.google.gwt.user.cellview.client.Column;
+import com.google.gwt.user.cellview.client.ColumnSortEvent;
+import com.google.gwt.user.cellview.client.ColumnSortEvent.AsyncHandler;
+import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
+import com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo;
+import com.google.gwt.user.cellview.client.Header;
+import com.google.gwt.view.client.AbstractDataProvider;
+import com.google.gwt.view.client.AsyncDataProvider;
+import com.google.gwt.view.client.ListDataProvider;
+
+/**
+ * The Class SortedCellTable.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+ *
+ * Jun 15, 2021
+ * @param the generic type
+ */
+public class SortedCellTable extends CellTable {
+
+ /**
+ * To keep track of the currently sorted column
+ */
+ private Column currentlySortedColumn;
+ /**
+ * Tells us which way to sort a column initially
+ */
+ private Map, Boolean> defaultSortOrderMap = new HashMap, Boolean>();
+ /**
+ * Comparators associated with their columns
+ */
+ private Map