Java 类javafx.scene.control.cell.ComboBoxTableCell 实例源码

项目:marathonv5    文件:RFXTableViewComboBoxTableCell.java   
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void select() {
    TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        Point2D point = getPoint(tableView, 2, 1);
        ComboBoxTableCell cell = (ComboBoxTableCell) getCellAt(tableView, 1, 2);
        RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
        rfxTableView.focusGained(null);
        cell.startEdit();
        tableView.edit(1, (TableColumn) tableView.getColumns().get(2));
        Person person = (Person) tableView.getItems().get(1);
        person.setLastName("Jones");
        cell.commitEdit("Jones");
        rfxTableView.focusLost(null);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("Jones", recording.getParameters()[0]);
}
项目:marathonv5    文件:RFXTableViewComboBoxTableCell.java   
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void selectEditable() {
    TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        Point2D point = getPoint(tableView, 2, 1);
        ComboBoxTableCell cell = (ComboBoxTableCell) getCellAt(tableView, 1, 2);
        cell.setEditable(true);
        RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
        rfxTableView.focusGained(null);
        cell.startEdit();
        tableView.edit(1, (TableColumn) tableView.getColumns().get(2));
        Person person = (Person) tableView.getItems().get(1);
        person.setLastName("Jones");
        cell.commitEdit("Jones");
        rfxTableView.focusLost(null);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("Jones", recording.getParameters()[0]);
}
项目:openjfx-8u-dev-tests    文件:NewTableViewApp.java   
private void setComboboxCellEditor(boolean isCustom) {

            for (int i = 0; i < testedTableView.getColumns().size(); i++) {
                TableColumn col = testedTableView.getColumns().get(i);
                String colName = col.getText();
                final ObservableList<String> items = FXCollections.observableArrayList();

                for (DataItem dataItem : allData) {
                    items.add(dataItem.get(colName).get());
                }
                if (!isCustom) {
                    col.setCellFactory(ComboBoxTableCell.forTableColumn(items));
                } else {
                    col.setCellFactory(new Callback() {
                        public Object call(Object p) {
                            return new EditingComboBoxCell(items);
                        }
                    });
                }
            }
        }
