public void submit() {
   dbTextArea.clear();
   LocalDate from = fromDate.getValue(), to = toDate.getValue();
   Future<String[]> fwarNames = db.getWarNamesByDate(from, to);
   HashSet<Future<long[]>> fstats = new HashSet<Future<long[]>>();
   try {
     String[] warNames = fwarNames.get();
     for (String war : warNames) {
       fstats.add(db.getWarStats(war));
     }
     int i = 0;
     for (Future<long[]> fWarStats : fstats) {
       long[] stats = fWarStats.get();
       dbTextArea.appendText("\t" + warNames[i++] + " Statistics\n");
       dbTextArea.appendText("=========================================\n");
       dbTextArea.appendText('\t' + stats[0] == 0 ? "War is still running" : "\tWar has ended\n");
       dbTextArea.appendText("\tNum of launch missiles: " + stats[1] + "\n");
       dbTextArea.appendText("\tNum of intercept missiles: " + stats[2] + "\n");
       dbTextArea.appendText("\tNum of hit target missiles: " + stats[3] + "\n");
       dbTextArea.appendText("\tNum of launchers destroyed: " + stats[4] + "\n");
       dbTextArea.appendText("\ttotal damage: " + stats[5] + "\n");
       dbTextArea.appendText("==========================================\n");
     }
   } catch (InterruptedException | ExecutionException e) {
     e.printStackTrace();
   }
 }
  @FXML
  public void initialize() {
    initializeWorkflowProcessesComboBox();

    // TODO (artf231901): must move to model to handle other WorkflowProcessModel types
    instructionsTextArea.clear();

    promotionPathCoordinateLabel.setText(getDefaultPromotionPathCoordinateTextFieldContent());

    instructionsTextArea.setOnKeyTyped(
        (e) -> initiateButton.setDisable(!isDataRequiredForInitiateOk()));
    instructionsTextArea.addEventHandler(
        InputEvent.ANY,
        new EventHandler<InputEvent>() {
          @Override
          public void handle(InputEvent event) {
            initiateButton.setDisable(!isDataRequiredForInitiateOk());
          }
        });

    cancelButton.setOnAction((e) -> doCancel());

    initiateButton.setDisable(!isDataRequiredForInitiateOk());
    initiateButton.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            initiateWorkflow();
          }
        });
  }
Ejemplo n.º 3
0
 @FXML
 public void sendGameLobbyMessage(Event evt) throws RemoteException {
   if (!"".equals(TaGameChat.getText())) {
     LobbySession.game.addToGameChat(LobbySession.user.getName() + ": " + TaGameChat.getText());
     initGameLobbyViews();
     TaGameChat.clear();
     loadGameLobbyChat();
   }
 }
  private void setField(TextArea field, ConfigDataHolder data) {
    field.clear();
    StringBuilder sb = new StringBuilder();
    for (Cluding i : getData()) {
      sb.append(i.toString());
      sb.append(CRLF);
    }

    field.setText(sb.toString());
  }
Ejemplo n.º 5
0
  // Send a message to the chat. Adding it to the lobbychat.
  @FXML
  public void sendLobbyMessage(Event evt) throws RemoteException {

    if (!"".equals(tfLobbyChat.getText())) {
      gameManager.addToChat(LobbySession.user.getName() + ": " + tfLobbyChat.getText());
      initViews();
      tfLobbyChat.clear();
      loadLobbyChat();
    }
  }
Ejemplo n.º 6
0
 @FXML
 void onTweetButton(ActionEvent event) {
   String tweet = tweetTextArea.getText();
   try {
     @SuppressWarnings("unused")
     Status status = twitter.updateStatus(tweet);
     reloadHomeTL(lastStatusId);
   } catch (TwitterException e) {
     e.printStackTrace();
   }
   tweetTextArea.clear();
 }
  @FXML
  void deleteAction(ActionEvent event) {

    // reset Eingabfelder
    titelField.clear();
    beschreibungTextField.clear();
    kategorieComboBox.getSelectionModel().clearSelection();
    messageField.setText("Felder gelöscht");

    // reset Kalender
    vonDatePicker.setValue(null);
    bisDatePicker.setValue(null);
    return;
  }
