Beispiel #1
0
  /** Die Methode speichert den Inhalt des Text Felder in die Datenbank */
  private boolean addToDB() {
    myFrame.setCursorWait();
    Vector<ContainerAttribute> myAtt = new Vector<ContainerAttribute>();
    String objKey = ReqField.get(0).getText();

    if (objKey.isEmpty() == false) {
      for (int i = 1; i < ReqField.size(); i++) {
        if (ReqField.get(i).getAtt().size() != 0 && ReqField.get(i).getText().isEmpty() == false) {
          myAtt.addAll(ReqField.get(i).getAtt());
        }
      }
      for (int i = 0; i < OptField.size(); i++) {
        if (OptField.get(i).getAtt().size() != 0 && OptField.get(i).getText().isEmpty() == false) {
          myAtt.addAll(OptField.get(i).getAtt());
        }
      }
      int ret = -1;

      // New Entry
      if (isNewEntry == true) {
        if (theDb.getObject(objKey) == null) {
          ret =
              theDb.setObject(
                  new ContainerObject(
                      -1, theDb.convTypeNameToTypeId(this.entryTypeString), objKey, myAtt));
        } else {
          JOptionPane.showMessageDialog(
              null,
              Main.myLang.getString(Main.myLang.getString("textFildTab.existingkey.message")),
              Main.myLang.getString(Main.myLang.getString("textFildTab.existingkey.title")),
              JOptionPane.ERROR_MESSAGE);
        }
      }
      // Edit Entry
      else {
        if (theDb.getObject(objKey) != null) {
        } else {
          JOptionPane.showMessageDialog(
              null,
              Main.myLang.getString(Main.myLang.getString("textFildTab.changedkey.message")),
              Main.myLang.getString(Main.myLang.getString("textFildTab.changedkey.title")),
              JOptionPane.WARNING_MESSAGE);
        }
        ret =
            theDb.setObject(
                new ContainerObject(
                    obj.getId(), theDb.convTypeNameToTypeId(this.entryTypeString), objKey, myAtt));
      }

      // file into DB
      if (ret != -1) {
        try {
          theDb.setAllFiles(this.fileModel.getData(), ret);
          obj = theDb.getObject(ret);
          myFrame.setCursorNormal();
          return true;
        } catch (PacketTooBigException e) {
          JOptionPane.showMessageDialog(
              null,
              Main.myLang.getString(Main.myLang.getString("textFildTab.FileSizeToSmall.message")),
              Main.myLang.getString(Main.myLang.getString("textFildTab.FileSizeToSmall.title")),
              JOptionPane.ERROR_MESSAGE);
          myFrame.setCursorNormal();
        }
      }
      myFrame.setCursorNormal();
      return false;
    } else {
      JOptionPane.showMessageDialog(
          null,
          Main.myLang.getString(Main.myLang.getString("textFildTab.missingKey.message")),
          Main.myLang.getString(Main.myLang.getString("textFildTab.missingKey.title")),
          JOptionPane.ERROR_MESSAGE);
      myFrame.setCursorNormal();
      return false;
    }
  }