private final CustomMenuItem createHeaderItem(final String header) {
   final CustomMenuItem item = new CustomMenuItem(new Text(header), false);
   item.getStyleClass().add("ac-menu-label");
   item.setHideOnClick(false);
   item.setMnemonicParsing(false);
   return item;
 }
예제 #2
0
  /**
   * Populate the pop-up box.
   *
   * @param index - index of the task
   * @param task - task to be displayed
   */
  private void populatePopup(int index, Task task) {
    ArrayList<String> displayList = getDisplayItems(index, task);
    ArrayList<CustomMenuItem> menuItems = new ArrayList<CustomMenuItem>();

    for (int i = 0; i < displayList.size(); i++) {
      String str = displayList.get(i);
      Label label = new Label(str);
      CustomMenuItem item = new CustomMenuItem(label, true);

      item.setOnAction(
          new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
              replaceText(str);
              positionCaret(str.length());
            }
          });

      menuItems.add(item);
    }

    popupMenu.getItems().clear();
    popupMenu.getItems().addAll(menuItems);
  }
 @Override
 public String toString() {
   return ((Text) label.getContent()).getText()
       + " at "
       + expected
       + " ("
       + results.size()
       + "): "
       + results.toString();
 }
 protected boolean textIs(final String str) {
   return ((Text) label.getContent()).getText().equals(str);
 }