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

项目:SONDY    文件:EventDetectionUI.java   
public final void initializeParameterTable(){
    parameterTable.setEditable(true);
    TableColumn keyColumn = new TableColumn("Parameter");
    keyColumn.setMinWidth(Main.columnWidthRIGHT/2-1);
    keyColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
    TableColumn valueColumn = new TableColumn("Value");
    valueColumn.setMinWidth(Main.columnWidthRIGHT/2-1);
    valueColumn.setCellFactory(TextFieldTableCell.forTableColumn());
    valueColumn.setCellValueFactory(new PropertyValueFactory<>("value")); 
    valueColumn.setOnEditCommit(
        new EventHandler<CellEditEvent<Parameter, String>>() {
            @Override
            public void handle(CellEditEvent<Parameter, String> t) {
                ((Parameter) t.getTableView().getItems().get(t.getTablePosition().getRow())).setValue(t.getNewValue());
            }
        }
    );
    parameterTable.getColumns().addAll(keyColumn,valueColumn);
}
项目:Gargoyle    文件:TableEditCell.java   
@Override
    public void commitEdit(T item) {

        if (!isEditing() && !item.equals(getItem())) {
            TableView<S> table = getTableView();
            if (table != null) {
                TableColumn<S, T> column = getTableColumn();

//              S dvo = getTableView().getItems().get(getIndex());
//              if (!CommonConst._STATUS_CREATE.equals(dvo.get_status())) {
//                  dvo.set_status(CommonConst._STATUS_UPDATE);
//              }
                // ObservableValue<T> ov = column.getCellObservableValue(dvo);
                // if (ov instanceof WritableValue) {
                // ((WritableValue) ov).setValue(item);
                // }
                CellEditEvent<S, T> event = new CellEditEvent<>(table, new TablePosition<S, T>(table, getIndex(), column),
                        TableColumn.editCommitEvent(), item);
                Event.fireEvent(column, event);
            }
        }
        super.commitEdit(item);
        getTableView().refresh();
    }
