task_21363 #1
|
@ -9,6 +9,8 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEv
|
|||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ClickItemEventHandler;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEventHandler;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStausEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStausEventHandler;
|
||||
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;
|
||||
|
@ -56,7 +58,7 @@ public class CkanContentModeratorWidgetController {
|
|||
*/
|
||||
public CkanContentModeratorWidgetController(ItemStatus status, DISPLAY_FIELD[] displayFields,
|
||||
DISPLAY_FIELD sortByField) {
|
||||
toolbar = new ContentModeratorToolbar(eventBus);
|
||||
toolbar = new ContentModeratorToolbar(eventBus, status);
|
||||
howeView = new HomeView(eventBus, status, displayFields, sortByField);
|
||||
mainTabPanel.addHomeWidget(howeView.getPanel());
|
||||
mainPanel.add(toolbar);
|
||||
|
@ -110,23 +112,36 @@ public class CkanContentModeratorWidgetController {
|
|||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventBus.addHandler(TableRangeViewChangedEvent.TYPE, new TableRangeViewChangedEventHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public <T> void onRangeChanged(TableRangeViewChangedEvent<T> tableRangeViewChangedEvent) {
|
||||
howeView.setVisibleUpdateStatusAction(false);
|
||||
howeView.setCheckedCheckboxSelectAll(false);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventBus.addHandler(CloseAllTabsEvent.TYPE, new CloseAllTabsEventHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(CloseAllTabsEvent closeAllTabsEvent) {
|
||||
mainTabPanel.closeTabs();
|
||||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(SelectItemsWithItemStausEvent.TYPE, new SelectItemsWithItemStausEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onValueChanged(SelectItemsWithItemStausEvent statusSelectedEvent) {
|
||||
if(statusSelectedEvent.getItemStatus()!=null) {
|
||||
howeView.loadItemsWithStatus(statusSelectedEvent.getItemStatus());
|
||||
mainTabPanel.selectTab(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
|
||||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
|
||||
/**
|
||||
* The Class SelectItemsWithItemStausEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 25, 2021
|
||||
*/
|
||||
public class SelectItemsWithItemStausEvent extends GwtEvent<SelectItemsWithItemStausEventHandler> {
|
||||
public static Type<SelectItemsWithItemStausEventHandler> TYPE = new Type<SelectItemsWithItemStausEventHandler>();
|
||||
private ItemStatus itemStatus;
|
||||
|
||||
/**
|
||||
* Instantiates a new click item event.
|
||||
*
|
||||
* @param itemStatus the item status
|
||||
*/
|
||||
public SelectItemsWithItemStausEvent(ItemStatus itemStatus) {
|
||||
this.itemStatus = itemStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated type.
|
||||
*
|
||||
* @return the associated type
|
||||
*/
|
||||
@Override
|
||||
public Type<SelectItemsWithItemStausEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch.
|
||||
*
|
||||
* @param handler the handler
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(SelectItemsWithItemStausEventHandler handler) {
|
||||
handler.onValueChanged(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item status.
|
||||
*
|
||||
* @return the item status
|
||||
*/
|
||||
public ItemStatus getItemStatus() {
|
||||
return itemStatus;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
|
||||
/**
|
||||
* The Interface SelectItemsWithItemStausEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 25, 2021
|
||||
*/
|
||||
public interface SelectItemsWithItemStausEventHandler extends EventHandler {
|
||||
|
||||
/**
|
||||
* On value changed.
|
||||
*
|
||||
* @param statusSelectedEvent the status selected event
|
||||
*/
|
||||
void onValueChanged(SelectItemsWithItemStausEvent statusSelectedEvent);
|
||||
}
|
|
@ -42,7 +42,7 @@ public class ContentModeratorPaginatedView {
|
|||
private static final int ITEMS_PER_PAGE = ContentModeratorWidgetConstants.ITEMS_PER_PAGE;
|
||||
private VerticalPanel vPanel = new VerticalPanel();
|
||||
private FlowPanel pagerPanel = new FlowPanel();
|
||||
private Boolean newLoading = false;
|
||||
private Boolean initClassFirstRangeChanged = false;
|
||||
private ItemsTable<CatalogueDataset> itemsTable;
|
||||
private MyCustomDataProvider<CatalogueDataset> dataProvider = new MyCustomDataProvider<CatalogueDataset>();
|
||||
protected Widget orginalLoadingIndicator = null;
|
||||
|
@ -63,14 +63,15 @@ public class ContentModeratorPaginatedView {
|
|||
public ContentModeratorPaginatedView(HandlerManager eventbus, ItemStatus theStatus, DISPLAY_FIELD[] displayFields,
|
||||
DISPLAY_FIELD sortByField) {
|
||||
this.itemStatus = theStatus;
|
||||
this.newLoading = true;
|
||||
this.initClassFirstRangeChanged = true;
|
||||
this.eventBus = eventbus;
|
||||
itemsTable = new ItemsTable<CatalogueDataset>(eventbus, displayFields, sortByField);
|
||||
itemsTable.initTable(null, null, dataProvider);
|
||||
|
||||
orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator();
|
||||
initPagination(ITEMS_PER_PAGE);
|
||||
loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false);
|
||||
//loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false);
|
||||
loadItemsForStatus(theStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,15 +144,15 @@ public class ContentModeratorPaginatedView {
|
|||
* @param limit the limit
|
||||
* @param resetStore the reset store
|
||||
*/
|
||||
public void loadNewPage(final int startIdx, final int limit, final boolean resetStore) {
|
||||
newLoading = resetStore;
|
||||
private void loadNewPage(final int startIdx, final int limit, final boolean resetStore) {
|
||||
//initFirstRangeChanged = resetStore;
|
||||
GWT.log("loading data with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:"
|
||||
+ resetStore + "]");
|
||||
// showLoading(true);
|
||||
|
||||
int newStartIndex = startIdx;
|
||||
|
||||
if (newLoading) {
|
||||
if (resetStore) {
|
||||
GWT.log("Cleaning all data...");
|
||||
newStartIndex = 0;
|
||||
serverStartIndex = 0;
|
||||
|
@ -163,6 +164,13 @@ public class ContentModeratorPaginatedView {
|
|||
loadItemsForStatus(itemStatus, newStartIndex, limit, serverStartIndex);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void loadItemsForStatus(ItemStatus itemStatus) {
|
||||
this.itemStatus = itemStatus;
|
||||
getCellTable().setVisibleRangeAndClearData(new Range(0, ITEMS_PER_PAGE), false);
|
||||
loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new page result.
|
||||
|
@ -173,9 +181,9 @@ public class ContentModeratorPaginatedView {
|
|||
|
||||
serverStartIndex = result.getServerEndIndex();
|
||||
|
||||
if (newLoading) {
|
||||
getCellTable().setVisibleRangeAndClearData(new Range(result.getClientStartIndex(), ITEMS_PER_PAGE), false);
|
||||
}
|
||||
// if (initFirstRangeChanged) {
|
||||
// getCellTable().setVisibleRangeAndClearData(new Range(result.getClientStartIndex(), ITEMS_PER_PAGE), false);
|
||||
// }
|
||||
|
||||
SelectionModel<? super CatalogueDataset> sm = getCellTable().getSelectionModel();
|
||||
|
||||
|
@ -201,7 +209,7 @@ public class ContentModeratorPaginatedView {
|
|||
GWT.log("Search finished!!!");
|
||||
getAsycnDataProvider().updateRowCount(getCellTable().getRowCount(), true);
|
||||
}
|
||||
newLoading = false;
|
||||
//initFirstRangeChanged = false;
|
||||
|
||||
}
|
||||
|
||||
|
@ -260,11 +268,11 @@ public class ContentModeratorPaginatedView {
|
|||
int start = range.getStart();
|
||||
int length = range.getLength();
|
||||
|
||||
if (newLoading) {
|
||||
GWT.log("OnLoading is true.. returning");
|
||||
if (initClassFirstRangeChanged) {
|
||||
GWT.log("initClassFirstRangeChanged is true.. returning");
|
||||
initClassFirstRangeChanged = false;
|
||||
return;
|
||||
}
|
||||
|
||||
GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount());
|
||||
loadNewPage(start, length, false);
|
||||
eventBus.fireEvent(new TableRangeViewChangedEvent<T>(start, length));
|
||||
|
|
|
@ -2,8 +2,10 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
|
|||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEvent;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStausEvent;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Dropdown;
|
||||
import com.github.gwtbootstrap.client.ui.Label;
|
||||
import com.github.gwtbootstrap.client.ui.NavLink;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
|
@ -27,29 +29,35 @@ public class ContentModeratorToolbar extends Composite {
|
|||
@UiField
|
||||
NavLink closeAllTabs;
|
||||
|
||||
@UiField
|
||||
Label statusInfo;
|
||||
|
||||
private HandlerManager eventBus;
|
||||
|
||||
public ContentModeratorToolbar(HandlerManager eventBus) {
|
||||
private ItemStatus activeStatus;
|
||||
|
||||
public ContentModeratorToolbar(HandlerManager eventBus, ItemStatus status) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.eventBus = eventBus;
|
||||
//statusInfo.setReadOnly(true);
|
||||
fillItemStatusOptions();
|
||||
bindEvents();
|
||||
setActiveStatus(status);
|
||||
}
|
||||
|
||||
private void bindEvents() {
|
||||
closeAllTabs.addClickHandler(new ClickHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
eventBus.fireEvent(new CloseAllTabsEvent());
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void fillItemStatusOptions() {
|
||||
for (ItemStatus status : ItemStatus.values()) {
|
||||
for (final ItemStatus status : ItemStatus.values()) {
|
||||
|
||||
NavLink link = new NavLink();
|
||||
link.setText(status.getLabel());
|
||||
|
@ -57,13 +65,23 @@ public class ContentModeratorToolbar extends Composite {
|
|||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
// TODO Auto-generated method stub
|
||||
setActiveStatus(status);
|
||||
eventBus.fireEvent(new SelectItemsWithItemStausEvent(activeStatus));
|
||||
|
||||
}
|
||||
});
|
||||
dropdownSelectStatus.add(link);
|
||||
}
|
||||
}
|
||||
|
||||
private void setActiveStatus(ItemStatus status) {
|
||||
this.activeStatus = status;
|
||||
statusInfo.setText(activeStatus.getLabel());
|
||||
|
||||
}
|
||||
|
||||
public ItemStatus getActiveStatus() {
|
||||
return activeStatus;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,14 +7,26 @@
|
|||
.important {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.margin-top-12 {
|
||||
margin-top: 12px;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel>
|
||||
<b:NavPills>
|
||||
<b:Dropdown text="Select Items with status..."
|
||||
ui:field="dropdownSelectStatus">
|
||||
</b:Dropdown>
|
||||
<b:NavLink ui:field="closeAllTabs">Close All Tabs
|
||||
</b:NavLink>
|
||||
</b:NavPills>
|
||||
<b:Navbar>
|
||||
<b:Nav>
|
||||
<b:Dropdown text="Select Items with status..."
|
||||
ui:field="dropdownSelectStatus">
|
||||
</b:Dropdown>
|
||||
</b:Nav>
|
||||
<b:Nav>
|
||||
<b:Label ui:field="statusInfo" type="INFO"
|
||||
addStyleNames="{style.margin-top-12}"></b:Label>
|
||||
</b:Nav>
|
||||
<b:Nav alignment="RIGHT">
|
||||
<b:NavLink ui:field="closeAllTabs">Close All Tabs
|
||||
</b:NavLink>
|
||||
</b:Nav>
|
||||
</b:Navbar>
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
|
@ -88,9 +88,8 @@ public class HomeView extends Composite {
|
|||
public HomeView(HandlerManager eventBus, ItemStatus status, DISPLAY_FIELD[] displayFields,
|
||||
DISPLAY_FIELD sortByField) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.displayingItemStatus = status;
|
||||
setDisplayingWithStatus(status);
|
||||
this.eventBus = eventBus;
|
||||
this.pageHeader.setSubtext(status.getLabel());
|
||||
paginatedView = new ContentModeratorPaginatedView(eventBus, status, displayFields, sortByField);
|
||||
cmsPanel.addToCenter(paginatedView.getCellPanel());
|
||||
cmsPanel.addToBottom(paginatedView.getPagerPanel());
|
||||
|
@ -114,6 +113,11 @@ public class HomeView extends Composite {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
private void setDisplayingWithStatus(ItemStatus status) {
|
||||
this.displayingItemStatus = status;
|
||||
this.pageHeader.setSubtext(status.getLabel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind events.
|
||||
|
@ -188,10 +192,25 @@ public class HomeView extends Composite {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show confirm.
|
||||
*
|
||||
* @param msg the msg
|
||||
*/
|
||||
public void showConfirm(String msg) {
|
||||
actionConfirmAlert.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load form server the items with status.
|
||||
*
|
||||
* @param itemStatus the item status
|
||||
*/
|
||||
public void loadItemsWithStatus(ItemStatus itemStatus) {
|
||||
setDisplayingWithStatus(itemStatus);
|
||||
paginatedView.loadItemsForStatus(itemStatus);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -91,13 +91,13 @@ public class MainTabPanel extends Composite {
|
|||
|
||||
results.add(tab);
|
||||
mainTabPanel.add(tab);
|
||||
activeTabPanels(false);
|
||||
//activeTabPanels(false);
|
||||
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
mainTabPanel.selectTab(results.size() - 1);
|
||||
//mainTabPanel.selectTab(results.size() - 1);
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -141,7 +141,7 @@ public class MainTabPanel extends Composite {
|
|||
selectTab(0);
|
||||
}
|
||||
|
||||
private void selectTab(int tabIndex) {
|
||||
public void selectTab(int tabIndex) {
|
||||
if (tabIndex <= results.size()) {
|
||||
mainTabPanel.selectTab(tabIndex);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue