task_21363 #1

Closed
francesco.mangiacrapa wants to merge 53 commits from task_21363 into master
11 changed files with 306 additions and 130 deletions
Showing only changes of commit 9977824106 - Show all commits

View File

@ -9,8 +9,11 @@ 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.ClickItemEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEvent; 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.CloseAllTabsEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStausEvent; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.IFrameInstanciedEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStausEventHandler; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.IFrameInstanciedEvent.OPERATION;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.IFrameInstanciedEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStatusEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStatusEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowItemEvent; 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.ShowItemEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent;
@ -104,6 +107,28 @@ public class CkanContentModeratorWidgetController {
} }
}); });
eventBus.addHandler(IFrameInstanciedEvent.TYPE, new IFrameInstanciedEventHandler() {
@Override
public void onIFrameAction(IFrameInstanciedEvent iFrameInstanciedEent) {
OPERATION operation = iFrameInstanciedEent.getOperation();
if (operation != null) {
switch (operation) {
case INIT:
break;
case ONLOAD:
break;
default:
break;
}
}
}
});
eventBus.addHandler(CheckBoxSelectIemsEvent.TYPE, new CheckBoxSelectIemsEventHandler() { eventBus.addHandler(CheckBoxSelectIemsEvent.TYPE, new CheckBoxSelectIemsEventHandler() {
@Override @Override
@ -130,16 +155,16 @@ public class CkanContentModeratorWidgetController {
} }
}); });
eventBus.addHandler(SelectItemsWithItemStausEvent.TYPE, new SelectItemsWithItemStausEventHandler() { eventBus.addHandler(SelectItemsWithItemStatusEvent.TYPE, new SelectItemsWithItemStatusEventHandler() {
@Override @Override
public void onValueChanged(SelectItemsWithItemStausEvent statusSelectedEvent) { public void onValueChanged(SelectItemsWithItemStatusEvent statusSelectedEvent) {
if(statusSelectedEvent.getItemStatus()!=null) { GWT.log("On value changed: "+statusSelectedEvent.getItemStatus());
if (statusSelectedEvent.getItemStatus() != null) {
howeView.loadItemsWithStatus(statusSelectedEvent.getItemStatus()); howeView.loadItemsWithStatus(statusSelectedEvent.getItemStatus());
mainTabPanel.selectTab(0); mainTabPanel.selectTab(0);
} }
} }
}); });
} }

View File

@ -4,26 +4,48 @@ import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.user.client.ui.Frame; import com.google.gwt.user.client.ui.Frame;
/** /**
* The Class NotifyLogoutEvent. * The Class IFrameInstanciedEvent.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* Jun 23, 2016 *
* Jun 28, 2021
*/ */
public class IFrameInstanciedEvent extends GwtEvent<IFrameInstanciedEventHandler> { public class IFrameInstanciedEvent extends GwtEvent<IFrameInstanciedEventHandler> {
public static Type<IFrameInstanciedEventHandler> TYPE = new Type<IFrameInstanciedEventHandler>(); public static Type<IFrameInstanciedEventHandler> TYPE = new Type<IFrameInstanciedEventHandler>();
private Frame iFrame; private Frame iFrame;
private OPERATION operation;
/**
* The Enum OPERATION.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 28, 2021
*/
public static enum OPERATION {
INIT, ONLOAD
}
/** /**
* Instantiates a new insert metadata event. * Instantiates a new insert metadata event.
*
* @param iFrame the i frame
* @param operation the operation
*/ */
public IFrameInstanciedEvent(Frame iFrame) { public IFrameInstanciedEvent(Frame iFrame, OPERATION operation) {
this.iFrame = iFrame; this.iFrame = iFrame;
this.operation = operation;
} }
/* (non-Javadoc) /**
* Gets the associated type.
*
* @return the associated type
*/
/*
* (non-Javadoc)
*
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/ */
@Override @Override
@ -31,16 +53,39 @@ public class IFrameInstanciedEvent extends GwtEvent<IFrameInstanciedEventHandler
return TYPE; 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 @Override
protected void dispatch(IFrameInstanciedEventHandler handler) { protected void dispatch(IFrameInstanciedEventHandler handler) {
handler.onNewInstance(this); handler.onIFrameAction(this);
} }
/**
* Gets the i frame.
*
* @return the i frame
*/
public Frame getiFrame() { public Frame getiFrame() {
return iFrame; return iFrame;
} }
/**
* Gets the operation.
*
* @return the operation
*/
public OPERATION getOperation() {
return operation;
}
} }

