/** * Execute the script with the specified variable values. * * @param variables A mapped of named variable values. * @return Result of the script execution. */ public Object execute(Map<String, Object> variables) { Map<String, Object> vars = new HashMap<>(); BaseComponent self = this.self.getReference(); vars.put(getSelfName(), self); if (includeNamedComponents && self != null) { vars.putAll(self.findAllNamed()); } if (variables != null) { vars.putAll(variables); } return _execute(vars); }
/** * Handle changes to published properties that are component references. If the old and new * values are the same, no action is taken. Otherwise, the client is notified of the new value * (if syncToClient is true) and a {@link PropertychangeEvent} is fired. * * @param <T> The type of the referenced component. * @param propertyName The property name. * @param reference The property reference object. * @param newValue The new value. * @param syncToClient If true, notify client of change. * @return True if property value changed. */ protected <T extends BaseComponent> boolean propertyChange(String propertyName, ComponentReference<T> reference, T newValue, boolean syncToClient) { T oldValue = reference.getReference(); if (reference.setReference(newValue)) { propertyChange(propertyName, oldValue, newValue, false); if (syncToClient) { sync(propertyName, reference); } return true; } return false; }
/** * Sets the component to be referenced by the script language's "self" variable. If "self" is * explicitly included in the variable map passed to {@link #execute(Map)}, that value will be * used instead. * * @param self The component to be referenced by the script language's "self" variable. */ @PropertySetter(value = "self", description = "The component to be referenced by the script language's \"self\" variable.") public void setSelf(BaseComponent self) { BaseComponent oldSelf = this.self.getReference(); if (oldSelf != self) { this.self.setReference(self); propertyChange("self", oldSelf, self, false); } }
/** * If the child being removed is the popup, set the popup to null. * * @see org.fujion.component.BaseComponent#afterRemoveChild(org.fujion.component.BaseComponent) */ @Override protected void afterRemoveChild(BaseComponent child) { super.afterRemoveChild(child); if (child == popup.getReference()) { setPopup(null); } }
/** * Returns the popup component that will appear when hovering over this component. * * @return The popup component that will appear when hovering over this component. */ @PropertyGetter(value = "popup", description = "The popup component that will appear when hovering over this component.") public Popup getPopup() { return popup == null ? null : popup.getReference(); }
/** * Returns the component referenced by the script language's "self" variable. By default, it is * the script component itself. If "self" is explicitly included in the variable map passed to * {@link #execute(Map)}, that value will be used instead. * * @return The component referenced by the script language's "self" variable. */ @PropertyGetter(value = "self", description = "The component to be referenced by the script language's \"self\" variable.") public BaseComponent getSelf() { return self.getReference(); }
/** * Returns the popup component that will appear when right-clicking on this component. * * @return The popup component that will appear when right-clicking on this component. */ @PropertyGetter(value = "context", description = "The popup component that will appear when right-clicking on this component.") public Popup getContext() { return context == null ? null : context.getReference(); }