Ejemplo n.º 8
0
  private void onSendMessage(String inputText, Dispute dispute) {
    DisputeDirectMessage disputeDirectMessage =
        disputeManager.sendDisputeDirectMessage(
            dispute, inputText, new ArrayList<>(tempAttachments));
    tempAttachments.clear();
    scrollToBottom();

    inputTextArea.setDisable(true);
    inputTextArea.clear();

    final Timer timer =
        FxTimer.runLater(
            Duration.ofMillis(500),
            () -> {
              sendMsgInfoLabel.setVisible(true);
              sendMsgInfoLabel.setManaged(true);
              sendMsgInfoLabel.setText("Sending Message...");

              sendMsgProgressIndicator.setProgress(-1);
              sendMsgProgressIndicator.setVisible(true);
              sendMsgProgressIndicator.setManaged(true);
            });

    disputeDirectMessage
        .arrivedProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (newValue) {
                hideSendMsgInfo(timer);
              }
            });
    disputeDirectMessage
        .storedInMailboxProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (newValue) {
                sendMsgInfoLabel.setVisible(true);
                sendMsgInfoLabel.setManaged(true);
                sendMsgInfoLabel.setText(
                    "Receiver is not online. Message is saved to his mailbox.");
                hideSendMsgInfo(timer);
              }
            });
  }
 @SuppressWarnings("restriction")
 @FXML
 private void stopPongButtonPressed(ActionEvent action) {
   websocketClientEndpoint.sendTextToServer("STOPPONGING");
   receiveTextArea.clear();
 }
Ejemplo n.º 10
0
  public void HandlerCalcPriceButton(ActionEvent event) {
    try {
      grain = getGrain(selectGrainCb.getValue());
      System.out.println("> " + grain.getName());

      try {
        grain.setWeight(Double.parseDouble(weightTf.getText()));
      } catch (NumberFormatException e) {
        weightTf.requestFocus();
        throw new NumberFormatException("Вес партии зерна");
      }

      for (Entry<String, TextField> entry : propertiesTf.entrySet()) {
        TextField tf = entry.getValue();
        String propertyName = entry.getKey();
        System.out.println("\t> " + propertyName);

        if (!tf.isDisable()) {
          try {
            grain.getProperty(propertyName).setValue(Double.parseDouble(tf.getText()));

          } catch (NumberFormatException e) {
            tf.requestFocus();
            throw new NumberFormatException(grain.getProperty(propertyName).getDescription());
          }

          grain.getProperty(propertyName).setEnabled(true);

        } else {
          grain.getProperty(propertyName).setEnabled(false);
        }
      }

      System.out.println("> before calculator");

      PriceCalculator calculator = new PriceCalculator(grain, dao);
      calculator.calculatePrice();
      infoTa.setText(calculator.toString());

      Supply supply = new Supply();
      supply.setProvider(selectProviderCb.getValue());
      supply.setDate(new Date(Calendar.getInstance().getTimeInMillis()));
      //            supply.setGrain(grain.getName());
      supply.setGrain(grain.getDescription());
      supply.setWeight(grain.getWeight());
      supply.setPrice(calculator.getPrice());

      dao.saveSupply(supply);

    } catch (RestrictiveConditionException e) {
      Utils.showErrorDialog("Ограшичительные кондиции!", e);
      infoTa.clear();
    } catch (DataBaseException e) {
      Utils.showErrorDialog("Обшибка базы данных!", e);
      infoTa.clear();
    } catch (NumberFormatException e) {
      Utils.showErrorDialog("Неверный ввод!", e);
      infoTa.clear();
    } catch (Exception ex) {
      Utils.showErrorDialog("Ошибка!", ex);
      infoTa.clear();
    }
  }
