private static void layoutizeLabelCreator(
      ICreatorCustomLabel myLabel, double r, double g, double b) {
    Color color = Color.color(r, g, b);
    ((Label) myLabel)
        .setBackground(
            new Background(new BackgroundFill(color, new CornerRadii(3), new Insets(0))));
    ((Label) myLabel).setStyle("-fx-border-color: white;");
    ((Label) myLabel).setMinSize(400, 35);
    ((Label) myLabel).setTextAlignment(TextAlignment.CENTER);
    ((Label) myLabel).setFont(Font.font(20));
    ((Label) myLabel)
        .setOnDragDetected(
            new EventHandler<MouseEvent>() {
              @Override
              public void handle(MouseEvent event) {
                Dragboard db = ((Label) event.getSource()).startDragAndDrop(TransferMode.ANY);

                ClipboardContent content = new ClipboardContent();
                content.putString("clipboardString");
                db.setContent(content);

                event.consume();
              }
            });
    ((Label) myLabel).setVisible(true);
  }
  private boolean handleSitLeave(
      boolean bSit,
      int iPlayerPosition,
      Label lblPlayer,
      TextField txtPlayer,
      ToggleButton btnSitLeave,
      HBox HBoxPlayerCards) {
    if (bSit == false) {
      Player p = new Player(txtPlayer.getText(), iPlayerPosition);
      mainApp.AddPlayerToTable(p);
      lblPlayer.setText(txtPlayer.getText());
      lblPlayer.setVisible(true);
      btnSitLeave.setText("Leave");
      txtPlayer.setVisible(false);
      bSit = true;
    } else {
      mainApp.RemovePlayerFromTable(iPlayerPosition);
      btnSitLeave.setText("Sit");
      txtPlayer.setVisible(true);
      lblPlayer.setVisible(false);
      HBoxPlayerCards.getChildren().clear();
      bSit = false;
    }

    return bSit;
  }
 public void deleteEmployee(EmployeeVO employeeVO) {
   LOG.info("Enter : deleteEmployee");
   try {
     DialogResponse response =
         Dialogs.showConfirmDialog(
             new Stage(),
             "Do you want to delete selected customer(s)",
             "Confirm",
             "Delete customer",
             DialogOptions.OK_CANCEL);
     if (response.equals(DialogResponse.OK)) {
       helpDAO.deleteEmployees(employeeVO);
       message.setText(CommonConstants.EMPLOYEE_DELETE_SUCCESS);
       message.getStyleClass().remove("failure");
       message.getStyleClass().add("success");
       message.setVisible(true);
       fillTableFromData();
     }
   } catch (Exception e) {
     message.setText(CommonConstants.FAILURE);
     message.getStyleClass().remove("success");
     message.getStyleClass().add("failure");
     message.setVisible(true);
     LOG.error(e.getMessage());
   }
   LOG.info("Exit : deleteEmployee");
 }
 private void setClanTag(String newValue) {
   if (StringUtils.isEmpty(newValue)) {
     clanLabel.setVisible(false);
   } else {
     clanLabel.setText(String.format(CLAN_TAG_FORMAT, newValue));
     clanLabel.setVisible(true);
   }
 }
  /**
   * Creates a new account (User)
   *
   * @param event
   * @throws IOException
   * @throws ClassNotFoundException
   * @throws SQLException
   */
  @FXML
  public void createAccount(ActionEvent event)
      throws IOException, ClassNotFoundException, SQLException {

    roles.setTextFill(Color.RED);
    wrongPass.setTextFill(Color.RED);
    duplicateID.setTextFill(Color.RED);

    if (super.loadShell() != null) {
      Shell loadShell = loadShell();
      shl.setEmployees(loadShell.getEmployees());
      shl.setManagers(loadShell.getManagers());
      shl.setTabs(loadShell.getTabs());
      shl.setUsers(loadShell.getUsers());
    }

    loadLog();

    if (!user.getText().equals("")
        && !password.getText().equals("")
        && !passconf.getText().equals("")
        && !name.getText().equals("")
        && !post.getText().equals("")) {

      if (shl.findUser(user.getText()) != null) {
        user.getStyleClass().add("error");
        duplicateID.setVisible(true);

        System.out.printf(
            "[SHELL] User %s exists as %s %s\n ",
            user.getText(), shl.findUser(user.getText()), shl.findUser(user.getText()));
      } else if (password.getText().equals(passconf.getText())) {
        shl.createUser(user.getText(), password.getText(), post.getText(), name.getText());

        System.out.printf("Created User %s\n", user.getText());

        user.getStyleClass().remove("error");
        password.getStyleClass().remove("error");
        passconf.getStyleClass().remove("error");
        roles.setVisible(false);
        duplicateID.setVisible(false);
        wrongPass.setVisible(false);

        super.saveShell();
        super.saveLog("USER " + user.getText() + " - " + name.getText() + " HAS BEEN CREATED");

        goToScreen1(event);

      } else {
        System.out.println("[SHELL] User creation failed - Passwords don't match");

        password.getStyleClass().add("error");
        passconf.getStyleClass().add("error");
        wrongPass.setVisible(true);
      }

    } else System.out.println("[SHELL] User creation failed - Missing fields");
  }
 private void checkForHire() {
   if (!(player.getShip().getCrewSize() < player.getShip().getMaxCrew())) {
     hire_button.setDisable(true);
     no_space_label.setVisible(true);
   } else {
     no_space_label.setVisible(false);
     if (!name_field.getText().isEmpty()) {
       hire_button.setDisable(false);
     } else {
       hire_button.setDisable(true);
     }
   }
 }
