List of usage examples for com.google.gwt.user.client.ui Widget getAbsoluteLeft
public int getAbsoluteLeft()
From source file:org.bonitasoft.forms.client.view.widget.FormFieldWidget.java
License:Open Source License
/** * Create the widget//from w w w . java2 s .com * * @param widgetData * the widget data object */ protected void createWidget(final ReducedFormWidget widgetData, final FormFieldValue fieldValue) { // label creation if (widgetData.isMandatory() || widgetData.getLabel() != null && widgetData.getLabel().length() > 0) { labelWidget = new LabelWidget(widgetData, mandatoryFieldSymbol, mandatoryFieldClasses); if (ItemPosition.LEFT.equals(widgetData.getLabelPosition())) { addLabel(labelWidget, "bonita_form_label_left"); } else if (ItemPosition.TOP.equals(widgetData.getLabelPosition())) { addLabel(labelWidget, "bonita_form_label_top"); } } // field creation switch (widgetType) { case TEXTBOX: fieldWidget = createTextBox(widgetData, fieldValue); break; case TEXTAREA: fieldWidget = createTextArea(widgetData, fieldValue); break; case RICH_TEXTAREA: fieldWidget = createRichTextArea(widgetData, fieldValue); break; case PASSWORD: fieldWidget = createPasswordTextBox(widgetData, fieldValue); break; case TEXT: fieldWidget = createText(widgetData, fieldValue); break; case CHECKBOX: fieldWidget = createCheckBox(widgetData, fieldValue); break; case RADIOBUTTON_GROUP: fieldWidget = createRadioButtonGroup(widgetData, fieldValue); break; case LISTBOX_SIMPLE: fieldWidget = createListBox(widgetData, fieldValue); break; case LISTBOX_MULTIPLE: fieldWidget = createListBoxMulti(widgetData, fieldValue); break; case SUGGESTBOX: fieldWidget = createSuggestBox(widgetData, fieldValue); break; case SUGGESTBOX_ASYNC: fieldWidget = createSuggestBoxAsync(widgetData, fieldValue); break; case CHECKBOX_GROUP: fieldWidget = createCheckboxGroup(widgetData, fieldValue); break; case DATE: fieldWidget = createDateBox(widgetData, fieldValue); break; case DURATION: fieldWidget = createDuration(widgetData, fieldValue); break; case FILEUPLOAD: fieldWidget = createFileUpload(widgetData, fieldValue); break; case FILEDOWNLOAD: fieldWidget = createFileDownload(widgetData, fieldValue); break; case IMAGE: fieldWidget = createImage(widgetData, fieldValue, widgetData.isDisplayAttachmentImage()); break; case TABLE: fieldWidget = createTable(widgetData, fieldValue); break; case EDITABLE_GRID: fieldWidget = createEditableGrid(widgetData, fieldValue); break; case HIDDEN: fieldWidget = createHidden(widgetData, fieldValue); fieldContainer.add(fieldWidget); break; default: Window.alert(widgetType + " widget not supported."); break; } if (widgetType == WidgetType.LISTBOX_SIMPLE) { final FlowPanel div = new FlowPanel(); div.add(fieldWidget); addStandardWidgetFeatures(div, widgetData); div.addStyleName("list_container"); } else { addStandardWidgetFeatures(fieldWidget, widgetData); } if (labelWidget != null) { if (ItemPosition.RIGHT.equals(widgetData.getLabelPosition())) { addLabel(labelWidget, "bonita_form_label_right"); if (isStaticField()) { fieldWidget.addStyleName("bonita_form_static_field_left"); } else if (WidgetType.TEXTAREA.equals(widgetData.getType()) && widgetData.getMaxLength() != 0) { fieldWidget.addStyleName("bonita_form_field_left_no_width"); } else { fieldWidget.addStyleName("bonita_form_field_left"); } } else if (ItemPosition.BOTTOM.equals(widgetData.getLabelPosition())) { addLabel(labelWidget, "bonita_form_label_bottom"); if (isStaticField()) { fieldWidget.addStyleName("bonita_form_static_field_top"); } else if (WidgetType.TEXTAREA.equals(widgetData.getType()) && widgetData.getMaxLength() != 0) { fieldWidget.addStyleName("bonita_form_field_top_no_width"); } else { fieldWidget.addStyleName("bonita_form_field_top"); } } else if (ItemPosition.TOP.equals(widgetData.getLabelPosition())) { if (isStaticField()) { fieldWidget.addStyleName("bonita_form_static_field_bottom"); } else if (WidgetType.TEXTAREA.equals(widgetData.getType()) && widgetData.getMaxLength() != 0) { fieldWidget.addStyleName("bonita_form_field_bottom_no_width"); } else { fieldWidget.addStyleName("bonita_form_field_bottom"); } } else { if (isStaticField()) { fieldWidget.addStyleName("bonita_form_static_field_right"); } else if (WidgetType.TEXTAREA.equals(widgetData.getType()) && widgetData.getMaxLength() != 0) { fieldWidget.addStyleName("bonita_form_field_right_no_width"); } else { fieldWidget.addStyleName("bonita_form_field_right"); } } if (widgetData.getLabelStyle() != null && widgetData.getLabelStyle().length() > 0) { labelWidget.addStyleName(widgetData.getLabelStyle()); } } else { if (isStaticField()) { fieldWidget.addStyleName("bonita_form_static_field_top"); } else { fieldWidget.addStyleName("bonita_form_field_top"); } } if (widgetData.getInputStyle() != null && widgetData.getInputStyle().length() > 0) { fieldWidget.addStyleName(widgetData.getInputStyle()); } // display sub title if (widgetData.getSubtitle() != null) { final String label = widgetData.getSubtitle().getLabel(); if (label != null && label.trim().length() > 0) { if (SubTitlePosition.TOP.equals(widgetData.getSubtitle().getPosition())) { final HTML subTitle = new HTML(widgetData.getSubtitle().getLabel()); subTitle.addStyleName("bonita_form_field_sub_title"); flowPanel.add(subTitle); flowPanel.add(fieldContainer); } else { final HTML subTitle = new HTML(widgetData.getSubtitle().getLabel()); subTitle.addStyleName("bonita_form_field_sub_title"); flowPanel.add(fieldContainer); flowPanel.add(subTitle); } } else { flowPanel.add(fieldContainer); } } else { flowPanel.add(fieldContainer); } flowPanel.addStyleName("bonita_form_vertical_panel"); // tool-tip widget display if (widgetData.getPopupTooltip() != null && widgetData.getPopupTooltip().length() > 0) { theOuterToolTipPanel = new FlowPanel(); final PopupPanel toolTipPopupFrame = new PopupPanel(true); toolTipPopupFrame.setWidget(new Label(widgetData.getPopupTooltip())); toolTipPopupFrame.addStyleName("bonita_form_popup_tooltip"); final Image toolTipIcon = new Image("themeResource?theme=portal&location=images/tooltip.gif"); toolTipIcon.setStylePrimaryName("bonita_form_popup_tooltip_img"); theOuterToolTipPanel.add(toolTipIcon); theOuterToolTipPanel.setStylePrimaryName("bonita_form_popup_tooltip_icon"); toolTipIcon.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { final Widget source = (Widget) event.getSource(); final int left = source.getAbsoluteLeft(); final int top = source.getAbsoluteTop(); toolTipPopupFrame.setPopupPosition(left + 10, top + 5); toolTipPopupFrame.show(); } }); if (ItemPosition.RIGHT.equals(widgetData.getLabelPosition())) { toolTipPopupFrame.addStyleName("bonita_form_popup_tooltip_left"); fieldContainer.add(theOuterToolTipPanel); } else if (ItemPosition.LEFT.equals(widgetData.getLabelPosition())) { fieldContainer.add(theOuterToolTipPanel); } else if (ItemPosition.TOP.equals(widgetData.getLabelPosition())) { fieldContainer.add(theOuterToolTipPanel); } else if (ItemPosition.BOTTOM.equals(widgetData.getLabelPosition())) { fieldContainer.add(theOuterToolTipPanel); } } }
From source file:org.drools.brms.client.admin.CategoryManager.java
License:Apache License
public CategoryManager() { FormStyleLayout form = new FormStyleLayout("images/edit_category.gif", "Edit categories"); form.addAttribute("", new HTML( "<i>Categories aid in managing large numbers of rules/assets. A shallow hierarchy is recommented.</i>")); explorer = new CategoryExplorerWidget(new CategorySelectHandler() { public void selected(String sel) { //don't need this here as we don't do anything on select in this spot }/* ww w . ja va 2 s . c o m*/ }); explorer.setStyleName("category-explorer-Admin"); SimplePanel editable = new SimplePanel(); editable.setStyleName("metadata-Widget"); editable.add(explorer); form.addRow(new HTML("<hr/>")); form.addAttribute("Current categories:", editable); Image refresh = new ImageButton("images/refresh.gif"); refresh.setTitle("Refresh categories"); refresh.addClickListener(new ClickListener() { public void onClick(Widget w) { explorer.refresh(); } }); form.addAttribute("Refresh view:", refresh); form.addRow(new HTML("<hr/>")); Image newCat = new ImageButton("images/new.gif"); newCat.setTitle("Create a new category"); newCat.addClickListener(new ClickListener() { public void onClick(Widget w) { CategoryEditor newCat = new CategoryEditor(explorer.getSelectedPath()); newCat.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop() - 400); newCat.show(); } }); form.addAttribute("Create a new category:", newCat); Image delete = new ImageButton("images/delete_obj.gif"); delete.addClickListener(new ClickListener() { public void onClick(Widget w) { deleteSelected(); } }); delete.setTitle( "Deletes the currently selected category. You won't be able to delete if the category is in use."); form.addAttribute("Delete the currently selected category:", delete); initWidget(form); }
From source file:org.drools.brms.client.common.InfoPopup.java
License:Apache License
public InfoPopup(final String title, final String message) { Image info = new Image("images/information.gif"); info.setTitle(message);/*from w w w .j a va2 s .c o m*/ info.addClickListener(new ClickListener() { public void onClick(Widget w) { final FormStylePopup pop = new FormStylePopup("images/information.gif", title); pop.addRow(new Lbl(message, "small-Text")); pop.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop()); pop.show(); } }); initWidget(info); }
From source file:org.drools.brms.client.modeldriven.ui.ActionInsertFactWidget.java
License:Apache License
private void doLayout() { layout.clear();/*from w ww. ja v a 2 s. co m*/ layout.setWidget(0, 0, getAssertLabel()); 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.ActionInsertFactWidget.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]); }/* w ww . j a va2s .com*/ 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(model.factType, 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.ActionSetFieldWidget.java
License:Apache License
private void doLayout() { layout.clear();/*from w w w . jav a 2s. c om*/ 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 w ww. j a v 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./* www . j a v a2s. c o m*/ */ 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 . jav a 2s. c om 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 *//*from w ww. j a va 2s .c o m*/ 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(); }