task_21363 #1

Closed
francesco.mangiacrapa wants to merge 53 commits from task_21363 into master
10 changed files with 246 additions and 101 deletions
Showing only changes of commit 8f9fc4ef04 - Show all commits

View File

@ -5,7 +5,6 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTabl
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Composite;
/**
* The Class CkanContentModeratorWidget.

View File

@ -5,8 +5,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.ui.CkanFramePanel;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorPaginatedView;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorSystemBaseView;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorToolbar;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.HomeView;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.MainTabPanel;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.table.ItemsTable.DISPLAY_FIELD;
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
@ -16,9 +16,7 @@ import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
/**
* The Class CkanContentModeratorWidget.
@ -34,13 +32,12 @@ public class CkanContentModeratorWidgetController {
private FlowPanel mainPanel = new FlowPanel();
// private ItemsTable<CatalogueDataset> itemsTable;
private ContentModeratorSystemBaseView cmsPanel = new ContentModeratorSystemBaseView();
private ContentModeratorToolbar toolbar;
private MainTabPanel mainTabPanel = new MainTabPanel();
private Boolean isContentModeratorEnabled = null;
private ContentModeratorPaginatedView paginatedView;
public final static HandlerManager eventBus = new HandlerManager(null);
private HomeView howeView;
/**
* Instantiates a new ckan content moderator widget.
@ -51,17 +48,9 @@ public class CkanContentModeratorWidgetController {
*/
public CkanContentModeratorWidgetController(ItemStatus status, DISPLAY_FIELD[] displayFields,
DISPLAY_FIELD sortByField) {
// itemsTable = new ItemsTable<CatalogueDataset>(null, displayFields, sortByField);
// itemsTable.initTable(null, null, new ListDataProvider<CatalogueDataset>());
// cmsPanel.add(itemsTable.getCellTable());
toolbar = new ContentModeratorToolbar(eventBus);
paginatedView = new ContentModeratorPaginatedView(eventBus, status, displayFields, sortByField);
// cmsPanel.addToTop(new LoadingPanel(new HTML("Loading...")));
//cmsPanel.addToTop(toolbar);
cmsPanel.addToCenter(paginatedView.getCellPanel());
cmsPanel.addToBottom(paginatedView.getPagerPanel());
mainTabPanel.addHomeWidget(cmsPanel.getPanel());
howeView = new HomeView(eventBus, status, displayFields, sortByField);
mainTabPanel.addHomeWidget(howeView.getPanel());
mainPanel.add(toolbar);
mainPanel.add(mainTabPanel);
bindEvents();

View File

@ -4,7 +4,7 @@ import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
// TODO: Auto-generated Javadoc
/**
* The Class ContentModeratorSystemBaseView.
*

View File

@ -0,0 +1,69 @@
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.ui.table.ItemsTable.DISPLAY_FIELD;
import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.Dropdown;
import com.github.gwtbootstrap.client.ui.NavLink;
import com.google.gwt.core.client.GWT;
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;
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;
private List<NavLink> setStatusOptions = new ArrayList<>();
private ItemStatus displayingItemStatus;
interface HomeViewUiBinder extends UiBinder<Widget, HomeView> {
}
public HomeView(HandlerManager eventBus, ItemStatus status, DISPLAY_FIELD[] displayFields,
DISPLAY_FIELD sortByField) {
initWidget(uiBinder.createAndBindUi(this));
this.displayingItemStatus = status;
paginatedView = new ContentModeratorPaginatedView(eventBus, status, displayFields, sortByField);
cmsPanel.addToCenter(paginatedView.getCellPanel());
cmsPanel.addToBottom(paginatedView.getPagerPanel());
panelContainer.add(cmsPanel.getPanel());
fillSetStatusOptions();
}
private void fillSetStatusOptions() {
for (ItemStatus status : ItemStatus.values()) {
if (!status.equals(displayingItemStatus)) {
NavLink nl = new NavLink(status.getLabel());
dropdownSetStatus.add(nl);
setStatusOptions.add(nl);
}
}
}
public Composite getPanel() {
return this;
}
}

View File

@ -0,0 +1,29 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
.margin-left-20 {
margin-left: 20px;
}
.margin-left-5 {
margin-left: 5px;
}
</ui:style>
<g:HTMLPanel>
<g:HorizontalPanel
addStyleNames="{style.margin-left-5}">
<b:CheckBox ui:field="cbSelectAll"></b:CheckBox>
<b:Dropdown text="Set 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>
</ui:UiBinder>

View File

@ -8,7 +8,6 @@ import com.github.gwtbootstrap.client.ui.TabPanel;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;

View File

@ -14,7 +14,6 @@ import com.google.gwt.event.dom.client.ContextMenuHandler;
import com.google.gwt.event.dom.client.DoubleClickEvent;
import com.google.gwt.event.dom.client.DoubleClickHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.DialogBox;
@ -146,25 +145,25 @@ public abstract class AbstractItemsCellTable<T> {
}
/**
* Update items.
*
* @param items the items
* @param removeOldItems the remove old items
*/
public void updateItems(List<T> items, boolean removeOldItems) {
if (removeOldItems) {
if (theSelectionModel instanceof SingleSelectionModel) {
((SingleSelectionModel<T>) theSelectionModel).clear();
} else if (theSelectionModel instanceof MultiSelectionModel) {
((MultiSelectionModel<T>) theSelectionModel).clear();
}
}
sortedCellTable.setList(items);
sortedCellTable.setPageSize(items.size() + 1);
sortedCellTable.redraw();
}
// /**
// * Update items.
// *
// * @param items the items
// * @param removeOldItems the remove old items
// */
// public void updateItems(List<T> items, boolean removeOldItems) {
//
// if (removeOldItems) {
// if (theSelectionModel instanceof SingleSelectionModel) {
// ((SingleSelectionModel<T>) theSelectionModel).clear();
// } else if (theSelectionModel instanceof MultiSelectionModel) {
// ((MultiSelectionModel<T>) theSelectionModel).clear();
// }
// }
// sortedCellTable.setList(items);
// sortedCellTable.setPageSize(items.size() + 1);
// sortedCellTable.redraw();
// }
/**
* Gets the cell tables.

View File

@ -19,6 +19,7 @@ import com.github.gwtbootstrap.client.ui.Pagination;
import com.google.gwt.cell.client.ButtonCell;
import com.google.gwt.cell.client.CheckboxCell;
import com.google.gwt.cell.client.DateCell;
import com.google.gwt.cell.client.FieldUpdater;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.shared.HandlerManager;
@ -85,22 +86,22 @@ 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);
}
// /**
// * 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.
@ -142,6 +143,23 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
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";
}
};
showdItemColumn.setFieldUpdater(new FieldUpdater<T, String>() {
@Override
public void update(int index, T object, String value) {
GWT.log("clicked");
}
});
sortedCellTable.addColumn(showdItemColumn);
sortedCellTable.setColumnWidth(showdItemColumn, 80, Unit.PX);
if (this.displayFields.contains(DISPLAY_FIELD.NAME)) {
// NAME
@ -313,7 +331,8 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
if (o2 == null || o2.getExtra_SystemType() == null)
return 1;
return ((CatalogueDataset) o1).getExtra_SystemType().compareTo(((CatalogueDataset) o2).getExtra_SystemType());
return ((CatalogueDataset) o1).getExtra_SystemType()
.compareTo(((CatalogueDataset) o2).getExtra_SystemType());
}
};

View File

@ -12,7 +12,7 @@ import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.cellview.client.Column;
// TODO: Auto-generated Javadoc
/**
* The Class MyToolTipColumn.
*

View File

@ -15,13 +15,14 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.CellTabl
import com.github.gwtbootstrap.client.ui.CellTable;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.cellview.client.ColumnSortEvent;
import com.google.gwt.user.cellview.client.ColumnSortEvent.AsyncHandler;
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
import com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo;
import com.google.gwt.user.cellview.client.Header;
import com.google.gwt.view.client.AbstractDataProvider;
import com.google.gwt.view.client.AsyncDataProvider;
import com.google.gwt.view.client.ListDataProvider;
/**
* The Class SortedCellTable.
*
@ -58,8 +59,7 @@ public class SortedCellTable<T> extends CellTable<T> {
* Special column sorting handler that will allow us to do more controlled
* sorting
*/
private ListHandler<T> columnSortHandler;
private ColumnSortEvent.Handler columnSortHandler;
/**
* Instantiates a new sorted cell table.
@ -68,11 +68,12 @@ public class SortedCellTable<T> extends CellTable<T> {
* @param dataProv the data prov
*/
public SortedCellTable(int pageSize, AbstractDataProvider<T> dataProv) {
super(pageSize,CellTableResources.INSTANCE);
super(pageSize, CellTableResources.INSTANCE);
this.dataProvider = dataProv;
if(this.dataProvider instanceof ListDataProvider){
columnSortHandler = new ListHandler<T>(((ListDataProvider<T>) this.dataProvider).getList()) {
if (this.dataProvider instanceof ListDataProvider) {
ListDataProvider<T> listDataProvider = (ListDataProvider<T>) this.dataProvider;
ListHandler<T> listSortHandler = new ListHandler<T>((listDataProvider).getList()) {
@Override
public void onColumnSort(ColumnSortEvent event) {
@ -85,8 +86,7 @@ public class SortedCellTable<T> extends CellTable<T> {
if (column.equals(currentlySortedColumn)) {
// Default behavior
super.onColumnSort(event);
}
else {
} else {
// Initial sort; look up which direction we need
final Comparator<T> comparator = comparators.get(column);
if (comparator == null) {
@ -96,8 +96,7 @@ public class SortedCellTable<T> extends CellTable<T> {
if (ascending == null || ascending) {
// Default behavior
super.onColumnSort(event);
}
else {
} else {
// Sort the column descending
Collections.sort(getList(), new Comparator<T>() {
@ -120,10 +119,53 @@ public class SortedCellTable<T> extends CellTable<T> {
super.setComparator(column, comparator);
}
};
addColumnSortHandler(listSortHandler);
columnSortHandler = listSortHandler;
} else if (this.dataProvider instanceof AsyncDataProvider) {
//AsyncDataProvider asyncDataProvider = ((AsyncDataProvider) this.dataProvider);
//asyncDataProvider.get
AsyncHandler asyncSortHandler = new AsyncHandler(this) {
@Override
public void onColumnSort(ColumnSortEvent event) {
addColumnSortHandler(columnSortHandler);
@SuppressWarnings("unchecked")
Column<T, ?> column = (Column<T, ?>) event.getColumn();
if (column == null) {
return;
}
if (column.equals(currentlySortedColumn)) {
// Default behavior
super.onColumnSort(event);
} else {
// Initial sort; look up which direction we need
final Comparator<T> comparator = comparators.get(column);
if (comparator == null) {
return;
}
Boolean ascending = defaultSortOrderMap.get(column);
if (ascending == null || ascending) {
// Default behavior
super.onColumnSort(event);
} else {
// Sort the column descending
Collections.sort(getVisibleItems(), new Comparator<T>() {
public int compare(T o1, T o2) {
return -comparator.compare(o1, o2);
}
});
// Set the proper arrow in the header
getColumnSortList().push(new ColumnSortInfo(column, false));
}
currentlySortedColumn = column;
}
}
};
// addColumnSortHandler(asyncSortHandler);
// columnSortHandler = asyncSortHandler;
}
}
@ -149,8 +191,12 @@ public class SortedCellTable<T> extends CellTable<T> {
* @param column the column
* @param headerName the header name
*/
/* (non-Javadoc)
* @see com.google.gwt.user.cellview.client.AbstractCellTable#addColumn(com.google.gwt.user.cellview.client.Column, java.lang.String)
/*
* (non-Javadoc)
*
* @see
* com.google.gwt.user.cellview.client.AbstractCellTable#addColumn(com.google.
* gwt.user.cellview.client.Column, java.lang.String)
*/
public void addColumn(Column<T, ?> column, String headerName) {
@ -185,14 +231,13 @@ public class SortedCellTable<T> extends CellTable<T> {
}
/**
* Sets a comparator to use when sorting the given column.
* Set the comparator used to sort the specified column in ascending order.
*
* @param column the column
* @param comparator the comparator
* @param column the {@link Column}
* @param comparator the {@link Comparator} to use for the {@link Column}
*/
public void setComparator(Column<T, ?> column, Comparator<T> comparator) {
columnSortHandler.setComparator(column, comparator);
comparators.put(column, comparator);
}
/**
@ -208,20 +253,20 @@ public class SortedCellTable<T> extends CellTable<T> {
}
/**
* Sets the table's data provider list and sorts the table based on the
* column given in {@link SortedCellTable#setInitialSortColumn(Column)}.
* Sets the table's data provider list and sorts the table based on the column
* given in {@link SortedCellTable#setInitialSortColumn(Column)}.
*
* @param list the new list
*/
public void setList(List<T> list) {
if(dataProvider instanceof ListDataProvider){
if (dataProvider instanceof ListDataProvider) {
List<T> myData = ((ListDataProvider) dataProvider).getList();
myData.clear();
if (list != null) {
/*for (T t : list) {
dataProvider.getList().add(t);
}*/
/*
* for (T t : list) { dataProvider.getList().add(t); }
*/
myData.addAll(list);
}
// Do a first-time sort based on which column was set in
@ -232,22 +277,19 @@ public class SortedCellTable<T> extends CellTable<T> {
@Override
public int compare(T o1, T o2) {
return (defaultSortOrderMap.get(initialSortColumn) ? 1 : -1) * comparators.get(initialSortColumn).compare(o1, o2);
return (defaultSortOrderMap.get(initialSortColumn) ? 1 : -1)
* comparators.get(initialSortColumn).compare(o1, o2);
}
});
// Might as well get the little arrow on the header to make it
// official
getColumnSortList().push(
new ColumnSortInfo(
initialSortColumn,
defaultSortOrderMap.get(initialSortColumn)));
getColumnSortList().push(new ColumnSortInfo(initialSortColumn, defaultSortOrderMap.get(initialSortColumn)));
currentlySortedColumn = initialSortColumn;
}
}
}
/**
* Gets the data provider.
*