task_21363 #1
|
@ -4,6 +4,7 @@ import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
||||||
|
|
||||||
import com.google.gwt.user.client.Command;
|
import com.google.gwt.user.client.Command;
|
||||||
|
import com.google.gwt.user.client.ui.ComplexPanel;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,7 +62,7 @@ public class CkanContentModeratorWidget {
|
||||||
*
|
*
|
||||||
* @return the panel
|
* @return the panel
|
||||||
*/
|
*/
|
||||||
public Composite getPanel() {
|
public ComplexPanel getPanel() {
|
||||||
return cmsController.getMainPanel();
|
return cmsController.getMainPanel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEv
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.CkanFramePanel;
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.CkanFramePanel;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorPaginatedView;
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorPaginatedView;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorSystemBaseView;
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorSystemBaseView;
|
||||||
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorToolbar;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.MainTabPanel;
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.MainTabPanel;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
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;
|
||||||
|
@ -14,11 +15,11 @@ import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
import com.google.gwt.user.client.Command;
|
import com.google.gwt.user.client.Command;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.Anchor;
|
import com.google.gwt.user.client.ui.ComplexPanel;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.Frame;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
|
||||||
// TODO: Auto-generated Javadoc
|
|
||||||
/**
|
/**
|
||||||
* The Class CkanContentModeratorWidget.
|
* The Class CkanContentModeratorWidget.
|
||||||
*
|
*
|
||||||
|
@ -31,8 +32,11 @@ public class CkanContentModeratorWidgetController {
|
||||||
public final static CkanContentModeratorServiceAsync contentModeratorService = GWT
|
public final static CkanContentModeratorServiceAsync contentModeratorService = GWT
|
||||||
.create(CkanContentModeratorService.class);
|
.create(CkanContentModeratorService.class);
|
||||||
|
|
||||||
|
private FlowPanel mainPanel = new FlowPanel();
|
||||||
|
|
||||||
// private ItemsTable<CatalogueDataset> itemsTable;
|
// private ItemsTable<CatalogueDataset> itemsTable;
|
||||||
private ContentModeratorSystemBaseView cmsPanel = new ContentModeratorSystemBaseView();
|
private ContentModeratorSystemBaseView cmsPanel = new ContentModeratorSystemBaseView();
|
||||||
|
private ContentModeratorToolbar toolbar;
|
||||||
private MainTabPanel mainTabPanel = new MainTabPanel();
|
private MainTabPanel mainTabPanel = new MainTabPanel();
|
||||||
private Boolean isContentModeratorEnabled = null;
|
private Boolean isContentModeratorEnabled = null;
|
||||||
private ContentModeratorPaginatedView paginatedView;
|
private ContentModeratorPaginatedView paginatedView;
|
||||||
|
@ -51,11 +55,15 @@ public class CkanContentModeratorWidgetController {
|
||||||
// itemsTable.initTable(null, null, new ListDataProvider<CatalogueDataset>());
|
// itemsTable.initTable(null, null, new ListDataProvider<CatalogueDataset>());
|
||||||
// cmsPanel.add(itemsTable.getCellTable());
|
// cmsPanel.add(itemsTable.getCellTable());
|
||||||
|
|
||||||
|
toolbar = new ContentModeratorToolbar(eventBus);
|
||||||
paginatedView = new ContentModeratorPaginatedView(eventBus, status, displayFields, sortByField);
|
paginatedView = new ContentModeratorPaginatedView(eventBus, status, displayFields, sortByField);
|
||||||
// cmsPanel.addToTop(new LoadingPanel(new HTML("Loading...")));
|
// cmsPanel.addToTop(new LoadingPanel(new HTML("Loading...")));
|
||||||
|
//cmsPanel.addToTop(toolbar);
|
||||||
cmsPanel.addToCenter(paginatedView.getCellPanel());
|
cmsPanel.addToCenter(paginatedView.getCellPanel());
|
||||||
cmsPanel.addToBottom(paginatedView.getPagerPanel());
|
cmsPanel.addToBottom(paginatedView.getPagerPanel());
|
||||||
mainTabPanel.addHomeWidget(cmsPanel.getPanel());
|
mainTabPanel.addHomeWidget(cmsPanel.getPanel());
|
||||||
|
mainPanel.add(toolbar);
|
||||||
|
mainPanel.add(mainTabPanel);
|
||||||
bindEvents();
|
bindEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,8 +137,8 @@ public class CkanContentModeratorWidgetController {
|
||||||
*
|
*
|
||||||
* @return the main panel
|
* @return the main panel
|
||||||
*/
|
*/
|
||||||
public Composite getMainPanel() {
|
public ComplexPanel getMainPanel() {
|
||||||
return mainTabPanel;
|
return mainPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
|
||||||
|
|
||||||
|
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Dropdown;
|
||||||
|
import com.github.gwtbootstrap.client.ui.NavLink;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class ContentModeratorToolbar extends Composite {
|
||||||
|
|
||||||
|
private static ContentModeratorToolbarUiBinder uiBinder = GWT.create(ContentModeratorToolbarUiBinder.class);
|
||||||
|
|
||||||
|
interface ContentModeratorToolbarUiBinder extends UiBinder<Widget, ContentModeratorToolbar> {
|
||||||
|
}
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
Dropdown dropdownSelectStatus;
|
||||||
|
|
||||||
|
private HandlerManager eventBus;
|
||||||
|
|
||||||
|
public ContentModeratorToolbar(HandlerManager eventBus) {
|
||||||
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
fillItemStatusOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillItemStatusOptions() {
|
||||||
|
for (ItemStatus status : ItemStatus.values()) {
|
||||||
|
|
||||||
|
NavLink link = new NavLink();
|
||||||
|
link.setText(status.getLabel());
|
||||||
|
link.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dropdownSelectStatus.add(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||||
|
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||||
|
xmlns:g="urn:import:com.google.gwt.user.client.ui"
|
||||||
|
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
|
||||||
|
|
||||||
|
<ui:style>
|
||||||
|
.important {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
</ui:style>
|
||||||
|
<g:HTMLPanel>
|
||||||
|
<b:NavPills>
|
||||||
|
<b:Dropdown text="Select Items with status..."
|
||||||
|
ui:field="dropdownSelectStatus">
|
||||||
|
</b:Dropdown>
|
||||||
|
<b:NavLink>Close All Tabs
|
||||||
|
</b:NavLink>
|
||||||
|
</b:NavPills>
|
||||||
|
</g:HTMLPanel>
|
||||||
|
</ui:UiBinder>
|
|
@ -1,24 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
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();
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface SelectionItems.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Jun 18, 2021
|
||||||
|
*/
|
||||||
|
public interface SelectionItems {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the selected items.
|
||||||
|
*
|
||||||
|
* @param <T> the generic type
|
||||||
|
* @return the selected items
|
||||||
|
*/
|
||||||
|
<T> List<T> getSelectedItems();
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table;
|
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEvent;
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEvent;
|
||||||
|
|
||||||
|
@ -21,11 +22,15 @@ import com.google.gwt.user.client.ui.MenuBar;
|
||||||
import com.google.gwt.user.client.ui.MenuItem;
|
import com.google.gwt.user.client.ui.MenuItem;
|
||||||
import com.google.gwt.view.client.AbstractDataProvider;
|
import com.google.gwt.view.client.AbstractDataProvider;
|
||||||
import com.google.gwt.view.client.AsyncDataProvider;
|
import com.google.gwt.view.client.AsyncDataProvider;
|
||||||
|
import com.google.gwt.view.client.DefaultSelectionEventManager;
|
||||||
import com.google.gwt.view.client.ListDataProvider;
|
import com.google.gwt.view.client.ListDataProvider;
|
||||||
|
import com.google.gwt.view.client.MultiSelectionModel;
|
||||||
import com.google.gwt.view.client.SelectionChangeEvent;
|
import com.google.gwt.view.client.SelectionChangeEvent;
|
||||||
import com.google.gwt.view.client.SelectionChangeEvent.Handler;
|
import com.google.gwt.view.client.SelectionChangeEvent.Handler;
|
||||||
|
import com.google.gwt.view.client.SelectionModel;
|
||||||
import com.google.gwt.view.client.SingleSelectionModel;
|
import com.google.gwt.view.client.SingleSelectionModel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class AbstractItemsCellTable.
|
* The Class AbstractItemsCellTable.
|
||||||
*
|
*
|
||||||
|
@ -37,7 +42,7 @@ public abstract class AbstractItemsCellTable<T> {
|
||||||
protected SortedCellTable<T> sortedCellTable;
|
protected SortedCellTable<T> sortedCellTable;
|
||||||
protected T itemContextMenu = null;
|
protected T itemContextMenu = null;
|
||||||
protected boolean fireEventOnClick = true;
|
protected boolean fireEventOnClick = true;
|
||||||
protected SingleSelectionModel<T> ssm;
|
protected SelectionModel<T> theSelectionModel;
|
||||||
protected HandlerManager eventBus;
|
protected HandlerManager eventBus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,37 +58,46 @@ public abstract class AbstractItemsCellTable<T> {
|
||||||
/**
|
/**
|
||||||
* Inits the abstract table.
|
* Inits the abstract table.
|
||||||
*
|
*
|
||||||
* @param eventBus the event bus
|
* @param eventBus the event bus
|
||||||
* @param fireOnClick the fire on click
|
* @param fireOnClick the fire on click
|
||||||
* @param dataProvider the data provider
|
* @param dataProvider the data provider
|
||||||
* @param pageSize the page size
|
* @param selectionModel the selection model
|
||||||
|
* @param pageSize the page size
|
||||||
*/
|
*/
|
||||||
protected void initAbstractTable(HandlerManager eventBus, boolean fireOnClick, AbstractDataProvider<T> dataProvider,
|
protected void initAbstractTable(HandlerManager eventBus, boolean fireOnClick, AbstractDataProvider<T> dataProvider,
|
||||||
int pageSize) {
|
SelectionModel<T> selectionModel, int pageSize) {
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.fireEventOnClick = fireOnClick;
|
this.fireEventOnClick = fireOnClick;
|
||||||
|
this.theSelectionModel = selectionModel;
|
||||||
sortedCellTable = new SortedCellTable<T>(pageSize, dataProvider);
|
sortedCellTable = new SortedCellTable<T>(pageSize, dataProvider);
|
||||||
sortedCellTable.addStyleName("table-cms-widget");
|
sortedCellTable.addStyleName("table-cms-widget");
|
||||||
// cellTable.getElement().getStyle().setOverflow(Overflow.HIDDEN);
|
|
||||||
sortedCellTable.addStyleName("table-cms-widget-vertical-middle");
|
sortedCellTable.addStyleName("table-cms-widget-vertical-middle");
|
||||||
sortedCellTable.setStriped(true);
|
sortedCellTable.setStriped(true);
|
||||||
sortedCellTable.setCondensed(true);
|
sortedCellTable.setCondensed(true);
|
||||||
sortedCellTable.setWidth("100%", true);
|
sortedCellTable.setWidth("100%", true);
|
||||||
// dataProvider.addDataDisplay(sortedCellTable);
|
// dataProvider.addDataDisplay(sortedCellTable);
|
||||||
// initTable(cellTable, null, null);
|
// initTable(cellTable, null, null);
|
||||||
sortedCellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
|
//sortedCellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
|
||||||
|
|
||||||
ssm = new SingleSelectionModel<T>();
|
DefaultSelectionEventManager<T> checkBoxManager = DefaultSelectionEventManager.<T> createCheckboxManager();
|
||||||
sortedCellTable.setSelectionModel(ssm);
|
sortedCellTable.setSelectionModel(theSelectionModel,checkBoxManager);
|
||||||
ssm.addSelectionChangeHandler(new Handler() {
|
|
||||||
|
theSelectionModel.addSelectionChangeHandler(new Handler() {
|
||||||
@Override
|
@Override
|
||||||
public void onSelectionChange(final SelectionChangeEvent event) {
|
public void onSelectionChange(final SelectionChangeEvent event) {
|
||||||
final T selectedObject = ssm.getSelectedObject();
|
|
||||||
if (selectedObject != null) {
|
if (theSelectionModel instanceof SingleSelectionModel) {
|
||||||
GWT.log("Clicked: " + selectedObject);
|
SingleSelectionModel<T> ssm = (SingleSelectionModel<T>) theSelectionModel;
|
||||||
// selectedItem(selectedObject);
|
final T selectedObject = ssm.getSelectedObject();
|
||||||
if (fireEventOnClick)
|
if (selectedObject != null) {
|
||||||
AbstractItemsCellTable.this.eventBus.fireEvent(new ClickItemEvent<T>(selectedObject));
|
GWT.log("Clicked: " + selectedObject);
|
||||||
|
// selectedItem(selectedObject);
|
||||||
|
if (fireEventOnClick)
|
||||||
|
AbstractItemsCellTable.this.eventBus.fireEvent(new ClickItemEvent<T>(selectedObject));
|
||||||
|
}
|
||||||
|
}else if (theSelectionModel instanceof MultiSelectionModel) {
|
||||||
|
Set<T> selected = ((MultiSelectionModel<T>) theSelectionModel).getSelectedSet();
|
||||||
|
GWT.log("Selected are:" +selected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -92,12 +106,16 @@ public abstract class AbstractItemsCellTable<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDoubleClick(final DoubleClickEvent event) {
|
public void onDoubleClick(final DoubleClickEvent event) {
|
||||||
T selected = ssm.getSelectedObject();
|
if (theSelectionModel instanceof SingleSelectionModel) {
|
||||||
if (selected != null) {
|
SingleSelectionModel<T> ssm = (SingleSelectionModel<T>) theSelectionModel;
|
||||||
GWT.log("Double Click: " + selected);
|
T selected = ssm.getSelectedObject();
|
||||||
// AbstractItemsCellTable.this.eventBus.fireEvent(new
|
if (selected != null) {
|
||||||
// org.gcube.portlets.widgets.wsexplorer.client.event.LoadFolderEvent<T>(selected));
|
GWT.log("Double Click: " + selected);
|
||||||
|
// AbstractItemsCellTable.this.eventBus.fireEvent(new
|
||||||
|
// org.gcube.portlets.widgets.wsexplorer.client.event.LoadFolderEvent<T>(selected));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}, DoubleClickEvent.getType());
|
}, DoubleClickEvent.getType());
|
||||||
|
|
||||||
|
@ -137,14 +155,13 @@ public abstract class AbstractItemsCellTable<T> {
|
||||||
public void updateItems(List<T> items, boolean removeOldItems) {
|
public void updateItems(List<T> items, boolean removeOldItems) {
|
||||||
|
|
||||||
if (removeOldItems) {
|
if (removeOldItems) {
|
||||||
// dataProvider.getList().clear();
|
if (theSelectionModel instanceof SingleSelectionModel) {
|
||||||
ssm.clear();
|
((SingleSelectionModel<T>) theSelectionModel).clear();
|
||||||
|
} else if (theSelectionModel instanceof MultiSelectionModel) {
|
||||||
|
((MultiSelectionModel<T>) theSelectionModel).clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sortedCellTable.setList(items);
|
sortedCellTable.setList(items);
|
||||||
// dataProvider.flush();
|
|
||||||
// dataProvider.refresh();
|
|
||||||
|
|
||||||
sortedCellTable.setPageSize(items.size() + 1);
|
sortedCellTable.setPageSize(items.size() + 1);
|
||||||
sortedCellTable.redraw();
|
sortedCellTable.redraw();
|
||||||
}
|
}
|
||||||
|
@ -169,6 +186,8 @@ public abstract class AbstractItemsCellTable<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Sets the fire event on click.
|
||||||
|
*
|
||||||
* @param fireEventOnClick the fireEventOnClick to set
|
* @param fireEventOnClick the fireEventOnClick to set
|
||||||
*/
|
*/
|
||||||
public void setFireEventOnClick(boolean fireEventOnClick) {
|
public void setFireEventOnClick(boolean fireEventOnClick) {
|
||||||
|
|
|
@ -3,20 +3,24 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table;
|
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ContentModeratorWidgetConstants;
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ContentModeratorWidgetConstants;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.ContentModeratorWidgetResources;
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.ContentModeratorWidgetResources;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.SelectionItem;
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.SelectionItems;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.Pagination;
|
import com.github.gwtbootstrap.client.ui.Pagination;
|
||||||
import com.google.gwt.cell.client.ButtonCell;
|
import com.google.gwt.cell.client.ButtonCell;
|
||||||
|
import com.google.gwt.cell.client.CheckboxCell;
|
||||||
import com.google.gwt.cell.client.DateCell;
|
import com.google.gwt.cell.client.DateCell;
|
||||||
import com.google.gwt.core.shared.GWT;
|
import com.google.gwt.core.shared.GWT;
|
||||||
|
import com.google.gwt.dom.client.Style.Unit;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||||
import com.google.gwt.resources.client.ImageResource;
|
import com.google.gwt.resources.client.ImageResource;
|
||||||
|
@ -32,19 +36,19 @@ import com.google.gwt.user.client.ui.Image;
|
||||||
import com.google.gwt.user.client.ui.Label;
|
import com.google.gwt.user.client.ui.Label;
|
||||||
import com.google.gwt.view.client.AbstractDataProvider;
|
import com.google.gwt.view.client.AbstractDataProvider;
|
||||||
import com.google.gwt.view.client.ListDataProvider;
|
import com.google.gwt.view.client.ListDataProvider;
|
||||||
|
import com.google.gwt.view.client.MultiSelectionModel;
|
||||||
|
import com.google.gwt.view.client.SingleSelectionModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class ItemsTable.
|
* The Class ItemsTable.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
*
|
*
|
||||||
* Jun 15, 2021
|
* Jun 15, 2021
|
||||||
* @param <T> the generic type
|
* @param <T> the generic type
|
||||||
*/
|
*/
|
||||||
public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTable<T> implements SelectionItem {
|
public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTable<T> implements SelectionItems {
|
||||||
|
|
||||||
// private Column<T, ImageResource> icon;
|
|
||||||
private TextColumn<T> type;
|
private TextColumn<T> type;
|
||||||
private TextColumn<T> name;
|
private TextColumn<T> name;
|
||||||
private TextColumn<T> title;
|
private TextColumn<T> title;
|
||||||
|
@ -60,26 +64,22 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016
|
||||||
*/
|
*/
|
||||||
public static enum DISPLAY_FIELD {
|
public static enum DISPLAY_FIELD {
|
||||||
TYPE, NAME, TITLE, AUTHOR, CREATED
|
NAME, TITLE, AUTHOR, CREATED, TYPE
|
||||||
};
|
};
|
||||||
|
|
||||||
private List<DISPLAY_FIELD> displayFields;
|
private List<DISPLAY_FIELD> displayFields;
|
||||||
private Column<T, Date> dateColumn;
|
private Column<T, Date> dateColumn;
|
||||||
// private List<String> displayProperties;
|
|
||||||
// private boolean showGcubeItemsInfo;
|
|
||||||
private DISPLAY_FIELD startSortByColumn;
|
private DISPLAY_FIELD startSortByColumn;
|
||||||
private boolean isAsyncronusTable;
|
private boolean isAsyncronusTable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new items table.
|
* Instantiates a new items table.
|
||||||
*
|
*
|
||||||
* @param eventBus the event bus
|
* @param eventBus the event bus
|
||||||
* @param fields the fields
|
* @param fields the fields
|
||||||
* @param startSortByColumn the start sort by column
|
* @param startSortByColumn the start sort by column
|
||||||
*/
|
*/
|
||||||
public ItemsTable(HandlerManager eventBus, DISPLAY_FIELD[] fields,
|
public ItemsTable(HandlerManager eventBus, DISPLAY_FIELD[] fields, DISPLAY_FIELD startSortByColumn) {
|
||||||
DISPLAY_FIELD startSortByColumn) {
|
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.startSortByColumn = startSortByColumn;
|
this.startSortByColumn = startSortByColumn;
|
||||||
setDisplayFields(fields);
|
setDisplayFields(fields);
|
||||||
|
@ -118,72 +118,29 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
||||||
* @param pagination the pagination
|
* @param pagination the pagination
|
||||||
* @param dataProvider the data provider
|
* @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
|
@Override
|
||||||
public void initTable(final SimplePager pager, final Pagination pagination, AbstractDataProvider<T> dataProvider) {
|
public void initTable(final SimplePager pager, final Pagination pagination, AbstractDataProvider<T> dataProvider) {
|
||||||
this.dataProvider = dataProvider;
|
this.dataProvider = dataProvider;
|
||||||
initAbstractTable(eventBus, fireEventOnClick, dataProvider, ContentModeratorWidgetConstants.ITEMS_PER_PAGE);
|
this.theSelectionModel = new MultiSelectionModel<T>();
|
||||||
|
initAbstractTable(eventBus, fireEventOnClick, dataProvider, theSelectionModel,
|
||||||
|
ContentModeratorWidgetConstants.ITEMS_PER_PAGE);
|
||||||
this.dataProvider.addDataDisplay(sortedCellTable);
|
this.dataProvider.addDataDisplay(sortedCellTable);
|
||||||
|
|
||||||
// this.isAsyncronusTable = dataProvider instanceof
|
|
||||||
// AbstractDataProvider?true:false;
|
|
||||||
this.isAsyncronusTable = dataProvider instanceof ListDataProvider ? false : true;
|
this.isAsyncronusTable = dataProvider instanceof ListDataProvider ? false : true;
|
||||||
|
|
||||||
// sortedCellTable.setEmptyTableWidget(new
|
|
||||||
// Label(WorkspaceExplorerConstants.WORKSPACE_FOLDER_EMPTY_MESSAGE));
|
|
||||||
setEmptyTableMessage(ContentModeratorWidgetConstants.NO_DATA);
|
setEmptyTableMessage(ContentModeratorWidgetConstants.NO_DATA);
|
||||||
|
|
||||||
if (this.displayFields.contains(DISPLAY_FIELD.TYPE)) {
|
// Checkbox column. This table will uses a checkbox column for selection.
|
||||||
|
// Alternatively, you can call cellTable.setSelectionEnabled(true) to enable
|
||||||
// NAME
|
// mouse selection.
|
||||||
type = new TextColumn<T>() {
|
Column<T, Boolean> checkColumn = new Column<T, Boolean>(new CheckboxCell(true, false)) {
|
||||||
@Override
|
@Override
|
||||||
public String getValue(T object) {
|
public Boolean getValue(T object) {
|
||||||
if (object == null)
|
// Get the value from the selection model.
|
||||||
return "";
|
return theSelectionModel.isSelected(object);
|
||||||
|
|
||||||
String type = ((CatalogueDataset) object).getType();
|
|
||||||
|
|
||||||
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).getType();
|
|
||||||
if (type == null)
|
|
||||||
type = "";
|
|
||||||
sb.appendHtmlConstant("<div title=\"" + type + "\">");
|
|
||||||
super.render(context, object, sb);
|
|
||||||
sb.appendHtmlConstant("</div>");
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
sortedCellTable.addColumn(type, "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);
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
sortedCellTable.addColumn(checkColumn, "", false);
|
||||||
|
sortedCellTable.setColumnWidth(checkColumn, 40, Unit.PX);
|
||||||
|
|
||||||
if (this.displayFields.contains(DISPLAY_FIELD.NAME)) {
|
if (this.displayFields.contains(DISPLAY_FIELD.NAME)) {
|
||||||
|
|
||||||
|
@ -315,6 +272,55 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.displayFields.contains(DISPLAY_FIELD.TYPE)) {
|
||||||
|
|
||||||
|
// NAME
|
||||||
|
type = new TextColumn<T>() {
|
||||||
|
@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("<div title=\"" + type + "\">");
|
||||||
|
super.render(context, object, sb);
|
||||||
|
sb.appendHtmlConstant("</div>");
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sortedCellTable.addColumn(type, "Type", true);
|
||||||
|
|
||||||
|
if (!isAsyncronusTable) {
|
||||||
|
Comparator<T> c = new Comparator<T>() {
|
||||||
|
@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);
|
GWT.log("startSortByColumn: " + startSortByColumn);
|
||||||
|
|
||||||
|
@ -335,6 +341,11 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
||||||
sortedCellTable.setInitialSortColumn(author);
|
sortedCellTable.setInitialSortColumn(author);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case TYPE:
|
||||||
|
if (this.displayFields.contains(DISPLAY_FIELD.TYPE)) {
|
||||||
|
sortedCellTable.setInitialSortColumn(type);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case CREATED:
|
case CREATED:
|
||||||
if (this.displayFields.contains(DISPLAY_FIELD.CREATED)) {
|
if (this.displayFields.contains(DISPLAY_FIELD.CREATED)) {
|
||||||
sortedCellTable.setDefaultSortOrder(dateColumn, false); // sorts ascending on first click
|
sortedCellTable.setDefaultSortOrder(dateColumn, false); // sorts ascending on first click
|
||||||
|
@ -346,7 +357,6 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* final SingleSelectionModel<Item> selectionModel = new
|
* final SingleSelectionModel<Item> selectionModel = new
|
||||||
* SingleSelectionModel<Item>(); selectionModel.addSelectionChangeHandler(new
|
* SingleSelectionModel<Item>(); selectionModel.addSelectionChangeHandler(new
|
||||||
|
@ -450,8 +460,21 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
||||||
* SelectionItemHandler#getSelectionItem()
|
* SelectionItemHandler#getSelectionItem()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public T getSelectedItem() {
|
public List<T> getSelectedItems() {
|
||||||
return ssm.getSelectedObject();
|
if (theSelectionModel instanceof SingleSelectionModel) {
|
||||||
|
T selected = ((SingleSelectionModel<T>) theSelectionModel).getSelectedObject();
|
||||||
|
if (selected != null) {
|
||||||
|
return Arrays.asList(selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (theSelectionModel instanceof MultiSelectionModel) {
|
||||||
|
Set<T> selected = ((MultiSelectionModel<T>) theSelectionModel).getSelectedSet();
|
||||||
|
if (selected != null) {
|
||||||
|
return new ArrayList<T>(selected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class SortedCellTable<T> extends CellTable<T> {
|
||||||
* @param dataProv the data prov
|
* @param dataProv the data prov
|
||||||
*/
|
*/
|
||||||
public SortedCellTable(int pageSize, AbstractDataProvider<T> dataProv) {
|
public SortedCellTable(int pageSize, AbstractDataProvider<T> dataProv) {
|
||||||
super(1,CellTableResources.INSTANCE);
|
super(pageSize,CellTableResources.INSTANCE);
|
||||||
this.dataProvider = dataProv;
|
this.dataProvider = dataProv;
|
||||||
|
|
||||||
if(this.dataProvider instanceof ListDataProvider){
|
if(this.dataProvider instanceof ListDataProvider){
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.portlets.widgets.ckancontentmoderator.server;
|
package org.gcube.portlets.widgets.ckancontentmoderator.server;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
|
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
|
||||||
|
@ -26,7 +27,16 @@ public class CatalogueBeansConverter {
|
||||||
myDataset.setAuthorEmail(t.getAuthorEmail());
|
myDataset.setAuthorEmail(t.getAuthorEmail());
|
||||||
|
|
||||||
//is it needed??
|
//is it needed??
|
||||||
myDataset.setD4ScienceItemURL(null);
|
myDataset.setExtra_ItemURL(null);
|
||||||
|
|
||||||
|
System.out.println("Extras: "+t.getExtrasAsHashMap());
|
||||||
|
Map<String, String> extrasMap = t.getExtrasAsHashMap();
|
||||||
|
if(extrasMap!=null) {
|
||||||
|
String type = extrasMap.get("system:type");
|
||||||
|
myDataset.setExtra_SystemType(type);
|
||||||
|
String itemURL = extrasMap.get("Item URL");
|
||||||
|
myDataset.setExtra_ItemURL(itemURL);
|
||||||
|
}
|
||||||
|
|
||||||
myDataset.setId(t.getId());
|
myDataset.setId(t.getId());
|
||||||
myDataset.setLicenseId(t.getLicenseId());
|
myDataset.setLicenseId(t.getLicenseId());
|
||||||
|
@ -36,7 +46,7 @@ public class CatalogueBeansConverter {
|
||||||
myDataset.setNotes(t.getNotes());
|
myDataset.setNotes(t.getNotes());
|
||||||
myDataset.setOwnerOrg(t.getOwnerOrg());
|
myDataset.setOwnerOrg(t.getOwnerOrg());
|
||||||
myDataset.setTitle(t.getTitle());
|
myDataset.setTitle(t.getTitle());
|
||||||
myDataset.setType(t.getType());
|
|
||||||
//here is always null
|
//here is always null
|
||||||
myDataset.setUrl(t.getUrl());
|
myDataset.setUrl(t.getUrl());
|
||||||
myDataset.setCreated(t.getMetadataCreated().getTime());
|
myDataset.setCreated(t.getMetadataCreated().getTime());
|
||||||
|
|
|
@ -6,7 +6,6 @@ import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CatalogueDataset.
|
* The Class CatalogueDataset.
|
||||||
*
|
*
|
||||||
|
@ -31,10 +30,10 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
||||||
private String ownerOrg;
|
private String ownerOrg;
|
||||||
private ItemStatus status;
|
private ItemStatus status;
|
||||||
private String title;
|
private String title;
|
||||||
private String type;
|
|
||||||
private String url;
|
private String url;
|
||||||
private String version;
|
private String version;
|
||||||
private String d4scienceItemURL;
|
private String extra_ItemURL;
|
||||||
|
private String extra_SystemType;
|
||||||
private long created;
|
private long created;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,10 +86,6 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +95,7 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getD4scienceItemURL() {
|
public String getD4scienceItemURL() {
|
||||||
return d4scienceItemURL;
|
return extra_ItemURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCreated() {
|
public long getCreated() {
|
||||||
|
@ -151,10 +146,6 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUrl(String url) {
|
public void setUrl(String url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
@ -163,14 +154,26 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setD4ScienceItemURL(String d4scienceItemURL) {
|
|
||||||
this.d4scienceItemURL = d4scienceItemURL;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreated(long created) {
|
public void setCreated(long created) {
|
||||||
this.created = created;
|
this.created = created;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getExtra_ItemURL() {
|
||||||
|
return extra_ItemURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExtra_ItemURL(String extra_ItemURL) {
|
||||||
|
this.extra_ItemURL = extra_ItemURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getExtra_SystemType() {
|
||||||
|
return extra_SystemType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExtra_SystemType(String extra_SystemType) {
|
||||||
|
this.extra_SystemType = extra_SystemType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
@ -196,14 +199,14 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
||||||
builder.append(status);
|
builder.append(status);
|
||||||
builder.append(", title=");
|
builder.append(", title=");
|
||||||
builder.append(title);
|
builder.append(title);
|
||||||
builder.append(", type=");
|
|
||||||
builder.append(type);
|
|
||||||
builder.append(", url=");
|
builder.append(", url=");
|
||||||
builder.append(url);
|
builder.append(url);
|
||||||
builder.append(", version=");
|
builder.append(", version=");
|
||||||
builder.append(version);
|
builder.append(version);
|
||||||
builder.append(", d4scienceItemURL=");
|
builder.append(", extra_ItemURL=");
|
||||||
builder.append(d4scienceItemURL);
|
builder.append(extra_ItemURL);
|
||||||
|
builder.append(", extra_SystemType=");
|
||||||
|
builder.append(extra_SystemType);
|
||||||
builder.append(", created=");
|
builder.append(", created=");
|
||||||
builder.append(created);
|
builder.append(created);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
|
|
Loading…
Reference in New Issue