// https://docs.oracle.com/javafx/2/ui_controls/table-view.htm
 @SuppressWarnings("unchecked")
 public DataPanel(final String string) {
   super(string);
   tableView = new ScrollPane();
   tableView.setPrefSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE);
   tableView.setMaxSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE);
   // set(MsstGuiPckg.getInstance().getGuiPreferredSize().propertyDataPanelWithHeight(),
   // MsstGuiPckg.getInstance().getGuiPreferredSize().propertyDataPanelWithWidth());
   elementName = new TableColumn<>("element-name");
   elementValue = new TableColumn<>("element-value");
   elementName.setCellValueFactory(new PropertyValueFactory<TableEntry, String>("elementName"));
   elementValue.setCellValueFactory(new PropertyValueFactory<TableEntry, String>("elementValue"));
   dataTable = new TableView<TableEntry>();
   dataTable.getColumns().addAll(elementName, elementValue);
   dataTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
   dataTable.setPrefHeight(
       MsstGuiPckg.getInstance().getGuiPreferredSize().propertyDataPanelWithHeight());
   dataTable.setPrefWidth(
       MsstGuiPckg.getInstance().getGuiPreferredSize().propertyDataPanelWithWidth());
   dataTable.setEditable(true);
   tableView.setContent(dataTable);
   ;
   tableView.setFitToHeight(true);
   tableView.setFitToWidth(true);
   setContent(tableView);
 }
示例#2
0
  @Override
  public void initialize() {
    disputesTable = new TableView<>();
    VBox.setVgrow(disputesTable, Priority.SOMETIMES);
    disputesTable.setMinHeight(150);
    root.getChildren().add(disputesTable);

    TableColumn<Dispute, Dispute> tradeIdColumn = getTradeIdColumn();
    disputesTable.getColumns().add(tradeIdColumn);
    TableColumn<Dispute, Dispute> roleColumn = getRoleColumn();
    disputesTable.getColumns().add(roleColumn);
    TableColumn<Dispute, Dispute> dateColumn = getDateColumn();
    disputesTable.getColumns().add(dateColumn);
    TableColumn<Dispute, Dispute> contractColumn = getContractColumn();
    disputesTable.getColumns().add(contractColumn);
    TableColumn<Dispute, Dispute> stateColumn = getStateColumn();
    disputesTable.getColumns().add(stateColumn);

    disputesTable.getSortOrder().add(dateColumn);
    disputesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    Label placeholder = new Label("There are no open tickets");
    placeholder.setWrapText(true);
    disputesTable.setPlaceholder(placeholder);
    disputesTable.getSelectionModel().clearSelection();

    disputeChangeListener = (observableValue, oldValue, newValue) -> onSelectDispute(newValue);
  }
  @FXML
  void initialize() {
    getAllImageViewsForButtons();
    configureWidthHeightForImageViews();
    configureButtons();
    contentPane.setAlignment(Pos.CENTER);

    // show all customers and all employees
    titleLabel.setText("All Customers and All Employees");
    TableView table = new TableView();

    TableColumn fnCol = new TableColumn("First Name");
    fnCol.setCellValueFactory(new PropertyValueFactory<>("firstName"));
    TableColumn lnCol = new TableColumn("Last Name");
    lnCol.setCellValueFactory(new PropertyValueFactory<>("lastName"));
    TableColumn emailCol = new TableColumn("email");
    emailCol.setCellValueFactory(new PropertyValueFactory<>("email"));

    table.getColumns().addAll(fnCol, lnCol, emailCol);

    ObservableList<Person> data =
        FXCollections.observableArrayList(operation.getAllCustomersAndEmployees());
    table.setItems(data);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    contentPane.getChildren().add(table);
  }
示例#4
0
  private Pane buildUpperArea() {

    Pane up = new Pane();
    up.prefHeightProperty().bind(this.heightProperty());
    up.prefWidthProperty().bind(this.widthProperty());

    TableView<DebateDetails> table = new TableView<DebateDetails>();
    table.prefHeightProperty().bind(up.heightProperty());
    table.prefWidthProperty().bind(up.widthProperty());

    final Label label = new Label("Debate Tournament");
    label.setFont(new Font("Arial", 20));

    table.setEditable(false);

    table.getChildrenUnmodifiable().clear();
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    TableColumn<DebateDetails, String> divCol = new TableColumn<DebateDetails, String>("Division");
    divCol.setCellValueFactory(new PropertyValueFactory<>("division"));

    TableColumn<DebateDetails, String> teamCountCol =
        new TableColumn<DebateDetails, String>("Team Count");
    teamCountCol.setCellValueFactory(new PropertyValueFactory<>(String.valueOf("teamCount")));

    TableColumn<DebateDetails, String> debCountCol =
        new TableColumn<DebateDetails, String>("Debate Count");
    debCountCol.setCellValueFactory(new PropertyValueFactory<>(String.valueOf("totalMatch")));

    TableColumn<DebateDetails, String> debCompCol =
        new TableColumn<DebateDetails, String>("Debates Completed ");
    debCompCol.setCellValueFactory(new PropertyValueFactory<>(String.valueOf("matchCompleted")));

    TableColumn<DebateDetails, String> debRemCol =
        new TableColumn<DebateDetails, String>("Upcoming Debates");
    debRemCol.setCellValueFactory(new PropertyValueFactory<>(String.valueOf("matchRemaining")));

    final ObservableList<DebateDetails> data =
        FXCollections.observableArrayList(TeamManager.getDebateDetails());

    table.setItems(data);
    table.getColumns().add(divCol);
    table.getColumns().add(teamCountCol);
    table.getColumns().add(debCountCol);
    table.getColumns().add(debCompCol);
    table.getColumns().add(debRemCol);

    final VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(label, table);
    up.getChildren().add(vbox);

    return up;
  }
示例#5
0
  private void setupTracksView() {
    TableColumn titleColumn = new TableColumn("Title");
    titleColumn.setSortable(false);
    titleColumn.setMinWidth(USE_COMPUTED_SIZE);
    titleColumn.setCellValueFactory(new PropertyValueFactory<>("title"));

    TableColumn durationColumn = new TableColumn("Duration");
    durationColumn.setMinWidth(60);
    durationColumn.setMaxWidth(60);
    durationColumn.setSortable(false);
    durationColumn.setCellValueFactory(new PropertyValueFactory<>("durationFormatted"));
    durationColumn.getStyleClass().add("text-layout-center");

    tracksView.getColumns().clear();
    tracksView.getColumns().addAll(titleColumn, durationColumn);
    tracksView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
  }
  @FXML
  private void customersButtonClicked(ActionEvent event) {
    configureButtons();
    customersButton.setGraphic(customersSelectedIMV);

    // Clear old content
    contentPane.getChildren().clear();

    titleLabel.setText("Customer Information");

    ScrollPane scrollPane = new ScrollPane();

    contentPane.getChildren().add(scrollPane);

    VBox box = new VBox();
    box.setSpacing(10);
    box.setAlignment(Pos.TOP_CENTER);
    box.setPrefWidth(900);

    // set up for ALL CUSTOMERS
    Text cHeader = new Text("All Customers");
    cHeader.setFont(new Font("System", 24));

    ObservableList<Customer> data = FXCollections.observableArrayList(operation.getAllCustomers());
    TableView cTable = new TableView();

    TableColumn cfnCol = new TableColumn("First Name");
    cfnCol.setCellValueFactory(new PropertyValueFactory<>("firstName"));
    TableColumn clnCol = new TableColumn("Last Name");
    clnCol.setCellValueFactory(new PropertyValueFactory<>("lastName"));
    TableColumn cEmailCol = new TableColumn("Email");
    cEmailCol.setCellValueFactory(new PropertyValueFactory<>("email"));
    TableColumn cUpdatedAtCol = new TableColumn("Updated At");
    cUpdatedAtCol.setCellValueFactory(new PropertyValueFactory<>("updatedAt"));
    TableColumn cDiscountCol = new TableColumn("Discount");
    cDiscountCol.setCellValueFactory(new PropertyValueFactory<>("discount"));

    cTable.getColumns().addAll(cfnCol, clnCol, cEmailCol, cUpdatedAtCol, cDiscountCol);
    cTable.setItems(data);
    cTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    box.getChildren().addAll(cHeader, cTable);
    scrollPane.setContent(box);
  }
