Пример #1
0
    private void updateViewModel() {

      setText(null);
      setGraphic(null);

      if (getItem() != null) {

        BorderPane mainBox = new BorderPane();
        mainBox.setPadding(new Insets(3.0, 5.0, 3.0, 3.0));

        VBox taskNameDisplay = new VBox();
        taskNameDisplay.setAlignment(Pos.CENTER_LEFT);
        Text taskNameText = new Text();
        taskNameDisplay.getChildren().addAll(taskNameText);

        HBox priorityDueDateDisplay = new HBox();
        priorityDueDateDisplay.setAlignment(Pos.CENTER_RIGHT);
        Text taskPriorityText = new Text();
        Text taskDueDateText = new Text();
        taskPriorityText.setScaleX(1.25);
        taskPriorityText.setScaleY(1.25);
        priorityDueDateDisplay.setSpacing(40);
        priorityDueDateDisplay.getChildren().addAll(taskDueDateText, taskPriorityText);

        mainBox.leftProperty().set(taskNameDisplay);
        mainBox.rightProperty().set(priorityDueDateDisplay);

        mainBox.setMargin(mainBox.getLeft(), new Insets(0, 20, 0, 0));

        Task currentTask = getItem();
        int currentTaskPriority = currentTask.getPriority();

        // setting task name to be displayed by the cell
        taskNameText.setText(currentTask.getTaskTitle());

        // setting task due date to be displayed by the cell
        if (currentTask.getTaskDueDate() != null) {

          LocalDate currentDueDate = currentTask.getTaskDueDate();
          taskDueDateText.setText(
              currentDueDate.getMonthValue()
                  + "/"
                  + currentDueDate.getDayOfMonth()
                  + "/"
                  + currentDueDate.getYear());
        }

        // setting task priority to be displayed by the cell
        switch (currentTaskPriority) {
          case 1:
            {
              taskPriorityText.setText("!");
              taskPriorityText.setFill(Color.web("#28ae33"));
              break;
            }
          case 2:
            {
              taskPriorityText.setText("!!");
              taskPriorityText.setFill(Color.web("#babf23"));
              break;
            }
          case 3:
            {
              taskPriorityText.setText("!!!");
              taskPriorityText.setFill(Color.web("#ee0606"));
              break;
            }
          default:
            {
            }
        }

        if (!currentTask.getComplete()) {
          taskNameText.setStrikethrough(false);
        } else {
          // if task is completed, strike out the task name

          mainBox.setOpacity(0.5);
          taskNameText.setStrikethrough(true);
        }

        setText(null);
        setGraphic(mainBox);
      }
    }
Пример #2
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;
            }
          });
    }
  }