示例#1
2
  /** {@inheritDoc} */
  @Override
  public void commitEdit(T newValue) {
    if (!isEditing()) return;

    final TableView table = getTableView();
    if (table != null) {
      // Inform the TableView of the edit being ready to be committed.
      CellEditEvent editEvent =
          new CellEditEvent(table, table.getEditingCell(), TableColumn.editCommitEvent(), newValue);

      Event.fireEvent(getTableColumn(), editEvent);
    }

    // inform parent classes of the commit, so that they can switch us
    // out of the editing state.
    // This MUST come before the updateItem call below, otherwise it will
    // call cancelEdit(), resulting in both commit and cancel events being
    // fired (as identified in RT-29650)
    super.commitEdit(newValue);

    // update the item within this cell, so that it represents the new value
    updateItem(newValue, false);

    if (table != null) {
      // reset the editing cell on the TableView
      table.edit(-1, null);

      // request focus back onto the table, only if the current focus
      // owner has the table as a parent (otherwise the user might have
      // clicked out of the table entirely and given focus to something else.
      // It would be rude of us to request it back again.
      ControlUtils.requestFocusOnControlOnlyIfCurrentFocusOwnerIsChild(table);
    }
  }
示例#2
2
  /** {@inheritDoc} */
  @Override
  public void startEdit() {
    final TableView table = getTableView();
    final TableColumn column = getTableColumn();
    if (!isEditable()
        || (table != null && !table.isEditable())
        || (column != null && !getTableColumn().isEditable())) {
      return;
    }

    // We check the boolean lockItemOnEdit field here, as whilst we want to
    // updateItem normally, when it comes to unit tests we can't have the
    // item change in all circumstances.
    if (!lockItemOnEdit) {
      updateItem();
    }

    // it makes sense to get the cell into its editing state before firing
    // the event to listeners below, so that's what we're doing here
    // by calling super.startEdit().
    super.startEdit();

    if (column != null) {
      CellEditEvent editEvent =
          new CellEditEvent(table, table.getEditingCell(), TableColumn.editStartEvent(), null);

      Event.fireEvent(column, editEvent);
    }
  }
示例#3
0
  /*
   * This is called when we think that the data within this TableCell may have
   * changed. You'll note that this is a private function - it is only called
   * when one of the triggers above call it.
   */
  private void updateItem() {
    if (currentObservableValue != null) {
      currentObservableValue.removeListener(weaktableRowUpdateObserver);
    }

    // get the total number of items in the data model
    final TableView tableView = getTableView();
    final List<T> items =
        tableView == null ? FXCollections.<T>emptyObservableList() : tableView.getItems();
    final TableColumn tableColumn = getTableColumn();
    final int itemCount = items == null ? -1 : items.size();
    final int index = getIndex();
    final boolean isEmpty = isEmpty();
    final T oldValue = getItem();

    final boolean indexExceedsItemCount = index >= itemCount;

    // there is a whole heap of reasons why we should just punt...
    if (indexExceedsItemCount
        || index < 0
        || columnIndex < 0
        || !isVisible()
        || tableColumn == null
        || !tableColumn.isVisible()) {

      // RT-30484 We need to allow a first run to be special-cased to allow
      // for the updateItem method to be called at least once to allow for
      // the correct visual state to be set up. In particular, in RT-30484
      // refer to Ensemble8PopUpTree.png - in this case the arrows are being
      // shown as the new cells are instantiated with the arrows in the
      // children list, and are only hidden in updateItem.
      // RT-32621: There are circumstances where we need to updateItem,
      // even when the index is greater than the itemCount. For example,
      // RT-32621 identifies issues where a TreeTableView collapses a
      // TreeItem but the custom cells remain visible. This is now
      // resolved with the check for indexExceedsItemCount.
      if ((!isEmpty && oldValue != null) || isFirstRun || indexExceedsItemCount) {
        updateItem(null, true);
        isFirstRun = false;
      }
      return;
    } else {
      currentObservableValue = tableColumn.getCellObservableValue(index);
      final T newValue = currentObservableValue == null ? null : currentObservableValue.getValue();

      // There used to be conditional code here to prevent updateItem from
      // being called when the value didn't change, but that led us to
      // issues such as RT-33108, where the value didn't change but the item
      // we needed to be listening to did. Without calling updateItem we
      // were breaking things, so once again the conditionals are gone.
      updateItem(newValue, false);
    }

    if (currentObservableValue == null) {
      return;
    }

    // add property change listeners to this item
    currentObservableValue.addListener(weaktableRowUpdateObserver);
  }
  @Override
  public void updateItem(T item, boolean empty) {
    super.updateItem(item, empty);
    if (item == null) {
      setGraphic(null);
      setText(null);
    } else {
      if (item.toString().equalsIgnoreCase("Processing")) {
        Platform.runLater(
            new Runnable() {
              @Override
              public void run() {

                if (getGraphic() == null) {
                  setGraphic(progressBar);
                  progressBar.setProgress(-1);
                } else {
                  ProgressBar objpProgressBar = (ProgressBar) getGraphic();
                  objpProgressBar.setProgress(-1);
                }
                setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
              }
            });
      }
    }
  }
示例#5
0
 @Override
 protected void layoutChildren() {
   if (itemDirty) {
     updateItem();
     itemDirty = false;
   }
   super.layoutChildren();
 }
 // Display button if the row is not empty
 @Override
 protected void updateItem(Boolean t, boolean empty) {
   super.updateItem(t, empty);
   if (!empty) {
     HBox box = new HBox();
     box.getChildren().addAll(cellEditButton, cellDeleteButton);
     setGraphic(box);
   }
 }
示例#7
0
 @Override
 protected void updateItem(T item, boolean empty) {
   super.updateItem(item, empty);
   if (empty) {
     setGraphic(null);
   } else {
     link.setText(getDisplayName(item));
     setGraphic(link);
   }
 }
示例#8
0
    @Override
    protected void updateItem(LocalDateTime item, boolean empty) {
      super.updateItem(item, empty);

      if (!empty) {
        setText(item.format(DateTimeFormatter.ISO_LOCAL_DATE));
      } else {
        setText(null);
      }
    }
 @Override
 protected void updateItem(String item, boolean empty) {
   super.updateItem(item, empty);
   if (!empty) {
     label.setText(genDotString(item.length()));
     setGraphic(label);
   } else {
     setGraphic(null);
   }
 }
 @Override
 protected void updateItem(Calendar item, boolean empty) {
   super.updateItem(item, empty);
   if ((item == null) || empty) {
     setText(null);
     setStyle("");
   } else {
     String cellText = CFLibXmlUtil.formatTZTimestamp(item);
     setText(cellText);
     setStyle("-fx-alignment: CENTER-LEFT");
   }
 }
示例#11
0
  @Override
  public void updateItem(String item, boolean empty) {
    super.updateItem(item, empty);

    if (empty) {
      setText(null);
      setGraphic(null);
    } else {
      setText(getString());
      setGraphic(null);
    }
  }
示例#12
0
 @Override
 void indexChanged() {
   super.indexChanged();
   // Ideally we would just use the following two lines of code, rather
   // than the updateItem() call beneath, but if we do this we end up with
   // RT-22428 where all the columns are collapsed.
   // itemDirty = true;
   // requestLayout();
   updateItem();
   updateSelection();
   updateFocus();
 }
 @Override
 public void updateItem(T item, boolean empty) {
   super.updateItem(item, empty);
   if (empty) {
     setText(null);
     setGraphic(null);
   } else {
     if (isEditing()) {
       if (textField != null) {
         textField.setText(getString());
       }
       setGraphic(textField);
       setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
     } else {
       setText(getString());
       setContentDisplay(ContentDisplay.TEXT_ONLY);
     }
   }
 }
示例#14
0
 /**
  * Performs an item update
  *
  * @param item the updated cell type class instance
  * @param empty true if the item is empty
  */
 @Override
 public void updateItem(PropertyType item, boolean empty) {
   super.updateItem(item, empty);
   if (empty) {
     setText(null);
     setGraphic(null);
   } else {
     if (isEditing()) {
       if (textField != null) {
         textField.setText(getString());
       }
       setText(null);
       setGraphic(textField);
     } else {
       setText(getString());
       setGraphic(null);
     }
   }
 }
  @Override
  protected void updateItem(IlliquidMainSalesStatusBean item, boolean empty) {
    super.updateItem(item, empty);
    if ((!isEmpty()) && (item != null)) {
      StringBuilder tooltext = new StringBuilder();
      HBox hb = new HBox();
      hb.setAlignment(Pos.CENTER);
      VBox vb = new VBox();
      vb.setAlignment(Pos.CENTER);

      double totalCount =
          item.getCountTvr() + item.getDays30sale() + item.getDays60sale() + item.getDays90sale();
      double proc30;
      double proc60;
      double proc90;
      if (totalCount > 0) {
        proc30 = item.getDays30sale() / totalCount;
        proc60 = item.getDays60sale() / totalCount;
        proc90 = item.getDays90sale() / totalCount;
      } else {
        proc30 = 1;
        proc60 = 1;
        proc90 = 1;
      }

      if (proc30 == 0) {
        hb.getChildren().add(new ImageView(imEmpty));
        vb.getChildren().add(new ImageView(imEmpty));
      } else if (proc30 < 0.10) {
        hb.getChildren().add(new ImageView(imRed));
        vb.getChildren().add(new ImageView(imRed));
      } else if (proc30 >= 0.10 && proc30 < 0.30) {
        hb.getChildren().add(new ImageView(imYelow));
        vb.getChildren().add(new ImageView(imYelow));
      } else if (proc30 >= 0.30) {
        hb.getChildren().add(new ImageView(imGreen));
        vb.getChildren().add(new ImageView(imGreen));
      }
      tooltext
          .append("1 міс. {")
          .append(DateConverters.getDateToStr(per30From))
          .append(" - ")
          .append(DateConverters.getDateToStr(now))
          .append("}:  ")
          .append(String.format("%.2f", proc30 * 100))
          .append("%\n");

      if (proc60 == 0) {
        hb.getChildren().add(new ImageView(imEmpty));
        vb.getChildren().add(new ImageView(imEmpty));
      } else if (proc60 < 0.10) {
        hb.getChildren().add(new ImageView(imRed));
        vb.getChildren().add(new ImageView(imRed));
      } else if (proc60 >= 0.10 && proc60 < 0.30) {
        hb.getChildren().add(new ImageView(imYelow));
        vb.getChildren().add(new ImageView(imYelow));
      } else if (proc60 >= 0.30) {
        hb.getChildren().add(new ImageView(imGreen));
        vb.getChildren().add(new ImageView(imGreen));
      }
      tooltext
          .append("2 міс. {")
          .append(DateConverters.getDateToStr(per60From))
          .append(" - ")
          .append(DateConverters.getDateToStr(per30From))
          .append("}:  ")
          .append(String.format("%.2f", proc60 * 100))
          .append("%\n");

      if (proc90 == 0) {
        hb.getChildren().add(new ImageView(imEmpty));
        vb.getChildren().add(new ImageView(imEmpty));
      } else if (proc90 < 0.10) {
        hb.getChildren().add(new ImageView(imRed));
        vb.getChildren().add(new ImageView(imRed));
      } else if (proc90 >= 0.10 && proc90 < 0.30) {
        hb.getChildren().add(new ImageView(imYelow));
        vb.getChildren().add(new ImageView(imYelow));
      } else if (proc90 >= 0.30) {
        hb.getChildren().add(new ImageView(imGreen));
        vb.getChildren().add(new ImageView(imGreen));
      }
      tooltext
          .append("3 міс. {")
          .append(DateConverters.getDateToStr(per90From))
          .append(" - ")
          .append(DateConverters.getDateToStr(per60From))
          .append("}:  ")
          .append(String.format("%.2f", proc90 * 100))
          .append("%");
      tooltip.setText(tooltext.toString());
      tooltip.setGraphic(vb);
      setTooltip(tooltip);
      setGraphic(hb);
    } else {
      setGraphic(null);
    }
  }
示例#16
0
 @Override
 public void updateItem(Integer item, boolean empty) {
   super.updateItem(item, empty);
   setText(empty ? null : getString());
   setGraphic(null);
 }