Java 类javafx.util.Callback 实例源码

项目:voogasalad-ltub    文件:ComponentSelectorPane.java   
public ComponentSelectorPane(String listTitle, ObservableList<Class<? extends Component>> displayedData, SpriteDataPane infoPane) {
    this.infoPane=infoPane;
    this.setPrefWidth(PREF_WIDTH);
    ListView<Class<? extends Component>> componentDisplay = new ListView<>();
    componentDisplay.setItems(displayedData);

    componentDisplay.setCellFactory(
            new Callback<ListView<Class<? extends Component>>, ListCell<Class<? extends Component>>>() {
                @Override
                public ListCell<Class<? extends Component>> call(ListView<Class<? extends Component>> list) {
                    return new ComponentCustomizerOption();
                }
            });

    Label title = new Label(listTitle);
    this.getChildren().addAll(title, componentDisplay);
}
项目:marathonv5    文件:MarathonFileChooser.java   
private void initListView() {
    if (!doesAllowChildren) {
        fillUpChildren(fileChooserInfo.getRoot());
    }
    childrenListView.setCellFactory(new Callback<ListView<File>, ListCell<File>>() {
        @Override public ListCell<File> call(ListView<File> param) {
            return new ChildrenFileCell();
        }
    });
    childrenListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (fileChooserInfo.isFileCreation()) {
            return;
        }
        File selectedItem = childrenListView.getSelectionModel().getSelectedItem();
        if (selectedItem == null) {
            fileNameBox.clear();
        }
    });
}
项目:marathonv5    文件:MarathonFileChooser.java   
private void initTreeView() {
    parentTreeView.setCellFactory(new Callback<TreeView<File>, TreeCell<File>>() {
        @Override public TreeCell<File> call(TreeView<File> param) {
            return new ParentFileCell();
        }
    });
    parentTreeView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newVlaue) -> {
        TreeItem<File> selectedItem = parentTreeView.getSelectionModel().getSelectedItem();
        if (selectedItem != null) {
            newFolderButton.setDisable(false);
            fileNameBox.setEditable(true);
            File selectedFile = selectedItem.getValue();
            fillUpChildren(selectedFile);
        } else {
            fileNameBox.setEditable(false);
            newFolderButton.setDisable(true);
            childrenListView.getItems().clear();
        }
    });
    File root = fileChooserInfo.getRoot();
    TreeItem<File> rootItem = new TreeItem<>(root);
    parentTreeView.setRoot(rootItem);
    rootItem.setExpanded(true);
    parentTreeView.getSelectionModel().select(0);
    populateChildren(root, rootItem);
}
项目:marathonv5    文件:FunctionStage.java   
private Node createTree() {
    VBox treeContentBox = new VBox();
    tree.setRoot(functionInfo.getRoot(true));
    tree.setShowRoot(false);
    tree.getSelectionModel().selectedItemProperty().addListener(new TreeViewSelectionChangeListener());
    tree.setCellFactory(new Callback<TreeView<Object>, TreeCell<Object>>() {
        @Override public TreeCell<Object> call(TreeView<Object> param) {
            return new FunctionTreeCell();
        }
    });
    filterByName.setOnAction((e) -> {
        tree.setRoot(functionInfo.refreshNode(filterByName.isSelected()));
        expandAll();
    });
    filterByName.setSelected(true);
    expandAll();
    treeContentBox.getChildren().addAll(topButtonBar, tree, filterByName);
    VBox.setVgrow(tree, Priority.ALWAYS);
    return treeContentBox;
}
项目:marathonv5    文件:CompositeLayout.java   
private void initComponents() {
    optionBox.setItems(model);
    optionBox.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
        if (newValue != null) {
            updateTabPane();
        }
    });
    optionBox.setCellFactory(new Callback<ListView<PlugInModelInfo>, ListCell<PlugInModelInfo>>() {
        @Override public ListCell<PlugInModelInfo> call(ListView<PlugInModelInfo> param) {
            return new LauncherCell();
        }
    });
    optionTabpane.setId("CompositeTabPane");
    optionTabpane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
    optionTabpane.getStyleClass().add(TabPane.STYLE_CLASS_FLOATING);
    VBox.setVgrow(optionTabpane, Priority.ALWAYS);
}
项目:marathonv5    文件:JavaFXCheckBoxTreeTableCell.java   
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public String _getValue() {
    CheckBoxTreeTableCell cell = (CheckBoxTreeTableCell) node;
    Callback selectedStateCallback = cell.getSelectedStateCallback();
    String cbText;
    if (selectedStateCallback != null) {
        ObservableValue<Boolean> call = (ObservableValue<Boolean>) selectedStateCallback.call(cell.getItem());
        int selection = call.getValue() ? 2 : 0;
        cbText = JavaFXCheckBoxElement.states[selection];
    } else {
        Node cb = cell.getGraphic();
        JavaFXElement comp = (JavaFXElement) JavaFXElementFactory.createElement(cb, driver, window);
        cbText = comp._getValue();

    }
    String cellText = cell.getText();
    if (cellText == null) {
        cellText = "";
    }
    String text = cellText + ":" + cbText;
    return text;
}
项目:springfx    文件:ModalDialog.java   
public ModalDialog(final Modal controller, URL fxml, Window owner, StageStyle style, Modality modality, ResourceBundle bundle) {
    super(style);
    initOwner(owner);
    initModality(modality);
    FXMLLoader loader = new FXMLLoader(fxml);
    loader.setResources(bundle);
    try {
        loader.setControllerFactory(new Callback<Class<?>, Object>() {
            public Object call(Class<?> aClass) {
                return controller;
            }
        });
        controller.setDialog(this);
        scene = new Scene((Parent) loader.load());
        setScene(scene);
    } catch (IOException e) {
        logger.error("Error loading modal class", e);
        throw new RuntimeException(e);
    }
}
项目:marathonv5    文件:ListViewCellFactorySample.java   
public ListViewCellFactorySample() {
    final ListView<Number> listView = new ListView<Number>();
    listView.setItems(FXCollections.<Number>observableArrayList(
            100.00, -12.34, 33.01, 71.00, 23000.00, -6.00, 0, 42223.00, -12.05, 500.00,
            430000.00, 1.00, -4.00, 1922.01, -90.00, 11111.00, 3901349.00, 12.00, -1.00, -2.00,
            15.00, 47.50, 12.11

    ));

    listView.setCellFactory(new Callback<ListView<java.lang.Number>, ListCell<java.lang.Number>>() {
        @Override public ListCell<Number> call(ListView<java.lang.Number> list) {
            return new MoneyFormatCell();
        }
    });        

    listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    getChildren().add(listView);
}
项目:voogasalad-ltub    文件:PathSetter.java   
public PathSetter(ObservableList<Path> paths, String variableName){
    super(Path.class,variableName);
    this.myPaths=paths;     

    pathChoices= new ComboBox<>(myPaths);

    pathChoices.setCellFactory(new Callback<ListView<Path>, ListCell<Path>>(){
        @Override
        public ListCell<Path> call(ListView<Path> list){
            return new PathCell();
        }
    });
    pathChoices.setButtonCell(new PathButtonCell());

    this.getChildren().add(pathChoices);

}
项目:CalendarFX    文件:DayViewSkin.java   
private DayEntryView doAddEntryView(Entry<?> entry) {
    Callback<Entry<?>, DayEntryView> factory = getSkinnable().getEntryViewFactory();
    DayEntryView view = factory.call(entry);
    view.getProperties().put("control", getSkinnable()); //$NON-NLS-1$
    view.setManaged(false);

    int index = findIndex(entry);

    getChildren().add(index, view);

    if (!(entry instanceof DraggedEntry) && LoggingDomain.VIEW.isLoggable(Level.FINE)) {
        LoggingDomain.VIEW.fine("added entry view " + entry.getTitle() + ", day = " + getSkinnable().getDate());
    }

    return view;
}
项目:git-rekt    文件:BrowseRoomsScreenController.java   
/**
 * Ensures that the date pickers only allow selection of dates within the valid booking date
 * range, as defined in the specifications document.
 *
 * Chief among these rules is that bookings may not be placed more than one year in advance.
 */
private void initializeDatePickers() {
    Callback<DatePicker, DateCell> dayCellFactory =
        (final DatePicker datePicker) -> new DateCell() {
            @Override
            public void updateItem(LocalDate item, boolean empty) {
                super.updateItem(item, empty);

                if(item.isAfter(LocalDate.now().plusYears(1))) {
                    setDisable(true);
                }
                if(item.isBefore(ChronoLocalDate.from(LocalDate.now()))) {
                    setDisable(true);
                }
            }
        };
    // Disable selecting invalid check-in/check-out dates
    checkInDatePicker.setDayCellFactory(dayCellFactory);
    checkOutDatePicker.setDayCellFactory(dayCellFactory);
}
项目:Clipcon-Client    文件:MainScene.java   
/** Add participant in group list */
public void addGroupParticipantList() {
    Platform.runLater(() -> {
        groupParticipantTable.setItems(groupParticipantList);

        // Nickname column setting
        groupPartiNicknameColumn.setCellValueFactory(cellData -> cellData.getValue().getNameProperty());
        groupPartiNicknameColumn.setCellFactory(new Callback<TableColumn<User, String>, TableCell<User, String>>() {
            @Override
            public TableCell<User, String> call(TableColumn<User, String> column) {
                TableCell<User, String> tc = new TableCell<User, String>() {
                    @Override
                    public void updateItem(String item, boolean empty) {
                        if (item != null) {
                            setText(item);
                        }
                    }
                };
                tc.setAlignment(Pos.CENTER);
                return tc;
            }
        });
    });
}
项目:stvs    文件:SpecificationRow.java   
/**
 * Create a SpecificationRow from a given number of cells and an extractor. The extractor is
 * required for "deep observing", i.e. the registering of change listeners on the contents of an
 * observable collection (here, the collection of cells - to fire change events not only when
 * cells are added or removed, but also when properties in the cells change). For more information
 * on extractors, see https://docs.oracle
 * .com/javase/8/javafx/api/javafx/collections/FXCollections.html.
 *
 * @param cells The initial cells of the row
 * @param extractor The extractor to be used for deep observing on the cells
 */
public SpecificationRow(Map<String, C> cells, Callback<C, Observable[]> extractor) {
  this.cells = FXCollections.observableMap(cells);
  this.cells.addListener(this::cellsMapChanged);
  this.listeners = new ArrayList<>();
  this.comment = new SimpleStringProperty("");
  this.extractor = extractor;

  this.cells.addListener(this::listenRowInvalidation);
  comment.addListener(this::listenRowInvalidation);
  cells.values().forEach(this::subscribeToCell);
}
项目:desktop-gmail-client    文件:MainUI3Controller.java   
public void setSentListView(){
    sentMessageListView = new JFXListView<>();
    sentMessageListView.setItems(GmailMessages.sentMessages);
    sentMessageListView.setCellFactory(new Callback<ListView<FormattedMessage>, ListCell<FormattedMessage>>() {
        @Override
        public ListCell<FormattedMessage> call(ListView<FormattedMessage> param) {
            return new CustomListCell(currentFolderName);
        }
    });
    sentMessageListView.getStylesheets().add(String.valueOf(getClass().getResource("/listview.css")));
    sentMessageListView.setExpanded(true);
    sentMessageListView.depthProperty().set(1);

    sentMessageListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<FormattedMessage>() {
        @Override
        public void changed(ObservableValue<? extends FormattedMessage> observable, FormattedMessage oldValue, FormattedMessage newValue) {
            if (newValue != null) {
                if (!componentFlag) {
                    componentFlag = true;
                    screenComponent.setScreenComponent(currentFolderName, sentMessageListView.getSelectionModel().getSelectedIndex());
                    setScreenComponent();
                }
                screenComponent.setInfo(newValue);
            }
        }
    });
    /*ScrollBar listViewScrollBar = getListViewScrollBar(sentMessageListView);
    listViewScrollBar.valueProperty().addListener((observable, oldValue, newValue) -> {
        double position = newValue.doubleValue();
        ScrollBar scrollBar = getListViewScrollBar(sentMessageListView);
        if (position == scrollBar.getMax()) {
            try {
                GmailMessages.sentMessages.addAll(GmailOperations.getSentMessages(10));
            } catch (IOException e) {
                e.printStackTrace();
                NotifyUser.getNotification("Internet connection has lost", "Please check your internet connection").showInformation();
            }
        }
    });*/
}
项目:desktop-gmail-client    文件:MainUI3Controller.java   
public void setTrashListView(){
    trashMessageListView = new JFXListView<>();
    trashMessageListView.setItems(GmailMessages.trashMessages);
    trashMessageListView.setCellFactory(new Callback<ListView<FormattedMessage>, ListCell<FormattedMessage>>() {
        @Override
        public ListCell<FormattedMessage> call(ListView<FormattedMessage> param) {
            return new CustomListCell(currentFolderName);
        }
    });
    trashMessageListView.getStylesheets().add(String.valueOf(getClass().getResource("/listview.css")));
    trashMessageListView.setExpanded(true);
    trashMessageListView.depthProperty().set(1);

    trashMessageListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<FormattedMessage>() {
        @Override
        public void changed(ObservableValue<? extends FormattedMessage> observable, FormattedMessage oldValue, FormattedMessage newValue) {
            if (newValue != null) {
                if (!componentFlag) {
                    componentFlag = true;
                    screenComponent.setScreenComponent(currentFolderName);
                    setScreenComponent();
                }
                screenComponent.setInfo(newValue);
            }
        }
    });
    /*ScrollBar listViewScrollBar = getListViewScrollBar(trashMessageListView);
    listViewScrollBar.valueProperty().addListener((observable, oldValue, newValue) -> {
        double position = newValue.doubleValue();
        ScrollBar scrollBar = getListViewScrollBar(trashMessageListView);
        if (position == scrollBar.getMax()) {
            try {
                GmailMessages.trashMessages.addAll(GmailOperations.getTrashMessages(10));
            } catch (IOException e) {
                e.printStackTrace();
                NotifyUser.getNotification("Internet connection has lost", "Please check your internet connection").showInformation();
            }
        }
    });*/
}
项目:desktop-gmail-client    文件:MainUI3Controller.java   
public void setSearchListView() {
    searchMessageListView = new JFXListView<>();
    searchMessageListView.setItems(GmailMessages.searchMessages);
    searchMessageListView.setCellFactory(new Callback<ListView<FormattedMessage>, ListCell<FormattedMessage>>() {
        @Override
        public ListCell<FormattedMessage> call(ListView<FormattedMessage> param) {
            return new CustomListCell(currentFolderName);
        }
    });
    searchMessageListView.getStylesheets().add(String.valueOf(getClass().getResource("/listview.css")));
    searchMessageListView.setExpanded(true);
    searchMessageListView.depthProperty().set(1);

    searchMessageListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<FormattedMessage>() {
        @Override
        public void changed(ObservableValue<? extends FormattedMessage> observable, FormattedMessage oldValue, FormattedMessage newValue) {
            if (newValue != null) {
                if (!componentFlag) {
                    componentFlag = true;
                    screenComponent.setScreenComponent(currentFolderName);
                    setScreenComponent();
                }
                screenComponent.setInfo(newValue);
            }
        }
    });
}
项目:Matcher    文件:HierarchyTab.java   
private void init() {
    VBox vBox = new VBox();
    vBox.getChildren().add(classHierarchyTree);
    vBox.getChildren().add(ifaceList);

    Callback<TreeView<ClassInstance>, TreeCell<ClassInstance>> cellFactory = tree -> new TreeCell<ClassInstance>() { // makes entries in highLights bold
        @Override
        protected void updateItem(ClassInstance item, boolean empty) {
            super.updateItem(item, empty);

            if (empty || item == null) {
                setText(null);
                setStyle("");
            } else {
                setText(item.toString());

                if (highLights.contains(item)) {
                    setStyle("-fx-font-weight: bold;");
                } else {
                    setStyle("");
                }
            }
        }
    };

    classHierarchyTree.setCellFactory(cellFactory);

    setContent(vBox);
}
项目:voogasalad-ltub    文件:SpriteVariableSelector.java   
public SpriteVariableSelector(String variableName, DeveloperData data) {
    super(variableName);
    sprites=data.getSprites();
    availableSprites = new ComboBox<>(sprites);
    availableSprites.setCellFactory(new Callback<ListView<SpriteMakerModel>, ListCell<SpriteMakerModel>>() {
        @Override
        public ListCell<SpriteMakerModel> call(ListView<SpriteMakerModel> param) {
            return new SpriteCell();
        }
    });

    availableSprites.setButtonCell(new SpriteCell());
    this.getChildren().add(availableSprites);
}
项目:fx-media-tags    文件:FxMediaTags.java   
private Callback<ButtonType, Model> createResultConverter() {
    return new Callback<ButtonType, Model>() {
        @Override
        public Model call(ButtonType aDialogButton) {
            if (ButtonType.OK == aDialogButton) {
                return MODEL;
            }
            else {
                return null;
            }
        }
    };
}
项目:marathonv5    文件:PaginationSample.java   
public PaginationSample() {
    VBox outerBox = new VBox();
    outerBox.setAlignment(Pos.CENTER);
    //Images for our pages
    for (int i = 0; i < 7; i++) {
        images[i] = new Image(PaginationSample.class.getResource("animal" + (i + 1) + ".jpg").toExternalForm(), false);
    }

    pagination = PaginationBuilder.create().pageCount(7).pageFactory(new Callback<Integer, Node>() {           
        @Override public Node call(Integer pageIndex) {
            return createAnimalPage(pageIndex);
        }
    }).build();
    //Style can be numeric page indicators or bullet indicators
    Button styleButton = ButtonBuilder.create().text("Toggle pagination style").onAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent me) {
            if (!pagination.getStyleClass().contains(Pagination.STYLE_CLASS_BULLET)) {
                pagination.getStyleClass().add(Pagination.STYLE_CLASS_BULLET);
            } else {
                pagination.getStyleClass().remove(Pagination.STYLE_CLASS_BULLET);
            }
        }
    }).build();

    outerBox.getChildren().addAll(pagination, styleButton);
    getChildren().add(outerBox);
}
项目:everywhere    文件:Controller.java   
private void showTableData(List<SearchedResult> searchedResults) {
    ObservableList<SearchedResult> list = FXCollections.observableArrayList();
    if (searchedResults != null && searchedResults.size() != 0) {
        for (SearchedResult searchedResult: searchedResults) {
            SearchedResult result = new SearchedResult();
            result.setContext(searchedResult.getContext());
            result.setFilepath(searchedResult.getFilepath());
            result.setLastModified(searchedResult.getLastModified());
            filepathCol.setCellFactory(new Callback<TableColumn<SearchedResult, String>, TableCell<SearchedResult, String>>() {
                @Override
                public TableCell<SearchedResult, String> call(TableColumn<SearchedResult, String> col) {
                    final TableCell<SearchedResult, String> cell = new TableCell<>();
                    cell.textProperty().bind(cell.itemProperty()); // in general might need to subclass TableCell and override updateItem(...) here
                    cell.setTextFill(Color.BLUE);
                    cell.setOnMouseClicked(new EventHandler<MouseEvent>() {
                        @Override
                        public void handle(MouseEvent event) {
                            if (event.getButton() == MouseButton.PRIMARY) {
                                cell.setTextFill(Color.GRAY);
                                ClientWindow clientWindow = new ClientWindow();
                                clientWindow.getHostServices().showDocument(cell.getText());
                            }
                        }
                    });
                    return cell ;
                }
            });
            filepathCol.setCellValueFactory(new PropertyValueFactory<SearchedResult, String>("filepath"));
            contextCol.setCellValueFactory(new PropertyValueFactory<SearchedResult, String>("context"));
            lastModifiedCol.setCellValueFactory(new PropertyValueFactory<>("lastModified"));
            list.add(result);
        }
        tview.setItems(list);
    }
}
项目:marathonv5    文件:PaginationSample.java   
public PaginationSample() {
    VBox outerBox = new VBox();
    outerBox.setAlignment(Pos.CENTER);
    //Images for our pages
    for (int i = 0; i < 7; i++) {
        images[i] = new Image(PaginationSample.class.getResource("animal" + (i + 1) + ".jpg").toExternalForm(), false);
    }

    pagination = PaginationBuilder.create().pageCount(7).pageFactory(new Callback<Integer, Node>() {           
        @Override public Node call(Integer pageIndex) {
            return createAnimalPage(pageIndex);
        }
    }).build();
    //Style can be numeric page indicators or bullet indicators
    Button styleButton = ButtonBuilder.create().text("Toggle pagination style").onAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent me) {
            if (!pagination.getStyleClass().contains(Pagination.STYLE_CLASS_BULLET)) {
                pagination.getStyleClass().add(Pagination.STYLE_CLASS_BULLET);
            } else {
                pagination.getStyleClass().remove(Pagination.STYLE_CLASS_BULLET);
            }
        }
    }).build();

    outerBox.getChildren().addAll(pagination, styleButton);
    getChildren().add(outerBox);
}
项目:marathonv5    文件:RFXCheckBoxTableCell.java   
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public String _getValue() {
    CheckBoxTableCell cell = (CheckBoxTableCell) node;
    Callback selectedStateCallback = cell.getSelectedStateCallback();
    String cbText;
    if (selectedStateCallback != null) {
        ObservableValue<Boolean> call = (ObservableValue<Boolean>) selectedStateCallback.call(cell.getItem());
        int selection = call.getValue() ? 2 : 0;
        cbText = JavaFXCheckBoxElement.states[selection];
    } else {
        Node cb = cell.getGraphic();
        RFXComponent comp = getFinder().findRawRComponent(cb, null, null);
        cbText = comp._getValue();
    }
    return cbText;
}
项目:LIRE-Lab    文件:ChooseFeatureDialog.java   
private void addOkButton() {
    this.dialogActions.addButtonType(ButtonType.OK);
    this.dialogActions.addButtonType(ButtonType.CANCEL);

    setResultConverter(new Callback<ButtonType, Feature>() {
        @Override
        public Feature call(ButtonType param) {
            if(param.equals(ButtonType.OK)) return selectedFeature;
            return null;
        }
    });
}
项目:LIRE-Lab    文件:PageFactoryProvider.java   
public Callback<Integer, Node> getPageFactory(List<Image> images,
                                              int pageSize,
                                              ImageClickHandler imageClickHandler,
                                              DoubleProperty gridGap,
                                              DoubleProperty imageHeight) {

    return new CollectionGridPageFactory(images, pageSize, imageClickHandler, gridGap, imageHeight);
}
项目:fx-dialogs    文件:FxDialog.java   
private Callback<ButtonType, M> createResultConverter() {
    return new Callback<ButtonType, M>() {
        @Override
        public M call(ButtonType aDialogButton) {
            if (ButtonType.OK == aDialogButton) {
                return MODEL;
            }
            else {
                return null;
            }
        }
    };
}
项目:uPMT    文件:LaunchingScreenController.java   
@Override
public void initialize(URL location, ResourceBundle resources) {

    //TODO: in this part, we prompt a lauchingScreen Dialog for open or create new project
    ObservableList<Projet> items = FXCollections.observableArrayList (m_main.getProjects());
    tousLesProjets.setItems(items);
    tousLesProjets.getFocusModel().focus(0);
    tousLesProjets.setCellFactory(new Callback<ListView<Projet>, ListCell<Projet>>() {
        @Override
        public ListCell<Projet> call(ListView<Projet> param) {

            ListCell<Projet> cell = new ListCell<Projet>() {

                @Override
                protected void updateItem(Projet item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null) {
                        setText(item.getName());
                    } else {
                        setText(""); 
                    }
                }
            };
            return cell;
        }
    });
}
项目:stvs    文件:SpecificationTable.java   
/**
 * Construct a new SpecificationTable with a given name, no rows or columns and the specified
 * column header and row extractors. These are needed for "deep observing" and are used to
 * indicate to observable collections such as {@link ObservableList} which properties of the
 * items in the collection should cause change events on the collection itself.
 * See also
 * <a href="http://stackoverflow.com/questions/31687642/callback-and-extractors-for-javafx-observablelist">
 *   this post</a> on why and how extractors are used.
 * @param name name of this specification
 * @param columnHeaderExtractor The extractor for the column headers
 * @param durationExtractor The extractor for the duration headers
 */
public SpecificationTable(String name, Callback<H, Observable[]> columnHeaderExtractor,
    Callback<D, Observable[]> durationExtractor) {
  this.name = new SimpleStringProperty(name);
  this.rows =
      FXCollections.observableArrayList(specificationRow -> new Observable[] {specificationRow});
  this.durations = FXCollections.observableArrayList(durationExtractor);
  this.columnHeaders = FXCollections.observableArrayList(columnHeaderExtractor);

  this.rows.addListener(this::onRowChange);
  this.columnHeaders.addListener(this::onColumnHeadersChanged);
  this.durations.addListener(this::onDurationChange);
}
项目:vars-annotation    文件:TableViewExt.java   
public TableViewExt(TableView<T> tableView) {
    this.tableView = tableView;

    // Callback to monitor row creation and to identify visible screen rows
    final Callback<TableView<T>, TableRow<T>> rf = tableView.getRowFactory();

    final Callback<TableView<T>, TableRow<T>> modifiedRowFactory = param -> {
        TableRow<T> r = rf != null ? rf.call(param) : new TableRow<>();
        // Save row, this implementation relies on JaxaFX re-using TableRow efficiently
        // TODO has been causing gui issues. I wonder if it's because rows are never removed
        rows.add(r);
        return r;
    };
    tableView.setRowFactory(modifiedRowFactory);
}
项目:CalendarFX    文件:DateControl.java   
/**
 * Creates a new calendar source that will be added to the list of calendar
 * sources of this date control. The method delegates the actual creation of
 * the calendar source to a factory, which can be specified by calling
 * {@link #setCalendarSourceFactory(Callback)}.
 *
 * @see #setCalendarSourceFactory(Callback)
 */
public final void createCalendarSource() {
    Callback<CreateCalendarSourceParameter, CalendarSource> factory = getCalendarSourceFactory();
    if (factory != null) {
        CreateCalendarSourceParameter param = new CreateCalendarSourceParameter(this);
        CalendarSource calendarSource = factory.call(param);
        if (calendarSource != null && !getCalendarSources().contains(calendarSource)) {
            getCalendarSources().add(calendarSource);
        }
    }
}
项目:CalendarFX    文件:MonthSheetViewSkin.java   
private void showDateDetails(LocalDate date) {
    DateCell cell = cellMap.get(date);
    Bounds bounds = cell.localToScreen(cell.getLayoutBounds());
    Callback<DateControl.DateDetailsParameter, Boolean> callback = getSkinnable().getDateDetailsCallback();
    DateControl.DateDetailsParameter param = new DateControl.DateDetailsParameter(null, getSkinnable(), cell, date, bounds.getMinX(), bounds.getMinY());
    callback.call(param);
}
项目:CORNETTO    文件:LoadedData.java   
/**
 * <h1>Initializes the TreeView FXML element.</h1>
 * The TreeView is divided into CheckBoxTreeItems as representation of samples
 * and TreeItems as representation of Taxa and information concerning those Taxa
 * @param treeViewFiles
 */
