Added Rows Delete By Expression
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@113682 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3f62196aba
commit
275bb0a540
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||
import org.gcube.portlets.user.td.expressionwidget.client.properties.ColumnDataPropertiesCombo;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ConditionTypeMapException;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.logical.C_Not;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.monitorwidget.client.utils.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ExpressionEvent;
|
||||
|
@ -46,7 +47,7 @@ import com.sencha.gxt.widget.core.client.form.TextField;
|
|||
*/
|
||||
public class ColumnExpressionPanel extends FramedPanel {
|
||||
private enum ColumnExpressionPanelType {
|
||||
MultiColumnFilter, ColumnFilter, Template;
|
||||
MultiColumnFilter, ColumnFilter, RowDeleteByExpression, Template;
|
||||
}
|
||||
|
||||
private static final String WIDTH_MULTI = "642px";
|
||||
|
@ -59,6 +60,7 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
|
||||
private ColumnExpressionDialog parentRuleDialog;
|
||||
private ColumnFilterDialog parentFilterDialog;
|
||||
private RowsDeleteByExpressionDialog parentRowsDeleteByExpressionDialog;
|
||||
private MultiColumnFilterTabPanel parentMultiColumnFilterTabPanel;
|
||||
|
||||
private ColumnData column;
|
||||
|
@ -84,7 +86,7 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
this.column = column;
|
||||
this.columns = null;
|
||||
this.eventBus = eventBus;
|
||||
Log.debug("Column:"+column);
|
||||
Log.debug("Column:" + column);
|
||||
|
||||
createOnMultiColumnFilter();
|
||||
}
|
||||
|
@ -99,9 +101,25 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
this.column = column;
|
||||
this.columns = columns;
|
||||
this.eventBus = eventBus;
|
||||
Log.debug("Column:"+column);
|
||||
Log.debug("Column:" + column);
|
||||
createOnFilter();
|
||||
}
|
||||
|
||||
public ColumnExpressionPanel(RowsDeleteByExpressionDialog parentRowsDeleteByExpressionDialog,
|
||||
ColumnData column, ArrayList<ColumnData> columns, EventBus eventBus) {
|
||||
super();
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
type = ColumnExpressionPanelType.RowDeleteByExpression;
|
||||
this.parentRowsDeleteByExpressionDialog = parentRowsDeleteByExpressionDialog;
|
||||
this.column = column;
|
||||
this.columns = columns;
|
||||
this.eventBus = eventBus;
|
||||
Log.debug("Column:" + column);
|
||||
createOnRowsDeleteByExpression();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -118,7 +136,7 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
this.column = column;
|
||||
this.columns = null;
|
||||
this.eventBus = eventBus;
|
||||
Log.debug("Column:"+column);
|
||||
Log.debug("Column:" + column);
|
||||
|
||||
createOnTemplate();
|
||||
}
|
||||
|
@ -272,8 +290,7 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
storeCols.addAll(columns);
|
||||
|
||||
Log.debug("StoreCol created");
|
||||
comboCols = new ComboBox<ColumnData>(
|
||||
storeCols, propsCols.label());
|
||||
comboCols = new ComboBox<ColumnData>(storeCols, propsCols.label());
|
||||
|
||||
Log.debug("Combo Threshold created");
|
||||
|
||||
|
@ -309,10 +326,9 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
|
||||
}
|
||||
});
|
||||
if(column==null){
|
||||
if (column == null) {
|
||||
btnApply.disable();
|
||||
}
|
||||
|
||||
|
||||
btnClose = new TextButton("Close");
|
||||
btnClose.setIcon(ExpressionResources.INSTANCE.close());
|
||||
|
@ -339,6 +355,107 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
|
||||
}
|
||||
|
||||
|
||||
protected void createOnRowsDeleteByExpression() {
|
||||
forceLayoutOnResize = true;
|
||||
|
||||
setBodyBorder(false);
|
||||
setHeaderVisible(false);
|
||||
|
||||
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
|
||||
basicLayout.setAdjustForScroll(true);
|
||||
|
||||
FieldSet properties = null;
|
||||
VerticalLayoutContainer propertiesLayout;
|
||||
|
||||
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
|
||||
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||
flowButton.setPack(BoxLayoutPack.CENTER);
|
||||
|
||||
properties = new FieldSet();
|
||||
properties.setHeadingText("Properties");
|
||||
properties.setCollapsible(false);
|
||||
|
||||
propertiesLayout = new VerticalLayoutContainer();
|
||||
properties.add(propertiesLayout);
|
||||
|
||||
// Combo Column
|
||||
ColumnDataPropertiesCombo propsCols = GWT
|
||||
.create(ColumnDataPropertiesCombo.class);
|
||||
Log.debug("Props: " + propsCols);
|
||||
final ListStore<ColumnData> storeCols = new ListStore<ColumnData>(
|
||||
propsCols.id());
|
||||
Log.debug("Store Col: " + storeCols);
|
||||
storeCols.addAll(columns);
|
||||
|
||||
Log.debug("StoreCol created");
|
||||
comboCols = new ComboBox<ColumnData>(storeCols, propsCols.label());
|
||||
|
||||
Log.debug("Combo Threshold created");
|
||||
|
||||
comboCols.addSelectionHandler(comboColsSelection());
|
||||
|
||||
comboCols.setEmptyText("Select a column...");
|
||||
comboCols.setEditable(false);
|
||||
comboCols.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
setSelectedColumn();
|
||||
|
||||
propertiesLayout.add(new FieldLabel(comboCols, "Column"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
|
||||
//
|
||||
conditionsField = new FieldSet();
|
||||
conditionsField.setHeadingText("Conditions");
|
||||
conditionsField.setCollapsible(false);
|
||||
|
||||
conditionWidget = new ConditionWidget(column);
|
||||
Log.debug("ConditionWidget" + conditionWidget);
|
||||
conditionsField.add(conditionWidget);
|
||||
|
||||
btnApply = new TextButton("Delete");
|
||||
btnApply.setIcon(ExpressionResources.INSTANCE.tableRowDeleteByExpression());
|
||||
btnApply.setIconAlign(IconAlign.RIGHT);
|
||||
btnApply.setTitle("Delete rows");
|
||||
btnApply.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Delete");
|
||||
applySeleceted();
|
||||
|
||||
}
|
||||
});
|
||||
if (column == null) {
|
||||
btnApply.disable();
|
||||
}
|
||||
|
||||
btnClose = new TextButton("Close");
|
||||
btnClose.setIcon(ExpressionResources.INSTANCE.close());
|
||||
btnClose.setIconAlign(IconAlign.RIGHT);
|
||||
btnClose.setTitle("Cancel filter");
|
||||
btnClose.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Close");
|
||||
close();
|
||||
}
|
||||
});
|
||||
flowButton.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
|
||||
basicLayout.add(properties, new VerticalLayoutData(1, -1,
|
||||
new Margins(1)));
|
||||
basicLayout.add(conditionsField, new VerticalLayoutData(1, -1,
|
||||
new Margins(1)));
|
||||
basicLayout.add(flowButton, new VerticalLayoutData(1, 36, new Margins(
|
||||
5, 2, 5, 2)));
|
||||
|
||||
add(basicLayout);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void setSelectedColumn() {
|
||||
if (column == null) {
|
||||
|
||||
|
@ -347,7 +464,7 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
.getColumnTypeCodeFromId(column.getTypeCode());
|
||||
HTML errorMessage;
|
||||
if (typeCode == null) {
|
||||
errorMessage = new HTML(
|
||||
errorMessage = new HTML(
|
||||
"This column has column data type null!");
|
||||
UtilsGXT3.alert("Error",
|
||||
"This column has column data type null!!");
|
||||
|
@ -391,11 +508,11 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
if (event.getSelectedItem() != null) {
|
||||
ColumnData col = event.getSelectedItem();
|
||||
Log.debug("Col selected:" + col.toString());
|
||||
column=col;
|
||||
column = col;
|
||||
btnApply.enable();
|
||||
conditionWidget.update(col);
|
||||
} else {
|
||||
column=null;
|
||||
column = null;
|
||||
btnApply.disable();
|
||||
conditionWidget.update(null);
|
||||
}
|
||||
|
@ -472,7 +589,7 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
}
|
||||
|
||||
protected void applySeleceted() {
|
||||
Log.debug("Apply: "+column);
|
||||
Log.debug("Apply: " + column);
|
||||
|
||||
C_Expression exp;
|
||||
try {
|
||||
|
@ -482,7 +599,7 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (type) {
|
||||
case Template:
|
||||
parentRuleDialog.setExpression(exp);
|
||||
|
@ -502,7 +619,12 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
eventBus.fireEvent(expressionEvent);
|
||||
break;
|
||||
case ColumnFilter:
|
||||
parentFilterDialog.applyFilter(column,exp);
|
||||
parentFilterDialog.applyFilter(column, exp);
|
||||
break;
|
||||
case RowDeleteByExpression:
|
||||
C_Expression notExp=new C_Not(exp);
|
||||
parentRowsDeleteByExpressionDialog.deleteRowsByExpression(column,notExp);
|
||||
|
||||
break;
|
||||
case MultiColumnFilter:
|
||||
parentMultiColumnFilterTabPanel.applyFilter(column, exp);
|
||||
|
@ -533,6 +655,9 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
case ColumnFilter:
|
||||
parentFilterDialog.close();
|
||||
break;
|
||||
case RowDeleteByExpression:
|
||||
parentRowsDeleteByExpressionDialog.close();
|
||||
break;
|
||||
case MultiColumnFilter:
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -0,0 +1,261 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
|
||||
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
|
||||
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
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.expression.C_Expression;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sencha.gxt.widget.core.client.Window;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class RowsDeleteByExpressionDialog extends Window implements MonitorDialogListener {
|
||||
private static final String WIDTH = "660px";
|
||||
private static final String HEIGHT = "400px";
|
||||
private ColumnExpressionPanel columnExpressionPanel;
|
||||
private C_Expression exp = null;
|
||||
private TRId trId;
|
||||
private ColumnData column = null;
|
||||
private String columnLocalId = null;
|
||||
private ArrayList<ColumnData> columns=null;
|
||||
private ArrayList<ColumnData> removableColumn=null;
|
||||
private EventBus eventBus;
|
||||
private FilterColumnSession filterColumnSession;
|
||||
|
||||
|
||||
|
||||
public RowsDeleteByExpressionDialog(TRId trId, String columnLocalId, EventBus eventBus) {
|
||||
initWindow();
|
||||
this.eventBus = eventBus;
|
||||
this.trId = trId;
|
||||
this.columnLocalId = columnLocalId;
|
||||
loadColumns();
|
||||
|
||||
}
|
||||
|
||||
protected void initWindow() {
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setBodyBorder(false);
|
||||
setResizable(false);
|
||||
setHeadingText("Delete Rows By Expression");
|
||||
setClosable(true);
|
||||
getHeader().setIcon(ExpressionResources.INSTANCE.tableRowDeleteByExpression());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void initTools() {
|
||||
super.initTools();
|
||||
|
||||
closeBtn.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void create() {
|
||||
columnExpressionPanel = new ColumnExpressionPanel(this, column,columns,
|
||||
eventBus);
|
||||
add(columnExpressionPanel);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public C_Expression getExpression() {
|
||||
return exp;
|
||||
}
|
||||
|
||||
protected void setExpression(C_Expression exp) {
|
||||
Log.debug("New Expression set:" + exp.toString());
|
||||
this.exp = exp;
|
||||
}
|
||||
|
||||
protected void deleteRowsByExpression(ColumnData column,C_Expression exp) {
|
||||
this.exp = exp;
|
||||
this.column= column;
|
||||
callDeleteRows();
|
||||
}
|
||||
|
||||
protected void loadColumns() {
|
||||
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsLockedException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
|
||||
} else {
|
||||
Log.error("Error retrieving column: "
|
||||
+ caught.getMessage());
|
||||
UtilsGXT3.alert("Error retrieving column",
|
||||
caught.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onSuccess(ArrayList<ColumnData> result) {
|
||||
Log.debug("Retrived column: " + result);
|
||||
columns = result;
|
||||
sanitizesColumns();
|
||||
create();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void sanitizesColumns() {
|
||||
removableColumn=new ArrayList<ColumnData>();
|
||||
for(ColumnData c:columns){
|
||||
if(c.getTypeCode().compareTo(ColumnTypeCode.DIMENSION.toString())==0||
|
||||
c.getTypeCode().compareTo(ColumnTypeCode.TIMEDIMENSION.toString())==0 ){
|
||||
removableColumn.add(c);
|
||||
} else {
|
||||
if(columnLocalId!=null && c.getColumnId().compareTo(columnLocalId)==0){
|
||||
column=c;
|
||||
}
|
||||
}
|
||||
}
|
||||
columns.removeAll(removableColumn);
|
||||
}
|
||||
|
||||
|
||||
protected void callDeleteRows() {
|
||||
filterColumnSession = new FilterColumnSession(column, exp);
|
||||
Log.debug(filterColumnSession.toString());
|
||||
|
||||
ExpressionServiceAsync.INSTANCE.startFilterColumn(filterColumnSession,
|
||||
new AsyncCallback<String>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(String taskId) {
|
||||
Log.debug("Submitted column filter");
|
||||
openMonitorDialog(taskId);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsLockedException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsFinalException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Final",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
Log.error("Error submitting the column filter: "
|
||||
+ caught.getLocalizedMessage());
|
||||
caught.printStackTrace();
|
||||
UtilsGXT3
|
||||
.alert("Error submitting the column filter",
|
||||
caught.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void close() {
|
||||
hide();
|
||||
}
|
||||
|
||||
// /
|
||||
protected void openMonitorDialog(String taskId) {
|
||||
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
|
||||
monitorDialog.addProgressDialogListener(this);
|
||||
monitorDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationComplete(OperationResult operationResult) {
|
||||
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
|
||||
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
||||
ChangeTableRequestType.COLUMNFILTER, operationResult.getTrId(), why);
|
||||
eventBus.fireEvent(changeTableRequestEvent);
|
||||
close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationFailed(Throwable caught, String reason, String details) {
|
||||
UtilsGXT3.alert(reason, details);
|
||||
close();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationStopped(OperationResult operationResult, String reason, String details) {
|
||||
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
|
||||
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
||||
ChangeTableRequestType.COLUMNFILTER, operationResult.getTrId(), why);
|
||||
eventBus.fireEvent(changeTableRequestEvent);
|
||||
close();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationAborted() {
|
||||
close();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationPutInBackground() {
|
||||
close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -51,5 +51,10 @@ public interface ExpressionResources extends ClientBundle {
|
|||
ImageResource columnReplaceByExpression();
|
||||
|
||||
|
||||
@Source("table-row-delete-byexpression_32.png")
|
||||
ImageResource tableRowDeleteByExpression32();
|
||||
|
||||
@Source("table-row-delete-byexpression.png")
|
||||
ImageResource tableRowDeleteByExpression();
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 849 B |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 849 B |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Loading…
Reference in New Issue