예제 #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:
    }
  }
예제 #2
0
파일: View.java 프로젝트: schenkto/Info3P
  /**
   * legt fest, welche JTextfields auf der rechten Seite je nach Table-Auswahl markiert bzw.
   * editierbar sind
   *
   * @param currentlySelectedType Typ des aktuell in der Liste selektierten Eintrags (z.B.
   *     "Direction", "Gear", ...)
   * @param currentlySelectedRow Index der aktuell selektierten Tabellenzeile
   */
  public void updateConfigurationPanel(String currentlySelectedType, int currentlySelectedRow) {
    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);
    Command currentCommand = cM.getCommandList().get(currentlySelectedRow + 1);
    // System.out.println(currentlySelectedRow);
    this.currentlySelectedType = currentlySelectedType;
    this.currentlySelectedRow = currentlySelectedRow;

    switch (currentlySelectedType) {
      case "Direction":
        in1.setEnabled(true);
        in1.setBackground(Color.YELLOW);
        in2.setEnabled(false);
        in2.setBackground(Color.white);
        in3.setEnabled(false);
        in3.setBackground(Color.white);
        in4.setEnabled(false);
        in4.setBackground(Color.white);
        in5.setEnabled(false);
        in5.setBackground(Color.white);

        double currentDegree = ((Direction) currentCommand).getDegree();
        in1.setText(String.valueOf(currentDegree));

        break;
      case "Gear":
        in1.setEnabled(false);
        in1.setBackground(Color.white);
        in2.setEnabled(true);
        in2.setBackground(Color.YELLOW);
        in3.setEnabled(true);
        in3.setBackground(Color.YELLOW);
        in4.setEnabled(false);
        in4.setBackground(Color.white);
        in5.setEnabled(false);
        in5.setBackground(Color.white);

        double currentSpeed = ((Gear) currentCommand).getSpeed();
        double currentDurationG = ((Gear) currentCommand).getDuration();
        in2.setText(String.valueOf(currentSpeed));
        in3.setText(String.valueOf(currentDurationG));
        break;
      case "Pause":
        in1.setEnabled(false);
        in1.setBackground(Color.white);
        in2.setEnabled(false);
        in2.setBackground(Color.white);
        in3.setEnabled(false);
        in3.setBackground(Color.white);
        in4.setEnabled(true);
        in4.setBackground(Color.YELLOW);
        in5.setEnabled(false);
        in5.setBackground(Color.white);

        double currentDurationP = ((Pause) currentCommand).getDuration();
        in4.setText(String.valueOf(currentDurationP));
        break;
      case "Repetition":
        in1.setEnabled(false);
        in1.setBackground(Color.white);
        in2.setEnabled(false);
        in2.setBackground(Color.white);
        in3.setEnabled(false);
        in3.setBackground(Color.white);
        in4.setEnabled(false);
        in4.setBackground(Color.white);
        in5.setEnabled(true);
        in5.setBackground(Color.YELLOW);

        int currentNrRepetitions = ((Repetition) currentCommand).getNrRepetitions();
        in5.setText(String.valueOf(currentNrRepetitions));
        break;
      default:
    }
  }