项目:Cachoeira    文件:TaskDependenciesModuleController.java   
private void selectedTaskObserver(ObservableValue<? extends ITask> observableValue,
                                  ITask oldTask,
                                  ITask newTask) {
    if (newTask != null) {
        module.setItems(newTask.getParentTasks());
        module.getParentTaskNameColumn().setCellValueFactory(cellData -> cellData.getValue().getTask().nameProperty());
        module.getParentTaskDependencyTypeColumn().setCellValueFactory(cellData -> cellData.getValue().dependenceTypeProperty());
        // Добавляем возможность изменять тип связи в таблице
        module.setEditable(true);
        // TODO: 18.04.2016 Сделать изменение строки через команды
        module.getParentTaskDependencyTypeColumn().setCellFactory(ComboBoxTableCell.forTableColumn(TaskDependencyType.values()));
        // Контекстное меню
        ParentTaskContextMenu parentTaskContextMenu = new ParentTaskContextMenu();
        parentTaskContextMenu.initMenus(controller.getProject(), newTask);
        module.setContextMenu(parentTaskContextMenu);
    }
}
项目:LesPatternsDuSwag    文件:ParkingFloorTableView.java   
private ComboBoxTableCell<ParkingTableViewRow, Class<? extends ParkingSpot>> parkingSpotClassComboBoxTableCell() {
    ComboBoxTableCell<ParkingTableViewRow, Class<? extends ParkingSpot>> field = new ComboBoxTableCell<>();
    field.getItems().addAll(MainApplication.ParkingSpotTypes);
    field.setConverter(new StringConverter<Class<? extends ParkingSpot>>() {
        @Override
        public String toString(Class<? extends ParkingSpot> object) {
            return object.getSimpleName().replace("ParkingSpot", "");
        }

        @Override
        public Class<? extends ParkingSpot> fromString(String string) {
            try {
                Class type = Class.forName(string + "ParkingSpot");
                if (ParkingSpot.class.isAssignableFrom(type))
                    return Utils.<Class<? extends ParkingSpot>>uncheckedCast(type);
            } catch (ClassNotFoundException e) {
                field.cancelEdit();
            }

            return null;
        }
    });
    return field;
}
项目:jfxtables    文件:PersonTable.java   
private void initTownNameCol() {
    townName.setCellValueFactory(p -> p.getValue().townProperty());
    townName.setCellFactory(ComboBoxTableCell.<Person, Town> forTableColumn(new StringConverter<Town>() {

        @Override
        public String toString(Town object) {
            if (object == null) {
                return DEFAULT_FILL;
            }
            return object.getName();
        }

        @Override
        public Town fromString(String string) {
            return townService.getTownForName(string);
        }
    }, townService.getTowns().getValue()));

}
项目:marathonv5    文件:JavaFXElementFactory.java   
public static void reset() {
    add(Node.class, JavaFXElement.class);
    add(TextInputControl.class, JavaFXTextInputControlElement.class);
    add(HTMLEditor.class, JavaFXHTMLEditor.class);
    add(CheckBox.class, JavaFXCheckBoxElement.class);
    add(ToggleButton.class, JavaFXToggleButtonElement.class);
    add(Slider.class, JavaFXSliderElement.class);
    add(Spinner.class, JavaFXSpinnerElement.class);
    add(SplitPane.class, JavaFXSplitPaneElement.class);
    add(ProgressBar.class, JavaFXProgressBarElement.class);
    add(ChoiceBox.class, JavaFXChoiceBoxElement.class);
    add(ColorPicker.class, JavaFXColorPickerElement.class);
    add(ComboBox.class, JavaFXComboBoxElement.class);
    add(DatePicker.class, JavaFXDatePickerElement.class);
    add(TabPane.class, JavaFXTabPaneElement.class);
    add(ListView.class, JavaFXListViewElement.class);
    add(TreeView.class, JavaFXTreeViewElement.class);
    add(TableView.class, JavaFXTableViewElement.class);
    add(TreeTableView.class, JavaFXTreeTableViewElement.class);
    add(CheckBoxListCell.class, JavaFXCheckBoxListCellElement.class);
    add(ChoiceBoxListCell.class, JavaFXChoiceBoxListCellElement.class);
    add(ComboBoxListCell.class, JavaFXComboBoxListCellElemnt.class);
    add(CheckBoxTreeCell.class, JavaFXCheckBoxTreeCellElement.class);
    add(ChoiceBoxTreeCell.class, JavaFXChoiceBoxTreeCellElement.class);
    add(ComboBoxTreeCell.class, JavaFXComboBoxTreeCellElement.class);
    add(TableCell.class, JavaFXTableViewCellElement.class);
    add(CheckBoxTableCell.class, JavaFXCheckBoxTableCellElement.class);
    add(ChoiceBoxTableCell.class, JavaFXChoiceBoxTableCellElement.class);
    add(ComboBoxTableCell.class, JavaFXComboBoxTableCellElemnt.class);
    add(TreeTableCell.class, JavaFXTreeTableCellElement.class);
    add(CheckBoxTreeTableCell.class, JavaFXCheckBoxTreeTableCell.class);
    add(ChoiceBoxTreeTableCell.class, JavaFXChoiceBoxTreeTableCell.class);
    add(ComboBoxTreeTableCell.class, JavaFXComboBoxTreeTableCell.class);
}
项目:drd    文件:DiceController.java   
/**
 * Inicializuje tabulku pro přidávání konstant k hodu kostkou
 */