Beispiel #7
0
  public void setLimit(long newLimit) {
    if (newLimit != 0) {
      this.limit = newLimit;

      if (formatting == Formatting.TIME) {
        limitDisplay.setText(StringUtils.toHhMmSs(limit));
      } else {
        limitDisplay.setText(String.valueOf(limit));
      }

      separationSlash.setVisible(limit != -1);
      limitDisplay.setVisible(limit != -1);
      progress.setVisible(limit != -1);
    }
  }
 private void setPrefix(String str) {
   if (!prefixLb.isVisible()) {
     prefixLb.setVisible(true);
     prefixLb.setManaged(true);
   }
   prefixLb.setText(str);
 }
  @FXML
  private void buttonListenerEdit(ActionEvent event) {
    Employee emp = new Employee();

    try {
      emp.setId(Integer.parseInt(tfInfoId.getText()));
      emp.setName(tfInfoName.getText());
      emp.setPosition(tfInfoPos.getText());
      emp.setStreet(tfInfoStreet.getText());
      StringTokenizer tokens = new StringTokenizer(tfInfoCSZ.getText(), ","); // REQ#2
      String cityState = tokens.nextToken().toString();
      String zip = tokens.nextToken();
      emp.setCity(cityState.substring(0, cityState.length() - 3));
      emp.setState(cityState.substring(cityState.length() - 2));
      emp.setZip(zip);
      emp.setPayRate(Double.parseDouble(tfInfoPayRate.getText()));
      Environment.updateEmployee(emp);
      lblEditConfirm.setText("Employee Updated");
    } catch (MinimumWageException e) { // REQ#11 REQ#12
      lblWageError.setVisible(true);
    } catch (Exception e) {
      lblEditConfirm.setText("Error Could Not Update Employee");
    }

    if (rbHourly.isSelected()) {
      initialize();
      populateHourlyEmployee();
    } else if (rbSalary.isSelected()) {
      initialize();
      populateSalaryEmployee();
    }
  }
  private void showTaskDetails(Task task) {
    if (task != null) {
      taskNLabel.setVisible(true);
      nextExecutionLabel.setVisible(true);
      actveLabel.setVisible(true);
      taskNameLabel.setText(task.getTitle());

      if (task.isRepeated()) {
        taskExecutionTime.setText((DateUtil.format(task.getExecutionDate())));
      } else {
        taskExecutionTime.setText(DateUtil.format(task.getStartTime()));
      }
      taskActiveLabel.setText((task.isActive()) ? "Yes" : "No");
      chooseLabel.setVisible(false);

    } else {
      taskNLabel.setVisible(false);
      nextExecutionLabel.setVisible(false);
      actveLabel.setVisible(false);

      taskNameLabel.setText("");
      taskExecutionTime.setText("");

      taskActiveLabel.setText("");
    }
    logger.info("Task was set");
  }
Beispiel #11
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);
              }
            });
  }
Beispiel #12
0
 /**
  * JavaFX event triggered when the user changes the border thickness of the shape
  *
  * @param e the JavaFX event
  */
 @FXML
 protected void borderThicknessChanged(KeyEvent e) {
   try {
     shape.setBorderThickness(Integer.parseInt(borderThickness.getText()));
     checkErrors();
   } catch (Exception ex) {
     // The user did not enter an integer
     error.setVisible(true);
   }
 }
Beispiel #13
0
 /**
  * JavaFX event triggered when the user enters a new height for the shape
  *
  * @param e the JavaFX event
  */
 @FXML
 protected void heightChanged(KeyEvent e) {
   try {
     shape.setHeight(Integer.parseInt(height.getText()));
     checkErrors();
   } catch (Exception ex) {
     // The user did not enter an integer
     error.setVisible(true);
   }
 }