示例#7
0
  private void setupPlaylistsView() {
    TableColumn titleColumn = new TableColumn("Title");
    titleColumn.setMinWidth(USE_COMPUTED_SIZE);
    titleColumn.setSortable(false);
    titleColumn.setCellValueFactory(new PropertyValueFactory<>("title"));

    TableColumn countColumn = new TableColumn("Tracks");
    countColumn.setMinWidth(60);
    countColumn.setMaxWidth(60);
    countColumn.setSortable(false);
    countColumn.setCellValueFactory(new PropertyValueFactory<>("count"));
    countColumn.getStyleClass().add("text-layout-right");

    playlistsView.getColumns().clear();
    playlistsView.getColumns().addAll(titleColumn, countColumn);
    playlistsView.setContextMenu(playlistsContextMenu);
    playlistsView.setPlaceholder(playlistPlaceholder);
    playlistsView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
  }
示例#8
0
  /** Starts the Gui applicaiton. */
  public void start(Stage myStage) {

    System.out.println("Inside the start() method.");

    table = new TableView<PersonBean>();
    table.setEditable(true);
    // Give the stage a title.
    myStage.setTitle("Person Spam App");
    filteredData = new FilteredList<>(personData, p -> true);
    sortedData = new SortedList<>(filteredData);
    sortedData.comparatorProperty().bind(table.comparatorProperty());

    table.setItems(sortedData);
    table.setPrefWidth(500);
    table.getStylesheets().add("resource/style.css");

    table.setColumnResizePolicy(TableView.UNCONSTRAINED_RESIZE_POLICY);

    // My edition:
    TableColumn<PersonBean, String> wholeNameCol = new TableColumn<PersonBean, String>("Full name");
    wholeNameCol.setCellValueFactory(new PropertyValueFactory("firstAndLastName"));
    wholeNameCol.setCellFactory(TextFieldTableCell.<PersonBean>forTableColumn());
    wholeNameCol.setOnEditCommit(
        (CellEditEvent<PersonBean, String> t) -> { // Start on line below
          ((PersonBean) t.getTableView().getItems().get(t.getTablePosition().getRow()))
              .setFirstAndLastName(t.getNewValue());
        });

    //		TableColumn<PersonBean, String> firstNameCol = new TableColumn<PersonBean, String>("First
    // Name");
    //		firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
    //		firstNameCol.setCellFactory(TextFieldTableCell.<PersonBean> forTableColumn());
    //		firstNameCol.setOnEditCommit((CellEditEvent<PersonBean, String> t) -> {
    //
    //	((PersonBean)t.getTableView().getItems().get(t.getTablePosition().getRow())).setFirstName(t.getNewValue());
    //		});
    //
    //		TableColumn<PersonBean, String> lastNameCol = new TableColumn<PersonBean, String>("Last
    // Name");
    //		lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
    //		lastNameCol.setCellFactory(TextFieldTableCell.<PersonBean> forTableColumn());
    //		lastNameCol.setOnEditCommit((CellEditEvent<PersonBean, String> t) -> {
    //			((PersonBean)
    // t.getTableView().getItems().get(t.getTablePosition().getRow())).setLastName(t.getNewValue());
    //		});

    TableColumn<PersonBean, String> emailCol = new TableColumn<PersonBean, String>("Email");
    emailCol.setCellValueFactory(new PropertyValueFactory("email"));
    emailCol.setCellFactory(TextFieldTableCell.<PersonBean>forTableColumn());
    emailCol.setOnEditCommit(
        (CellEditEvent<PersonBean, String> t) -> {
          ((PersonBean) t.getTableView().getItems().get(t.getTablePosition().getRow()))
              .setEmail(t.getNewValue());
        });

    TableColumn<PersonBean, String> genderCol = new TableColumn<PersonBean, String>("Gender");
    genderCol.setCellValueFactory(new PropertyValueFactory("gender"));
    genderCol.setCellFactory(TextFieldTableCell.<PersonBean>forTableColumn());
    genderCol.setOnEditCommit(
        (CellEditEvent<PersonBean, String> t) -> {
          ((PersonBean) t.getTableView().getItems().get(t.getTablePosition().getRow()))
              .setGender(t.getNewValue());
        });

    TableColumn<PersonBean, Integer> ageCol = new TableColumn<PersonBean, Integer>("Age");
    ageCol.setCellValueFactory(new PropertyValueFactory("age"));
    ageCol.setCellFactory(
        TextFieldTableCell.<PersonBean, Integer>forTableColumn(new IntegerStringConverter()));
    ageCol.setOnEditCommit(
        (CellEditEvent<PersonBean, Integer> t) -> {
          ((PersonBean) t.getTableView().getItems().get(t.getTablePosition().getRow()))
              .setAge(t.getNewValue());
        });
    table.getColumns().setAll(wholeNameCol, emailCol, genderCol, ageCol);
    ageCol.setId("white");

    Button allButton = new Button("All");
    allButton.setMinSize(100, 10);
    allButton.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            System.out.println("Show all!");
            filteredData.setPredicate(showAll());
          }
        });

    Button maleButton = new Button("Male");
    maleButton.setMinSize(100, 10);
    maleButton.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            System.out.println("Show male");
            // printIt();
            filteredData.setPredicate(isMale());
          }
        });
    Button femaleButton = new Button("Female");
    femaleButton.setMinSize(100, 10);
    femaleButton.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            System.out.println("Show female");
            filteredData.setPredicate(isFemale());
          }
        });

    Button over18Button = new Button("Over 18");
    over18Button.setMinSize(100, 10);
    over18Button.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            System.out.println("Above 18");
            // filteredData.setPredicate(over18());
            filteredData.setPredicate(
                new Predicate<PersonBean>() {
                  public boolean test(PersonBean p) {
                    return p.getAge() > 17;
                  }
                });
          }
        });

    Button addButton = new Button("Add row");
    addButton.setMinSize(100, 10);
    addButton.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            System.out.println("Add me!");
            filteredData.setPredicate(showAll());
            addRow();
          }
        });

    Button removeButton = new Button("Delete row");
    removeButton.setMinSize(100, 10);
    removeButton.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            System.out.println("delete me!");
            List items = new ArrayList(table.getSelectionModel().getSelectedItems());
            personData.removeAll(items);
            table.getSelectionModel().clearSelection();
          }
        });

    // Create a root node. In this case, a flow layout
    // is used, but several alternatives exist.
    FlowPane rootNode = new FlowPane();

    rootNode.getStylesheets().add("resource/style.css");

    rootNode
        .getChildren()
        .addAll(table, allButton, maleButton, femaleButton, over18Button, addButton, removeButton);
    // Create a scene.
    Scene myScene = new Scene(rootNode, 800, 800);

    // Set the scene on the stage.
    myStage.setScene(myScene);

    // Show the stage and its scene.
    myStage.show();
  }
  /** @return Top-level {@link Node} */
  public Node create() {
    // Layout:
    //
    // | table |  [Add]
    // | table |  [Remove]
    // | table |
    // | table |

    // Create table with editable columns for type Double (supported as Number)
    final TableColumn<Point, Number> x_col = new TableColumn<>(Messages.PointsTable_X);
    x_col.setCellValueFactory(
        new Callback<TableColumn.CellDataFeatures<Point, Number>, ObservableValue<Number>>() {
          @Override
          public ObservableValue<Number> call(CellDataFeatures<Point, Number> param) {
            return new SimpleDoubleProperty(param.getValue().getX());
          }
        });
    x_col.setCellFactory(
        TextFieldTableCell.<Point, Number>forTableColumn(new NumberStringConverter()));
    x_col.setOnEditCommit(
        event -> {
          final int row = event.getTablePosition().getRow();
          points.setX(row, event.getNewValue().doubleValue());
        });

    final TableColumn<Point, Number> y_col = new TableColumn<>(Messages.PointsTable_Y);
    y_col.setCellValueFactory(
        new Callback<TableColumn.CellDataFeatures<Point, Number>, ObservableValue<Number>>() {
          @Override
          public ObservableValue<Number> call(CellDataFeatures<Point, Number> param) {
            return new SimpleDoubleProperty(param.getValue().getY());
          }
        });
    y_col.setCellFactory(
        TextFieldTableCell.<Point, Number>forTableColumn(new NumberStringConverter()));
    y_col.setOnEditCommit(
        event -> {
          final int row = event.getTablePosition().getRow();
          points.setY(row, event.getNewValue().doubleValue());
        });

    final ObservableList<Point> data = new PointsAdapter(points);
    final TableView<Point> table = new TableView<>(data);
    table.getColumns().add(x_col);
    table.getColumns().add(y_col);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    table.setPlaceholder(new Label(Messages.PointsTable_Empty));
    table.setEditable(true);

    // Buttons
    final Button add = new Button(Messages.Add, JFXUtil.getIcon("add.png"));
    add.setMaxWidth(Double.MAX_VALUE);
    add.setOnAction(event -> data.add(new Point(0, 0)));

    final Button remove = new Button(Messages.Remove, JFXUtil.getIcon("delete.png"));
    remove.setMaxWidth(Double.MAX_VALUE);
    remove.setOnAction(
        event -> {
          final int sel = table.getSelectionModel().getSelectedIndex();
          if (sel >= 0) data.remove(sel);
        });

    final VBox buttons = new VBox(10, add, remove);
    final HBox content = new HBox(10, table, buttons);
    HBox.setHgrow(table, Priority.ALWAYS);
    return content;
  }
示例#10
0
  public ChooseStudent(Stage primaryStage, ObservableList<Student> data) {

    Button addnewsub = new Button("ADD NEW SUBJECT");
    addnewsub.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            new AddNewSubject();
          }
        });
    this.student = student;
    this.data = data;
    Button report = new Button("REPORT");
    report.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            new Report(data);
          }
        });
    table = new TableView<Student>();
    table.getColumns().addAll(Student.getColumn(table));
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    table.setItems(data);
    table.setOnMouseClicked(
        new EventHandler<javafx.scene.input.MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            if (event.getClickCount() > 0) {
              if (table.getSelectionModel().getSelectedIndex() >= 0) {
                new AddSubject(primaryStage, table.getSelectionModel().getSelectedItem(), data);
              }
            }
          }
        });
    Label labelsearch = new Label("Search ID : ");
    final TextField searchField = new TextField();
    searchField.setPromptText("Search ID...");
    searchField
        .textProperty()
        .addListener(
            new InvalidationListener() {

              @Override
              public void invalidated(Observable o) {

                if (searchField.textProperty().get().isEmpty()) {

                  table.setItems(data);

                  return;
                }

                ObservableList<Student> tableItems = FXCollections.observableArrayList();

                ObservableList<TableColumn<Student, ?>> cols = table.getColumns();

                for (int i = 0; i < data.size(); i++) {

                  for (int j = 0; j < cols.size(); j++) {

                    TableColumn col = cols.get(j);

                    String cellValue = col.getCellData(data.get(i)).toString();

                    cellValue = cellValue.toLowerCase();

                    if (cellValue.contains(searchField.textProperty().get().toLowerCase())) {

                      tableItems.add(data.get(i));

                      break;
                    }
                  }
                }

                table.setItems(tableItems);
                table.setOnMouseClicked(
                    new EventHandler<javafx.scene.input.MouseEvent>() {
                      @Override
                      public void handle(MouseEvent event) {
                        if (event.getClickCount() > 0) {
                          if (table.getSelectionModel().getSelectedIndex() >= 0) {
                            new AddSubject(
                                primaryStage, table.getSelectionModel().getSelectedItem(), data);
                          }
                        }
                      }
                    });
              }
            });

    HBox hb = new HBox();
    hb.getChildren().addAll(labelsearch, searchField, addnewsub, report);
    hb.setSpacing(30);
    VBox vb = new VBox();
    vb.getChildren().addAll(table, hb);
    Scene scene2 = new Scene(vb, 800, 500);
    primaryStage.setScene(scene2);
    primaryStage.show();
  }
示例#11
0
  public ChooseStudent(Stage primaryStage) {
    data.addAll(new Student("Fahmi", "1300001", "3"));
    data.addAll(new Student("Ahmad", "1300002", "3"));
    data.addAll(new Student("Nasuha", "1300003", "3"));
    data.addAll(new Student("Kimi", "1300004", "3"));
    data.addAll(new Student("Alia", "1300005", "3"));
    data.addAll(new Student("Ariff", "1400001", "2"));
    data.addAll(new Student("Faiz", "1400002", "2"));
    data.addAll(new Student("Osman", "1400003", "2"));
    data.addAll(new Student("Hadi", "1200001", "4"));
    data.addAll(new Student("Nabilah", "1300006", "3"));
    data.addAll(new Student("Syafiqah", "1500001", "1"));
    data.addAll(new Student("Amalina", "1200002", "1"));
    data.addAll(new Student("Intan", "1500002", "1"));
    data.addAll(new Student("Rahman", "1400004", "1"));
    data.addAll(new Student("Hazim", "1000001", "6"));
    data.addAll(new Student("Azri", "1100001", "5"));
    data.addAll(new Student("Hanif", "1100002", "5"));
    data.addAll(new Student("Nazim", "1100003", "5"));
    data.addAll(new Student("Faris", "1400005", "2"));
    data.addAll(new Student("Firdaus", "1500003", "1"));
    Button addnewsub = new Button("ADD NEW SUBJECT");
    suboptions.addAll(new Subject("Bahasa Malaysia", "BM501", "Cikgu Suraya", 55.55));
    addnewsub.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            new AddNewSubject();
          }
        });
    table = new TableView<Student>();
    table.getColumns().addAll(Student.getColumn(table));
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    Button report = new Button("REPORT");
    table.setItems(data);
    table.setOnMouseClicked(
        new EventHandler<javafx.scene.input.MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            if (event.getClickCount() > 0) {
              if (table.getSelectionModel().getSelectedIndex() >= 0) {
                new AddSubject(primaryStage, table.getSelectionModel().getSelectedItem(), data);
              }
            }
          }
        });
    final TextField searchField = new TextField();
    searchField.setPromptText("Search ID...");
    searchField
        .textProperty()
        .addListener(
            new InvalidationListener() {

              @Override
              public void invalidated(Observable o) {

                if (searchField.textProperty().get().isEmpty()) {

                  table.setItems(data);

                  return;
                }

                ObservableList<Student> tableItems = FXCollections.observableArrayList();

                ObservableList<TableColumn<Student, ?>> cols = table.getColumns();

                for (int i = 0; i < 19; i++) {

                  for (int j = 0; j < cols.size(); j++) {

                    TableColumn col = cols.get(j);

                    String cellValue = col.getCellData(data.get(i)).toString();

                    cellValue = cellValue.toLowerCase();

                    if (cellValue.contains(searchField.textProperty().get().toLowerCase())) {

                      tableItems.add(data.get(i));

                      break;
                    }
                  }
                }

                table.setItems(tableItems);
              }
            });
    HBox hb = new HBox();
    hb.getChildren().addAll(searchField, addnewsub);
    VBox vb = new VBox();
    vb.getChildren().addAll(table, hb);
    Scene scene2 = new Scene(vb, 800, 500);
    primaryStage.setScene(scene2);
    primaryStage.show();
  }
