Updated Column Expression Panel
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@90350 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
15a627f4bb
commit
ee34e3d721
|
@ -0,0 +1,40 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.resource.ExpressionResources;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.sencha.gxt.widget.core.client.Window;
|
||||
|
||||
public class ColumnExpressionDialog extends Window {
|
||||
protected String WIDTH = "640px";
|
||||
protected String HEIGHT = "520px";
|
||||
protected ColumnExpressionPanel columnExpressionPanel;
|
||||
|
||||
public ColumnExpressionDialog(String columnId, String columnTypeCode,
|
||||
String dataTypeName) {
|
||||
setBodyBorder(false);
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setResize(true);
|
||||
setHeadingText("New Rule");
|
||||
getHeader().setIcon(ExpressionResources.INSTANCE.rule());
|
||||
|
||||
columnExpressionPanel=new ColumnExpressionPanel(columnId, columnTypeCode,dataTypeName);
|
||||
add(columnExpressionPanel);
|
||||
}
|
||||
|
||||
|
||||
public ColumnExpressionDialog(TRId trId, String columnName) {
|
||||
setBodyBorder(false);
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setResize(true);
|
||||
setHeadingText("New Rule");
|
||||
getHeader().setIcon(ExpressionResources.INSTANCE.rule());
|
||||
|
||||
columnExpressionPanel=new ColumnExpressionPanel(trId, columnName);
|
||||
add(columnExpressionPanel);
|
||||
}
|
||||
|
||||
}
|
|
@ -11,6 +11,7 @@ import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
|||
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||
import com.sencha.gxt.widget.core.client.Window;
|
||||
import com.sencha.gxt.widget.core.client.button.CellButtonBase;
|
||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||
|
@ -33,7 +34,7 @@ import com.sencha.gxt.widget.core.client.form.TextField;
|
|||
*
|
||||
*/
|
||||
public class ColumnExpressionPanel extends FramedPanel {
|
||||
protected String WIDTH = "700px";
|
||||
protected String WIDTH = "640px";
|
||||
protected String HEIGHT = "520px";
|
||||
|
||||
protected TRId trId;
|
||||
|
@ -69,12 +70,15 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
|
||||
protected void create() {
|
||||
setBodyBorder(false);
|
||||
// getHeader().setIcon(Resources.IMAGES.side_list());
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setHeaderVisible(false);
|
||||
/*
|
||||
setResize(true);
|
||||
setHeadingText("New Rule");
|
||||
|
||||
getHeader().setIcon(ExpressionResources.INSTANCE.rule());
|
||||
*/
|
||||
|
||||
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
|
||||
basicLayout.setScrollMode(ScrollMode.AUTO);
|
||||
basicLayout.setAdjustForScroll(true);
|
||||
|
|
|
@ -9,20 +9,18 @@ import org.gcube.portlets.user.td.expressionwidget.client.operation.OperationsSt
|
|||
import org.gcube.portlets.user.td.expressionwidget.client.resource.ExpressionResources;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.cell.client.SafeHtmlCell;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.IsWidget;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
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.core.client.util.ToggleGroup;
|
||||
import com.sencha.gxt.data.shared.ListStore;
|
||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
||||
|
@ -31,6 +29,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.form.ComboBox;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||
import com.sencha.gxt.widget.core.client.form.Radio;
|
||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||
|
||||
/**
|
||||
|
@ -43,6 +42,8 @@ public class ConditionWidget extends SimpleContainer {
|
|||
|
||||
private final ConditionWidget thisCont;
|
||||
protected String HEIGHT = "210px";
|
||||
protected FieldLabel matchLabel;
|
||||
|
||||
protected String itemIdCombo = "ComboConditions";
|
||||
protected String itemIdFirstArg = "FirstArg";
|
||||
protected String itemIdSecondArg = "SecondArg";
|
||||
|
@ -54,28 +55,7 @@ public class ConditionWidget extends SimpleContainer {
|
|||
protected String columnTypeCode;
|
||||
protected String dataTypeName;
|
||||
|
||||
/*
|
||||
* interface ConditionProperties extends PropertyAccess<Condition> {
|
||||
*
|
||||
* @Path("id") ModelKeyProvider<Condition> key();
|
||||
*
|
||||
* ValueProvider<Condition, Operation> condition();
|
||||
*
|
||||
* ValueProvider<Condition, String> firstArg();
|
||||
*
|
||||
* ValueProvider<Condition, String> secondArg();
|
||||
*
|
||||
* ValueProvider<Condition, String> btnAdd();
|
||||
*
|
||||
* ValueProvider<Condition, String> btnDel();
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
/*
|
||||
* private static final ConditionProperties properties = GWT
|
||||
* .create(ConditionProperties.class); private ListStore<Condition> store;
|
||||
*/
|
||||
|
||||
|
||||
ConditionWidget(String columnPlaceHolderId, String columnTypeCode,
|
||||
String dataTypeName) {
|
||||
|
@ -87,10 +67,38 @@ public class ConditionWidget extends SimpleContainer {
|
|||
|
||||
thisCont = this;
|
||||
|
||||
vert = new VerticalLayoutContainer();
|
||||
VerticalLayoutContainer baseLayout = new VerticalLayoutContainer();
|
||||
|
||||
Radio radioAll = new Radio();
|
||||
radioAll.setBoxLabel("All conditions");
|
||||
|
||||
Radio radioAny = new Radio();
|
||||
radioAny.setBoxLabel("Any condition");
|
||||
|
||||
HorizontalPanel matchPanel = new HorizontalPanel();
|
||||
matchPanel.add(radioAll);
|
||||
matchPanel.add(radioAny);
|
||||
|
||||
matchLabel=new FieldLabel(matchPanel, "Match");
|
||||
matchLabel.setVisible(false);
|
||||
|
||||
baseLayout.add(matchLabel, new VerticalLayoutData(-1, -1, new Margins(2,1,2,1)));
|
||||
|
||||
ToggleGroup groupMatch = new ToggleGroup();
|
||||
groupMatch.add(radioAll);
|
||||
groupMatch.add(radioAny);
|
||||
|
||||
|
||||
vert = new VerticalLayoutContainer();
|
||||
vert.setScrollMode(ScrollMode.AUTO);
|
||||
vert.setAdjustForScroll(true);
|
||||
|
||||
setup();
|
||||
|
||||
baseLayout.add(vert,new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||
add(baseLayout);
|
||||
show();
|
||||
|
||||
}
|
||||
|
||||
protected void setup(){
|
||||
|
@ -104,13 +112,6 @@ public class ConditionWidget extends SimpleContainer {
|
|||
|
||||
final TextField secondArg = new TextField();
|
||||
secondArg.setVisible(false);
|
||||
|
||||
/*
|
||||
final FieldLabel labelAnd=new FieldLabel(secondArg,"and");
|
||||
labelAnd.setLabelSeparator("");
|
||||
labelAnd.setLabelPad(0);
|
||||
labelAnd.setVisible(false);
|
||||
*/
|
||||
|
||||
final IconButton btnAdd = new IconButton();
|
||||
btnAdd.setItemId(itemIdBtnAdd);
|
||||
|
@ -119,7 +120,10 @@ public class ConditionWidget extends SimpleContainer {
|
|||
|
||||
public void onClick(ClickEvent event) {
|
||||
Log.debug("Clicked btnAdd");
|
||||
matchLabel.setVisible(true);
|
||||
addCondition();
|
||||
thisCont.forceLayout();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -135,6 +139,11 @@ public class ConditionWidget extends SimpleContainer {
|
|||
vert.remove(horiz);
|
||||
if(vert.getWidgetCount()==0){
|
||||
setup();
|
||||
matchLabel.setVisible(false);
|
||||
} else {
|
||||
if(vert.getWidgetCount()==1){
|
||||
matchLabel.setVisible(false);
|
||||
}
|
||||
}
|
||||
thisCont.forceLayout();
|
||||
|
||||
|
@ -149,29 +158,10 @@ public class ConditionWidget extends SimpleContainer {
|
|||
Log.debug("Store created");
|
||||
ComboBox<Operation> comboOp = new ComboBox<Operation>(storeOp,
|
||||
props.label());
|
||||
/*
|
||||
* ComboBoxCell<Operation> conditionCombo = new ComboBoxCell<Operation>(
|
||||
* storeOp, props.label());
|
||||
*/
|
||||
|
||||
Log.debug("Combo created");
|
||||
|
||||
/*
|
||||
* conditionCombo.addSelectionHandler(new SelectionHandler<Operation>()
|
||||
* {
|
||||
*
|
||||
* public void onSelection(SelectionEvent<Operation> event) {
|
||||
* CellSelectionEvent<Operation> sel = (CellSelectionEvent<Operation>)
|
||||
* event; Operation p = storeOp.get(sel.getContext().getIndex());
|
||||
* Info.display("Condition Selected", p.getName() + " selected " +
|
||||
* event.getSelectedItem());
|
||||
*
|
||||
* } }); conditionCombo.setTriggerAction(TriggerAction.ALL);
|
||||
* conditionCombo.setForceSelection(true); conditionCombo.setWidth(224);
|
||||
*
|
||||
* TextInputCell firstArg= new TextInputCell(); TextInputCell secondArg=
|
||||
* new TextInputCell();
|
||||
*/
|
||||
|
||||
|
||||
comboOp.addSelectionHandler(new SelectionHandler<Operation>() {
|
||||
|
||||
public void onSelection(SelectionEvent<Operation> event) {
|
||||
|
@ -190,6 +180,8 @@ public class ConditionWidget extends SimpleContainer {
|
|||
case IN:
|
||||
case NOT_IN:
|
||||
firstArg.setVisible(true);
|
||||
andText.setVisible(false);
|
||||
secondArg.setVisible(false);
|
||||
btnAdd.setVisible(true);
|
||||
btnDel.setVisible(true);
|
||||
break;
|
||||
|
@ -203,9 +195,11 @@ public class ConditionWidget extends SimpleContainer {
|
|||
break;
|
||||
case IS_NULL:
|
||||
case IS_NOT_NULL:
|
||||
firstArg.setVisible(false);
|
||||
andText.setVisible(false);
|
||||
secondArg.setVisible(false);
|
||||
btnAdd.setVisible(true);
|
||||
btnDel.setVisible(true);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -223,49 +217,9 @@ public class ConditionWidget extends SimpleContainer {
|
|||
comboOp.setEmptyText("Select a condition...");
|
||||
comboOp.setItemId(itemIdCombo);
|
||||
comboOp.setWidth("230px");
|
||||
// comboOp.setTypeAhead(true);
|
||||
comboOp.setEditable(false);
|
||||
comboOp.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
/*
|
||||
* ColumnConfig<Condition, Operation> conditionColumn = new
|
||||
* ColumnConfig<Condition, Operation>( properties.condition(), 230,
|
||||
* "Condition"); conditionColumn.setColumnTextStyle(SafeStylesUtils
|
||||
* .fromTrustedString("padding: 2px 1px 2px 2px;margin: 1px;"));
|
||||
* conditionColumn.setCell(conditionCombo);
|
||||
*
|
||||
* ColumnConfig<Condition, String> firstArgColumn = new
|
||||
* ColumnConfig<Condition, String>( properties.firstArg(), 160,
|
||||
* "First Arg");
|
||||
* firstArgColumn.setColumnTextStyle(SafeStylesUtils.fromTrustedString
|
||||
* ("padding: 2px 1px 2px 3px; margin: 1px;"));
|
||||
* firstArgColumn.setCell(firstArg);
|
||||
*
|
||||
* ColumnConfig<Condition, String> secondArgColumn = new
|
||||
* ColumnConfig<Condition, String>( properties.secondArg(), 160,
|
||||
* "Second Arg");
|
||||
* secondArgColumn.setColumnTextStyle(SafeStylesUtils.fromTrustedString
|
||||
* ("padding: 2px 1px 2px 1px; margin: 1px;"));
|
||||
* secondArgColumn.setCell(secondArg);
|
||||
*
|
||||
*
|
||||
* List<ColumnConfig<Condition, ?>> l = new
|
||||
* ArrayList<ColumnConfig<Condition, ?>>(); l.add(conditionColumn);
|
||||
* l.add(firstArgColumn); l.add(secondArgColumn); ColumnModel<Condition>
|
||||
* cm = new ColumnModel<Condition>(l);
|
||||
*
|
||||
* store = new ListStore<Condition>(properties.key());
|
||||
*
|
||||
* List<Condition> conditions = new ArrayList<Condition>(); Condition
|
||||
* init=new Condition(); conditions.add(init);
|
||||
*
|
||||
* store.addAll(conditions);
|
||||
*
|
||||
* final Grid<Condition> grid = new Grid<Condition>(store, cm);
|
||||
* grid.setBorders(false); grid.getView().setTrackMouseOver(false);
|
||||
* grid.setHideHeaders(true); add(grid,new MarginData(new Margins(0)));
|
||||
*/
|
||||
|
||||
horiz.add(comboOp, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(firstArg, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(andText, new BoxLayoutData(new Margins(0)));
|
||||
|
@ -275,28 +229,10 @@ public class ConditionWidget extends SimpleContainer {
|
|||
|
||||
vert.add(horiz, new VerticalLayoutData(-1, -1, new Margins(1)));
|
||||
|
||||
add(vert);
|
||||
show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* private <T> void addHandlersForEventObservation(ComboBox<T> combo, final
|
||||
* LabelProvider<T> labelProvider) { combo.addSelectionHandler(new
|
||||
* SelectionHandler<T>() { public void onSelection(SelectionEvent<T> event)
|
||||
* { Info.display( "State Selected", "You selected " +
|
||||
* (event.getSelectedItem() == null ? "nothing" :
|
||||
* labelProvider.getLabel(event .getSelectedItem()) + "!"));
|
||||
*
|
||||
* if (event.getSelectedItem() != null) { Operation op = (Operation)
|
||||
* event.getSelectedItem(); Log.debug("Condition selected:" +
|
||||
* op.toString());
|
||||
*
|
||||
*
|
||||
* } }
|
||||
*
|
||||
* }); }
|
||||
*/
|
||||
|
||||
protected void addCondition() {
|
||||
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
||||
|
@ -310,11 +246,6 @@ public class ConditionWidget extends SimpleContainer {
|
|||
final TextField secondArg = new TextField();
|
||||
secondArg.setVisible(false);
|
||||
|
||||
/*final FieldLabel labelAnd=new FieldLabel(secondArg,"and");
|
||||
labelAnd.setLabelSeparator("");
|
||||
labelAnd.setLabelPad(0);
|
||||
labelAnd.setVisible(false);
|
||||
*/
|
||||
|
||||
final IconButton btnAdd = new IconButton();
|
||||
btnAdd.setItemId(itemIdBtnAdd);
|
||||
|
@ -323,7 +254,9 @@ public class ConditionWidget extends SimpleContainer {
|
|||
|
||||
public void onClick(ClickEvent event) {
|
||||
Log.debug("Clicked btnAdd");
|
||||
matchLabel.setVisible(true);
|
||||
addCondition();
|
||||
thisCont.forceLayout();
|
||||
}
|
||||
});
|
||||
btnAdd.setVisible(false);
|
||||
|
@ -338,6 +271,11 @@ public class ConditionWidget extends SimpleContainer {
|
|||
vert.remove(horiz);
|
||||
if(vert.getWidgetCount()==0){
|
||||
setup();
|
||||
matchLabel.setVisible(false);
|
||||
} else {
|
||||
if(vert.getWidgetCount()==1){
|
||||
matchLabel.setVisible(false);
|
||||
}
|
||||
}
|
||||
thisCont.forceLayout();
|
||||
}
|
||||
|
@ -372,7 +310,10 @@ public class ConditionWidget extends SimpleContainer {
|
|||
case IN:
|
||||
case NOT_IN:
|
||||
firstArg.setVisible(true);
|
||||
andText.setVisible(false);
|
||||
secondArg.setVisible(false);
|
||||
btnAdd.setVisible(true);
|
||||
btnDel.setVisible(true);
|
||||
break;
|
||||
case BETWEEN:
|
||||
case NOT_BETWEEN:
|
||||
|
@ -380,10 +321,15 @@ public class ConditionWidget extends SimpleContainer {
|
|||
andText.setVisible(true);
|
||||
secondArg.setVisible(true);
|
||||
btnAdd.setVisible(true);
|
||||
btnDel.setVisible(true);
|
||||
break;
|
||||
case IS_NULL:
|
||||
case IS_NOT_NULL:
|
||||
firstArg.setVisible(false);
|
||||
andText.setVisible(false);
|
||||
secondArg.setVisible(false);
|
||||
btnAdd.setVisible(true);
|
||||
btnDel.setVisible(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -409,7 +355,7 @@ public class ConditionWidget extends SimpleContainer {
|
|||
horiz.add(btnAdd, new BoxLayoutData(new Margins(2, 0, 2, 0)));
|
||||
horiz.add(btnDel, new BoxLayoutData(new Margins(2, 0, 2, 0)));
|
||||
|
||||
vert.add(horiz, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||
vert.add(horiz, new VerticalLayoutData(-1, -1, new Margins(1)));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ public interface ExpressionResources extends ClientBundle {
|
|||
@Source("close-red.png")
|
||||
ImageResource close();
|
||||
|
||||
@Source("wrench.png")
|
||||
ImageResource rule();
|
||||
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 523 B |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 523 B |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in New Issue