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 com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.ui.ComplexPanel;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
|
||||
/**
|
||||
|
@ -61,7 +62,7 @@ public class CkanContentModeratorWidget {
|
|||
*
|
||||
* @return the panel
|
||||
*/
|
||||
public Composite getPanel() {
|
||||
public ComplexPanel getPanel() {
|
||||
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.ContentModeratorPaginatedView;
|
||||
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.table.ItemsTable.DISPLAY_FIELD;
|
||||
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.user.client.Command;
|
||||
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.Frame;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CkanContentModeratorWidget.
|
||||
*
|
||||
|
@ -31,8 +32,11 @@ public class CkanContentModeratorWidgetController {
|
|||
public final static CkanContentModeratorServiceAsync contentModeratorService = GWT
|
||||
.create(CkanContentModeratorService.class);
|
||||
|
||||
private FlowPanel mainPanel = new FlowPanel();
|
||||
|
||||
// private ItemsTable<CatalogueDataset> itemsTable;
|
||||
private ContentModeratorSystemBaseView cmsPanel = new ContentModeratorSystemBaseView();
|
||||
private ContentModeratorToolbar toolbar;
|
||||
private MainTabPanel mainTabPanel = new MainTabPanel();
|
||||
private Boolean isContentModeratorEnabled = null;
|
||||
private ContentModeratorPaginatedView paginatedView;
|
||||
|
@ -51,11 +55,15 @@ public class CkanContentModeratorWidgetController {
|
|||
// itemsTable.initTable(null, null, new ListDataProvider<CatalogueDataset>());
|
||||
// cmsPanel.add(itemsTable.getCellTable());
|
||||
|
||||
toolbar = new ContentModeratorToolbar(eventBus);
|
||||
paginatedView = new ContentModeratorPaginatedView(eventBus, status, displayFields, sortByField);
|
||||
// cmsPanel.addToTop(new LoadingPanel(new HTML("Loading...")));
|
||||
//cmsPanel.addToTop(toolbar);
|
||||
cmsPanel.addToCenter(paginatedView.getCellPanel());
|
||||
cmsPanel.addToBottom(paginatedView.getPagerPanel());
|
||||
mainTabPanel.addHomeWidget(cmsPanel.getPanel());
|
||||
mainPanel.add(toolbar);
|
||||
mainPanel.add(mainTabPanel);
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
|
@ -129,8 +137,8 @@ public class CkanContentModeratorWidgetController {
|
|||
*
|
||||
* @return the main panel
|
||||
*/
|
||||
public Composite getMainPanel() {
|
||||
return mainTabPanel;
|
||||
public ComplexPanel getMainPanel() {
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
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.view.client.AbstractDataProvider;
|
||||
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.MultiSelectionModel;
|
||||
import com.google.gwt.view.client.SelectionChangeEvent;
|
||||
import com.google.gwt.view.client.SelectionChangeEvent.Handler;
|
||||
import com.google.gwt.view.client.SelectionModel;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
|
||||
|
||||
/**
|
||||
* The Class AbstractItemsCellTable.
|
||||
*
|
||||
|
@ -37,7 +42,7 @@ public abstract class AbstractItemsCellTable<T> {
|
|||
protected SortedCellTable<T> sortedCellTable;
|
||||
protected T itemContextMenu = null;
|
||||
protected boolean fireEventOnClick = true;
|
||||
protected SingleSelectionModel<T> ssm;
|
||||
protected SelectionModel<T> theSelectionModel;
|
||||
protected HandlerManager eventBus;
|
||||
|
||||
/**
|
||||
|
@ -56,28 +61,33 @@ public abstract class AbstractItemsCellTable<T> {
|
|||
* @param eventBus the event bus
|
||||
* @param fireOnClick the fire on click
|
||||
* @param dataProvider the data provider
|
||||
* @param selectionModel the selection model
|
||||
* @param pageSize the page size
|
||||
*/
|
||||
protected void initAbstractTable(HandlerManager eventBus, boolean fireOnClick, AbstractDataProvider<T> dataProvider,
|
||||
int pageSize) {
|
||||
SelectionModel<T> selectionModel, int pageSize) {
|
||||
this.eventBus = eventBus;
|
||||
this.fireEventOnClick = fireOnClick;
|
||||
this.theSelectionModel = selectionModel;
|
||||
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);
|
||||
//sortedCellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
|
||||
|
||||
ssm = new SingleSelectionModel<T>();
|
||||
sortedCellTable.setSelectionModel(ssm);
|
||||
ssm.addSelectionChangeHandler(new Handler() {
|
||||
DefaultSelectionEventManager<T> checkBoxManager = DefaultSelectionEventManager.<T> createCheckboxManager();
|
||||
sortedCellTable.setSelectionModel(theSelectionModel,checkBoxManager);
|
||||
|
||||
theSelectionModel.addSelectionChangeHandler(new Handler() {
|
||||
@Override
|
||||
public void onSelectionChange(final SelectionChangeEvent event) {
|
||||
|
||||
if (theSelectionModel instanceof SingleSelectionModel) {
|
||||
SingleSelectionModel<T> ssm = (SingleSelectionModel<T>) theSelectionModel;
|
||||
final T selectedObject = ssm.getSelectedObject();
|
||||
if (selectedObject != null) {
|
||||
GWT.log("Clicked: " + selectedObject);
|
||||
|
@ -85,6 +95,10 @@ public abstract class AbstractItemsCellTable<T> {
|
|||
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,6 +106,8 @@ public abstract class AbstractItemsCellTable<T> {
|
|||
|
||||
@Override
|
||||
public void onDoubleClick(final DoubleClickEvent event) {
|
||||
if (theSelectionModel instanceof SingleSelectionModel) {
|
||||
SingleSelectionModel<T> ssm = (SingleSelectionModel<T>) theSelectionModel;
|
||||
T selected = ssm.getSelectedObject();
|
||||
if (selected != null) {
|
||||
GWT.log("Double Click: " + selected);
|
||||
|
@ -99,6 +115,8 @@ public abstract class AbstractItemsCellTable<T> {
|
|||
// org.gcube.portlets.widgets.wsexplorer.client.event.LoadFolderEvent<T>(selected));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}, DoubleClickEvent.getType());
|
||||
|
||||
MenuBar options = new MenuBar(true);
|
||||
|
@ -137,14 +155,13 @@ public abstract class AbstractItemsCellTable<T> {
|
|||
public void updateItems(List<T> items, boolean removeOldItems) {
|
||||
|
||||
if (removeOldItems) {
|
||||
// dataProvider.getList().clear();
|
||||
ssm.clear();
|
||||
if (theSelectionModel instanceof SingleSelectionModel) {
|
||||
((SingleSelectionModel<T>) theSelectionModel).clear();
|
||||
} else if (theSelectionModel instanceof MultiSelectionModel) {
|
||||
((MultiSelectionModel<T>) theSelectionModel).clear();
|
||||
}
|
||||
}
|
||||
|
||||
sortedCellTable.setList(items);
|
||||
// dataProvider.flush();
|
||||
// dataProvider.refresh();
|
||||
|
||||
sortedCellTable.setPageSize(items.size() + 1);
|
||||
sortedCellTable.redraw();
|
||||
}
|
||||
|
@ -169,6 +186,8 @@ public abstract class AbstractItemsCellTable<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the fire event on click.
|
||||
*
|
||||
* @param fireEventOnClick the fireEventOnClick to set
|
||||
*/
|
||||
public void setFireEventOnClick(boolean fireEventOnClick) {
|
||||
|
|
|
@ -3,20 +3,24 @@
|
|||
*/
|
||||
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
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.client.ui.SelectionItems;
|
||||
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.CheckboxCell;
|
||||
import com.google.gwt.cell.client.DateCell;
|
||||
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.i18n.client.DateTimeFormat;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
|
@ -32,7 +36,8 @@ 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;
|
||||
|
||||
import com.google.gwt.view.client.MultiSelectionModel;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
|
||||
/**
|
||||
* The Class ItemsTable.
|
||||
|
@ -42,9 +47,8 @@ import com.google.gwt.view.client.ListDataProvider;
|
|||
* Jun 15, 2021
|
||||
* @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> name;
|
||||
private TextColumn<T> title;
|
||||
|
@ -60,17 +64,14 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016
|
||||
*/
|
||||
public static enum DISPLAY_FIELD {
|
||||
TYPE, NAME, TITLE, AUTHOR, CREATED
|
||||
NAME, TITLE, AUTHOR, CREATED, TYPE
|
||||
};
|
||||
|
||||
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.
|
||||
*
|
||||
|
@ -78,8 +79,7 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
* @param fields the fields
|
||||
* @param startSortByColumn the start sort by column
|
||||
*/
|
||||
public ItemsTable(HandlerManager eventBus, DISPLAY_FIELD[] fields,
|
||||
DISPLAY_FIELD startSortByColumn) {
|
||||
public ItemsTable(HandlerManager eventBus, DISPLAY_FIELD[] fields, DISPLAY_FIELD startSortByColumn) {
|
||||
this.eventBus = eventBus;
|
||||
this.startSortByColumn = startSortByColumn;
|
||||
setDisplayFields(fields);
|
||||
|
@ -118,72 +118,29 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
* @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.theSelectionModel = new MultiSelectionModel<T>();
|
||||
initAbstractTable(eventBus, fireEventOnClick, dataProvider, theSelectionModel,
|
||||
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>() {
|
||||
// Checkbox column. This table will uses a checkbox column for selection.
|
||||
// Alternatively, you can call cellTable.setSelectionEnabled(true) to enable
|
||||
// mouse selection.
|
||||
Column<T, Boolean> checkColumn = new Column<T, Boolean>(new CheckboxCell(true, false)) {
|
||||
@Override
|
||||
public String getValue(T object) {
|
||||
if (object == null)
|
||||
return "";
|
||||
|
||||
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());
|
||||
public Boolean getValue(T object) {
|
||||
// Get the value from the selection model.
|
||||
return theSelectionModel.isSelected(object);
|
||||
}
|
||||
};
|
||||
|
||||
sortedCellTable.setComparator(type, c);
|
||||
}
|
||||
|
||||
}
|
||||
sortedCellTable.addColumn(checkColumn, "", false);
|
||||
sortedCellTable.setColumnWidth(checkColumn, 40, Unit.PX);
|
||||
|
||||
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);
|
||||
|
||||
|
@ -335,6 +341,11 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
sortedCellTable.setInitialSortColumn(author);
|
||||
}
|
||||
break;
|
||||
case TYPE:
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.TYPE)) {
|
||||
sortedCellTable.setInitialSortColumn(type);
|
||||
}
|
||||
break;
|
||||
case CREATED:
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.CREATED)) {
|
||||
sortedCellTable.setDefaultSortOrder(dateColumn, false); // sorts ascending on first click
|
||||
|
@ -346,7 +357,6 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* final SingleSelectionModel<Item> selectionModel = new
|
||||
* SingleSelectionModel<Item>(); selectionModel.addSelectionChangeHandler(new
|
||||
|
@ -450,8 +460,21 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
* SelectionItemHandler#getSelectionItem()
|
||||
*/
|
||||
@Override
|
||||
public T getSelectedItem() {
|
||||
return ssm.getSelectedObject();
|
||||
public List<T> getSelectedItems() {
|
||||
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
|
||||
*/
|
||||
public SortedCellTable(int pageSize, AbstractDataProvider<T> dataProv) {
|
||||
super(1,CellTableResources.INSTANCE);
|
||||
super(pageSize,CellTableResources.INSTANCE);
|
||||
this.dataProvider = dataProv;
|
||||
|
||||
if(this.dataProvider instanceof ListDataProvider){
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.server;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
|
||||
|
@ -26,7 +27,16 @@ public class CatalogueBeansConverter {
|
|||
myDataset.setAuthorEmail(t.getAuthorEmail());
|
||||
|
||||
//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.setLicenseId(t.getLicenseId());
|
||||
|
@ -36,7 +46,7 @@ public class CatalogueBeansConverter {
|
|||
myDataset.setNotes(t.getNotes());
|
||||
myDataset.setOwnerOrg(t.getOwnerOrg());
|
||||
myDataset.setTitle(t.getTitle());
|
||||
myDataset.setType(t.getType());
|
||||
|
||||
//here is always null
|
||||
myDataset.setUrl(t.getUrl());
|
||||
myDataset.setCreated(t.getMetadataCreated().getTime());
|
||||
|
|
|
@ -6,7 +6,6 @@ import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
|||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
|
||||
/**
|
||||
* The Class CatalogueDataset.
|
||||
*
|
||||
|
@ -31,10 +30,10 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
|||
private String ownerOrg;
|
||||
private ItemStatus status;
|
||||
private String title;
|
||||
private String type;
|
||||
private String url;
|
||||
private String version;
|
||||
private String d4scienceItemURL;
|
||||
private String extra_ItemURL;
|
||||
private String extra_SystemType;
|
||||
private long created;
|
||||
|
||||
/**
|
||||
|
@ -87,10 +86,6 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
|||
return title;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
@ -100,7 +95,7 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
|||
}
|
||||
|
||||
public String getD4scienceItemURL() {
|
||||
return d4scienceItemURL;
|
||||
return extra_ItemURL;
|
||||
}
|
||||
|
||||
public long getCreated() {
|
||||
|
@ -151,10 +146,6 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
|||
this.title = title;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
@ -163,14 +154,26 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
|||
this.version = version;
|
||||
}
|
||||
|
||||
public void setD4ScienceItemURL(String d4scienceItemURL) {
|
||||
this.d4scienceItemURL = d4scienceItemURL;
|
||||
}
|
||||
|
||||
public void setCreated(long 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
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
@ -196,14 +199,14 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
|||
builder.append(status);
|
||||
builder.append(", title=");
|
||||
builder.append(title);
|
||||
builder.append(", type=");
|
||||
builder.append(type);
|
||||
builder.append(", url=");
|
||||
builder.append(url);
|
||||
builder.append(", version=");
|
||||
builder.append(version);
|
||||
builder.append(", d4scienceItemURL=");
|
||||
builder.append(d4scienceItemURL);
|
||||
builder.append(", extra_ItemURL=");
|
||||
builder.append(extra_ItemURL);
|
||||
builder.append(", extra_SystemType=");
|
||||
builder.append(extra_SystemType);
|
||||
builder.append(", created=");
|
||||
builder.append(created);
|
||||
builder.append("]");
|
||||
|
|
Loading…
Reference in New Issue