task_21363 #1

Closed
francesco.mangiacrapa wants to merge 53 commits from task_21363 into master
30 changed files with 1528 additions and 375 deletions
Showing only changes of commit cfa3484421 - Show all commits

View File

@ -5,6 +5,6 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v0.1.0-SNAPSHOT] - 2021-05-06 ## [v0.2.0-SNAPSHOT] - 2021-06-15
First Release First Release

67
pom.xml
View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.widgets</groupId> <groupId>org.gcube.portlets.widgets</groupId>
<artifactId>ckan-content-moderator-widget</artifactId> <artifactId>ckan-content-moderator-widget</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>0.1.0-SNAPSHOT</version> <version>0.2.0-SNAPSHOT</version>
<name>gCube Ckan Content Moderator Widget</name> <name>gCube Ckan Content Moderator Widget</name>
<description> <description>
@ -68,18 +68,19 @@
<dependencies> <dependencies>
<dependency> <!-- <dependency> -->
<groupId>javax.servlet</groupId> <!-- <groupId>javax.servlet</groupId> -->
<artifactId>javax.servlet-api</artifactId> <!-- <artifactId>javax.servlet-api</artifactId> -->
<version>3.1.0</version> <!-- <version>3.1.0</version> -->
<scope>provided</scope> <!-- <scope>provided</scope> -->
</dependency> <!-- </dependency> -->
<dependency> <!-- <dependency> -->
<groupId>xml-apis</groupId> <!-- <groupId>xml-apis</groupId> -->
<artifactId>xml-apis</artifactId> <!-- <artifactId>xml-apis</artifactId> -->
<version>1.4.01</version> <!-- <version>1.4.01</version> -->
<scope>provided</scope> <!-- <scope>provided</scope> -->
</dependency> <!-- </dependency> -->
<dependency> <dependency>
<groupId>com.google.gwt</groupId> <groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId> <artifactId>gwt-user</artifactId>
@ -102,34 +103,6 @@
<artifactId>gwt-bootstrap</artifactId> <artifactId>gwt-bootstrap</artifactId>
<version>2.3.2.0</version> <version>2.3.2.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-jquery</artifactId>
<version>${gwt-material.version}</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>com.github.gwtmaterialdesign</groupId> -->
<!-- <artifactId>gwt-material-addins</artifactId> -->
<!-- <version>${gwt-material.version}</version> -->
<!-- </dependency> -->
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-table</artifactId>
<version>${gwt-material.version}</version>
</dependency>
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-addins</artifactId>
<version>${gwt-material.version}</version>
</dependency>
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-themes</artifactId>
<version>${gwt-material.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.gcube.core</groupId> <groupId>org.gcube.core</groupId>
@ -148,18 +121,6 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- <dependency> -->
<!-- <groupId>org.gcube.portal</groupId> -->
<!-- <artifactId>custom-portal-handler</artifactId> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>javax.portlet</groupId> -->
<!-- <artifactId>portlet-api</artifactId> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<dependency> <dependency>
<groupId>org.gcube.datacatalogue</groupId> <groupId>org.gcube.datacatalogue</groupId>
<artifactId>catalogue-util-library</artifactId> <artifactId>catalogue-util-library</artifactId>

View File

@ -3,22 +3,16 @@
<!-- Inherit the core Web Toolkit stuff. --> <!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' /> <inherits name='com.google.gwt.user.User' />
<inherits name="gwt.material.design.jquery.JQuery" />
<inherits
name="gwt.material.design.GwtMaterialBasicWithJQuery" />
<inherits name="gwt.material.design.addins.GwtMaterialAddins" />
<inherits name="gwt.material.design.themes.ThemeBlue" />
<inherits name="gwt.material.design.GwtMaterialTable" />
<inherits <inherits
name="org.gcube.datacatalogue.utillibrary.CkanUtilLibrary" /> name="org.gcube.datacatalogue.utillibrary.CkanUtilLibrary" />
<inherits name="com.github.gwtbootstrap.Bootstrap" />
<!-- Other module inherits --> <!-- Other module inherits -->
<!-- Specify the app entry point class. --> <!-- Specify the app entry point class. -->
<!-- <entry-point <!-- <entry-point class='org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModeratorWidget'
class='org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModeratorWidget' /> --> /> -->
<!-- Specify the paths for translatable code --> <!-- Specify the paths for translatable code -->
<source path='client' /> <source path='client' />

View File

@ -3,63 +3,44 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client;
import java.util.List; import java.util.List;
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus; import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
import org.gcube.portlets.widgets.ckancontentmoderator.client.material.table.CustomizedView; import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable;
import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.DataTableClientBundle; import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset; import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.StyleInjector;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;
/** /**
* Entry point classes define <code>onModuleLoad()</code>. * Entry point classes define <code>onModuleLoad()</code>.
*/ */
public class CkanContentModeratorWidget implements EntryPoint { public class CkanContentModeratorWidget {
/**
* The message displayed to the user when the server cannot be reached or
* returns an error.
*/
private static final String SERVER_ERROR = "An error occurred while "
+ "attempting to contact the server. Please check your network " + "connection and try again.";
/** public final CkanContentModeratorServiceAsync contentModeratorService = GWT.create(CkanContentModeratorService.class);
* Create a remote service proxy to talk to the server-side Greeting service.
*/
private final CkanContentModeratorServiceAsync greetingService = GWT.create(CkanContentModeratorService.class);
/** ItemsTable<CatalogueDataset> itemsTable;
* This is the entry point method.
*/
public void onModuleLoad() {
/*StyleInjector.inject(DataTableClientBundle.INSTANCE.dataTable().getText());
// MaterialDataTable<String> table = new MaterialDataTable<String>(); CkanContentModeratorWidget(DISPLAY_FIELD[] displayFields, DISPLAY_FIELD sortByField){
// table.getTableTitle().setText("Customers"); itemsTable = new ItemsTable<CatalogueDataset>(null, displayFields, sortByField);
// List<String> users = new ArrayList<String>(); }
// users.add("Pippo");
// table.setRowData(0, users);
final CustomizedView cvTable = new CustomizedView();
RootPanel.get().add(cvTable);
// table.getView().refresh();
greetingService.getListItemsForStatus(ItemStatus.PENDING, 20, 0, new AsyncCallback<List<CatalogueDataset>>() { public void loadItemsForStatus(ItemStatus status){
contentModeratorService.getListItemsForStatus(status, ContentModeratorWidgetConstants.ITEMS_PER_PAGE, ContentModeratorWidgetConstants.ITEM_START_INDEX, new AsyncCallback<List<CatalogueDataset>>() {
@Override @Override
public void onSuccess(List<CatalogueDataset> result) { public void onSuccess(List<CatalogueDataset> result) {
cvTable.setData(result); itemsTable.updateItems(result, true);
} }
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
Window.alert(caught.getMessage()); // TODO Auto-generated method stub
} }
});*/ });
}
} }
}

