예제 #1
0
  /** have a look at the supplied editors, find which properties are common */
  protected static MWC.GUI.Tools.SubjectAction[] getUndoableActionsFor(final Editable[] editables) {
    MWC.GUI.Tools.SubjectAction[] res = null;
    final MWC.GUI.Tools.SubjectAction[] demo = new MWC.GUI.Tools.SubjectAction[] {};

    // right, get the first set of properties
    if (editables.length > 0) {
      final Editable first = editables[0];
      final EditorType firstInfo = first.getInfo();
      if (firstInfo != null) {
        res = firstInfo.getUndoableActions();

        // only continue if there are any methods to compare against
        if (res != null) {
          // right, are there any more?
          if (editables.length > 1) {
            // pass through the others, finding the common ground
            for (int cnt = 1; cnt < editables.length; cnt++) {
              final Editable thisE = editables[cnt];

              // get its props
              final EditorType thisEditor = thisE.getInfo();

              // do we have an editor?
              if (thisEditor != null) {
                final MWC.GUI.Tools.SubjectAction[] newSet = thisEditor.getUndoableActions();

                // find the common ones
                res = (MWC.GUI.Tools.SubjectAction[]) getIntersectionFor(res, newSet, demo);
              }
            }
          }
        }
      }
    }
    return res;
  }