Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@91781 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
93a6c7c1bb
commit
dbcd0f235e
|
@ -117,6 +117,7 @@ public class ColumnExpressionDialog extends Window {
|
||||||
@Override
|
@Override
|
||||||
public void hide() {
|
public void hide() {
|
||||||
ExpressionEvent expressionEvent= new ExpressionEvent(ExpressionType.EXPRESSIONNULL);
|
ExpressionEvent expressionEvent= new ExpressionEvent(ExpressionType.EXPRESSIONNULL);
|
||||||
|
Log.debug(expressionEvent.toString());
|
||||||
eventBus.fireEvent(expressionEvent);
|
eventBus.fireEvent(expressionEvent);
|
||||||
hide(null);
|
hide(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,8 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
this.parent=parent;
|
this.parent=parent;
|
||||||
this.column = column;
|
this.column = column;
|
||||||
this.eventBus=eventBus;
|
this.eventBus=eventBus;
|
||||||
|
Log.debug(column.toString());
|
||||||
|
|
||||||
create();
|
create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +174,6 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
|
|
||||||
|
|
||||||
protected void applyRule() {
|
protected void applyRule() {
|
||||||
Log.debug("Apply");
|
|
||||||
C_Expression exp=conditionWidget.getExpression();
|
C_Expression exp=conditionWidget.getExpression();
|
||||||
parent.setExpression(exp);
|
parent.setExpression(exp);
|
||||||
ExpressionEvent expressionEvent= new ExpressionEvent(ExpressionType.CREATECOLUMNEXPRESSION);
|
ExpressionEvent expressionEvent= new ExpressionEvent(ExpressionType.CREATECOLUMNEXPRESSION);
|
||||||
|
@ -199,6 +200,7 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
|
|
||||||
protected void close() {
|
protected void close() {
|
||||||
ExpressionEvent expressionEvent= new ExpressionEvent(ExpressionType.EXPRESSIONNULL);
|
ExpressionEvent expressionEvent= new ExpressionEvent(ExpressionType.EXPRESSIONNULL);
|
||||||
|
Log.debug(expressionEvent.toString());
|
||||||
eventBus.fireEvent(expressionEvent);
|
eventBus.fireEvent(expressionEvent);
|
||||||
parent.hide();
|
parent.hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class ConditionWidget extends SimpleContainer {
|
||||||
protected String HEIGHT = "210px";
|
protected String HEIGHT = "210px";
|
||||||
protected FieldLabel matchLabel;
|
protected FieldLabel matchLabel;
|
||||||
protected ToggleGroup groupMatch;
|
protected ToggleGroup groupMatch;
|
||||||
|
|
||||||
protected String itemIdCombo = "ComboConditions";
|
protected String itemIdCombo = "ComboConditions";
|
||||||
protected String itemIdFirstArg = "FirstArg";
|
protected String itemIdFirstArg = "FirstArg";
|
||||||
protected String itemIdSecondArg = "SecondArg";
|
protected String itemIdSecondArg = "SecondArg";
|
||||||
|
@ -57,68 +57,66 @@ public class ConditionWidget extends SimpleContainer {
|
||||||
protected String itemIdBtnDel = "BtnDel";
|
protected String itemIdBtnDel = "BtnDel";
|
||||||
protected VerticalLayoutContainer vert;
|
protected VerticalLayoutContainer vert;
|
||||||
protected ColumnData column;
|
protected ColumnData column;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ConditionWidget(ColumnData column){
|
ConditionWidget(ColumnData column) {
|
||||||
this.column=column;
|
this.column = column;
|
||||||
setBorders(true);
|
setBorders(true);
|
||||||
setHeight(HEIGHT);
|
setHeight(HEIGHT);
|
||||||
|
|
||||||
thisCont = this;
|
thisCont = this;
|
||||||
|
|
||||||
VerticalLayoutContainer baseLayout = new VerticalLayoutContainer();
|
VerticalLayoutContainer baseLayout = new VerticalLayoutContainer();
|
||||||
|
|
||||||
Radio radioAll = new Radio();
|
Radio radioAll = new Radio();
|
||||||
radioAll.setName("All");
|
radioAll.setName("All");
|
||||||
radioAll.setBoxLabel("All conditions");
|
radioAll.setBoxLabel("All conditions");
|
||||||
radioAll.setValue(true);
|
radioAll.setValue(true);
|
||||||
|
|
||||||
Radio radioAny = new Radio();
|
Radio radioAny = new Radio();
|
||||||
radioAny.setName("Any");
|
radioAny.setName("Any");
|
||||||
radioAny.setBoxLabel("Any condition");
|
radioAny.setBoxLabel("Any condition");
|
||||||
|
|
||||||
HorizontalPanel matchPanel = new HorizontalPanel();
|
HorizontalPanel matchPanel = new HorizontalPanel();
|
||||||
matchPanel.add(radioAll);
|
matchPanel.add(radioAll);
|
||||||
matchPanel.add(radioAny);
|
matchPanel.add(radioAny);
|
||||||
|
|
||||||
matchLabel=new FieldLabel(matchPanel, "Match");
|
matchLabel = new FieldLabel(matchPanel, "Match");
|
||||||
matchLabel.setVisible(false);
|
matchLabel.setVisible(false);
|
||||||
|
|
||||||
baseLayout.add(matchLabel, new VerticalLayoutData(-1, -1, new Margins(2,1,2,1)));
|
baseLayout.add(matchLabel, new VerticalLayoutData(-1, -1, new Margins(
|
||||||
|
2, 1, 2, 1)));
|
||||||
groupMatch = new ToggleGroup();
|
|
||||||
groupMatch.add(radioAll);
|
groupMatch = new ToggleGroup();
|
||||||
groupMatch.add(radioAny);
|
groupMatch.add(radioAll);
|
||||||
|
groupMatch.add(radioAny);
|
||||||
|
|
||||||
vert = new VerticalLayoutContainer();
|
vert = new VerticalLayoutContainer();
|
||||||
vert.setScrollMode(ScrollMode.AUTO);
|
vert.setScrollMode(ScrollMode.AUTO);
|
||||||
vert.setAdjustForScroll(true);
|
vert.setAdjustForScroll(true);
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
baseLayout.add(vert,new VerticalLayoutData(-1, -1, new Margins(0)));
|
baseLayout.add(vert, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||||
add(baseLayout);
|
add(baseLayout);
|
||||||
show();
|
show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setup(){
|
protected void setup() {
|
||||||
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
||||||
|
|
||||||
final TextField firstArg = new TextField();
|
final TextField firstArg = new TextField();
|
||||||
firstArg.setItemId(itemIdFirstArg);
|
firstArg.setItemId(itemIdFirstArg);
|
||||||
firstArg.setVisible(false);
|
firstArg.setVisible(false);
|
||||||
|
|
||||||
final HTML andText=new HTML("<div style='vertical-align:middle; margin-left:2px;margin-right:2px;margin-top:4px;'>and</div>");
|
final HTML andText = new HTML(
|
||||||
|
"<div style='vertical-align:middle; margin-left:2px;margin-right:2px;margin-top:4px;'>and</div>");
|
||||||
andText.setVisible(false);
|
andText.setVisible(false);
|
||||||
|
|
||||||
final TextField secondArg = new TextField();
|
final TextField secondArg = new TextField();
|
||||||
firstArg.setItemId(itemIdSecondArg);
|
secondArg.setItemId(itemIdSecondArg);
|
||||||
secondArg.setVisible(false);
|
secondArg.setVisible(false);
|
||||||
|
|
||||||
final IconButton btnAdd = new IconButton();
|
final IconButton btnAdd = new IconButton();
|
||||||
btnAdd.setItemId(itemIdBtnAdd);
|
btnAdd.setItemId(itemIdBtnAdd);
|
||||||
btnAdd.setIcon(ExpressionResources.INSTANCE.add());
|
btnAdd.setIcon(ExpressionResources.INSTANCE.add());
|
||||||
|
@ -129,12 +127,11 @@ public class ConditionWidget extends SimpleContainer {
|
||||||
matchLabel.setVisible(true);
|
matchLabel.setVisible(true);
|
||||||
addCondition();
|
addCondition();
|
||||||
thisCont.forceLayout();
|
thisCont.forceLayout();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnAdd.setVisible(false);
|
btnAdd.setVisible(false);
|
||||||
|
|
||||||
final IconButton btnDel = new IconButton();
|
final IconButton btnDel = new IconButton();
|
||||||
btnAdd.setItemId(itemIdBtnDel);
|
btnAdd.setItemId(itemIdBtnDel);
|
||||||
btnDel.setIcon(ExpressionResources.INSTANCE.delete());
|
btnDel.setIcon(ExpressionResources.INSTANCE.delete());
|
||||||
|
@ -143,20 +140,20 @@ public class ConditionWidget extends SimpleContainer {
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
Log.debug("Clicked btnDel");
|
Log.debug("Clicked btnDel");
|
||||||
vert.remove(horiz);
|
vert.remove(horiz);
|
||||||
if(vert.getWidgetCount()==0){
|
if (vert.getWidgetCount() == 0) {
|
||||||
setup();
|
setup();
|
||||||
matchLabel.setVisible(false);
|
matchLabel.setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
if(vert.getWidgetCount()==1){
|
if (vert.getWidgetCount() == 1) {
|
||||||
matchLabel.setVisible(false);
|
matchLabel.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
thisCont.forceLayout();
|
thisCont.forceLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnDel.setVisible(false);
|
btnDel.setVisible(false);
|
||||||
|
|
||||||
OperationProperties props = GWT.create(OperationProperties.class);
|
OperationProperties props = GWT.create(OperationProperties.class);
|
||||||
ListStore<Operation> storeOp = new ListStore<Operation>(props.id());
|
ListStore<Operation> storeOp = new ListStore<Operation>(props.id());
|
||||||
storeOp.addAll(OperationsStore.getAll(column.getDataTypeName()));
|
storeOp.addAll(OperationsStore.getAll(column.getDataTypeName()));
|
||||||
|
@ -164,10 +161,9 @@ public class ConditionWidget extends SimpleContainer {
|
||||||
Log.debug("Store created");
|
Log.debug("Store created");
|
||||||
ComboBox<Operation> comboOp = new ComboBox<Operation>(storeOp,
|
ComboBox<Operation> comboOp = new ComboBox<Operation>(storeOp,
|
||||||
props.label());
|
props.label());
|
||||||
|
|
||||||
Log.debug("Combo created");
|
Log.debug("Combo created");
|
||||||
|
|
||||||
|
|
||||||
comboOp.addSelectionHandler(new SelectionHandler<Operation>() {
|
comboOp.addSelectionHandler(new SelectionHandler<Operation>() {
|
||||||
|
|
||||||
public void onSelection(SelectionEvent<Operation> event) {
|
public void onSelection(SelectionEvent<Operation> event) {
|
||||||
|
@ -215,7 +211,6 @@ public class ConditionWidget extends SimpleContainer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -235,24 +230,23 @@ public class ConditionWidget extends SimpleContainer {
|
||||||
|
|
||||||
vert.add(horiz, new VerticalLayoutData(-1, -1, new Margins(1)));
|
vert.add(horiz, new VerticalLayoutData(-1, -1, new Margins(1)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void addCondition() {
|
protected void addCondition() {
|
||||||
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
||||||
|
|
||||||
final TextField firstArg = new TextField();
|
final TextField firstArg = new TextField();
|
||||||
|
firstArg.setItemId(itemIdFirstArg);
|
||||||
firstArg.setVisible(false);
|
firstArg.setVisible(false);
|
||||||
|
|
||||||
final HTML andText=new HTML("<div style='vertical-align:middle; margin-left:2px;margin-right:2px;margin-top:4px;'>and</div>");
|
final HTML andText = new HTML(
|
||||||
|
"<div style='vertical-align:middle; margin-left:2px;margin-right:2px;margin-top:4px;'>and</div>");
|
||||||
andText.setVisible(false);
|
andText.setVisible(false);
|
||||||
|
|
||||||
final TextField secondArg = new TextField();
|
final TextField secondArg = new TextField();
|
||||||
|
secondArg.setItemId(itemIdSecondArg);
|
||||||
secondArg.setVisible(false);
|
secondArg.setVisible(false);
|
||||||
|
|
||||||
|
|
||||||
final IconButton btnAdd = new IconButton();
|
final IconButton btnAdd = new IconButton();
|
||||||
btnAdd.setItemId(itemIdBtnAdd);
|
btnAdd.setItemId(itemIdBtnAdd);
|
||||||
btnAdd.setIcon(ExpressionResources.INSTANCE.add());
|
btnAdd.setIcon(ExpressionResources.INSTANCE.add());
|
||||||
|
@ -275,11 +269,11 @@ public class ConditionWidget extends SimpleContainer {
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
Log.debug("Clicked btnDel");
|
Log.debug("Clicked btnDel");
|
||||||
vert.remove(horiz);
|
vert.remove(horiz);
|
||||||
if(vert.getWidgetCount()==0){
|
if (vert.getWidgetCount() == 0) {
|
||||||
setup();
|
setup();
|
||||||
matchLabel.setVisible(false);
|
matchLabel.setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
if(vert.getWidgetCount()==1){
|
if (vert.getWidgetCount() == 1) {
|
||||||
matchLabel.setVisible(false);
|
matchLabel.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -338,7 +332,7 @@ public class ConditionWidget extends SimpleContainer {
|
||||||
btnDel.setVisible(true);
|
btnDel.setVisible(true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
thisCont.forceLayout();
|
thisCont.forceLayout();
|
||||||
|
@ -366,45 +360,53 @@ public class ConditionWidget extends SimpleContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public C_Expression getExpression() {
|
public C_Expression getExpression() {
|
||||||
C_Expression exp=null;
|
C_Expression exp = null;
|
||||||
List<C_Expression> arguments=new ArrayList<C_Expression>();
|
List<C_Expression> arguments = new ArrayList<C_Expression>();
|
||||||
|
TextField firstArg;
|
||||||
OperatorTypeMap mapOp=new OperatorTypeMap();
|
TextField secondArg;
|
||||||
|
C_Expression expression;
|
||||||
|
|
||||||
|
OperatorTypeMap mapOp = new OperatorTypeMap();
|
||||||
Iterator<Widget> iteratorVert = vert.iterator();
|
Iterator<Widget> iteratorVert = vert.iterator();
|
||||||
|
HBoxLayoutContainer horiz;
|
||||||
while (iteratorVert.hasNext()) {
|
while (iteratorVert.hasNext()) {
|
||||||
HBoxLayoutContainer horiz = (HBoxLayoutContainer) iteratorVert
|
horiz = (HBoxLayoutContainer) iteratorVert
|
||||||
.next();
|
.next();
|
||||||
Log.debug("horiz:");
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
ComboBox<Operation> comboOp = (ComboBox<Operation>) horiz
|
ComboBox<Operation> comboOp = (ComboBox<Operation>) horiz
|
||||||
.getItemByItemId(itemIdCombo);
|
.getItemByItemId(itemIdCombo);
|
||||||
Log.debug("combo:" + comboOp.getCurrentValue().toString());
|
Log.debug("combo:" + comboOp.getCurrentValue().toString());
|
||||||
|
|
||||||
TextField firstArg = (TextField) horiz.getItemByItemId(itemIdFirstArg);
|
firstArg = (TextField) horiz.getItemByItemId(itemIdFirstArg);
|
||||||
TextField secondArg = (TextField) horiz.getItemByItemId(itemIdSecondArg);
|
secondArg = (TextField) horiz.getItemByItemId(itemIdSecondArg);
|
||||||
C_Expression expression=mapOp.map(column,comboOp.getCurrentValue().getOperatorType(), firstArg.getCurrentValue(), secondArg.getCurrentValue());
|
Log.debug("argLeft:" + firstArg + " argRight:" + secondArg);
|
||||||
|
|
||||||
|
expression = mapOp.map(column, comboOp.getCurrentValue()
|
||||||
|
.getOperatorType(),
|
||||||
|
firstArg == null ? null : firstArg.getCurrentValue(),
|
||||||
|
secondArg == null ? null : secondArg.getCurrentValue());
|
||||||
|
Log.debug(expression.toString());
|
||||||
arguments.add(expression);
|
arguments.add(expression);
|
||||||
}
|
}
|
||||||
if(arguments.size()>0){
|
if (arguments.size() > 0) {
|
||||||
if(arguments.size()==1){
|
if (arguments.size() == 1) {
|
||||||
exp=arguments.get(0);
|
exp = arguments.get(0);
|
||||||
} else {
|
} else {
|
||||||
Radio radio=(Radio) groupMatch.getValue();
|
Radio radio = (Radio) groupMatch.getValue();
|
||||||
if (radio.getName().compareTo("All") == 0) {
|
if (radio.getName().compareTo("All") == 0) {
|
||||||
} else {
|
} else {
|
||||||
exp=mapOp.createC_And(arguments);
|
exp = mapOp.createC_And(arguments);
|
||||||
if (radio.getName().compareTo("Any") == 0) {
|
if (radio.getName().compareTo("Any") == 0) {
|
||||||
exp=mapOp.createC_Or(arguments);
|
exp = mapOp.createC_Or(arguments);
|
||||||
} else {
|
} else {
|
||||||
Log.error("No All or Any set!");
|
Log.error("No All or Any set!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Log.debug("C_Expression" + exp);
|
||||||
return exp;
|
return exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class ExpressionWidgetEntry implements EntryPoint {
|
||||||
public void onModuleLoad() {
|
public void onModuleLoad() {
|
||||||
EventBus eventBus= new SimpleEventBus();
|
EventBus eventBus= new SimpleEventBus();
|
||||||
|
|
||||||
ColumnExpressionDialog expressionDialog=new ColumnExpressionDialog("0", ColumnTypeCode.ATTRIBUTE, ColumnDataType.Integer, eventBus);
|
ColumnExpressionDialog expressionDialog=new ColumnExpressionDialog("1", ColumnTypeCode.ATTRIBUTE, ColumnDataType.Integer, eventBus);
|
||||||
RootPanel.get().add(expressionDialog);
|
RootPanel.get().add(expressionDialog);
|
||||||
|
|
||||||
Log.info("Hello!");
|
Log.info("Hello!");
|
||||||
|
|
Loading…
Reference in New Issue