View File

@ -3,21 +3,21 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client.events;
import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.EventHandler;
/** /**
* The Interface IFrameInstanciedEentHandler. * The Interface IFrameInstanciedEventHandler.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* Jun 23, 2016 *
* Jun 28, 2021
*/ */
public interface IFrameInstanciedEventHandler extends EventHandler { public interface IFrameInstanciedEventHandler extends EventHandler {
/** /**
* On new instance. * On I frame action.
* *
* @param iFrameInstanciedEent the i frame instancied eent * @param iFrameInstanciedEent the i frame instancied eent
*/ */
void onNewInstance(IFrameInstanciedEvent iFrameInstanciedEent); void onIFrameAction(IFrameInstanciedEvent iFrameInstanciedEent);
} }

View File

@ -4,16 +4,15 @@ import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.GwtEvent;
/** /**
* The Class SelectItemsWithItemStausEvent. * The Class SelectItemsWithItemStatusEvent.
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Jun 25, 2021 * Jun 28, 2021
*/ */
public class SelectItemsWithItemStausEvent extends GwtEvent<SelectItemsWithItemStausEventHandler> { public class SelectItemsWithItemStatusEvent extends GwtEvent<SelectItemsWithItemStatusEventHandler> {
public static Type<SelectItemsWithItemStausEventHandler> TYPE = new Type<SelectItemsWithItemStausEventHandler>(); public static Type<SelectItemsWithItemStatusEventHandler> TYPE = new Type<SelectItemsWithItemStatusEventHandler>();
private ItemStatus itemStatus; private ItemStatus itemStatus;
/** /**
@ -21,7 +20,7 @@ public class SelectItemsWithItemStausEvent extends GwtEvent<SelectItemsWithItemS
* *
* @param itemStatus the item status * @param itemStatus the item status
*/ */
public SelectItemsWithItemStausEvent(ItemStatus itemStatus) { public SelectItemsWithItemStatusEvent(ItemStatus itemStatus) {
this.itemStatus = itemStatus; this.itemStatus = itemStatus;
} }
@ -31,7 +30,7 @@ public class SelectItemsWithItemStausEvent extends GwtEvent<SelectItemsWithItemS
* @return the associated type * @return the associated type
*/ */
@Override @Override
public Type<SelectItemsWithItemStausEventHandler> getAssociatedType() { public Type<SelectItemsWithItemStatusEventHandler> getAssociatedType() {
return TYPE; return TYPE;
} }
@ -41,7 +40,7 @@ public class SelectItemsWithItemStausEvent extends GwtEvent<SelectItemsWithItemS
* @param handler the handler * @param handler the handler
*/ */
@Override @Override
protected void dispatch(SelectItemsWithItemStausEventHandler handler) { protected void dispatch(SelectItemsWithItemStatusEventHandler handler) {
handler.onValueChanged(this); handler.onValueChanged(this);
} }

View File

@ -4,18 +4,18 @@ import com.google.gwt.event.shared.EventHandler;
/** /**
* The Interface SelectItemsWithItemStausEventHandler. * The Interface SelectItemsWithItemStatusEventHandler.
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Jun 25, 2021 * Jun 28, 2021
*/ */
public interface SelectItemsWithItemStausEventHandler extends EventHandler { public interface SelectItemsWithItemStatusEventHandler extends EventHandler {
/** /**
* On value changed. * On value changed.
* *
* @param statusSelectedEvent the status selected event * @param statusSelectedEvent the status selected event
*/ */
void onValueChanged(SelectItemsWithItemStausEvent statusSelectedEvent); void onValueChanged(SelectItemsWithItemStatusEvent statusSelectedEvent);
} }

View File

@ -4,6 +4,7 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui; package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.IFrameInstanciedEvent; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.IFrameInstanciedEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.IFrameInstanciedEvent.OPERATION;
import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.ContentModeratorWidgetResources; import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.ContentModeratorWidgetResources;
import com.google.gwt.core.shared.GWT; import com.google.gwt.core.shared.GWT;
@ -107,6 +108,7 @@ public class CkanFramePanel extends FlowPanel{
public void onLoad(LoadEvent arg0) { public void onLoad(LoadEvent arg0) {
CkanFramePanel.this.remove(loading); CkanFramePanel.this.remove(loading);
eventBus.fireEvent(new IFrameInstanciedEvent(frame, OPERATION.ONLOAD));
if(messageToSend!=null) if(messageToSend!=null)
sendMessage(messageToSend, iFrameRandomName); sendMessage(messageToSend, iFrameRandomName);
@ -114,7 +116,7 @@ public class CkanFramePanel extends FlowPanel{
}); });
add(frame); add(frame);
frame.setVisible(true); frame.setVisible(true);
eventBus.fireEvent(new IFrameInstanciedEvent(frame)); eventBus.fireEvent(new IFrameInstanciedEvent(frame, OPERATION.INIT));
return frame; return frame;
} }

