fixed "Get list of Concessioni" table

This commit is contained in:
Francesco Mangiacrapa 2021-08-05 11:21:39 +02:00
parent b5ccba5551
commit bd49bd6f4e
11 changed files with 252 additions and 134 deletions

View File

@ -5,17 +5,19 @@ import org.gcube.portlets.widgets.mpformbuilder.client.ConstantsMPFormBuilder;
public class ConstantsGeoPortalDataEntryApp { public class ConstantsGeoPortalDataEntryApp {
public static final String DATE_FORMAT = ConstantsMPFormBuilder.DATE_FORMAT; public static final String DATE_FORMAT = ConstantsMPFormBuilder.DATE_FORMAT;
public static final String TIME_FORMAT = ConstantsMPFormBuilder.TIME_FORMAT; public static final String TIME_FORMAT = ConstantsMPFormBuilder.TIME_FORMAT;
public static final String HOURS_MINUTES_SEPARATOR = ConstantsMPFormBuilder.HOURS_MINUTES_SEPARATOR; public static final String HOURS_MINUTES_SEPARATOR = ConstantsMPFormBuilder.HOURS_MINUTES_SEPARATOR;
public static final String ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT = "Error on inizialization stage, please contact the support!"; public static final String ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT = "Error on inizialization stage, please contact the support!";
public enum RECORD_TYPE { public enum RECORD_TYPE {
CONCESSIONE CONCESSIONE
} }
public enum ACTION_ON_ITEM {
SHOW_ON_MAP, SHOW_METADATA, REMOVE
}
} }

View File

@ -132,6 +132,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
private void buildNewCards(Collection<GeoNaFormCardModel> orderedCards) { private void buildNewCards(Collection<GeoNaFormCardModel> orderedCards) {
projectSavedWithSuccess = false; //resetting state of saving projectSavedWithSuccess = false; //resetting state of saving
mainPanel.setFormPanelVisible(true);
mainPanel.setLoaderVisible("Loading...", true); mainPanel.setLoaderVisible("Loading...", true);
resetUI(); resetUI();
//ordered values //ordered values
@ -361,13 +362,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override @Override
public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) { public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) {
Modal modal = new Modal(true);
modal.setCloseVisible(true);
GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus,RECORD_TYPE.CONCESSIONE,null, DISPLAY_FIELD.NAME); GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus,RECORD_TYPE.CONCESSIONE,null, DISPLAY_FIELD.NAME);
modal.add(grpw.getCellPanel()); mainPanel.showListOfConcessioniView(grpw);
modal.add(grpw.getPagerPanel());
modal.show();
} }
}); });
} }

View File

@ -2,27 +2,31 @@ package org.gcube.portlets.user.geoportaldataentry.client.events;
import java.util.List; import java.util.List;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.GwtEvent;
/** /**
* The Class ShowItemEvent. * The Class ActionOnItemEvent.
* *
* @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 * Aug 5, 2021
* @param <T> the generic type * @param <T> the generic type
*/ */
public class ShowItemEvent<T> extends GwtEvent<ShowItemEventHandler> { public class ActionOnItemEvent<T> extends GwtEvent<ActionOnItemEventHandler> {
public static Type<ShowItemEventHandler> TYPE = new Type<ShowItemEventHandler>(); public static Type<ActionOnItemEventHandler> TYPE = new Type<ActionOnItemEventHandler>();
private List<T> selectItems; private List<T> selectItems;
private ACTION_ON_ITEM action;
/** /**
* Instantiates a new click item event. * Instantiates a new click item event.
* *
* @param selectItems the select items * @param selectItems the select items
*/ */
public ShowItemEvent(List<T> selectItems) { public ActionOnItemEvent(List<T> selectItems, ACTION_ON_ITEM doAction) {
this.selectItems = selectItems; this.selectItems = selectItems;
this.action = doAction;
} }
/** /**
@ -36,7 +40,7 @@ public class ShowItemEvent<T> extends GwtEvent<ShowItemEventHandler> {
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/ */
@Override @Override
public Type<ShowItemEventHandler> getAssociatedType() { public Type<ActionOnItemEventHandler> getAssociatedType() {
return TYPE; return TYPE;
} }
@ -53,8 +57,8 @@ public class ShowItemEvent<T> extends GwtEvent<ShowItemEventHandler> {
* EventHandler) * EventHandler)
*/ */
@Override @Override
protected void dispatch(ShowItemEventHandler handler) { protected void dispatch(ActionOnItemEventHandler handler) {
handler.onShowItemClicked(this); handler.onDoActionFired(this);
} }
/** /**
@ -65,4 +69,8 @@ public class ShowItemEvent<T> extends GwtEvent<ShowItemEventHandler> {
public List<T> getSelectItems() { public List<T> getSelectItems() {
return selectItems; return selectItems;
} }
public ACTION_ON_ITEM getAction() {
return action;
}
} }

View File

@ -2,22 +2,20 @@ package org.gcube.portlets.user.geoportaldataentry.client.events;
import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.EventHandler;
// TODO: Auto-generated Javadoc
/** /**
* The Interface ShowItemEventHandler. * The Interface ActionOnItemEventHandler.
* *
* @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 * Aug 5, 2021
*/ */
public interface ShowItemEventHandler extends EventHandler { public interface ActionOnItemEventHandler extends EventHandler {
/** /**
* On show item clicked. * On do action fired.
* *
* @param <T> the generic type * @param <T> the generic type
* @param showItemEvent the show item event * @param showItemEvent the show item event
*/ */
<T> void onShowItemClicked(ShowItemEvent<T> showItemEvent); <T> void onDoActionFired(ActionOnItemEvent<T> showItemEvent);
} }

View File

@ -9,6 +9,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.VerticalPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
/** /**
@ -16,19 +17,22 @@ 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)
* *
* Oct 13, 2020 * Oct 13, 2020
*/ */
public class GeonaMainPanel extends Composite { public class GeonaMainPanel extends Composite {
/** The geona main form panel. */ /** The geona main form panel. */
@UiField @UiField
HTMLPanel geonaMainFormPanel; HTMLPanel geonaMainFormPanel;
@UiField
HTMLPanel geonaListOfConcessioniPanel;
/** The loader. */ /** The loader. */
@UiField @UiField
LoaderIcon loader; LoaderIcon loader;
@UiField @UiField
GeonaNavigationBar geonaNavigationBar; GeonaNavigationBar geonaNavigationBar;
private HandlerManager appManagerBus; private HandlerManager appManagerBus;
@ -41,40 +45,57 @@ public class GeonaMainPanel extends Composite {
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Oct 13, 2020 * Oct 13, 2020
*/ */
interface GeonaMainPanelUiBinder extends UiBinder<Widget, GeonaMainPanel> { interface GeonaMainPanelUiBinder extends UiBinder<Widget, GeonaMainPanel> {
} }
/** /**
* Instantiates a new geona main panel. * Instantiates a new geona main panel.
* @param appManagerBus *
* @param appManagerBus
*/ */
public GeonaMainPanel(HandlerManager appManagerBus) { public GeonaMainPanel(HandlerManager appManagerBus) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
this.appManagerBus = appManagerBus; this.appManagerBus = appManagerBus;
geonaNavigationBar.setAppManagerBus(appManagerBus); geonaNavigationBar.setAppManagerBus(appManagerBus);
} }
/** /**
* Adds the form panel. * Adds the form panel.
* *
* @param formPanel the form panel * @param formPanel the form panel
*/ */
public void addFormPanel(GeonaDataEntryMainForm formPanel) { public void addFormPanel(GeonaDataEntryMainForm formPanel) {
geonaListOfConcessioniPanel.setVisible(false);
geonaMainFormPanel.add(formPanel); geonaMainFormPanel.add(formPanel);
geonaMainFormPanel.setVisible(true);
} }
public void showListOfConcessioniView(GeonaRecordsPaginatedView grpw) {
setFormPanelVisible(false);
geonaListOfConcessioniPanel.clear();
VerticalPanel htmllPanel = new VerticalPanel();
htmllPanel.add(grpw.getCellPanel());
htmllPanel.add(grpw.getPagerPanel());
geonaListOfConcessioniPanel.add(htmllPanel);
}
/** /**
* Sets the loader visible. * Sets the loader visible.
* *
* @param txtHTML the txt HTML * @param txtHTML the txt HTML
* @param visible the visible * @param visible the visible
*/ */
public void setLoaderVisible(String txtHTML, boolean visible){ public void setLoaderVisible(String txtHTML, boolean visible) {
loader.setText(txtHTML); loader.setText(txtHTML);
loader.setVisible(visible); loader.setVisible(visible);
} }
public void setFormPanelVisible(boolean bool) {
geonaMainFormPanel.setVisible(bool);
geonaListOfConcessioniPanel.setVisible(!bool);
}
} }

View File

@ -23,5 +23,6 @@
<m:GeonaNavigationBar ui:field="geonaNavigationBar"></m:GeonaNavigationBar> <m:GeonaNavigationBar ui:field="geonaNavigationBar"></m:GeonaNavigationBar>
<r:LoaderIcon ui:field="loader"></r:LoaderIcon> <r:LoaderIcon ui:field="loader"></r:LoaderIcon>
<g:HTMLPanel ui:field="geonaMainFormPanel"></g:HTMLPanel> <g:HTMLPanel ui:field="geonaMainFormPanel"></g:HTMLPanel>
<g:HTMLPanel ui:field="geonaListOfConcessioniPanel" visible="false"></g:HTMLPanel>
</g:HTMLPanel> </g:HTMLPanel>
</ui:UiBinder> </ui:UiBinder>

View File

@ -15,6 +15,7 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.cellview.client.SimplePager; import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.cellview.client.SimplePager.TextLocation; import com.google.gwt.user.cellview.client.SimplePager.TextLocation;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Label;
@ -27,13 +28,12 @@ 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;
/** /**
* The Class GeonaRecordsPaginatedView. * The Class GeonaRecordsPaginatedView.
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Aug 4, 2021 * Aug 4, 2021
*/ */
public class GeonaRecordsPaginatedView { public class GeonaRecordsPaginatedView {
@ -50,14 +50,13 @@ public class GeonaRecordsPaginatedView {
private HandlerManager eventBus; private HandlerManager eventBus;
private RECORD_TYPE recordType; private RECORD_TYPE recordType;
/** /**
* Instantiates a new geona records paginated view. * Instantiates a new geona records paginated view.
* *
* @param eventbus the eventbus * @param eventbus the eventbus
* @param recordType the record type * @param recordType the record type
* @param displayFields the display fields * @param displayFields the display fields
* @param sortByField the sort by field * @param sortByField the sort by field
*/ */
public GeonaRecordsPaginatedView(HandlerManager eventbus, RECORD_TYPE recordType, DISPLAY_FIELD[] displayFields, public GeonaRecordsPaginatedView(HandlerManager eventbus, RECORD_TYPE recordType, DISPLAY_FIELD[] displayFields,
DISPLAY_FIELD sortByField) { DISPLAY_FIELD sortByField) {
@ -74,11 +73,11 @@ public class GeonaRecordsPaginatedView {
} }
/** /**
* Gets the asycn data provider. * Gets the table data provider.
* *
* @return the asycn data provider * @return the table data provider
*/ */
public AsyncDataProvider<ConcessioneDV> getAsycnDataProvider() { public AsyncDataProvider<ConcessioneDV> getTableDataProvider() {
return (AsyncDataProvider<ConcessioneDV>) getCellTable().getDataProvider(); return (AsyncDataProvider<ConcessioneDV>) getCellTable().getDataProvider();
} }
@ -109,33 +108,6 @@ public class GeonaRecordsPaginatedView {
pagerPanel.add(pager); pagerPanel.add(pager);
} }
/**
* Gets the pager panel.
*
* @return the pager panel
*/
public VerticalPanel getCellPanel() {
return vPanel;
}
/**
* Set the panel in loading mode.
*
* @param show the show
*/
protected void showLoading(boolean show) {
loadingPanel.setVisible(show);
}
/**
* Gets the pager panel.
*
* @return the pager panel
*/
public FlowPanel getPagerPanel() {
return pagerPanel;
}
/** /**
* Load new page. * Load new page.
* *
@ -156,11 +128,10 @@ public class GeonaRecordsPaginatedView {
newStartIndex = 0; newStartIndex = 0;
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); getTableDataProvider().updateRowCount(ITEMS_PER_PAGE, false);
} }
loadItemsForStatus(newStartIndex, limit, serverStartIndex); loadItemsForStatus(newStartIndex, limit, serverStartIndex);
} }
/** /**
@ -192,8 +163,8 @@ public class GeonaRecordsPaginatedView {
msm.clear(); msm.clear();
} }
getAsycnDataProvider().updateRowCount((int) result.getTotalItems(), true); getTableDataProvider().updateRowCount((int) result.getTotalItems(), true);
getAsycnDataProvider().updateRowData(result.getClientStartIndex(), result.getData()); getTableDataProvider().updateRowData(result.getClientStartIndex(), result.getData());
if (result.getData().size() == 0) { if (result.getData().size() == 0) {
getCellTable().setLoadingIndicator(new Label("No data")); getCellTable().setLoadingIndicator(new Label("No data"));
@ -207,7 +178,7 @@ public class GeonaRecordsPaginatedView {
if (result.isServerSearchFinished()) { if (result.isServerSearchFinished()) {
GWT.log("Search finished!!!"); GWT.log("Search finished!!!");
getAsycnDataProvider().updateRowCount(getCellTable().getRowCount(), true); getTableDataProvider().updateRowCount(getCellTable().getRowCount(), true);
} }
// initFirstRangeChanged = false; // initFirstRangeChanged = false;
@ -216,32 +187,34 @@ public class GeonaRecordsPaginatedView {
/** /**
* Load items for status. * Load items for status.
* *
* @param <T> the generic type * @param <T> the generic type
* @param offset the offset * @param newStartIndex the new start index
* @param limit the limit * @param limit the limit
* @param serverIndex the server index * @param serverIndex the server index
*/ */
private <T> void loadItemsForStatus(int newStartIndex, int limit, int serverIndex) { private <T> void loadItemsForStatus(int newStartIndex, int limit, int serverIndex) {
showLoading(true); showLoading(true);
GWT.log("calling getDataForStatus with parameters [startIndex: " + newStartIndex + ", limit: " + limit GWT.log("calling loadItemsForStatus with parameters [startIndex: " + newStartIndex + ", limit: " + limit
+ ", serverIndex:" + serverIndex + "]"); + ", serverIndex:" + serverIndex + "]");
GeoPortalDataEntryApp.greetingService.getListConcessioni(newStartIndex, limit, new AsyncCallback<SearchedData>() { GeoPortalDataEntryApp.greetingService.getListConcessioni(newStartIndex, limit,
new AsyncCallback<SearchedData>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
showLoading(false); showLoading(false);
Window.alert(caught.getMessage());
} }
@Override @Override
public void onSuccess(SearchedData result) { public void onSuccess(SearchedData result) {
showLoading(false); showLoading(false);
setNewPageResult(result); setNewPageResult(result);
} }
}); });
} }
@ -269,6 +242,9 @@ public class GeonaRecordsPaginatedView {
public List<ConcessioneDV> getSelectItems() { public List<ConcessioneDV> getSelectItems() {
return itemsTable.getSelectedItems(); return itemsTable.getSelectedItems();
} }
// int latestRangeStart = -1;
// int latestRangeLenght = -1;
/** /**
* A custom {@link AsyncDataProvider}. * A custom {@link AsyncDataProvider}.
@ -293,6 +269,15 @@ public class GeonaRecordsPaginatedView {
int start = range.getStart(); int start = range.getStart();
int length = range.getLength(); int length = range.getLength();
// if(latestRangeStart!=start || latestRangeLenght!=length) {
// GWT.log("ranges really changed");
// latestRangeStart = start;
// latestRangeLenght = length;
// }else {
// GWT.log("ranges DO NOT changed");
// return;
// }
if (initClassFirstRangeChanged) { if (initClassFirstRangeChanged) {
GWT.log("initClassFirstRangeChanged is true.. returning"); GWT.log("initClassFirstRangeChanged is true.. returning");
@ -301,10 +286,37 @@ public class GeonaRecordsPaginatedView {
} }
GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount()); GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount());
loadNewPage(start, length, false); loadNewPage(start, length, false);
//eventBus.fireEvent(new TableRangeViewChangedEvent<T>(start, length)); // eventBus.fireEvent(new TableRangeViewChangedEvent<T>(start, length));
} }
} }
/**
* Gets the pager panel.
*
* @return the pager panel
*/
public VerticalPanel getCellPanel() {
return vPanel;
}
/**
* Set the panel in loading mode.
*
* @param show the show
*/
protected void showLoading(boolean show) {
loadingPanel.setVisible(show);
}
/**
* Gets the pager panel.
*
* @return the pager panel
*/
public FlowPanel getPagerPanel() {
return pagerPanel;
}
} }