private void initTable() {
    columnAdditionType.setCellValueFactory(new PropertyValueFactory<>("additionType"));
    columnAdditionType.setCellFactory(ComboBoxTableCell
        .forTableColumn(StringConvertors.forAdditionType(translator), AdditionType.values()));
    columnAdditionType.setOnEditCommit(
        event -> tableAdditions.getItems().get(event.getTablePosition().getRow())
            .setAdditionType(event.getNewValue()));

    columnUseRepair.setCellValueFactory(new PropertyValueFactory<>("useRepair"));
    columnUseRepair.setCellFactory(CheckBoxTableCell.forTableColumn(columnUseRepair));
    columnUseRepair.setOnEditCommit(
        event -> tableAdditions.getItems().get(event.getTablePosition().getRow())
            .setUseRepair(event.getNewValue()));

    columnUseSubtract.setCellValueFactory(new PropertyValueFactory<>("useSubtract"));
    columnUseSubtract.setCellFactory(CheckBoxTableCell.forTableColumn(columnUseSubtract));
    columnUseSubtract.setOnEditCommit(
        event -> tableAdditions.getItems().get(event.getTablePosition().getRow())
            .setUseSubtract(event.getNewValue()));
}
项目:xbrowser    文件:TableView.java   
private TableColumn processComboBoxColumnName(String name, JsonArray items){
    TableColumn column = new TableColumn(name);
    column.setCellValueFactory( p -> ((TableColumn.CellDataFeatures<Item, Object>)p).getValue().getStringProperty(name));
    ObservableList list = FXCollections.observableArrayList();
    if(items!=null) list.addAll(items.getList());
    column.setCellFactory(ComboBoxTableCell.forTableColumn(list));
    column.setOnEditCommit( t -> {
        int index = ((TableColumn.CellEditEvent<Item, Object>) t).getTablePosition().getRow();
        Item item = ((TableColumn.CellEditEvent<Item, Object>) t).getTableView().getItems().get(index);
        item.setProperty(name,((TableColumn.CellEditEvent<Item, Object>) t).getNewValue());
    });
    columnMap.put(name, column);
    return column;
}
项目:Gargoyle    文件:CommboBoxExam.java   
@FXML
public void initialize() {
    colCommbo.setCellFactory(param -> {
        ComboBoxTableCell<SampleVO, String> comboBoxTableCell = new ComboBoxTableCell<>("Hi", "My", "Name", "Is", "Kim");
        comboBoxTableCell.setPickOnBounds(true);
        comboBoxTableCell.updateSelected(true);
        return comboBoxTableCell;
    });
    colCommbo.setCellValueFactory(v -> v.getValue().nameProperty());

    tbSample.getItems().add(new SampleVO("Hi"));
    tbSample.getItems().add(new SampleVO("My"));
    tbSample.getItems().add(new SampleVO("Name"));
    tbSample.getItems().add(new SampleVO("Is"));

}
项目:javafx-dpi-scaling    文件:AdjusterTest.java   
@Test
public void testGetComboBoxTableCellAdjuster() {
    Adjuster adjuster = Adjuster.getAdjuster(ComboBoxTableCell.class);

    assertThat(adjuster, is(instanceOf(ControlAdjuster.class)));
    assertThat(adjuster.getNodeClass(), is(sameInstance(Control.class)));
}
项目:spring-labs    文件:ProjectsPresenter.java   
private void configureTasksTable() {

        taskNameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
        taskDescriptionColumn.setCellValueFactory(new PropertyValueFactory<>("description"));

        taskStatusColumn.setCellValueFactory(new PropertyValueFactory<>("status"));
        taskStatusColumn.setCellFactory(ComboBoxTableCell.forTableColumn(Task.Status.values()));

        taskStatusColumn.setOnEditCommit(edit -> {
            edit.getRowValue().setStatus(edit.getNewValue());
            projectTrackingService.save(edit.getRowValue());
        });
    }
项目:spring-labs    文件:ProjectsController.java   
private void configureTasksTable() {

        taskNameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
        taskDescriptionColumn.setCellValueFactory(new PropertyValueFactory<>("description"));

        taskStatusColumn.setCellValueFactory(new PropertyValueFactory<>("status"));
        taskStatusColumn.setCellFactory(ComboBoxTableCell.forTableColumn(Task.Status.values()));

        taskStatusColumn.setOnEditCommit(edit -> {
            edit.getRowValue().setStatus(edit.getNewValue());
            projectTrackingService.save(edit.getRowValue());
        });
    }