View File

@ -25,10 +25,12 @@ import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.AsyncDataProvider; import com.google.gwt.view.client.AsyncDataProvider;
import com.google.gwt.view.client.HasData; import com.google.gwt.view.client.HasData;
import com.google.gwt.view.client.MultiSelectionModel;
import com.google.gwt.view.client.Range; import com.google.gwt.view.client.Range;
import com.google.gwt.view.client.SelectionModel; import com.google.gwt.view.client.SelectionModel;
import com.google.gwt.view.client.SingleSelectionModel; import com.google.gwt.view.client.SingleSelectionModel;
// TODO: Auto-generated Javadoc
/** /**
* The Class ContentModeratorPaginatedView. * The Class ContentModeratorPaginatedView.
* *
@ -54,8 +56,7 @@ public class ContentModeratorPaginatedView {
/** /**
* Instantiates a new content moderator paginated view. * Instantiates a new content moderator paginated view.
* *
* @param eventbus * @param eventbus the eventbus
*
* @param theStatus the the status * @param theStatus the the status
* @param displayFields the display fields * @param displayFields the display fields
* @param sortByField the sort by field * @param sortByField the sort by field
@ -70,7 +71,7 @@ public class ContentModeratorPaginatedView {
orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator(); orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator();
initPagination(ITEMS_PER_PAGE); initPagination(ITEMS_PER_PAGE);
//loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false); // loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false);
loadItemsForStatus(theStatus); loadItemsForStatus(theStatus);
} }
@ -145,9 +146,8 @@ public class ContentModeratorPaginatedView {
* @param resetStore the reset store * @param resetStore the reset store
*/ */
private void loadNewPage(final int startIdx, final int limit, final boolean resetStore) { private void loadNewPage(final int startIdx, final int limit, final boolean resetStore) {
//initFirstRangeChanged = resetStore; // initFirstRangeChanged = resetStore;
GWT.log("loading data with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:" GWT.log("loadNewPage with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:"+ resetStore + "]");
+ resetStore + "]");
// showLoading(true); // showLoading(true);
int newStartIndex = startIdx; int newStartIndex = startIdx;
@ -158,14 +158,17 @@ public class ContentModeratorPaginatedView {
serverStartIndex = 0; serverStartIndex = 0;
GWT.log("Store reset performed start index is: " + newStartIndex); GWT.log("Store reset performed start index is: " + newStartIndex);
getAsycnDataProvider().updateRowCount(ITEMS_PER_PAGE, false); getAsycnDataProvider().updateRowCount(ITEMS_PER_PAGE, false);
// newLoading = false;
} }
loadItemsForStatus(itemStatus, newStartIndex, limit, serverStartIndex); loadItemsForStatus(itemStatus, newStartIndex, limit, serverStartIndex);
} }
/**
* Load items for status.
*
* @param itemStatus the item status
*/
public void loadItemsForStatus(ItemStatus itemStatus) { public void loadItemsForStatus(ItemStatus itemStatus) {
this.itemStatus = itemStatus; this.itemStatus = itemStatus;
getCellTable().setVisibleRangeAndClearData(new Range(0, ITEMS_PER_PAGE), false); getCellTable().setVisibleRangeAndClearData(new Range(0, ITEMS_PER_PAGE), false);
@ -178,18 +181,16 @@ public class ContentModeratorPaginatedView {
* @param result the new new page result * @param result the new new page result
*/ */
private void setNewPageResult(SearchedData result) { private void setNewPageResult(SearchedData result) {
GWT.log("setNewPageResult: "+result);
serverStartIndex = result.getServerEndIndex(); serverStartIndex = result.getServerEndIndex();
// if (initFirstRangeChanged) {
// getCellTable().setVisibleRangeAndClearData(new Range(result.getClientStartIndex(), ITEMS_PER_PAGE), false);
// }
SelectionModel<? super CatalogueDataset> sm = getCellTable().getSelectionModel(); SelectionModel<? super CatalogueDataset> sm = getCellTable().getSelectionModel();
if (sm instanceof SingleSelectionModel) { if (sm instanceof SingleSelectionModel) {
SingleSelectionModel<CatalogueDataset> ssm = (SingleSelectionModel<CatalogueDataset>) sm; SingleSelectionModel<CatalogueDataset> ssm = (SingleSelectionModel<CatalogueDataset>) sm;
ssm.clear(); ssm.clear();
}else if (sm instanceof MultiSelectionModel) {
MultiSelectionModel<CatalogueDataset> msm = (MultiSelectionModel<CatalogueDataset>) sm;
msm.clear();
} }
getAsycnDataProvider().updateRowCount((int) result.getTotalItems(), true); getAsycnDataProvider().updateRowCount((int) result.getTotalItems(), true);
@ -209,7 +210,7 @@ public class ContentModeratorPaginatedView {
GWT.log("Search finished!!!"); GWT.log("Search finished!!!");
getAsycnDataProvider().updateRowCount(getCellTable().getRowCount(), true); getAsycnDataProvider().updateRowCount(getCellTable().getRowCount(), true);
} }
//initFirstRangeChanged = false; // initFirstRangeChanged = false;
} }
@ -244,6 +245,31 @@ public class ContentModeratorPaginatedView {
} }
/**
* Select items.
*
* @param select the select
* @param limitToPage the limit to page
*/
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);
}
}
/**
* Gets the select items.
*
* @return the select items
*/
public List<CatalogueDataset> getSelectItems() {
return itemsTable.getSelectedItems();
}
/** /**
* A custom {@link AsyncDataProvider}. * A custom {@link AsyncDataProvider}.
* *
@ -281,14 +307,4 @@ public class ContentModeratorPaginatedView {
} }
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);
}
}
} }

View File

@ -2,7 +2,7 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus; import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEvent; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CloseAllTabsEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStausEvent; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.SelectItemsWithItemStatusEvent;
import com.github.gwtbootstrap.client.ui.Dropdown; import com.github.gwtbootstrap.client.ui.Dropdown;
import com.github.gwtbootstrap.client.ui.Label; import com.github.gwtbootstrap.client.ui.Label;
@ -39,10 +39,10 @@ public class ContentModeratorToolbar extends Composite {
public ContentModeratorToolbar(HandlerManager eventBus, ItemStatus status) { public ContentModeratorToolbar(HandlerManager eventBus, ItemStatus status) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
this.eventBus = eventBus; this.eventBus = eventBus;
//statusInfo.setReadOnly(true); setActiveStatus(status);
fillItemStatusOptions(); fillItemStatusOptions();
bindEvents(); bindEvents();
setActiveStatus(status);
} }
private void bindEvents() { private void bindEvents() {
@ -59,24 +59,25 @@ public class ContentModeratorToolbar extends Composite {
private void fillItemStatusOptions() { private void fillItemStatusOptions() {
for (final ItemStatus status : ItemStatus.values()) { for (final ItemStatus status : ItemStatus.values()) {
NavLink link = new NavLink(); NavLink navLink = new NavLink();
link.setText(status.getLabel()); navLink.setText(status.getLabel());
link.addClickHandler(new ClickHandler() { navLink.addClickHandler(new ClickHandler() {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
GWT.log("clicked: "+status);
setActiveStatus(status); setActiveStatus(status);
eventBus.fireEvent(new SelectItemsWithItemStausEvent(activeStatus)); eventBus.fireEvent(new SelectItemsWithItemStatusEvent(status));
} }
}); });
dropdownSelectStatus.add(link); dropdownSelectStatus.add(navLink);
} }
} }
private void setActiveStatus(ItemStatus status) { private void setActiveStatus(ItemStatus status) {
this.activeStatus = status; this.activeStatus = status;
statusInfo.setText(activeStatus.getLabel()); this.statusInfo.setText(activeStatus.getLabel());
} }

View File

@ -14,7 +14,12 @@ import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.Dropdown; import com.github.gwtbootstrap.client.ui.Dropdown;
import com.github.gwtbootstrap.client.ui.Heading; import com.github.gwtbootstrap.client.ui.Heading;
import com.github.gwtbootstrap.client.ui.NavLink; import com.github.gwtbootstrap.client.ui.NavLink;
import com.github.gwtbootstrap.client.ui.base.AlertBase;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.event.ClosedEvent;
import com.github.gwtbootstrap.client.ui.event.ClosedHandler;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeEvent;
@ -24,6 +29,7 @@ import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
// TODO: Auto-generated Javadoc // TODO: Auto-generated Javadoc
@ -32,7 +38,7 @@ import com.google.gwt.user.client.ui.Widget;
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Jun 22, 2021 * Jun 22, 2021
*/ */
public class HomeView extends Composite { public class HomeView extends Composite {
@ -53,26 +59,24 @@ public class HomeView extends Composite {
Heading pageHeader; Heading pageHeader;
@UiField @UiField
AlertBlock actionConfirmAlert; HTMLPanel confirmPanel;
@UiField private ScrollPanel confirmPanelContainer = new ScrollPanel();
Button buttActionConfirmYes;
@UiField private List<NavLink> setStatusOptions = new ArrayList<NavLink>();
Button buttonActionConfirmNo;
private List<NavLink> setStatusOptions = new ArrayList<>();
private ItemStatus displayingItemStatus; private ItemStatus displayingItemStatus;
private HandlerManager eventBus; private HandlerManager eventBus;
private List<CatalogueDataset> selectedItems;
/** /**
* The Interface HomeViewUiBinder. * The Interface HomeViewUiBinder.
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Jun 22, 2021 * Jun 22, 2021
*/ */
interface HomeViewUiBinder extends UiBinder<Widget, HomeView> { interface HomeViewUiBinder extends UiBinder<Widget, HomeView> {
} }
@ -80,10 +84,10 @@ public class HomeView extends Composite {
/** /**
* Instantiates a new home view. * Instantiates a new home view.
* *
* @param eventBus the event bus * @param eventBus the event bus
* @param status the status * @param status the status
* @param displayFields the display fields * @param displayFields the display fields
* @param sortByField the sort by field * @param sortByField the sort by field
*/ */
public HomeView(HandlerManager eventBus, ItemStatus status, DISPLAY_FIELD[] displayFields, public HomeView(HandlerManager eventBus, ItemStatus status, DISPLAY_FIELD[] displayFields,
DISPLAY_FIELD sortByField) { DISPLAY_FIELD sortByField) {
@ -95,9 +99,9 @@ public class HomeView extends Composite {
cmsPanel.addToBottom(paginatedView.getPagerPanel()); cmsPanel.addToBottom(paginatedView.getPagerPanel());
panelContainer.add(cmsPanel.getPanel()); panelContainer.add(cmsPanel.getPanel());
setVisibleUpdateStatusAction(false); setVisibleUpdateStatusAction(false);
fillSetStatusOptions(); fillSetStatusOptions();
bindEvents(); bindEvents();
confirmPanel.add(confirmPanelContainer);
} }
/** /**
@ -134,24 +138,31 @@ public class HomeView extends Composite {
} }
}); });
for (final NavLink navLink : setStatusOptions) {
navLink.addClickHandler(new ClickHandler() {
buttActionConfirmYes.addClickHandler(new ClickHandler() { @Override
public void onClick(ClickEvent event) {
selectedItems = paginatedView.getSelectItems();
int count = selectedItems.size();
String msg = "Going to update status of";
if (count > 0) {
if (count == 1) {
msg += " one item";
} else {
msg += " " + count + " items";
}
@Override msg += " from <b>" + displayingItemStatus.getLabel() + "</b> to <b>" + navLink.getText()
public void onClick(ClickEvent event) { + "</b>. Confirm?";
// TODO Auto-generated method stub }else
return;
} showConfirm(msg);
});
buttonActionConfirmNo.addClickHandler(new ClickHandler() { }
});
@Override }
public void onClick(ClickEvent event) {
actionConfirmAlert.setVisible(false);
}
});
} }
/** /**
@ -175,7 +186,7 @@ public class HomeView extends Composite {
/** /**
* Mark items as checked. * Mark items as checked.
* *
* @param select the select * @param select the select
* @param limitToPage the limit to page * @param limitToPage the limit to page
*/ */
public void markItemsAsChecked(boolean select, boolean limitToPage) { public void markItemsAsChecked(boolean select, boolean limitToPage) {
@ -191,14 +202,51 @@ public class HomeView extends Composite {
cbSelectAll.setValue(bool); cbSelectAll.setValue(bool);
} }
/** /**
* Show confirm. * Show confirm.
* *
* @param msg the msg * @param msg the msg
*/ */
public void showConfirm(String msg) { public void showConfirm(String msg) {
actionConfirmAlert.setVisible(true); confirmPanelContainer.clear();
final AlertBlock newAlertBlock = new AlertBlock(AlertType.DEFAULT);
newAlertBlock.setAnimation(true);
newAlertBlock.setClose(true);
newAlertBlock.addClosedHandler(new ClosedHandler<AlertBase>() {
@Override
public void onClosed(ClosedEvent<AlertBase> event) {
confirmPanelContainer.clear();
}
});
Button buttActionConfirmYes = new Button(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
confirmPanelContainer.clear();
}
});
buttActionConfirmYes.getElement().getStyle().setMarginLeft(10, Unit.PX);
buttActionConfirmYes.setText("YES");
newAlertBlock.add(buttActionConfirmYes);
Button buttonActionConfirmNo = new Button(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
confirmPanelContainer.clear();
}
});
buttonActionConfirmNo.getElement().getStyle().setMarginLeft(10, Unit.PX);
buttonActionConfirmNo.setText("NO");
newAlertBlock.add(buttonActionConfirmNo);
newAlertBlock.setHTML(msg);
confirmPanelContainer.add(newAlertBlock);
} }
/** /**
@ -207,10 +255,19 @@ public class HomeView extends Composite {
* @param itemStatus the item status * @param itemStatus the item status
*/ */
public void loadItemsWithStatus(ItemStatus itemStatus) { public void loadItemsWithStatus(ItemStatus itemStatus) {
GWT.log("loadItemsWithStatus started");
setDisplayingWithStatus(itemStatus); setDisplayingWithStatus(itemStatus);
setCheckedCheckboxSelectAll(false);
setVisibleUpdateStatusAction(false);
try {
confirmPanelContainer.clear();
}catch (Exception e) {
GWT.log("error: "+e.getMessage() + " cause: "+e.getCause().toString());
}
paginatedView.loadItemsForStatus(itemStatus); paginatedView.loadItemsForStatus(itemStatus);
GWT.log("loadItemsWithStatus end");
} }
} }

View File

@ -35,13 +35,7 @@
ui:field="dropdownSetStatus" addStyleNames="{style.margin-left-20}"> ui:field="dropdownSetStatus" addStyleNames="{style.margin-left-20}">
</b:Dropdown> </b:Dropdown>
</g:HorizontalPanel> </g:HorizontalPanel>
<g:HTMLPanel ui:field="confirmPanel"></g:HTMLPanel>
<b:AlertBlock type="DEFAULT" close="true"
animation="true" ui:field="actionConfirmAlert" visible="false">
<b:Button ui:field="buttActionConfirmYes">Yes</b:Button>
<b:Button ui:field="buttonActionConfirmNo">No</b:Button>
</b:AlertBlock>
<g:HTMLPanel ui:field="panelContainer"></g:HTMLPanel> <g:HTMLPanel ui:field="panelContainer"></g:HTMLPanel>
</g:HTMLPanel> </g:HTMLPanel>
</ui:UiBinder> </ui:UiBinder>

View File

@ -13,8 +13,11 @@ import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.LoadEvent;
import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
@ -73,16 +76,28 @@ public class MainTabPanel extends Composite {
* @return the tab * @return the tab
*/ */
public Tab addTab(String heading, Widget w) { public Tab addTab(String heading, Widget w) {
Tab tab = new Tab(); final Tab tab = new Tab();
tab.setIcon(IconType.BOOK);
if (w instanceof CkanFramePanel) {
tab.setCustomIconStyle("icon-rotate-right icon-spin");
CkanFramePanel ckanFramePanel = (CkanFramePanel) w;
ckanFramePanel.getFrame().addLoadHandler(new LoadHandler() {
@Override
public void onLoad(LoadEvent event) {
tab.setIcon(IconType.BOOK);
setNoSpinner(tab);
}
});
}
tab.addClickHandler(new ClickHandler() { tab.addClickHandler(new ClickHandler() {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
} }
}); });
String shortTitle = UtilFunct.ellipsis(heading, 20, false); String shortTitle = UtilFunct.ellipsis(heading, 20, false);
tab.asWidget().setTitle(heading); tab.asWidget().setTitle(heading);
tab.setHeading(shortTitle); tab.setHeading(shortTitle);
@ -91,13 +106,13 @@ public class MainTabPanel extends Composite {
results.add(tab); results.add(tab);
mainTabPanel.add(tab); mainTabPanel.add(tab);
//activeTabPanels(false); // activeTabPanels(false);
Scheduler.get().scheduleDeferred(new ScheduledCommand() { Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override @Override
public void execute() { public void execute() {
//mainTabPanel.selectTab(results.size() - 1); // mainTabPanel.selectTab(results.size() - 1);
} }
}); });
@ -133,11 +148,12 @@ public class MainTabPanel extends Composite {
int tabSize = results.size(); int tabSize = results.size();
GWT.log("tab size is: " + tabSize); GWT.log("tab size is: " + tabSize);
for (int i = 1; i < tabSize; i++) { for (int i = 1; i < tabSize; i++) {
//each remove shifts any subsequent elements to the left, so I'm removing always the first element // each remove shifts any subsequent elements to the left, so I'm removing
// always the first element
mainTabPanel.remove(1); mainTabPanel.remove(1);
results.remove(1); results.remove(1);
} }
//selecting Home Tab // selecting Home Tab
selectTab(0); selectTab(0);
} }
@ -148,4 +164,25 @@ public class MainTabPanel extends Composite {
} }
/**
* Sets the no spinner.
*
* @param tab the new no spinner
*/
private void setNoSpinner(Tab tab) {
try{
tab.asTabLink().getAnchor().removeStyleName("icon-spin");
tab.asTabLink().getAnchor().removeStyleName("icon-rotate-right");
Element anchorElem = tab.asTabLink().getAnchor().asWidget().getElement();
anchorElem.getFirstChildElement().removeClassName("icon-spin");
anchorElem.getFirstChildElement().removeClassName("icon-rotate-right");
}catch(Exception e){
//silent
}
tab.asTabLink().getAnchor().setIcon(IconType.BOOK);
//tab.asTabLink().getAnchor().setVisible(false);
//if(tab.asTabLink().getAnchor().setVisible(false);)
}
} }