2021-06-21 18:08:20 +02:00
|
|
|
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
2021-06-22 17:38:42 +02:00
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.CheckBoxSelectIemsEvent;
|
2021-06-21 18:08:20 +02:00
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
2021-06-22 17:38:42 +02:00
|
|
|
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
2021-06-21 18:08:20 +02:00
|
|
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.CheckBox;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Dropdown;
|
2021-06-22 17:38:42 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.Heading;
|
2021-06-21 18:08:20 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.NavLink;
|
|
|
|
import com.google.gwt.core.client.GWT;
|
2021-06-24 15:02:49 +02:00
|
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
2021-06-22 17:38:42 +02:00
|
|
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
|
|
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
2021-06-21 18:08:20 +02:00
|
|
|
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.HTMLPanel;
|
2021-06-28 15:40:53 +02:00
|
|
|
import com.google.gwt.user.client.ui.ScrollPanel;
|
2021-06-21 18:08:20 +02:00
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
2021-06-22 17:38:42 +02:00
|
|
|
// TODO: Auto-generated Javadoc
|
|
|
|
/**
|
|
|
|
* The Class HomeView.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
|
|
|
*
|
2021-06-28 15:40:53 +02:00
|
|
|
* Jun 22, 2021
|
2021-06-22 17:38:42 +02:00
|
|
|
*/
|
2021-06-21 18:08:20 +02:00
|
|
|
public class HomeView extends Composite {
|
|
|
|
|
|
|
|
private static HomeViewUiBinder uiBinder = GWT.create(HomeViewUiBinder.class);
|
|
|
|
private ContentModeratorSystemBaseView cmsPanel = new ContentModeratorSystemBaseView();
|
|
|
|
private ContentModeratorPaginatedView paginatedView;
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
HTMLPanel panelContainer;
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
CheckBox cbSelectAll;
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
Dropdown dropdownSetStatus;
|
|
|
|
|
2021-06-22 17:38:42 +02:00
|
|
|
@UiField
|
|
|
|
Heading pageHeader;
|
2021-06-28 15:40:53 +02:00
|
|
|
|
2021-06-24 15:02:49 +02:00
|
|
|
@UiField
|
2021-06-28 15:40:53 +02:00
|
|
|
HTMLPanel confirmPanel;
|
2021-06-28 18:41:52 +02:00
|
|
|
|
|
|
|
private ScrollPanel confirmPanelContainer = new ScrollPanel();
|
2021-06-22 17:38:42 +02:00
|
|
|
|
2021-06-28 15:40:53 +02:00
|
|
|
private List<NavLink> setStatusOptions = new ArrayList<NavLink>();
|
2021-06-21 18:08:20 +02:00
|
|
|
|
|
|
|
private ItemStatus displayingItemStatus;
|
|
|
|
|
2021-06-22 17:38:42 +02:00
|
|
|
private HandlerManager eventBus;
|
|
|
|
|
2021-06-28 15:40:53 +02:00
|
|
|
private List<CatalogueDataset> selectedItems;
|
|
|
|
|
2021-06-22 17:38:42 +02:00
|
|
|
/**
|
|
|
|
* The Interface HomeViewUiBinder.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
|
|
|
*
|
2021-06-28 15:40:53 +02:00
|
|
|
* Jun 22, 2021
|
2021-06-22 17:38:42 +02:00
|
|
|
*/
|
2021-06-21 18:08:20 +02:00
|
|
|
interface HomeViewUiBinder extends UiBinder<Widget, HomeView> {
|
|
|
|
}
|
|
|
|
|
2021-06-22 17:38:42 +02:00
|
|
|
/**
|
|
|
|
* Instantiates a new home view.
|
|
|
|
*
|
2021-06-28 15:40:53 +02:00
|
|
|
* @param eventBus the event bus
|
|
|
|
* @param status the status
|
2021-06-22 17:38:42 +02:00
|
|
|
* @param displayFields the display fields
|
2021-06-28 15:40:53 +02:00
|
|
|
* @param sortByField the sort by field
|
2021-06-22 17:38:42 +02:00
|
|
|
*/
|
2021-06-21 18:08:20 +02:00
|
|
|
public HomeView(HandlerManager eventBus, ItemStatus status, DISPLAY_FIELD[] displayFields,
|
|
|
|
DISPLAY_FIELD sortByField) {
|
|
|
|
initWidget(uiBinder.createAndBindUi(this));
|
2021-06-25 16:56:43 +02:00
|
|
|
setDisplayingWithStatus(status);
|
2021-06-22 17:38:42 +02:00
|
|
|
this.eventBus = eventBus;
|
2021-06-21 18:08:20 +02:00
|
|
|
paginatedView = new ContentModeratorPaginatedView(eventBus, status, displayFields, sortByField);
|
|
|
|
cmsPanel.addToCenter(paginatedView.getCellPanel());
|
|
|
|
cmsPanel.addToBottom(paginatedView.getPagerPanel());
|
|
|
|
panelContainer.add(cmsPanel.getPanel());
|
2021-06-22 17:38:42 +02:00
|
|
|
setVisibleUpdateStatusAction(false);
|
2021-06-21 18:08:20 +02:00
|
|
|
fillSetStatusOptions();
|
2021-06-22 17:38:42 +02:00
|
|
|
bindEvents();
|
2021-06-28 15:40:53 +02:00
|
|
|
confirmPanel.add(confirmPanelContainer);
|
2021-06-21 18:08:20 +02:00
|
|
|
}
|
|
|
|
|
2021-06-22 17:38:42 +02:00
|
|
|
/**
|
|
|
|
* Fill set status options.
|
|
|
|
*/
|
2021-06-21 18:08:20 +02:00
|
|
|
private void fillSetStatusOptions() {
|
|
|
|
for (ItemStatus status : ItemStatus.values()) {
|
|
|
|
if (!status.equals(displayingItemStatus)) {
|
|
|
|
NavLink nl = new NavLink(status.getLabel());
|
|
|
|
dropdownSetStatus.add(nl);
|
|
|
|
setStatusOptions.add(nl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-06-28 15:40:53 +02:00
|
|
|
|
2021-06-25 16:56:43 +02:00
|
|
|
private void setDisplayingWithStatus(ItemStatus status) {
|
|
|
|
this.displayingItemStatus = status;
|
|
|
|
this.pageHeader.setSubtext(status.getLabel());
|
|
|
|
}
|
2021-06-21 18:08:20 +02:00
|
|
|
|
2021-06-22 17:38:42 +02:00
|
|
|
/**
|
|
|
|
* 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()));
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2021-06-28 15:40:53 +02:00
|
|
|
|
|
|
|
for (final NavLink navLink : setStatusOptions) {
|
|
|
|
navLink.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
2021-06-28 18:41:52 +02:00
|
|
|
// 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";
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// msg += " from <b>" + displayingItemStatus.getLabel() + "</b> to <b>" + navLink.getText()
|
|
|
|
// + "</b>. Confirm?";
|
|
|
|
// } else
|
|
|
|
// return;
|
|
|
|
if(paginatedView.getSelectItems().size()>0) {
|
|
|
|
showConfirm(navLink);
|
|
|
|
}
|
2021-06-28 15:40:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2021-06-22 17:38:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the panel.
|
|
|
|
*
|
|
|
|
* @return the panel
|
|
|
|
*/
|
2021-06-21 18:08:20 +02:00
|
|
|
public Composite getPanel() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-06-22 17:38:42 +02:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
2021-06-28 15:40:53 +02:00
|
|
|
* @param select the select
|
2021-06-22 17:38:42 +02:00
|
|
|
* @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);
|
|
|
|
}
|
2021-06-28 15:40:53 +02:00
|
|
|
|
2021-06-25 16:56:43 +02:00
|
|
|
/**
|
|
|
|
* Show confirm.
|
|
|
|
*
|
|
|
|
* @param msg the msg
|
|
|
|
*/
|
2021-06-28 18:41:52 +02:00
|
|
|
public void showConfirm(NavLink navLink) {
|
2021-06-28 15:40:53 +02:00
|
|
|
confirmPanelContainer.clear();
|
2021-06-28 18:41:52 +02:00
|
|
|
GWT.log("showConfirm clicked link: "+navLink.getText());
|
|
|
|
ItemStatus fromStatus = displayingItemStatus;
|
|
|
|
ItemStatus toStatus = null;
|
2021-06-28 15:40:53 +02:00
|
|
|
|
2021-06-28 18:41:52 +02:00
|
|
|
for (ItemStatus theStatus : ItemStatus.values()) {
|
|
|
|
if(theStatus.getLabel().compareTo(navLink.getText().trim())==0) {
|
|
|
|
toStatus = theStatus;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GWT.log("Do action on from: "+fromStatus + " to: "+toStatus);
|
|
|
|
if(toStatus==null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DoActionCMS doActionCMS = new DoActionCMS(fromStatus, toStatus, paginatedView.getSelectItems());
|
|
|
|
|
|
|
|
/*final AlertBlock newAlertBlock = new AlertBlock(AlertType.DEFAULT);
|
2021-06-28 15:40:53 +02:00
|
|
|
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);
|
|
|
|
|
2021-06-28 18:41:52 +02:00
|
|
|
newAlertBlock.setHTML(msg);*/
|
|
|
|
|
|
|
|
confirmPanelContainer.add(doActionCMS);
|
2021-06-24 15:02:49 +02:00
|
|
|
}
|
2021-06-25 16:56:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load form server the items with status.
|
|
|
|
*
|
|
|
|
* @param itemStatus the item status
|
|
|
|
*/
|
|
|
|
public void loadItemsWithStatus(ItemStatus itemStatus) {
|
2021-06-28 15:40:53 +02:00
|
|
|
GWT.log("loadItemsWithStatus started");
|
2021-06-25 16:56:43 +02:00
|
|
|
setDisplayingWithStatus(itemStatus);
|
2021-06-28 15:40:53 +02:00
|
|
|
setCheckedCheckboxSelectAll(false);
|
|
|
|
setVisibleUpdateStatusAction(false);
|
|
|
|
try {
|
|
|
|
confirmPanelContainer.clear();
|
2021-06-28 18:41:52 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
GWT.log("error: " + e.getMessage() + " cause: " + e.getCause().toString());
|
2021-06-28 15:40:53 +02:00
|
|
|
}
|
2021-06-25 16:56:43 +02:00
|
|
|
paginatedView.loadItemsForStatus(itemStatus);
|
2021-06-24 15:02:49 +02:00
|
|
|
|
2021-06-28 15:40:53 +02:00
|
|
|
GWT.log("loadItemsWithStatus end");
|
|
|
|
}
|
|
|
|
|
2021-06-21 18:08:20 +02:00
|
|
|
}
|