List of usage examples for com.google.gwt.user.client.ui Widget getAbsoluteTop
public int getAbsoluteTop()
From source file:org.drools.brms.client.modeldriven.ui.ActionSetFieldWidget.java
License:Apache License
private void doLayout() { layout.clear();/* ww w . ja v a2 s . com*/ layout.setWidget(0, 0, getSetterLabel()); DirtyableFlexTable inner = new DirtyableFlexTable(); for (int i = 0; i < model.fieldValues.length; i++) { ActionFieldValue val = model.fieldValues[i]; inner.setWidget(i, 0, fieldSelector(val)); inner.setWidget(i, 1, valueEditor(val)); final int idx = i; Image remove = new ImageButton("images/delete_item_small.gif"); remove.addClickListener(new ClickListener() { public void onClick(Widget w) { YesNoDialog diag = new YesNoDialog("Remove this item?", new Command() { public void execute() { model.removeField(idx); modeller.refreshWidget(); } }); diag.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop()); diag.show(); } }); inner.setWidget(i, 2, remove); } layout.setWidget(0, 1, inner); }
From source file:org.drools.brms.client.modeldriven.ui.ActionSetFieldWidget.java
License:Apache License
protected void showAddFieldPopup(Widget w) { final FormStylePopup popup = new FormStylePopup("images/newex_wiz.gif", "Add a field"); popup.setStyleName("ks-popups-Popup"); final ListBox box = new ListBox(); box.addItem("..."); for (int i = 0; i < fieldCompletions.length; i++) { box.addItem(fieldCompletions[i]); }/*from ww w. j av a 2 s.c om*/ box.setSelectedIndex(0); popup.addAttribute("Add field", box); box.addChangeListener(new ChangeListener() { public void onChange(Widget w) { String fieldName = box.getItemText(box.getSelectedIndex()); String fieldType = completions.getFieldType(variableClass, fieldName); model.addFieldValue(new ActionFieldValue(fieldName, "", fieldType)); modeller.refreshWidget(); popup.hide(); } }); popup.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop()); popup.show(); }
From source file:org.drools.brms.client.modeldriven.ui.CompositeFactPatternWidget.java
License:Apache License
/** * Pops up the fact selector./*from w w w . j a va2 s.com*/ */ protected void showFactTypeSelector(final Widget w) { final ListBox box = new ListBox(); String[] facts = completions.getFactTypes(); box.addItem("Choose..."); for (int i = 0; i < facts.length; i++) { box.addItem(facts[i]); } box.setSelectedIndex(0); final FormStylePopup popup = new FormStylePopup("images/new_fact.gif", "New fact pattern..."); popup.addAttribute("choose fact type", box); box.addChangeListener(new ChangeListener() { public void onChange(Widget w) { pattern.addFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex()))); modeller.refreshWidget(); popup.hide(); } }); popup.setStyleName("ks-popups-Popup"); popup.setPopupPosition(w.getAbsoluteLeft() - 400, w.getAbsoluteTop()); popup.show(); }
From source file:org.drools.brms.client.modeldriven.ui.ConstraintValueEditor.java
License:Apache License
/** * Show a list of possibilities for the value type. *//* w w w . ja v a 2s . com*/ private void showTypeChoice(Widget w, final ISingleFieldConstraint con) { final FormStylePopup form = new FormStylePopup("images/newex_wiz.gif", "Field value"); Button lit = new Button("Literal value"); lit.addClickListener(new ClickListener() { public void onClick(Widget w) { con.constraintValueType = SingleFieldConstraint.TYPE_LITERAL; doTypeChosen(form); } }); form.addAttribute("Literal value:", widgets(lit, new InfoPopup("Literal", "A literal value means the " + "constraint is directly against the value that you type (ie. what you see on screen)."))); form.addRow(new HTML("<hr/>")); form.addRow(new Lbl("Advanced options", "weak-Text")); //only want to show variables if we have some ! if (this.model.getBoundVariablesInScope(this.constraint).size() > 0) { Button variable = new Button("Bound variable"); variable.addClickListener(new ClickListener() { public void onClick(Widget w) { con.constraintValueType = SingleFieldConstraint.TYPE_VARIABLE; doTypeChosen(form); } }); form.addAttribute("A variable:", widgets(variable, new InfoPopup("A bound variable", "Will apply a constraint that compares a field to a bound variable."))); } Button formula = new Button("New formula"); formula.addClickListener(new ClickListener() { public void onClick(Widget w) { con.constraintValueType = SingleFieldConstraint.TYPE_RET_VALUE; doTypeChosen(form); } }); form.addAttribute("A formula:", widgets(formula, new InfoPopup("A formula", "A formula is an expression that calculates and returns a value " + ". That value is used to enforce the constraint."))); form.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop()); form.show(); }
From source file:org.drools.brms.client.modeldriven.ui.FactPatternWidget.java
License:Apache License
/** * This shows a popup for adding fields to a composite *///ww w . j a v a2 s . c om private void showPatternPopupForComposite(Widget w, final CompositeFieldConstraint composite) { final FormStylePopup popup = new FormStylePopup("images/newex_wiz.gif", "Add fields to this constraint"); popup.setStyleName("ks-popups-Popup"); final ListBox box = new ListBox(); box.addItem("..."); String[] fields = this.completions.getFieldCompletions(this.pattern.factType); for (int i = 0; i < fields.length; i++) { box.addItem(fields[i]); } box.setSelectedIndex(0); box.addChangeListener(new ChangeListener() { public void onChange(Widget w) { composite.addConstraint(new SingleFieldConstraint(box.getItemText(box.getSelectedIndex()))); modeller.refreshWidget(); popup.hide(); } }); popup.addAttribute("Add a restriction on a field", box); final ListBox composites = new ListBox(); composites.addItem("..."); composites.addItem("All of (And)", CompositeFieldConstraint.COMPOSITE_TYPE_AND); composites.addItem("Any of (Or)", CompositeFieldConstraint.COMPOSITE_TYPE_OR); composites.setSelectedIndex(0); composites.addChangeListener(new ChangeListener() { public void onChange(Widget w) { CompositeFieldConstraint comp = new CompositeFieldConstraint(); comp.compositeJunctionType = composites.getValue(composites.getSelectedIndex()); composite.addConstraint(comp); modeller.refreshWidget(); popup.hide(); } }); InfoPopup infoComp = new InfoPopup("Multiple field constraints", "You can specify constraints that span multiple fields (and more). The results of all these constraints can be combined with a 'and' or an 'or' logically." + "You can also have other multiple field constraints nested inside these restrictions."); HorizontalPanel horiz = new HorizontalPanel(); horiz.add(composites); horiz.add(infoComp); popup.addAttribute("Multiple field constraint", horiz); popup.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop()); popup.show(); }
From source file:org.drools.brms.client.modeldriven.ui.FactPatternWidget.java
License:Apache License
/** * This shows a popup allowing you to add field constraints to a pattern (its a popup). *//*ww w . j av a 2s .c o m*/ private void showPatternPopup(Widget w) { final FormStylePopup popup = new FormStylePopup("images/newex_wiz.gif", "Modify constraints for " + pattern.factType); popup.setStyleName("ks-popups-Popup"); final ListBox box = new ListBox(); box.addItem("..."); String[] fields = this.completions.getFieldCompletions(this.pattern.factType); for (int i = 0; i < fields.length; i++) { box.addItem(fields[i]); } box.setSelectedIndex(0); box.addChangeListener(new ChangeListener() { public void onChange(Widget w) { pattern.addConstraint(new SingleFieldConstraint(box.getItemText(box.getSelectedIndex()))); modeller.refreshWidget(); popup.hide(); } }); popup.addAttribute("Add a restriction on a field", box); final ListBox composites = new ListBox(); composites.addItem("..."); composites.addItem("All of (And)", CompositeFieldConstraint.COMPOSITE_TYPE_AND); composites.addItem("Any of (Or)", CompositeFieldConstraint.COMPOSITE_TYPE_OR); composites.setSelectedIndex(0); composites.addChangeListener(new ChangeListener() { public void onChange(Widget w) { CompositeFieldConstraint comp = new CompositeFieldConstraint(); comp.compositeJunctionType = composites.getValue(composites.getSelectedIndex()); pattern.addConstraint(comp); modeller.refreshWidget(); popup.hide(); } }); InfoPopup infoComp = new InfoPopup("Multiple field constraints", "You can specify constraints that span multiple fields (and more). The results of all these constraints can be combined with a 'and' or an 'or' logically." + "You can also have other multiple field constraints nested inside these restrictions."); HorizontalPanel horiz = new HorizontalPanel(); horiz.add(composites); horiz.add(infoComp); popup.addAttribute("Multiple field constraint", horiz); //popup.addRow( new HTML("<hr/>") ); popup.addRow(new Lbl("Advanced options", "weak-Text")); final Button predicate = new Button("New formula"); predicate.addClickListener(new ClickListener() { public void onClick(Widget w) { SingleFieldConstraint con = new SingleFieldConstraint(); con.constraintValueType = SingleFieldConstraint.TYPE_PREDICATE; pattern.addConstraint(con); modeller.refreshWidget(); popup.hide(); } }); popup.addAttribute("Add a new formula style expression", predicate); doBindingEditor(popup); popup.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop()); popup.show(); }
From source file:org.drools.brms.client.modeldriven.ui.FactPatternWidget.java
License:Apache License
/** * Display a little editor for field bindings. *///from ww w.j a va 2 s .c o m private void showBindFieldPopup(final Widget w, final SingleFieldConstraint con) { final FormStylePopup popup = new FormStylePopup("images/newex_wiz.gif", "Bind the field called [" + con.fieldName + "] to a variable."); final AbsolutePanel vn = new AbsolutePanel(); final TextBox varName = new TextBox(); final Button ok = new Button("Set"); vn.add(varName); vn.add(ok); ok.addClickListener(new ClickListener() { public void onClick(Widget w) { String var = varName.getText(); if (modeller.isVariableNameUsed(var)) { Window.alert("The variable name [" + var + "] is already taken."); return; } con.fieldBinding = var; modeller.refreshWidget(); popup.hide(); } }); popup.addAttribute("Variable name", vn); popup.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop()); popup.show(); }
From source file:org.drools.brms.client.modeldriven.ui.RuleAttributeWidget.java
License:Apache License
private Image getRemoveIcon(final int idx) { Image remove = new Image("images/delete_item_small.gif"); remove.addClickListener(new ClickListener() { public void onClick(Widget w) { YesNoDialog diag = new YesNoDialog("Remove this rule option?", new Command() { public void execute() { model.removeAttribute(idx); parent.refreshWidget(); }/*from w w w . j a v a 2 s . c o m*/ }); diag.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop()); diag.show(); } }); return remove; }
From source file:org.drools.brms.client.modeldriven.ui.RuleModeller.java
License:Apache License
protected void showAttributeSelector(Widget w) { final FormStylePopup pop = new FormStylePopup("images/config.png", "Add an option to the rule"); final ListBox list = RuleAttributeWidget.getAttributeList(); list.setSelectedIndex(0);//from w w w. j a v a 2s .c o m list.addChangeListener(new ChangeListener() { public void onChange(Widget w) { model.addAttribute(new RuleAttribute(list.getItemText(list.getSelectedIndex()), "")); refreshWidget(); pop.hide(); } }); pop.setStyleName("ks-popups-Popup"); pop.addAttribute("Attribute", list); pop.setPopupPosition(w.getAbsoluteLeft() - 400, w.getAbsoluteTop()); pop.show(); }
From source file:org.drools.brms.client.modeldriven.ui.RuleModeller.java
License:Apache License
/** * Do all the widgets for the RHS.//from w w w . j a v a2 s . c o m */ /* * TODO STILL NEED TO BE CHECKED */ private Widget renderRhs(final RuleModel model) { DirtyableVerticalPane vert = new DirtyableVerticalPane(); for (int i = 0; i < model.rhs.length; i++) { IAction action = model.rhs[i]; Widget w = null; if (action instanceof ActionSetField) { w = new ActionSetFieldWidget(this, (ActionSetField) action, completions); } else if (action instanceof ActionInsertFact) { w = new ActionInsertFactWidget(this, (ActionInsertFact) action, completions); } else if (action instanceof ActionRetractFact) { w = new ActionRetractFactWidget(this.completions, (ActionRetractFact) action); } else if (action instanceof DSLSentence) { w = new DSLSentenceWidget((DSLSentence) action); w.setStyleName("model-builderInner-Background"); } //w.setWidth( "100%" ); vert.add(spacerWidget()); //vert.setWidth( "100%" ); DirtyableHorizontalPane horiz = new DirtyableHorizontalPane(); Image remove = new ImageButton("images/delete_item_small.gif"); remove.setTitle("Remove this action."); final int idx = i; remove.addClickListener(new ClickListener() { public void onClick(Widget w) { YesNoDialog diag = new YesNoDialog("Remove this item?", new Command() { public void execute() { model.removeRhsItem(idx); refreshWidget(); } }); diag.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop()); diag.show(); } }); horiz.add(w); if (!(w instanceof ActionRetractFactWidget)) { w.setWidth("100%"); horiz.setWidth("100%"); } horiz.add(remove); vert.add(horiz); } return vert; }