Esempio n. 1
0
 private void init() {
   constructedTimes++;
   id = constructedTimes;
   Err.pr("####### Have created DebugList " + id);
   if (id == 0) {
     Err.stack();
   }
 }
Esempio n. 2
0
 /** Should not be used directly by Strandz. See package org.strandz.core.info.convert */
 public static String _getText(Object comp) {
   String result = null;
   Err.pr(SdzNote.DONT_USE_FROM_STRANDZ, "Don't use");
   if (comp instanceof JComponent) {
     if (comp instanceof JTextComponent) {
       result = ((JTextComponent) comp).getText();
     } else if (comp instanceof JLabel) {
       result = ((JLabel) comp).getText();
     } else {
       Err.error(
           "ComponentUtils.getText(), not yet support JComponent of type " + comp.getClass());
     }
   } else {
     Err.error("ComponentUtils.getText(), not yet support " + comp.getClass());
   }
   return result;
 }
Esempio n. 3
0
 /**
  * Should not be used directly by Strandz. See package org.strandz.core.info.convert This must
  * come out as Strandz needs control over assignment
  *
  * @param comp
  * @param txt
  */
 public static void _setText(Object comp, Object txt) {
   Err.pr(SdzNote.DONT_USE_FROM_STRANDZ, "Don't use");
   if (comp instanceof JComponent) {
     String s = null;
     if (txt != null) {
       s = txt.toString();
     }
     if (comp instanceof JTextComponent) {
       ((JTextComponent) comp).setText(s);
     } else if (comp instanceof JLabel) {
       ((JLabel) comp).setText(s);
     } else {
       Err.error(
           "ComponentUtils.setText(), not yet support JComponent of type " + comp.getClass());
     }
   } else {
     Err.error("ComponentUtils.setText(), not yet support " + comp.getClass());
   }
 }
