Minor updated

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-export-widget@86423 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-12-02 13:05:05 +00:00
parent d26215288a
commit 347bb154b0
5 changed files with 99 additions and 25 deletions

View File

@ -1,5 +1,7 @@
package org.gcube.portlets.user.td.csvexportwidget.client;
import java.util.ArrayList;
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;
@ -21,7 +23,10 @@ import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
import com.sencha.gxt.core.client.util.Padding;
import com.sencha.gxt.core.client.util.ToggleGroup;
import com.sencha.gxt.data.shared.StringLabelProvider;
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.FieldLabel;
import com.sencha.gxt.widget.core.client.form.FormPanel;
import com.sencha.gxt.widget.core.client.form.Radio;
@ -40,7 +45,7 @@ public class CSVExportConfigCard extends WizardCard {
private static final String DEFAULT_DELIMETER = ",";
protected CSVExportSession exportSession;
protected SimpleComboBox<String> encodings;
protected TextField customDelimiterField;
protected Radio otherDelimiter;
@ -53,6 +58,7 @@ public class CSVExportConfigCard extends WizardCard {
public CSVExportConfigCard(final CSVExportSession exportSession) {
super("CSV configuration", "");
if (exportSession == null) {
Log.error("CSVExportSession is null");
}
@ -82,10 +88,10 @@ public class CSVExportConfigCard extends WizardCard {
@Override
public void onSelection(SelectionEvent<String> event) {
// updateGrid();
}
});
encodings.focus();
TDGWTServiceAsync.INSTANCE
@ -115,7 +121,6 @@ public class CSVExportConfigCard extends WizardCard {
"Error loading charset list", "", caught);
}
});
content.add(new FieldLabel(encodings, "File encoding"));
@ -188,15 +193,13 @@ public class CSVExportConfigCard extends WizardCard {
@Override
public void onSelection(SelectionEvent<ColumnData> event) {
exportSession.setColumns(csvColumnGridPanel
.getSelectedItems());
getWizardWindow().setEnableNextButton(true);
}
});
content.add(csvColumnGridPanel);
return panel;
}
@ -216,14 +219,65 @@ public class CSVExportConfigCard extends WizardCard {
@Override
public void setup() {
Log.debug("CSVExportConfigCard Setup");
Command sayNextCard = new Command() {
@Override
public void execute() {
Log.debug("CSVExportConfigCard Call sayNextCard");
checkData();
}
};
getWizardWindow().setNextButtonCommand(sayNextCard);
setEnableBackButton(false);
setEnableNextButton(false);
setEnableNextButton(true);
}
protected void checkData() {
getWizardWindow().setEnableNextButton(false);
getWizardWindow().setEnableBackButton(false);
AlertMessageBox d;
HideHandler hideHandler = new HideHandler() {
@Override
public void onHide(HideEvent event) {
getWizardWindow().setEnableNextButton(true);
getWizardWindow().setEnableBackButton(false);
}
};
ArrayList<ColumnData> columns = csvColumnGridPanel.getSelectedItems();
if (columns.size() == 0) {
d = new AlertMessageBox("Attention", "No columns selected");
d.addHideHandler(hideHandler);
d.setModal(false);
d.show();
} else {
exportSession.setColumns(columns);
exportSession.setEncoding(encodings.getCurrentValue());
exportSession.setSeparator(String.valueOf(getSelectedDelimiter()));
goNext();
}
}
protected void goNext() {
try {
DestinationSelectionCard destCard = new DestinationSelectionCard(
exportSession);
getWizardWindow().addCard(destCard);
getWizardWindow().nextCard();
} catch (Exception e) {
Log.error("sayNextCard :" + e.getLocalizedMessage());
}
}
@Override
public void dispose() {
// csvExportSession
// .setColumnToImportMask(csvSample.getImportColumnsMask());
}
}

View File

@ -27,11 +27,10 @@ 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);
csvExportConfigCard.setup();
}

View File

@ -114,7 +114,7 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
exportSession.setFileName(fileName.getCurrentValue());
getFileFromWorkspace();
} else {
d = new AlertMessageBox("Attention", "No folder selected");
d = new AlertMessageBox("AttecheckExportDatantion", "No folder selected");
d.addHideHandler(hideHandler);
d.setModal(false);
d.show();

View File

@ -28,13 +28,14 @@ import com.sencha.gxt.widget.core.client.form.Radio;
public class DestinationSelectionCard extends WizardCard {
protected final CSVExportSession exportSession;
protected DestinationSelectionCard thisCard;
final FileDestination fileDestination = FileDestination.INSTANCE;
final WorkspaceDestination workspaceDestination = WorkspaceDestination.INSTANCE;
public DestinationSelectionCard(final CSVExportSession exportSession) {
super("CSV destination selection", "");
thisCard=this;
this.exportSession = exportSession;
// Default
exportSession.setDestination(fileDestination);
@ -136,7 +137,25 @@ public class DestinationSelectionCard extends WizardCard {
};
getWizardWindow().setNextButtonCommand(sayNextCard);
Command sayPreviousCard = new Command() {
public void execute() {
try {
getWizardWindow().previousCard();
getWizardWindow().removeCard(thisCard);
Log.info("Remove DestinationSelectionCard");
} catch (Exception e) {
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
}
}
};
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
setEnableBackButton(true);
setEnableNextButton(true);
}
}

View File

@ -34,12 +34,14 @@ import com.sencha.gxt.widget.core.client.grid.Grid;
public class ColumnDataGridPanel extends ContentPanel implements
HasSelectionHandlers<ColumnData> {
private static final ColumnDataProperties props = GWT
protected static final ColumnDataProperties props = GWT
.create(ColumnDataProperties.class);
protected final CheckBoxSelectionModel<ColumnData> sm;
protected final Grid<ColumnData> grid;
public ColumnDataGridPanel() {
Log.debug("ColumnDataGridPanel");
setHeadingText("Columns");
//setHeaderVisible(false);
//new Resizable(this, Dir.E, Dir.SE, Dir.S);
@ -54,7 +56,7 @@ public class ColumnDataGridPanel extends ContentPanel implements
IdentityValueProvider<ColumnData> identity = new IdentityValueProvider<ColumnData>();
final CheckBoxSelectionModel<ColumnData> sm = new CheckBoxSelectionModel<ColumnData>(
sm = new CheckBoxSelectionModel<ColumnData>(
identity);
@ -79,7 +81,6 @@ public class ColumnDataGridPanel extends ContentPanel implements
loader.setRemoteSort(false);
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ColumnData, ListLoadResult<ColumnData>>(
store) {
});
grid = new Grid<ColumnData>(store, cm) {
@ -97,7 +98,6 @@ public class ColumnDataGridPanel extends ContentPanel implements
sm.setSelectionMode(SelectionMode.MULTI);
sm.selectAll();
grid.setLoader(loader);
grid.setSelectionModel(sm);
grid.getView().setAutoExpandColumn(labelCol);
@ -111,7 +111,7 @@ public class ColumnDataGridPanel extends ContentPanel implements
VerticalLayoutContainer con = new VerticalLayoutContainer();
con.add(grid, new VerticalLayoutData(-1, -1,new Margins(0)));
con.add(grid, new VerticalLayoutData(-1, -1));
setWidget(con);
}
@ -137,6 +137,8 @@ public class ColumnDataGridPanel extends ContentPanel implements
Log.trace("loaded " + result.size() + " columns");
callback.onSuccess(new ListLoadResultBean<ColumnData>(
result));
sm.selectAll();
}
});
}