Ejemplo n.º 1
0
  /**
   * Refresh a property feature and/or value of iUserSession session.
   *
   * @param iUserSession The User Session
   * @param iUserObject The User Object of changed property
   * @param iFieldNames Optional field names to signal the change
   */
  public static void fieldChanged(
      SessionInfo iUserSession, Object iUserObject, String... iFieldNames) {
    if (iUserObject == null) return;

    if (iUserSession == null) iUserSession = component(SessionAspect.class).getActiveSessionInfo();

    List<FieldRefreshListener> listeners =
        Controller.getInstance().getListeners(FieldRefreshListener.class);

    synchronized (listeners) {
      SchemaObject sObj = Roma.session().getSchemaObject(iUserObject);
      if (sObj == null) return;

      if (iFieldNames == null || iFieldNames.length == 0) {
        // REFRESH ALL FIELDS
        for (Iterator<SchemaField> it = sObj.getFieldIterator(); it.hasNext(); )
          signalFieldChanged(iUserSession, iUserObject, listeners, sObj, it.next().getName());
      } else {
        // REFRESH PASSED FIELDS
        for (String fieldName : iFieldNames) {
          signalFieldChanged(iUserSession, iUserObject, listeners, sObj, fieldName);
        }
      }
    }
  }
Ejemplo n.º 2
0
  public static <T> boolean setFeature(
      Object iUserObject, String elementName, Feature<T> feature, T value) {
    SchemaFeatures features = getSchemaFeature(iUserObject, elementName, feature);

    if (features == null) return false;
    T oldValue = features.getFeature(feature);
    features.setFeature(feature, value);
    // BROADCAST CHANGES TO ALL REGISTERED LISTENERS
    List<SchemaFeaturesChangeListener> listeners =
        Controller.getInstance().getListeners(SchemaFeaturesChangeListener.class);
    if (listeners != null)
      switch (feature.getType()) {
        case ACTION:
          for (SchemaFeaturesChangeListener listener : listeners) {
            listener.signalChangeAction(iUserObject, elementName, feature, oldValue, value);
          }

          break;
        case FIELD:
          for (SchemaFeaturesChangeListener listener : listeners) {
            listener.signalChangeField(iUserObject, elementName, feature, oldValue, value);
          }
          break;
        case EVENT:
          break;
        case CLASS:
          for (SchemaFeaturesChangeListener listener : listeners) {
            listener.signalChangeClass(iUserObject, feature, oldValue, value);
          }
        default:
          break;
      }
    return true;
  }
Ejemplo n.º 3
0
  /**
   * Refresh an object.
   *
   * @see ObjectContext#objectChanged(SessionInfo, Object)
   * @param iUserSession The User Session
   * @param iUserObject The User Object of changed property
   */
  public static void objectChanged(SessionInfo iUserSession, Object iUserObject) {
    if (iUserObject == null) return;

    if (iUserSession == null) iUserSession = Roma.session().getActiveSessionInfo();

    List<ObjectRefreshListener> listeners =
        Controller.getInstance().getListeners(ObjectRefreshListener.class);

    for (ObjectRefreshListener objectRefreshListener : listeners) {
      objectRefreshListener.onObjectRefresh(iUserSession, iUserObject);
    }
  }
Ejemplo n.º 4
0
 protected Roma() {
   Controller.getInstance().registerListener(ScriptingAspectListener.class, this);
 }