Exemple #1
0
 private long getInvalidFrom(DataRecord r) {
   long rv = r.getInvalidFrom();
   return (rv > 0 && rv < Long.MAX_VALUE ? rv : -1);
 }
  protected void iniDialog() throws Exception {
    // create GUI items
    mainPanel.setLayout(new GridBagLayout());

    ItemTypeLabel label1 =
        new ItemTypeLabel(
            "LABEL1",
            IItemType.TYPE_PUBLIC,
            "",
            International.getMessage(
                "Gültigkeitszeitraum von Version {version} ändern", version + 1));
    label1.setPadding(0, 0, 0, 10);
    label1.displayOnGui(this, mainPanel, 0, 0);

    validFrom =
        new ItemTypeDateTime(
            "VALID_FROM",
            (rCurrent.getValidFrom() == 0 ? null : new DataTypeDate(rCurrent.getValidFrom())),
            (rCurrent.getValidFrom() == 0 ? null : new DataTypeTime(rCurrent.getValidFrom())),
            IItemType.TYPE_PUBLIC,
            "",
            International.getString("gültig ab"));
    validFrom.registerItemListener(this);
    if (rPrev != null && rPrev.getValidFrom() != 0) {
      validFrom.setMustBeAfter(
          new ItemTypeDateTime(
              "PREVRECORD_VALID_FROM",
              new DataTypeDate(rPrev.getValidFrom()),
              new DataTypeTime(rPrev.getValidFrom()),
              IItemType.TYPE_INTERNAL,
              "",
              ""),
          false);
    }
    validFrom.setNotNull(rPrev != null);
    validFrom.displayOnGui(this, mainPanel, 0, 1);
    validFrom.requestFocus();
    validUntil =
        new ItemTypeDateTime(
            "VALID_UNTIL",
            (rCurrent.getInvalidFrom() == Long.MAX_VALUE
                ? null
                : new DataTypeDate(rCurrent.getInvalidFrom() - 1)),
            (rCurrent.getInvalidFrom() == Long.MAX_VALUE
                ? null
                : new DataTypeTime(rCurrent.getInvalidFrom() - 1)),
            IItemType.TYPE_PUBLIC,
            "",
            International.getString("gültig bis"));
    validUntil.registerItemListener(this);
    validUntil.setMustBeAfter(validFrom, true);
    if (rNext != null && rNext.getInvalidFrom() != Long.MAX_VALUE) {
      validUntil.setMustBeBefore(
          new ItemTypeDateTime(
              "NEXTRECORD_VALID_UNTIL",
              new DataTypeDate(rNext.getInvalidFrom() - 1),
              new DataTypeTime(rNext.getInvalidFrom() - 1),
              IItemType.TYPE_INTERNAL,
              "",
              ""),
          false);
    }
    validUntil.setNotNull(rNext != null);

    validUntil.displayOnGui(this, mainPanel, 0, 2);

    closeButton.setIcon(getIcon(BaseDialog.IMAGE_ACCEPT));
    closeButton.setIconTextGap(10);
  }