List of usage examples for com.google.gwt.user.client.ui TextBox setVisibleLength
public void setVisibleLength(int length)
From source file:org.drools.guvnor.client.modeldriven.ui.RuleAttributeWidget.java
License:Apache License
private TextBox textBoxEditor(final RuleAttribute at) { final TextBox box = new TextBox(); box.setVisibleLength((at.value.length() < 3) ? 3 : at.value.length()); box.setText(at.value);// w w w.j ava 2 s . c o m box.addChangeListener(new ChangeListener() { public void onChange(Widget w) { at.value = box.getText(); makeDirty(); } }); if (at.attributeName.equals("date-effective") || at.attributeName.equals("date-expires")) { if (at.value == null || "".equals(at.value)) box.setText(""); box.setVisibleLength(10); } box.addKeyboardListener(new KeyboardListener() { public void onKeyDown(Widget arg0, char arg1, int arg2) { } public void onKeyPress(Widget arg0, char arg1, int arg2) { } public void onKeyUp(Widget arg0, char arg1, int arg2) { box.setVisibleLength(box.getText().length()); } }); return box; }
From source file:org.drools.guvnor.client.modeldriven.ui.RuleAttributeWidget.java
License:Apache License
private TextBox textBoxEditor(final RuleMetadata rm) { final TextBox box = new TextBox(); box.setVisibleLength((rm.value.length() < 3) ? 3 : rm.value.length()); box.setText(rm.value);/*from w w w. ja va2 s.c o m*/ box.addChangeListener(new ChangeListener() { public void onChange(Widget w) { rm.value = box.getText(); makeDirty(); } }); box.addKeyboardListener(new KeyboardListener() { public void onKeyDown(Widget arg0, char arg1, int arg2) { } public void onKeyPress(Widget arg0, char arg1, int arg2) { } public void onKeyUp(Widget arg0, char arg1, int arg2) { box.setVisibleLength(box.getText().length()); } }); return box; }
From source file:org.drools.guvnor.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(); final Image addbutton = new ImageButton("images/new_item.gif"); final TextBox box = new TextBox(); list.setSelectedIndex(0);/*from w w w. ja v a 2 s. co m*/ list.addChangeListener(new ChangeListener() { public void onChange(Widget w) { model.addAttribute(new RuleAttribute(list.getItemText(list.getSelectedIndex()), "")); refreshWidget(); pop.hide(); } }); box.setVisibleLength(15); addbutton.setTitle("Add Metadata to the rule."); addbutton.addClickListener(new ClickListener() { public void onClick(Widget w) { model.addMetadata(new RuleMetadata(box.getText(), "")); refreshWidget(); pop.hide(); } }); DirtyableHorizontalPane horiz = new DirtyableHorizontalPane(); horiz.add(box); horiz.add(addbutton); pop.addAttribute("Metadata: ", horiz); pop.addAttribute("Attribute: ", list); //add text field //add button //add listener that adds the rule Attribute // pop.addAttribute( "Metadata:", // editableText( new FieldBinding() { // public String getValue() { // return data.subject; // } // // public void setValue(String val) { // data.subject = val; // } // }, // "A short description of the subject matter." ) ); pop.show(); }
From source file:org.drools.guvnor.client.moduleeditor.drools.PackageEditor.java
License:Apache License
protected void showCatRuleSelector(Widget w) { Image image = new Image(DroolsGuvnorImageResources.INSTANCE.config()); image.setAltText(Constants.INSTANCE.Config()); final FormStylePopup pop = new FormStylePopup(image, Constants.INSTANCE.AddACategoryRuleToThePackage()); final Button addbutton = new Button(Constants.INSTANCE.OK()); final TextBox ruleName = new TextBox(); final CategoryExplorerWidget exw = new CategoryExplorerWidget(new CategorySelectHandler() { public void selected(String selectedPath) { //not needed }/* w w w . j a v a2 s. com*/ }); ruleName.setVisibleLength(15); addbutton.setTitle(Constants.INSTANCE.CreateCategoryRule()); addbutton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (exw.getSelectedPath().length() > 0 && ruleName.getText().trim().length() > 0) { addToCatRules(exw.getSelectedPath(), ruleName.getText()); } refreshWidgets(); pop.hide(); } }); pop.addAttribute(Constants.INSTANCE.AllTheRulesInFollowingCategory(), exw); pop.addAttribute(Constants.INSTANCE.WillExtendTheFollowingRuleCalled(), ruleName); pop.addAttribute("", addbutton); pop.show(); }
From source file:org.drools.guvnor.client.moduleeditor.soa.SOAServiceEditor.java
License:Apache License
protected void showCatRuleSelector(Widget w) { final FormStylePopup pop = new FormStylePopup(images.config(), constants.AddACategoryRuleToThePackage()); final Button addbutton = new Button(constants.OK()); final TextBox ruleName = new TextBox(); final CategoryExplorerWidget exw = new CategoryExplorerWidget(new CategorySelectHandler() { public void selected(String selectedPath) { //not needed }/*from w ww . j a v a 2 s. com*/ }); ruleName.setVisibleLength(15); addbutton.setTitle(constants.CreateCategoryRule()); addbutton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (exw.getSelectedPath().length() > 0 && ruleName.getText().trim().length() > 0) { addToCatRules(exw.getSelectedPath(), ruleName.getText()); } refreshWidgets(); pop.hide(); } }); pop.addAttribute(constants.AllTheRulesInFollowingCategory(), exw); pop.addAttribute(constants.WillExtendTheFollowingRuleCalled(), ruleName); pop.addAttribute("", addbutton); pop.show(); }
From source file:org.drools.guvnor.client.packages.PackageEditor2.java
License:Apache License
protected void showCatRuleSelector(Widget w) { final FormStylePopup pop = new FormStylePopup("images/config.png", "Add a Category Rule to the Package"); final Button addbutton = new Button("OK"); final TextBox ruleName = new TextBox(); final CategoryExplorerWidget exw = new CategoryExplorerWidget(new CategorySelectHandler() { public void selected(String selectedPath) { //not needed }/*from w w w .java 2 s. com*/ }); ruleName.setVisibleLength(15); addbutton.setTitle("Create Category Rule."); addbutton.addClickListener(new ClickListener() { public void onClick(Widget w) { if (exw.getSelectedPath().length() > 0 && ruleName.getText().trim().length() > 0) { addToCatRules(exw.getSelectedPath(), ruleName.getText()); } refreshWidgets(); pop.hide(); } }); pop.addAttribute("All the rules in category: ", exw); pop.addAttribute("Will extend the rule called: ", ruleName); pop.addAttribute("", addbutton); pop.show(); }
From source file:org.drools.guvnor.client.packages.PackageEditor2.java
License:Apache License
private Widget description() { final TextBox box = new TextBox(); box.setText(conf.description);/* w w w . j av a 2s . c om*/ box.addChangeListener(new ChangeListener() { public void onChange(Widget arg0) { conf.description = box.getText(); } }); box.setVisibleLength(64); return box; }
From source file:org.drools.guvnor.client.qa.testscenarios.MethodParameterCallValueEditor.java
License:Apache License
private TextBox boundTextBox(final CallFieldValue c) { final TextBox box = new TextBox(); box.setStyleName("constraint-value-Editor"); if (c.value == null) { box.setText(""); } else {//from ww w .j a v a 2 s . c o m if (c.value.trim().equals("")) { c.value = ""; } box.setText(c.value); } if (c.value == null || c.value.length() < 5) { box.setVisibleLength(6); } else { box.setVisibleLength(c.value.length() - 1); } box.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { c.value = box.getText(); if (onValueChangeCommand != null) { onValueChangeCommand.execute(); } makeDirty(); } }); box.addKeyUpHandler(new KeyUpHandler() { public void onKeyUp(KeyUpEvent event) { box.setVisibleLength(box.getText().length()); } }); if (methodParameter.type.equals(SuggestionCompletionEngine.TYPE_NUMERIC)) { box.addKeyPressHandler(new NumbericFilterKeyPressHandler(box)); } return box; }
From source file:org.drools.guvnor.client.qa.VerifyRulesFiredWidget.java
License:Apache License
private FlexTable render(final FixtureList rfl, final Scenario sc) { FlexTable data = new DirtyableFlexTable(); for (int i = 0; i < rfl.size(); i++) { final VerifyRuleFired v = (VerifyRuleFired) rfl.get(i); if (showResults && v.successResult != null) { if (!v.successResult.booleanValue()) { data.setWidget(i, 0, new Image(images.warning())); data.setWidget(i, 4, new HTML(Format.format(constants.ActualResult(), v.actualResult))); data.getCellFormatter().addStyleName(i, 4, "testErrorValue"); //NON-NLS } else { data.setWidget(i, 0, new Image(images.testPassed())); }/*from w ww.j av a 2 s. c om*/ } data.setWidget(i, 1, new SmallLabel(v.ruleName + ":")); data.getFlexCellFormatter().setAlignment(i, 1, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_MIDDLE); final ListBox b = new ListBox(); b.addItem(constants.firedAtLeastOnce(), "y"); b.addItem(constants.didNotFire(), "n"); b.addItem(constants.firedThisManyTimes(), "e"); final TextBox num = new TextBox(); num.setVisibleLength(5); if (v.expectedFire != null) { b.setSelectedIndex((v.expectedFire.booleanValue()) ? 0 : 1); num.setVisible(false); } else { b.setSelectedIndex(2); String xc = (v.expectedCount != null) ? "" + v.expectedCount.intValue() : "0"; num.setText(xc); } b.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { String s = b.getValue(b.getSelectedIndex()); if (s.equals("y") || s.equals("n")) { num.setVisible(false); v.expectedFire = (s.equals("y")) ? Boolean.TRUE : Boolean.FALSE; v.expectedCount = null; } else { num.setVisible(true); v.expectedFire = null; num.setText("1"); v.expectedCount = new Integer(1); } } }); b.addItem(constants.ChooseDotDotDot()); num.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { v.expectedCount = new Integer(num.getText()); } }); HorizontalPanel h = new HorizontalPanel(); h.add(b); h.add(num); data.setWidget(i, 2, h); Image del = new ImageButton(images.deleteItemSmall(), constants.RemoveThisRuleExpectation(), new ClickHandler() { public void onClick(ClickEvent w) { if (Window.confirm(constants.AreYouSureYouWantToRemoveThisRuleExpectation())) { rfl.remove(v); sc.removeFixture(v); outer.setWidget(1, 0, render(rfl, sc)); } } }); data.setWidget(i, 3, del); //we only want numbers here... num.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (Character.isLetter(event.getCharCode())) { ((TextBox) event.getSource()).cancelKey(); } } }); } return data; }
From source file:org.drools.guvnor.client.ruleeditor.MetaDataWidget.java
License:Apache License
/** This binds a field, and returns a text editor for it */ private Widget editableText(final FieldBinding bind, String toolTip) { if (!readOnly) { final TextBox box = new TextBox(); box.setTitle(toolTip);/* www . j a va2 s . c o m*/ box.setText(bind.getValue()); box.setVisibleLength(10); ChangeListener listener = new ChangeListener() { public void onChange(Widget w) { bind.setValue(box.getText()); } }; box.addChangeListener(listener); return box; } else { return new Label(bind.getValue()); } }