protected void bind() { if (data != null && field != null && !field.isEmpty() && Scripts.isInitialized()) { boundToData = Scripts.getSpace().listen(data, field, new AbstractJSObject() { @Override public Object call(Object thiz, Object... args) { rebind(); return null; } }); Object oData = ModelWidget.getPathData(data, field); setJsValue(oData); boundToValue = (PropertyChangeEvent evt) -> { if (!settingValueFromJs) { settingValueToJs = true; try { ModelWidget.setPathData(data, field, Scripts.getSpace().toJs(evt.getNewValue())); } finally { settingValueToJs = false; } } }; addValueChangeListener(boundToValue); } else { setJsValue(null); } }
boundToData = Scripts.getSpace().listen(data, field, new AbstractJSObject() {
@Override public void setPublished(JSObject aValue) { if (published != null && Scripts.isInitialized()) { throw new AlreadyPublishedException(); } published = aValue; if (Scripts.isInitialized()) { Scripts.getSpace().listen(published, "cursor", new AbstractJSObject() { @Override public boolean isFunction() { return true; } @Override public Object call(Object thiz, Object... args) { try { resignOnCursor(); internalExecuteChildren(false); } catch (Exception ex) { Logger.getLogger(ApplicationEntity.class.getName()).log(Level.SEVERE, null, ex); } return null; } }); } }
protected void resignOnCursor() { if (cursorListener != null) { cursorListener.remove(); cursorListener = null; } if (published != null && published.getMember(CURSOR_PROP_NAME) instanceof JSObject) { JSObject jsCursor = (JSObject) published.getMember(CURSOR_PROP_NAME); JSObject jsReg = Scripts.getSpace().listen(jsCursor, "", new AbstractJSObject() { @Override public boolean isFunction() { return true; } @Override public Object call(Object thiz, Object... args) { try { internalExecuteChildren(false); } catch (Exception ex) { Logger.getLogger(ApplicationEntity.class.getName()).log(Level.SEVERE, null, ex); } return null; } }); cursorListener = () -> { Scripts.unlisten(jsReg); }; } } protected static final String CURSOR_PROP_NAME = "cursor";
protected void bind() { if (data != null && Scripts.isInitialized()) { boundToData = Scripts.getSpace().listen(data, "length", new AbstractJSObject() { @Override public Object call(Object thiz, Object... args) { enqueueElementsChanged(); return null; } }); } }
protected void bindCursor(JSObject aModelData) { if (aModelData != null) { boundToCursor = Scripts.getSpace().listen(aModelData, cursorProperty, new AbstractJSObject() { @Override public Object call(Object thiz, Object... args) { ModelGrid.this.invalidate(); ModelGrid.this.repaint(); return null; } }); } }
protected void bindList() { if (displayList != null && Scripts.isInitialized()) { boundToList = Scripts.getSpace().listen(displayList, "length", new AbstractJSObject() { @Override public Object call(Object thiz, Object... args) { enqueueListChanged(); return null; } }); } }