View File

@ -0,0 +1,54 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class CkanContentModeratorWidgetEntryPoint implements EntryPoint {
/**
* The message displayed to the user when the server cannot be reached or
* returns an error.
*/
private static final String SERVER_ERROR = "An error occurred while "
+ "attempting to contact the server. Please check your network " + "connection and try again.";
/**
* Create a remote service proxy to talk to the server-side Greeting service.
*/
private final CkanContentModeratorServiceAsync greetingService = GWT.create(CkanContentModeratorService.class);
/**
* This is the entry point method.
*/
public void onModuleLoad() {
/*StyleInjector.inject(DataTableClientBundle.INSTANCE.dataTable().getText());
// MaterialDataTable<String> table = new MaterialDataTable<String>();
// table.getTableTitle().setText("Customers");
// List<String> users = new ArrayList<String>();
// users.add("Pippo");
// table.setRowData(0, users);
final CustomizedView cvTable = new CustomizedView();
RootPanel.get().add(cvTable);
// table.getView().refresh();
greetingService.getListItemsForStatus(ItemStatus.PENDING, 20, 0, new AsyncCallback<List<CatalogueDataset>>() {
@Override
public void onSuccess(List<CatalogueDataset> result) {
cvTable.setData(result);
}
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
}
});*/
}
}

View File

@ -0,0 +1,16 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client;
/**
* The Class ContentModeratorWidgetConstants.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 15, 2021
*/
public class ContentModeratorWidgetConstants {
public static final String NO_DATA = "No data";
public static int ITEMS_PER_PAGE = 10;
public static int ITEM_START_INDEX = 0;
}

View File