项目:zest-writer    文件:TableController.java   
private void addCol() {
    TableColumn tc = new TableColumn();
    tc.setEditable(true);
    tc.setCellValueFactory(param -> {
        CellDataFeatures<ZRow, String> dtf = (CellDataFeatures<ZRow, String>) param;
        return new SimpleStringProperty(dtf.getValue().getRow().get(0));
    });

    tc.setCellFactory(TextFieldTableCell.forTableColumn());
    tc.setOnEditCommit(t -> {
        CellEditEvent<ZRow, String> evt = (CellEditEvent<ZRow, String>) t;
        List<String> row = evt.getTableView().getItems().get(evt.getTablePosition().getRow()).getRow();
        row.set(evt.getTablePosition().getColumn(), evt.getNewValue());
    });
    tc.setPrefWidth(150);
    TextField txf = new TextField();
    txf.setPrefWidth(150);
    txf.setPromptText(Configuration.getBundle().getString("ui.dialog.table_editor.colon") +
            (tableView.getColumns().size()+1));
    tc.setGraphic(txf);
    tableView.getColumns().addAll(tc);
    postAddColumn();
}
项目:slogo    文件:Variables.java   
@SuppressWarnings("unchecked")
private void initializeTable () {
    this.setEditable(true);
    this.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    TableColumn<IVariable, String> nameColumn = new TableColumn<IVariable, String>("Name");
    TableColumn<IVariable, Double> valueColumn = new TableColumn<IVariable, Double>("Value");

    // set where to read values from
    nameColumn.setCellValueFactory(new PropertyValueFactory<IVariable, String>("name"));
    valueColumn.setCellValueFactory(new PropertyValueFactory<IVariable, Double>("value"));

    // set editable column (valueColumn)
    valueColumn.setCellFactory(TextFieldTableCell
            .<IVariable, Double> forTableColumn(new DoubleStringConverter()));

    // Set listener to execute when on edit commit runs
    valueColumn.setOnEditCommit( (CellEditEvent<IVariable, Double> event) -> setVariableValue(event));
    valueColumn.setEditable(true);

    this.getColumns().addAll(nameColumn, valueColumn);
}
项目:slogo    文件:TableWindow.java   
@SuppressWarnings("unchecked")
private void initializeTable () {
    this.setEditable(true);
    this.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    TableColumn<Object, String> nameColumn = new TableColumn<Object, String>("Name");
    TableColumn<Object, Double> valueColumn = new TableColumn<Object, Double>("Value");

    // set where to read values from
    nameColumn.setCellValueFactory(new PropertyValueFactory<Object, String>("name"));
    valueColumn.setCellValueFactory(new PropertyValueFactory<Object, Double>("value"));

    // set editable column (valueColumn)
    valueColumn.setCellFactory(TextFieldTableCell.<Object, Double> forTableColumn(new DoubleStringConverter()));

    // Set listener to execute when on edit commit runs
    valueColumn.setOnEditCommit( (CellEditEvent<Object, Double> event) -> setVariableValue(event));
    valueColumn.setEditable(true);

    this.getColumns().addAll(nameColumn, valueColumn);
}
项目:TableFilterFX    文件:ColumnFilter.java   
public ColumnFilter(TableFilter<S> tablefilter, TableColumn<S, T> columnToFilter) {
    super();
    this.tableFilter = tablefilter;
    this.column = columnToFilter;
    EventHandler<CellEditEvent<S, T>> editCommitHandler = this.column.getOnEditCommit();
    this.column.setOnEditCommit(event -> {
        editCommitHandler.handle(event);
        updateCellValues();
    });

    // set custom header
    header = new FilteredColumnHeader(column);
    header.prefWidthProperty().bind(column.widthProperty());
    header.getFilterButton().setOnMouseClicked(this::onFilterButtonClicked);
    header.isFilteredProperty().bind(blacklistedCellValues.emptyProperty().not());
    column.setGraphic(header);

    filterPopup = new FilterPopUp<>(mergedCellValues, blacklistedCellValues);
    blacklistedCellValues.addListener(this::onBlacklistedCellValuesChanged);
    initColumnFilter();
}
项目:SurePulseDataProcessor    文件:EditCell.java   
/** {@inheritDoc} */
 @Override
 public void commitEdit(T newValue) {
     if (!isEditing())
         return;
     final TableView < S > table = getTableView();
     if (table != null) {
         // Inform the TableView of the edit being ready to be committed.
         @SuppressWarnings({ "rawtypes", "unchecked" })
CellEditEvent editEvent = new CellEditEvent(table, tablePos,
             TableColumn.editCommitEvent(), newValue);
         Event.fireEvent(getTableColumn(), editEvent);
     }
     // we need to setEditing(false):
     super.cancelEdit(); // this fires an invalid EditCancelEvent.
     // update the item within this cell, so that it represents the new value
     updateItem(newValue, false);
     if (table != null) {
         // reset the editing cell on the TableView
         table.edit(-1, null);
     }
 }
项目:pdfsam    文件:TooltippedTextFieldTableCell.java   
@Override
public void commitEdit(String item) {

    // This block is necessary to support commit on losing focus, because the baked-in mechanism
    // sets our editing state to false before we can intercept the loss of focus.
    // The default commitEdit(...) method simply bails if we are not editing...
    if (!isEditing() && !item.equals(getItem())) {
        TableView<SelectionTableRowData> table = getTableView();
        if (table != null) {
            TableColumn<SelectionTableRowData, String> column = getTableColumn();
            CellEditEvent<SelectionTableRowData, String> event = new CellEditEvent<>(table,
                    new TablePosition<>(table, getIndex(), column), TableColumn.editCommitEvent(), item);
            Event.fireEvent(column, event);
        }
    }

    super.commitEdit(item);
    setContentDisplay(ContentDisplay.TEXT_ONLY);
}
项目:qgu    文件:TaskTableView.java   
private void onTaskNameEditCommit(CellEditEvent<ObservableGanttTask, String> event) {
    if(event.getOldValue().equals(event.getNewValue())) {
        event.consume();
        return;
    }
    event.getRowValue().setName(event.getNewValue());
    //onEditCommit(event); // TODO maybe not necessary to propagate name change
}
项目:qgu    文件:TaskTableView.java   
private void onStartDateEditCommit(CellEditEvent<ObservableGanttTask, String> event) {
    if(event.getOldValue().equals(event.getNewValue())) {
        event.consume();
        return;
    }
    event.getRowValue().setStartDate(event.getNewValue());
    onEditCommit(event);
}
项目:qgu    文件:TaskTableView.java   
private void onEndDateEditCommit(CellEditEvent<ObservableGanttTask, String> event) {
    if(event.getOldValue().equals(event.getNewValue())) {
        event.consume();
        return;
    }
    event.getRowValue().setEndDate(event.getNewValue());
    onEditCommit(event);
}
项目:SnapDup    文件:MapDeviceDialog.java   
@Override
public void handle(CellEditEvent<Pair<String, String>, String> event)
{
    ObservableList<Pair<String, String>> deviceList = tblMapDevice.getItems();
    Pair<String, String> pair = event.getRowValue();

    int index = deviceList.indexOf(pair);

    deviceList.set(index, new Pair<String, String>(pair.first, event.getNewValue()));
}
项目:boolean-simplifier-visualizer    文件:Main.java   
public TableColumn<TTRow, String> createTableColumn(String name, String input, TruthTable m) {
    TableColumn<TTRow, String> tc = new TableColumn<TTRow, String>(name);
    tc.setMinWidth((tableSize / (tt.getInputs().size() + 1)) + 1);
    tc.setMaxWidth((tableSize / (tt.getInputs().size() + 1)) + 1);
    tc.setCellValueFactory(new PropertyValueFactory<>(input));

    if (input.equals("4")) {
        if (!tt.isTrue() && m==tt) {

            tc.setCellFactory(TextFieldTableCell.forTableColumn());
            tc.setOnEditCommit(new EventHandler<CellEditEvent<TTRow, String>>() {
                TableView<TTRow> old = tableV1;

                public void handle(CellEditEvent<TTRow, String> t) {

                    if (t.getNewValue().equals("1") || t.getNewValue().equals("0")) {
                        System.out.println(t.getOldValue());
                        ((TTRow) t.getTableView().getItems().get(t.getTablePosition().getRow())).getCol()[t
                                                                                                          .getTablePosition().getColumn()] = t.getNewValue();
                        tt.edit(t.getTablePosition().getColumn(), t.getTablePosition().getRow(), t.getNewValue());
                        updatetableV2();
                        kmap.drawKMap(tt, tt.getInputs().size(), pane, (int)(Screen.getPrimary().getVisualBounds().getWidth()/2)-(15*tt.getInputs().size()), 10);
                    } else {
                        tableV1 = old;
                    }
                    refreshTable(tableV1);
                    refreshTableV2(tableV2);
                }
            });
        }
    }
    tc.getStyleClass().add("tablecolumn");
    return tc;
}
项目:slogo    文件:Variables.java   
private void setVariableValue (CellEditEvent<IVariable, Double> event) {
    IVariable changedVariable = event.getTableView().getItems().get(event.getTablePosition().getRow());
    ((Variable) changedVariable).setValue(event.getNewValue());

    memory.getStorageMemory().writeVariable(changedVariable.getName(), changedVariable.getValue());

    System.out.println(changedVariable);
}
项目:mlo-gui    文件:MloCommonTable.java   
/**
 * Updates view by input data.
 * @param nameCol the name column.
 */
private void updateObservableListProperties(TableColumn<SliceData, String> nameCol) {
    nameCol.setOnEditCommit(new EventHandler<CellEditEvent<SliceData, String>>() {
        @Override public void handle(CellEditEvent<SliceData, String> t) {
            ((SliceData) t.getTableView().getItems().get(t.getTablePosition().getRow())).setValue(t.getNewValue());
        }
    });
}
项目:jManagr    文件:DepartmentController.java   
public void initialize(URL location, ResourceBundle resources)
{
    idCol.setCellValueFactory(new PropertyValueFactory("id"));
    nameCol.setCellValueFactory(new PropertyValueFactory<Department, String>("name"));

    // makes nameCol to a textField
    nameCol.setCellFactory(TextFieldTableCell.<Department>forTableColumn());

    // sets the new Value after enterPressed in the ObserverList
    nameCol.setOnEditCommit(
            new EventHandler<CellEditEvent<Department, String>>()
            {
                public void handle(CellEditEvent<Department, String> t)
                {
                    Department dep = t.getTableView().getItems().get(
                            t.getTablePosition()
                             .getRow()
                    ); //get changed object
                    dep.setName(t.getNewValue()); // set changed value
                    bl.save(dep);
                    Logger.logln("Updated in table: " + t.getNewValue() + " " + dep.getId());
                }
            }
    );

    // Only checking if add or delete - so dont need it, but leave it for maybe later
    /*ObservableList<Department> b = bl.getAll();
    b.addListener(new ListChangeListener<Department>() {
           @Override
           public void onChanged(Change change) {
               System.out.println("Detected a change! ");
           }
       });*/
    this.refresh();
}
项目:qgu    文件:TaskTableView.java   
private void onEditCommit(CellEditEvent<ObservableGanttTask, String> event) {
    taskListener.taskEditedEvent(event.getTablePosition().getRow(), event.getRowValue().getTask());
}
项目:ISAAC    文件:RefsetTableHandler.java   
private TableColumn<RefsetInstance, String> createCidColumn(String columnTitle, String associatedValue, final int columnNumber) {
    TableColumn<RefsetInstance, String> col = new TableColumn<>(columnTitle);   
    col.setCellValueFactory(new PropertyValueFactory<RefsetInstance,String>(associatedValue));
    col.setCellFactory(RefsetTableEditingCell.create());

    col.setOnEditCommit(new EventHandler<CellEditEvent<RefsetInstance, String>>() {
        @Override
        public void handle(CellEditEvent<RefsetInstance, String> t) {
            try
            {
                if (!Utility.isUUID(t.getNewValue()))
                {
                    AppContext.getCommonDialogs().showErrorDialog("Invalid UUID", "Value requested is not a valid UUID", t.getNewValue());
                    return;
                }

                ConceptVersionBI comp = OTFUtility.lookupIdentifier(t.getNewValue());
                if (comp == null) {
                    AppContext.getCommonDialogs().showErrorDialog("UUID Not Found", "Could not find the UUID in the database", t.getNewValue());
                } else {
                    RefexCAB bp = null;

                    if (refsetType == RefexType.CID ||
                        refsetType == RefexType.CID_STR ||
                        refsetType == RefexType.UNKNOWN)
                    {
                        if (columnNumber == 1) {
                            NidExtRefsetInstance instance = (NidExtRefsetInstance) t.getTableView().getItems().get(t.getTablePosition().getRow());
                            if (OTFUtility.getRefsetMember(instance.getMemberNid()) == null) {
                                RefexCAB newMember = new RefexCAB(RefexType.CID, instance.getRefCompConNid(), refsetNid, IdDirective.GENERATE_RANDOM, RefexDirective.EXCLUDE);

                                newMember.put(ComponentProperty.COMPONENT_EXTENSION_1_ID, comp.getPrimordialUuid());

                                RefexChronicleBI<?> newMemChron = OTFUtility.getBuilder().construct(newMember);
                                instance.setMemberNid(newMemChron.getNid());


                                ConceptVersionBI refCompCon;
                                if (!isAnnotation) {
                                    refCompCon = OTFUtility.getConceptVersion(instance.getRefCompConNid());
                                } else {
                                    refCompCon = OTFUtility.getConceptVersion(refsetNid);
                                }
                                refCompCon.addAnnotation(newMemChron);

                                OTFUtility.addUncommitted(instance.getRefCompConNid());
                                rvc_.reloadData();
                                return;
                            } else {
                                instance.setCidExtFsn(comp.getFullySpecifiedDescription().getText());
                                instance.setCidExtUuid(comp.getPrimordialUuid());

                                bp = createBlueprint(instance.getMemberNid());
                                bp.put(ComponentProperty.COMPONENT_EXTENSION_1_ID, comp.getPrimordialUuid());
                            }
                        }
                    }

                    addUncommitted(bp, isAnnotation);
                    rvc_.reloadData();
                }
            }
            catch (Exception e)
            {
                logger.error("Unexpected error handling edit", e);
            }
        }
    });

    return col;
}
项目:examples-javafx-repos1    文件:BigTableController.java   
static <T, S> T getObjectAtEvent(CellEditEvent<T, S> evt) {

    TableView<T> tableView = evt.getTableView();

    ObservableList<T> items = tableView.getItems();

    TablePosition<T,S> tablePosition = evt.getTablePosition();

    int rowId = tablePosition.getRow();

    T obj = items.get(rowId);

    return obj;
}
项目:slogo    文件:TableWindow.java   
protected abstract void setVariableValue(CellEditEvent<Object, Double> event);