View File

@ -71,11 +71,16 @@ public abstract class AbstractItemsCellTable<T> {
this.fireEventOnClick = fireOnClick; this.fireEventOnClick = fireOnClick;
this.theSelectionModel = selectionModel; this.theSelectionModel = selectionModel;
sortedCellTable = new SortedCellTable<T>(pageSize, dataProvider); sortedCellTable = new SortedCellTable<T>(pageSize, dataProvider);
// sortedCellTable.addStyleName("table-cms-widget"); sortedCellTable.addStyleName("table-glor");
// sortedCellTable.addStyleName("table-cms-widget-vertical-middle"); sortedCellTable.addStyleName("table-glor-vertical-middle");
sortedCellTable.setStriped(true); sortedCellTable.setStriped(true);
sortedCellTable.setCondensed(true); sortedCellTable.setCondensed(true);
sortedCellTable.setWidth("100%", true); sortedCellTable.setWidth("100%", true);
//sortedCellTable.setBordered(true);
sortedCellTable.setAutoHeaderRefreshDisabled(true);
sortedCellTable.setAutoFooterRefreshDisabled(true);
// dataProvider.addDataDisplay(sortedCellTable); // dataProvider.addDataDisplay(sortedCellTable);
// initTable(cellTable, null, null); // initTable(cellTable, null, null);
//sortedCellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); //sortedCellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);

View File

@ -12,7 +12,8 @@ import java.util.Set;
import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataentry.client.events.ShowItemEvent; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
import com.github.gwtbootstrap.client.ui.Pagination; import com.github.gwtbootstrap.client.ui.Pagination;
import com.google.gwt.cell.client.ButtonCell; import com.google.gwt.cell.client.ButtonCell;
@ -63,7 +64,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016 * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016
*/ */
public static enum DISPLAY_FIELD { public static enum DISPLAY_FIELD {
NAME, INTRO, AUTHOR, PROJECT_START_DATE, PROJECT_END_DATE NAME, INTRO, AUTHOR, PROJECT_START_DATE, PROJECT_END_DATE, INSERTED_BY
}; };
private List<DISPLAY_FIELD> displayFields; private List<DISPLAY_FIELD> displayFields;
@ -71,6 +72,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
private Column<T, Date> endProjectDateColumn; private Column<T, Date> endProjectDateColumn;
private DISPLAY_FIELD startSortByColumn; private DISPLAY_FIELD startSortByColumn;
private boolean isAsyncronusTable; private boolean isAsyncronusTable;
private TextColumn<T> insertedBy;
/** /**
* Instantiates a new items table. * Instantiates a new items table.
@ -130,23 +132,6 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
// sortedCellTable.addColumn(checkColumn, "", false); // sortedCellTable.addColumn(checkColumn, "", false);
// sortedCellTable.setColumnWidth(checkColumn, 40, Unit.PX); // 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 show");
eventBus.fireEvent(new ShowItemEvent<T>(Arrays.asList(object)));
}
});
sortedCellTable.addColumn(showdItemColumn);
sortedCellTable.setColumnWidth(showdItemColumn, 80, Unit.PX);
if (this.displayFields.contains(DISPLAY_FIELD.NAME)) { if (this.displayFields.contains(DISPLAY_FIELD.NAME)) {
// NAME // NAME
@ -197,7 +182,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
} }
}; };
sortedCellTable.addColumn(introduction, "Intro", true); sortedCellTable.addColumn(introduction, "Introduction", true);
if (!isAsyncronusTable) { if (!isAsyncronusTable) {
Comparator<T> c = new Comparator<T>() { Comparator<T> c = new Comparator<T>() {
@ -209,6 +194,8 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
sortedCellTable.setComparator(introduction, c); sortedCellTable.setComparator(introduction, c);
} }
// sortedCellTable.setColumnWidth(introduction, 100, Unit.PCT);
} }
if (this.displayFields.contains(DISPLAY_FIELD.AUTHOR)) { if (this.displayFields.contains(DISPLAY_FIELD.AUTHOR)) {
@ -238,6 +225,8 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
sortedCellTable.setComparator(author, c); sortedCellTable.setComparator(author, c);
} }
sortedCellTable.setColumnWidth(author, 220, Unit.PX);
} }
if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_DATE)) { if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_DATE)) {
@ -280,6 +269,8 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
sortedCellTable.setComparator(startProjectDateColumn, c); sortedCellTable.setComparator(startProjectDateColumn, c);
} }
sortedCellTable.setColumnWidth(startProjectDateColumn, 150, Unit.PX);
} }
if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_END_DATE)) { if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_END_DATE)) {
@ -322,8 +313,71 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
sortedCellTable.setComparator(endProjectDateColumn, c); sortedCellTable.setComparator(endProjectDateColumn, c);
} }
sortedCellTable.setColumnWidth(endProjectDateColumn, 150, Unit.PX);
} }
if (this.displayFields.contains(DISPLAY_FIELD.INSERTED_BY)) {
// NAME
insertedBy = new TextColumn<T>() {
@Override
public String getValue(T object) {
if (object == null)
return "";
return ((ConcessioneDV) object).getCreationUser();
}
};
sortedCellTable.addColumn(insertedBy, "Inserted by", true);
if (!isAsyncronusTable) {
Comparator<T> c = new Comparator<T>() {
@Override
public int compare(T o1, T o2) {
return ((ConcessioneDV) o1).getCreationUser().compareTo(((ConcessioneDV) o2).getCreationUser());
}
};
sortedCellTable.setComparator(insertedBy, c);
}
sortedCellTable.setColumnWidth(insertedBy, 220, Unit.PX);
}
ButtonCell showOnMapButton = new ButtonCell();
Column<T, String> showOnMapColumn = new Column<T, String>(showOnMapButton) {
public String getValue(T object) {
return "Show on Map";
}
};
showOnMapColumn.setFieldUpdater(new FieldUpdater<T, String>() {
@Override
public void update(int index, T object, String value) {
GWT.log("clicked show");
eventBus.fireEvent(new ActionOnItemEvent<T>(Arrays.asList(object), ACTION_ON_ITEM.SHOW_ON_MAP));
}
});
sortedCellTable.addColumn(showOnMapColumn);
sortedCellTable.setColumnWidth(showOnMapColumn, 120, Unit.PX);
ButtonCell deleteRecordButton = new ButtonCell();
Column<T, String> deleteRecordColumn = new Column<T, String>(deleteRecordButton) {
public String getValue(T object) {
return "Delete";
}
};
deleteRecordColumn.setFieldUpdater(new FieldUpdater<T, String>() {
@Override
public void update(int index, T object, String value) {
eventBus.fireEvent(new ActionOnItemEvent<T>(Arrays.asList(object), ACTION_ON_ITEM.REMOVE));
}
});
sortedCellTable.addColumn(deleteRecordColumn);
sortedCellTable.setColumnWidth(deleteRecordColumn, 80, Unit.PX);
GWT.log("startSortByColumn: " + startSortByColumn); GWT.log("startSortByColumn: " + startSortByColumn);
if (startSortByColumn != null) if (startSortByColumn != null)

View File

@ -122,8 +122,9 @@ public class SortedCellTable<T> extends CellTable<T> {
addColumnSortHandler(listSortHandler); addColumnSortHandler(listSortHandler);
columnSortHandler = listSortHandler; columnSortHandler = listSortHandler;
} else if (this.dataProvider instanceof AsyncDataProvider) { } else if (this.dataProvider instanceof AsyncDataProvider) {
//AsyncDataProvider asyncDataProvider = ((AsyncDataProvider) this.dataProvider); // AsyncDataProvider asyncDataProvider = ((AsyncDataProvider)
//asyncDataProvider.get // this.dataProvider);
// asyncDataProvider.get
AsyncHandler asyncSortHandler = new AsyncHandler(this) { AsyncHandler asyncSortHandler = new AsyncHandler(this) {
@Override @Override
public void onColumnSort(ColumnSortEvent event) { public void onColumnSort(ColumnSortEvent event) {
@ -162,7 +163,7 @@ public class SortedCellTable<T> extends CellTable<T> {
} }
} }
}; };
// addColumnSortHandler(asyncSortHandler); // addColumnSortHandler(asyncSortHandler);
// columnSortHandler = asyncSortHandler; // columnSortHandler = asyncSortHandler;
} }
@ -229,16 +230,16 @@ public class SortedCellTable<T> extends CellTable<T> {
initialSortColumn = column; initialSortColumn = column;
} }
/** /**
* Set the comparator used to sort the specified column in ascending order. * Set the comparator used to sort the specified column in ascending order.
* *
* @param column the {@link Column} * @param column the {@link Column}
* @param comparator the {@link Comparator} to use for the {@link Column} * @param comparator the {@link Comparator} to use for the {@link Column}
*/ */
public void setComparator(Column<T, ?> column, Comparator<T> comparator) { public void setComparator(Column<T, ?> column, Comparator<T> comparator) {
comparators.put(column, comparator); comparators.put(column, comparator);
} }
/** /**
* Sets the sort order to use when this column is clicked and it was not * Sets the sort order to use when this column is clicked and it was not
@ -283,7 +284,8 @@ public class SortedCellTable<T> extends CellTable<T> {
}); });
// Might as well get the little arrow on the header to make it // Might as well get the little arrow on the header to make it
// official // official
getColumnSortList().push(new ColumnSortInfo(initialSortColumn, defaultSortOrderMap.get(initialSortColumn))); getColumnSortList()
.push(new ColumnSortInfo(initialSortColumn, defaultSortOrderMap.get(initialSortColumn)));
currentlySortedColumn = initialSortColumn; currentlySortedColumn = initialSortColumn;
} }

View File

@ -52,4 +52,23 @@ h1 {
.my-html-table td:first-child { .my-html-table td:first-child {
color: gray; color: gray;
} }
/*** TABLE GET LIST OF RECORDS***/
.table-glor {
word-wrap: break-word;
}
.table-glor td, th {
overflow: hidden !important;
}
.table-glor th {
/*text-align: center !important;*/
}
.table-glor-vertical-middle td, th {
height: 50%;
vertical-align: middle !important;
}