Пример #1
0
  /**
   * This mSerod is executed when the user hit's the enter button. It will delete the link on
   * selected interface.
   *
   * @author Key
   */
  private void okButton() {
    try {
      String CR = txtCR.getText();
      if (CR.matches("[0-9]+")) {
        if (Sim.getNode(NodeName) instanceof NetworkLayerDevice) {
          NetworkLayerDevice tmpNode = (NetworkLayerDevice) Sim.getNode(NodeName);
          tmpNode.getConfig().executeCommand("int " + NodeInt + " clock-rate " + CR);

          if (chkUP.isSelected()) {
            tmpNode.getConfig().executeCommand("int " + NodeInt + " shutdown");
            tmpNode.getConfig().executeCommand("no int " + NodeInt + " shutdown");
          } else {
            tmpNode.getConfig().executeCommand("int " + NodeInt + " shutdown");
          }
          tmpNode.getConfig().executeCommand("write mem");
        } else {
          ((core.SerialNetworkInterface) Sim.getNode(NodeName).getNIC(NodeInt))
              .setClockRate(Integer.valueOf(CR));
          Sim.getNode(NodeName).getNIC(NodeInt).DOWN();
          if (chkUP.isSelected()) {
            Sim.getNode(NodeName).getNIC(NodeInt).UP();
          }
        }

        this.dispose();
      } else {
        lblError.setText("Invalid MAC Address!");
        lblError.setForeground(Color.RED);
        lblError.setVisible(true);
        controller.shakeDiaLog(this);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }