You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
179 lines
4.9 KiB
Java
179 lines
4.9 KiB
Java
package org.gcube.portlets.user.td.jsonexportwidget.client;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
|
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
|
import org.gcube.portlets.user.td.jsonexportwidget.client.grid.ColumnDataGridPanel;
|
|
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.google.gwt.user.client.ui.HorizontalPanel;
|
|
import com.sencha.gxt.core.client.util.Padding;
|
|
import com.sencha.gxt.core.client.util.ToggleGroup;
|
|
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;
|
|
import com.sencha.gxt.widget.core.client.tips.ToolTip;
|
|
import com.sencha.gxt.widget.core.client.tips.ToolTipConfig;
|
|
|
|
/**
|
|
*
|
|
* @author "Giancarlo Panichi" <a
|
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
*
|
|
*/
|
|
public class JSONExportConfigCard extends WizardCard {
|
|
|
|
private static final int LABEL_WIDTH = 128;
|
|
private static final int LABEL_PAD_WIDTH = 2;
|
|
|
|
protected JSONExportSession exportSession;
|
|
|
|
|
|
|
|
private Radio viewColumnExportTrue;
|
|
private Radio viewColumnExportFalse;
|
|
|
|
protected ColumnDataGridPanel jsonColumnGridPanel;
|
|
|
|
public JSONExportConfigCard(final JSONExportSession exportSession) {
|
|
super("JSON configuration", "");
|
|
|
|
if (exportSession == null) {
|
|
Log.error("JSONExportSession is null");
|
|
}
|
|
this.exportSession = exportSession;
|
|
|
|
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);
|
|
|
|
// Export View Column
|
|
viewColumnExportTrue = new Radio();
|
|
viewColumnExportTrue.setBoxLabel("True");
|
|
viewColumnExportTrue.setValue(true);
|
|
|
|
viewColumnExportFalse = new Radio();
|
|
viewColumnExportFalse.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");
|
|
fieldViewColumns.setLabelWidth(LABEL_WIDTH);
|
|
fieldViewColumns.setLabelPad(LABEL_PAD_WIDTH);
|
|
content.add(fieldViewColumns);
|
|
|
|
// Column Selection Grid
|
|
jsonColumnGridPanel = new ColumnDataGridPanel(this);
|
|
|
|
jsonColumnGridPanel
|
|
.addSelectionHandler(new SelectionHandler<ColumnData>() {
|
|
|
|
public void onSelection(SelectionEvent<ColumnData> event) {
|
|
|
|
}
|
|
|
|
});
|
|
|
|
content.add(jsonColumnGridPanel);
|
|
|
|
return panel;
|
|
}
|
|
|
|
|
|
|
|
protected boolean getExportViewColumns() {
|
|
if(viewColumnExportTrue.getValue()){
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void setup() {
|
|
Log.debug("JSONExportConfigCard Setup");
|
|
Command sayNextCard = new Command() {
|
|
|
|
public void execute() {
|
|
Log.debug("JSONExportConfigCard 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);
|
|
|
|
}
|
|
};
|
|
|
|
ArrayList<ColumnData> columns = jsonColumnGridPanel.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.setExportViewColumns(getExportViewColumns());
|
|
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() {
|
|
|
|
}
|
|
|
|
}
|