Updated Map Creation

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-map-widget@100628 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-10-13 09:58:16 +00:00 committed by Giancarlo Panichi
parent 74dcc22df4
commit 6b1c562042
8 changed files with 450 additions and 217 deletions

View File

@ -2,7 +2,7 @@ package org.gcube.portlets.user.td.mapwidget.client;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.map.MapCreationSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.mapwidget.client.grid.ColumnDataGridPanel;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
@ -34,23 +34,21 @@ public class MapWidgetConfigCard extends WizardCard {
private static final int LABEL_WIDTH = 128;
private static final int LABEL_PAD_WIDTH = 2;
protected JSONExportSession exportSession;
protected MapCreationSession mapCreationSession;
private Radio viewColumnExportTrue;
private Radio viewColumnExportFalse;
private Radio viewColumnMapTrue;
private Radio viewColumnMapFalse;
protected ColumnDataGridPanel jsonColumnGridPanel;
private ColumnDataGridPanel mapColumnGridPanel;
public MapWidgetConfigCard(final JSONExportSession exportSession) {
super("JSON configuration", "");
public MapWidgetConfigCard(final MapCreationSession mapCreationSession) {
super("Map configuration", "");
if (exportSession == null) {
Log.error("JSONExportSession is null");
if (mapCreationSession == null) {
Log.error("MapCreationSession is null");
}
this.exportSession = exportSession;
this.mapCreationSession = mapCreationSession;
FormPanel panel = createPanel();
setContent(panel);
@ -66,32 +64,33 @@ public class MapWidgetConfigCard extends WizardCard {
panel.add(content);
// Export View Column
viewColumnExportTrue = new Radio();
viewColumnExportTrue.setBoxLabel("True");
viewColumnExportTrue.setValue(true);
viewColumnMapTrue = new Radio();
viewColumnMapTrue.setBoxLabel("True");
viewColumnMapTrue.setValue(true);
viewColumnExportFalse = new Radio();
viewColumnExportFalse.setBoxLabel("False");
viewColumnMapFalse = new Radio();
viewColumnMapFalse.setBoxLabel("False");
ToggleGroup exportViewColumnGroup = new ToggleGroup();
exportViewColumnGroup.add(viewColumnExportTrue);
exportViewColumnGroup.add(viewColumnExportFalse);
HorizontalPanel viewColumnExportPanel = new HorizontalPanel();
viewColumnExportPanel.add(viewColumnExportTrue);
viewColumnExportPanel.add(viewColumnExportFalse);
new ToolTip(viewColumnExportPanel, new ToolTipConfig(
"Export View Columns Too"));
FieldLabel fieldViewColumns=new FieldLabel(viewColumnExportPanel, "Export View Columns");
ToggleGroup mapViewColumnGroup = new ToggleGroup();
mapViewColumnGroup.add(viewColumnMapTrue);
mapViewColumnGroup.add(viewColumnMapFalse);
HorizontalPanel mapViewColumnPanel = new HorizontalPanel();
mapViewColumnPanel.add(viewColumnMapTrue);
mapViewColumnPanel.add(viewColumnMapFalse);
new ToolTip(mapViewColumnPanel, new ToolTipConfig(
"Use View Columns Too"));
FieldLabel fieldViewColumns = new FieldLabel(mapViewColumnPanel,
"Use View Columns");
fieldViewColumns.setLabelWidth(LABEL_WIDTH);
fieldViewColumns.setLabelPad(LABEL_PAD_WIDTH);
content.add(fieldViewColumns);
// Column Selection Grid
jsonColumnGridPanel = new ColumnDataGridPanel(this);
mapColumnGridPanel = new ColumnDataGridPanel(this);
jsonColumnGridPanel
mapColumnGridPanel
.addSelectionHandler(new SelectionHandler<ColumnData>() {
public void onSelection(SelectionEvent<ColumnData> event) {
@ -100,15 +99,13 @@ public class MapWidgetConfigCard extends WizardCard {
});
content.add(jsonColumnGridPanel);
content.add(mapColumnGridPanel);
return panel;
}
protected boolean getExportViewColumns() {
if(viewColumnExportTrue.getValue()){
protected boolean useViewColumnsInMap() {
if (viewColumnMapTrue.getValue()) {
return true;
} else {
return false;
@ -117,11 +114,11 @@ public class MapWidgetConfigCard extends WizardCard {
@Override
public void setup() {
Log.debug("JSONExportConfigCard Setup");
Log.debug("MapWidgetConfigCard Setup");
Command sayNextCard = new Command() {
public void execute() {
Log.debug("JSONExportConfigCard Call sayNextCard");
Log.debug("MapWidgetConfigCard Call sayNextCard");
checkData();
}
@ -145,15 +142,17 @@ public class MapWidgetConfigCard extends WizardCard {
}
};
ArrayList<ColumnData> columns = jsonColumnGridPanel.getSelectedItems();
if (columns.size() == 0) {
ColumnData column = mapColumnGridPanel.getSelectedItem();
if (column == null) {
d = new AlertMessageBox("Attention", "No columns selected");
d.addHideHandler(hideHandler);
d.setModal(false);
d.show();
} else {
exportSession.setColumns(columns);
exportSession.setExportViewColumns(getExportViewColumns());
ArrayList<ColumnData> columns=new ArrayList<ColumnData>();
columns.add(column);
mapCreationSession.setFeature(columns);
mapCreationSession.setUseView(useViewColumnsInMap());
goNext();
}
@ -161,10 +160,14 @@ public class MapWidgetConfigCard extends WizardCard {
protected void goNext() {
try {
/*DestinationSelectionCard destCard = new DestinationSelectionCard(
exportSession);
getWizardWindow().addCard(destCard);
getWizardWindow().nextCard();*/
if (mapCreationSession.getCountGeometryColumns() == 1) {
MapWidgetDetailCard mapWidgetDetailCard = new MapWidgetDetailCard(
mapCreationSession);
getWizardWindow().addCard(mapWidgetDetailCard);
getWizardWindow().nextCard();
} else {
}
} catch (Exception e) {
Log.error("sayNextCard :" + e.getLocalizedMessage());
}
@ -175,4 +178,11 @@ public class MapWidgetConfigCard extends WizardCard {
}
public MapCreationSession getMapCreationSession() {
return mapCreationSession;
}
}

View File

@ -4,37 +4,25 @@
package org.gcube.portlets.user.td.mapwidget.client;
import java.util.ArrayList;
import java.util.Date;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData;
import org.gcube.portlets.user.td.gwtservice.shared.map.MapCreationSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
import com.allen_sauer.gwt.log.client.Log;
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.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
import com.sencha.gxt.data.client.loader.RpcProxy;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
import com.sencha.gxt.data.shared.loader.ListLoadConfigBean;
import com.sencha.gxt.data.shared.loader.ListLoadResult;
import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
import com.sencha.gxt.data.shared.loader.ListLoader;
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
@ -42,10 +30,8 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.Verti
import com.sencha.gxt.widget.core.client.event.HideEvent;
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
import com.sencha.gxt.widget.core.client.form.ComboBox;
import com.sencha.gxt.widget.core.client.form.DateField;
import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.form.FieldSet;
import com.sencha.gxt.widget.core.client.form.TextArea;
import com.sencha.gxt.widget.core.client.form.TextField;
/**
@ -61,7 +47,7 @@ public class MapWidgetDetailCard extends WizardCard {
protected final String TABLEDETAILPANELHEIGHT = "100%";
protected final String FORMWIDTH = "538px";
protected MapCreationSession mapCreationSession;
protected MapCreationSession mapCreationSession;
protected MapWidgetDetailCard thisCard;
protected VerticalLayoutContainer p;
@ -74,12 +60,11 @@ public class MapWidgetDetailCard extends WizardCard {
private TextField metaCredits;
private TextField metaKeywords;
protected ListLoader<ListLoadConfig, ListLoadResult<LicenceData>> loader;
protected ComboBox<LicenceData> comboLicences;
public MapWidgetDetailCard(final MapCreationSession mapCreationSession) {
super("Tabular Resource Detail", "");
public MapWidgetDetailCard(final MapCreationSession mapCreationSession) {
super("Map Detail", "");
this.mapCreationSession = mapCreationSession;
thisCard = this;
@ -105,40 +90,44 @@ public class MapWidgetDetailCard extends WizardCard {
name = new TextField();
name.setAllowBlank(false);
name.setEmptyText("Enter a name...");
name.setValue(mapCreationSession.getName());
name.setValue("");
p.add(new FieldLabel(name, "Name"), new VerticalLayoutData(1, -1));
userName = new TextField();
userName.setAllowBlank(false);
userName.setEmptyText("Enter a user name...");
userName.setValue(mapCreationSession.getUsername());
p.add(new FieldLabel(userName, "User Name"), new VerticalLayoutData(1, -1));
p.add(new FieldLabel(userName, "User Name"), new VerticalLayoutData(1,
-1));
metaAbstract = new TextField();
metaAbstract.setAllowBlank(false);
metaAbstract.setEmptyText("Enter a abstract...");
metaAbstract.setValue("");
p.add(new FieldLabel(metaAbstract, "Abstract"), new VerticalLayoutData(1, -1));
p.add(new FieldLabel(metaAbstract, "Abstract"), new VerticalLayoutData(
1, -1));
metaPurpose = new TextField();
metaPurpose.setAllowBlank(false);
metaPurpose.setEmptyText("Enter a purpose...");
metaPurpose.setValue("");
p.add(new FieldLabel(metaPurpose, "Purpose"), new VerticalLayoutData(1, -1));
p.add(new FieldLabel(metaPurpose, "Purpose"), new VerticalLayoutData(1,
-1));
metaCredits = new TextField();
metaCredits.setAllowBlank(false);
metaCredits.setEmptyText("Enter credits...");
metaCredits.setValue("");
p.add(new FieldLabel(metaCredits, "Credits"), new VerticalLayoutData(1, -1));
p.add(new FieldLabel(metaCredits, "Credits"), new VerticalLayoutData(1,
-1));
metaKeywords = new TextField();
metaKeywords.setAllowBlank(false);
metaKeywords.setEmptyText("Enter keywords...");
metaKeywords.setValue("");
p.add(new FieldLabel(metaKeywords, "Keywords"), new VerticalLayoutData(1, -1));
p.add(new FieldLabel(metaKeywords, "Keywords"), new VerticalLayoutData(
1, -1));
tableDetailPanel.add(form);
setContent(tableDetailPanel);
@ -224,53 +213,45 @@ public class MapWidgetDetailCard extends WizardCard {
d.addHideHandler(hideHandler);
d.show();
} else {
name.setReadOnly(true);
goNext();
if (userName.getValue() == null || userName.getValue().isEmpty()
|| !userName.isValid()) {
d = new AlertMessageBox("Attention!", "Fill in user name field");
d.addHideHandler(hideHandler);
d.show();
} else {
name.setReadOnly(true);
userName.setReadOnly(true);
metaAbstract.setReadOnly(true);
metaPurpose.setReadOnly(true);
metaCredits.setReadOnly(true);
metaKeywords.setReadOnly(true);
goNext();
}
}
}
protected void goNext() {
try {
/*
detail= new TabResource();
detail.setName(name.getCurrentValue());
detail.setDescription(description.getCurrentValue());
detail.setRight(rights.getCurrentValue());
Date vFrom = validFrom.getCurrentValue();
if (vFrom == null) {
Log.debug("Valid From is null");
} else {
try {
detail.setValidFrom(sdf.format(vFrom));
} catch (Throwable e) {
Log.error("Error parsing Valid From "
+ e.getLocalizedMessage());
}
}
Date vUntilTo = validUntilTo.getCurrentValue();
if (vUntilTo == null) {
Log.debug("Valid Until To is null");
} else {
try {
detail.setValidUntilTo(sdf.format(vUntilTo));
} catch (Throwable e) {
Log.error("Error parsing Valid Until To "
+ e.getLocalizedMessage());
}
mapCreationSession.setName(name.getCurrentValue());
mapCreationSession.setUsername(userName.getCurrentValue());
mapCreationSession.setMetaAbstract(metaAbstract.getCurrentValue());
mapCreationSession.setMetaPurpose(metaPurpose.getCurrentValue());
mapCreationSession.setMetaCredits(metaCredits.getCurrentValue());
ArrayList<String> keywordsList=new ArrayList<String>();
String keys=metaKeywords.getCurrentValue();
int separator=keys.indexOf(",");
while(separator!=-1){
String keyNew=keys.substring(0, separator);
keywordsList.add(keyNew);
keys=keys.substring(separator+1);
separator=keys.indexOf(",");
}
keywordsList.add(keys);
if(comboLicences.getCurrentValue()!=null&&
comboLicences.getCurrentValue().getLicence()!=null && !comboLicences.getCurrentValue().getLicence().isEmpty()){
detail.setLicence(comboLicences.getCurrentValue().getLicence());
}
mapCreationSession.setTabResource(detail);
*/
mapCreationSession.setMetaKeywords(keywordsList);
MapWidgetOperationInProgressCard mapWidgetOperationInProgressCard = new MapWidgetOperationInProgressCard(
mapCreationSession);
getWizardWindow().addCard(mapWidgetOperationInProgressCard);

View File

@ -0,0 +1,133 @@
package org.gcube.portlets.user.td.mapwidget.client;
import org.gcube.portlets.user.td.gwtservice.shared.map.MapCreationSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.mapwidget.client.grid.GeometrySelectionGridPanel;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.Command;
import com.sencha.gxt.core.client.util.Padding;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.event.HideEvent;
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
import com.sencha.gxt.widget.core.client.form.FormPanel;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class MapWidgetGeometrySelectionCard extends WizardCard {
protected MapCreationSession mapCreationSession;
private GeometrySelectionGridPanel geometrySelectionGridPanel;
public MapWidgetGeometrySelectionCard(
final MapCreationSession mapCreationSession) {
super("Geometry Selection", "");
if (mapCreationSession == null) {
Log.error("MapCreationSession is null");
}
this.mapCreationSession = mapCreationSession;
FormPanel panel = createPanel();
setContent(panel);
}
protected FormPanel createPanel() {
FormPanel panel = new FormPanel();
panel.setLabelWidth(90);
panel.getElement().setPadding(new Padding(5));
VerticalLayoutContainer content = new VerticalLayoutContainer();
panel.add(content);
// Column Selection Grid
geometrySelectionGridPanel = new GeometrySelectionGridPanel(this);
geometrySelectionGridPanel
.addSelectionHandler(new SelectionHandler<ColumnData>() {
public void onSelection(SelectionEvent<ColumnData> event) {
}
});
content.add(geometrySelectionGridPanel);
return panel;
}
@Override
public void setup() {
Log.debug("MapWidgetConfigCard Setup");
Command sayNextCard = new Command() {
public void execute() {
Log.debug("MapWidgetConfigCard Call sayNextCard");
checkData();
}
};
getWizardWindow().setNextButtonCommand(sayNextCard);
setEnableBackButton(false);
setEnableNextButton(true);
}
protected void checkData() {
getWizardWindow().setEnableNextButton(false);
getWizardWindow().setEnableBackButton(false);
AlertMessageBox d;
HideHandler hideHandler = new HideHandler() {
public void onHide(HideEvent event) {
getWizardWindow().setEnableNextButton(true);
getWizardWindow().setEnableBackButton(false);
}
};
ColumnData columnGeo = geometrySelectionGridPanel.getSelectedItem();
if (columnGeo == null) {
d = new AlertMessageBox("Attention", "No columns selected");
d.addHideHandler(hideHandler);
d.setModal(false);
d.show();
} else {
mapCreationSession.setGeometry(columnGeo);
goNext();
}
}
protected void goNext() {
try {
MapWidgetDetailCard mapWidgetDetailCard = new MapWidgetDetailCard(
mapCreationSession);
getWizardWindow().addCard(mapWidgetDetailCard);
getWizardWindow().nextCard();
} catch (Exception e) {
Log.error("sayNextCard :" + e.getLocalizedMessage());
}
}
@Override
public void dispose() {
}
public MapCreationSession getMapCreationSession() {
return mapCreationSession;
}
}

View File

@ -4,10 +4,9 @@
package org.gcube.portlets.user.td.mapwidget.client;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.map.MapCreationSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.map.MapCreationSession;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
@ -106,8 +105,8 @@ public class MapWidgetOperationInProgressCard extends WizardCard implements
showErrorAndHide("Error Locked",
caught.getLocalizedMessage(), caught);
} else {
showErrorAndHide("Error in export",
"An error occured in export: "
showErrorAndHide("Error",
"An error occured in map creation: "
+ caught.getLocalizedMessage(),
caught);

View File

@ -2,8 +2,22 @@ package org.gcube.portlets.user.td.mapwidget.client;
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.map.MapCreationSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow;
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
@ -16,28 +30,87 @@ import com.google.web.bindery.event.shared.EventBus;
*/
public class MapWidgetTD extends WizardWindow {
protected JSONExportSession exportSession;
protected MapCreationSession mapCreationSession;
/**
*
* @param title
* @param eventBus
*/
public MapWidgetTD(String title, EventBus eventBus) {
public MapWidgetTD(TRId trId, String userName, String title, EventBus eventBus) {
super(title,eventBus);
exportSession= new JSONExportSession();
MapWidgetConfigCard jsonExportConfigCard=new MapWidgetConfigCard(exportSession);
addCard(jsonExportConfigCard);
jsonExportConfigCard.setup();
mapCreationSession= new MapCreationSession();
mapCreationSession.setTrId(trId);
mapCreationSession.setUsername(userName);
retrieveColumns();
}
private void startMapCreation() {
MapWidgetConfigCard mapWidgetConfigCard=new MapWidgetConfigCard(mapCreationSession);
addCard(mapWidgetConfigCard);
mapWidgetConfigCard.setup();
show();
}
protected void retrieveColumns(){
TDGWTServiceAsync.INSTANCE
.getColumns(new AsyncCallback<ArrayList<ColumnData>>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus
.fireEvent(
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
showErrorAndHide("Error Locked",
caught.getLocalizedMessage(), caught);
} else {
Log.error("No load columns: "
+ caught.getLocalizedMessage());
}
}
}
public void onSuccess(ArrayList<ColumnData> result) {
Log.trace("loaded " + result.size() + " columns");
ArrayList<ColumnData> geometryColumnsList=new ArrayList<ColumnData>();
boolean existsGeometryColumn=false;
int countGeometryColumns=0;
for(ColumnData column:result){
if(column.getDataTypeName().compareTo(ColumnDataType.Geometry.toString())==0){
existsGeometryColumn=true;
countGeometryColumns++;
geometryColumnsList.add(column);
}
}
mapCreationSession.setColumns(result);
mapCreationSession.setGeometryColumns(geometryColumnsList);
mapCreationSession.setExistsGeometryColumn(existsGeometryColumn);
mapCreationSession.setCountGeometryColumns(countGeometryColumns);
if(!existsGeometryColumn){
Log.info("Attention, no Geometry Column present!");
UtilsGXT3.alert("Attention", "No Geometry Column Present!");
close(false);
} else {
if(countGeometryColumns==1){
mapCreationSession.setGeometry(geometryColumnsList.get(0));
}
startMapCreation();
}
}
});
}
}

View File

@ -1,5 +1,7 @@
package org.gcube.portlets.user.td.mapwidget.client;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.EntryPoint;
import com.google.web.bindery.event.shared.SimpleEventBus;
@ -8,8 +10,11 @@ public class MapWidgetTDEntry implements EntryPoint {
public void onModuleLoad() {
TRId trId=new TRId("10","20");
String userName="test.user";
SimpleEventBus eventBus=new SimpleEventBus();
MapWidgetTD exportWizard= new MapWidgetTD("CSVExport",eventBus);
Log.info(exportWizard.getId());
MapWidgetTD mapCreationWizard= new MapWidgetTD(trId, userName,"Map Creation",eventBus);
Log.info(mapCreationWizard.getId());
}
}

View File

@ -3,33 +3,19 @@ package org.gcube.portlets.user.td.mapwidget.client.grid;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import org.gcube.portlets.user.td.mapwidget.client.MapWidgetConfigCard;
import com.allen_sauer.gwt.log.client.Log;
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.event.logical.shared.HasSelectionHandlers;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.sencha.gxt.core.client.IdentityValueProvider;
import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.client.loader.RpcProxy;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
import com.sencha.gxt.data.shared.loader.ListLoadResult;
import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
import com.sencha.gxt.data.shared.loader.ListLoader;
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
@ -40,27 +26,27 @@ import com.sencha.gxt.widget.core.client.grid.Grid;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ColumnDataGridPanel extends ContentPanel implements
HasSelectionHandlers<ColumnData> {
//private static final String GRID_WIDTH ="524px";
// private static final String GRID_WIDTH ="524px";
private static final String GRID_HEIGHT = "320px";
protected static final ColumnDataProperties props = GWT
.create(ColumnDataProperties.class);
protected final CheckBoxSelectionModel<ColumnData> sm;
protected final Grid<ColumnData> grid;
private WizardCard parent;
protected MapWidgetConfigCard parent;
/**
*
* @param parent
*/
public ColumnDataGridPanel(WizardCard parent) {
this.parent=parent;
public ColumnDataGridPanel(MapWidgetConfigCard parent) {
this.parent = parent;
Log.debug("ColumnDataGridPanel");
setHeadingText("Columns");
@ -77,40 +63,13 @@ public class ColumnDataGridPanel extends ContentPanel implements
ColumnModel<ColumnData> cm = new ColumnModel<ColumnData>(l);
ListStore<ColumnData> store = new ListStore<ColumnData>(props.id());
store.addAll(parent.getMapCreationSession().getColumns());
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
public void load(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
loadData(loadConfig, callback);
}
};
final ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader = new ListLoader<ListLoadConfig, ListLoadResult<ColumnData>>(
proxy);
loader.setRemoteSort(false);
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ColumnData, ListLoadResult<ColumnData>>(
store) {
});
grid = new Grid<ColumnData>(store, cm) {
@Override
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
loader.load();
}
});
}
};
sm.setSelectionMode(SelectionMode.MULTI);
grid.setLoader(loader);
grid = new Grid<ColumnData>(store, cm);
sm.setSelectionMode(SelectionMode.SINGLE);
grid.setSelectionModel(sm);
grid.setHeight(GRID_HEIGHT);
//grid.setWidth(GRID_WIDTH);
// grid.setWidth(GRID_WIDTH);
// grid.getView().setAutoExpandColumn(labelCol);
grid.getView().setStripeRows(true);
grid.getView().setColumnLines(true);
@ -130,39 +89,8 @@ public class ColumnDataGridPanel extends ContentPanel implements
return grid;
}
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
TDGWTServiceAsync.INSTANCE
.getColumns(new AsyncCallback<ArrayList<ColumnData>>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
parent.getEventBus()
.fireEvent(
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
parent.showErrorAndHide("Error Locked",
caught.getLocalizedMessage(), caught);
} else {
Log.error("No load columns: "
+ caught.getLocalizedMessage());
}
}
callback.onFailure(caught);
}
public void onSuccess(ArrayList<ColumnData> result) {
Log.trace("loaded " + result.size() + " columns");
callback.onSuccess(new ListLoadResultBean<ColumnData>(
result));
sm.selectAll();
forceLayout();
}
});
public ColumnData getSelectedItem() {
return grid.getSelectionModel().getSelectedItem();
}
public ArrayList<ColumnData> getSelectedItems() {

View File

@ -0,0 +1,104 @@
package org.gcube.portlets.user.td.mapwidget.client.grid;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.mapwidget.client.MapWidgetGeometrySelectionCard;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.HasSelectionHandlers;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.sencha.gxt.core.client.IdentityValueProvider;
import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.grid.CheckBoxSelectionModel;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class GeometrySelectionGridPanel extends ContentPanel implements
HasSelectionHandlers<ColumnData> {
//private static final String GRID_WIDTH ="524px";
private static final String GRID_HEIGHT = "320px";
protected static final ColumnDataProperties props = GWT
.create(ColumnDataProperties.class);
protected final CheckBoxSelectionModel<ColumnData> sm;
protected final Grid<ColumnData> grid;
protected MapWidgetGeometrySelectionCard parent;
/**
*
* @param parent
*/
public GeometrySelectionGridPanel(MapWidgetGeometrySelectionCard parent) {
this.parent=parent;
Log.debug("GeometrySelectionGridPanel");
setHeadingText("Geometries");
ColumnConfig<ColumnData, String> labelCol = new ColumnConfig<ColumnData, String>(
props.label());
IdentityValueProvider<ColumnData> identity = new IdentityValueProvider<ColumnData>();
sm = new CheckBoxSelectionModel<ColumnData>(identity);
List<ColumnConfig<ColumnData, ?>> l = new ArrayList<ColumnConfig<ColumnData, ?>>();
l.add(sm.getColumn());
l.add(labelCol);
ColumnModel<ColumnData> cm = new ColumnModel<ColumnData>(l);
ListStore<ColumnData> store = new ListStore<ColumnData>(props.id());
store.addAll(parent.getMapCreationSession().getGeometryColumns());
grid = new Grid<ColumnData>(store, cm);
sm.setSelectionMode(SelectionMode.SINGLE);
grid.setSelectionModel(sm);
grid.setHeight(GRID_HEIGHT);
//grid.setWidth(GRID_WIDTH);
// grid.getView().setAutoExpandColumn(labelCol);
grid.getView().setStripeRows(true);
grid.getView().setColumnLines(true);
grid.getView().setAutoFill(true);
grid.setBorders(false);
grid.setLoadMask(true);
grid.setColumnReordering(false);
VerticalLayoutContainer con = new VerticalLayoutContainer();
con.setScrollMode(ScrollMode.AUTO);
con.add(grid, new VerticalLayoutData(-1, -1, new Margins(0)));
setWidget(con);
}
public Grid<ColumnData> getGrid() {
return grid;
}
public ColumnData getSelectedItem() {
return grid.getSelectionModel()
.getSelectedItem();
}
public HandlerRegistration addSelectionHandler(
SelectionHandler<ColumnData> handler) {
return grid.getSelectionModel().addSelectionHandler(handler);
}
}