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;
|
||||
|
||||
|
||||
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.shared.csv.AvailableCharsetList;
|
||||
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 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 {
|
||||
|
||||
private static final String DEFAULT_DELIMETER = ",";
|
||||
protected CSVExportSession csvExportSession;
|
||||
protected CSVExportSession exportSession;
|
||||
|
||||
protected SimpleComboBox<String> encodings;
|
||||
protected TextField customDelimiterField;
|
||||
|
@ -48,15 +48,15 @@ public class CSVExportConfigCard extends WizardCard {
|
|||
protected Radio spaceDelimiter;
|
||||
protected Radio tabDelimiter;
|
||||
protected Radio semicoloDelimiter;
|
||||
|
||||
|
||||
protected ColumnDataGridPanel csvColumnGridPanel;
|
||||
|
||||
public CSVExportConfigCard(final CSVExportSession csvExportSession) {
|
||||
public CSVExportConfigCard(final CSVExportSession exportSession) {
|
||||
super("CSV configuration", "");
|
||||
if (csvExportSession == null) {
|
||||
if (exportSession == null) {
|
||||
Log.error("CSVExportSession is null");
|
||||
}
|
||||
this.csvExportSession = csvExportSession;
|
||||
this.exportSession = exportSession;
|
||||
|
||||
FormPanel panel = createPanel();
|
||||
setContent(panel);
|
||||
|
@ -82,14 +82,43 @@ public class CSVExportConfigCard extends WizardCard {
|
|||
|
||||
@Override
|
||||
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"));
|
||||
|
||||
|
||||
|
||||
commaDelimiter = new Radio();
|
||||
commaDelimiter.setBoxLabel("Comma");
|
||||
commaDelimiter.setValue(true);
|
||||
|
@ -152,14 +181,25 @@ public class CSVExportConfigCard extends WizardCard {
|
|||
"The delimiter use to delimit the CSV fields"));
|
||||
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);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
protected char getSelectedDelimiter() {
|
||||
if (otherDelimiter.getValue())
|
||||
return customDelimiterField.getValue().charAt(0);
|
||||
|
@ -176,66 +216,14 @@ public class CSVExportConfigCard extends WizardCard {
|
|||
|
||||
@Override
|
||||
public void setup() {
|
||||
setEnableBackButton(true);
|
||||
setEnableBackButton(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
|
||||
public void dispose() {
|
||||
//csvExportSession
|
||||
// .setColumnToImportMask(csvSample.getImportColumnsMask());
|
||||
// csvExportSession
|
||||
// .setColumnToImportMask(csvSample.getImportColumnsMask());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ public class CSVExportWizardTD extends WizardWindow {
|
|||
exportSession= new CSVExportSession();
|
||||
|
||||
CSVExportConfigCard csvExportConfigCard=new CSVExportConfigCard(exportSession);
|
||||
csvExportConfigCard.setEnableBackButton(false);
|
||||
csvExportConfigCard.setEnableNextButton(false);
|
||||
addCard(csvExportConfigCard);
|
||||
DestinationSelectionCard destinationSelection= new DestinationSelectionCard(exportSession);
|
||||
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.Grid;
|
||||
|
||||
public class ColumnDataGridPanel extends ContentPanel implements HasSelectionHandlers<ColumnData> {
|
||||
public class ColumnDataGridPanel extends ContentPanel implements
|
||||
HasSelectionHandlers<ColumnData> {
|
||||
private static final ColumnDataProperties props = GWT
|
||||
.create(ColumnDataProperties.class);
|
||||
|
||||
protected final Grid<ColumnData> grid;
|
||||
|
||||
public ColumnDataGridPanel() {
|
||||
|
||||
|
||||
ColumnConfig<ColumnData, String> nameCol = new ColumnConfig<ColumnData, String>(
|
||||
props.name());
|
||||
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>(
|
||||
props.typeCode());
|
||||
|
||||
|
||||
List<ColumnConfig<ColumnData, ?>> l = new ArrayList<ColumnConfig<ColumnData, ?>>();
|
||||
l.add(nameCol);
|
||||
l.add(typeNameCol);
|
||||
l.add(typeCodeCol);
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
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.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
|
||||
protected void onAfterFirstAttach() {
|
||||
super.onAfterFirstAttach();
|
||||
|
@ -87,52 +87,55 @@ public class ColumnDataGridPanel extends ContentPanel implements HasSelectionHan
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
grid.setLoader(loader);
|
||||
grid.setSelectionModel(sm);
|
||||
grid.getView().setAutoExpandColumn(nameCol);
|
||||
grid.getView().setStripeRows(true);
|
||||
grid.getView().setColumnLines(true);
|
||||
grid.setBorders(false);
|
||||
|
||||
|
||||
VerticalLayoutContainer con = new VerticalLayoutContainer();
|
||||
con.add(grid, new VerticalLayoutData(1, 1));
|
||||
setWidget(con);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Grid<ColumnData> getGrid() {
|
||||
return grid;
|
||||
}
|
||||
|
||||
protected void loadData(ListLoadConfig loadConfig, final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
||||
TDGWTServiceAsync.INSTANCE.getColumns(new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.error("No load columns: "+caught.getLocalizedMessage());
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
protected void loadData(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
||||
TDGWTServiceAsync.INSTANCE
|
||||
.getColumns(new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<ColumnData> result) {
|
||||
Log.trace("loaded "+result.size()+" columns");
|
||||
callback.onSuccess(new ListLoadResultBean<ColumnData>(result));
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.error("No load columns: "
|
||||
+ 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 List<ColumnData> getSelectedItems() {
|
||||
return grid.getSelectionModel().getSelectedItems();
|
||||
public ArrayList<ColumnData> getSelectedItems() {
|
||||
return new ArrayList<ColumnData>(grid
|
||||
.getSelectionModel().getSelectedItems());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HandlerRegistration addSelectionHandler(SelectionHandler<ColumnData> handler) {
|
||||
public HandlerRegistration addSelectionHandler(
|
||||
SelectionHandler<ColumnData> handler) {
|
||||
return grid.getSelectionModel().addSelectionHandler(handler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue