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 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.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.mapwidget.client.grid.ColumnDataGridPanel; import org.gcube.portlets.user.td.mapwidget.client.grid.ColumnDataGridPanel;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; 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_WIDTH = 128;
private static final int LABEL_PAD_WIDTH = 2; private static final int LABEL_PAD_WIDTH = 2;
protected JSONExportSession exportSession;
protected MapCreationSession mapCreationSession;
private Radio viewColumnExportTrue; private Radio viewColumnMapTrue;
private Radio viewColumnExportFalse; private Radio viewColumnMapFalse;
protected ColumnDataGridPanel jsonColumnGridPanel; private ColumnDataGridPanel mapColumnGridPanel;
public MapWidgetConfigCard(final JSONExportSession exportSession) { public MapWidgetConfigCard(final MapCreationSession mapCreationSession) {
super("JSON configuration", ""); super("Map configuration", "");
if (exportSession == null) { if (mapCreationSession == null) {
Log.error("JSONExportSession is null"); Log.error("MapCreationSession is null");
} }
this.exportSession = exportSession; this.mapCreationSession = mapCreationSession;
FormPanel panel = createPanel(); FormPanel panel = createPanel();
setContent(panel); setContent(panel);
@ -66,32 +64,33 @@ public class MapWidgetConfigCard extends WizardCard {
panel.add(content); panel.add(content);
// Export View Column // Export View Column
viewColumnExportTrue = new Radio(); viewColumnMapTrue = new Radio();
viewColumnExportTrue.setBoxLabel("True"); viewColumnMapTrue.setBoxLabel("True");
viewColumnExportTrue.setValue(true); viewColumnMapTrue.setValue(true);
viewColumnExportFalse = new Radio(); viewColumnMapFalse = new Radio();
viewColumnExportFalse.setBoxLabel("False"); viewColumnMapFalse.setBoxLabel("False");
ToggleGroup exportViewColumnGroup = new ToggleGroup(); ToggleGroup mapViewColumnGroup = new ToggleGroup();
exportViewColumnGroup.add(viewColumnExportTrue); mapViewColumnGroup.add(viewColumnMapTrue);
exportViewColumnGroup.add(viewColumnExportFalse); mapViewColumnGroup.add(viewColumnMapFalse);
HorizontalPanel viewColumnExportPanel = new HorizontalPanel(); HorizontalPanel mapViewColumnPanel = new HorizontalPanel();
viewColumnExportPanel.add(viewColumnExportTrue); mapViewColumnPanel.add(viewColumnMapTrue);
viewColumnExportPanel.add(viewColumnExportFalse); mapViewColumnPanel.add(viewColumnMapFalse);
new ToolTip(viewColumnExportPanel, new ToolTipConfig( new ToolTip(mapViewColumnPanel, new ToolTipConfig(
"Export View Columns Too")); "Use View Columns Too"));
FieldLabel fieldViewColumns=new FieldLabel(viewColumnExportPanel, "Export View Columns"); FieldLabel fieldViewColumns = new FieldLabel(mapViewColumnPanel,
"Use View Columns");
fieldViewColumns.setLabelWidth(LABEL_WIDTH); fieldViewColumns.setLabelWidth(LABEL_WIDTH);
fieldViewColumns.setLabelPad(LABEL_PAD_WIDTH); fieldViewColumns.setLabelPad(LABEL_PAD_WIDTH);
content.add(fieldViewColumns); content.add(fieldViewColumns);
// Column Selection Grid // Column Selection Grid
jsonColumnGridPanel = new ColumnDataGridPanel(this); mapColumnGridPanel = new ColumnDataGridPanel(this);
jsonColumnGridPanel mapColumnGridPanel
.addSelectionHandler(new SelectionHandler<ColumnData>() { .addSelectionHandler(new SelectionHandler<ColumnData>() {
public void onSelection(SelectionEvent<ColumnData> event) { public void onSelection(SelectionEvent<ColumnData> event) {
@ -100,15 +99,13 @@ public class MapWidgetConfigCard extends WizardCard {
}); });
content.add(jsonColumnGridPanel); content.add(mapColumnGridPanel);
return panel; return panel;
} }
protected boolean useViewColumnsInMap() {
if (viewColumnMapTrue.getValue()) {
protected boolean getExportViewColumns() {
if(viewColumnExportTrue.getValue()){
return true; return true;
} else { } else {
return false; return false;
@ -117,11 +114,11 @@ public class MapWidgetConfigCard extends WizardCard {
@Override @Override
public void setup() { public void setup() {
Log.debug("JSONExportConfigCard Setup"); Log.debug("MapWidgetConfigCard Setup");
Command sayNextCard = new Command() { Command sayNextCard = new Command() {
public void execute() { public void execute() {
Log.debug("JSONExportConfigCard Call sayNextCard"); Log.debug("MapWidgetConfigCard Call sayNextCard");
checkData(); checkData();
} }
@ -145,15 +142,17 @@ public class MapWidgetConfigCard extends WizardCard {
} }
}; };
ArrayList<ColumnData> columns = jsonColumnGridPanel.getSelectedItems(); ColumnData column = mapColumnGridPanel.getSelectedItem();
if (columns.size() == 0) { if (column == null) {
d = new AlertMessageBox("Attention", "No columns selected"); d = new AlertMessageBox("Attention", "No columns selected");
d.addHideHandler(hideHandler); d.addHideHandler(hideHandler);
d.setModal(false); d.setModal(false);
d.show(); d.show();
} else { } else {
exportSession.setColumns(columns); ArrayList<ColumnData> columns=new ArrayList<ColumnData>();
exportSession.setExportViewColumns(getExportViewColumns()); columns.add(column);
mapCreationSession.setFeature(columns);
mapCreationSession.setUseView(useViewColumnsInMap());
goNext(); goNext();
} }
@ -161,10 +160,14 @@ public class MapWidgetConfigCard extends WizardCard {
protected void goNext() { protected void goNext() {
try { try {
/*DestinationSelectionCard destCard = new DestinationSelectionCard( if (mapCreationSession.getCountGeometryColumns() == 1) {
exportSession); MapWidgetDetailCard mapWidgetDetailCard = new MapWidgetDetailCard(
getWizardWindow().addCard(destCard); mapCreationSession);
getWizardWindow().nextCard();*/ getWizardWindow().addCard(mapWidgetDetailCard);
getWizardWindow().nextCard();
} else {
}
} catch (Exception e) { } catch (Exception e) {
Log.error("sayNextCard :" + e.getLocalizedMessage()); 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; package org.gcube.portlets.user.td.mapwidget.client;
import java.util.ArrayList; 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.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.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData; 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.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.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; 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.WizardCard;
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3; import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
import com.allen_sauer.gwt.log.client.Log; 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.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.VerticalPanel; 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.ListLoadConfig;
import com.sencha.gxt.data.shared.loader.ListLoadConfigBean;
import com.sencha.gxt.data.shared.loader.ListLoadResult; import com.sencha.gxt.data.shared.loader.ListLoadResult;
import com.sencha.gxt.data.shared.loader.ListLoadResultBean; import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
import com.sencha.gxt.data.shared.loader.ListLoader; 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.FramedPanel;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox; 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.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;
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler; 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.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.FieldLabel;
import com.sencha.gxt.widget.core.client.form.FieldSet; 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; 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 TABLEDETAILPANELHEIGHT = "100%";
protected final String FORMWIDTH = "538px"; protected final String FORMWIDTH = "538px";
protected MapCreationSession mapCreationSession; protected MapCreationSession mapCreationSession;
protected MapWidgetDetailCard thisCard; protected MapWidgetDetailCard thisCard;
protected VerticalLayoutContainer p; protected VerticalLayoutContainer p;
@ -74,12 +60,11 @@ public class MapWidgetDetailCard extends WizardCard {
private TextField metaCredits; private TextField metaCredits;
private TextField metaKeywords; private TextField metaKeywords;
protected ListLoader<ListLoadConfig, ListLoadResult<LicenceData>> loader; protected ListLoader<ListLoadConfig, ListLoadResult<LicenceData>> loader;
protected ComboBox<LicenceData> comboLicences; protected ComboBox<LicenceData> comboLicences;
public MapWidgetDetailCard(final MapCreationSession mapCreationSession) { public MapWidgetDetailCard(final MapCreationSession mapCreationSession) {
super("Tabular Resource Detail", ""); super("Map Detail", "");
this.mapCreationSession = mapCreationSession; this.mapCreationSession = mapCreationSession;
thisCard = this; thisCard = this;
@ -105,40 +90,44 @@ public class MapWidgetDetailCard extends WizardCard {
name = new TextField(); name = new TextField();
name.setAllowBlank(false); name.setAllowBlank(false);
name.setEmptyText("Enter a name..."); name.setEmptyText("Enter a name...");
name.setValue(mapCreationSession.getName()); name.setValue("");
p.add(new FieldLabel(name, "Name"), new VerticalLayoutData(1, -1)); p.add(new FieldLabel(name, "Name"), new VerticalLayoutData(1, -1));
userName = new TextField(); userName = new TextField();
userName.setAllowBlank(false); userName.setAllowBlank(false);
userName.setEmptyText("Enter a user name..."); userName.setEmptyText("Enter a user name...");
userName.setValue(mapCreationSession.getUsername()); 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 = new TextField();
metaAbstract.setAllowBlank(false); metaAbstract.setAllowBlank(false);
metaAbstract.setEmptyText("Enter a abstract..."); metaAbstract.setEmptyText("Enter a abstract...");
metaAbstract.setValue(""); 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 = new TextField();
metaPurpose.setAllowBlank(false); metaPurpose.setAllowBlank(false);
metaPurpose.setEmptyText("Enter a purpose..."); metaPurpose.setEmptyText("Enter a purpose...");
metaPurpose.setValue(""); 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 = new TextField();
metaCredits.setAllowBlank(false); metaCredits.setAllowBlank(false);
metaCredits.setEmptyText("Enter credits..."); metaCredits.setEmptyText("Enter credits...");
metaCredits.setValue(""); 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 = new TextField();
metaKeywords.setAllowBlank(false); metaKeywords.setAllowBlank(false);
metaKeywords.setEmptyText("Enter keywords..."); metaKeywords.setEmptyText("Enter keywords...");
metaKeywords.setValue(""); 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); tableDetailPanel.add(form);
setContent(tableDetailPanel); setContent(tableDetailPanel);
@ -224,53 +213,45 @@ public class MapWidgetDetailCard extends WizardCard {
d.addHideHandler(hideHandler); d.addHideHandler(hideHandler);
d.show(); d.show();
} else { } else {
if (userName.getValue() == null || userName.getValue().isEmpty()
name.setReadOnly(true); || !userName.isValid()) {
goNext(); 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() { protected void goNext() {
try { try {
/*
detail= new TabResource(); mapCreationSession.setName(name.getCurrentValue());
detail.setName(name.getCurrentValue()); mapCreationSession.setUsername(userName.getCurrentValue());
detail.setDescription(description.getCurrentValue()); mapCreationSession.setMetaAbstract(metaAbstract.getCurrentValue());
detail.setRight(rights.getCurrentValue()); mapCreationSession.setMetaPurpose(metaPurpose.getCurrentValue());
mapCreationSession.setMetaCredits(metaCredits.getCurrentValue());
Date vFrom = validFrom.getCurrentValue(); ArrayList<String> keywordsList=new ArrayList<String>();
if (vFrom == null) { String keys=metaKeywords.getCurrentValue();
Log.debug("Valid From is null"); int separator=keys.indexOf(",");
} else { while(separator!=-1){
try { String keyNew=keys.substring(0, separator);
detail.setValidFrom(sdf.format(vFrom)); keywordsList.add(keyNew);
} catch (Throwable e) { keys=keys.substring(separator+1);
Log.error("Error parsing Valid From " separator=keys.indexOf(",");
+ 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());
}
} }
keywordsList.add(keys);
if(comboLicences.getCurrentValue()!=null&& mapCreationSession.setMetaKeywords(keywordsList);
comboLicences.getCurrentValue().getLicence()!=null && !comboLicences.getCurrentValue().getLicence().isEmpty()){
detail.setLicence(comboLicences.getCurrentValue().getLicence());
}
mapCreationSession.setTabResource(detail);
*/
MapWidgetOperationInProgressCard mapWidgetOperationInProgressCard = new MapWidgetOperationInProgressCard( MapWidgetOperationInProgressCard mapWidgetOperationInProgressCard = new MapWidgetOperationInProgressCard(
mapCreationSession); mapCreationSession);
getWizardWindow().addCard(mapWidgetOperationInProgressCard); 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; 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.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.TDGWTIsLockedException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; 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.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener; import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
@ -106,8 +105,8 @@ public class MapWidgetOperationInProgressCard extends WizardCard implements
showErrorAndHide("Error Locked", showErrorAndHide("Error Locked",
caught.getLocalizedMessage(), caught); caught.getLocalizedMessage(), caught);
} else { } else {
showErrorAndHide("Error in export", showErrorAndHide("Error",
"An error occured in export: " "An error occured in map creation: "
+ caught.getLocalizedMessage(), + caught.getLocalizedMessage(),
caught); 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.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; 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 { public class MapWidgetTD extends WizardWindow {
protected JSONExportSession exportSession; protected MapCreationSession mapCreationSession;
/** /**
* *
* @param title * @param title
* @param eventBus * @param eventBus
*/ */
public MapWidgetTD(String title, EventBus eventBus) { public MapWidgetTD(TRId trId, String userName, String title, EventBus eventBus) {
super(title,eventBus); super(title,eventBus);
exportSession= new JSONExportSession(); mapCreationSession= new MapCreationSession();
mapCreationSession.setTrId(trId);
MapWidgetConfigCard jsonExportConfigCard=new MapWidgetConfigCard(exportSession); mapCreationSession.setUsername(userName);
addCard(jsonExportConfigCard); retrieveColumns();
jsonExportConfigCard.setup();
} }
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; 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.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.EntryPoint;
import com.google.web.bindery.event.shared.SimpleEventBus; import com.google.web.bindery.event.shared.SimpleEventBus;
@ -8,8 +10,11 @@ public class MapWidgetTDEntry implements EntryPoint {
public void onModuleLoad() { public void onModuleLoad() {
TRId trId=new TRId("10","20");
String userName="test.user";
SimpleEventBus eventBus=new SimpleEventBus(); SimpleEventBus eventBus=new SimpleEventBus();
MapWidgetTD exportWizard= new MapWidgetTD("CSVExport",eventBus); MapWidgetTD mapCreationWizard= new MapWidgetTD(trId, userName,"Map Creation",eventBus);
Log.info(exportWizard.getId()); 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.ArrayList;
import java.util.List; 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.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import org.gcube.portlets.user.td.mapwidget.client.MapWidgetConfigCard;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT; 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.HasSelectionHandlers;
import com.google.gwt.event.logical.shared.SelectionHandler; import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.event.shared.HandlerRegistration; 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.IdentityValueProvider;
import com.sencha.gxt.core.client.Style.SelectionMode; import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode; import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins; 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.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.ContentPanel;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; 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.container.VerticalLayoutContainer.VerticalLayoutData;
@ -40,27 +26,27 @@ import com.sencha.gxt.widget.core.client.grid.Grid;
/** /**
* *
* @author giancarlo * @author giancarlo email: <a
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class ColumnDataGridPanel extends ContentPanel implements public class ColumnDataGridPanel extends ContentPanel implements
HasSelectionHandlers<ColumnData> { HasSelectionHandlers<ColumnData> {
//private static final String GRID_WIDTH ="524px"; // private static final String GRID_WIDTH ="524px";
private static final String GRID_HEIGHT = "320px"; private static final String GRID_HEIGHT = "320px";
protected static final ColumnDataProperties props = GWT protected static final ColumnDataProperties props = GWT
.create(ColumnDataProperties.class); .create(ColumnDataProperties.class);
protected final CheckBoxSelectionModel<ColumnData> sm; protected final CheckBoxSelectionModel<ColumnData> sm;
protected final Grid<ColumnData> grid; protected final Grid<ColumnData> grid;
private WizardCard parent; protected MapWidgetConfigCard parent;
/** /**
* *
* @param parent * @param parent
*/ */
public ColumnDataGridPanel(WizardCard parent) { public ColumnDataGridPanel(MapWidgetConfigCard parent) {
this.parent=parent; this.parent = parent;
Log.debug("ColumnDataGridPanel"); Log.debug("ColumnDataGridPanel");
setHeadingText("Columns"); setHeadingText("Columns");
@ -77,40 +63,13 @@ public class ColumnDataGridPanel extends ContentPanel implements
ColumnModel<ColumnData> cm = new ColumnModel<ColumnData>(l); ColumnModel<ColumnData> cm = new ColumnModel<ColumnData>(l);
ListStore<ColumnData> store = new ListStore<ColumnData>(props.id()); ListStore<ColumnData> store = new ListStore<ColumnData>(props.id());
store.addAll(parent.getMapCreationSession().getColumns());
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() { grid = new Grid<ColumnData>(store, cm);
sm.setSelectionMode(SelectionMode.SINGLE);
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.setSelectionModel(sm); grid.setSelectionModel(sm);
grid.setHeight(GRID_HEIGHT); grid.setHeight(GRID_HEIGHT);
//grid.setWidth(GRID_WIDTH); // grid.setWidth(GRID_WIDTH);
// grid.getView().setAutoExpandColumn(labelCol); // grid.getView().setAutoExpandColumn(labelCol);
grid.getView().setStripeRows(true); grid.getView().setStripeRows(true);
grid.getView().setColumnLines(true); grid.getView().setColumnLines(true);
@ -130,39 +89,8 @@ public class ColumnDataGridPanel extends ContentPanel implements
return grid; return grid;
} }
protected void loadData(ListLoadConfig loadConfig, public ColumnData getSelectedItem() {
final AsyncCallback<ListLoadResult<ColumnData>> callback) { return grid.getSelectionModel().getSelectedItem();
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 ArrayList<ColumnData> getSelectedItems() { 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);
}
}