Beispiel #14
0
 /** checks if there are any errors in the values entered by the user */
 private void checkErrors() {
   try {
     Integer.parseInt(borderThickness.getText());
     Integer.parseInt(width.getText());
     Integer.parseInt(height.getText());
     error.setVisible(false); // Only hide the error message if no exceptions were thrown before
   } catch (Exception e) {
     // Don't do anything if an exception is thrown. The error just won't be hidden
   }
 }
 private void clearTextFields() {
   tfInfoId.clear();
   tfInfoPos.clear();
   tfInfoName.clear();
   tfInfoStreet.clear();
   tfInfoCSZ.clear();
   tfInfoPayRate.clear();
   tfHours.clear();
   lblEditConfirm.setText("");
   lblWageError.setVisible(false);
 }
  private void showRegister() {

    login = false;

    errorLabel.setVisible(false);

    gridPane.add(emailLabel, 0, 2);
    gridPane.add(emailField, 1, 2);

    loginButton.setText("Submit");
    registerLabel.setText("Cancel");
  }
  @FXML
  private void handleP4SitLeave() {

    int iPlayerPosition = 4;

    if (bP4Sit == false) {
      Player p = new Player(txtP4Name.getText(), iPlayerPosition);
      mainApp.AddPlayerToTable(p);
      lblP4Name.setText(txtP4Name.getText());
      lblP4Name.setVisible(true);
      btnP4SitLeave.setText("Leave");
      txtP4Name.setVisible(false);
      bP4Sit = true;
    } else {
      mainApp.RemovePlayerFromTable(iPlayerPosition);
      btnP4SitLeave.setText("Sit");
      txtP4Name.setVisible(true);
      lblP4Name.setVisible(false);
      bP4Sit = false;
    }
  }
  private void showLogin() {

    login = true;

    errorLabel.setVisible(false);

    gridPane.getChildren().remove(emailField);
    gridPane.getChildren().remove(emailLabel);

    loginButton.setText("Login");
    registerLabel.setText("Register");
  }
 @FXML
 private void handleAddButton() {
   hideLabels();
   successLabel.setVisible(false);
   if (ver.verify(fieldArray) == true) {
     ingredientStorage.storeIngredientType(
         new IngredientType(nameField.getText(), measurementField.getText()));
     successLabel.setText(String.format("Ingredienttype %s added.", nameField.getText()));
     successLabel.setVisible(true);
     nameField.setText("");
     measurementField.setText("");
   } else {
     errorLabel.setVisible(true);
     for (TextField tf : ver.getErrorList()) {
       if (tf.equals(nameField)) {
         nameFieldErrorLabel.setVisible(true);
       } else if (tf.equals(measurementField)) {
         measurementFieldErrorLabel.setVisible(true);
       }
     }
   }
 }
Beispiel #20
0
 public static void layoutizeLabel(ICustomLabel myLabel, Color color) {
   ((Label) myLabel)
       .setBackground(
           new Background(new BackgroundFill(color, new CornerRadii(3), new Insets(0))));
   ((Label) myLabel).setBorder(Border.EMPTY);
   ((Label) myLabel).setStyle("-fx-border-color: white;");
   ((Label) myLabel).setMinSize(400, 35);
   ((Label) myLabel).setText(myLabel.getName());
   myLabel.setDescription(myLabel.getDescription());
   ((Label) myLabel).setTextAlignment(TextAlignment.CENTER);
   ((Label) myLabel).setFont(Font.font(20));
   ((Label) myLabel).setVisible(true);
 }
  @FXML
  private void initialize() throws IOException, ParseException {
    taskNLabel.setVisible(false);
    nextExecutionLabel.setVisible(false);
    actveLabel.setVisible(false);
    initData();
    logger.info("Data were initialized");
    taskName.setCellValueFactory(new PropertyValueFactory<Task, String>("title"));

    taskTable.setItems(userData2);

    taskTable
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            new ChangeListener<Task>() {
              public void changed(
                  ObservableValue<? extends Task> observable, Task oldValue, Task newValue) {
                showTaskDetails(newValue);
              }
            });
  }
