List of usage examples for com.google.gwt.user.client.ui Widget getAbsoluteLeft
public int getAbsoluteLeft()
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). *///w ww.ja v a 2 s. co 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. */// w ww. ja v a 2 s . c om 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 www. java2s.com }); 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 ww . ja v a 2 s . 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.// ww w . j ava 2s. co 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; }
From source file:org.drools.brms.client.modeldriven.ui.RuleModeller.java
License:Apache License
/** * Pops up the fact selector.//from w ww .j a v a 2 s . c o m */ protected void showConditionSelector(final Widget w) { final FormStylePopup popup = new FormStylePopup("images/new_fact.gif", "Add a condition to the rule..."); // // The list of facts // String[] facts = completions.getFactTypes(); final ListBox factTypeBox = new ListBox(); factTypeBox.addItem("Choose fact type...", "IGNORE"); for (int i = 0; i < facts.length; i++) { factTypeBox.addItem(facts[i]); } factTypeBox.setSelectedIndex(0); if (facts.length > 0) popup.addAttribute("Fact", factTypeBox); factTypeBox.addChangeListener(new ChangeListener() { public void onChange(Widget w) { String s = factTypeBox.getItemText(factTypeBox.getSelectedIndex()); if (!s.equals("IGNORE")) { addNewFact(s); popup.hide(); } } }); popup.setStyleName("ks-popups-Popup"); // // The list of top level CEs // String ces[] = HumanReadable.CONDITIONAL_ELEMENTS; final ListBox ceBox = new ListBox(); ceBox.addItem("Choose condition type...", "IGNORE"); for (int i = 0; i < ces.length; i++) { String ce = ces[i]; ceBox.addItem(HumanReadable.getCEDisplayName(ce), ce); } ceBox.setSelectedIndex(0); if (facts.length > 0) popup.addAttribute("Condition type", ceBox); ceBox.addChangeListener(new ChangeListener() { public void onChange(Widget w) { String s = ceBox.getValue(ceBox.getSelectedIndex()); if (!s.equals("IGNORE")) { addNewCE(s); popup.hide(); } } }); // // The list of DSL sentences // if (completions.getDSLConditions().length > 0) { final ListBox dsls = new ListBox(); dsls.addItem("Choose..."); for (int i = 0; i < completions.getDSLConditions().length; i++) { DSLSentence sen = completions.getDSLConditions()[i]; dsls.addItem(sen.toString(), Integer.toString(i)); } dsls.addChangeListener(new ChangeListener() { public void onChange(Widget w) { int idx = Integer.parseInt(dsls.getValue(dsls.getSelectedIndex())); addNewDSLLhs((DSLSentence) completions.getDSLConditions()[idx]); popup.hide(); } }); popup.addAttribute("DSL sentence", dsls); } popup.setPopupPosition(w.getAbsoluteLeft() - 400, w.getAbsoluteTop()); popup.show(); }
From source file:org.drools.brms.client.modeldriven.ui.RuleModeller.java
License:Apache License
/** * This adds the widget to the UI, also adding the remove icon. */// w w w . ja va 2 s .c om private Widget wrapLHSWidget(final RuleModel model, int i, Widget w) { DirtyableHorizontalPane horiz = new DirtyableHorizontalPane(); Image remove = new ImageButton("images/delete_item_small.gif"); remove.setTitle("Remove this ENTIRE condition, and all the field constraints that belong to it."); final int idx = i; remove.addClickListener(new ClickListener() { public void onClick(Widget w) { YesNoDialog diag = new YesNoDialog("Remove this entire condition?", new Command() { public void execute() { if (model.removeLhsItem(idx)) { refreshWidget(); } else { ErrorPopup.showMessage( "Can't remove that item as it is used in the action part of the rule."); } } }); diag.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop()); diag.show(); } }); horiz.setWidth("100%"); w.setWidth("100%"); horiz.add(w); horiz.add(remove); return horiz; }
From source file:org.drools.brms.client.packages.PackageEditor.java
License:Apache License
protected void showStatusChanger(Widget w) { final StatusChangePopup pop = new StatusChangePopup(conf.uuid, true); pop.setChangeStatusEvent(new Command() { public void execute() { setState(pop.getState());//from w w w .j a v a 2 s .c o m } }); pop.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop()); pop.show(); }
From source file:org.drools.brms.client.packages.PackageEditor.java
License:Apache License
private Widget header() { final TextArea area = new TextArea(); area.setWidth("100%"); area.setVisibleLines(8);//from w w w .j av a 2 s . c om area.setCharacterWidth(100); area.setText(this.conf.header); area.addChangeListener(new ChangeListener() { public void onChange(Widget w) { conf.header = area.getText(); dirtyCommand.execute(); } }); HorizontalPanel panel = new HorizontalPanel(); panel.add(area); VerticalPanel vert = new VerticalPanel(); Image max = new Image("images/max_min.gif"); max.addClickListener(new ClickListener() { public void onClick(Widget w) { if (area.getVisibleLines() != 32) { area.setVisibleLines(32); } else { area.setVisibleLines(8); } } }); max.setTitle("Increase view area."); vert.add(max); Image newImport = new Image("images/new_import.gif"); newImport.addClickListener(new ClickListener() { public void onClick(Widget w) { area.setText(area.getText() + "\n" + "import <your class here>"); conf.header = area.getText(); } }); vert.add(newImport); newImport.setTitle("Add a new Type/Class import to the package."); Image newGlobal = new Image("images/new_global.gif"); newGlobal.addClickListener(new ClickListener() { public void onClick(Widget w) { area.setText(area.getText() + "\n" + "global <your class here> <variable name>"); conf.header = area.getText(); } }); newGlobal.setTitle("Add a new global variable declaration."); vert.add(newGlobal); Image newFactTemplate = new Image("images/fact_template.gif"); newFactTemplate.addClickListener(new ClickListener() { public void onClick(Widget w) { final FactTemplateWizard wiz = new FactTemplateWizard(); wiz.setPopupPosition(w.getAbsoluteLeft() - 400, w.getAbsoluteTop() - 250); wiz.setOKClick(new Command() { public void execute() { area.setText(area.getText() + "\n" + wiz.getTemplateText()); conf.header = area.getText(); } }); wiz.show(); } }); newFactTemplate.setTitle("Add a new fact template."); //vert.add( newFactTemplate ); panel.setWidth("100%"); panel.add(vert); return panel; }
From source file:org.drools.brms.client.ruleeditor.ActionToolbar.java
License:Apache License
/** * Called when user wants to checkin.//from w ww. ja v a 2 s .c om */ protected void doCheckinConfirm(Widget w) { final CheckinPopup pop = new CheckinPopup(w.getAbsoluteLeft(), w.getAbsoluteTop(), "Check in changes."); pop.setCommand(new Command() { public void execute() { metaData.checkinComment = pop.getCheckinComment(); checkinAction.execute(); } }); pop.show(); }