Beispiel #1
0
  @SuppressWarnings("unchecked")
  public boolean validateOperatorPanel(boolean showErrors, Object data) {
    try {
      String idText = this.jTF_id.getText();

      AbstractRuleOperator ruleOp = (AbstractRuleOperator) this.operator;
      AbstractRuleOperator ruleChildOp = (AbstractRuleOperator) this.child;

      ruleOp.setActiveConnection(ruleChildOp, this.jCB_activate.isSelected());
      boolean ret = ruleChildOp.setOpID(idText, this.isActive());

      if (ret) {
        ruleOp.setChildOpID(ruleChildOp, idText);
      }

      ruleOp.setMode(ruleChildOp, this.getMode());

      if (!idText.equals("")) {
        try {
          Integer.parseInt(idText);
        } catch (NumberFormatException nfe) {
          HashMap<String, Operator> names = (HashMap<String, Operator>) data;

          if (names.containsKey(idText)) {
            throw new ModificationException("Name already in use!", this.operator);
          } else {
            names.put(idText, this.operator);
          }
        }
      }
    } catch (ModificationException me) {
      if (showErrors) {
        JOptionPane.showOptionDialog(
            this.parent.visualEditor,
            me.getMessage(),
            "Error",
            JOptionPane.DEFAULT_OPTION,
            JOptionPane.ERROR_MESSAGE,
            null,
            null,
            null);

        this.jTF_id.grabFocus();
      }

      return false;
    }

    return true;
  }