Beispiel #22
0
  private void hideSendMsgInfo(Timer timer) {
    timer.stop();
    inputTextArea.setDisable(false);

    FxTimer.runLater(
        Duration.ofMillis(5000),
        () -> {
          sendMsgInfoLabel.setVisible(false);
          sendMsgInfoLabel.setManaged(false);
        });
    sendMsgProgressIndicator.setProgress(0);
    sendMsgProgressIndicator.setVisible(false);
    sendMsgProgressIndicator.setManaged(false);
  }
  @FXML
  void searchTktButton(ActionEvent event) {
    // send a request to server for searching a ticket from database

    c.setDate(datePick.getValue());
    c.setAC(ACradioButton.isSelected());
    c.setNonAC(nonACradioButton.isSelected());
    if (allOptionsFilledUp()) {
      try {
        main.availableBusView();
      } catch (Exception e) {
        e.printStackTrace();
      }

      /*
      try {
          //String serverAddress="127.0.0.1";
          //int serverPort=55555;
          //NetworkUtil nc = new NetworkUtil(serverAddress,serverPort);

          //nc.write(c);

      } catch(Exception e) {
          System.out.println (e);
      }
      */

    } else {
      alert.setVisible(true);
      PauseTransition visiblePause =
          new PauseTransition(
              Duration.seconds(2)); // making the "alert" label visible for 2 seconds
      visiblePause.setOnFinished(Event -> alert.setVisible(false));
      visiblePause.play();
    }
  }
  public void createNewUser() {
    // TODO make error and ok messages.. make local strings
    // TODO-maybe: make required password length(and double type it) and check for correct email
    // format

    if (firstNameCreateUserText.getText().equals("")
        && lastNameCreateUserText.getText().equals("")
        && userNameCreateUserText.getText().equals("")
        && passwordCreateUserText.getText().equals("")
        && emailCreateUserText.getText().equals("")) {

      emptyFieldErrorLbl.setVisible(true);
      createUserErrorLbl.setVisible(false);

      succesLbl.setVisible(false);
    }

    if (logic.createUser(
        firstNameCreateUserText.getText(),
        lastNameCreateUserText.getText(),
        userNameCreateUserText.getText(),
        passwordCreateUserText.getText(),
        emailCreateUserText.getText())) {

      logic.createGame("alexGameTest", "wwwdddssss");

      emptyFieldErrorLbl.setVisible(false);
      createUserErrorLbl.setVisible(false);

      succesLbl.setVisible(true);

    } else {
      emptyFieldErrorLbl.setVisible(false);
      createUserErrorLbl.setVisible(true);

      succesLbl.setVisible(false);
    }
  }
Beispiel #25
0
  @FXML
  void initialize() {
    assert progressBar != null
        : "fx:id=\"progressBar\" was not injected: check your FXML file 'StatusBar.fxml'."; // NON-NLS
    assert taskLabel != null
        : "fx:id=\"taskLabel\" was not injected: check your FXML file 'StatusBar.fxml'."; // NON-NLS
    assert messageLabel != null
        : "fx:id=\"messageLabel\" was not injected: check your FXML file 'StatusBar.fxml'."; // NON-NLS

    taskLabel.setVisible(false);
    taskLabel.textProperty().bind(this.controller.taskTitleProperty());
    taskLabel.visibleProperty().bind(this.controller.getTasks().emptyProperty().not());

    messageLabel.textProperty().bind(this.controller.taskMessageProperty());
    progressBar.progressProperty().bind(this.controller.taskProgressProperty());

    statusLabel.textProperty().bind(this.controller.statusMessageProperty());
    statusLabel.visibleProperty().bind(statusLabel.textProperty().isNotEmpty());
  }
Beispiel #26
0
  private void changeHidden(boolean hide) {
    hidePopOver();

    /*
     * If already hiding, we don't want the mouse event that MIGHT happen
     * when the resizing dock passes under the mouse (the user wont have
     * moved mouse yet)
     */
    if (hiding) {
      // TODO check this ...
      return;
    }

    hidden = hide;
    hiding = true;

    pull.setVisible(true);

    dockHider = new Timeline(new KeyFrame(Duration.millis(5), ae -> shiftDock()));
    yEnd = System.currentTimeMillis() + AUTOHIDE_DURATION;
    dockHider.play();
  }
  private void updateLayout(LibraryListItem listItem) {
    assert listItem != null;

    if (listItem.getLibItem() != null) {
      final ILibraryItem item = listItem.getLibItem();
      // The classname shall be space character free (it is an API name).
      // If there is a space character then it means a qualifier comes
      // right after.
      String classname = getClassName(item.getName());
      iconImageView.setManaged(true);
      classNameLabel.setManaged(true);
      qualifierLabel.setManaged(true);
      sectionLabel.setManaged(false);
      iconImageView.setVisible(true);
      classNameLabel.setVisible(true);
      qualifierLabel.setVisible(true);
      sectionLabel.setVisible(false);
      classNameLabel.setText(classname);
      qualifierLabel.setText(getQualifier(item.getName()));
      // getIconURL can return null, this is deliberate.
      URL iconURL = item.getIconURL();
      // Use missing icon
      if (iconURL == null) {
        iconURL = missingIconURL;
      }
      iconImageView.setImage(new Image(iconURL.toExternalForm()));
    } else if (listItem.getSectionName() != null) {
      iconImageView.setManaged(false);
      classNameLabel.setManaged(false);
      qualifierLabel.setManaged(false);
      sectionLabel.setManaged(true);
      iconImageView.setVisible(false);
      classNameLabel.setVisible(false);
      qualifierLabel.setVisible(false);
      sectionLabel.setVisible(true);
      sectionLabel.setText(listItem.getSectionName());
    }
  }
