Updated Normalize
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-table-widget@114685 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
01051f62ca
commit
7c6392a0a8
|
@ -54,6 +54,12 @@ 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.FieldLabel;
|
||||||
import com.sencha.gxt.widget.core.client.info.Info;
|
import com.sencha.gxt.widget.core.client.info.Info;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class DenormalizePanel extends FramedPanel implements
|
public class DenormalizePanel extends FramedPanel implements
|
||||||
MonitorDialogListener {
|
MonitorDialogListener {
|
||||||
protected String WIDTH = "640px";
|
protected String WIDTH = "640px";
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredTy
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.OperationResult;
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.OperationResult;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
@ -55,6 +56,12 @@ 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class NormalizePanel extends FramedPanel implements
|
public class NormalizePanel extends FramedPanel implements
|
||||||
MonitorDialogListener {
|
MonitorDialogListener {
|
||||||
protected String WIDTH = "640px";
|
protected String WIDTH = "640px";
|
||||||
|
@ -90,13 +97,46 @@ public class NormalizePanel extends FramedPanel implements
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void create() {
|
protected void create() {
|
||||||
|
Log.debug("Create NormalizationPanel(): [" + trId.toString() + "]");
|
||||||
|
|
||||||
setWidth(WIDTH);
|
setWidth(WIDTH);
|
||||||
setHeight(HEIGHT);
|
setHeight(HEIGHT);
|
||||||
setHeaderVisible(false);
|
setHeaderVisible(false);
|
||||||
setBodyBorder(false);
|
setBodyBorder(false);
|
||||||
Log.debug("Create NormalizationPanel(): [" + trId.toString() + "]");
|
|
||||||
|
|
||||||
|
// Normalize Button
|
||||||
|
normalizeButton = new TextButton("Normalize");
|
||||||
|
normalizeButton.setIcon(ResourceBundle.INSTANCE.tableNormalize());
|
||||||
|
normalizeButton.setIconAlign(IconAlign.RIGHT);
|
||||||
|
normalizeButton.setTitle("Normalize");
|
||||||
|
|
||||||
|
SelectHandler normalizeHandler = new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
onNormalize();
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
normalizeButton.addSelectHandler(normalizeHandler);
|
||||||
|
|
||||||
|
normalizedColumnName = new TextField();
|
||||||
|
FieldLabel normalizedColumnNameLabel = new FieldLabel(
|
||||||
|
normalizedColumnName, "Normalized column");
|
||||||
|
normalizedColumnNameLabel.setLabelWidth(110);
|
||||||
|
|
||||||
|
valueColumnName = new TextField();
|
||||||
|
FieldLabel valueColumnNameLabel = new FieldLabel(valueColumnName,
|
||||||
|
"Value column");
|
||||||
|
valueColumnNameLabel.setLabelWidth(110);
|
||||||
|
|
||||||
|
FieldLabel columnsLabel = new FieldLabel(null, "Columns to Normalize");
|
||||||
|
columnsLabel.setLabelWidth(150);
|
||||||
|
columnsLabel.getElement().applyStyles("font-weight:bold");
|
||||||
|
|
||||||
|
HBoxLayoutContainer hBox = new HBoxLayoutContainer();
|
||||||
|
hBox.add(normalizeButton, new BoxLayoutData(new Margins(2, 5, 2, 5)));
|
||||||
|
|
||||||
|
// Grid ColumnData
|
||||||
ColumnDataProperties props = GWT.create(ColumnDataProperties.class);
|
ColumnDataProperties props = GWT.create(ColumnDataProperties.class);
|
||||||
|
|
||||||
ColumnConfig<ColumnData, String> labelCol = new ColumnConfig<ColumnData, String>(
|
ColumnConfig<ColumnData, String> labelCol = new ColumnConfig<ColumnData, String>(
|
||||||
|
@ -153,38 +193,6 @@ public class NormalizePanel extends FramedPanel implements
|
||||||
grid.setColumnReordering(true);
|
grid.setColumnReordering(true);
|
||||||
grid.setColumnResize(false);
|
grid.setColumnResize(false);
|
||||||
|
|
||||||
// Normalize Button
|
|
||||||
normalizeButton = new TextButton("Normalize");
|
|
||||||
normalizeButton.setIcon(ResourceBundle.INSTANCE.tableNormalize());
|
|
||||||
normalizeButton.setIconAlign(IconAlign.RIGHT);
|
|
||||||
normalizeButton.setTitle("Normalize");
|
|
||||||
|
|
||||||
SelectHandler deleteHandler = new SelectHandler() {
|
|
||||||
|
|
||||||
public void onSelect(SelectEvent event) {
|
|
||||||
onNormalize();
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
normalizeButton.addSelectHandler(deleteHandler);
|
|
||||||
|
|
||||||
normalizedColumnName = new TextField();
|
|
||||||
FieldLabel normalizedColumnNameLabel = new FieldLabel(
|
|
||||||
normalizedColumnName, "Normalized column");
|
|
||||||
normalizedColumnNameLabel.setLabelWidth(110);
|
|
||||||
|
|
||||||
valueColumnName = new TextField();
|
|
||||||
FieldLabel valueColumnNameLabel = new FieldLabel(valueColumnName,
|
|
||||||
"Value column");
|
|
||||||
valueColumnNameLabel.setLabelWidth(110);
|
|
||||||
|
|
||||||
FieldLabel columnsLabel = new FieldLabel(null, "Columns to Normalize");
|
|
||||||
columnsLabel.setLabelWidth(150);
|
|
||||||
|
|
||||||
columnsLabel.getElement().applyStyles("font-weight:bold");
|
|
||||||
HBoxLayoutContainer hBox = new HBoxLayoutContainer();
|
|
||||||
hBox.add(normalizeButton, new BoxLayoutData(new Margins(2, 5, 2, 5)));
|
|
||||||
|
|
||||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||||
v.setScrollMode(ScrollMode.AUTOY);
|
v.setScrollMode(ScrollMode.AUTOY);
|
||||||
v.setAdjustForScroll(true);
|
v.setAdjustForScroll(true);
|
||||||
|
@ -230,13 +238,27 @@ public class NormalizePanel extends FramedPanel implements
|
||||||
"Error retrieving columns");
|
"Error retrieving columns");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
normalizeButton.disable();
|
||||||
callback.onFailure(caught);
|
callback.onFailure(caught);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSuccess(ArrayList<ColumnData> result) {
|
public void onSuccess(ArrayList<ColumnData> result) {
|
||||||
Log.trace("loaded " + result.size() + " ColumnData");
|
Log.trace("loaded " + result.size() + " ColumnData");
|
||||||
callback.onSuccess(new ListLoadResultBean<ColumnData>(
|
sanitizesColumns(result);
|
||||||
result));
|
if (result.size() > 0) {
|
||||||
|
callback.onSuccess(new ListLoadResultBean<ColumnData>(
|
||||||
|
result));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
normalizeButton.disable();
|
||||||
|
Log.error("This tabular resource has not Integer or Numeric columns, normalize is not applicable!");
|
||||||
|
UtilsGXT3
|
||||||
|
.alert("Attention",
|
||||||
|
"This tabular resource has not Integer or Numeric columns, normalize is not applicable!");
|
||||||
|
callback.onFailure(new Throwable(
|
||||||
|
"This tabular resource has not Integer or Numeric columns, normalize is not applicable!"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,6 +266,19 @@ public class NormalizePanel extends FramedPanel implements
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void sanitizesColumns(ArrayList<ColumnData> columns) {
|
||||||
|
ArrayList<ColumnData> removableColumn = new ArrayList<ColumnData>();
|
||||||
|
for (ColumnData c : columns) {
|
||||||
|
if (!(c.getDataTypeName().compareTo(
|
||||||
|
ColumnDataType.Integer.toString()) == 0 || c
|
||||||
|
.getDataTypeName().compareTo(
|
||||||
|
ColumnDataType.Numeric.toString()) == 0)) {
|
||||||
|
removableColumn.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
columns.removeAll(removableColumn);
|
||||||
|
}
|
||||||
|
|
||||||
protected void onNormalize() {
|
protected void onNormalize() {
|
||||||
ArrayList<ColumnData> col = getSelectedItems();
|
ArrayList<ColumnData> col = getSelectedItems();
|
||||||
if (col == null || col.size() < 1) {
|
if (col == null || col.size() < 1) {
|
||||||
|
@ -308,7 +343,8 @@ public class NormalizePanel extends FramedPanel implements
|
||||||
public void operationComplete(OperationResult operationResult) {
|
public void operationComplete(OperationResult operationResult) {
|
||||||
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
|
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
|
||||||
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
||||||
ChangeTableRequestType.NORMALIZE, operationResult.getTrId(), why);
|
ChangeTableRequestType.NORMALIZE, operationResult.getTrId(),
|
||||||
|
why);
|
||||||
eventBus.fireEvent(changeTableRequestEvent);
|
eventBus.fireEvent(changeTableRequestEvent);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
@ -321,10 +357,12 @@ public class NormalizePanel extends FramedPanel implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void operationStopped(OperationResult operationResult, String reason, String details) {
|
public void operationStopped(OperationResult operationResult,
|
||||||
|
String reason, String details) {
|
||||||
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
|
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
|
||||||
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
||||||
ChangeTableRequestType.NORMALIZE, operationResult.getTrId(), why);
|
ChangeTableRequestType.NORMALIZE, operationResult.getTrId(),
|
||||||
|
why);
|
||||||
eventBus.fireEvent(changeTableRequestEvent);
|
eventBus.fireEvent(changeTableRequestEvent);
|
||||||
close();
|
close();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue