public LockCell(boolean check, String text, String ariaLabel) { super(null); if (CONSTANTS.listOfClassesUseLockIcon()) { iCheck = new AriaToggleButton(RESOURCES.locked(), RESOURCES.unlocked()); } else { iCheck = new AriaCheckBox(); } if (text != null) ((HasText)iCheck).setText(text); iCheck.setValue(check); ((HasClickHandlers)iCheck).addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { event.stopPropagation(); } }); if (ariaLabel != null) setAriaLabel(ariaLabel); }
public Widget addToolButton(final GeneralCommand cmd, boolean alignRight) { final FocusWidget btn = new Button(cmd.getLabel()); updateHighlighted(btn, cmd); btn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent ev) { cmd.execute(); } }); cmd.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent pce) { if (pce.getPropertyName().equals(GeneralCommand.PROP_TITLE)) { if (btn instanceof HasText) { ((HasText) btn).setText(String.valueOf(pce.getNewValue())); } } else if (pce.getPropertyName().equals(GeneralCommand.PROP_HIGHLIGHT)) { updateHighlighted(btn, cmd); } } }); if (!StringUtils.isEmpty(cmd.getShortDesc())) { btn.setTitle(cmd.getShortDesc()); } addToolButton(btn, alignRight); return btn; }
public void setEditor(Widget aEditor) { editor = aEditor; if (editor == null || ((editor instanceof HasValue<?>) && (editor instanceof HasText))) { valueHost = (HasValue<C>) editor; } else { throw new IllegalArgumentException("Editor must implement interfaces HasValue<?> and HasText"); } if (editor instanceof Focusable) { focusHost = (Focusable) editor; focusHost.setTabIndex(1); } if (editor != null){ CommonResources.INSTANCE.commons().ensureInjected(); editor.getElement().addClassName(CommonResources.INSTANCE.commons().borderSized()); } }
private static Object getData(UIObject ui) { if (ui instanceof HasValue) { return ((HasValue)ui).getValue(); } else if (ui instanceof HasText) { return ((HasText)ui).getText(); } else if (ui instanceof HasData) { return ((HasData)ui).getData(); } else if (ui instanceof ListBox) { ListBox listBox = (ListBox) ui; if(listBox.getSelectedIndex() > 0) { return listBox.getValue(listBox.getSelectedIndex()); } } else if (ui instanceof ValueSpinner) { ValueSpinner spinner = (ValueSpinner) ui; return spinner.getTextBox().getValue(); } return null; }
private void updateChecksum(UIObject uiObject, DataMap dataMap) { UIObject component = getComponentByName(uiObject, DataContainerGVO.QAFE_CHECKSUM); if (component != null) { int checksum = 0; for (Map.Entry<String, DataContainerGVO> field : dataMap.entrySet()) { if (!isMetaData(field.getKey())) { Object value = field.getValue().createType(); checksum += QAMLUtil.calculateChecksum(field.getKey(), value); } } if (component instanceof HasText) { HasText hasText = (HasText)component; hasText.setText(String.valueOf(checksum)); } } }
private static Object getData(UIObject ui) { if (ui instanceof HasValue) { return ((HasValue)ui).getValue(); } else if (ui instanceof HasText) { return ((HasText)ui).getText(); } else if (ui instanceof HasData) { return ((HasData)ui).getData(); } else if (ui instanceof ListBox) { ListBox listBox = (ListBox) ui; if(listBox.getSelectedIndex() > 0) { return listBox.getValue(listBox.getSelectedIndex()); } } // else if (ui instanceof ValueSpinner) { // ValueSpinner spinner = (ValueSpinner) ui; // return spinner.getTextBox().getValue(); // } return null; }
public boolean validate(){ boolean result = true; clear(); for (FormValidatorInfo formValidator : formValidatorList) { if (formValidator.getValidationType().equals(FormValidatorInfo.urlValidator)) { result = validateItemUrl(formValidator) && result; } else { if (formValidator.getUiElement() instanceof CheckBox) { result = validate(((CheckBox)formValidator.getUiElement()).getValue(), formValidator.getUiElementName(), formValidator.getValidationType(), formValidator.isCustomMessage()) && result; } else if (formValidator.getUiElement() instanceof RiseListBox) { result = validate(((RiseListBox)formValidator.getUiElement()).getSelectedValue(), formValidator.getUiElementName(), formValidator.getValidationType(), formValidator.isCustomMessage()) && result; } else if (formValidator.getUiElement() instanceof HasText) { result = validate(((HasText)formValidator.getUiElement()).getText(), formValidator.getUiElementName(), formValidator.getValidationType(), formValidator.isCustomMessage()) && result; } } } return result; }
private boolean validateItemRequired(FormValidatorInfo formValidator){ boolean result = true; if (formValidator.getUiElement() instanceof HasText) result = !((HasText)formValidator.getUiElement()).getText().isEmpty(); else if (formValidator.getUiElement() instanceof HasValue<?>) result = (((HasValue<?>)formValidator.getUiElement()).getValue() != null); if (!result) { if (!formValidator.isCustomMessage()) addErrorMessage("* " + formValidator.getUiElementName() + " is a required field."); else addErrorMessage(formValidator.getUiElementName()); } return result; }
public int getCell(String text) { for (int i = 0; i < getWidgetCount(); i++) { Widget w = getWidget(i); if ("header-cell".equals(w.getStylePrimaryName()) && w instanceof HasText && text.equals(((HasText)w).getText())) { return 1 + i; } } return -1; }
public int getRow(String text) { for (int row = 0; row < getRowCount(); row ++) { if (getCellCount(row) > 1) { Widget w = getWidget(row, 0); if (w instanceof HasText && text.equals(((HasText)w).getText())) return row; } } return -1; }
public void setText(String html) { if (iReadOnly == null) { iReadOnly = new P("label"); iReadOnly.setVisible(!getWidget().isVisible()); if (iPrint != null) iReadOnly.addStyleName("unitime-NoPrint"); insert(iReadOnly, 1); } if (iReadOnly instanceof HasHTML) { ((HasHTML)iReadOnly).setHTML(html); } else if (iReadOnly instanceof HasText) { ((HasText)iReadOnly).setText(html); } }
public static boolean validate(String url, HasText errorWidget) { if(url != null && url.trim().length() > 0) { try { UrlParser.parse(url.trim()); return true; } catch(Exception e) { if(errorWidget != null) { errorWidget.setText(e.getMessage()); } } } return false; }
@Override public void processDataAdapter(Object object, Object context, String property, Class<?> srcType, DataAdapterInfo res) { // try to guess the HasValue type res.setDataType(Object.class); if (object instanceof HasText) { res.setDataType(String.class); } String debugString = ""; // try to find a converter if dataType does not match srcType Class<?> dataType = res.getDataType(); if (srcType != null && dataType != null && dataType != srcType && srcType != Property.class) { // try to find a converter, if not : fail res.setConverter(DefaultConverters.findConverter(srcType, dataType)); if (res.getConverter() == null) { debugString = "[ERROR: Cannot find converter from " + srcType + " to " + dataType + "]"; } else { debugString = "[" + srcType.getSimpleName() + ">" + dataType.getSimpleName() + "] " + debugString; } } debugString += "\"" + property + ".$HasValue\""; res.setDebugString(debugString); res.setAdapter(new CompositePropertyAdapter(context, property + ".$HasValue")); }
protected void renderCell(Context context, T value, SafeHtmlBuilder sb) { if (editor != null) { String display = null; T oldValue = ((HasValue<T>) editor).getValue(); ((HasValue<T>) editor).setValue(value); try { display = ((HasText) editor).getText(); } finally { ((HasValue<T>) editor).setValue(oldValue); } sb.appendEscaped(display != null ? display : ""); } else { sb.appendEscaped(value != null ? value.toString() : ""); } }
@Override public void readImageParagraph(Element anElement, final UIObject aImageParagraph) throws Exception { if (Utils.hasAttribute(anElement, "i", "icon") && aImageParagraph instanceof HasImageResource) { String iconImage = Utils.getAttribute(anElement, "i", "icon", null); PlatypusImageResource.load(iconImage, new CallbackAdapter<ImageResource, String>() { @Override protected void doWork(ImageResource aResult) throws Exception { ((HasImageResource) aImageParagraph).setImageResource(aResult); } @Override public void onFailure(String reason) { Logger.getLogger(PlatypusWindow.class.getName()).log(Level.SEVERE, "Factory failed to load button icon. " + reason); } }); } if (Utils.hasAttribute(anElement, "tx", "text") && aImageParagraph instanceof HasText) { ((HasText) aImageParagraph).setText(Utils.getAttribute(anElement, "tx", "text", null)); } if (aImageParagraph instanceof HasImageParagraph) { HasImageParagraph hip = (HasImageParagraph) aImageParagraph; hip.setHorizontalAlignment(Utils.getIntegerAttribute(anElement, "ha", "horizontalAlignment", aImageParagraph instanceof ImageButton || aImageParagraph instanceof DropDownButton ? HasImageParagraph.CENTER : HasImageParagraph.LEFT)); hip.setVerticalAlignment(Utils.getIntegerAttribute(anElement, "va", "verticalAlignment", HasImageParagraph.CENTER)); hip.setIconTextGap(Utils.getIntegerAttribute(anElement, "itg", "iconTextGap", 4)); hip.setHorizontalTextPosition(Utils.getIntegerAttribute(anElement, "htp", "horizontalTextPosition", HasImageParagraph.RIGHT)); hip.setVerticalTextPosition(Utils.getIntegerAttribute(anElement, "vtp", "verticalTextPosition", HasImageParagraph.CENTER)); } }
private void handleValueAttribute(TextFieldGVO gvo, UIObject uiObject) { String value = gvo.getValue(); if ((value != null) && (value.length() > 0)) { if (uiObject instanceof HasData) { HasData hasData = (HasData)uiObject; hasData.setData(value, SetValueGVO.ACTION_ADD, null); } else if (uiObject instanceof HasText) { HasText hasText = (HasText)uiObject; String oldValue = hasText.getText(); hasText.setText(value); doDataChange(gvo, uiObject, oldValue, hasText.getText()); } } }
public String getText() { if (textbox instanceof HasText) { return ((HasText)textbox).getText(); } if (textbox instanceof QValueSpinner) { return ((QValueSpinner)textbox).getTextBox().getText(); } return null; }
private void doItemValueChange(ValueChangeEvent<Boolean> event) { Object value = event.getValue(); UIObject source = (UIObject)event.getSource(); if (source instanceof HasText) { value = ((HasText)source).getText(); } fireDataChange(uiObject, null, value); }
private void handleDisplayName(UIObject uiObject, BuiltInComponentGVO builtInComponentGVO, String value) { if (uiObject instanceof HasDataGridMethods) { HasDataGridMethods hasDataGridMethods = (HasDataGridMethods)uiObject; String uuid = builtInComponentGVO.getComponentIdUUID(); if (uuid != null) { boolean containsColumn = uuid.contains("."); if (containsColumn) { String columnId = uuid.replaceFirst(".+\\.", "").replaceFirst("\\|.+", ""); hasDataGridMethods.setColumnLabel(columnId, value); } } } else if (uiObject instanceof PushButton) { ((PushButton)uiObject).getUpFace().setText(value); ((PushButton)uiObject).getDownFace().setText(value); } else if (uiObject instanceof HasText) { HasText t = (HasText)uiObject; t.setText(value); } else if (uiObject instanceof VerticalPanel) { VerticalPanel vp = (VerticalPanel)uiObject; Widget tabPanelWidget = vp.getParent().getParent().getParent(); if (tabPanelWidget instanceof TabPanel) { TabPanel tp = (TabPanel)tabPanelWidget; TabBar tb = tp.getTabBar(); int tabCount =tp.getWidgetCount(); for (int i=0;i < tabCount;i++){ Widget w = tp.getWidget(i); if (w == vp){ tb.setTabText(i, value); } } } } else if (uiObject instanceof QWindowPanel) { QWindowPanel p = (QWindowPanel) uiObject; p.setCaption(value); } }
private void copy(CopyGVO copyGVO, UIObject sender, String appId, String windowId, String eventSessionId) { String toKey = generateId(copyGVO.getTo(), windowId, appId, eventSessionId); String fromKey = generateId(copyGVO.getFrom(), windowId, appId, eventSessionId); List<UIObject> uiObjectsFrom = getUIObjects(fromKey); if (uiObjectsFrom == null) { return; } List<UIObject> uiObjectsTo = getUIObjects(toKey); if (uiObjectsTo == null) { return; } if (uiObjectsTo.size()==uiObjectsFrom.size()){ for (int i=0;i<uiObjectsTo.size();i++){ UIObject uiObjectFrom = uiObjectsFrom.get(i); UIObject uiObjectTo = uiObjectsTo.get(i); if (uiObjectFrom instanceof HasText) { HasText hasTextFrom = (HasText) uiObjectFrom; String fromValue = hasTextFrom.getText(); if (uiObjectTo instanceof HasText) { HasText hasTextTo = (HasText) uiObjectTo; hasTextTo.setText(fromValue); } } } } }
public static Object getValue(UIObject uiObject, final UIObject sender, boolean idValueOnly , String groupName) { Object returnObject = null; if (uiObject instanceof QPagingScrollTable) { returnObject = getValue((QPagingScrollTable) uiObject, groupName); } else if (uiObject instanceof QRadioButton) { returnObject = getValue((QRadioButton) uiObject); } else if (uiObject instanceof HasData) { returnObject = getValue((HasData) uiObject); } else if (uiObject instanceof CheckBox) { returnObject = getValue((CheckBox) uiObject); } else if (uiObject instanceof FormPanel) { returnObject = getValue((FormPanel) uiObject); } else if (uiObject instanceof ListBox) { returnObject = getValue((ListBox) uiObject, idValueOnly); } else if (uiObject instanceof QDatePicker) { returnObject = getValue((QDatePicker) uiObject); } else if (uiObject instanceof HasText) { returnObject = getValue((HasText) uiObject); } else if (uiObject instanceof MapWidget) { returnObject = getValue((MapWidget) uiObject, sender); } else if (uiObject instanceof Image) { returnObject = getValue((Image) uiObject); } else if (uiObject instanceof ValueSpinner) { returnObject = getValue((ValueSpinner) uiObject); } else if (uiObject instanceof Tiles) { returnObject = getValue((Tiles) uiObject, sender); } else if (uiObject instanceof SliderBar) { returnObject = getValue((SliderBar) uiObject); } else if (isDataGridField(uiObject)) { returnObject = getDataGridValue(sender); } return returnObject; }
private static String getValue(HasText hasText) { String value = hasText.getText(); if (hasText instanceof UIObject) { handleSimpleValue((UIObject) hasText, value); } return value; }
public void execute(BuiltInFunctionGVO builtInFunction) { if (builtInFunction instanceof CopyGVO) { CopyGVO copy = (CopyGVO) builtInFunction; List<UIObject> uiObjectsFrom = null; if (copy.getFromGVO().getComponentIdUUID() != null) { uiObjectsFrom = RendererHelper.getComponent(copy.getFromGVO().getComponentIdUUID()); } else { uiObjectsFrom = RendererHelper.getNamedComponent(copy.getFromGVO().getComponentName()); } List<UIObject> uiObjectsTo = null; if (copy.getToGVO().getComponentIdUUID() != null) { uiObjectsTo = RendererHelper.getComponent(copy.getToGVO().getComponentIdUUID()); } else { uiObjectsTo = RendererHelper.getNamedComponent(copy.getToGVO().getComponentName()); } if (uiObjectsTo != null && uiObjectsFrom != null) { if (uiObjectsTo.size()==uiObjectsFrom.size()){ for (int i=0;i<uiObjectsTo.size();i++){ UIObject uiObjectFrom = uiObjectsFrom.get(i); UIObject uiObjectTo = uiObjectsTo.get(i); if (uiObjectFrom instanceof HasText) { HasText hasTextFrom = (HasText) uiObjectFrom; String fromValue = hasTextFrom.getText(); if (uiObjectTo instanceof HasText) { HasText hasTextTo = (HasText) uiObjectTo; hasTextTo.setText(fromValue); } } } } } } FunctionsExecutor.setProcessedBuiltIn(true); }
private ListItem change2TextListItem(Widget w) { String text = null; if (w instanceof HasText) { text = ((HasText) w).getText(); } else { text = w.getElement().getInnerText(); } ListItem newest = new ListItem(); newest.setStyleName(Utils.avroUiStyle.active()); newest.getElement().appendChild(Document.get().createTextNode(text)); return newest; }
private void buildUrl() { // String params = ""; if (gadgetSettings.getGadgetSettings().size() > 0 /* || urlParams.size() > 0 */) { for (GadgetSetting g: gadgetSettings.getGadgetSettings()) { String value = ""; if (g.getWidget() instanceof CheckBox) { value = ((CheckBox) g.getWidget()).getValue() ? "true" : "false"; } else if (g.getWidget() instanceof RiseListBox) { value = ((RiseListBox)g.getWidget()).getSelectedValue(); } // else if (g.widget instanceof TextBox || g.widget instanceof ColorPickerTextBox || g.widget instanceof TextStyleWidget) // value = URL.encodeQueryString(((HasText)g.widget).getText())); else if (g.getWidget() instanceof HasText) value = URL.encodeQueryString(((HasText)g.getWidget()).getText()); // else if (g.widget instanceof Hidden) // value = URL.encodeQueryString(((Hidden)g.widget).getValue()); // urlParams.put("up_" + g.getName(), value); g.setValue(value); } // for (Map.Entry<String, String> obj: urlParams.entrySet()) { // if (obj.getValue() != null && !obj.getValue().isEmpty()) { // params += "&" + obj.getKey() + "=" + obj.getValue(); // } // } // // if (params.length() > 0) // params = "&" + params.substring(1); // gadgetUrl = (gadgetSettings.getGadgetXmlUrl() + params).trim(); // gadgetUrl = gadgetSettings.getGadgetUrl(); } }
public DefaultSettingWidget(HasText textBox) { this.textBox = textBox; HorizontalPanel mainPanel = new HorizontalPanel(); mainPanel.add((Widget) textBox); mainPanel.setCellWidth((Widget) textBox, "450px"); mainPanel.add(new HTML("<span style='padding-left:20px'></span>")); mainPanel.add(defaultHyperlink); initHandlers(); initWidget(mainPanel); }
private Object getUiElementValue(FormValidatorInfo formValidator) { Object value = null; if (formValidator.getUiElement() instanceof HasValue<?>) value = ((HasValue<?>)formValidator.getUiElement()).getValue(); else if (formValidator.getUiElement() instanceof HasText) value = ((HasText)formValidator.getUiElement()).getText(); return value; }
/** * Set the text of the button. */ public void setText(String text) { this.text = text; if (button instanceof HasText) { ((HasText) button).setText(text); updateSize(); } }
/** * This constructor allows to use an existing form panel. * * @param type * file input to use * @param status * Customized status widget to use * @param submitButton * Customized button which submits the form * @param form * Customized form panel */ public SingleUploader(FileInputType type, IUploadStatus status, Widget submitButton, FormPanel form) { super(type, form); final Uploader thisInstance = this; if (status == null) { status = new BaseUploadStatus(); super.add(status.getWidget()); } super.setStatusWidget(status); this.button = submitButton; if (submitButton != null) { submitButton.addStyleName("submit"); if (submitButton instanceof HasClickHandlers) { ((HasClickHandlers)submitButton).addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { thisInstance.submit(); } }); } if (submitButton instanceof HasText) { ((HasText)submitButton).setText(I18N_CONSTANTS.uploaderSend()); } // The user could have attached the button anywhere in the page. if (!submitButton.isAttached()) { super.add(submitButton); } } }
@Override public void setI18Constants(UploaderConstants strs) { super.setI18Constants(strs); if (button != null && button instanceof HasText) { ((HasText)button).setText(strs.uploaderSend()); } }
protected Object getFieldValue(FormField field) { if (field.getWidget() instanceof HasValue) { return ((HasValue) field.getWidget()).getValue(); } else if (field.getWidget() instanceof TakesValue) { return ((TakesValue) field.getWidget()).getValue(); } else if (field.getWidget() instanceof HasText) { return ((HasText) field.getWidget()).getText(); } throw new IllegalStateException("Unexpected widget type: impossible to read the value"); }
public FlagToggle(Button target, HasText text, String flag) { this.target = target; this.text = text; this.flag = flag; refresh(); }
@Override public HasText getDescription() { return descriptionLabel; }
public HasText getFirstName() { return firstName; }
public HasText getLastName() { return lastName; }