Ejemplo n.º 11
0
  @FXML
  public void openButtonClick(ActionEvent event) {
    switch (choiceBox.getSelectionModel().getSelectedItem()) {
      case "Simple ASCII Cipher":
        deOpenLabel.setText("Opening not possible...");
        break;
      case "Cesar Chiper":
        choose.setTitle("Open File: ");
        choose.setInitialDirectory(new File(System.getProperty("user.home") + "/Desktop"));
        choose.setSelectedExtensionFilter(new ExtensionFilter("Text Files (*.txt)", "*.txt"));
        choose.getExtensionFilters().add(new ExtensionFilter("Text Files (*.txt)", "*.txt"));

        try {
          File fileToOpen = choose.showOpenDialog(Main.primaryStage);
          textArea.clear();

          BufferedReader br = new BufferedReader(new FileReader(fileToOpen));

          String test;

          try {

            while ((test = br.readLine()) != null) {
              textArea.setText(textArea.getText() + test + "\n");
            }

            textArea.setText(textArea.getText().trim());

          } finally {
            br.close();
          }

        } catch (FileNotFoundException e2) {

        } catch (IOException e) {

        } catch (NullPointerException e) {

        }
        break;
      case "Vigenere":
        choose.setTitle("Open File: ");
        choose.setInitialDirectory(new File(System.getProperty("user.home") + "/Desktop"));
        choose.setSelectedExtensionFilter(new ExtensionFilter("Text Files (*.txt)", "*.txt"));
        choose.getExtensionFilters().add(new ExtensionFilter("Text Files (*.txt)", "*.txt"));

        try {
          File fileToOpen = choose.showOpenDialog(Main.primaryStage);
          textArea.clear();

          BufferedReader br = new BufferedReader(new FileReader(fileToOpen));

          String test;

          try {

            while ((test = br.readLine()) != null) {
              textArea.setText(textArea.getText() + test + "\n");
            }

            textArea.setText(textArea.getText().trim());

          } finally {
            br.close();
          }

        } catch (FileNotFoundException e2) {

        } catch (IOException e) {

        } catch (NullPointerException e) {

        }
        break;
      case "RC4":
        choose.setTitle("Open File: ");
        choose.setInitialDirectory(new File(System.getProperty("user.home") + "/Desktop"));
        choose.setSelectedExtensionFilter(new ExtensionFilter("Text Files (*.txt)", "*.txt"));
        choose.getExtensionFilters().add(new ExtensionFilter("Text Files (*.txt)", "*.txt"));

        try {
          File fileToOpen = choose.showOpenDialog(Main.primaryStage);
          textArea.clear();

          BufferedReader br = new BufferedReader(new FileReader(fileToOpen));

          String test;

          try {

            while ((test = br.readLine()) != null) {
              textArea.setText(textArea.getText() + test + "\n");
            }

            textArea.setText(textArea.getText().trim());

          } finally {
            br.close();
          }

        } catch (FileNotFoundException e2) {

        } catch (IOException e) {

        } catch (NullPointerException e) {

        }
        break;
    }
  }
  @FXML
  void sendAction(ActionEvent event) {

    // Anlegen der Variablen für
    String titel = titelField.getText().trim();
    String beschreibung = beschreibungTextField.getText().trim();
    String kategorie = "";

    // Wenn etwas in der Combobox ausgewählt wurde, schreibe Inhalt in die
    // Variable kategorie
    if (!(kategorieComboBox.getSelectionModel().isEmpty())) {
      kategorie = kategorieComboBox.getSelectionModel().getSelectedItem().trim();
    }

    // Falls in einem der Felder nichts ausgewählt wurde, melde Fehler
    if (titel.equals("") || kategorie.equals("") || beschreibung.equals("")) {
      messageField.setText("Eingaben fehlerhaft");
      return;
    }

    // überprüfen,ob Datum = null. Ansonsten Datum umwandeln (vonDatum)
    if ((vonDatePicker.getValue() != null)) {
      vonDate =
          Date.from(
              vonDatePicker.getValue().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
    }

    // überprüfen,ob Datum = null. Ansonsten Datum umwandeln (bisDatum)
    if ((bisDatePicker.getValue() != null)) {
      bisDate =
          Date.from(
              bisDatePicker.getValue().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
    }

    Dienstleistung neueDienstleistung = DienstleistungDAO.createDienstleistung();

    // Bereite Daten für Datenbank vor
    neueDienstleistung.setBeschreibung(beschreibung);
    neueDienstleistung.dienstnutzer.add(user);
    neueDienstleistung.setKategorie(kategorie);

    // Setze Zeit
    neueDienstleistung.setVonTermin(vonDate);
    neueDienstleistung.setBisTermin(bisDate);

    // Erfolgsmeldung
    messageField.setText("Anfrage erfolgreich erstellt");

    // reset Eingabfelder
    titelField.clear();
    beschreibungTextField.clear();
    kategorieComboBox.getSelectionModel().clearSelection();

    // reset Kalender
    vonDatePicker.setValue(null);
    bisDatePicker.setValue(null);

    try {
      DienstleistungDAO.save(neueDienstleistung);
    } catch (PersistentException e) {
      messageField.setText("Datenbankfehler");
      e.printStackTrace();
    }
  }