Beispiel #28
0
  private void onSelectDispute(Dispute dispute) {
    if (dispute == null) {
      if (root.getChildren().size() > 1) root.getChildren().remove(1);

      selectedDispute = null;
    } else if (selectedDispute != dispute) {
      this.selectedDispute = dispute;

      boolean isTrader = disputeManager.isTrader(dispute);

      TableGroupHeadline tableGroupHeadline = new TableGroupHeadline();
      tableGroupHeadline.setText("Messages");
      tableGroupHeadline.prefWidthProperty().bind(root.widthProperty());
      AnchorPane.setTopAnchor(tableGroupHeadline, 10d);
      AnchorPane.setRightAnchor(tableGroupHeadline, 0d);
      AnchorPane.setBottomAnchor(tableGroupHeadline, 0d);
      AnchorPane.setLeftAnchor(tableGroupHeadline, 0d);

      ObservableList<DisputeDirectMessage> list =
          dispute.getDisputeDirectMessagesAsObservableList();
      SortedList<DisputeDirectMessage> sortedList = new SortedList<>(list);
      sortedList.setComparator((o1, o2) -> o1.getDate().compareTo(o2.getDate()));
      list.addListener((ListChangeListener<DisputeDirectMessage>) c -> scrollToBottom());
      messageListView = new ListView<>(sortedList);
      messageListView.setId("message-list-view");
      messageListView.prefWidthProperty().bind(root.widthProperty());
      messageListView.setMinHeight(150);
      AnchorPane.setTopAnchor(messageListView, 30d);
      AnchorPane.setRightAnchor(messageListView, 0d);
      AnchorPane.setLeftAnchor(messageListView, 0d);

      messagesAnchorPane = new AnchorPane();
      messagesAnchorPane.prefWidthProperty().bind(root.widthProperty());
      VBox.setVgrow(messagesAnchorPane, Priority.ALWAYS);

      inputTextArea = new TextArea();
      inputTextArea.setPrefHeight(70);
      inputTextArea.setWrapText(true);

      Button sendButton = new Button("Send");
      sendButton.setDefaultButton(true);
      sendButton.setOnAction(e -> onSendMessage(inputTextArea.getText(), dispute));
      sendButton.setDisable(true);
      inputTextArea
          .textProperty()
          .addListener(
              (observable, oldValue, newValue) -> {
                sendButton.setDisable(
                    newValue.length() == 0
                        && tempAttachments.size() == 0
                        && dispute.disputeResultProperty().get() == null);
              });

      Button uploadButton = new Button("Add attachments");
      uploadButton.setOnAction(e -> onRequestUpload());

      sendMsgInfoLabel = new Label();
      sendMsgInfoLabel.setVisible(false);
      sendMsgInfoLabel.setManaged(false);
      sendMsgInfoLabel.setPadding(new Insets(5, 0, 0, 0));

      sendMsgProgressIndicator = new ProgressIndicator(0);
      sendMsgProgressIndicator.setPrefHeight(24);
      sendMsgProgressIndicator.setPrefWidth(24);
      sendMsgProgressIndicator.setVisible(false);
      sendMsgProgressIndicator.setManaged(false);

      dispute
          .isClosedProperty()
          .addListener(
              (observable, oldValue, newValue) -> {
                messagesInputBox.setVisible(!newValue);
                messagesInputBox.setManaged(!newValue);
                AnchorPane.setBottomAnchor(messageListView, newValue ? 0d : 120d);
              });
      if (!dispute.isClosed()) {
        HBox buttonBox = new HBox();
        buttonBox.setSpacing(10);
        buttonBox
            .getChildren()
            .addAll(sendButton, uploadButton, sendMsgProgressIndicator, sendMsgInfoLabel);

        if (!isTrader) {
          Button closeDisputeButton = new Button("Close ticket");
          closeDisputeButton.setOnAction(e -> onCloseDispute(dispute));
          closeDisputeButton.setDefaultButton(true);
          Pane spacer = new Pane();
          HBox.setHgrow(spacer, Priority.ALWAYS);
          buttonBox.getChildren().addAll(spacer, closeDisputeButton);
        }

        messagesInputBox = new VBox();
        messagesInputBox.setSpacing(10);
        messagesInputBox.getChildren().addAll(inputTextArea, buttonBox);
        VBox.setVgrow(buttonBox, Priority.ALWAYS);

        AnchorPane.setRightAnchor(messagesInputBox, 0d);
        AnchorPane.setBottomAnchor(messagesInputBox, 5d);
        AnchorPane.setLeftAnchor(messagesInputBox, 0d);

        AnchorPane.setBottomAnchor(messageListView, 120d);

        messagesAnchorPane
            .getChildren()
            .addAll(tableGroupHeadline, messageListView, messagesInputBox);
      } else {
        AnchorPane.setBottomAnchor(messageListView, 0d);
        messagesAnchorPane.getChildren().addAll(tableGroupHeadline, messageListView);
      }

      messageListView.setCellFactory(
          new Callback<ListView<DisputeDirectMessage>, ListCell<DisputeDirectMessage>>() {
            @Override
            public ListCell<DisputeDirectMessage> call(ListView<DisputeDirectMessage> list) {
              return new ListCell<DisputeDirectMessage>() {
                final Pane bg = new Pane();
                final ImageView arrow = new ImageView();
                final Label headerLabel = new Label();
                final Label messageLabel = new Label();
                final HBox attachmentsBox = new HBox();
                final AnchorPane messageAnchorPane = new AnchorPane();
                final Label statusIcon = new Label();
                final double arrowWidth = 15d;
                final double attachmentsBoxHeight = 20d;
                final double border = 10d;
                final double bottomBorder = 25d;
                final double padding = border + 10d;

                {
                  bg.setMinHeight(30);
                  messageLabel.setWrapText(true);
                  headerLabel.setTextAlignment(TextAlignment.CENTER);
                  attachmentsBox.setSpacing(5);
                  statusIcon.setStyle("-fx-font-size: 10;");
                  messageAnchorPane
                      .getChildren()
                      .addAll(bg, arrow, headerLabel, messageLabel, attachmentsBox, statusIcon);
                }

                @Override
                public void updateItem(final DisputeDirectMessage item, boolean empty) {
                  super.updateItem(item, empty);

                  if (item != null && !empty) {
                    /* messageAnchorPane.prefWidthProperty().bind(EasyBind.map(messageListView.widthProperty(),
                    w -> (double) w - padding - GUIUtil.getScrollbarWidth(messageListView)));*/
                    if (!messageAnchorPane.prefWidthProperty().isBound())
                      messageAnchorPane
                          .prefWidthProperty()
                          .bind(
                              messageListView
                                  .widthProperty()
                                  .subtract(padding + GUIUtil.getScrollbarWidth(messageListView)));

                    AnchorPane.setTopAnchor(bg, 15d);
                    AnchorPane.setBottomAnchor(bg, bottomBorder);
                    AnchorPane.setTopAnchor(headerLabel, 0d);
                    AnchorPane.setBottomAnchor(arrow, bottomBorder + 5d);
                    AnchorPane.setTopAnchor(messageLabel, 25d);
                    AnchorPane.setBottomAnchor(attachmentsBox, bottomBorder + 10);

                    boolean senderIsTrader = item.isSenderIsTrader();
                    boolean isMyMsg = isTrader ? senderIsTrader : !senderIsTrader;

                    arrow.setVisible(!item.isSystemMessage());
                    arrow.setManaged(!item.isSystemMessage());
                    statusIcon.setVisible(false);
                    if (item.isSystemMessage()) {
                      headerLabel.setStyle("-fx-text-fill: -bs-green; -fx-font-size: 11;");
                      bg.setId("message-bubble-green");
                      messageLabel.setStyle("-fx-text-fill: white;");
                    } else if (isMyMsg) {
                      headerLabel.setStyle("-fx-text-fill: -fx-accent; -fx-font-size: 11;");
                      bg.setId("message-bubble-blue");
                      messageLabel.setStyle("-fx-text-fill: white;");
                      if (isTrader) arrow.setId("bubble_arrow_blue_left");
                      else arrow.setId("bubble_arrow_blue_right");

                      sendMsgProgressIndicator
                          .progressProperty()
                          .addListener(
                              (observable, oldValue, newValue) -> {
                                if ((double) oldValue == -1 && (double) newValue == 0) {
                                  if (item.arrivedProperty().get()) showArrivedIcon();
                                  else if (item.storedInMailboxProperty().get()) showMailboxIcon();
                                }
                              });

                      if (item.arrivedProperty().get()) showArrivedIcon();
                      else if (item.storedInMailboxProperty().get()) showMailboxIcon();
                      // TODO show that icon on error
                      /*else if (sendMsgProgressIndicator.getProgress() == 0)
                      showNotArrivedIcon();*/
                    } else {
                      headerLabel.setStyle("-fx-text-fill: -bs-light-grey; -fx-font-size: 11;");
                      bg.setId("message-bubble-grey");
                      messageLabel.setStyle("-fx-text-fill: black;");
                      if (isTrader) arrow.setId("bubble_arrow_grey_right");
                      else arrow.setId("bubble_arrow_grey_left");
                    }

                    if (item.isSystemMessage()) {
                      AnchorPane.setLeftAnchor(headerLabel, padding);
                      AnchorPane.setRightAnchor(headerLabel, padding);
                      AnchorPane.setLeftAnchor(bg, border);
                      AnchorPane.setRightAnchor(bg, border);
                      AnchorPane.setLeftAnchor(messageLabel, padding);
                      AnchorPane.setRightAnchor(messageLabel, padding);
                      AnchorPane.setLeftAnchor(attachmentsBox, padding);
                      AnchorPane.setRightAnchor(attachmentsBox, padding);
                    } else if (senderIsTrader) {
                      AnchorPane.setLeftAnchor(headerLabel, padding + arrowWidth);
                      AnchorPane.setLeftAnchor(bg, border + arrowWidth);
                      AnchorPane.setRightAnchor(bg, border);
                      AnchorPane.setLeftAnchor(arrow, border);
                      AnchorPane.setLeftAnchor(messageLabel, padding + arrowWidth);
                      AnchorPane.setRightAnchor(messageLabel, padding);
                      AnchorPane.setLeftAnchor(attachmentsBox, padding + arrowWidth);
                      AnchorPane.setRightAnchor(attachmentsBox, padding);
                      AnchorPane.setRightAnchor(statusIcon, padding);
                    } else {
                      AnchorPane.setRightAnchor(headerLabel, padding + arrowWidth);
                      AnchorPane.setLeftAnchor(bg, border);
                      AnchorPane.setRightAnchor(bg, border + arrowWidth);
                      AnchorPane.setRightAnchor(arrow, border);
                      AnchorPane.setLeftAnchor(messageLabel, padding);
                      AnchorPane.setRightAnchor(messageLabel, padding + arrowWidth);
                      AnchorPane.setLeftAnchor(attachmentsBox, padding);
                      AnchorPane.setRightAnchor(attachmentsBox, padding + arrowWidth);
                      AnchorPane.setLeftAnchor(statusIcon, padding);
                    }

                    AnchorPane.setBottomAnchor(statusIcon, 7d);
                    headerLabel.setText(formatter.formatDateTime(item.getDate()));
                    messageLabel.setText(item.getMessage());
                    if (item.getAttachments().size() > 0) {
                      AnchorPane.setBottomAnchor(
                          messageLabel, bottomBorder + attachmentsBoxHeight + 10);
                      attachmentsBox
                          .getChildren()
                          .add(
                              new Label("Attachments: ") {
                                {
                                  setPadding(new Insets(0, 0, 3, 0));
                                  if (isMyMsg) setStyle("-fx-text-fill: white;");
                                  else setStyle("-fx-text-fill: black;");
                                }
                              });

                      item.getAttachments()
                          .stream()
                          .forEach(
                              attachment -> {
                                final Label icon = new Label();
                                setPadding(new Insets(0, 0, 3, 0));
                                if (isMyMsg) icon.getStyleClass().add("attachment-icon");
                                else icon.getStyleClass().add("attachment-icon-black");

                                AwesomeDude.setIcon(icon, AwesomeIcon.FILE_TEXT);
                                icon.setPadding(new Insets(-2, 0, 0, 0));
                                icon.setTooltip(new Tooltip(attachment.getFileName()));
                                icon.setOnMouseClicked(event -> onOpenAttachment(attachment));
                                attachmentsBox.getChildren().add(icon);
                              });
                    } else {
                      attachmentsBox.getChildren().clear();
                      AnchorPane.setBottomAnchor(messageLabel, bottomBorder + 10);
                    }

                    // TODO There are still some cell rendering issues on updates
                    setGraphic(messageAnchorPane);
                  } else {
                    messageAnchorPane.prefWidthProperty().unbind();

                    AnchorPane.clearConstraints(bg);
                    AnchorPane.clearConstraints(headerLabel);
                    AnchorPane.clearConstraints(arrow);
                    AnchorPane.clearConstraints(messageLabel);
                    AnchorPane.clearConstraints(statusIcon);
                    AnchorPane.clearConstraints(attachmentsBox);

                    setGraphic(null);
                  }
                }

                /*  private void showNotArrivedIcon() {
                    statusIcon.setVisible(true);
                    AwesomeDude.setIcon(statusIcon, AwesomeIcon.WARNING_SIGN, "14");
                    Tooltip.install(statusIcon, new Tooltip("Message did not arrive. Please try to send again."));
                    statusIcon.setTextFill(Paint.valueOf("#dd0000"));
                }*/

                private void showMailboxIcon() {
                  statusIcon.setVisible(true);
                  AwesomeDude.setIcon(statusIcon, AwesomeIcon.ENVELOPE_ALT, "14");
                  Tooltip.install(statusIcon, new Tooltip("Message saved in receivers mailbox"));
                  statusIcon.setTextFill(Paint.valueOf("#0f87c3"));
                }

                private void showArrivedIcon() {
                  statusIcon.setVisible(true);
                  AwesomeDude.setIcon(statusIcon, AwesomeIcon.OK, "14");
                  Tooltip.install(statusIcon, new Tooltip("Message arrived at receiver"));
                  statusIcon.setTextFill(Paint.valueOf("#0f87c3"));
                }
              };
            }
          });

      if (root.getChildren().size() > 1) root.getChildren().remove(1);
      root.getChildren().add(1, messagesAnchorPane);

      scrollToBottom();
    }
  }
 private void cambiarWarning(boolean esVisible) {
   textoWarning.setVisible(esVisible);
   imagenWarning.setVisible(esVisible);
 }
Beispiel #30
0
  private void shiftDock() {
    long now = System.currentTimeMillis();
    Rectangle2D cfgBounds = Client.getConfiguredBounds();

    // The bounds to work in
    int boundsSize = cfg.isVertical() ? (int) cfgBounds.getHeight() : (int) cfgBounds.getWidth();

    // Total amount to slide
    int value = cfg.sizeProperty().get() - AUTOHIDE_TAB_OPPOSITE_SIZE;

    // How far along the timeline?
    float fac = Math.min(1f, 1f - ((float) (yEnd - now) / (float) AUTOHIDE_DURATION));

    // The amount of movement so far
    float amt = fac * (float) value;

    // The amount to shrink the width (or height when vertical) of the
    // visible 'bar'
    float barSize = (float) boundsSize * fac;

    // If showing, reverse
    final boolean fhidden = hidden;

    if (!hidden) {
      amt = value - amt;
      barSize = (float) boundsSize - barSize;
      if (!pull.isVisible()) pull.setVisible(true);
    }

    // Reveal or hide the pull tab
    dockContent.setOpacity(hidden ? 1f - fac : fac);
    pull.setOpacity((hidden ? fac : 1f - fac) * 0.5f);

    Stage stage = getStage();
    if (stage != null) {
      if (cfg.topProperty().get()) {
        getScene().getRoot().translateYProperty().set(-amt);
        stage.setHeight(cfg.sizeProperty().get() - amt + Client.DROP_SHADOW_SIZE);
        stage.setWidth(Math.max(AUTOHIDE_TAB_SIZE, cfgBounds.getWidth() - barSize));
        stage.setX(cfgBounds.getMinX() + ((cfgBounds.getWidth() - stage.getWidth()) / 2f));
      } else if (cfg.bottomProperty().get()) {
        stage.setY(cfgBounds.getMaxY() + amt);
        stage.setHeight(cfg.sizeProperty().get() - amt + Client.DROP_SHADOW_SIZE);
        stage.setWidth(Math.max(AUTOHIDE_TAB_SIZE, cfgBounds.getWidth() - barSize));
        stage.setX(cfgBounds.getMinX() + ((cfgBounds.getWidth() - stage.getWidth()) / 2f));
      } else if (cfg.leftProperty().get()) {
        getScene().getRoot().translateXProperty().set(-amt);
        stage.setWidth(cfg.sizeProperty().get() - amt);
        stage.setHeight(Math.max(AUTOHIDE_TAB_SIZE, cfgBounds.getHeight() - barSize));
        stage.setY(cfgBounds.getMinY() + ((cfgBounds.getHeight() - stage.getHeight()) / 2f));
      } else if (cfg.rightProperty().get()) {
        stage.setX(cfgBounds.getMaxX() + amt - cfg.sizeProperty().get());
        stage.setWidth(cfg.sizeProperty().get() - amt);
        stage.setHeight(Math.max(AUTOHIDE_TAB_SIZE, cfgBounds.getHeight() - barSize));
        stage.setY(cfgBounds.getMinY() + ((cfgBounds.getHeight() - stage.getHeight()) / 2f));
      } else {
        throw new UnsupportedOperationException();
      }
    }

    // The update or the sign in dialog may have been popped, so make sure
    // it is position correctly
    if (signInPopup != null && signInPopup.isShowing()) {
      signInPopup.sizeToScene();
    }

    // If not fully hidden / revealed, play again
    if (now < yEnd) {
      dockHider.playFromStart();
    } else {
      // Defer this as events may still be coming in
      Platform.runLater(
          new Runnable() {
            @Override
            public void run() {
              if (!fhidden && stage != null) {
                stage.requestFocus();
                pull.setVisible(false);
              }
              hiding = false;
            }
          });
    }
  }