2021-05-06 17:48:18 +02:00
|
|
|
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
|
|
|
|
2021-06-14 17:39:44 +02:00
|
|
|
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
2021-06-16 18:02:54 +02:00
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEvent;
|
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEventHandler;
|
2021-06-16 15:53:06 +02:00
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorPaginatedView;
|
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorSystemBaseView;
|
2021-06-15 12:38:59 +02:00
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
2021-06-16 18:02:54 +02:00
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
2021-06-01 13:24:09 +02:00
|
|
|
|
2021-05-06 17:48:18 +02:00
|
|
|
import com.google.gwt.core.client.GWT;
|
2021-06-16 18:02:54 +02:00
|
|
|
import com.google.gwt.event.shared.HandlerManager;
|
2021-06-15 16:52:27 +02:00
|
|
|
import com.google.gwt.user.client.Command;
|
2021-06-01 18:36:18 +02:00
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
2021-06-16 11:25:49 +02:00
|
|
|
import com.google.gwt.user.client.ui.Composite;
|
2021-06-01 13:24:09 +02:00
|
|
|
|
2021-05-06 17:48:18 +02:00
|
|
|
/**
|
2021-06-15 16:52:27 +02:00
|
|
|
* The Class CkanContentModeratorWidget.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
|
|
|
*
|
|
|
|
* Jun 15, 2021
|
2021-05-06 17:48:18 +02:00
|
|
|
*/
|
2021-06-15 12:38:59 +02:00
|
|
|
public class CkanContentModeratorWidget {
|
|
|
|
|
2021-06-16 15:53:06 +02:00
|
|
|
public final static CkanContentModeratorServiceAsync contentModeratorService = GWT
|
2021-06-15 16:52:27 +02:00
|
|
|
.create(CkanContentModeratorService.class);
|
|
|
|
|
2021-06-16 15:53:06 +02:00
|
|
|
// private ItemsTable<CatalogueDataset> itemsTable;
|
|
|
|
private ContentModeratorSystemBaseView cmsPanel = new ContentModeratorSystemBaseView();
|
2021-06-15 16:52:27 +02:00
|
|
|
private Boolean isContentModeratorEnabled = null;
|
2021-06-16 15:53:06 +02:00
|
|
|
private ContentModeratorPaginatedView paginatedView;
|
2021-06-16 18:02:54 +02:00
|
|
|
public final static HandlerManager eventBus = new HandlerManager(null);
|
2021-06-15 16:52:27 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new ckan content moderator widget.
|
|
|
|
*
|
|
|
|
* @param displayFields the display fields
|
|
|
|
* @param sortByField the sort by field
|
|
|
|
*/
|
2021-06-16 15:53:06 +02:00
|
|
|
public CkanContentModeratorWidget(ItemStatus status, DISPLAY_FIELD[] displayFields, DISPLAY_FIELD sortByField) {
|
|
|
|
// itemsTable = new ItemsTable<CatalogueDataset>(null, displayFields, sortByField);
|
|
|
|
// itemsTable.initTable(null, null, new ListDataProvider<CatalogueDataset>());
|
|
|
|
// cmsPanel.add(itemsTable.getCellTable());
|
|
|
|
|
2021-06-16 18:02:54 +02:00
|
|
|
paginatedView = new ContentModeratorPaginatedView(eventBus, status, displayFields, sortByField);
|
2021-06-16 15:53:06 +02:00
|
|
|
//cmsPanel.addToTop(new LoadingPanel(new HTML("Loading...")));
|
|
|
|
cmsPanel.addToCenter(paginatedView.getCellPanel());
|
|
|
|
cmsPanel.addToBottom(paginatedView.getPagerPanel());
|
2021-06-16 18:02:54 +02:00
|
|
|
bindEvents();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void bindEvents() {
|
|
|
|
|
|
|
|
|
|
|
|
eventBus.addHandler(ClickItemEvent.TYPE, new ClickItemEventHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public <T> void onClick(ClickItemEvent<T> clickItemEvent) {
|
|
|
|
|
|
|
|
if(clickItemEvent.getItem() instanceof CatalogueDataset) {
|
|
|
|
CatalogueDataset clickedDataset = (CatalogueDataset) clickItemEvent.getItem();
|
|
|
|
//Window.open(clickedDataset.getUrl(), null, "_blank");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2021-06-15 12:38:59 +02:00
|
|
|
}
|
2021-06-15 16:52:27 +02:00
|
|
|
|
2021-06-16 15:53:06 +02:00
|
|
|
// /**
|
|
|
|
// * Load items for status.
|
|
|
|
// *
|
|
|
|
// * @param status the status
|
|
|
|
// * @throws Exception the exception
|
|
|
|
// */
|
|
|
|
// public void loadItemsForStatus(ItemStatus status) throws Exception {
|
|
|
|
//
|
|
|
|
// if (isContentModeratorEnabled == null)
|
|
|
|
// throw new Exception("Please, first check if the content moderator is enabled in this context");
|
|
|
|
//
|
|
|
|
// if (!isContentModeratorEnabled)
|
|
|
|
// throw new Exception("Content Moderator is not enabled in this context");
|
|
|
|
//
|
|
|
|
// cmsPanel.showLoading(true);
|
|
|
|
// contentModeratorService.getListItemsForStatus(status, ContentModeratorWidgetConstants.ITEMS_PER_PAGE,
|
|
|
|
// ContentModeratorWidgetConstants.ITEM_START_INDEX, new AsyncCallback<List<CatalogueDataset>>() {
|
|
|
|
//
|
|
|
|
// @Override
|
|
|
|
// public void onSuccess(List<CatalogueDataset> result) {
|
|
|
|
// cmsPanel.showLoading(false);
|
|
|
|
// itemsTable.updateItems(result, true);
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// @Override
|
|
|
|
// public void onFailure(Throwable caught) {
|
|
|
|
// cmsPanel.showLoading(false);
|
|
|
|
// // TODO Auto-generated method stub
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
//
|
|
|
|
// }
|
2021-06-15 16:52:27 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if is content moderator enabled.
|
|
|
|
*
|
|
|
|
* @param onCompletation the on completation
|
|
|
|
*/
|
|
|
|
public void isContentModeratorEnabled(final Command onCompletation) {
|
|
|
|
|
|
|
|
contentModeratorService.isContentModeratorEnabled(new AsyncCallback<Boolean>() {
|
|
|
|
|
2021-06-01 18:36:18 +02:00
|
|
|
@Override
|
2021-06-15 16:52:27 +02:00
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
onCompletation.execute();
|
|
|
|
|
2021-06-01 18:36:18 +02:00
|
|
|
}
|
2021-06-15 16:52:27 +02:00
|
|
|
|
2021-06-01 18:36:18 +02:00
|
|
|
@Override
|
2021-06-15 16:52:27 +02:00
|
|
|
public void onSuccess(Boolean result) {
|
|
|
|
isContentModeratorEnabled = result;
|
|
|
|
onCompletation.execute();
|
|
|
|
|
2021-06-01 18:36:18 +02:00
|
|
|
}
|
2021-06-15 12:38:59 +02:00
|
|
|
});
|
2021-06-15 16:52:27 +02:00
|
|
|
|
|
|
|
}
|
2021-06-15 18:36:28 +02:00
|
|
|
|
2021-06-16 11:25:49 +02:00
|
|
|
public Composite getPanel(){
|
|
|
|
return cmsPanel.getPanel();
|
2021-05-26 17:58:12 +02:00
|
|
|
}
|
2021-05-06 17:48:18 +02:00
|
|
|
}
|