task_21363 #1
|
@ -1,8 +1,16 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CheckBoxSelectIemsEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CheckBoxSelectIemsEventHandler;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEventHandler;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEventHandler;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEventHandler;
|
||||
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.ContentModeratorToolbar;
|
||||
|
@ -29,7 +37,7 @@ public class CkanContentModeratorWidgetController {
|
|||
|
||||
public final static CkanContentModeratorServiceAsync contentModeratorService = GWT
|
||||
.create(CkanContentModeratorService.class);
|
||||
|
||||
|
||||
private FlowPanel mainPanel = new FlowPanel();
|
||||
|
||||
private ContentModeratorToolbar toolbar;
|
||||
|
@ -42,7 +50,7 @@ public class CkanContentModeratorWidgetController {
|
|||
/**
|
||||
* Instantiates a new ckan content moderator widget.
|
||||
*
|
||||
* @param status the status
|
||||
* @param status the status
|
||||
* @param displayFields the display fields
|
||||
* @param sortByField the sort by field
|
||||
*/
|
||||
|
@ -66,14 +74,49 @@ public class CkanContentModeratorWidgetController {
|
|||
@Override
|
||||
public <T> void onClick(ClickItemEvent<T> clickItemEvent) {
|
||||
|
||||
if (clickItemEvent.getItem() instanceof CatalogueDataset) {
|
||||
CatalogueDataset clickedDataset = (CatalogueDataset) clickItemEvent.getItem();
|
||||
CkanFramePanel cfp = new CkanFramePanel(eventBus);
|
||||
cfp.instanceFrame(clickedDataset.getUrl(), null);
|
||||
mainTabPanel.addTab(clickedDataset.getName(), cfp);
|
||||
// Window.open(clickedDataset.getUrl(), null, "_blank");
|
||||
}
|
||||
if (clickItemEvent.getSelectItems() != null) {
|
||||
List<T> items = clickItemEvent.getSelectItems();
|
||||
// if items selected are > 0 then shows button "Update status as.."
|
||||
howeView.setVisibleUpdateStatusAction(items.size() > 0);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(ShowItemEvent.TYPE, new ShowItemEventHandler() {
|
||||
|
||||
@Override
|
||||
public <T> void onShowItemClicked(ShowItemEvent<T> showItemEvent) {
|
||||
|
||||
if (showItemEvent.getSelectItems() != null) {
|
||||
List<T> items = showItemEvent.getSelectItems();
|
||||
|
||||
for (T t : items) {
|
||||
CatalogueDataset clickedDataset = (CatalogueDataset) t;
|
||||
CkanFramePanel cfp = new CkanFramePanel(eventBus);
|
||||
cfp.instanceFrame(clickedDataset.getUrl(), null);
|
||||
mainTabPanel.addTab(clickedDataset.getTitle(), cfp);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(CheckBoxSelectIemsEvent.TYPE, new CheckBoxSelectIemsEventHandler() {
|
||||
|
||||
@Override
|
||||
public <T> void onValueChanged(CheckBoxSelectIemsEvent<T> onValueChangedEvent) {
|
||||
howeView.markItemsAsChecked(onValueChangedEvent.isChecked(), true);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(TableRangeViewChangedEvent.TYPE, new TableRangeViewChangedEventHandler() {
|
||||
|
||||
@Override
|
||||
public <T> void onRangeChanged(TableRangeViewChangedEvent<T> tableRangeViewChangedEvent) {
|
||||
howeView.setVisibleUpdateStatusAction(false);
|
||||
howeView.setCheckedCheckboxSelectAll(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -93,7 +136,6 @@ public class CkanContentModeratorWidgetController {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check content moderator configuration.
|
||||
*
|
||||
|
@ -113,7 +155,7 @@ public class CkanContentModeratorWidgetController {
|
|||
@Override
|
||||
public void onSuccess(Boolean result) {
|
||||
isContentModeratorEnabled = result;
|
||||
if(whenDone!=null)
|
||||
if (whenDone != null)
|
||||
whenDone.execute();
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class CheckBoxSelectIemsEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 22, 2021
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
public class CheckBoxSelectIemsEvent<T> extends GwtEvent<CheckBoxSelectIemsEventHandler> {
|
||||
public static Type<CheckBoxSelectIemsEventHandler> TYPE = new Type<CheckBoxSelectIemsEventHandler>();
|
||||
private boolean isChecked;
|
||||
|
||||
/**
|
||||
* Instantiates a new click item event.
|
||||
*
|
||||
* @param selectItems the select items
|
||||
*/
|
||||
public CheckBoxSelectIemsEvent(boolean checkedValue) {
|
||||
this.isChecked = checkedValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated type.
|
||||
*
|
||||
* @return the associated type
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||
*/
|
||||
@Override
|
||||
public Type<CheckBoxSelectIemsEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch.
|
||||
*
|
||||
* @param handler the handler
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.
|
||||
* EventHandler)
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(CheckBoxSelectIemsEventHandler handler) {
|
||||
handler.onValueChanged(this);
|
||||
}
|
||||
|
||||
public boolean isChecked() {
|
||||
return isChecked;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
|
||||
/**
|
||||
* The Interface CheckBoxSelectIemsEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 22, 2021
|
||||
*/
|
||||
public interface CheckBoxSelectIemsEventHandler extends EventHandler {
|
||||
|
||||
|
||||
/**
|
||||
* On value changed.
|
||||
*
|
||||
* @param <T> the generic type
|
||||
* @param onValueChangedEvent the on value changed event
|
||||
*/
|
||||
<T> void onValueChanged(CheckBoxSelectIemsEvent<T> onValueChangedEvent);
|
||||
}
|
|
@ -1,29 +1,38 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class ClickItemEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jul 6, 2015
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 22, 2021
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
public class ClickItemEvent<T> extends GwtEvent<ClickItemEventHandler> {
|
||||
public static Type<ClickItemEventHandler> TYPE = new Type<ClickItemEventHandler>();
|
||||
private T item;
|
||||
|
||||
private List<T> selectItems;
|
||||
|
||||
/**
|
||||
* Instantiates a new click item event.
|
||||
*
|
||||
* @param item the item
|
||||
* @param selectItems the select items
|
||||
*/
|
||||
public ClickItemEvent(T item) {
|
||||
this.item = item;
|
||||
public ClickItemEvent(List<T> selectItems) {
|
||||
this.selectItems = selectItems;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* Gets the associated type.
|
||||
*
|
||||
* @return the associated type
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||
*/
|
||||
@Override
|
||||
|
@ -31,8 +40,17 @@ public class ClickItemEvent<T> extends GwtEvent<ClickItemEventHandler> {
|
|||
return TYPE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
|
||||
/**
|
||||
* Dispatch.
|
||||
*
|
||||
* @param handler the handler
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.
|
||||
* EventHandler)
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(ClickItemEventHandler handler) {
|
||||
|
@ -40,11 +58,11 @@ public class ClickItemEvent<T> extends GwtEvent<ClickItemEventHandler> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the item.
|
||||
* Gets the select items.
|
||||
*
|
||||
* @return the item
|
||||
* @return the select items
|
||||
*/
|
||||
public T getItem() {
|
||||
return item;
|
||||
public List<T> getSelectItems() {
|
||||
return selectItems;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class ShowItemEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 22, 2021
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
public class ShowItemEvent<T> extends GwtEvent<ShowItemEventHandler> {
|
||||
public static Type<ShowItemEventHandler> TYPE = new Type<ShowItemEventHandler>();
|
||||
private List<T> selectItems;
|
||||
|
||||
/**
|
||||
* Instantiates a new click item event.
|
||||
*
|
||||
* @param selectItems the select items
|
||||
*/
|
||||
public ShowItemEvent(List<T> selectItems) {
|
||||
this.selectItems = selectItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated type.
|
||||
*
|
||||
* @return the associated type
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||
*/
|
||||
@Override
|
||||
public Type<ShowItemEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch.
|
||||
*
|
||||
* @param handler the handler
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.
|
||||
* EventHandler)
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(ShowItemEventHandler handler) {
|
||||
handler.onShowItemClicked(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the select items.
|
||||
*
|
||||
* @return the select items
|
||||
*/
|
||||
public List<T> getSelectItems() {
|
||||
return selectItems;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Interface ShowItemEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 22, 2021
|
||||
*/
|
||||
public interface ShowItemEventHandler extends EventHandler {
|
||||
|
||||
/**
|
||||
* On show item clicked.
|
||||
*
|
||||
* @param <T> the generic type
|
||||
* @param showItemEvent the show item event
|
||||
*/
|
||||
<T> void onShowItemClicked(ShowItemEvent<T> showItemEvent);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class TableRangeViewChangedEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 22, 2021
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
public class TableRangeViewChangedEvent<T> extends GwtEvent<TableRangeViewChangedEventHandler> {
|
||||
public static Type<TableRangeViewChangedEventHandler> TYPE = new Type<TableRangeViewChangedEventHandler>();
|
||||
private int startIndex;
|
||||
private int limitIndex;
|
||||
|
||||
/**
|
||||
* Instantiates a new click item event.
|
||||
*
|
||||
* @param handler the handler
|
||||
* @return
|
||||
*/
|
||||
public TableRangeViewChangedEvent(int start, int limit) {
|
||||
this.startIndex = start;
|
||||
this.limitIndex = limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<TableRangeViewChangedEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(TableRangeViewChangedEventHandler handler) {
|
||||
handler.onRangeChanged(this);
|
||||
}
|
||||
|
||||
public int getStartIndex() {
|
||||
return startIndex;
|
||||
}
|
||||
|
||||
public int getLimitIndex() {
|
||||
return limitIndex;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
/**
|
||||
* The Interface TableRangeViewChangedEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 22, 2021
|
||||
*/
|
||||
public interface TableRangeViewChangedEventHandler extends EventHandler {
|
||||
|
||||
<T> void onRangeChanged(TableRangeViewChangedEvent<T> tableRangeViewChangedEvent);
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModeratorWidgetController;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ContentModeratorWidgetConstants;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.SortedCellTable;
|
||||
|
@ -48,6 +49,7 @@ public class ContentModeratorPaginatedView {
|
|||
private LoadingPanel loadingPanel = new LoadingPanel(new HTML("Loading data..."));
|
||||
private ItemStatus itemStatus;
|
||||
private int serverStartIndex;
|
||||
private HandlerManager eventBus;
|
||||
|
||||
/**
|
||||
* Instantiates a new content moderator paginated view.
|
||||
|
@ -62,6 +64,7 @@ public class ContentModeratorPaginatedView {
|
|||
DISPLAY_FIELD sortByField) {
|
||||
this.itemStatus = theStatus;
|
||||
this.newLoading = true;
|
||||
this.eventBus = eventbus;
|
||||
itemsTable = new ItemsTable<CatalogueDataset>(eventbus, displayFields, sortByField);
|
||||
itemsTable.initTable(null, null, dataProvider);
|
||||
|
||||
|
@ -215,9 +218,9 @@ public class ContentModeratorPaginatedView {
|
|||
|
||||
GWT.log("calling getDataForStatus with parameters [startIndex: " + offset + ", limit: " + limit
|
||||
+ ", serverIndex:" + serverIndex + "]");
|
||||
|
||||
CkanContentModeratorWidgetController.contentModeratorService.getDataForStatus(status, offset, limit, serverIndex,
|
||||
new AsyncCallback<SearchedData>() {
|
||||
|
||||
CkanContentModeratorWidgetController.contentModeratorService.getDataForStatus(status, offset, limit,
|
||||
serverIndex, new AsyncCallback<SearchedData>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(SearchedData result) {
|
||||
|
@ -264,9 +267,20 @@ public class ContentModeratorPaginatedView {
|
|||
|
||||
GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount());
|
||||
loadNewPage(start, length, false);
|
||||
eventBus.fireEvent(new TableRangeViewChangedEvent<T>(start, length));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void selectItems(boolean select, boolean limitToPage) {
|
||||
SortedCellTable<CatalogueDataset> table = getCellTable();
|
||||
int rowSize = table.getVisibleItemCount();
|
||||
|
||||
for (int i = 0; i < rowSize; i++) {
|
||||
CatalogueDataset item = table.getVisibleItem(i);
|
||||
itemsTable.getSelectionModel().setSelected(item, select);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,12 +4,17 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CheckBoxSelectIemsEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.CheckBox;
|
||||
import com.github.gwtbootstrap.client.ui.Dropdown;
|
||||
import com.github.gwtbootstrap.client.ui.Heading;
|
||||
import com.github.gwtbootstrap.client.ui.NavLink;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
|
@ -17,6 +22,14 @@ import com.google.gwt.user.client.ui.Composite;
|
|||
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class HomeView.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 22, 2021
|
||||
*/
|
||||
public class HomeView extends Composite {
|
||||
|
||||
private static HomeViewUiBinder uiBinder = GWT.create(HomeViewUiBinder.class);
|
||||
|
@ -32,25 +45,52 @@ public class HomeView extends Composite {
|
|||
@UiField
|
||||
Dropdown dropdownSetStatus;
|
||||
|
||||
@UiField
|
||||
Heading pageHeader;
|
||||
|
||||
private List<NavLink> setStatusOptions = new ArrayList<>();
|
||||
|
||||
private ItemStatus displayingItemStatus;
|
||||
|
||||
private HandlerManager eventBus;
|
||||
|
||||
/**
|
||||
* The Interface HomeViewUiBinder.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 22, 2021
|
||||
*/
|
||||
interface HomeViewUiBinder extends UiBinder<Widget, HomeView> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new home view.
|
||||
*
|
||||
* @param eventBus the event bus
|
||||
* @param status the status
|
||||
* @param displayFields the display fields
|
||||
* @param sortByField the sort by field
|
||||
*/
|
||||
public HomeView(HandlerManager eventBus, ItemStatus status, DISPLAY_FIELD[] displayFields,
|
||||
DISPLAY_FIELD sortByField) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.displayingItemStatus = status;
|
||||
this.eventBus = eventBus;
|
||||
this.pageHeader.setSubtext(status.getLabel());
|
||||
paginatedView = new ContentModeratorPaginatedView(eventBus, status, displayFields, sortByField);
|
||||
cmsPanel.addToCenter(paginatedView.getCellPanel());
|
||||
cmsPanel.addToBottom(paginatedView.getPagerPanel());
|
||||
panelContainer.add(cmsPanel.getPanel());
|
||||
setVisibleUpdateStatusAction(false);
|
||||
|
||||
fillSetStatusOptions();
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill set status options.
|
||||
*/
|
||||
private void fillSetStatusOptions() {
|
||||
for (ItemStatus status : ItemStatus.values()) {
|
||||
if (!status.equals(displayingItemStatus)) {
|
||||
|
@ -62,8 +102,57 @@ public class HomeView extends Composite {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind events.
|
||||
*/
|
||||
public void bindEvents() {
|
||||
|
||||
cbSelectAll.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
|
||||
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<Boolean> event) {
|
||||
GWT.log("Is checked: " + cbSelectAll.getValue());
|
||||
eventBus.fireEvent(new CheckBoxSelectIemsEvent<CatalogueDataset>(cbSelectAll.getValue()));
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the panel.
|
||||
*
|
||||
* @return the panel
|
||||
*/
|
||||
public Composite getPanel() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the visible update status action.
|
||||
*
|
||||
* @param bool the new visible update status action
|
||||
*/
|
||||
public void setVisibleUpdateStatusAction(boolean bool) {
|
||||
dropdownSetStatus.setVisible(bool);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark items as checked.
|
||||
*
|
||||
* @param select the select
|
||||
* @param limitToPage the limit to page
|
||||
*/
|
||||
public void markItemsAsChecked(boolean select, boolean limitToPage) {
|
||||
paginatedView.selectItems(select, limitToPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the checked checkbox select all.
|
||||
*
|
||||
* @param bool the new checked checkbox select all
|
||||
*/
|
||||
public void setCheckedCheckboxSelectAll(boolean bool) {
|
||||
cbSelectAll.setValue(bool);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,15 +14,25 @@
|
|||
.margin-left-5 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.headinghome {
|
||||
margin-left: 5px;
|
||||
margin-bottom: 20px;
|
||||
font-size: 16px !important;
|
||||
}
|
||||
.headinghome>small {
|
||||
font-size: 16px !important;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel>
|
||||
<b:Heading ui:field="pageHeader" size="4"
|
||||
addStyleNames="{style.headinghome}">Items with status: </b:Heading>
|
||||
<g:HorizontalPanel
|
||||
addStyleNames="{style.margin-left-5}">
|
||||
<b:CheckBox ui:field="cbSelectAll"></b:CheckBox>
|
||||
<b:Dropdown text="Set status as..."
|
||||
<b:Dropdown text="Update status as..."
|
||||
ui:field="dropdownSetStatus" addStyleNames="{style.margin-left-20}">
|
||||
</b:Dropdown>
|
||||
<!-- <b:SubmitButton addStyleNames="btn">Confirm</b:SubmitButton> -->
|
||||
</g:HorizontalPanel>
|
||||
<g:HTMLPanel ui:field="panelContainer"></g:HTMLPanel>
|
||||
</g:HTMLPanel>
|
||||
|
|
|
@ -3,8 +3,11 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util.UtilFunct;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Tab;
|
||||
import com.github.gwtbootstrap.client.ui.TabPanel;
|
||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.Scheduler;
|
||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||
|
@ -70,6 +73,7 @@ public class MainTabPanel extends Composite {
|
|||
*/
|
||||
public Tab addTab(String heading, Widget w){
|
||||
Tab tab = new Tab();
|
||||
tab.setIcon(IconType.BOOK);
|
||||
tab.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
|
@ -78,7 +82,9 @@ public class MainTabPanel extends Composite {
|
|||
|
||||
}
|
||||
});
|
||||
tab.setHeading(heading);
|
||||
String shortTitle = UtilFunct.ellipsis(heading, 20, false);
|
||||
tab.asWidget().setTitle(heading);
|
||||
tab.setHeading(shortTitle);
|
||||
if(w!=null)
|
||||
tab.add(w);
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -92,11 +94,13 @@ public abstract class AbstractItemsCellTable<T> {
|
|||
GWT.log("Clicked: " + selectedObject);
|
||||
// selectedItem(selectedObject);
|
||||
if (fireEventOnClick)
|
||||
AbstractItemsCellTable.this.eventBus.fireEvent(new ClickItemEvent<T>(selectedObject));
|
||||
AbstractItemsCellTable.this.eventBus.fireEvent(new ClickItemEvent<T>(Arrays.asList(selectedObject)));
|
||||
}
|
||||
}else if (theSelectionModel instanceof MultiSelectionModel) {
|
||||
Set<T> selected = ((MultiSelectionModel<T>) theSelectionModel).getSelectedSet();
|
||||
GWT.log("Selected are:" +selected);
|
||||
if (fireEventOnClick)
|
||||
AbstractItemsCellTable.this.eventBus.fireEvent(new ClickItemEvent<T>(new ArrayList<T>(selected)));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -11,12 +11,14 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ContentModeratorWidgetConstants;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.ContentModeratorWidgetResources;
|
||||
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.Cell.Context;
|
||||
import com.google.gwt.cell.client.CheckboxCell;
|
||||
import com.google.gwt.cell.client.DateCell;
|
||||
import com.google.gwt.cell.client.FieldUpdater;
|
||||
|
@ -38,6 +40,7 @@ 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.SelectionModel;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
|
||||
/**
|
||||
|
@ -86,23 +89,6 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
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.
|
||||
*
|
||||
|
@ -130,36 +116,42 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
this.isAsyncronusTable = dataProvider instanceof ListDataProvider ? false : true;
|
||||
setEmptyTableMessage(ContentModeratorWidgetConstants.NO_DATA);
|
||||
|
||||
// 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)) {
|
||||
final CheckboxCell cellCheckBox = new CheckboxCell(true, false);
|
||||
Column<T, Boolean> checkColumn = new Column<T, Boolean>(cellCheckBox) {
|
||||
@Override
|
||||
public Boolean getValue(T object) {
|
||||
// Get the value from the selection model.
|
||||
return theSelectionModel.isSelected(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Context context, T object, SafeHtmlBuilder sb) {
|
||||
super.render(context, object, sb);
|
||||
GWT.log("added checkbox: " + cellCheckBox + " to object: " + object);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
sortedCellTable.addColumn(checkColumn, "", false);
|
||||
sortedCellTable.setColumnWidth(checkColumn, 40, Unit.PX);
|
||||
|
||||
|
||||
ButtonCell previewButton = new ButtonCell();
|
||||
Column<T,String> showdItemColumn = new Column<T,String>(previewButton) {
|
||||
public String getValue(T object) {
|
||||
return "Show";
|
||||
}
|
||||
Column<T, String> showdItemColumn = new Column<T, String>(previewButton) {
|
||||
public String getValue(T object) {
|
||||
return "Show";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
showdItemColumn.setFieldUpdater(new FieldUpdater<T, String>() {
|
||||
@Override
|
||||
public void update(int index, T object, String value) {
|
||||
GWT.log("clicked");
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void update(int index, T object, String value) {
|
||||
GWT.log("clicked show");
|
||||
eventBus.fireEvent(new ShowItemEvent<T>(Arrays.asList(object)));
|
||||
}
|
||||
});
|
||||
sortedCellTable.addColumn(showdItemColumn);
|
||||
sortedCellTable.setColumnWidth(showdItemColumn, 80, Unit.PX);
|
||||
|
||||
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.NAME)) {
|
||||
|
||||
// NAME
|
||||
|
@ -340,7 +332,7 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
GWT.log("startSortByColumn: " + startSortByColumn);
|
||||
|
||||
if (startSortByColumn != null)
|
||||
|
@ -376,13 +368,6 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* final SingleSelectionModel<Item> selectionModel = new
|
||||
* SingleSelectionModel<Item>(); selectionModel.addSelectionChangeHandler(new
|
||||
* Handler() {
|
||||
*
|
||||
* @Override public void onSelectionChange(SelectionChangeEvent event) { } });
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -506,4 +491,14 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
if (sortedCellTable != null)
|
||||
sortedCellTable.setEmptyTableWidget(new Label(msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the selection model.
|
||||
*
|
||||
* @return the selection model
|
||||
*/
|
||||
public SelectionModel<T> getSelectionModel() {
|
||||
return theSelectionModel;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui.util;
|
||||
|
||||
|
||||
/**
|
||||
* The Class UtilFunct.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 22, 2021
|
||||
*/
|
||||
public class UtilFunct {
|
||||
|
||||
/**
|
||||
* Ellipsis.
|
||||
*
|
||||
* @param value the value
|
||||
* @param lenght the length
|
||||
* @param left the left
|
||||
* @return the string
|
||||
*/
|
||||
public static String ellipsis(String value, int length, boolean left) {
|
||||
if (value.length() < 3)
|
||||
return value;
|
||||
|
||||
if (value.length() > length) {
|
||||
if (left)
|
||||
return "..." + value.substring(value.length() - length + 3);
|
||||
else
|
||||
return value.substring(0, length) + "...";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue