Updated Filter
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@113659 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7f5271c519
commit
5748639757
|
@ -1,5 +1,8 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.client;
|
||||
|
||||
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.gwtservice.shared.tr.ColumnData;
|
||||
|
@ -8,11 +11,18 @@ import org.gcube.portlets.user.td.widgetcommonevent.client.event.ExpressionEvent
|
|||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ExpressionType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_ExpressionContainer;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
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.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.BoxLayoutContainer.BoxLayoutData;
|
||||
|
@ -23,6 +33,7 @@ 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.FieldSet;
|
||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||
|
@ -38,11 +49,11 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
MultiColumnFilter, ColumnFilter, Template;
|
||||
}
|
||||
|
||||
private String WIDTH_MULTI = "642px";
|
||||
private String HEIGHT_MULTI = "290px";
|
||||
private String WIDTH = "648px";
|
||||
private String HEIGHT = "364px";
|
||||
|
||||
private static final String WIDTH_MULTI = "642px";
|
||||
private static final String HEIGHT_MULTI = "290px";
|
||||
private static final String WIDTH = "648px";
|
||||
private static final String HEIGHT = "364px";
|
||||
|
||||
private ColumnExpressionPanelType type;
|
||||
private EventBus eventBus;
|
||||
|
||||
|
@ -51,7 +62,8 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
private MultiColumnFilterTabPanel parentMultiColumnFilterTabPanel;
|
||||
|
||||
private ColumnData column;
|
||||
|
||||
private ArrayList<ColumnData> columns;
|
||||
|
||||
private TextButton btnApply;
|
||||
private TextButton btnSearch;
|
||||
private TextButton btnSave;
|
||||
|
@ -59,6 +71,7 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
|
||||
private FieldSet conditionsField;
|
||||
private ConditionWidget conditionWidget;
|
||||
private ComboBox<ColumnData> comboCols;
|
||||
|
||||
public ColumnExpressionPanel(
|
||||
MultiColumnFilterTabPanel parentMultiColumnFilterTabPanel,
|
||||
|
@ -69,30 +82,31 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
type = ColumnExpressionPanelType.MultiColumnFilter;
|
||||
this.parentMultiColumnFilterTabPanel = parentMultiColumnFilterTabPanel;
|
||||
this.column = column;
|
||||
this.columns = null;
|
||||
this.eventBus = eventBus;
|
||||
Log.debug(column.toString());
|
||||
|
||||
create();
|
||||
createOnMultiColumnFilter();
|
||||
}
|
||||
|
||||
public ColumnExpressionPanel(ColumnFilterDialog parentFilterDialog,
|
||||
ColumnData column, EventBus eventBus) {
|
||||
ColumnData column, ArrayList<ColumnData> columns, EventBus eventBus) {
|
||||
super();
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
type = ColumnExpressionPanelType.ColumnFilter;
|
||||
this.parentFilterDialog = parentFilterDialog;
|
||||
this.column = column;
|
||||
this.columns = columns;
|
||||
this.eventBus = eventBus;
|
||||
Log.debug(column.toString());
|
||||
|
||||
create();
|
||||
createOnFilter();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param trId
|
||||
* @param columnName
|
||||
* @param columnLocalId
|
||||
*/
|
||||
public ColumnExpressionPanel(ColumnExpressionDialog parent,
|
||||
ColumnData column, EventBus eventBus) {
|
||||
|
@ -102,22 +116,297 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
type = ColumnExpressionPanelType.Template;
|
||||
this.parentRuleDialog = parent;
|
||||
this.column = column;
|
||||
this.columns = null;
|
||||
this.eventBus = eventBus;
|
||||
Log.debug(column.toString());
|
||||
|
||||
create();
|
||||
createOnTemplate();
|
||||
}
|
||||
|
||||
protected void create() {
|
||||
//Important: fixed rendering of widgets
|
||||
protected void createOnTemplate() {
|
||||
// Important: fixed rendering of widgets
|
||||
forceLayoutOnResize = true;
|
||||
|
||||
|
||||
setBodyBorder(false);
|
||||
setHeaderVisible(false);
|
||||
|
||||
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
|
||||
basicLayout.setAdjustForScroll(true);
|
||||
//basicLayout.setScrollMode(ScrollMode.AUTO); Set In GXT 3.0.1
|
||||
// basicLayout.setScrollMode(ScrollMode.AUTO); Set In GXT 3.0.1
|
||||
|
||||
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);
|
||||
|
||||
TextField columnType = new TextField();
|
||||
columnType.setToolTip("The type of column");
|
||||
columnType.setReadOnly(true);
|
||||
columnType.setValue(column.getTypeCode());
|
||||
propertiesLayout.add(new FieldLabel(columnType, "Column Type"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
|
||||
TextField dataType = new TextField();
|
||||
dataType.setToolTip("The data type");
|
||||
dataType.setReadOnly(true);
|
||||
dataType.setValue(column.getDataTypeName());
|
||||
propertiesLayout.add(new FieldLabel(dataType, "Data Type"),
|
||||
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("Apply");
|
||||
btnApply.setIcon(ExpressionResources.INSTANCE.apply());
|
||||
btnApply.setIconAlign(IconAlign.RIGHT);
|
||||
btnApply.setTitle("Apply rule");
|
||||
btnApply.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Apply");
|
||||
applyRule();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
btnSearch = new TextButton("Search");
|
||||
btnSearch.setIcon(ExpressionResources.INSTANCE.search());
|
||||
btnSearch.setIconAlign(IconAlign.RIGHT);
|
||||
btnSearch.setTitle("Search rule");
|
||||
btnSearch.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Search");
|
||||
searchRule();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
btnSave = new TextButton("Save");
|
||||
btnSave.setIcon(ExpressionResources.INSTANCE.save());
|
||||
btnSave.setIconAlign(IconAlign.RIGHT);
|
||||
btnSave.setTitle("Save rule");
|
||||
btnSave.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Save");
|
||||
saveRule();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
btnClose = new TextButton("Close");
|
||||
btnClose.setIcon(ExpressionResources.INSTANCE.close());
|
||||
btnClose.setIconAlign(IconAlign.RIGHT);
|
||||
btnClose.setTitle("Cancel rule");
|
||||
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(btnSave, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
/*
|
||||
* flowButton.add(btnSearch, 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 createOnFilter() {
|
||||
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("Apply");
|
||||
btnApply.setIcon(ExpressionResources.INSTANCE.applyFilter());
|
||||
btnApply.setIconAlign(IconAlign.RIGHT);
|
||||
btnApply.setTitle("Apply Filter");
|
||||
btnApply.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Apply");
|
||||
applyRule();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
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) {
|
||||
|
||||
} else {
|
||||
ColumnTypeCode typeCode = ColumnTypeCode
|
||||
.getColumnTypeCodeFromId(column.getTypeCode());
|
||||
HTML errorMessage;
|
||||
if (typeCode == null) {
|
||||
errorMessage = new HTML(
|
||||
"This column has column data type null!");
|
||||
UtilsGXT3.alert("Error",
|
||||
"This column has column data type null!!");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (typeCode) {
|
||||
case ANNOTATION:
|
||||
case ATTRIBUTE:
|
||||
case CODE:
|
||||
case CODEDESCRIPTION:
|
||||
case CODENAME:
|
||||
case MEASURE:
|
||||
comboCols.setValue(column);
|
||||
break;
|
||||
case DIMENSION:
|
||||
case TIMEDIMENSION:
|
||||
errorMessage = new HTML(
|
||||
"This type of column is not supported for now!");
|
||||
add(errorMessage);
|
||||
UtilsGXT3.alert("Error",
|
||||
"This type of column is not supported for now!");
|
||||
break;
|
||||
default:
|
||||
errorMessage = new HTML(
|
||||
"This type of column is not supported for now!");
|
||||
add(errorMessage);
|
||||
UtilsGXT3.alert("Error",
|
||||
"This type of column is not supported for now!");
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected SelectionHandler<ColumnData> comboColsSelection() {
|
||||
SelectionHandler<ColumnData> selectionHandler = new SelectionHandler<ColumnData>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<ColumnData> event) {
|
||||
if (event.getSelectedItem() != null) {
|
||||
ColumnData col = event.getSelectedItem();
|
||||
Log.debug("Col selected:" + col.toString());
|
||||
conditionWidget.update(col);
|
||||
} else {
|
||||
conditionWidget.update(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return selectionHandler;
|
||||
}
|
||||
|
||||
protected void createOnMultiColumnFilter() {
|
||||
// Important: fixed rendering of widgets
|
||||
forceLayoutOnResize = true;
|
||||
|
||||
setBodyBorder(false);
|
||||
setHeaderVisible(false);
|
||||
|
||||
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
|
||||
basicLayout.setAdjustForScroll(true);
|
||||
// basicLayout.setScrollMode(ScrollMode.AUTO); Set In GXT 3.0.1
|
||||
|
||||
FieldSet properties = null;
|
||||
VerticalLayoutContainer propertiesLayout;
|
||||
|
@ -127,199 +416,51 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||
flowButton.setPack(BoxLayoutPack.CENTER);
|
||||
|
||||
switch (type) {
|
||||
case Template:
|
||||
properties = new FieldSet();
|
||||
properties.setHeadingText("Properties");
|
||||
properties.setCollapsible(false);
|
||||
properties = new FieldSet();
|
||||
properties.setHeadingText("Properties");
|
||||
properties.setCollapsible(false);
|
||||
|
||||
propertiesLayout = new VerticalLayoutContainer();
|
||||
properties.add(propertiesLayout);
|
||||
propertiesLayout = new VerticalLayoutContainer();
|
||||
properties.add(propertiesLayout);
|
||||
|
||||
TextField columnType = new TextField();
|
||||
columnType.setToolTip("The type of column");
|
||||
columnType.setReadOnly(true);
|
||||
columnType.setValue(column.getTypeCode());
|
||||
propertiesLayout.add(new FieldLabel(columnType, "Column Type"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
columnName = new TextField();
|
||||
columnName.setToolTip("Column");
|
||||
columnName.setReadOnly(true);
|
||||
columnName.setValue(column.getLabel());
|
||||
propertiesLayout.add(new FieldLabel(columnName, "Column"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
|
||||
TextField dataType = new TextField();
|
||||
dataType.setToolTip("The data type");
|
||||
dataType.setReadOnly(true);
|
||||
dataType.setValue(column.getDataTypeName());
|
||||
propertiesLayout.add(new FieldLabel(dataType, "Data Type"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
conditionsField = new FieldSet();
|
||||
conditionsField.setHeadingText("Conditions");
|
||||
conditionsField.setCollapsible(false);
|
||||
|
||||
conditionsField = new FieldSet();
|
||||
conditionsField.setHeadingText("Conditions");
|
||||
conditionsField.setCollapsible(false);
|
||||
conditionWidget = new ConditionWidget(column, "612px", "110px");
|
||||
Log.debug("ConditionWidget" + conditionWidget);
|
||||
conditionsField.add(conditionWidget);
|
||||
|
||||
conditionWidget = new ConditionWidget(column);
|
||||
Log.debug("ConditionWidget" + conditionWidget);
|
||||
conditionsField.add(conditionWidget);
|
||||
|
||||
btnApply = new TextButton("Apply");
|
||||
btnApply.setIcon(ExpressionResources.INSTANCE.apply());
|
||||
btnApply.setIconAlign(IconAlign.RIGHT);
|
||||
btnApply.setTitle("Apply rule");
|
||||
btnApply.addSelectHandler(new SelectHandler() {
|
||||
btnApply = new TextButton("Add");
|
||||
btnApply.setIcon(ExpressionResources.INSTANCE.applyFilter());
|
||||
btnApply.setIconAlign(IconAlign.RIGHT);
|
||||
btnApply.setTitle("Add Filter");
|
||||
btnApply.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Apply");
|
||||
applyRule();
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Add Filter");
|
||||
applyRule();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
btnSearch = new TextButton("Search");
|
||||
btnSearch.setIcon(ExpressionResources.INSTANCE.search());
|
||||
btnSearch.setIconAlign(IconAlign.RIGHT);
|
||||
btnSearch.setTitle("Search rule");
|
||||
btnSearch.addSelectHandler(new SelectHandler() {
|
||||
flowButton.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Search");
|
||||
searchRule();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
btnSave = new TextButton("Save");
|
||||
btnSave.setIcon(ExpressionResources.INSTANCE.save());
|
||||
btnSave.setIconAlign(IconAlign.RIGHT);
|
||||
btnSave.setTitle("Save rule");
|
||||
btnSave.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Save");
|
||||
saveRule();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
btnClose = new TextButton("Close");
|
||||
btnClose.setIcon(ExpressionResources.INSTANCE.close());
|
||||
btnClose.setIconAlign(IconAlign.RIGHT);
|
||||
btnClose.setTitle("Cancel rule");
|
||||
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(btnSave, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
/*flowButton.add(btnSearch,
|
||||
new BoxLayoutData(new Margins(2, 4, 2, 4)));*/
|
||||
flowButton
|
||||
.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
break;
|
||||
case ColumnFilter:
|
||||
properties = new FieldSet();
|
||||
properties.setHeadingText("Properties");
|
||||
properties.setCollapsible(false);
|
||||
|
||||
propertiesLayout = new VerticalLayoutContainer();
|
||||
properties.add(propertiesLayout);
|
||||
|
||||
columnName = new TextField();
|
||||
columnName.setToolTip("Column");
|
||||
columnName.setReadOnly(true);
|
||||
columnName.setValue(column.getLabel());
|
||||
propertiesLayout.add(new FieldLabel(columnName, "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("Apply");
|
||||
btnApply.setIcon(ExpressionResources.INSTANCE.applyFilter());
|
||||
btnApply.setIconAlign(IconAlign.RIGHT);
|
||||
btnApply.setTitle("Apply Filter");
|
||||
btnApply.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Apply");
|
||||
applyRule();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
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)));
|
||||
|
||||
break;
|
||||
case MultiColumnFilter:
|
||||
properties = new FieldSet();
|
||||
properties.setHeadingText("Properties");
|
||||
properties.setCollapsible(false);
|
||||
|
||||
propertiesLayout = new VerticalLayoutContainer();
|
||||
properties.add(propertiesLayout);
|
||||
|
||||
columnName = new TextField();
|
||||
columnName.setToolTip("Column");
|
||||
columnName.setReadOnly(true);
|
||||
columnName.setValue(column.getLabel());
|
||||
propertiesLayout.add(new FieldLabel(columnName, "Column"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
|
||||
conditionsField = new FieldSet();
|
||||
conditionsField.setHeadingText("Conditions");
|
||||
conditionsField.setCollapsible(false);
|
||||
|
||||
conditionWidget = new ConditionWidget(column,"612px", "110px");
|
||||
Log.debug("ConditionWidget" + conditionWidget);
|
||||
conditionsField.add(conditionWidget);
|
||||
|
||||
btnApply = new TextButton("Add");
|
||||
btnApply.setIcon(ExpressionResources.INSTANCE.applyFilter());
|
||||
btnApply.setIconAlign(IconAlign.RIGHT);
|
||||
btnApply.setTitle("Add Filter");
|
||||
btnApply.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Add Filter");
|
||||
applyRule();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
flowButton
|
||||
.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
basicLayout.add(properties, new VerticalLayoutData(1, -1, new Margins(
|
||||
1)));
|
||||
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 applyRule() {
|
||||
|
@ -331,7 +472,7 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (type) {
|
||||
case Template:
|
||||
parentRuleDialog.setExpression(exp);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
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;
|
||||
|
@ -19,12 +21,10 @@ 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.TRId;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
|
||||
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.gwt.user.client.ui.HTML;
|
||||
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;
|
||||
|
@ -37,34 +37,26 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
|||
*
|
||||
*/
|
||||
public class ColumnFilterDialog extends Window implements MonitorDialogListener {
|
||||
protected String WIDTH = "660px";
|
||||
protected String HEIGHT = "400px";
|
||||
protected ColumnExpressionPanel columnExpressionPanel;
|
||||
protected C_Expression exp = null;
|
||||
protected ColumnData column = null;
|
||||
protected TRId trId;
|
||||
protected String columnName = null;
|
||||
protected EventBus eventBus;
|
||||
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 ColumnFilterDialog(String columnId, ColumnTypeCode columnTypeCode,
|
||||
ColumnDataType dataTypeName, EventBus eventBus) {
|
||||
initWindow();
|
||||
this.eventBus = eventBus;
|
||||
column = new ColumnData();
|
||||
column.setColumnId(columnId);
|
||||
column.setDataTypeName(dataTypeName.toString());
|
||||
column.setTypeCode(columnTypeCode.toString());
|
||||
create();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ColumnFilterDialog(TRId trId, String columnName, EventBus eventBus) {
|
||||
public ColumnFilterDialog(TRId trId, String columnLocalId, EventBus eventBus) {
|
||||
initWindow();
|
||||
this.eventBus = eventBus;
|
||||
this.trId = trId;
|
||||
this.columnName = columnName;
|
||||
load(trId, columnName);
|
||||
this.columnLocalId = columnLocalId;
|
||||
loadColumns();
|
||||
|
||||
}
|
||||
|
||||
|
@ -96,30 +88,16 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
|
|||
}
|
||||
|
||||
protected void create() {
|
||||
if (column.getTypeCode()
|
||||
.compareTo(ColumnTypeCode.ANNOTATION.toString()) == 0
|
||||
|| column.getTypeCode().compareTo(
|
||||
ColumnTypeCode.ATTRIBUTE.toString()) == 0
|
||||
|| column.getTypeCode().compareTo(
|
||||
ColumnTypeCode.CODE.toString()) == 0
|
||||
|| column.getTypeCode().compareTo(
|
||||
ColumnTypeCode.CODEDESCRIPTION.toString()) == 0
|
||||
|| column.getTypeCode().compareTo(
|
||||
ColumnTypeCode.CODENAME.toString()) == 0
|
||||
|| column.getTypeCode().compareTo(
|
||||
ColumnTypeCode.MEASURE.toString()) == 0) {
|
||||
columnExpressionPanel = new ColumnExpressionPanel(this, column,
|
||||
eventBus);
|
||||
add(columnExpressionPanel);
|
||||
|
||||
} else {
|
||||
HTML errorMessage = new HTML(
|
||||
"This type of column is not supported for now!");
|
||||
add(errorMessage);
|
||||
UtilsGXT3.alert("Error",
|
||||
"This type of column is not supported for now!");
|
||||
}
|
||||
columnExpressionPanel = new ColumnExpressionPanel(this, column,columns,
|
||||
eventBus);
|
||||
add(columnExpressionPanel);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public C_Expression getExpression() {
|
||||
return exp;
|
||||
|
@ -135,9 +113,9 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
|
|||
callApplyFilter();
|
||||
}
|
||||
|
||||
protected void load(TRId trId, String columnName) {
|
||||
TDGWTServiceAsync.INSTANCE.getColumn(trId, columnName,
|
||||
new AsyncCallback<ColumnData>() {
|
||||
protected void loadColumns() {
|
||||
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
|
@ -158,17 +136,22 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
|
|||
}
|
||||
}
|
||||
|
||||
public void onSuccess(ColumnData result) {
|
||||
public void onSuccess(ArrayList<ColumnData> result) {
|
||||
Log.debug("Retrived column: " + result);
|
||||
if (result.isViewColumn()) {
|
||||
UtilsGXT3
|
||||
.info("View Column",
|
||||
"You can not make expressions on view column for now");
|
||||
hide();
|
||||
} else {
|
||||
column = result;
|
||||
create();
|
||||
columns = result;
|
||||
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(c.getColumnId().compareTo(columnLocalId)==0){
|
||||
column=c;
|
||||
}
|
||||
}
|
||||
}
|
||||
columns.removeAll(removableColumn);
|
||||
create();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -82,6 +82,16 @@ public class ConditionWidget extends SimpleContainer {
|
|||
super();
|
||||
create(column, width, height);
|
||||
}
|
||||
|
||||
public void update(ColumnData newColumn){
|
||||
int count=vert.getWidgetCount();
|
||||
for(int i=0; i<count;i++){
|
||||
vert.remove(i);
|
||||
}
|
||||
this.column=newColumn;
|
||||
setup();
|
||||
}
|
||||
|
||||
|
||||
protected void create(ColumnData column, String width, String height) {
|
||||
this.column = column;
|
||||
|
|
Loading…
Reference in New Issue