项目:marathonv5    文件:JavaFXComboBoxTableCellElemnt.java   
@SuppressWarnings("unchecked") @Override public String _getValue() {
    @SuppressWarnings("rawtypes")
    ComboBoxTableCell cell = (ComboBoxTableCell) node;
    return cell.getConverter().toString(cell.getItem());
}
项目:marathonv5    文件:RFXComboBoxTableCell.java   
@SuppressWarnings("unchecked") @Override public String _getValue() {
    @SuppressWarnings("rawtypes")
    ComboBoxTableCell cell = (ComboBoxTableCell) node;
    return cell.getConverter().toString(cell.getItem());
}
项目:Steam-trader-tools    文件:AppController.java   
@Override
public void initialize(URL location, ResourceBundle resources)
{
    if (prefs.get(PreferencesKeys.SAVE_PATH.toString(), null) != null)
    {
        try
        {
            userAppList.loadFromXml(new File(prefs.get(PreferencesKeys.SAVE_PATH.toString(), null)));
        } catch (JAXBException | SteamApiException e)
        {
            e.printStackTrace();
        }
    }
    currentAppList = userAppList.getAppList();
    updateListApp();

    /* Define the Table View */
    key.setCellValueFactory(new PropertyValueFactory<>("key"));
    key.setCellFactory(TextFieldTableCell.forTableColumn());
    state.setCellValueFactory(new PropertyValueFactory<>("state"));
    state.setCellFactory(ComboBoxTableCell.forTableColumn(KeyState.values()));
    currentUse.setCellValueFactory(new PropertyValueFactory<>("currentUse"));
    currentUse.setCellFactory(ComboBoxTableCell.forTableColumn(KeyCurrentUse.values()));
    used.setCellValueFactory(new PropertyValueFactory<>("used"));
    used.setCellFactory(CheckBoxTableCell.forTableColumn(used));
    dateAdded.setCellValueFactory(new PropertyValueFactory<>("dateAdded"));
    dateAdded.setCellFactory(TextFieldTableCell.forTableColumn());

    /*Change listener for table view */
    ChangeListener<Object> listener = (obs, oldValue, newValue) ->
            modified = true;
    keyList.focusedProperty().addListener(listener);
    keyList.getSelectionModel().selectedItemProperty().addListener(listener);

    /* Context Menu for the filter button */
    ContextMenu contextMenu = new ContextMenu();
    MenuItem showAll = new MenuItem();
    MenuItem showUsed = new MenuItem();
    showAll.setText(I18n.getMessage("allGame"));
    showUsed.setText(I18n.getMessage("gameWithUsedKey"));
    showAll.setOnAction(event ->
    {
        currentAppList = userAppList.getAppList();
        updateListApp();
        filterMode = false;
    });
    showUsed.setOnAction(event ->
    {
        currentAppList = userAppList.getGamesWithUsedKey();
        updateListApp();
        filterMode = true;
    });
    contextMenu.getItems().addAll(showAll,showUsed);
    filterButton.setContextMenu(contextMenu);
    imageCacheHandler.loadImageCache();

}
项目:mars-sim    文件:TableViewCombo.java   
@SuppressWarnings("restriction")
public void init() {
       TableColumn<SettlementBase, String> nameCol = new TableColumn<>(headers[0]);
       nameCol.setCellValueFactory(cellData -> cellData.getValue().nameProperty());
       //nameCol.setCellFactory(TextFieldTableCell.forTableColumn());
       nameCol = setCellFactory(nameCol);
       nameCol.setMinWidth(150);

       templateCol = new TableColumn<>(headers[1]);
       templateCol.setCellValueFactory(cellData -> cellData.getValue().templateProperty());
       templateCol.setCellFactory(ComboBoxTableCell.forTableColumn(
            templates.get(0).getTemplateName(),
            templates.get(1).getTemplateName(),
            templates.get(2).getTemplateName(),
            templates.get(3).getTemplateName(),
            templates.get(4).getTemplateName(),
            templates.get(5).getTemplateName()));
       templateCol.setMinWidth(250);

       settlerCol = new TableColumn<>(headers[2]);
       settlerCol.setCellValueFactory(cellData -> cellData.getValue().settlerProperty());
       //settlerCol.setCellFactory(TextFieldTableCell.forTableColumn());
       settlerCol = setCellFactory(settlerCol);
       settlerCol.setMinWidth(50);

       //private ValidationSupport validationSupport = new ValidationSupport();
    //validationSupport.registerValidator(TextField, Validator.createEmptyValidator("Text is required"));

       botCol = new TableColumn<>(headers[3]);
       botCol.setCellValueFactory(cellData -> cellData.getValue().botProperty());
       //botCol.setCellFactory(TextFieldTableCell.forTableColumn());
       botCol = setCellFactory(botCol);
       botCol.setMinWidth(50);

       TableColumn<SettlementBase, String> sponsorCol = new TableColumn<>(headers[4]);
       sponsorCol.setCellValueFactory(cellData -> cellData.getValue().sponsorProperty());
       sponsorCol.setCellFactory(ComboBoxTableCell.forTableColumn(
            SPONSORS[0].toString(),
            SPONSORS[1].toString(),
            SPONSORS[2].toString(),
            SPONSORS[3].toString(),
            SPONSORS[4].toString(),
            SPONSORS[5].toString(),
            SPONSORS[6].toString(),
            SPONSORS[7].toString()));
       sponsorCol.setMinWidth(250);


       latCol = new TableColumn<>(headers[5]);
       latCol.setCellValueFactory(cellData -> cellData.getValue().latitudeProperty());
       //latCol.setCellFactory(TextFieldTableCell.forTableColumn());
       latCol = setCellFactory(latCol);
       latCol.setMinWidth(70);


       longCol = new TableColumn<>(headers[6]);
       longCol.setCellValueFactory(cellData -> cellData.getValue().longitudeProperty());
       //longCol.setCellFactory(TextFieldTableCell.forTableColumn());
       longCol = setCellFactory(longCol);
       longCol.setMinWidth(70);

       table_view.getColumns().addAll(nameCol,templateCol,settlerCol,botCol,sponsorCol,latCol, longCol);
       table_view.getItems().addAll(generateDataInMap());

   }