Java 类javafx.scene.control.TableColumn 实例源码

项目:xbrowser    文件:TableView.java   
private TableColumn processChoiceBoxColumnName(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(ChoiceBoxTableCell.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;
}
项目:titanium    文件:OrganizationManagerStage.java   
private TableView<OrganizationView> createOrganizationTable(ObservableList<OrganizationView> orgas) {
    TableView<OrganizationView> result = new TableView<>(orgas);

    TableColumn<OrganizationView, String> name = new TableColumn<>("Name");
    TableColumn<OrganizationView, String> owned = new TableColumn<>("Owned");
    TableColumn<OrganizationView, Integer> serverCount = new TableColumn<>("Servers");

    name.setCellValueFactory(new PropertyValueFactory<>("name"));
    serverCount.setCellValueFactory(new PropertyValueFactory<>("serverCount"));
    owned.setCellValueFactory(new PropertyValueFactory<>("isOwned"));

    serverCount.setMinWidth(70);
    serverCount.setMaxWidth(70);
    owned.setMaxWidth(70);
    owned.setMinWidth(70);

    result.getColumns().add(name);
    result.getColumns().add(serverCount);
    result.getColumns().add(owned);

    return result;
}
项目:tenhou-visualizer    文件:UkeireTableView.java   
public UkeireTableView() {
    super();

    TableColumn<Ukeire, String> candidateHaiStringColmun = new TableColumn<>("選");
    TableColumn<Ukeire, String> syantenColmun = new TableColumn<>("聴");
    TableColumn<Ukeire, String> infoColmun = new TableColumn<>("枚数");
    TableColumn<Ukeire, String> ukeireHaiStringsColmun = new TableColumn<>("受入牌");

    candidateHaiStringColmun.setCellValueFactory(e -> new SimpleStringProperty(HaiString.getHaiStringByIndex(e.getValue().getCandidateIndex())));
    syantenColmun.setCellValueFactory(e -> new SimpleStringProperty(e.getValue().getSyanten() == -1 ? "-" : String.valueOf(e.getValue().getSyanten())));
    infoColmun.setCellValueFactory(e -> new SimpleStringProperty(e.getValue().getSize() + "種" + e.getValue().getSum() + "牌"));
    ukeireHaiStringsColmun.setCellValueFactory(e -> new SimpleStringProperty(e.getValue().getUkeireIndices().stream().map(HaiString::getHaiStringByIndex).collect(Collectors.joining())));

    candidateHaiStringColmun.prefWidthProperty().bind(widthProperty().multiply(0.15));
    syantenColmun.prefWidthProperty().bind(widthProperty().multiply(0.13));
    infoColmun.prefWidthProperty().bind(widthProperty().multiply(0.3));
    ukeireHaiStringsColmun.prefWidthProperty().bind(widthProperty().multiply(0.41));

    getColumns().addAll(candidateHaiStringColmun, syantenColmun, infoColmun, ukeireHaiStringsColmun);
}
项目:hygene    文件:AnnotationController.java   
/**
 * Creates a wrapped table cell.
 *
 * @param column the table column in which the cell resides
 * @return a TableCell with the text wrapped inside
 */
private TableCell<Annotation, String> createWrappableTableCell(final TableColumn<Annotation, String> column) {
    return new TableCell<Annotation, String>() {
        @Override
        protected void updateItem(final String item, final boolean empty) {
            super.updateItem(item, empty);
            if (item == null || empty) {
                setGraphic(null);
                return;
            }

            final Text text = new Text(item);
            text.setWrappingWidth(column.getWidth() - TEXT_PADDING);
            setPrefHeight(text.getLayoutBounds().getHeight());

            setGraphic(text);
        }
    };
}
项目:hygene    文件:NodePropertiesController.java   
/**
 * Create a table cell that wraps the text inside.
 *
 * @param param the table column
 * @return a table cell that wraps the text inside
 */
TableCell<Annotation, String> wrappableTableCell(final TableColumn<Annotation, String> param) {
    return new TableCell<Annotation, String>() {
        @Override
        protected void updateItem(final String item, final boolean empty) {
            super.updateItem(item, empty);
            if (item == null || empty) {
                setGraphic(null);
                return;
            }
            final Text text = new Text(item);
            text.setWrappingWidth(param.getWidth());
            setPrefHeight(text.getLayoutBounds().getHeight());
            setGraphic(text);
        }
    };
}
项目:dragdropfx    文件:DnDPrepare.java   
public static void tableColumns(final Visitor v, List<? extends TableColumn<?, ?>> addedSubList) {
    for(int i = 0; i < addedSubList.size(); i++){
        final TableColumn<?,?> col = addedSubList.get(i);

        col.setCellFactory(new DnDTableCellFactory(v, col.getCellFactory()));
        col.cellFactoryProperty().addListener(new ChangeListener<Callback>() {
            @Override
            public void changed(ObservableValue<? extends Callback> observable, Callback oldValue,
                    Callback newValue) {
                if(!(newValue instanceof DnDTableCellFactory)){
                    col.setCellFactory(new DnDTableCellFactory(v, col.getCellFactory()));
                }
            }
        });
    }
}
项目:marathonv5    文件:JavaFXElementPropertyAccessor.java   
public TableCell<?, ?> getVisibleCellAt(TableView<?> tableView, int row, int column) {
    Set<Node> lookupAll = getTableCells(tableView);
    TableCell<?, ?> cell = null;
    for (Node node : lookupAll) {
        TableCell<?, ?> cell1 = (TableCell<?, ?>) node;
        TableRow<?> tableRow = cell1.getTableRow();
        TableColumn<?, ?> tableColumn = cell1.getTableColumn();
        if (tableRow.getIndex() == row && tableColumn == tableView.getColumns().get(column)) {
            cell = cell1;
            break;
        }
    }
    if (cell != null) {
        return cell;
    }
    return null;
}
项目:marathonv5    文件:JavaFXElementPropertyAccessor.java   
@SuppressWarnings("unchecked") public void selectCells(TableView<?> tableView, String value) {
    @SuppressWarnings("rawtypes")
    TableViewSelectionModel selectionModel = tableView.getSelectionModel();
    selectionModel.clearSelection();
    JSONObject cells = new JSONObject(value);
    JSONArray object = (JSONArray) cells.get("cells");
    for (int i = 0; i < object.length(); i++) {
        JSONArray jsonArray = object.getJSONArray(i);
        int rowIndex = Integer.parseInt(jsonArray.getString(0));
        int columnIndex = getColumnIndex(jsonArray.getString(1));
        @SuppressWarnings("rawtypes")
        TableColumn column = tableView.getColumns().get(columnIndex);
        if (getVisibleCellAt(tableView, rowIndex, columnIndex) == null) {
            tableView.scrollTo(rowIndex);
            tableView.scrollToColumn(column);
        }
        selectionModel.select(rowIndex, column);
    }
}
项目: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]);
}
项目:marathonv5    文件:RFXTableViewTest.java   
@SuppressWarnings("unchecked") @Test public void selectACell() {
    TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        tableView.getSelectionModel().setCellSelectionEnabled(true);
        Point2D point = getPoint(tableView, 1, 1);
        RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
        rfxTableView.focusGained(null);
        @SuppressWarnings("rawtypes")
        TableColumn column = getTableColumnAt(tableView, 1);
        tableView.getSelectionModel().select(1, column);
        rfxTableView.focusLost(null);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("{\"cells\":[[\"1\",\"Last\"]]}", recording.getParameters()[0]);
}
项目:marathonv5    文件:RFXTableViewTest.java   
@SuppressWarnings("unchecked") @Test public void selectCell() {
    TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        tableView.getSelectionModel().setCellSelectionEnabled(true);
        Point2D point = getPoint(tableView, 1, 1);
        RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
        rfxTableView.focusGained(null);
        @SuppressWarnings("rawtypes")
        TableColumn column = getTableColumnAt(tableView, 1);
        tableView.getSelectionModel().select(1, column);
        rfxTableView.focusLost(null);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("{\"cells\":[[\"1\",\"Last\"]]}", recording.getParameters()[0]);
}
项目:marathonv5    文件:RFXTableViewTest.java   
@SuppressWarnings("unchecked") @Test public void selectMultipleCells() {
    TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        tableView.getSelectionModel().setCellSelectionEnabled(true);
        tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        Point2D point = getPoint(tableView, 1, 1);
        RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
        rfxTableView.focusGained(null);
        @SuppressWarnings("rawtypes")
        TableColumn column = getTableColumnAt(tableView, 1);
        tableView.getSelectionModel().select(1, column);
        tableView.getSelectionModel().select(2, column);
        rfxTableView.focusLost(null);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("{\"cells\":[[\"1\",\"Last\"],[\"2\",\"Last\"]]}", recording.getParameters()[0]);
}
项目:marathonv5    文件:RFXTableViewTest.java   
@SuppressWarnings("unchecked") @Test public void getText() {
    TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
    LoggingRecorder lr = new LoggingRecorder();
    List<Object> text = new ArrayList<>();
    Platform.runLater(() -> {
        tableView.getSelectionModel().setCellSelectionEnabled(true);
        Point2D point = getPoint(tableView, 1, 1);
        RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
        rfxTableView.focusGained(null);
        @SuppressWarnings("rawtypes")
        TableColumn column = getTableColumnAt(tableView, 1);
        tableView.getSelectionModel().select(1, column);
        rfxTableView.focusLost(null);
        text.add(rfxTableView.getAttribute("text"));
    });
    new Wait("Waiting for table text.") {
        @Override public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("{\"cells\":[[\"1\",\"Last\"]]}", text.get(0));
}
项目:Java-9-Programming-Blueprints    文件:Controller.java   
private void configureRulesListTable() {
    ObservableList<TableColumn> columns = rulesTableView.getColumns();
    final TableColumn<Rule, String> typeCol = columns.get(0);
    typeCol.prefWidthProperty().bind(rulesTableView.widthProperty().multiply(0.12));
    typeCol.setCellValueFactory(c -> new SimpleStringProperty(c.getValue().getType().toString()));

    final TableColumn<Rule, String> sourceCol = columns.get(1);
    sourceCol.prefWidthProperty().bind(rulesTableView.widthProperty().multiply(0.25));
    sourceCol.setCellValueFactory(c -> new SimpleStringProperty(c.getValue().getSourceFolder()));

    final TableColumn<Rule, String> descCol = columns.get(2);
    descCol.prefWidthProperty().bind(rulesTableView.widthProperty().multiply(0.65));
    descCol.setCellValueFactory(new RuleDescriptionFactory());
    rulesTableView.setItems(rules);

    rulesTableView.setOnMouseClicked(e -> {
        ruleProperty.set((Rule) rulesTableView.getSelectionModel().getSelectedItem());
    });
}
项目:vertx-generator    文件:HistoryConfigController.java   
/**
 * 初始化配置table
 */
public void initTable() {
    LOG.debug("初始化配置信息表格...");
    ObservableList<HistoryConfigCVF> data = null;
    try {
        data = getHistoryConfig();
    } catch (Exception e) {
        tblConfigInfo.setPlaceholder(new Label("加载配置文件失败!失败原因:\r\n" + e.getMessage()));
        LOG.error("初始化配置信息表格出现异常!!!" + e);
    }

    TableColumn<HistoryConfigCVF, String> tdInfo = new TableColumn<HistoryConfigCVF, String>("配置信息文件名");
    TableColumn<HistoryConfigCVF, String> tdOperation = new TableColumn<HistoryConfigCVF, String>("操作");

    tdInfo.setPrefWidth(320);
    tdInfo.setCellValueFactory(new PropertyValueFactory<>("name"));

    tdOperation.setPrefWidth(198);
    tdOperation.setCellValueFactory(new PropertyValueFactory<>("hbox"));

    tblConfigInfo.getColumns().add(tdInfo);
    tblConfigInfo.getColumns().add(tdOperation);

    tblConfigInfo.setItems(data);
    LOG.debug("初始化配置信息完成!");
}
项目:qgu    文件:TimelineView.java   
private void initTimeline(LocalDate start, LocalDate end) {
    this.timelineStart = start;
    this.timelineEnd = end;

    for(int m = start.getMonthValue(); m <= end.getMonthValue(); m++) {
        TableColumn<GanttTask,GanttBarPiece> monthCol = new TableColumn<GanttTask,GanttBarPiece>();
        Label month = new Label(Month.of(m).toString());
        monthCol.setGraphic(month);
        monthCol.setResizable(false);

        LocalDate tmp = LocalDate.of(start.getYear(), m, 1);
        LocalDate chartStart = start.compareTo(tmp) > 0 ? start : tmp;

        for(int d = chartStart.getDayOfMonth(); d <= chartStart.lengthOfMonth(); d++) {
            GanttDayColumn c = new GanttDayColumn(chartStart.getYear(), m, d);
            c.setPrefWidth(20);
            Label day = new Label(Integer.toString(d));
            c.setGraphic(day);
            monthCol.getColumns().add(c);
        }

        this.getColumns().add(monthCol);
    }
    // TODO make timeline right-left scrollable with wheel on windows 
}
项目:karate    文件:VarsPanel.java   
public VarsPanel(AppSession session) {
    this.session = session;        
    table = new TableView();
    table.setPrefWidth(300);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    setCenter(table);
    TableColumn nameCol = new TableColumn("Variable");
    nameCol.setMinWidth(120);
    nameCol.setMaxWidth(250);
    nameCol.setCellValueFactory(new PropertyValueFactory("name"));
    nameCol.setCellFactory(c -> new StringTooltipCell());
    TableColumn typeCol = new TableColumn("Type");
    typeCol.setMinWidth(45);
    typeCol.setMaxWidth(60);
    typeCol.setCellValueFactory(new PropertyValueFactory("type"));
    TableColumn<Var, ScriptValue> valueCol = new TableColumn("Value");
    valueCol.setCellValueFactory(c -> new ReadOnlyObjectWrapper(c.getValue().getValue()));        
    valueCol.setCellFactory(c -> new VarValueCell());
    table.getColumns().addAll(nameCol, typeCol, valueCol);
    table.setItems(session.getVars());
    table.setRowFactory(tv -> {
        TableRow<Var> row = new TableRow<>();
        row.setOnMouseClicked(e -> {
            if (e.getClickCount() == 2 && !row.isEmpty()) {
                Var var = row.getItem();
                session.logVar(var);
            }
        });
        return row ;
    });        
}
项目:dragdropfx    文件:DragDropFX.java   
@Override
public Void call(Object p) {
    if(isIgnored(p)){return null;}
    final TableView<?> t = (TableView<?>) p;
    DnDPrepare.tableColumns(DragDropFX.this, t.getColumns());
    t.getColumns().addListener(new ListChangeListener<TableColumn<?,?>>(){

        @Override
        public void onChanged(
                javafx.collections.ListChangeListener.Change<? extends TableColumn<?, ?>> arg0) {
            while(arg0.next()){
                if(arg0.wasAdded()){
                    DnDPrepare.tableColumns(DragDropFX.this, arg0.getAddedSubList());
                }
            }
        }

    });
    return null;
}
项目:OneClient    文件:JavaDialog.java   
public JavaDialog() {
    super(JavaUtil.getAvailableInstalls());

    TableColumn<JavaUtil.JavaInstall, String> paths = new TableColumn<>("Paths");
    paths.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().path));
    table.getColumns().addAll(paths);
    setTitle("Java Detection");
    dialogPane.setHeaderText("Please Choose a Java Version");
    dialogPane.getStyleClass().add("java-dialog");
    dialogPane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
}
项目:WebPLP    文件:WatcherWindow.java   
private TableView<MemoryRow> createMemoryTable()
{
    TableView<MemoryRow> table = new TableView<>();
    table.setEditable(true);

    TableColumn<MemoryRow, String> idColumn = new TableColumn<>("Address");
    idColumn.setCellValueFactory(memoryFactory("address"));
    setPercentSize(table, idColumn, 0.5);
    table.getColumns().add(idColumn);

    TableColumn<MemoryRow, String> valueColumn = new TableColumn<>("Value");
    valueColumn.setCellValueFactory(memoryFactory("value"));
    setPercentSize(table, valueColumn, 0.5);
    table.getColumns().add(valueColumn);

    table.setItems(memoryAddresses);
    table.setMinHeight(80);
    return table;
}
项目:WebPLP    文件:CpuWindow.java   
private TableView<RegisterRow> createRegisterTabContent()
{
    TableView<RegisterRow> table = new TableView<>();
    table.setEditable(true);

    TableColumn<RegisterRow, String> nameColumn = new TableColumn<>("Register");
    nameColumn.setCellValueFactory(registerFactory("register"));
    setPercentSize(table, nameColumn, 1.0 / 3.0);
    table.getColumns().add(nameColumn);

    TableColumn<RegisterRow, String> contentsColumn = new TableColumn<>("Contents");
    contentsColumn.setCellValueFactory(registerFactory("content"));
    setPercentSize(table, contentsColumn, 1.0 / 3.0);
    table.getColumns().add(contentsColumn);

    TableColumn<RegisterRow, String> valueColumn = new TableColumn<>("Edit Contents");
    valueColumn.setCellValueFactory(registerFactory("editContent"));
    setPercentSize(table, valueColumn, 1.0 / 3.0);
    table.getColumns().add(valueColumn);

    table.setItems(registers);
    return table;
}
项目:ExtremeGuiMakeover    文件:MovieTableView.java   
public MovieTableView() {

        TableColumn<Movie, String> titleColumn = new TableColumn<>("Title");
        titleColumn.setPrefWidth(300);
        titleColumn.setCellValueFactory(new PropertyValueFactory<>("title"));

        TableColumn<Movie, Integer> yearColumn = new TableColumn<>("Year");
        yearColumn.setPrefWidth(80);
        yearColumn.setCellValueFactory(new PropertyValueFactory<>("year"));

        TableColumn<Movie, String> genreColumn = new TableColumn<>("Genre");
        genreColumn.setPrefWidth(140);
        genreColumn.setCellValueFactory(new PropertyValueFactory<>("genre"));

        TableColumn<Movie, Integer> directorColumn = new TableColumn<>("Director");
        directorColumn.setPrefWidth(140);
        directorColumn.setCellValueFactory(new PropertyValueFactory<>("director"));

        TableColumn<Movie, Integer> ratingColumn = new TableColumn<>("Rating");
        ratingColumn.setPrefWidth(120);
        ratingColumn.setCellValueFactory(new PropertyValueFactory<>("rating"));

        getColumns().setAll(titleColumn, yearColumn, genreColumn, directorColumn, ratingColumn);
    }
项目: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;
            }
        });
    });
}
项目:xbrowser    文件:TableView.java   
private TableColumn processStringColumnName(String name){
    TableColumn column = new TableColumn(name);
    column.setCellValueFactory( p -> ((TableColumn.CellDataFeatures<Item, Object>)p).getValue().getStringProperty(name));
    column.setCellFactory(TextFieldTableCell.forTableColumn());
    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;
}
项目:WIFIProbe    文件:IndexController.java   
private void initProcessTable() {
    ObservableList<TableColumn<Process, ?>> processCols = processTable.getColumns();
    processCols.get(0).setCellValueFactory(new PropertyValueFactory<>("status"));
    TableColumn<Process,Double> processCol = new TableColumn<>("进度");
    processCol.setPrefWidth(475);
    processCol.setCellValueFactory(new PropertyValueFactory<>("progress"));
    processCol.setCellFactory(ProgressBarTableCell.forTableColumn());
    processCols.set(1,processCol);
    processCols.get(2).setCellValueFactory(new PropertyValueFactory<>("percent"));
    processCols.get(3).setCellValueFactory(new PropertyValueFactory<>("lastUpdate"));
}
项目:WIFIProbe    文件:IndexController.java   
private void initStatusTable() {
    ObservableList<TableColumn<ProbeStatus, ?>> statusColumns = statusTable.getColumns();
    statusColumns.get(0).setCellValueFactory(new PropertyValueFactory<>("id"));
    statusColumns.get(1).setCellValueFactory(new PropertyValueFactory<>("status"));
    statusColumns.get(2).setCellValueFactory(new PropertyValueFactory<>("ip"));
    TableColumn<ProbeStatus,String> actionCol = new TableColumn<>("操作");
    actionCol.setPrefWidth(250);
    actionCol.setCellValueFactory(new PropertyValueFactory<>("DUMMY"));
    actionCol.setCellFactory(param -> new TableCell<ProbeStatus,String>() {
        final Button btn = new Button("管理");
        @Override
        public void updateItem(String item, boolean empty) {
            super.updateItem(item, empty);
            if (empty) {
                setGraphic(null);
                setText(null);
            } else {
                btn.setOnAction(event -> {
                    ProbeStatus probeStatus = getTableView().getItems().get(getIndex());
                    try {
                        URI uri = new URI(probeStatus.getIp());
                        Desktop.getDesktop().browse(uri);
                    } catch (URISyntaxException | IOException e) {
                        e.printStackTrace();
                    }
                });
                setGraphic(btn);
                setText(null);
            }
        }
    });
    statusColumns.add(actionCol);
}
项目:marathonv5    文件:FormatedTableCellFactory.java   
@Override public TableCell<S,T> call(TableColumn<S,T> p) {
     TableCell<S,T> cell = new TableCell() {
        @Override public void updateItem(Object item, boolean empty) {
            if (item == getItem()) return;

            super.updateItem(item, empty);

            if (item == null) {
                super.setText(null);
                super.setGraphic(null);
            } else if (format != null) {
                super.setText(format.format(item));
            } else if (item instanceof Node) {
                super.setText(null);
                super.setGraphic((Node)item);
            } else {
                super.setText(item.toString());
                super.setGraphic(null);
            }
        }
    };
    cell.setTextAlignment(alignment);
    switch(alignment) {
        case CENTER:
            cell.setAlignment(Pos.CENTER);
            break;
        case RIGHT:
            cell.setAlignment(Pos.CENTER_RIGHT);
            break;
        default:
            cell.setAlignment(Pos.CENTER_LEFT);
            break;
    }
    return cell;
}
项目:marathonv5    文件:TaskSample.java   
public TaskSample() {
    TableView<DailySales> tableView = new TableView<DailySales>();
    Region veil = new Region();
    veil.setStyle("-fx-background-color: rgba(0, 0, 0, 0.4)");
    ProgressIndicator p = new ProgressIndicator();
    p.setMaxSize(150, 150);
    //Define table columns
    TableColumn idCol = new TableColumn();
    idCol.setText("ID");
    idCol.setCellValueFactory(new PropertyValueFactory("dailySalesId"));
    tableView.getColumns().add(idCol);
    TableColumn qtyCol = new TableColumn();
    qtyCol.setText("Qty");
    qtyCol.setCellValueFactory(new PropertyValueFactory("quantity"));
    tableView.getColumns().add(qtyCol);
    TableColumn dateCol = new TableColumn();
    dateCol.setText("Date");
    dateCol.setCellValueFactory(new PropertyValueFactory("date"));
    dateCol.setMinWidth(240);
    tableView.getColumns().add(dateCol);
    StackPane stack = new StackPane();
    stack.getChildren().addAll(tableView, veil, p);

    // Use binding to be notified whenever the data source chagnes
    Task<ObservableList<DailySales>> task = new GetDailySalesTask();
    p.progressProperty().bind(task.progressProperty());
    veil.visibleProperty().bind(task.runningProperty());
    p.visibleProperty().bind(task.runningProperty());
    tableView.itemsProperty().bind(task.valueProperty());

    getChildren().add(stack);
    new Thread(task).start();
}
项目:marathonv5    文件:JavaFXElementPropertyAccessor.java   
public int getColumnIndex(String columnName) {
    TableView<?> table = (TableView<?>) node;
    ObservableList<?> columns = table.getColumns();
    int ncolumns = columns.size();
    for (int i = 0; i < ncolumns; i++) {
        @SuppressWarnings("rawtypes")
        String column = ((TableColumn) columns.get(i)).getText();
        if (columnName.equals(escapeSpecialCharacters(column))) {
            return i;
        }
    }
    throw new RuntimeException("Could not find column " + columnName + " in table");
}
项目:marathonv5    文件:FormatedTableCellFactory.java   
@Override public TableCell<S,T> call(TableColumn<S,T> p) {
     TableCell<S,T> cell = new TableCell() {
        @Override public void updateItem(Object item, boolean empty) {
            if (item == getItem()) return;

            super.updateItem(item, empty);

            if (item == null) {
                super.setText(null);
                super.setGraphic(null);
            } else if (format != null) {
                super.setText(format.format(item));
            } else if (item instanceof Node) {
                super.setText(null);
                super.setGraphic((Node)item);
            } else {
                super.setText(item.toString());
                super.setGraphic(null);
            }
        }
    };
    cell.setTextAlignment(alignment);
    switch(alignment) {
        case CENTER:
            cell.setAlignment(Pos.CENTER);
            break;
        case RIGHT:
            cell.setAlignment(Pos.CENTER_RIGHT);
            break;
        default:
            cell.setAlignment(Pos.CENTER_LEFT);
            break;
    }
    return cell;
}
项目:marathonv5    文件:TaskSample.java   
public TaskSample() {
    TableView<DailySales> tableView = new TableView<DailySales>();
    Region veil = new Region();
    veil.setStyle("-fx-background-color: rgba(0, 0, 0, 0.4)");
    ProgressIndicator p = new ProgressIndicator();
    p.setMaxSize(150, 150);
    //Define table columns
    TableColumn idCol = new TableColumn();
    idCol.setText("ID");
    idCol.setCellValueFactory(new PropertyValueFactory("dailySalesId"));
    tableView.getColumns().add(idCol);
    TableColumn qtyCol = new TableColumn();
    qtyCol.setText("Qty");
    qtyCol.setCellValueFactory(new PropertyValueFactory("quantity"));
    tableView.getColumns().add(qtyCol);
    TableColumn dateCol = new TableColumn();
    dateCol.setText("Date");
    dateCol.setCellValueFactory(new PropertyValueFactory("date"));
    dateCol.setMinWidth(240);
    tableView.getColumns().add(dateCol);
    StackPane stack = new StackPane();
    stack.getChildren().addAll(tableView, veil, p);

    // Use binding to be notified whenever the data source chagnes
    Task<ObservableList<DailySales>> task = new GetDailySalesTask();
    p.progressProperty().bind(task.progressProperty());
    veil.visibleProperty().bind(task.runningProperty());
    p.visibleProperty().bind(task.runningProperty());
    tableView.itemsProperty().bind(task.valueProperty());

    getChildren().add(stack);
    new Thread(task).start();
}
项目:MediathekView14Concept    文件:Mv14Controller.java   
private ObservableValue<ImageView> senderImageProperty(TableColumn.CellDataFeatures<EntryModel, ImageView> param) {
  EntryModel model = param.getValue();
  ObjectProperty<ImageView> objectProperty = new SimpleObjectProperty<>(new ImageView());

  // Write image now
  if (model.getSender() != null) {
    objectProperty.get().setImage((MVSenderIconCache.iconCache.get(model.getSender())));
  }

  // Rewrite if changed
  model.senderProperty().addListener((observable, oldValue, newValue) ->
      objectProperty.get().setImage((MVSenderIconCache.iconCache.get(newValue))));

  return objectProperty;
}
项目:Goliath-Overclocking-Utility-FX    文件:PowerMizerPane.java   
public PowerMizerPane()
{
    super();

    table = new TableView<>(FXCollections.observableList(InstanceProvider.getPerformanceLevels()));
    table.setMinHeight(125);
    table.setMaxHeight(125);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    table.setEditable(false);

    perfLevel = new TableColumn<>("Performance Level");
    perfLevel.setCellValueFactory(new PropertyValueFactory("name"));
    perfLevel.setSortable(false);

    minClock = new TableColumn<>("Min Core(MHz)");
    minClock.setCellValueFactory(new PropertyValueFactory("minCore"));
    minClock.setSortable(false);

    maxClock = new TableColumn<>("Max Core(MHz)");
    maxClock.setCellValueFactory(new PropertyValueFactory("maxCore"));
    maxClock.setSortable(false);

    minMemory = new TableColumn<>("Min Memory(MHz)");
    minMemory.setCellValueFactory(new PropertyValueFactory("minMemory"));
    minMemory.setSortable(false);

    maxMemory = new TableColumn<>("Max Memory(MHz)");
    maxMemory.setCellValueFactory(new PropertyValueFactory("maxMemory"));
    maxMemory.setSortable(false);

    table.getColumns().addAll(perfLevel, minClock, maxClock, minMemory, maxMemory);

    performancePane = new PerformanceModePane();

    super.getChildren().addAll(table, performancePane);
}
项目:Goliath-Overclocking-Utility-FX    文件:InformationPane.java   
public InformationPane()
{
    super();
    super.setPrefHeight(AppTabPane.CONTENT_HEIGHT);
    super.setPrefWidth(AppTabPane.CONTENT_WIDTH);

    infoTable = new TableView<>(FXCollections.observableArrayList(InstanceProvider.getAttributes()));

    if(AppSettings.getShowExtraAttributeInfo())
    {
        cmdName = new TableColumn<>("Cmd Name");
        cmdName.setCellValueFactory(new PropertyValueFactory("cmdName"));

        cmdValue = new TableColumn<>("Cmd Value");
        cmdValue.setCellValueFactory(new PropertyValueFactory("cmdValue"));
    }

    displayName = new TableColumn<>("Name");
    displayName.setCellValueFactory(new PropertyValueFactory("displayName"));

    displayValue = new TableColumn<>("Value");
    displayValue.setCellValueFactory(new PropertyValueFactory("displayValue"));

    if(!AppSettings.getShowExtraAttributeInfo())
        infoTable.getColumns().addAll(displayName, displayValue);
    else
        infoTable.getColumns().addAll(cmdName, displayName, cmdValue, displayValue);

    infoTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    infoTable.setPrefWidth(AppTabPane.CONTENT_WIDTH);
    infoTable.setPrefHeight(AppTabPane.CONTENT_HEIGHT);
    infoTable.setEditable(false);

    super.getChildren().add(infoTable);
}
项目:UDE    文件:ClassTableView.java   
public void setValues(TableView<FileInfo> tableview,TableColumn<FileInfo, ImageView> image,TableColumn<FileInfo, String> date,
               TableColumn<FileInfo, String> name,TableColumn<FileInfo, String> size){
    this.tableview = tableview;
    this.date = date;
    this.name=name;
    this.size = size;
    this.image=image;
}
项目: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);
        }
    });
}
项目:x-facteur    文件:PathView.java   
@SuppressWarnings("unchecked")
public void reload() {
    tabs.getTabs().clear();
    for (Path path: PathController.getItems()) {
        // create one tab per path
        VBox container = new VBox(8);
        container.setPadding(new Insets(20));
        Text header = new Text("" + path.getMailman());

        TableView<Path.PathStep> pathTable = new TableView<Path.PathStep>();    
        pathTable.setItems(FXCollections.observableList(path.getSteps()));

        TableColumn<Path.PathStep, String> shipmentCol = new TableColumn<Path.PathStep, String>("Envois");
        shipmentCol.setCellValueFactory(new PropertyValueFactory<Path.PathStep, String>("shipment"));

        TableColumn<Path.PathStep, String> distanceToNextCol = new TableColumn<Path.PathStep, String>("Distances au suivant (km)");
        distanceToNextCol.setCellValueFactory(new PropertyValueFactory<Path.PathStep, String>("distanceToNext"));

        TableColumn<Path.PathStep, String> sumDistanceCol = new TableColumn<Path.PathStep, String>("Distances cumulées (km)");
        sumDistanceCol.setCellValueFactory(new PropertyValueFactory<Path.PathStep, String>("sumDistance"));

        pathTable.getColumns().setAll(shipmentCol, distanceToNextCol, sumDistanceCol);

        container.getChildren().addAll(header, pathTable);
        String tabName = path.getMailman().getName().charAt(0) + ". " + path.getMailman().getLastName() + " (" + path.size() + ")";
        tabs.getTabs().add(new Tab(tabName, container));
    }
}