예제 #1
0
파일: View.java 프로젝트: schenkto/Info3P
  /**
   * Übernehmen der in der Konfigurationsleiste(rechts) über die JTextfields eingegebenen Daten auf
   * das selektierte Command-Objekt
   */
  public void eingabeUebernehmen() {
    if (this.currentlySelectedType == null || tM.getRowData().isEmpty())
      return; // keine Zeile ausgewählt o. Table leer
    System.out.println("Save");
    ausgabe.append("Changes saved\n\n");

    Command currentCommand = cM.getCommandList().get(currentlySelectedRow + 1);
    JTextField in1 = (JTextField) this.panelR1.getComponent(1);
    JTextField in2 = (JTextField) this.panelR2.getComponent(1);
    JTextField in3 = (JTextField) this.panelR3.getComponent(1);
    JTextField in4 = (JTextField) this.panelR4.getComponent(1);
    JTextField in5 = (JTextField) this.panelR5.getComponent(1);
    Vector<Vector> tableData = tM.getRowData();

    switch (currentlySelectedType) {
      case "Direction":
        String eingabe = in1.getText();
        double newDegree = Double.valueOf(eingabe);
        System.out.println("Eingabe: " + newDegree);
        ((Direction) currentCommand).setDegree(newDegree);

        tM.editRowData(((Direction) currentCommand).toString(), currentlySelectedRow, 2);
        break;
      case "Gear":
        String eingabeSpeed = in2.getText();
        String eingabeDuration = in3.getText();
        double newSpeed = Double.valueOf(eingabeSpeed);
        double newDuration = Double.valueOf(eingabeDuration);
        System.out.println("Eingabe: " + newSpeed + newDuration);
        ((Gear) currentCommand).setSpeed(newSpeed);
        ((Gear) currentCommand).setDuration(newDuration);

        tM.editRowData(((Gear) currentCommand).toString(), currentlySelectedRow, 2);
        break;
      case "Pause":
        String eingabeDurationP = in4.getText();
        double newDurationP = Double.valueOf(eingabeDurationP);
        System.out.println("Eingabe: " + newDurationP);
        ((Pause) currentCommand).setDuration(newDurationP);

        tM.editRowData(((Pause) currentCommand).toString(), currentlySelectedRow, 2);
        break;
      case "Repetition":
        String eingabeRep = in5.getText();
        int newRep = Integer.valueOf(eingabeRep);
        System.out.println("Eingabe: " + newRep);
        ((Repetition) currentCommand).setNrRepetitions(newRep);

        tM.editRowData(((Repetition) currentCommand).toString(), currentlySelectedRow, 2);
        break;
      default:
    }
  }