@ -0,0 +1,50 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class ClickItemEvent.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jul 6, 2015
*/
public class ClickItemEvent<T> extends GwtEvent<ClickItemEventHandler> {
public static Type<ClickItemEventHandler> TYPE = new Type<ClickItemEventHandler>();
private T item;
/**
* Instantiates a new click item event.
*
* @param item the item
*/
public ClickItemEvent(T item) {
this.item = item;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/
@Override
public Type<ClickItemEventHandler> getAssociatedType() {
return TYPE;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
*/
@Override
protected void dispatch(ClickItemEventHandler handler) {
handler.onClick(this);
}
/**
* Gets the item.
*
* @return the item
*/
public T getItem() {
return item;
}
}

View File

@ -0,0 +1,21 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface ClickItemEventHandler.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jul 6, 2015
*/
public interface ClickItemEventHandler extends EventHandler {
/**
* On click.
*
* @param <T> the generic type
* @param moreInfoShowEvent the more info show event
*/
<T> void onClick(ClickItemEvent<T> moreInfoShowEvent);
}

View File

@ -1,226 +0,0 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.material.table;
import java.util.List;
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.client.data.events.ColumnSortHandler;
import gwt.material.design.client.data.events.RowSelectEvent;
import gwt.material.design.client.data.events.RowSelectHandler;
import gwt.material.design.client.ui.table.MaterialDataTable;
public class CustomizedView extends Composite {
interface CustomizedViewUiBinder extends UiBinder<Widget, CustomizedView> {
}
private static CustomizedViewUiBinder uiBinder = GWT.create(CustomizedViewUiBinder.class);
private List<CatalogueDataset> users;
@UiField
MaterialDataTable<CatalogueDataset> table;
public CustomizedView() {
initWidget(uiBinder.createAndBindUi(this));
setupTable();
}
public void setupTable() {
// MaterialIcon icon = new MaterialIcon();
// icon.setPadding(4);
// icon.setIconType(IconType.ADD_CIRCLE_OUTLINE);
//
// icon.addClickHandler(new ClickHandler() {
//
// @Override
// public void onClick(ClickEvent event) {
// users.add(0, new DataGenerator().generateUsers(1).get(0));
// setData(users);
//
// }
// });
// table.setWaves(null);
// table.setUseStickyHeader(false);
//table.getScaffolding().getToolPanel().add(icon);
// MaterialIcon delete = new MaterialIcon();
// delete.setPadding(4);
// delete.setIconType(IconType.DELETE);
// table.getScaffolding().getToolPanel().add(delete);
//
// delete.addClickHandler(new ClickHandler() {
//
// @Override
// public void onClick(ClickEvent event) {
// User user = table.getView().getSelectedRowModels(true).get(0);
// users.remove(user);
// setData(users);
//
// }
// });
// table.addColumn("Image", new WidgetColumn<User, MaterialPanel>() {
// @Override
// public MaterialPanel getValue(User object) {
// MaterialPanel panel = new MaterialPanel();
// MaterialImage image = new MaterialImage();
// // image.setUrl(object.getImage());
// image.setWidth("32px");
// image.setHeight("32px");
// image.setCircle(true);
// panel.add(image);
// return panel;
// }
// });
table.addColumn("Title", new gwt.material.design.client.ui.table.cell.TextColumn<CatalogueDataset>() {
@Override
public String getValue(CatalogueDataset object) {
return object.getTitle();
}
@Override
public boolean sortable() {
return true;
}
});
// table.addColumn("Option", new WidgetColumn<User, MaterialListBox>() {
// @Override
// public MaterialListBox getValue(User object) {
// MaterialListBox listBox = new MaterialListBox();
// listBox.addItem("Option 1");
// listBox.addItem("Option 2");
// listBox.addItem("Option 3");
// return listBox;
// }
// }).width(200);
table.addColumn("Author", new gwt.material.design.client.ui.table.cell.TextColumn<CatalogueDataset>() {
@Override
public String getValue(CatalogueDataset object) {
return object.getAuthor();
}
@Override
public boolean sortable() {
return true;
}
});
table.addRowSelectHandler(new RowSelectHandler<CatalogueDataset>() {
@Override
public void onRowSelect(RowSelectEvent<CatalogueDataset> event) {
log("RowSelectEvent", event.getModel().getName() + ": " + event.isSelected());
}
});
table.addColumnSortHandler(new ColumnSortHandler<CatalogueDataset>() {
@Override
public void onColumnSort(gwt.material.design.client.data.events.ColumnSortEvent<CatalogueDataset> event) {
log("ColumnSortEvent",
"Sorted: " + event.getSortContext().getSortDir() + ", columnIndex: " + event.getColumnIndex());
table.getView().refresh();
}
});
/*
* // Add category opened handler, called when a category is opened.
* table.addCategoryOpenedHandler(event -> { log("CategoryOpenedEvent",
* "Category Opened: " + event.getName()); });
*
* // Add category closed handler, called when a category is closed.
* table.addCategoryClosedHandler(event -> { log("CategoryClosedEvent",
* "Category Closed: " + event.getName()); });
*
* // Add a row double click handler, called when a row is double clicked.
* table.addRowDoubleClickHandler(event -> { log("RowDoubleClickEvent",
* "Row Double Clicked: " + event.getModel().getName() + ", x:" +
* event.getMouseEvent().getPageX() + ", y: " +
* event.getMouseEvent().getPageY()); });
*
* // Configure the tables long press duration configuration. // The short press
* is when a click is held less than this duration.
* table.setLongPressDuration(400);
*
* // Add a row long press handler, called when a row is long pressed.
* table.addRowLongPressHandler(event -> { log("RowLongPressEvent",
* "Row Long Pressed: " + event.getModel().getName() + ", x:" +
* event.getMouseEvent().getPageX() + ", y: " +
* event.getMouseEvent().getPageY()); });
*
* // Add a row short press handler, called when a row is short pressed.
* table.addRowShortPressHandler(event -> { log("RowShortPressEvent",
* "Row Short Pressed: " + event.getModel().getName() + ", x:" +
* event.getMouseEvent().getPageX() + ", y: " +
* event.getMouseEvent().getPageY()); });
*
* // Add rendered handler, called when 'setRowData' calls finish rendering. //
* Guaranteed to only be called once from the data set render, ignoring sort
* renders and refreshView renders. table.addRenderedHandler(e -> {
* log("RenderedEvent", "Table Rendered"); });
*
* // Add components rendered handler, Called each time when components are
* rendered, // which includes sorting renders and refreshView() renders.
* table.addComponentsRenderedHandler(e -> { log("ComponentsRenderedEvent",
* "Data Table Components Rendered"); });
*/
}
protected void log(String eventName, String description) {
GWT.log(description);
}
public void setData(List<CatalogueDataset> users) {
this.users = users;
// Customized Table Scaffolding elements
table.getTableTitle().setText("Customers");
table.setRowData(0, users);
table.getView().refresh();
}
// @Override
// public void setupOptions() {
// // Table Name
// tableName.addKeyUpHandler(event -> table.getTableTitle().setText(tableName.getValue()));
//
// // Selection Type
// selectionType.add(SelectionType.NONE);
// selectionType.add(SelectionType.SINGLE);
// selectionType.add(SelectionType.MULTIPLE);
// selectionType.addValueChangeHandler(event -> table.setSelectionType(event.getValue()));
// selectionType.setValue(SelectionType.SINGLE, true);
// // Density
// }
//
// @UiHandler("stickyHeader")
// void stickyHeader(ValueChangeEvent<Boolean> event) {
// table.setUseStickyHeader(event.getValue());
// }
//
// @UiHandler("striped")
// void striped(ValueChangeEvent<Boolean> event) {
// if (event.getValue()) {
// table.getScaffolding().getTable().addStyleName("striped");
// } else {
// table.getScaffolding().getTable().removeStyleName("striped");
// }
// }
public void reload() {
table.getView().setRedraw(true);
table.getView().refresh();
}
}

View File

@ -1,14 +0,0 @@
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:m="urn:import:gwt.material.design.client.ui"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<m:MaterialPanel>
<m:MaterialRow>
<m:MaterialColumn grid="s12 m10" offset="m1">
<m:table.MaterialDataTable
ui:field="table" shadow="1" height="440px" marginBottom="80" />
</m:MaterialColumn>
</m:MaterialRow>
</m:MaterialPanel>
</ui:UiBinder>

View File

@ -0,0 +1,110 @@
@def selectionBorderWidth 1px ; .cellTableWidget {
}
.cellTableFirstColumn {
}
.cellTableLastColumn {
}
.cellTableFooter {
}
.cellTableHeader {
}
.cellTableCell {
}
.cellTableFirstColumnFooter {
}
.cellTableFirstColumnHeader {
}
.cellTableLastColumnFooter {
}
.cellTableLastColumnHeader {
}
.cellTableSortableHeader {
}
.cellTableSortableHeader:hover {
}
.cellTableSortedHeaderAscending {
}
.cellTableSortedHeaderDescending {
}
.cellTableEvenRow {
}
.cellTableEvenRowCell {
}
.cellTableOddRow {
}
.cellTableOddRowCell {
}
.cellTableHoveredRow {
background: #D9EDF7 !important;
cursor: pointer;
}
.cellTableHoveredRowCell {
background: #D9EDF7 !important;
cursor: pointer;
}
.cellTableKeyboardSelectedRow, .cellTableKeyboardSelectedRow td, .cellTableKeyboardSelectedRow th {
background: #3A87AD !important;
}
.cellTableSelectedRow, .cellTableSelectedRow td, .cellTableSelectedRow th
{
/* background: #D9EDF7 !important; */
/* color: white !important; */
/* height: auto; */
/* overflow: auto; */
}
.cellTableSelectedRowCell, .cellTableSelectedRow td.cellTableSelectedRowCell {
background: #3A87AD !important;
}
.cellTableKeyboardSelectedRowCell, .cellTableKeyboardSelectedRow td.cellTableKeyboardSelectedRowCell{
background: #3A87AD !important;
}
.cellTableKeyboardSelectedCell, .cellTableKeyboardSelectedRow td.cellTableKeyboardSelectedCell{
background: #3A87AD !important;
color: white !important;
}
.cellTableLoading {
margin: 30px;
}

View File

@ -0,0 +1,23 @@
/**
*
*/
package org.gcube.portlets.widgets.ckancontentmoderator.client.resources;
import com.github.gwtbootstrap.client.ui.CellTable;
import com.github.gwtbootstrap.client.ui.CellTable.Resources;
import com.google.gwt.core.shared.GWT;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 23, 2015
*/
public interface CellTableResources extends Resources {
public CellTableResources INSTANCE = GWT.create(CellTableResources.class);
// The styles used in this widget.
@Override
@Source("CellTable.css")
CellTable.Style cellTableStyle();
}

View File

@ -0,0 +1,56 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.resources;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
/**
* The Interface WorkspaceExplorerIcons.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 15, 2021
*/
public interface ContentModeratorIcons extends ClientBundle {
/**
* Cancel.
*
* @return the image resource
*/
@Source("cancel.png")
ImageResource cancel();
/**
* Loading.
*
* @return the image resource
*/
@Source("loading.gif")
ImageResource loading();
/**
* Our sample image icon. Makes the image resource for the gwt-compiler's css
* composer accessible
*
* @return the image resource
*/
@Source("loading.gif")
ImageResource logo();
/**
* Info.
*
* @return the image resource
*/
@Source("info-icon.png")
ImageResource info();
/**
* Info square.
*
* @return the image resource
*/
@Source("info-square.png")
ImageResource infoSquare();
}

View File

@ -0,0 +1,56 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.resources;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
/**
* The Class ContentModeratorWidgetResources.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 15, 2021
*/
public class ContentModeratorWidgetResources {
public static final ContentModeratorIcons ICONS = GWT.create(ContentModeratorIcons.class);
/**
* Gets the icon cancel.
*
* @return the icon cancel
*/
public static AbstractImagePrototype getIconCancel() {
return AbstractImagePrototype.create(ICONS.cancel());
}
/**
* Gets the icon loading.
*
* @return the icon loading
*/
public static AbstractImagePrototype getIconLoading() {
return AbstractImagePrototype.create(ICONS.loading());
}
/**
* Gets the icon info.
*
* @return the icon info
*/
public static AbstractImagePrototype getIconInfo() {
return AbstractImagePrototype.create(ICONS.info());
}
/**
* Gets the icon info square.
*
* @return the icon info square
*/
public static AbstractImagePrototype getIconInfoSquare() {
return AbstractImagePrototype.create(ICONS.infoSquare());
}
}

View File

@ -1,17 +0,0 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.resources;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.TextResource;
/**
* Client Bundle for Icon Morph component
* @author kevzlou7979
*/
public interface DataTableClientBundle extends ClientBundle {
DataTableClientBundle INSTANCE = GWT.create(DataTableClientBundle.class);
@Source("css/data-table.css")
TextResource dataTable();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 908 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

@ -0,0 +1,24 @@
/**
*
*/
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
/**
* The Interface SelectionItem.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Apr 28, 2016
*/
public interface SelectionItem {
/**
* Gets the selected item.
*
* @param <T> the generic type
* @return the selected item
*/
<T> T getSelectedItem();
}

View File

@ -0,0 +1,202 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table;
import java.util.List;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEvent;
import com.github.gwtbootstrap.client.ui.Pagination;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.dom.client.Style.BorderStyle;
import com.google.gwt.event.dom.client.ContextMenuEvent;
import com.google.gwt.event.dom.client.ContextMenuHandler;
import com.google.gwt.event.dom.client.DoubleClickEvent;
import com.google.gwt.event.dom.client.DoubleClickHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.view.client.AbstractDataProvider;
import com.google.gwt.view.client.AsyncDataProvider;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.SelectionChangeEvent;
import com.google.gwt.view.client.SelectionChangeEvent.Handler;
import com.google.gwt.view.client.SingleSelectionModel;
/**
* The Class AbstractItemsCellTable.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jul 11, 2017
* @param <T> the generic type
*/
public abstract class AbstractItemsCellTable<T> {
protected SortedCellTable<T> sortedCellTable;
protected T itemContextMenu = null;
protected boolean fireEventOnClick = true;
protected SingleSelectionModel<T> ssm;
protected HandlerManager eventBus;
/**
* Inits the table.
*
* @param pager the pager
* @param pagination the pagination
* @param dataProvider the data provider
*/
public abstract void initTable(final SimplePager pager, final Pagination pagination,
AbstractDataProvider<T> dataProvider);
/**
* Inits the abstract table.
*
* @param eventBus the event bus
* @param fireOnClick the fire on click
* @param dataProvider the data provider
* @param pageSize the page size
*/
protected void initAbstractTable(HandlerManager eventBus, boolean fireOnClick, AbstractDataProvider<T> dataProvider,
int pageSize) {
this.eventBus = eventBus;
this.fireEventOnClick = fireOnClick;
sortedCellTable = new SortedCellTable<T>(pageSize, dataProvider);
sortedCellTable.addStyleName("table-cms-widget");
// cellTable.getElement().getStyle().setOverflow(Overflow.HIDDEN);
sortedCellTable.addStyleName("table-cms-widget-vertical-middle");
sortedCellTable.setStriped(true);
sortedCellTable.setCondensed(true);
sortedCellTable.setWidth("100%", true);
// dataProvider.addDataDisplay(sortedCellTable);
// initTable(cellTable, null, null);
sortedCellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
ssm = new SingleSelectionModel<T>();
sortedCellTable.setSelectionModel(ssm);
ssm.addSelectionChangeHandler(new Handler() {
@Override
public void onSelectionChange(final SelectionChangeEvent event) {
final T selectedObject = ssm.getSelectedObject();
if (selectedObject != null) {
GWT.log("Clicked: " + selectedObject);
// selectedItem(selectedObject);
if (fireEventOnClick)
AbstractItemsCellTable.this.eventBus.fireEvent(new ClickItemEvent<T>(selectedObject));
}
}
});
sortedCellTable.addDomHandler(new DoubleClickHandler() {
@Override
public void onDoubleClick(final DoubleClickEvent event) {
T selected = ssm.getSelectedObject();
if (selected != null) {
GWT.log("Double Click: " + selected);
// AbstractItemsCellTable.this.eventBus.fireEvent(new
// org.gcube.portlets.widgets.wsexplorer.client.event.LoadFolderEvent<T>(selected));
}
}
}, DoubleClickEvent.getType());
MenuBar options = new MenuBar(true);
ScheduledCommand openCommand = new ScheduledCommand() {
@Override
public void execute() {
GWT.log("Context menu shown: " + itemContextMenu);
// AbstractItemsCellTable.this.eventBus.fireEvent(new
// org.gcube.portlets.widgets.wsexplorer.client.event.LoadFolderEvent<T>(itemContextMenu));
}
};
MenuItem openItem = new MenuItem("Open", openCommand);
options.addItem(openItem);
final DialogBox menuWrapper = new DialogBox(true);
menuWrapper.getElement().getStyle().setBorderStyle(BorderStyle.NONE);
menuWrapper.getElement().getStyle().setZIndex(10000);
menuWrapper.add(options);
sortedCellTable.sinkEvents(Event.ONCONTEXTMENU);
sortedCellTable.addHandler(new ContextMenuHandler() {
@Override
public void onContextMenu(ContextMenuEvent event) {
}
}, ContextMenuEvent.getType());
}
/**
* Update items.
*
* @param items the items
* @param removeOldItems the remove old items
*/
public void updateItems(List<T> items, boolean removeOldItems) {
if (removeOldItems) {
// dataProvider.getList().clear();
ssm.clear();
}
sortedCellTable.setList(items);
// dataProvider.flush();
// dataProvider.refresh();
sortedCellTable.setPageSize(items.size() + 1);
sortedCellTable.redraw();
}
/**
* Gets the cell tables.
*
* @return the cell tables
*/
public SortedCellTable<T> getCellTable() {
return sortedCellTable;
}
/**
* Checks if is fire event on click.
*
* @return the fireEventOnClick
*/
public boolean isFireEventOnClick() {
return fireEventOnClick;
}
/**
* @param fireEventOnClick the fireEventOnClick to set
*/
public void setFireEventOnClick(boolean fireEventOnClick) {
this.fireEventOnClick = fireEventOnClick;
}
/**
* Adds the items.
*
* @param items the items
*/
public void addItems(List<T> items) {
AbstractDataProvider<T> dataProvider = sortedCellTable.getDataProvider();
if (dataProvider instanceof ListDataProvider) {
List<T> ldp = ((ListDataProvider<T>) dataProvider).getList();
for (int i = 0; i < items.size(); i++) {
ldp.add(i, items.get(i));
}
sortedCellTable.setPageSize(items.size() + 1);
sortedCellTable.redraw();
} else if (dataProvider instanceof AsyncDataProvider) {
// TODO ???
}
}
}

View File

@ -0,0 +1,487 @@
/**
*
*/
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ContentModeratorWidgetConstants;
import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.ContentModeratorWidgetResources;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.SelectionItem;
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
import com.github.gwtbootstrap.client.ui.Pagination;
import com.google.gwt.cell.client.ButtonCell;
import com.google.gwt.cell.client.DateCell;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.cellview.client.ColumnSortEvent;
import com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo;
import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.view.client.AbstractDataProvider;
import com.google.gwt.view.client.ListDataProvider;
// TODO: Auto-generated Javadoc
/**
* The Class ItemsTable.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 15, 2021
* @param <T> the generic type
*/
public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTable<T> implements SelectionItem {
// private Column<T, ImageResource> icon;
private TextColumn<T> type;
private TextColumn<T> name;
private TextColumn<T> title;
private TextColumn<T> author;
public DateTimeFormat dtformat = DateTimeFormat.getFormat("dd MMM hh:mm aaa yyyy");
public ImageResource info = ContentModeratorWidgetResources.ICONS.infoSquare();
private AbstractDataProvider<T> dataProvider;
/**
* The Enum DISPLAY_FIELD.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016
*/
public static enum DISPLAY_FIELD {
TYPE, NAME, TITLE, AUTHOR, CREATED
};
private List<DISPLAY_FIELD> displayFields;
private Column<T, Date> dateColumn;
// private List<String> displayProperties;
// private boolean showGcubeItemsInfo;
private DISPLAY_FIELD startSortByColumn;
private boolean isAsyncronusTable;
/**
* Instantiates a new items table.
*
* @param eventBus the event bus
* @param fields the fields
* @param startSortByColumn the start sort by column
*/
public ItemsTable(HandlerManager eventBus, DISPLAY_FIELD[] fields,
DISPLAY_FIELD startSortByColumn) {
this.eventBus = eventBus;
this.startSortByColumn = startSortByColumn;
setDisplayFields(fields);
}
/**
* Update items.
*
* @param items the items
* @param removeOldItems the remove old items
*/
/*
* (non-Javadoc)
*
* @see
* org.gcube.portlets.widgets.wsexplorer.client.view.grid.AbstractItemsCellTable
* #updateItems(java.util.List, boolean)
*/
public void updateItems(List<T> items, boolean removeOldItems) {
super.updateItems(items, removeOldItems);
}
/**
* Adds the items.
*
* @param items the items
*/
public void addItems(List<T> items) {
super.addItems(items);
}
/**
* Inits the table.
*
* @param pager the pager
* @param pagination the pagination
* @param dataProvider the data provider
*/
/*
* (non-Javadoc)
*
* @see org.gcube.portlets.admin.gcubereleases.client.view.AbstractPackageTable#
* initTable(com.google.gwt.user.cellview.client.AbstractCellTable,
* com.google.gwt.user.cellview.client.SimplePager,
* com.github.gwtbootstrap.client.ui.Pagination)
*/
@Override
public void initTable(final SimplePager pager, final Pagination pagination, AbstractDataProvider<T> dataProvider) {
this.dataProvider = dataProvider;
initAbstractTable(eventBus, fireEventOnClick, dataProvider, ContentModeratorWidgetConstants.ITEMS_PER_PAGE);
this.dataProvider.addDataDisplay(sortedCellTable);
// this.isAsyncronusTable = dataProvider instanceof
// AbstractDataProvider?true:false;
this.isAsyncronusTable = dataProvider instanceof ListDataProvider ? false : true;
// sortedCellTable.setEmptyTableWidget(new
// Label(WorkspaceExplorerConstants.WORKSPACE_FOLDER_EMPTY_MESSAGE));
setEmptyTableMessage(ContentModeratorWidgetConstants.NO_DATA);
if (this.displayFields.contains(DISPLAY_FIELD.TYPE)) {
// NAME
type = new TextColumn<T>() {
@Override
public String getValue(T object) {
if (object == null)
return "";
return ((CatalogueDataset) object).getType();
}
// ADDING TOOLTIP
@Override
public void render(com.google.gwt.cell.client.Cell.Context context, T object, SafeHtmlBuilder sb) {
if (object == null)
return;
sb.appendHtmlConstant("<div title=\"" + ((CatalogueDataset) object).getType() + "\">");
super.render(context, object, sb);
sb.appendHtmlConstant("</div>");
};
};
sortedCellTable.addColumn(name, "Type", true);
if (!isAsyncronusTable) {
Comparator<T> c = new Comparator<T>() {
@Override
public int compare(T o1, T o2) {
return ((CatalogueDataset) o1).getType().compareTo(((CatalogueDataset) o2).getType());
}
};
sortedCellTable.setComparator(type, c);
}
}
// if (this.displayFields.contains(DISPLAY_FIELD.ICON)) {
// // ICONS
// ImageResourceCell iconResourceCell = new ImageResourceCell() {
// public Set<String> getConsumedEvents() {
// HashSet<String> events = new HashSet<String>();
// events.add("click");
// return events;
// }
// };
//
// icon = new Column<T, ImageResource>(iconResourceCell) {
// @Override
// public ImageResource getValue(T dataObj) {
// return Util.getImage(dataObj);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// * com.google.gwt.user.cellview.client.Column#render(com.google.gwt.cell.client.
// * Cell.Context, java.lang.Object,
// * com.google.gwt.safehtml.shared.SafeHtmlBuilder)
// */
// @Override
// public void render(Context context, T object, SafeHtmlBuilder sb) {
// super.render(context, object, sb);
//
// }
// };
//// icon.setSortable(false);
// sortedCellTable.addColumn(icon, "", false);
// sortedCellTable.setColumnWidth(icon, 32.0, Unit.PX);
// }
if (this.displayFields.contains(DISPLAY_FIELD.NAME)) {
// NAME
name = new TextColumn<T>() {
@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("<div title=\"" + ((CatalogueDataset) object).getName() + "\">");
super.render(context, object, sb);
sb.appendHtmlConstant("</div>");
};
};
sortedCellTable.addColumn(name, "Name", true);
if (!isAsyncronusTable) {
Comparator<T> c = new Comparator<T>() {
@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<T>() {
@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<T> c = new Comparator<T>() {
@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<T>() {
@Override
public String getValue(T object) {
if (object == null)
return "";
return ((CatalogueDataset) object).getAuthor() != null ? ((CatalogueDataset) object).getAuthor()
: "";
}
};
sortedCellTable.addColumn(author, "Title", true);
if (!isAsyncronusTable) {
Comparator<T> c = new Comparator<T>() {
@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.AUTHOR)) {
DateCell date = new DateCell(dtformat);
dateColumn = new Column<T, Date>(date) {
@Override
public Date getValue(T object) {
if (object == null)
return null;
return new Date(((CatalogueDataset) object).getCreated());
}
};
sortedCellTable.addColumn(dateColumn, "Created", true);
if (!isAsyncronusTable) {
Comparator<T> c = new Comparator<T>() {
@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(dateColumn, 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.setDefaultSortOrder(dateColumn, false); // sorts ascending on first click
sortedCellTable.setInitialSortColumn(dateColumn);
GWT.log("sortedCellTable: " + sortedCellTable);
}
break;
default:
break;
}
/*
* final SingleSelectionModel<Item> selectionModel = new
* SingleSelectionModel<Item>(); selectionModel.addSelectionChangeHandler(new
* Handler() {
*
* @Override public void onSelectionChange(SelectionChangeEvent event) { } });
*/
}
/**
* 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 <code>true</code> for ascending icon, <code>false</code>
* for descending icon
*/
public void setSortedColumn(int columnIndex, boolean ascending) {
GWT.log("Column index: " + columnIndex);
GWT.log("ascending: " + ascending);
Column<T, ?> 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<DISPLAY_FIELD> 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 T getSelectedItem() {
return ssm.getSelectedObject();
}
/**
* 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));
}
}

View File

@ -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;
// TODO: Auto-generated Javadoc
/**
* The Class MyToolTipColumn.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 15, 2021
* @param <T> the generic type
* @param <C> the generic type
*/
public abstract class MyToolTipColumn<T, C> extends Column<T, C> {
/**
* 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("<div title=\"{0}\">")
SafeHtml startToolTip(String toolTipText);
/**
* End tool tip.
*
* @return the safe html
*/
@Template("</div>")
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<C> 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());
}
}

View File

@ -0,0 +1,260 @@
/**
*
*/
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.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.ListDataProvider;
/**
* The Class SortedCellTable.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 15, 2021
* @param <T> the generic type
*/
public class SortedCellTable<T> extends CellTable<T> {
/**
* To keep track of the currently sorted column
*/
private Column<T, ?> currentlySortedColumn;
/**
* Tells us which way to sort a column initially
*/
private Map<Column<T, ?>, Boolean> defaultSortOrderMap = new HashMap<Column<T, ?>, Boolean>();
/**
* Comparators associated with their columns
*/
private Map<Column<T, ?>, Comparator<T>> comparators = new HashMap<Column<T, ?>, Comparator<T>>();
/**
* Column to sort when the data provider's list is refreshed using
* {@link SortedCellTable#setList(List)}
*/
private Column<T, ?> initialSortColumn;
/**
* Data provider we will attach to this table
*/
private AbstractDataProvider<T> dataProvider;
/**
* Special column sorting handler that will allow us to do more controlled
* sorting
*/
private ListHandler<T> columnSortHandler;
/**
* Instantiates a new sorted cell table.
*
* @param pageSize the page size
* @param dataProv the data prov
*/
public SortedCellTable(int pageSize, AbstractDataProvider<T> dataProv) {
super(1,CellTableResources.INSTANCE);
this.dataProvider = dataProv;
if(this.dataProvider instanceof ListDataProvider){
columnSortHandler = new ListHandler<T>(((ListDataProvider<T>) this.dataProvider).getList()) {
@Override
public void onColumnSort(ColumnSortEvent event) {
@SuppressWarnings("unchecked")
Column<T, ?> column = (Column<T, ?>) event.getColumn();
if (column == null) {
return;
}
if (column.equals(currentlySortedColumn)) {
// Default behavior
super.onColumnSort(event);
}
else {
// Initial sort; look up which direction we need
final Comparator<T> comparator = comparators.get(column);
if (comparator == null) {
return;
}
Boolean ascending = defaultSortOrderMap.get(column);
if (ascending == null || ascending) {
// Default behavior
super.onColumnSort(event);
}
else {
// Sort the column descending
Collections.sort(getList(), new Comparator<T>() {
public int compare(T o1, T o2) {
return -comparator.compare(o1, o2);
}
});
// Set the proper arrow in the header
getColumnSortList().push(new ColumnSortInfo(column, false));
}
currentlySortedColumn = column;
}
}
@Override
public void setComparator(Column<T, ?> column, Comparator<T> comparator) {
comparators.put(column, comparator);
super.setComparator(column, comparator);
}
};
addColumnSortHandler(columnSortHandler);
}
}
/**
* Adds a column to the table and sets its sortable state.
*
* @param column the column
* @param headerName the header name
* @param sortable the sortable
*/
public void addColumn(Column<T, ?> column, String headerName, boolean sortable) {
addColumn(column, headerName);
column.setSortable(sortable);
if (sortable) {
defaultSortOrderMap.put(column, true);
}
}
/**
* Adds the column.
*
* @param column the column
* @param headerName the header name
*/
/* (non-Javadoc)
* @see com.google.gwt.user.cellview.client.AbstractCellTable#addColumn(com.google.gwt.user.cellview.client.Column, java.lang.String)
*/
public void addColumn(Column<T, ?> column, String headerName) {
super.addColumn(column, headerName);
}
/**
* Adds a column to the table and sets its sortable state.
*
* @param column the column
* @param header the header
* @param sortable the sortable
*/
public void addColumn(Column<T, ?> column, Header<?> header, boolean sortable) {
addColumn(column, header);
column.setSortable(sortable);
if (sortable) {
defaultSortOrderMap.put(column, true);
}
}
/**
* Sets the column to sort when the data list is reset using
* {@link SortedCellTable#setList(List)}.
*
* @param column the column
*/
public void setInitialSortColumn(Column<T, ?> column) {
initialSortColumn = column;
}
/**
* Sets a comparator to use when sorting the given column.
*
* @param column the column
* @param comparator the comparator
*/
public void setComparator(Column<T, ?> column, Comparator<T> comparator) {
columnSortHandler.setComparator(column, comparator);
}
/**
* Sets the sort order to use when this column is clicked and it was not
* previously sorted.
*
* @param column the column
* @param ascending the ascending
*/
public void setDefaultSortOrder(Column<T, ?> column, boolean ascending) {
defaultSortOrderMap.put(column, ascending);
}
/**
* Sets the table's data provider list and sorts the table based on the
* column given in {@link SortedCellTable#setInitialSortColumn(Column)}.
*
* @param list the new list
*/
public void setList(List<T> list) {
if(dataProvider instanceof ListDataProvider){
List<T> myData = ((ListDataProvider) dataProvider).getList();
myData.clear();
if (list != null) {
/*for (T t : list) {
dataProvider.getList().add(t);
}*/
myData.addAll(list);
}
// Do a first-time sort based on which column was set in
// setInitialSortColumn()
if (initialSortColumn != null) {
Collections.sort(myData, new Comparator<T>() {
@Override
public int compare(T o1, T o2) {
return (defaultSortOrderMap.get(initialSortColumn) ? 1 : -1) * comparators.get(initialSortColumn).compare(o1, o2);
}
});
// Might as well get the little arrow on the header to make it
// official
getColumnSortList().push(
new ColumnSortInfo(
initialSortColumn,
defaultSortOrderMap.get(initialSortColumn)));
currentlySortedColumn = initialSortColumn;
}
}
}
/**
* Gets the data provider.
*
* @return the data provider
*/
public AbstractDataProvider<T> getDataProvider() {
return dataProvider;
}
}

View File

@ -0,0 +1,25 @@
@charset "UTF-8";
/*** TABLE ***/
.table-cms-widget {
word-wrap: break-word;
}
.table-cms-widget td, th {
overflow: hidden !important;
}
.table-cms-widget th {
text-align: center !important;
}
.table-cms-widget-vertical-middle td, th {
height: 50%;
vertical-align: middle !important;
}
/***** WS EXPLORER DOCK PANEL - CENTER FLOW PANEL *****/
.we-dock-center-panel {
overflow-y: auto !important;
/* border: 1px solid #DDD; */
}

View File

@ -35,6 +35,7 @@ public class CatalogueBeansConverter {
myDataset.setTitle(t.getTitle()); myDataset.setTitle(t.getTitle());
myDataset.setType(t.getType()); myDataset.setType(t.getType());
myDataset.setUrl(t.getUrl()); myDataset.setUrl(t.getUrl());
myDataset.setCreated(t.getMetadataCreated().getTime());
return myDataset; return myDataset;
} }
}; };

View File

@ -35,6 +35,7 @@ public class CatalogueDataset implements Serializable, IsSerializable {
private String url; private String url;
private String version; private String version;
private String ckanDatasetURL; private String ckanDatasetURL;
private long created;
/** /**
* Instantiates a new ckan dataset base. * Instantiates a new ckan dataset base.
@ -162,6 +163,14 @@ public class CatalogueDataset implements Serializable, IsSerializable {
this.ckanDatasetURL = ckanDatasetURL; this.ckanDatasetURL = ckanDatasetURL;
} }
public void setCreated(long creationTime) {
this.created = creationTime;
}
public long getCreated() {
return created;
}
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -195,6 +204,8 @@ public class CatalogueDataset implements Serializable, IsSerializable {
builder.append(version); builder.append(version);
builder.append(", ckanDatasetURL="); builder.append(", ckanDatasetURL=");
builder.append(ckanDatasetURL); builder.append(ckanDatasetURL);
builder.append(", created=");
builder.append(created);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }

View File

@ -3,21 +3,16 @@
<!-- Inherit the core Web Toolkit stuff. --> <!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' /> <inherits name='com.google.gwt.user.User' />
<inherits name="gwt.material.design.jquery.JQuery" />
<inherits
name="gwt.material.design.GwtMaterialBasicWithJQuery" />
<inherits name="gwt.material.design.addins.GwtMaterialAddins" />
<inherits name="gwt.material.design.themes.ThemeBlue" />
<inherits name="gwt.material.design.GwtMaterialTable" />
<inherits <inherits
name="org.gcube.datacatalogue.utillibrary.CkanUtilLibrary" /> name="org.gcube.datacatalogue.utillibrary.CkanUtilLibrary" />
<inherits name="com.github.gwtbootstrap.Bootstrap" />
<!-- Other module inherits --> <!-- Other module inherits -->
<!-- Specify the app entry point class. --> <!-- Specify the app entry point class. -->
<!-- <entry-point class='org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModeratorWidget' /> --> <!-- <entry-point class='org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModeratorWidget'
/> -->
<!-- Specify the paths for translatable code --> <!-- Specify the paths for translatable code -->
<source path='client' /> <source path='client' />