159 lines
4.2 KiB
Java
159 lines
4.2 KiB
Java
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
|
|
|
|
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;
|
|
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);
|
|
private ContentModeratorSystemBaseView cmsPanel = new ContentModeratorSystemBaseView();
|
|
private ContentModeratorPaginatedView paginatedView;
|
|
|
|
@UiField
|
|
HTMLPanel panelContainer;
|
|
|
|
@UiField
|
|
CheckBox cbSelectAll;
|
|
|
|
@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)) {
|
|
NavLink nl = new NavLink(status.getLabel());
|
|
dropdownSetStatus.add(nl);
|
|
setStatusOptions.add(nl);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
}
|
|
|
|
}
|