Esempio n. 4
0
  public static boolean equalsByProperties(
      JComponent component1, JComponent component2, WidgetClassifierI widgetClassifier) {
    ReasonNotEquals.addClassVisiting("pUtils.equalsByProperties()");

    boolean result = true;
    List oneControls = getAllControls(component1);
    oneControls.add(0, component1);

    List twoControls = getAllControls(component2);
    twoControls.add(0, component2);
    if (oneControls.size() != twoControls.size()) {
      ReasonNotEquals.addReason(
          "got lists of controls of different sizes: "
              + oneControls.size()
              + " and "
              + twoControls.size());
      Print.prList(oneControls, "oneControls");
      Print.prList(twoControls, "twoControls");
      result = false;
    } else {
      for (int i = 0; i < oneControls.size(); i++) {
        Container comp1 = (Container) oneControls.get(i);
        // Err.pr( "Observing a " + comp1.getClass());
        Container comp2 = (Container) twoControls.get(i);
        if (comp1.getClass() != comp2.getClass()) {
          ReasonNotEquals.addReason(
              "first component is of type "
                  + comp1.getClass()
                  + " while second is of type "
                  + comp2.getClass());
          result = false;
          break;
        } else if (!Utils.equals(comp1.getName(), comp2.getName())) {
          ReasonNotEquals.addReason(
              "first component has name "
                  + comp1.getName()
                  + " while second has name "
                  + comp2.getName());
          result = false;
          break;
        } else if (widgetClassifier != null
            && !widgetClassifier.isAWidget(
                comp1.getClass())) { // If a comp1/comp2 is not a widget then end up here and we
          // won't examine
          // its properties
          // Err.pr( comp1.getClass() + " is not a widget: " + widgetClassifier.getReason());
        } else {
          List propertyNamesOne = new ArrayList();
          List propertyNamesTwo = new ArrayList();
          List propertyValuesOne = new ArrayList();
          List propertyValuesTwo = new ArrayList();
          loadPropertyNamesValues(comp1.getClass(), comp1, propertyNamesOne, propertyValuesOne);
          loadPropertyNamesValues(comp2.getClass(), comp2, propertyNamesTwo, propertyValuesTwo);
          if (propertyNamesOne.size() != propertyValuesOne.size()) {
            Err.error("expect names and properties to be same size for " + comp1.getClass());
          } else if (propertyNamesTwo.size() != propertyValuesTwo.size()) {
            Err.error("expect names and properties to be same size for " + comp2.getClass());
          } else if (propertyNamesOne.size() != propertyNamesTwo.size()) {
            ReasonNotEquals.addReason(
                "there should be an equal number of properties in "
                    + comp1.getClass()
                    + " and "
                    + comp2.getClass());
            result = false;
            break;
          } else {
            // Err.pr( "Will be examining properties from a " + comp1.getClass() + " against " +
            // comp2.getClass());
            for (int j = 0; j < propertyNamesOne.size(); j++) {
              String onePropName = (String) propertyNamesOne.get(j);
              String twoPropName = (String) propertyNamesTwo.get(j);
              if (!onePropName.equals(twoPropName)) {
                // If they are of thge same type, how could they possibly have
                // different property names, thus make this an error
                String txt =
                    "expect property names to be equal, got " + onePropName + " and " + twoPropName;
                // ReasonNotEquals.addReason( txt);
                Err.error(txt);
                result = false;
                break;
              } else {
                Object onePropValue = propertyValuesOne.get(j);
                Object twoPropValue = propertyValuesTwo.get(j);
                boolean debug = false;
                /*
                if(onePropName.equals( "text"))
                {
                Err.debug();
                debug = true;
                }
                */
                if (onePropValue.getClass() != twoPropValue.getClass()) {
                  Err.error(
                      "Property values to be examining should be of the same type, got "
                          + onePropValue.getClass().getName()
                          + " and "
                          + twoPropValue.getClass().getName());
                  result = false;
                  break;
                } else if (!Utils.isSimple(onePropValue.getClass())) {
                  // We only want to do value comparisons for simple types
                  // Err.pr( "Not simple: <" + onePropValue + ">");
                  if (debug) {
                    Err.error("Only supposed to be debugging on a simple property value");
                  }
                } else {
                  if (debug) {
                    Err.pr(
                        "Doing cf between <"
                            + onePropValue
                            + "> and <"
                            + twoPropValue
                            + "> for "
                            + onePropName
                            + " in a "
                            + comp1.getClass());
                    debug = false;
                  }
                  if (!onePropValue.equals(twoPropValue)) {
                    ReasonNotEquals.addReason(
                        "expect property values to be equal, got <"
                            + onePropValue
                            + "> and <"
                            + twoPropValue
                            + ">");
                    result = false;
                    break;
                  } else { // Err.pr( "\tconcordance, prop name " + onePropName + ", prop value " +
                    // onePropValue);
                  }
                }
              }
            }
            if (result == false) {
              break; // so break out of outer loop too
            }
          }
        }
      }
    }
    return result;
  }
Esempio n. 5
0
 public boolean add(Object o) {
   boolean result = super.add(o);
   Err.pr("$$$ DEBUG add[@2]: <" + o + "> to " + id);
   // Err.stack();
   return result;
 }
Esempio n. 6
0
 public void add(int index, Object o) {
   Err.pr("####### DEBUG add[@1]: <" + o + "> to " + id);
   // Err.stack();
   super.add(index, o);
 }
Esempio n. 7
0
 public boolean remove(Object obj) {
   Err.pr("####### DEBUG rem: <" + obj + "> from " + id);
   return super.remove(obj);
 }
Esempio n. 8
0
 public boolean addAll(Collection c) {
   Err.pr("####### DEBUG addAll: <" + c + "> to " + id);
   return super.addAll(c);
 }
Esempio n. 9
0
 public void clear() {
   Err.pr("####### DEBUG clear on " + id);
   super.clear();
 }