Minor updated
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-export-widget@86372 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
261880be29
commit
4d84848cc6
|
@ -1,10 +1,10 @@
|
||||||
package org.gcube.portlets.user.td.csvexportwidget.client;
|
package org.gcube.portlets.user.td.csvexportwidget.client;
|
||||||
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.csvexportwidget.client.grid.ColumnDataGridPanel;
|
import org.gcube.portlets.user.td.csvexportwidget.client.grid.ColumnDataGridPanel;
|
||||||
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.AvailableCharsetList;
|
import org.gcube.portlets.user.td.gwtservice.shared.csv.AvailableCharsetList;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
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;
|
||||||
|
@ -39,7 +39,7 @@ import com.sencha.gxt.widget.core.client.tips.ToolTipConfig;
|
||||||
public class CSVExportConfigCard extends WizardCard {
|
public class CSVExportConfigCard extends WizardCard {
|
||||||
|
|
||||||
private static final String DEFAULT_DELIMETER = ",";
|
private static final String DEFAULT_DELIMETER = ",";
|
||||||
protected CSVExportSession csvExportSession;
|
protected CSVExportSession exportSession;
|
||||||
|
|
||||||
protected SimpleComboBox<String> encodings;
|
protected SimpleComboBox<String> encodings;
|
||||||
protected TextField customDelimiterField;
|
protected TextField customDelimiterField;
|
||||||
|
@ -48,15 +48,15 @@ public class CSVExportConfigCard extends WizardCard {
|
||||||
protected Radio spaceDelimiter;
|
protected Radio spaceDelimiter;
|
||||||
protected Radio tabDelimiter;
|
protected Radio tabDelimiter;
|
||||||
protected Radio semicoloDelimiter;
|
protected Radio semicoloDelimiter;
|
||||||
|
|
||||||
protected ColumnDataGridPanel csvColumnGridPanel;
|
protected ColumnDataGridPanel csvColumnGridPanel;
|
||||||
|
|
||||||
public CSVExportConfigCard(final CSVExportSession csvExportSession) {
|
public CSVExportConfigCard(final CSVExportSession exportSession) {
|
||||||
super("CSV configuration", "");
|
super("CSV configuration", "");
|
||||||
if (csvExportSession == null) {
|
if (exportSession == null) {
|
||||||
Log.error("CSVExportSession is null");
|
Log.error("CSVExportSession is null");
|
||||||
}
|
}
|
||||||
this.csvExportSession = csvExportSession;
|
this.exportSession = exportSession;
|
||||||
|
|
||||||
FormPanel panel = createPanel();
|
FormPanel panel = createPanel();
|
||||||
setContent(panel);
|
setContent(panel);
|
||||||
|
@ -82,14 +82,43 @@ public class CSVExportConfigCard extends WizardCard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelection(SelectionEvent<String> event) {
|
public void onSelection(SelectionEvent<String> event) {
|
||||||
//updateGrid();
|
// updateGrid();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
encodings.focus();
|
||||||
|
|
||||||
|
TDGWTServiceAsync.INSTANCE
|
||||||
|
.getAvailableCharset(new AsyncCallback<AvailableCharsetList>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(AvailableCharsetList result) {
|
||||||
|
GWT.log("CharsetInfo: "
|
||||||
|
+ result.getCharsetList().size()
|
||||||
|
+ " charset, default: "
|
||||||
|
+ result.getDefaultCharset());
|
||||||
|
|
||||||
|
for (String charset : result.getCharsetList())
|
||||||
|
encodings.add(charset);
|
||||||
|
|
||||||
|
encodings.setValue(result.getDefaultCharset());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
GWT.log("Error loading charset list", caught);
|
||||||
|
showErrorAndHide("Error loading charset list",
|
||||||
|
"Error loading charset list", "", caught);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
content.add(new FieldLabel(encodings, "File encoding"));
|
content.add(new FieldLabel(encodings, "File encoding"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
commaDelimiter = new Radio();
|
commaDelimiter = new Radio();
|
||||||
commaDelimiter.setBoxLabel("Comma");
|
commaDelimiter.setBoxLabel("Comma");
|
||||||
commaDelimiter.setValue(true);
|
commaDelimiter.setValue(true);
|
||||||
|
@ -152,14 +181,25 @@ public class CSVExportConfigCard extends WizardCard {
|
||||||
"The delimiter use to delimit the CSV fields"));
|
"The delimiter use to delimit the CSV fields"));
|
||||||
content.add(new FieldLabel(delimitersPanel, "Delimiter"));
|
content.add(new FieldLabel(delimitersPanel, "Delimiter"));
|
||||||
|
|
||||||
|
csvColumnGridPanel = new ColumnDataGridPanel();
|
||||||
csvColumnGridPanel=new ColumnDataGridPanel();
|
|
||||||
|
csvColumnGridPanel
|
||||||
|
.addSelectionHandler(new SelectionHandler<ColumnData>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelection(SelectionEvent<ColumnData> event) {
|
||||||
|
exportSession.setColumns(csvColumnGridPanel
|
||||||
|
.getSelectedItems());
|
||||||
|
getWizardWindow().setEnableNextButton(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
content.add(csvColumnGridPanel);
|
content.add(csvColumnGridPanel);
|
||||||
|
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected char getSelectedDelimiter() {
|
protected char getSelectedDelimiter() {
|
||||||
if (otherDelimiter.getValue())
|
if (otherDelimiter.getValue())
|
||||||
return customDelimiterField.getValue().charAt(0);
|
return customDelimiterField.getValue().charAt(0);
|
||||||
|
@ -176,66 +216,14 @@ public class CSVExportConfigCard extends WizardCard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
setEnableBackButton(true);
|
setEnableBackButton(false);
|
||||||
setEnableNextButton(false);
|
setEnableNextButton(false);
|
||||||
encodings.focus();
|
|
||||||
|
|
||||||
TDGWTServiceAsync.INSTANCE
|
|
||||||
.getAvailableCharset(new AsyncCallback<AvailableCharsetList>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(AvailableCharsetList result) {
|
|
||||||
GWT.log("CharsetInfo: "
|
|
||||||
+ result.getCharsetList().size()
|
|
||||||
+ " charset, default: "
|
|
||||||
+ result.getDefaultCharset());
|
|
||||||
|
|
||||||
for (String charset : result.getCharsetList())
|
|
||||||
encodings.add(charset);
|
|
||||||
|
|
||||||
encodings.setValue(result.getDefaultCharset());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
GWT.log("Error loading charset list", caught);
|
|
||||||
showErrorAndHide("Error loading charset list",
|
|
||||||
"Error loading charset list", "", caught);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Command sayNextCard = new Command() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute() {
|
|
||||||
//CSVTableDetailCard csvTableDetailCard = new CSVTableDetailCard(
|
|
||||||
// csvImportSession);
|
|
||||||
//getWizardWindow()
|
|
||||||
// .addCard(csvTableDetailCard);
|
|
||||||
Log.info("NextCard CSVTableDetailCard");
|
|
||||||
//getWizardWindow().nextCard();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
getWizardWindow().setNextButtonCommand(sayNextCard);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
//csvExportSession
|
// csvExportSession
|
||||||
// .setColumnToImportMask(csvSample.getImportColumnsMask());
|
// .setColumnToImportMask(csvSample.getImportColumnsMask());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@ public class CSVExportWizardTD extends WizardWindow {
|
||||||
exportSession= new CSVExportSession();
|
exportSession= new CSVExportSession();
|
||||||
|
|
||||||
CSVExportConfigCard csvExportConfigCard=new CSVExportConfigCard(exportSession);
|
CSVExportConfigCard csvExportConfigCard=new CSVExportConfigCard(exportSession);
|
||||||
|
csvExportConfigCard.setEnableBackButton(false);
|
||||||
|
csvExportConfigCard.setEnableNextButton(false);
|
||||||
addCard(csvExportConfigCard);
|
addCard(csvExportConfigCard);
|
||||||
DestinationSelectionCard destinationSelection= new DestinationSelectionCard(exportSession);
|
DestinationSelectionCard destinationSelection= new DestinationSelectionCard(exportSession);
|
||||||
addCard(destinationSelection);
|
addCard(destinationSelection);
|
||||||
|
|
|
@ -30,14 +30,15 @@ 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.ColumnModel;
|
||||||
import com.sencha.gxt.widget.core.client.grid.Grid;
|
import com.sencha.gxt.widget.core.client.grid.Grid;
|
||||||
|
|
||||||
public class ColumnDataGridPanel extends ContentPanel implements HasSelectionHandlers<ColumnData> {
|
public class ColumnDataGridPanel extends ContentPanel implements
|
||||||
|
HasSelectionHandlers<ColumnData> {
|
||||||
private static final ColumnDataProperties props = GWT
|
private static final ColumnDataProperties props = GWT
|
||||||
.create(ColumnDataProperties.class);
|
.create(ColumnDataProperties.class);
|
||||||
|
|
||||||
protected final Grid<ColumnData> grid;
|
protected final Grid<ColumnData> grid;
|
||||||
|
|
||||||
public ColumnDataGridPanel() {
|
public ColumnDataGridPanel() {
|
||||||
|
|
||||||
ColumnConfig<ColumnData, String> nameCol = new ColumnConfig<ColumnData, String>(
|
ColumnConfig<ColumnData, String> nameCol = new ColumnConfig<ColumnData, String>(
|
||||||
props.name());
|
props.name());
|
||||||
ColumnConfig<ColumnData, String> typeNameCol = new ColumnConfig<ColumnData, String>(
|
ColumnConfig<ColumnData, String> typeNameCol = new ColumnConfig<ColumnData, String>(
|
||||||
|
@ -45,37 +46,36 @@ public class ColumnDataGridPanel extends ContentPanel implements HasSelectionHan
|
||||||
ColumnConfig<ColumnData, String> typeCodeCol = new ColumnConfig<ColumnData, String>(
|
ColumnConfig<ColumnData, String> typeCodeCol = new ColumnConfig<ColumnData, String>(
|
||||||
props.typeCode());
|
props.typeCode());
|
||||||
|
|
||||||
|
|
||||||
List<ColumnConfig<ColumnData, ?>> l = new ArrayList<ColumnConfig<ColumnData, ?>>();
|
List<ColumnConfig<ColumnData, ?>> l = new ArrayList<ColumnConfig<ColumnData, ?>>();
|
||||||
l.add(nameCol);
|
l.add(nameCol);
|
||||||
l.add(typeNameCol);
|
l.add(typeNameCol);
|
||||||
l.add(typeCodeCol);
|
l.add(typeCodeCol);
|
||||||
ColumnModel<ColumnData> cm = new ColumnModel<ColumnData>(l);
|
ColumnModel<ColumnData> cm = new ColumnModel<ColumnData>(l);
|
||||||
|
|
||||||
IdentityValueProvider<ColumnData> identity = new IdentityValueProvider<ColumnData>();
|
|
||||||
|
|
||||||
|
|
||||||
final CheckBoxSelectionModel<ColumnData> sm = new CheckBoxSelectionModel<ColumnData>(identity);
|
|
||||||
|
|
||||||
|
|
||||||
ListStore<ColumnData> store = new ListStore<ColumnData>(
|
|
||||||
props.id());
|
|
||||||
|
|
||||||
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
|
|
||||||
|
|
||||||
public void load(ListLoadConfig loadConfig, final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
IdentityValueProvider<ColumnData> identity = new IdentityValueProvider<ColumnData>();
|
||||||
|
|
||||||
|
final CheckBoxSelectionModel<ColumnData> sm = new CheckBoxSelectionModel<ColumnData>(
|
||||||
|
identity);
|
||||||
|
|
||||||
|
ListStore<ColumnData> store = new ListStore<ColumnData>(props.id());
|
||||||
|
|
||||||
|
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
|
||||||
|
|
||||||
|
public void load(ListLoadConfig loadConfig,
|
||||||
|
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
||||||
loadData(loadConfig, callback);
|
loadData(loadConfig, callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
final ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader = new ListLoader<ListLoadConfig, ListLoadResult<ColumnData>>(proxy);
|
final ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader = new ListLoader<ListLoadConfig, ListLoadResult<ColumnData>>(
|
||||||
|
proxy);
|
||||||
|
|
||||||
loader.setRemoteSort(false);
|
loader.setRemoteSort(false);
|
||||||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig,ColumnData , ListLoadResult<ColumnData>>(store){
|
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ColumnData, ListLoadResult<ColumnData>>(
|
||||||
|
store) {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
grid = new Grid<ColumnData>(store, cm) {
|
||||||
grid = new Grid<ColumnData>(store, cm){
|
|
||||||
@Override
|
@Override
|
||||||
protected void onAfterFirstAttach() {
|
protected void onAfterFirstAttach() {
|
||||||
super.onAfterFirstAttach();
|
super.onAfterFirstAttach();
|
||||||
|
@ -87,52 +87,55 @@ public class ColumnDataGridPanel extends ContentPanel implements HasSelectionHan
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
grid.setLoader(loader);
|
grid.setLoader(loader);
|
||||||
grid.setSelectionModel(sm);
|
grid.setSelectionModel(sm);
|
||||||
grid.getView().setAutoExpandColumn(nameCol);
|
grid.getView().setAutoExpandColumn(nameCol);
|
||||||
grid.getView().setStripeRows(true);
|
grid.getView().setStripeRows(true);
|
||||||
grid.getView().setColumnLines(true);
|
grid.getView().setColumnLines(true);
|
||||||
grid.setBorders(false);
|
grid.setBorders(false);
|
||||||
|
|
||||||
VerticalLayoutContainer con = new VerticalLayoutContainer();
|
VerticalLayoutContainer con = new VerticalLayoutContainer();
|
||||||
con.add(grid, new VerticalLayoutData(1, 1));
|
con.add(grid, new VerticalLayoutData(1, 1));
|
||||||
setWidget(con);
|
setWidget(con);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Grid<ColumnData> getGrid() {
|
public Grid<ColumnData> getGrid() {
|
||||||
return grid;
|
return grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadData(ListLoadConfig loadConfig, final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
|
||||||
TDGWTServiceAsync.INSTANCE.getColumns(new AsyncCallback<ArrayList<ColumnData>>() {
|
|
||||||
|
|
||||||
@Override
|
protected void loadData(ListLoadConfig loadConfig,
|
||||||
public void onFailure(Throwable caught) {
|
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
||||||
Log.error("No load columns: "+caught.getLocalizedMessage());
|
TDGWTServiceAsync.INSTANCE
|
||||||
callback.onFailure(caught);
|
.getColumns(new AsyncCallback<ArrayList<ColumnData>>() {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(ArrayList<ColumnData> result) {
|
public void onFailure(Throwable caught) {
|
||||||
Log.trace("loaded "+result.size()+" columns");
|
Log.error("No load columns: "
|
||||||
callback.onSuccess(new ListLoadResultBean<ColumnData>(result));
|
+ caught.getLocalizedMessage());
|
||||||
}
|
callback.onFailure(caught);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(ArrayList<ColumnData> result) {
|
||||||
|
Log.trace("loaded " + result.size() + " columns");
|
||||||
|
callback.onSuccess(new ListLoadResultBean<ColumnData>(
|
||||||
|
result));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<ColumnData> getSelectedItems() {
|
||||||
public List<ColumnData> getSelectedItems() {
|
return new ArrayList<ColumnData>(grid
|
||||||
return grid.getSelectionModel().getSelectedItems();
|
.getSelectionModel().getSelectedItems());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerRegistration addSelectionHandler(SelectionHandler<ColumnData> handler) {
|
public HandlerRegistration addSelectionHandler(
|
||||||
|
SelectionHandler<ColumnData> handler) {
|
||||||
return grid.getSelectionModel().addSelectionHandler(handler);
|
return grid.getSelectionModel().addSelectionHandler(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue