continue;
}
- // Ignore variable change
- String msg = "Warning: Ignoring variable change for ";
- if (owner != null) {
- msg += "disabled component " + owner.getClass();
- String caption = ((Component) owner).getCaption();
- if (caption != null) {
- msg += ", caption=" + caption;
+ final VariableOwner owner = getVariableOwner(invocation
+ .getPaintableId());
+
+ if (owner != null && owner.isEnabled()) {
+ VariableChange change = new VariableChange(invocation);
+
+ // TODO could optimize with a single value map if only one
+ // change for a paintable
+
+ Map<String, Object> m = new HashMap<String, Object>();
+ m.put(change.getName(), change.getValue());
+ while (nextInvocation != null
+ && invocation.getPaintableId().equals(
+ nextInvocation.getPaintableId())
+ && ApplicationConnection.UPDATE_VARIABLE_METHOD
+ .equals(nextInvocation.getMethodName())) {
+ i++;
+ invocation = nextInvocation;
+ change = new VariableChange(invocation);
+ m.put(change.getName(), change.getValue());
+ if (i + 1 < invocations.size()) {
+ nextInvocation = invocations.get(i + 1);
+ } else {
+ nextInvocation = null;
+ }
+ }
+
+ try {
+ changeVariables(source, owner, m);
+ } catch (Exception e) {
++ Component errorComponent = null;
+ if (owner instanceof Component) {
- handleChangeVariablesError(app, (Component) owner,
- e, m);
- } else {
- // TODO DragDropService error handling
- throw new RuntimeException(e);
++ errorComponent = (Component) owner;
++ } else if (owner instanceof DragAndDropService) {
++ if (m.get("dhowner") instanceof Component) {
++ errorComponent = (Component) m.get("dhowner");
++ }
+ }
++ handleChangeVariablesError(app, errorComponent, e, m);
}
} else {
- msg += "non-existent component, VAR_PID="
- + variable[VAR_PID];
- success = false;
+ // TODO convert window close to a separate RPC call and
+ // handle above - not a variable change
+
+ VariableChange change = new VariableChange(invocation);
+
+ // Handle special case where window-close is called
+ // after the window has been removed from the
+ // application or the application has closed
+ if ("close".equals(change.getName())
+ && Boolean.TRUE.equals(change.getValue())) {
+ // Silently ignore this
+ continue;
+ }
+
+ // Ignore variable change
+ String msg = "Warning: Ignoring RPC call for ";
+ if (owner != null) {
+ msg += "disabled component " + owner.getClass();
+ String caption = ((Component) owner).getCaption();
+ if (caption != null) {
+ msg += ", caption=" + caption;
+ }
+ } else {
+ msg += "non-existent component, VAR_PID="
+ + invocation.getPaintableId();
+ // TODO should this cause the message to be ignored?
+ success = false;
+ }
+ logger.warning(msg);
+ continue;
}
- logger.warning(msg);
- continue;
}
+
+ } catch (JSONException e) {
+ logger.warning("Unable to parse RPC call from the client: "
+ + e.getMessage());
+ // TODO or return success = false?
+ throw new RuntimeException(e);
}
+
return success;
}