示例#12
0
  private Tuple2<TableView<Offer>, VBox> getOfferTable(Offer.Direction direction) {
    TableView<Offer> tableView = new TableView();

    // price
    TableColumn<Offer, Offer> priceColumn = new TableColumn<>();
    priceColumn.textProperty().bind(priceColumnLabel);
    priceColumn.setMinWidth(120);
    priceColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    priceColumn.setCellFactory(
        new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() {
          @Override
          public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) {
            return new TableCell<Offer, Offer>() {
              @Override
              public void updateItem(final Offer item, boolean empty) {
                super.updateItem(item, empty);
                if (item != null && !empty) setText(formatter.formatFiat(item.getPrice()));
                else setText("");
              }
            };
          }
        });
    tableView.getColumns().add(priceColumn);

    // amount
    TableColumn<Offer, Offer> amountColumn = new TableColumn<>("Amount (BTC)");
    amountColumn.setText("Amount (BTC)");
    amountColumn.setMinWidth(120);
    amountColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    amountColumn.setCellFactory(
        new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() {
          @Override
          public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) {
            return new TableCell<Offer, Offer>() {
              @Override
              public void updateItem(final Offer item, boolean empty) {
                super.updateItem(item, empty);
                if (item != null && !empty) setText(formatter.formatCoin(item.getAmount()));
                else setText("");
              }
            };
          }
        });
    tableView.getColumns().add(amountColumn);

    // volume
    TableColumn<Offer, Offer> volumeColumn = new TableColumn<>("Amount (BTC)");
    volumeColumn.setMinWidth(120);
    volumeColumn.textProperty().bind(volumeColumnLabel);
    volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    volumeColumn.setCellFactory(
        new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() {
          @Override
          public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) {
            return new TableCell<Offer, Offer>() {
              @Override
              public void updateItem(final Offer item, boolean empty) {
                super.updateItem(item, empty);
                if (item != null && !empty) setText(formatter.formatFiat(item.getOfferVolume()));
                else setText("");
              }
            };
          }
        });
    tableView.getColumns().add(volumeColumn);

    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    Label placeholder = new Label("Currently there are no offers available");
    placeholder.setWrapText(true);
    tableView.setPlaceholder(placeholder);

    Label titleLabel =
        new Label(
            direction.equals(Offer.Direction.BUY)
                ? "Offers for buy bitcoin (bid)"
                : "Offers for sell bitcoin (ask)");
    titleLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 16; -fx-alignment: center");
    UserThread.execute(() -> titleLabel.prefWidthProperty().bind(tableView.widthProperty()));

    VBox vBox = new VBox();
    vBox.setSpacing(10);
    vBox.setFillWidth(true);
    vBox.setMinHeight(150);
    vBox.getChildren().addAll(titleLabel, tableView);
    return new Tuple2<>(tableView, vBox);
  }
