Esempio n. 1
0
 public void lastItem() {
   _value = new JComboBox<String>(_itemArray);
   // finish initialization
   _value.setActionCommand("");
   _defaultColor = _value.getBackground();
   _value.setBackground(COLOR_UNKNOWN);
   _value.setOpaque(true);
   // connect to the JComboBox model and the CV so we'll see changes.
   _value.addActionListener(this);
   CvValue cv = _cvMap.get(getCvNum());
   cv.addPropertyChangeListener(this);
   cv.setState(CvValue.FROMFILE);
 }
  public IndexedPairVariableValue(
      String name,
      String comment,
      String cvName,
      boolean readOnly,
      boolean infoOnly,
      boolean writeOnly,
      boolean opsOnly,
      String cvNum,
      String mask,
      int minVal,
      int maxVal,
      HashMap<String, CvValue> v,
      JLabel status,
      String stdname,
      String pSecondCV,
      int pFactor,
      int pOffset,
      String uppermask,
      boolean upperFirst) {
    super(
        name, comment, cvName, readOnly, infoOnly, writeOnly, opsOnly, cvNum, mask, v, status,
        stdname);
    _mask = mask;
    _uppermask = uppermask;
    _maxVal = maxVal;
    _minVal = minVal;
    mSecondCVname = pSecondCV;
    int len = 4;
    if (maxVal > 999) {
      len = 5;
    }
    if (maxVal > 9999) {
      len = 6;
    }
    _value = new JTextField("0", len);
    _defaultColor = _value.getBackground();
    _value.setBackground(COLOR_UNKNOWN);
    _upperFirst = upperFirst;
    mFactor = pFactor;
    mOffset = pOffset;
    if (log.isDebugEnabled()) {
      log.debug(
          "CV "
              + getCvName()
              + ","
              + getSecondCvNum()
              + " mfactor "
              + mFactor
              + " and mOffset="
              + mOffset);
    }

    // connect to the JTextField value, cv
    _value.addActionListener(this);
    _value.addFocusListener(this);

    lowerbitmask = maskVal(mask);
    lowerbitoffset = offsetVal(mask);
    upperbitmask = maskVal(uppermask);

    // upper bit offset includes lower bit offset, and MSB bits missing from upper part
    upperbitoffset = offsetVal(uppermask);
    String t = mask;
    while (t.length() > 0) {
      if (!t.startsWith("V")) {
        upperbitoffset++;
      }
      t = t.substring(1);
    }
    if (log.isDebugEnabled()) {
      log.debug(
          "CV "
              + getCvName()
              + ","
              + getSecondCvNum()
              + " upper mask "
              + uppermask
              + " had offsetVal="
              + offsetVal(uppermask)
              + " so upperbitoffset="
              + upperbitoffset);
    }

    // connect for notification
    CvValue cv = (_cvMap.get(getCvName()));
    cv.addPropertyChangeListener(this);
    cv.setState(CvValue.FROMFILE);
    CvValue cv1 = (_cvMap.get(mSecondCVname));
    cv1.addPropertyChangeListener(this);
    cv1.setState(CvValue.FROMFILE);
  }