Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-extractcodelist-widget@96150 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
73b0cd04fc
commit
81e2d1acad
8
pom.xml
8
pom.xml
|
@ -131,7 +131,13 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- tabular-data-column-widget -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>tabular-data-column-widget</artifactId>
|
||||
<version>[1.1.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- LOGGING -->
|
||||
<dependency>
|
||||
|
|
|
@ -73,11 +73,11 @@ public class SourceColumnsSelectionCard extends WizardCard {
|
|||
|
||||
@Override
|
||||
public void setup() {
|
||||
Log.debug("ColumnSourceSelectionCard Setup");
|
||||
Log.debug("SourceColumnsSelectionCard Setup");
|
||||
Command sayNextCard = new Command() {
|
||||
|
||||
public void execute() {
|
||||
Log.debug("ColumnSourceSelectionCard Call sayNextCard");
|
||||
Log.debug("SourceColumnsSelectionCard Call sayNextCard");
|
||||
checkData();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,21 +4,61 @@ import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistSessi
|
|||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.user.client.Command;
|
||||
|
||||
public class TargetColumnsSelectionCard extends WizardCard {
|
||||
|
||||
public class TargetColumnsSelectionCard extends WizardCard {
|
||||
private TargetColumnsSelectionCard thisCard;
|
||||
protected ExtractCodelistSession extractCodelistSession;
|
||||
|
||||
protected TargetColumnsSelectionPanel targetColumnsSelectionPanel;
|
||||
|
||||
public TargetColumnsSelectionCard(final ExtractCodelistSession extractCodelistSession) {
|
||||
super("Target Column", "");
|
||||
|
||||
thisCard=this;
|
||||
if (extractCodelistSession == null) {
|
||||
Log.error("ExtractCodelistSession is null");
|
||||
}
|
||||
this.extractCodelistSession = extractCodelistSession;
|
||||
|
||||
|
||||
targetColumnsSelectionPanel =new TargetColumnsSelectionPanel(this);
|
||||
setContent(targetColumnsSelectionPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
Log.debug("TargetColumnsSelectionCard Setup");
|
||||
Command sayNextCard = new Command() {
|
||||
|
||||
public void execute() {
|
||||
Log.debug("TargetColumnsSelectionCard Call sayNextCard");
|
||||
checkData();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||
|
||||
|
||||
Command sayPreviousCard = new Command() {
|
||||
public void execute() {
|
||||
try {
|
||||
getWizardWindow().previousCard();
|
||||
getWizardWindow().removeCard(thisCard);
|
||||
Log.info("Remove TargetColumnsSelectionCard");
|
||||
} catch (Exception e) {
|
||||
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||
|
||||
setEnableBackButton(true);
|
||||
setEnableNextButton(true);
|
||||
}
|
||||
|
||||
protected void checkData() {
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,372 @@
|
|||
package org.gcube.portlets.user.td.extractcodelistwidget.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.CodelistSelectionDialog;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.CodelistSelectionListener;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnDataPropertiesCombo;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.properties.ExtractCodelistDefColumnPropertiesCombo;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.utils.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistDefColumn;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistTargetColumn;
|
||||
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.type.SessionExpiredType;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
||||
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
||||
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.FramedPanel;
|
||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
||||
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.event.SelectEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class TargetColumnsSelectionPanel extends FramedPanel implements
|
||||
CodelistSelectionListener {
|
||||
|
||||
protected static final String WIDTH = "526px";
|
||||
protected static final String HEIGHT = "378px";
|
||||
protected static final String FIELDWIDTH = "526px";
|
||||
protected static final String FIELDSHEIGHT = "336px";
|
||||
protected static final int LABELSIZE = 128;
|
||||
protected static final int COMBOWIDTH = 300;
|
||||
|
||||
protected TargetColumnsSelectionCard parent;
|
||||
protected TabResource connection;
|
||||
protected ArrayList<ColumnData> connectionColumns;
|
||||
|
||||
protected ArrayList<ExtractCodelistTargetColumn> targetColumns;
|
||||
|
||||
private ToolBar toolBarHead;
|
||||
|
||||
private TextButton btnConnect;
|
||||
private TextButton btnDisconnect;
|
||||
private TextField connectionField;
|
||||
|
||||
private SimpleContainer form;
|
||||
private VerticalLayoutContainer formLayout;
|
||||
|
||||
public TargetColumnsSelectionPanel(TargetColumnsSelectionCard parent) {
|
||||
|
||||
this.parent = parent;
|
||||
connection = null;
|
||||
Log.debug("Create TargetColumnsSelectionPanel()");
|
||||
init();
|
||||
create();
|
||||
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setHeaderVisible(false);
|
||||
setBodyBorder(false);
|
||||
}
|
||||
|
||||
protected void create() {
|
||||
toolBarHead = new ToolBar();
|
||||
|
||||
// Connect Codelist
|
||||
btnConnect = new TextButton();
|
||||
btnConnect.setIcon(ResourceBundle.INSTANCE.codelistLink24());
|
||||
btnConnect.setIconAlign(IconAlign.TOP);
|
||||
btnConnect.setTitle("Connect Codelist");
|
||||
btnConnect.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Connect");
|
||||
btnConnect.disable();
|
||||
connectCodelist();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
toolBarHead.add(btnConnect);
|
||||
|
||||
// Disconnect Codelist
|
||||
btnDisconnect = new TextButton();
|
||||
btnDisconnect.setIcon(ResourceBundle.INSTANCE.codelistLinkBreak24());
|
||||
btnDisconnect.setIconAlign(IconAlign.TOP);
|
||||
btnDisconnect.setTitle("Disconnect Codelist");
|
||||
btnDisconnect.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Disconnect");
|
||||
btnDisconnect.disable();
|
||||
disconnectCodelist();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
toolBarHead.add(btnDisconnect);
|
||||
|
||||
connectionField = new TextField();
|
||||
toolBarHead.add(connectionField);
|
||||
|
||||
form = new SimpleContainer();
|
||||
form.setWidth(FIELDWIDTH);
|
||||
form.setHeight(FIELDSHEIGHT);
|
||||
|
||||
formLayout = new VerticalLayoutContainer();
|
||||
formLayout.setScrollMode(ScrollMode.AUTO);
|
||||
|
||||
ArrayList<FieldLabel> fields = generateFields();
|
||||
for (FieldLabel fl : fields) {
|
||||
formLayout.add(fl, new VerticalLayoutData(1, -1, new Margins(1)));
|
||||
|
||||
}
|
||||
|
||||
form.add(formLayout);
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
v.setHeight(HEIGHT);
|
||||
v.setWidth(WIDTH);
|
||||
v.add(toolBarHead, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||
v.add(form, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||
|
||||
add(v);
|
||||
|
||||
connectionField.setValue("");
|
||||
connectionField.setVisible(false);
|
||||
btnDisconnect.setVisible(false);
|
||||
btnConnect.setVisible(true);
|
||||
btnConnect.enable();
|
||||
|
||||
}
|
||||
|
||||
protected ArrayList<FieldLabel> generateFields() {
|
||||
ArrayList<FieldLabel> fields = new ArrayList<FieldLabel>();
|
||||
|
||||
for (ColumnData sourceCol : parent.extractCodelistSession
|
||||
.getSourceColumns()) {
|
||||
String label = new String();
|
||||
if (sourceCol != null && sourceCol.getLabel() != null) {
|
||||
label = SafeHtmlUtils.htmlEscape(sourceCol.getLabel());
|
||||
if (label.length() > LABELSIZE - 1) {
|
||||
label = label.substring(0, LABELSIZE - 3);
|
||||
label += "..";
|
||||
}
|
||||
}
|
||||
|
||||
if (connection == null) {
|
||||
FieldLabel fieldLabel = retrieveNewColumnLabel(sourceCol, label);
|
||||
fieldLabel.setLabelWidth(LABELSIZE);
|
||||
fieldLabel.setId(sourceCol.getColumnId());
|
||||
fields.add(fieldLabel);
|
||||
} else {
|
||||
FieldLabel fieldLabel = retrieveReferenceColumnLabel(sourceCol,
|
||||
label);
|
||||
fieldLabel.setLabelWidth(LABELSIZE);
|
||||
fieldLabel.setId(sourceCol.getColumnId());
|
||||
fields.add(fieldLabel);
|
||||
}
|
||||
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
protected FieldLabel retrieveNewColumnLabel(final ColumnData col,
|
||||
String label) {
|
||||
|
||||
// comboDefColumn
|
||||
ExtractCodelistDefColumnPropertiesCombo props = GWT
|
||||
.create(ExtractCodelistDefColumnPropertiesCombo.class);
|
||||
ListStore<ExtractCodelistDefColumn> storeComboDefColumn = new ListStore<ExtractCodelistDefColumn>(
|
||||
props.id());
|
||||
|
||||
|
||||
final ComboBox<ExtractCodelistDefColumn> comboDefColumn = new ComboBox<ExtractCodelistDefColumn>(
|
||||
storeComboDefColumn, props.label());
|
||||
|
||||
Log.debug("ComboDefColumn created");
|
||||
|
||||
comboDefColumn.setEmptyText("Select a Column...");
|
||||
comboDefColumn.setWidth(COMBOWIDTH);
|
||||
comboDefColumn.setEditable(false);
|
||||
comboDefColumn.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
FieldLabel columnLabel = new FieldLabel(comboDefColumn, label);
|
||||
columnLabel.setId(col.getColumnId());
|
||||
return columnLabel;
|
||||
}
|
||||
|
||||
protected FieldLabel retrieveReferenceColumnLabel(final ColumnData col,
|
||||
String label) {
|
||||
// comboColumn
|
||||
ColumnDataPropertiesCombo props = GWT
|
||||
.create(ColumnDataPropertiesCombo.class);
|
||||
ListStore<ColumnData> storeComboColumn = new ListStore<ColumnData>(
|
||||
props.id());
|
||||
storeComboColumn.addAll(connectionColumns);
|
||||
|
||||
final ComboBox<ColumnData> comboColumn = new ComboBox<ColumnData>(
|
||||
storeComboColumn, props.label());
|
||||
|
||||
Log.debug("ComboColumn created");
|
||||
|
||||
comboColumn.setEmptyText("Select a Column...");
|
||||
comboColumn.setWidth(COMBOWIDTH);
|
||||
comboColumn.setEditable(false);
|
||||
comboColumn.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
FieldLabel columnLabel = new FieldLabel(comboColumn, label);
|
||||
columnLabel.setId(col.getColumnId());
|
||||
return columnLabel;
|
||||
}
|
||||
|
||||
protected void disconnectCodelist() {
|
||||
Log.debug("Disconnect codelist");
|
||||
this.connection = null;
|
||||
connectionField.setValue("");
|
||||
connectionField.setVisible(false);
|
||||
btnDisconnect.setVisible(false);
|
||||
btnConnect.setVisible(true);
|
||||
btnConnect.enable();
|
||||
toolBarHead.forceLayout();
|
||||
updatedForm();
|
||||
|
||||
}
|
||||
|
||||
protected void connectCodelist() {
|
||||
CodelistSelectionDialog codelistSelectionDialog = new CodelistSelectionDialog(
|
||||
parent.getEventBus());
|
||||
codelistSelectionDialog.addListener(this);
|
||||
codelistSelectionDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selected(TabResource tabResource) {
|
||||
Log.debug("Selected connection: " + tabResource);
|
||||
this.connection = tabResource;
|
||||
retrieveColumnData();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void aborted() {
|
||||
Log.debug("Connection Aborted");
|
||||
btnConnect.enable();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(String reason, String detail) {
|
||||
Log.debug("Connection Failed: " + reason + " " + detail);
|
||||
UtilsGXT3.alert("Error on connect", reason);
|
||||
btnConnect.enable();
|
||||
|
||||
}
|
||||
|
||||
protected void retrieveColumnData() {
|
||||
TDGWTServiceAsync.INSTANCE.getColumnsForDimension(connection.getTrId(),
|
||||
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
parent.getEventBus()
|
||||
.fireEvent(
|
||||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.debug("Error retrieving columns: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error retrieving columns",
|
||||
"Error retrieving columns on server!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<ColumnData> result) {
|
||||
connectionColumns = result;
|
||||
enableConnection();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void enableConnection() {
|
||||
connectionField.setValue(connection.getName());
|
||||
connectionField.setVisible(true);
|
||||
btnDisconnect.setVisible(true);
|
||||
btnConnect.setVisible(false);
|
||||
btnConnect.enable();
|
||||
toolBarHead.forceLayout();
|
||||
updatedForm();
|
||||
|
||||
}
|
||||
|
||||
protected void updatedForm() {
|
||||
form.clear();
|
||||
formLayout = new VerticalLayoutContainer();
|
||||
formLayout.setScrollMode(ScrollMode.AUTO);
|
||||
|
||||
ArrayList<FieldLabel> fields = generateFields();
|
||||
for (FieldLabel fl : fields) {
|
||||
formLayout.add(fl, new VerticalLayoutData(1, -1, new Margins(1)));
|
||||
|
||||
}
|
||||
|
||||
form.add(formLayout);
|
||||
forceLayout();
|
||||
}
|
||||
|
||||
protected void updateExtractCodelistSession() {
|
||||
targetColumns = new ArrayList<ExtractCodelistTargetColumn>();
|
||||
|
||||
int i = 0;
|
||||
int lenght = formLayout.getWidgetCount();
|
||||
|
||||
for (; i < lenght; i++) {
|
||||
FieldLabel fieldLabel = (FieldLabel) formLayout.getWidget(i);
|
||||
String columnId = fieldLabel.getId();
|
||||
ColumnData colCurrent = null;
|
||||
for (ColumnData col : parent.extractCodelistSession
|
||||
.getSourceColumns()) {
|
||||
if (col.getColumnId().compareTo(columnId) == 0) {
|
||||
colCurrent = col;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (colCurrent == null) {
|
||||
UtilsGXT3.alert("Error creating form", "Error creating form!");
|
||||
return;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
ComboBox<ColumnData> comboColumn = (ComboBox<ColumnData>) fieldLabel
|
||||
.getWidget();
|
||||
ColumnData targetColumn = comboColumn.getValue();
|
||||
ExtractCodelistTargetColumn extractCodelistTargetColumn = new ExtractCodelistTargetColumn(
|
||||
colCurrent, targetColumn, connection.getTrId());
|
||||
targetColumns.add(extractCodelistTargetColumn);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -35,8 +35,11 @@ import com.sencha.gxt.widget.core.client.grid.Grid;
|
|||
|
||||
public class ColumnDataGridPanel extends ContentPanel implements
|
||||
HasSelectionHandlers<ColumnData> {
|
||||
protected static final int GRIDHEIGHT=360;
|
||||
|
||||
protected static final ColumnDataProperties props = GWT
|
||||
.create(ColumnDataProperties.class);
|
||||
|
||||
protected final CheckBoxSelectionModel<ColumnData> sm;
|
||||
|
||||
protected final Grid<ColumnData> grid;
|
||||
|
@ -95,7 +98,7 @@ public class ColumnDataGridPanel extends ContentPanel implements
|
|||
sm.setSelectionMode(SelectionMode.MULTI);
|
||||
grid.setLoader(loader);
|
||||
grid.setSelectionModel(sm);
|
||||
grid.setHeight(300);
|
||||
grid.setHeight(GRIDHEIGHT);
|
||||
//grid.getView().setAutoExpandColumn(labelCol);
|
||||
grid.getView().setStripeRows(true);
|
||||
grid.getView().setColumnLines(true);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
|
||||
<inherits name='org.gcube.portlets.user.td.gwtservice.TDGWTService' />
|
||||
<inherits name='org.gcube.portlets.user.td.wizardwidget.Wizard' />
|
||||
|
||||
<inherits name='org.gcube.portlets.user.td.columnwidget.ColumnWidget' />
|
||||
|
||||
<!-- Specify the app entry point class. -->
|
||||
<!-- <entry-point class='org.gcube.portlets.user.SDMXImportWizardTD.client.SDMXImportWizardTDEntry' /> -->
|
||||
|
|
Loading…
Reference in New Issue