private static void generateTreeViewStructure(TreeView<String> treeViewFiles) {
    treeViewFiles.setRoot(new TreeItem<>("root"));
    //The classic treeview only has one root item, but you can work around this by just setting it to invisible
    treeViewFiles.setShowRoot(false);
    treeViewFiles.setCellFactory(new Callback<TreeView<String>, TreeCell<String>>() {
        @Override
        public TreeCell<String> call(TreeView<String> param) {
            return new CheckBoxTreeCell<String>() {
                @Override
                public void updateItem(String item, boolean empty) {
                    super.updateItem(item, empty);
                    //If there is no information for the Cell, make it empty
                    if (empty) {
                        setGraphic(null);
                        setText(null);
                        //Otherwise if it's not representation as an item of the tree
                        //is not a CheckBoxTreeItem, remove the checkbox item
                    } else if (!(getTreeItem() instanceof CheckBoxTreeItem)) {
                        setGraphic(null);
                        //If the TreeItem is a CheckBoxItem (that is the case for every TreeItem representing a sample)
                        //add the function that the user is able to delete the entire TreeItem with all its children
                    } else if (getTreeItem() instanceof CheckBoxTreeItem) {
                        MenuItem removeSample = new MenuItem("remove");
                        removeSample.setOnAction(event -> {
                            int indexOfTreeItem = treeViewFiles.getRoot().getChildren().indexOf(getTreeItem());
                            removeSampleFromDatabase(getTreeItem().getValue(), treeViewFiles, indexOfTreeItem);
                        });
                        setContextMenu(new ContextMenu(removeSample));
                    }
                }
            };
        }
    });
}
项目:cassandra-client    文件:UIUtil.java   
public static <S, T> Callback<TableColumn<S, T>, TableCell<S, T>> cellFactory(
        TypeCodec<T> codec) {
    return TextFieldTableCell.forTableColumn(new StringConverter<T>() {
        @Override
        public String toString(T object) {
            return codec.format(object);
        }

        @Override
        public T fromString(String string) {
            return codec.parse(string);
        }
    });
}
项目:CalendarFX    文件:MonthSheetView.java   
private ContextMenu createContextMenu() {
    ContextMenu contextMenu = new ContextMenu();
    MenuItem newEntry = new MenuItem(Messages.getString("MonthSheetView.ADD_NEW_EVENT")); //$NON-NLS-1$
    newEntry.setOnAction(evt -> {

        LocalDate date = getDateSelectionModel().getLastSelected();
        Entry<?> entry = createEntryAt(ZonedDateTime.of(date, LocalTime.of(12, 0), getZoneId()));

        Callback<EntryDetailsParameter, Boolean> callback = getEntryDetailsCallback();
        EntryDetailsParameter param = new EntryDetailsParameter(null, this, entry, dateCell, ctxMenuScreenX, ctxMenuScreenY);
        callback.call(param);

    });
    contextMenu.getItems().add(newEntry);

    contextMenu.getItems().add(new SeparatorMenuItem());

    RadioMenuItem standardCellItem = new RadioMenuItem(Messages.getString("MonthSheetView.STANDARD_CELLS"));
    RadioMenuItem detailCellItem = new RadioMenuItem(Messages.getString("MonthSheetView.DETAIL_CELLS"));
    RadioMenuItem usageCellItem = new RadioMenuItem(Messages.getString("MonthSheetView.USAGE_CELLS"));
    RadioMenuItem badgeCellItem = new RadioMenuItem(Messages.getString("MonthSheetView.BADGE_CELLS"));

    standardCellItem.setOnAction(evt -> setCellFactory(param -> new SimpleDateCell(param.getView(), param.getDate())));
    detailCellItem.setOnAction(evt -> setCellFactory(param -> new DetailedDateCell(param.getView(), param.getDate())));
    usageCellItem.setOnAction(evt -> setCellFactory(param -> new UsageDateCell(param.getView(), param.getDate())));
    badgeCellItem.setOnAction(evt -> setCellFactory(param -> new BadgeDateCell(param.getView(), param.getDate())));

    ToggleGroup group = new ToggleGroup();
    group.getToggles().addAll(standardCellItem, detailCellItem, usageCellItem, badgeCellItem);

    contextMenu.getItems().addAll(standardCellItem, detailCellItem, usageCellItem, badgeCellItem);

    standardCellItem.setSelected(true);

    return contextMenu;
}
项目:springfx    文件:ScreensConfig.java   
private Node getNode(final Presentation control, URL location) {
    FXMLLoader loader = new FXMLLoader(location, lang.getBundle());
    loader.setControllerFactory(new Callback<Class<?>, Object>() {
        public Object call(Class<?> aClass) {
            return control;
        }
    });

    try {
        return (Node) loader.load();
    } catch (Exception e) {
        logger.error("Error casting node", e);
        return null;
    }
}
项目:drd    文件:DiceController.java   
@Override
public void initialize(URL location, ResourceBundle resources) {
    title = resources.getString(R.Translate.DICE_TITLE);

    lvDices.setItems(FXCollections.observableArrayList(DiceHelper.DiceType.values()));
    lvDices.setCellFactory(new Callback<ListView<DiceType>, ListCell<DiceType>>() {
        @Override
        public ListCell<DiceType> call(ListView<DiceType> param) {
            ListCell<DiceType> cell = new ListCell<DiceType>() {
                @Override
                protected void updateItem(DiceType item, boolean empty) {
                    super.updateItem(item, empty);
                    if (empty) {
                        setText(null);
                    } else {
                        if (item == DiceType.CUSTOM) {
                            setText("Vlastní");
                        } else {
                            setText(item.toString());
                        }
                    }
                }
            };
            return cell;
        }
    });
    spinnerDiceSideCount.disableProperty().bind(
        lvDices.getFocusModel().focusedIndexProperty().isEqualTo(0).not());
    // TODO vymyslet lepší způsob
    spinnerDiceSideCount.valueProperty().addListener((observable, oldValue, newValue) -> {
        diceSideCount.setValue(newValue);
    });
    lvDices.getFocusModel().focusedItemProperty()
        .addListener((observable, oldValue, newValue) -> {
            diceSideCount.setValue(newValue.getSideCount());
        });
    diceRollCount.bind(spinnerRollCount.valueProperty());

    initTable();
}
项目:MinecraftServerSync    文件:FXUtil.java   
public static <T> T createFXMLController(Class<T> controllerClass, Callback<Class<?>, Object> controllerFactory) throws IOException {
    URL fxmlClasspathURL = createControllerFXMLClasspathURL(controllerClass);
    FXMLLoader fxmlLoader = new FXMLLoader(fxmlClasspathURL);
    fxmlLoader.setControllerFactory(controllerFactory);
    fxmlLoader.load();
    return fxmlLoader.getController();
}
项目:board-client    文件:GameLobbyController.java   
@Override
public void initialize(URL location, ResourceBundle resources) {
    try {
        FXMLLoader roomStatusLoader = new FXMLLoader(App.class.getResource("status.fxml"));
        borderPane.setLeft(roomStatusLoader.load());
        this.gameRoomStatusController = (GameStatusController)roomStatusLoader.getController();
        this.gameRoomStatusController.getTableView().getColumns().get(0).setText("Room");
        this.gameRoomStatusController.getTableView().setPlaceholder(new Label("No room in lobby"));
        this.gameRoomStatusController.getTableView().setRowFactory(new Callback<TableView<GameStatusController.Status>, TableRow<GameStatusController.Status>>() {  
            @Override
            public TableRow<GameStatusController.Status> call(TableView<GameStatusController.Status> tableView) {
                final TableRow<GameStatusController.Status> row = new TableRow<>();
                row.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        final int index = row.getIndex();
                        if (index >= 0 && index < tableView.getItems().size() && tableView.getSelectionModel().isSelected(index)) {
                            tableView.getSelectionModel().clearSelection();
                            event.consume();
                        }
                    }
                });
                return row;
            }
        });
        this.gameRoomStatusController.getTableView().getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> {
            if (newSelection != null) {
                this.roomName.setText(newSelection.getName());
                updatePlayers(newSelection.getName());
            } else {
                updatePlayers();
            }
        });

        FXMLLoader playerStatusLoader = new FXMLLoader(App.class.getResource("status.fxml"));
        borderPane.setCenter(playerStatusLoader.load());
        this.gamePlayerStatusController = (GameStatusController)playerStatusLoader.getController();
        this.gamePlayerStatusController.getTableView().getColumns().get(0).setText("Player");
        this.gamePlayerStatusController.getTableView().setPlaceholder(new Label("No player in lobby"));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:marathonv5    文件:ImagePanel.java   
@SuppressWarnings({ "rawtypes", "unchecked" }) private void createRightPane() {
    annotationTable.getSelectionModel().getSelectedItems().addListener(new ListChangeListener<Annotation>() {
        @Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends Annotation> c) {
            drawGraphics();
            markSelected();
        }
    });
    annotationTable.setEditable(edit);
    annotationTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    annotationTable.addEventHandler(KeyEvent.KEY_PRESSED, (event) -> {
        if (event.getCode() == KeyCode.DELETE || event.getCode() == KeyCode.BACK_SPACE) {
            removeAnnotation();
        }
    });
    TableColumn<Annotation, String> messageColumn = new TableColumn<Annotation, String>("Annotation");
    PropertyValueFactory<Annotation, String> value = new PropertyValueFactory<>("text");
    messageColumn.setCellValueFactory(value);
    messageColumn.setCellFactory(new Callback<TableColumn<Annotation, String>, TableCell<Annotation, String>>() {
        @Override public TableCell<Annotation, String> call(TableColumn<Annotation, String> param) {
            return new TextAreaTableCell();
        }
    });
    messageColumn.prefWidthProperty().bind(annotationTable.widthProperty().subtract(25));

    TableColumn<Annotation, String> numCol = new TableColumn<>("#");
    numCol.setCellFactory(new Callback<TableColumn<Annotation, String>, TableCell<Annotation, String>>() {
        @Override public TableCell<Annotation, String> call(TableColumn<Annotation, String> p) {
            return new TableCell() {
                @Override protected void updateItem(Object item, boolean empty) {
                    super.updateItem(item, empty);
                    setGraphic(null);
                    setText(empty ? null : getIndex() + 1 + "");
                }
            };
        }
    });
    numCol.setPrefWidth(25);

    annotationTable.setItems(annotations);
    annotationTable.getColumns().addAll(numCol, messageColumn);
}
项目:CalendarFX    文件:AgendaView.java   
public final Callback<AgendaView, ? extends AgendaEntryCell> getCellFactory() {
    return cellFactoryProperty().get();
}