示例#13
0
 public void LLenarTabla() {
   cdCarrera datos = new cdCarrera();
   ObservableList<Carrera> lista = datos.listarDatos();
   tblCarrera.setItems(lista);
   tblCarrera.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
 }
  @FXML
  private void employeesButtonClicked(ActionEvent event) {
    configureButtons();
    employeesButton.setGraphic(employeesSelectedIMV);

    // Clear old content
    contentPane.getChildren().clear();

    titleLabel.setText("Employees");

    // 2 horizontal boxes for All Employees and Employees are Customers
    HBox hbox = new HBox();
    hbox.setSpacing(5);

    // 2 vboxes for each hbox
    VBox leftBox = new VBox();
    VBox rightBox = new VBox();

    // Set up All employees
    ObservableList<Employee> data = FXCollections.observableArrayList(operation.getAllEmployees());
    TableView table = new TableView();

    // Add title for all employees
    Text leftTitle = new Text("All Employees");
    leftTitle.setFont(new Font("System", 24));

    // add left table and title to left box
    leftBox.getChildren().addAll(leftTitle, table);
    leftBox.setSpacing(5);

    TableColumn efnCol = new TableColumn("First Name");
    efnCol.setCellValueFactory(new PropertyValueFactory<>("firstName"));
    TableColumn elnCol = new TableColumn("Last Name");
    elnCol.setCellValueFactory(new PropertyValueFactory<>("lastName"));
    TableColumn epositionCol = new TableColumn("Position");
    epositionCol.setCellValueFactory(new PropertyValueFactory<>("position"));
    TableColumn eemailCol = new TableColumn("Email");
    eemailCol.setCellValueFactory(new PropertyValueFactory<>("email"));
    TableColumn elastworkedCol = new TableColumn("Last Worked");
    elastworkedCol.setCellValueFactory(new PropertyValueFactory<>("lastWorked"));

    table.getColumns().addAll(efnCol, elnCol, epositionCol, eemailCol, elastworkedCol);
    table.setItems(data);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    // Set up for employees and also customers
    ObservableList<Employee> rightData =
        FXCollections.observableArrayList(operation.getEmployeesWhoAreCustomers());
    TableView rightTable = new TableView();

    // Add title for all employees
    Text rightTitle = new Text("Employees Are Customers");
    rightTitle.setFont(new Font("System", 24));

    TableColumn RfnCol = new TableColumn("First Name");
    RfnCol.setCellValueFactory(new PropertyValueFactory<>("firstName"));
    TableColumn RlnCol = new TableColumn("Last Name");
    RlnCol.setCellValueFactory(new PropertyValueFactory<>("lastName"));
    TableColumn RpositionCol = new TableColumn("Position");
    RpositionCol.setCellValueFactory(new PropertyValueFactory<>("position"));
    TableColumn RemailCol = new TableColumn("Email");
    RemailCol.setCellValueFactory(new PropertyValueFactory<>("email"));
    TableColumn RlastworkedCol = new TableColumn("Last Worked");
    RlastworkedCol.setCellValueFactory(new PropertyValueFactory<>("lastWorked"));

    rightTable.getColumns().addAll(RfnCol, RlnCol, RpositionCol, RemailCol, RlastworkedCol);
    rightTable.setItems(rightData);

    // add right table to the right box
    rightBox.getChildren().addAll(rightTitle, rightTable);
    rightBox.setSpacing(5);

    hbox.getChildren().addAll(leftBox, rightBox);
    hbox.setSpacing(10);
    hbox.setAlignment(Pos.CENTER);

    // add hbox to content pane
    contentPane.getChildren().add(hbox);
  }
  @FXML
  private void reservationsButtonClicked(ActionEvent event) {
    configureButtons();
    reservationsButton.setGraphic(reservationsSelectedIMV);

    // Clear the content of contentPane
    contentPane.getChildren().clear();

    // Set title
    titleLabel.setText("Reservations");

    // Make box for weekly availability and reservations
    VBox box = new VBox();
    box.setSpacing(10);
    box.setAlignment(Pos.TOP_CENTER);
    box.setPrefWidth(900);

    // box for availability
    VBox abox = new VBox();
    box.setSpacing(10);
    box.setAlignment(Pos.TOP_CENTER);
    box.setPrefWidth(900);

    // box for reservations
    VBox resbox = new VBox();
    box.setSpacing(10);
    box.setAlignment(Pos.TOP_CENTER);
    box.setPrefWidth(900);

    // set up for weekly table availability
    Text aHeader = new Text("Tables still available");
    aHeader.setFont(new Font("System", 24));

    TableView aTable = new TableView();
    TableColumn aDateCol = new TableColumn("Date");
    aDateCol.setCellValueFactory(new PropertyValueFactory<>("date"));
    TableColumn tablesCol = new TableColumn("Tables Available");
    tablesCol.setCellValueFactory(new PropertyValueFactory<>("tablesAvailable"));

    // add table and title to availability box
    abox.getChildren().addAll(aHeader, aTable);
    abox.setSpacing(5);

    // set width for all cols
    aDateCol.setMinWidth(100);
    tablesCol.setMinWidth(100);

    aTable.getColumns().addAll(aDateCol, tablesCol);
    // Populate data to the table view
    operation.callDates();
    ObservableList<Availability> adata =
        FXCollections.observableArrayList(operation.getWeeklyAvailability());
    aTable.setItems(adata);
    aTable.setMaxHeight(235);
    aTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    // set up for reservations
    Text resHeader = new Text("All Reservations");
    resHeader.setFont(new Font("System", 24));

    TableView resTable = new TableView();
    TableColumn firstNameCol = new TableColumn("First Name");
    firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName"));
    TableColumn lastNameCol = new TableColumn("Last Name");
    lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName"));
    TableColumn tidCol = new TableColumn("tID");
    tidCol.setCellValueFactory(new PropertyValueFactory<>("tID"));
    TableColumn partySizeCol = new TableColumn("Party Size");
    partySizeCol.setCellValueFactory(new PropertyValueFactory<>("partySize"));
    TableColumn seatsCol = new TableColumn("Seats");
    seatsCol.setCellValueFactory(new PropertyValueFactory<>("seats"));
    TableColumn dateCol = new TableColumn("Reservation Date");
    dateCol.setCellValueFactory(new PropertyValueFactory<>("reservationDate"));

    // set width for all cols
    firstNameCol.setMinWidth(100);
    lastNameCol.setMinWidth(100);
    tidCol.setMinWidth(100);
    partySizeCol.setMinWidth(100);
    seatsCol.setMinWidth(100);
    dateCol.setMinWidth(300);

    // add table and title to availability box
    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setContent(resTable);
    scrollPane.setFitToWidth(true);
    resbox.getChildren().addAll(resHeader, scrollPane);
    resbox.setSpacing(5);

    resTable
        .getColumns()
        .addAll(firstNameCol, lastNameCol, tidCol, partySizeCol, seatsCol, dateCol);
    // Populate data to the table view
    ObservableList<ReservationInfo> resdata =
        FXCollections.observableArrayList(operation.getAllReservations());
    resTable.setItems(resdata);
    resTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    // add table view to content pane
    box.getChildren().addAll(abox, resbox);
    contentPane.getChildren().add(box);
  }