public void updateText() { if (hasVars && (menuItem != null) && (originalValue != null)) { iWidget w = (contextWidget == null) ? Platform.getContextRootViewer() : contextWidget; menuItem.setText(w.expandString((String) originalValue, false)); } }
@Override public void actionPerformed(ActionEvent e) { iWidget w = this.context; if (w == null) { w = Platform.getContextRootViewer(); } iScriptHandler sh = w.getScriptHandler(); if (code instanceof String) { code = sh.compile(w.getScriptingContext(), "scriptActionListener", (String) code); } Object s = (this.source == null) ? w : this.source; aWidgetListener.execute( context, sh, code, iConstants.EVENT_ACTION, new ActionEvent(s, "onAction")); }
public Node(iWidget widget) { this.widget = widget; SPOTSequence e = (SPOTSequence) widget.getLinkedData(); iSPOTElement na = e.spot_elementFor("name"); this.name = na == null ? null : na.spot_stringValue(); this.typeName = e.spot_getClassShortName(); if (name == null) { name = typeName; } if (widget instanceof iContainer) { iContainer c = (iContainer) widget; int len = c.getWidgetCount(); for (int i = 0; i < len; i++) { addChild(new Node(c.getWidget(i))); } } }
@Override public Object objectFromString(iWidget widget, String value, Object context) { if (context == TITLECASE_CONTEXT) { value = ((value == null) || (value.length() == 0)) ? value : perThreadCharArray.get().set(value).toTitleCase().toString(); } else if (context == TITLECASE_CLEAN_CONTEXT) { if ((value != null) && (value.length() > 0)) { CharArray ca = perThreadCharArray.get(); try { CharScanner.cleanQuoted(value, ca); } catch (ParseException ex) { ca.set(value); } value = ca.toTitleCase().toString(); } } else if ((context != null) && ((ConverterContext) context).getName().equals("html")) { String style = (String) ((ConverterContext) context).getUserObject(); if (value == null) { return (style == null) ? null : "<html></html>"; } return (style == null) ? "<html>" + value + "</html>" : "<html>" + style + value + "</html>"; } else if (context == CAPITALIZE_CONTEXT) { value = ((value == null) || (value.length() == 0)) ? value : perThreadCharArray.get().set(value).toTitleCase().toString(); } else if (context == CAPITALIZE_CLEAN_CONTEXT) { if ((value != null) && (value.length() > 0)) { CharArray ca = perThreadCharArray.get(); try { CharScanner.cleanQuoted(value, ca); } catch (ParseException ex) { ca.set(value); } ca.toLowerCase(); ca.A[0] = Character.toUpperCase(ca.A[0]); value = ca.toString(); } } else if ((context instanceof ConverterContext) && (context != PASSWORD_CONTEXT)) { ConverterContext sc = (ConverterContext) context; try { value = CharScanner.cleanQuoted(value); } catch (ParseException e) { Platform.ignoreException(null, e); } if (sc == RESOURCE_CONTEXT) { String s = widget.getAppContext().getResourceAsString(value); if ((s != null) && (s.length() > 0)) { value = s; } } else if (sc != EXPANDER_CONTEXT) { String format = sc.getName(); if ((format != null) && (format.indexOf("%s") != -1)) { value = PlatformHelper.format(format, value); int min = (minValue instanceof Number) ? ((Number) minValue).intValue() : -1; int max = (maxValue instanceof Number) ? ((Number) maxValue).intValue() : Integer.MAX_VALUE; if ((value.length() < min) || (value.length() > max)) { throw new FormatException(Utils.makeInvalidRangeString(min, max)); } } } } return value; }