javafx.scene.control.cell.TextFieldTableCell Java Examples

The following examples show how to use javafx.scene.control.cell.TextFieldTableCell. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InfluenceAnalysisUI.java    From SONDY with GNU General Public License v3.0 6 votes vote down vote up
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<TableColumn.CellEditEvent<Parameter, String>>() {
            @Override
            public void handle(TableColumn.CellEditEvent<Parameter, String> t) {
                ((Parameter) t.getTableView().getItems().get(t.getTablePosition().getRow())).setValue(t.getNewValue());
            }
        }
    );
    parameterTable.getColumns().addAll(keyColumn,valueColumn);
}
 
Example #2
Source File: EventDetectionUI.java    From SONDY with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #3
Source File: InterpolatingLookupPaintScaleSetupDialogController.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
@FXML
private void initialize() {

    tableLookupValues.setEditable(true);
    valueColumn.setCellValueFactory(cell-> new ReadOnlyObjectWrapper<>(cell.getValue().getKey()));
    valueColumn.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
    valueColumn.setOnEditCommit(event -> {
        Double newKey = event.getNewValue();
        Double oldKey = event.getOldValue();
        lookupTable.put(newKey,lookupTable.get(oldKey));
        lookupTable.remove(oldKey);
        updateOBList(lookupTable);
    });

    colorColumn.setCellValueFactory(cell-> new ReadOnlyObjectWrapper<>(cell.getValue().getValue()));
    colorColumn.setCellFactory(column -> new ColorTableCell<InterpolatingLookupPaintScaleRow>(column));
    colorColumn.setOnEditCommit(event -> {
        Color newColor = event.getNewValue();
        Double key =  event.getRowValue().getKey();
        lookupTable.put(key,newColor);
        updateOBList(lookupTable);
    });

}
 
Example #4
Source File: TableController.java    From zest-writer with GNU General Public License v3.0 6 votes vote down vote up
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();
}
 
Example #5
Source File: FormulaPane.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
private TableView<InputItem> createInputs()
{
    TableColumn<InputItem, String> col = new TableColumn<>(Messages.FormulaTabInput);
    col.setCellValueFactory(c ->  c.getValue().input_name);
    input_table.getColumns().add(col);

    col = new TableColumn<>(Messages.FormulaTabVariable);
    col.setCellValueFactory(c ->  c.getValue().variable_name);
    col.setCellFactory(TextFieldTableCell.forTableColumn());
    // When variable is renamed, re-evaluate formula
    col.setOnEditCommit(event -> parseFormula());
    col.setEditable(true);
    input_table.getColumns().add(col);

    input_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    input_table.setTooltip(new Tooltip(Messages.FormulaTabTT));
    input_table.setEditable(true);
    // Double-click (on input column) adds that variable name to formula
    input_table.addEventHandler(MouseEvent.MOUSE_PRESSED, event ->
    {
        if (event.getClickCount() == 2)
            insert(input_table.getSelectionModel().getSelectedItem().variable_name.get());
    });

    return input_table;
}
 
Example #6
Source File: MainController.java    From neural-style-gui with GNU General Public License v3.0 5 votes vote down vote up
private void setupContentLayersTable() {
    log.log(Level.FINER, "Setting content layer table list.");
    contentLayersTable.setItems(contentLayers);
    contentLayersTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

    log.log(Level.FINER, "Setting content layer table selection listener.");
    EventStreams.changesOf(contentLayers).subscribe(change -> {
        log.log(Level.FINE, "contentLayers changed");

        List<NeuralBoolean> selectedContentLayers = contentLayers.stream()
                .filter(NeuralBoolean::getValue)
                .collect(Collectors.toList());

        String[] newContentLayers = new String[selectedContentLayers.size()];
        for (int i = 0; i < selectedContentLayers.size(); i++)
            newContentLayers[i] = selectedContentLayers.get(i).getName();
        neuralStyle.setContentLayers(newContentLayers);

        toggleStyleButtons();
    });

    log.log(Level.FINER, "Setting style layer table shortcut listener");
    EventStreams.eventsOf(contentLayersTable, KeyEvent.KEY_RELEASED).filter(spaceBar::match).subscribe(keyEvent -> {
        ObservableList<NeuralBoolean> selectedStyleLayers =
                contentLayersTable.getSelectionModel().getSelectedItems();
        for (NeuralBoolean neuralLayer : selectedStyleLayers)
            neuralLayer.setValue(!neuralLayer.getValue());
    });

    log.log(Level.FINER, "Setting content layer table column factories.");
    contentLayersTableSelected.setCellValueFactory(new PropertyValueFactory<>("value"));
    contentLayersTableSelected.setCellFactory(CheckBoxTableCell.forTableColumn(contentLayersTableSelected));

    contentLayersTableName.setCellValueFactory(new PropertyValueFactory<>("name"));
    contentLayersTableName.setCellFactory(TextFieldTableCell.forTableColumn());
}
 
Example #7
Source File: CalcExpSeaAreaEditorController.java    From logbook-kai with MIT License 5 votes vote down vote up
@FXML
void initialize() {
    // 海域
    this.name.setCellValueFactory(new PropertyValueFactory<>("name"));
    this.name.setCellFactory(TextFieldTableCell.forTableColumn());
    // 海域Exp
    this.exp.setCellValueFactory(new PropertyValueFactory<>("exp"));
    this.exp.setCellFactory(TextFieldTableCell.forTableColumn(new StringConverter<Integer>() {
        @Override
        public Integer fromString(String string) {
            try {
                return Integer.parseInt(string);
            } catch (Exception e) {
                return 0;
            }
        }

        @Override
        public String toString(Integer val) {
            return Integer.toString(val);
        }
    }));
    // 削除ボタン
    this.cmd.setCellValueFactory(new PropertyValueFactory<>("name"));
    this.cmd.setCellFactory(p -> new CmdCell());

    this.table.setItems(AppSeaAreaExpCollection.get()
            .getList()
            .stream()
            .map(SeaAreaExpItem::toItem)
            .collect(Collectors.toCollection(FXCollections::observableArrayList)));
}
 
Example #8
Source File: TagEditorPane.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public TagEditorPane(Map<String, String> tags) {
	tagTable.setEditable(true);
	tagTable.setPrefHeight(200);
	tagTable.setPrefWidth(200);

	final TableColumn<Tag, String> nameCol = new TableColumn<>("Name");
	nameCol.setCellValueFactory(new PropertyValueFactory<Tag, String>("name"));
	nameCol.setCellFactory(TextFieldTableCell.<Tag> forTableColumn());
	nameCol.setOnEditCommit((t) -> {
		t.getTableView().getItems().get(t.getTablePosition().getRow()).setName(t.getNewValue());
	});

	final TableColumn<Tag, String> valueCol = new TableColumn<>("Value");
	valueCol.setCellFactory(TextFieldTableCell.<Tag> forTableColumn());
	valueCol.setCellValueFactory(new PropertyValueFactory<Tag, String>("value"));
	valueCol.setOnEditCommit((t) -> {
		t.getTableView().getItems().get(t.getTablePosition().getRow()).setValue(t.getNewValue());
	});

	tagTable.getColumns().addAll(nameCol, valueCol);
	final ObservableList<Tag> data = FXCollections.observableArrayList();

	for (final Entry<String, String> entry : tags.entrySet())
		data.add(new Tag(entry.getKey(), entry.getValue()));

	tagTable.setItems(data);

	tagTable.setOnMouseClicked((event) -> {
		if (event.getClickCount() == 2) {
			data.add(new Tag("", ""));
		}
	});

	getChildren().add(tagTable);
}
 
Example #9
Source File: BigTableController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
@FXML
	public void initialize() {
		
		btnSave.disableProperty().bind( dirtyFlag.not() );
		
		// id is read-only
/*		tcId.setCellValueFactory(new PropertyValueFactory<MyObject,Number>("id") {

			@Override
			public ObservableValue<Number> call(CellDataFeatures<MyObject, Number> param) {
				return new ReadOnlyObjectWrapper<Number>(param.getValue().getId());
			}
			
		});		
*/
		tcId.setCellValueFactory(new PropertyValueFactory<MyObject,Number>("id"));		
		
		tcData.setCellValueFactory(new PropertyValueFactory<MyObject,String>("data"){			
			@Override
			public ObservableValue<String> call(CellDataFeatures<MyObject, String> param) {
				System.out.println("pvCounter=" + pvCounter++);
				return new ReadOnlyObjectWrapper<String>(param.getValue().getData());
			}
		
		});
		tcData.setCellFactory(TextFieldTableCell.forTableColumn());				
		tcData.setOnEditCommit( dataEditCommitHandler );		
		
	}
 
Example #10
Source File: MsSpectrumLayersDialogController.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public void initialize() {

    final ObservableList<MsSpectrumType> renderingChoices =
        FXCollections.observableArrayList(MsSpectrumType.CENTROIDED, MsSpectrumType.PROFILE);
    renderingTypeColumn.setCellFactory(ChoiceBoxTableCell.forTableColumn(renderingChoices));

    colorColumn.setCellFactory(column -> new ColorTableCell<MsSpectrumDataSet>(column));

    lineThicknessColumn
        .setCellFactory(column -> new SpinnerTableCell<MsSpectrumDataSet>(column, 1, 5));

    intensityScaleColumn.setCellFactory(TextFieldTableCell.forTableColumn(
        new NumberStringConverter(MZmineCore.getConfiguration().getIntensityFormat())));

    showDataPointsColumn
        .setCellFactory(column -> new CheckBoxTableCell<MsSpectrumDataSet, Boolean>() {
          {
            tableRowProperty().addListener(e -> {
              TableRow<?> row = getTableRow();
              if (row == null)
                return;
              MsSpectrumDataSet dataSet = (MsSpectrumDataSet) row.getItem();
              if (dataSet == null)
                return;
              disableProperty()
                  .bind(dataSet.renderingTypeProperty().isEqualTo(MsSpectrumType.CENTROIDED));

            });
          }
        });
  }
 
Example #11
Source File: RFXTextFieldTableCell.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public String _getValue() {
    TextFieldTableCell<?, ?> cell = (TextFieldTableCell<?, ?>) node;
    @SuppressWarnings("rawtypes")
    StringConverter converter = cell.getConverter();
    if (converter != null) {
        return converter.toString(cell.getItem());
    }
    return cell.getItem().toString();
}
 
Example #12
Source File: StringTableDemo.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void start(Stage stage) throws Exception
{
    TableColumn<List<StringProperty>, String> tc = new TableColumn<>("A");
    tc.setCellValueFactory(param ->  param.getValue().get(0));
    tc.setCellFactory(TextFieldTableCell.forTableColumn());

    tc.setOnEditCommit(event ->
    {
        final int col = event.getTablePosition().getColumn();
        event.getRowValue().get(col).set(event.getNewValue());
    });

    tc.setEditable(true);
    table.getColumns().add(tc);

    tc = new TableColumn<>("B");
    tc.setCellValueFactory(param ->  param.getValue().get(1));
    tc.setCellFactory(TextFieldTableCell.forTableColumn());
    tc.setEditable(true);
    table.getColumns().add(tc);

    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    table.setEditable(true);

    final Scene scene = new Scene(table, 800, 600);
    stage.setScene(scene);
    stage.show();

    List<StringProperty> row = new ArrayList<>();
    row.add(new SimpleStringProperty("One"));
    row.add(new SimpleStringProperty("Another"));
    data.add(row);

    row = new ArrayList<>();
    row.add(new SimpleStringProperty("Two"));
    row.add(new SimpleStringProperty("Something"));
    data.add(row);

    final Thread change_cell = new Thread(() ->
    {
        while (true)
        {
            try
            {
                Thread.sleep(500);
            }
            catch (InterruptedException e)
            {
                e.printStackTrace();
            }
            Platform.runLater(() ->  updateCell(1, 0, LocalDateTime.now().toString().replace('T', ' ')));
        }
    });
    change_cell.setDaemon(true);
    change_cell.start();
}
 
Example #13
Source File: ProjectParametersSetupDialogController.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
private TableColumn<ObservableList<StringProperty>, String> createColumn(
            final int columnIndex, String columnTitle) {
        TableColumn<ObservableList<StringProperty>, String> column = new TableColumn<>();
        String title;
        if (columnTitle == null || columnTitle.trim().length() == 0) {
            title = "Column " + (columnIndex + 1);
        } else {
            title = columnTitle;
        }
        column.setText(title);
        column.setCellValueFactory(cellDataFeatures -> {
                    ObservableList<StringProperty> values = cellDataFeatures.getValue();
                    if (columnIndex >= values.size()) {
                        return new SimpleStringProperty("");
                    } else {
                        return cellDataFeatures.getValue().get(columnIndex);
                    }
                });
        if(columnIndex!=0){
            column.setCellFactory(TextFieldTableCell.forTableColumn());
            column.setOnEditCommit(
                    event->{
//                        String oldParaVal = event.getOldValue();
                        String newParaVal = event.getNewValue();
                        String parameterName =  event.getTableColumn().getText();
                        UserParameter<?,?> parameter = currentProject.getParameterByName(parameterName);
                        int rowNo = parameterTable.getSelectionModel().selectedIndexProperty().get();
                        String fileName = parameterTable.getItems().get(rowNo).get(0).getValue();
                        RawDataFile rawDataFile = null;
                        for(RawDataFile file:fileList){
                            if(file.getName().equals(fileName)){
                                rawDataFile = file;
                                break;
                            }
                        }
                        currentProject.setParameterValue(parameter,rawDataFile,newParaVal);
                        updateParametersToTable();
                    }
            );

        }
        column.setMinWidth(175.0);
        return column;
    }
 
Example #14
Source File: ClientList.java    From Maus with GNU General Public License v3.0 4 votes vote down vote up
public TableView getClientList() {

        tableView = new TableView();
        tableView.setEditable(true);
        tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
        tableView.getStylesheets().add(getClass().getResource("/css/global.css").toExternalForm());

        TableColumn<String, String> onlineStatus = new TableColumn<>("Status");
        onlineStatus.setMaxWidth(70);
        onlineStatus.setResizable(false);
        onlineStatus.setCellValueFactory(
                new PropertyValueFactory<>("onlineStatus"));

        TableColumn<ClientObject, String> nickName = new TableColumn<>("Nickname");
        nickName.setMinWidth(150);
        nickName.setMaxWidth(200);
        nickName.setResizable(false);
        nickName.setCellValueFactory(new PropertyValueFactory<>("nickName"));
        nickName.setCellFactory(TextFieldTableCell.forTableColumn());
        nickName.setOnEditCommit(
                t -> t.getTableView().getItems().get(
                        t.getTablePosition().getRow()).setNickName(t.getNewValue())
        );

        TableColumn<ClientObject, String> IP = new TableColumn<>("IP");
        IP.setMinWidth(600);
        IP.setResizable(false);
        IP.setCellValueFactory(new PropertyValueFactory<>("IP"));
        IP.setCellFactory(col -> {
            final TableCell<ClientObject, String> cell = new TableCell<>();
            cell.textProperty().bind(cell.itemProperty());
            cell.setOnMouseClicked(event -> {
                if (event.getButton().equals(MouseButton.SECONDARY) && cell.getTableView().getSelectionModel().getSelectedItem() != null && cell.getTableView().getSelectionModel().getSelectedItem().getClient().isConnected()) {
                    IPContextMenu.getIPContextMenu(cell, event);
                }
            });
            return cell;
        });
        ObservableList<ClientObject> list = FXCollections.observableArrayList();
        list.addAll(CONNECTIONS.values());
        tableView.setItems(list);
        tableView.getColumns().addAll(onlineStatus, nickName, IP);

        return tableView;
    }
 
Example #15
Source File: SettlementTableView.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public TableView createGUI() {

		for (int x = 0; x < NUM_COLUMNS; x++) {
			TableColumn<Map, String> col = new TableColumn<>(headers[x]);
			col.setCellValueFactory(new MapValueFactory(x));
			col.setMinWidth(col_widths[x]);
			cols.add(col);
		}

        table_view = new TableView<>(generateDataInMap());
        table_view.setEditable(true);
        table_view.getSelectionModel().setCellSelectionEnabled(true);
        table_view.getColumns().setAll(cols.get(0), cols.get(1), cols.get(2), 
        		cols.get(3), cols.get(4), cols.get(5), cols.get(6));

        Callback<TableColumn<Map, String>, TableCell<Map, String>>
            cellFactoryForMap = new Callback<TableColumn<Map, String>, TableCell<Map, String>>() {
                    @Override
                    public TableCell call(TableColumn p) {
                        return new TextFieldTableCell(new StringConverter() {
                            @Override
                            public String toString(Object o) {
                            	//updateSettlementInfo();
                            	//System.out.println("o.toString() is "+ o.toString());                    	
                        		//validationSupport.registerValidator((TextField) o, Validator.createEmptyValidator("Text is required"));
                            	return o.toString();
                            }
                            @Override
                            public Object fromString(String s) {
                            	//updateSettlementInfo();
                            	//System.out.println("string() is "+ s);
                                return s;
                            }                                    
                        });
                    }
        };
        
        for (int x = 0; x < NUM_COLUMNS; x++) {
			cols.get(x).setCellFactory(cellFactoryForMap);
		}
        
        return table_view;
    }
 
Example #16
Source File: PersonsCellFactory.java    From examples-javafx-repos1 with Apache License 2.0 4 votes vote down vote up
@Override
 public TableCell<Person, String> call(TableColumn<Person, String> param) {

     return new TextFieldTableCell<Person, String>(new DefaultStringConverter()) {      
     	
     	{
         	ContextMenu cm = new ContextMenu();
         	MenuItem deletePersonsMenuItem = new MenuItem("Delete");
         	deletePersonsMenuItem.setOnAction( PersonsCellFactory.this.deletePersonsHandler );
         	cm.getItems().add(deletePersonsMenuItem);
         	this.setContextMenu(cm);      
     	}
     	
         @Override
         public void updateItem(String arg0, boolean empty) {
         	
             super.updateItem(arg0, empty);
             
             if( !empty ) {
                 this.setText( arg0 );
             } else {
                 this.setText( null );  // clear from recycled obj
             }
         }

@SuppressWarnings("unchecked")
@Override
public void commitEdit(String newValue) {
	super.commitEdit(newValue);
	TableRow<Person> row = this.getTableRow();
	Person p = row.getItem();
	
	String msg = p.validate();
	if( logger.isLoggable(Level.FINE) ) {
		logger.fine("[COMMIT EDIT] validate=" + msg);
	}
		
	if( msg == null || msg.isEmpty() ) {
		if( logger.isLoggable(Level.FINE) ) {
			logger.fine("[COMMIT EDIT] validation passed");
		}
		Task<Void> task = new Task<Void>() {
			@Override
			protected Void call() {
				dao.updatePerson(p);  // updates AR too
				return null;
			}
		};
		new Thread(task).start();
	} else {
		
		System.out.println("layoutBounds=" + this.getLayoutBounds());
		System.out.println("boundsInLocal=" + this.getBoundsInLocal());
		System.out.println("boundsInParent=" + this.getBoundsInParent());
		System.out.println("boundsInParent (Scene)=" + this.localToScene(this.getBoundsInParent()));
		System.out.println("boundsInParent (Screen)=" + this.localToScreen(this.getBoundsInParent()));

		System.out.println("row layoutBounds=" + row.getLayoutBounds());
		System.out.println("row boundsInLocal=" + row.getBoundsInLocal());
		System.out.println("row boundsInParent=" + row.getBoundsInParent());
		System.out.println("row boundsInParent (Scene)=" + row.localToScene(this.getBoundsInParent()));
		System.out.println("row boundsInParent (Screen)=" + row.localToScreen(this.getBoundsInParent()));

		VBox vbox = new VBox();
		vbox.setPadding(new Insets(10.0d));
		vbox.setStyle("-fx-background-color: white; -fx-border-color: red");
		vbox.getChildren().add( new Label(msg));
		//vbox.setEffect(new DropShadow());
		
		Popup popup = new Popup();
		popup.getContent().add( vbox );
		popup.setAutoHide(true);
		popup.setOnShown((evt) -> {
			
			System.out.println("vbox layoutBounds=" + vbox.getLayoutBounds());
			System.out.println("vbox boundsInLocal=" + vbox.getBoundsInLocal());
			System.out.println("vbox boundsInParent=" + vbox.getBoundsInParent());
			System.out.println("vbox boundsInParent (Scene)=" + vbox.localToScene(this.getBoundsInParent()));
			System.out.println("vbox boundsInParent (Screen)=" + vbox.localToScreen(this.getBoundsInParent()));

		});
		popup.show( row, 
				row.localToScreen(row.getBoundsInParent()).getMinX(), 
				row.localToScreen(row.getBoundsInParent()).getMaxY());					
	}
}
     };
 }
 
Example #17
Source File: WatchlistController.java    From Noexes with GNU General Public License v3.0 4 votes vote down vote up
@FXML
public void initialize() {
    updateCol.setCellValueFactory(param -> param.getValue().updateProperty());
    lockedCol.setCellValueFactory(param -> param.getValue().lockedProperty());
    typeCol.setCellValueFactory(param -> param.getValue().typeProperty());
    addrCol.setCellValueFactory(param -> param.getValue().addrProperty());
    descCol.setCellValueFactory(param -> param.getValue().descProperty());
    valueCol.setCellValueFactory(param -> param.getValue().valueProperty());

    updateCol.setCellFactory(param -> new CheckBoxTableCell<>());
    lockedCol.setCellFactory(param -> new CheckBoxTableCell<>());
    typeCol.setCellFactory(param -> new ComboBoxTableCell<>(DataType.values()) {
        {
            setItem(DataType.INT);
        }
    });
    addrCol.setCellFactory(TextFieldTableCell.forTableColumn());
    descCol.setCellFactory(TextFieldTableCell.forTableColumn());
    valueCol.setCellFactory(param -> new SpinnerTableCell<>(valueCol, new HexSpinner() {
                {
                    setEditable(true);
                    setSize(16);
                }
            }) {
                @Override
                protected void updateItem(Long item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item == null || empty) {
                        return;
                    }
                    WatchlistModel model = getTableRow().getItem();
                    if (model == null) {
                        return;
                    }
                    getSpinner().setSize(model.getSize() * 2);
                }
            }
    );

    watchlistTable.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> removeButton.setDisable(newValue == null));
}
 
Example #18
Source File: TableViewer.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
private void updateEditableState() {
    this.setEditable(false);
    this.setOnEditCommit(null);
    if (!(ds instanceof EditableDataSet) || (type != ColumnType.X && type != ColumnType.Y)) {
        // can edit only 'EditableDataSet's and (X or Y) columns
        return;
    }
    final EditableDataSet editableDataSet = (EditableDataSet) ds;
    final EditConstraints editConstraints = editableDataSet.getEditConstraints();

    if (type == ColumnType.X && editConstraints != null && !editConstraints.isEditable(DIM_X)) {
        // editing of x coordinate is excluded
        return;
    }
    if (type == ColumnType.Y && editConstraints != null && !editConstraints.isEditable(DIM_Y)) {
        // editing of y coordinate is excluded
        return;
    }

    // column can theoretically be edited as long as 'canChange(index)' is true for the selected index
    // and isAcceptable(index, double, double) is also true
    this.setEditable(true);
    this.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));

    this.setOnEditCommit(e -> {
        DataSetsRow rowValue = e.getRowValue();
        if (rowValue == null) {
            LOGGER.atError().log("DataSet row should not be null");
            return;
        }
        final int row = rowValue.getRow();
        final double oldX = editableDataSet.get(DIM_X, row);
        final double oldY = editableDataSet.get(DIM_Y, row);

        if (editConstraints != null && !editConstraints.canChange(row)) {
            // may not edit value, revert to old value (ie. via rewriting old value)
            editableDataSet.set(row, oldX, oldY);
            return;
        }

        final double newVal = e.getNewValue();
        switch (type) {
        case X:
            if (editConstraints != null && !editConstraints.isAcceptable(row, newVal, oldY)) {
                // may not edit x
                editableDataSet.set(row, oldX, oldY);
                break;
            }
            editableDataSet.set(row, newVal, oldY);
            break;
        case Y:
            if (editConstraints != null && !editConstraints.isAcceptable(row, oldX, newVal)) {
                // may not edit y
                editableDataSet.set(row, oldX, oldY);
                break;
            }
            editableDataSet.set(row, oldX, newVal);
            break;
        default:
            // Errors are not editable, as there is no interface for manipulating them
            editableDataSet.set(row, oldX, oldY);
            break;
        }
    });
}
 
Example #19
Source File: RightListViewInit.java    From mapper-generator-javafx with Apache License 2.0 4 votes vote down vote up
/**
 * 展开字段
 */
public void expandTableViewColumns(VBox selectedVBox) {
    HBox hBox = new HBox();
    hBox.setAlignment(Pos.CENTER);

    String tableName = ((Label) (((HBox) selectedVBox.getChildren().get(0))).getChildren().get(0)).getText();
    TableView<Column> columnTableView = new TableView<>(FXCollections.observableArrayList(BaseConstants.selectedTableNameTableMap.get(tableName).getColumns()));
    columnTableView.setEditable(true);
    columnTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    ReadOnlyDoubleProperty widthBind = hBox.widthProperty();

    TableColumn<Column, String> tcColumnNam = new TableColumn<>("字段名");
    tcColumnNam.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getColumnName()));
    tcColumnNam.setSortable(false);
    tcColumnNam.prefWidthProperty().bind(widthBind.multiply(0.16));
    tcColumnNam.getStyleClass().setAll("myColumn");

    TableColumn<Column, String> tcType = new TableColumn<>("类型");
    tcType.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getType()));
    tcType.setSortable(false);
    tcType.prefWidthProperty().bind(widthBind.multiply(0.16));
    tcType.getStyleClass().setAll("myColumn");

    TableColumn<Column, String> property = new TableColumn<>("property");
    property.setCellFactory(TextFieldTableCell.forTableColumn());
    property.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getColumnOverride().getProperty()));
    property.setOnEditCommit(event -> {
        event.getRowValue().getColumnOverride().setProperty(event.getNewValue());
        BaseConstants.tableNameIsOverrideRecodeMap.put(tableName, true);
    });
    property.setSortable(false);
    property.prefWidthProperty().bind(widthBind.multiply(0.16));
    property.getStyleClass().setAll("myColumn");

    TableColumn<Column, String> javaType = new TableColumn<>("java type");
    javaType.setCellFactory(TextFieldTableCell.forTableColumn());
    javaType.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getColumnOverride().getJavaType()));
    javaType.setOnEditCommit(event -> {
        event.getRowValue().getColumnOverride().setJavaType(event.getNewValue());
        BaseConstants.tableNameIsOverrideRecodeMap.put(tableName, true);
    });
    javaType.setSortable(false);
    javaType.prefWidthProperty().bind(widthBind.multiply(0.2));
    javaType.getStyleClass().setAll("myColumn");

    TableColumn<Column, String> typeHandler = new TableColumn<>("type handler");
    typeHandler.setCellFactory(TextFieldTableCell.forTableColumn());
    typeHandler.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getColumnOverride().getTypeHandler()));
    typeHandler.setOnEditCommit(event -> {
        event.getRowValue().getColumnOverride().setTypeHandler(event.getNewValue());
        BaseConstants.tableNameIsOverrideRecodeMap.put(tableName, true);
    });
    typeHandler.setSortable(false);
    typeHandler.prefWidthProperty().bind(widthBind.multiply(0.22));
    typeHandler.getStyleClass().setAll("myColumn");

    TableColumn<Column, Boolean> ignoreCheckBox = new TableColumn<>("是否忽略");
    ignoreCheckBox.setCellFactory(CheckBoxTableCell.forTableColumn(param -> {
        final Column column = columnTableView.getItems().get(param);
        column.ignoreProperty().addListener((observable, oldValue, newValue) -> {
            column.setIgnore(newValue);
            BaseConstants.tableNameIsOverrideRecodeMap.put(tableName, true);
        });
        return column.ignoreProperty();
    }));
    ignoreCheckBox.setSortable(false);
    ignoreCheckBox.prefWidthProperty().bind(widthBind.multiply(0.1));
    ignoreCheckBox.getStyleClass().setAll("myColumn");

    columnTableView.getColumns().add(tcColumnNam);
    columnTableView.getColumns().add(tcType);
    columnTableView.getColumns().add(ignoreCheckBox);
    columnTableView.getColumns().add(property);
    columnTableView.getColumns().add(javaType);
    columnTableView.getColumns().add(typeHandler);

    columnTableView.setFixedCellSize(30);
    columnTableView.prefHeightProperty().bind(columnTableView.fixedCellSizeProperty().multiply(Bindings.size(columnTableView.getItems()).add(1.3)));
    columnTableView.prefWidthProperty().bind(hBox.widthProperty());

    hBox.getChildren().add(columnTableView);
    selectedVBox.getChildren().add(hBox);
}
 
Example #20
Source File: SQLColumnSettingsComponent.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public SQLColumnSettingsComponent() {
    columnsTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    value = new SQLColumnSettings();
    TableColumn<SQLRowObject,String> columnName=new TableColumn<SQLRowObject,String> (value.getColumnName(0));
    TableColumn<SQLRowObject,SQLExportDataType>  columnType=new TableColumn<SQLRowObject,SQLExportDataType> (value.getColumnName(1));
    TableColumn<SQLRowObject,String>  columnValue= new TableColumn<SQLRowObject,String> (value.getColumnName(2));

    columnName.setCellValueFactory(new PropertyValueFactory<>("Name")); //this is needed during connection to a database
    columnType.setCellValueFactory(new PropertyValueFactory<>("Type"));
    columnValue.setCellValueFactory(new PropertyValueFactory<>("Value"));

    columnsTable.getColumns().addAll(columnName,columnType,columnValue);  //added all the columns in the table
    setValue(value);
    columnsTable.setStyle("-fx-selection-bar: #3399FF; -fx-selection-bar-non-focused: #E3E3E3;"); //CSS color change on selection of row


    columnsTable.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    columnName.setSortable(false);
    columnValue.setSortable(false);
    columnType.setSortable(false);

    columnName.setReorderable(false);
    columnValue.setReorderable(false);
    columnType.setReorderable(false);

    columnsTable.setPrefSize(550, 220);
    columnsTable.setFixedCellSize(columnsTable.getFixedCellSize()+20);
    columnsTable.setStyle("-fx-font: 10 \"Plain\"");

    //Setting action event on cells
    columnsTable.getSelectionModel().setCellSelectionEnabled(true);  //individual cell selection enabled
    columnsTable.setEditable(true);

    //Editors on each cell
  columnName.setCellFactory(TextFieldTableCell.<SQLRowObject>forTableColumn());
  columnName.setOnEditCommit(event -> {
    getValue().setValueAt(event.getNewValue(), event.getTablePosition().getRow(), 0);
    setValue(getValue()); //refresh the table
  });

  columnValue.setCellFactory(TextFieldTableCell.<SQLRowObject>forTableColumn());
  columnValue.setOnEditCommit(event -> {
    getValue().setValueAt(event.getNewValue().toUpperCase(), event.getTablePosition().getRow(), 2);
    setValue(getValue()); //refresh the table
  });

  ArrayList<SQLExportDataType> exportDataTypeValues=new ArrayList<SQLExportDataType>(Arrays.asList(SQLExportDataType.values()));

  columnType.setCellFactory(ComboBoxTableCell.forTableColumn(FXCollections.observableArrayList(SQLExportDataType.values())));
  columnType.setOnEditCommit(event -> {
    boolean selected = event.getNewValue().isSelectableValue();
    if(!selected){ //case of  invalid(Title) datatype selection
      getValue().setValueAt(exportDataTypeValues.get(exportDataTypeValues.indexOf(event.getNewValue())+1),event.getTablePosition().getRow(),1);
    }
    else {
      getValue().setValueAt(event.getNewValue(), event.getTablePosition().getRow(), 1);
    }
    setValue(getValue());
  });

    // Add buttons
    VBox buttonsPanel=new VBox(20);
    addColumnButton=new Button("Add");
    removeColumnButton=new Button("Remove");
    addColumnButton.setOnAction(this::actionPerformed);
    removeColumnButton.setOnAction(this::actionPerformed);
    buttonsPanel.getChildren().addAll(addColumnButton,removeColumnButton);


    this.setRight(buttonsPanel);
    this.setCenter(columnsTable);
    BorderPane.setMargin(buttonsPanel, new Insets(10));

}
 
Example #21
Source File: ElementsTableComponent.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public ElementsTableComponent() {

    elementsValueTable.setEditable(true);
    this.setMaxHeight(200);
    elementsValueTable.setMaxHeight(200);
    elementsValueTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);



// allows the individual cells to be selected
    elementsValueTable.getSelectionModel().cellSelectionEnabledProperty().set(true);
    TableColumn<ElementsValue, String> elementCol = new TableColumn("Element");
    TableColumn<ElementsValue, String> maxCol = new TableColumn("Max");
    TableColumn<ElementsValue, String> minCol = new TableColumn("Min");

    // Make Column editable
    maxCol.setCellFactory(TextFieldTableCell.forTableColumn());
    maxCol.setOnEditCommit(event -> event.getTableView().getItems().get(event.getTablePosition().
            getRow()).setMax(event.getNewValue()));
    minCol.setCellFactory(TextFieldTableCell.forTableColumn());
    minCol.setOnEditCommit(event -> event.getTableView().getItems().get(event.getTablePosition().
            getRow()).setMin(event.getNewValue()));

    elementCol.setCellValueFactory(cell-> new ReadOnlyObjectWrapper<>(cell.getValue().getIsotope().getSymbol()));
    maxCol.setCellValueFactory(col-> {
      String max = String.valueOf(col.getValue().getMax());
      return new ReadOnlyObjectWrapper<>(max);
    });

    minCol.setCellValueFactory(cell-> new ReadOnlyObjectWrapper<>(cell.getValue().getMin()));

    minCol.setOnEditCommit(event -> event.getTableView().getItems().get(event.getTablePosition().
            getRow()).setMin(event.getNewValue()));


    elementsValueTable.setItems(elementsValues);

    final Button addButton = new Button("Add");
    final Button removeButton = new Button("Remove");
    // Add event
    addButton.setOnAction(
        t -> {
          PeriodicTableDialog dialog = new PeriodicTableDialog();
          dialog.show();
          IIsotope chosenIsotope = dialog.getSelectedIsotope();
          if (chosenIsotope == null) return;
          ElementsValue elementsValue = new ElementsValue(chosenIsotope, "100", "0");
            elementsValues.add(elementsValue);
        });

    // Remove event
    removeButton.setOnAction(t -> {
      ElementsValue element = elementsValueTable.getSelectionModel().getSelectedItem();
        elementsValues.remove(element);

    });

    this.setPadding(new Insets(5, 0, 0, 5));

    elementsValueTable.getColumns().addAll(elementCol, minCol, maxCol);
    VBox vBox = new VBox();
    vBox.getChildren().addAll(addButton, removeButton);
    vBox.setSpacing(10);

    this.getChildren().addAll(elementsValueTable,vBox);
    this.setHgap(10d);
    this.setAlignment(Pos.BASELINE_RIGHT);
  }
 
Example #22
Source File: ChromatogramLayersDialogController.java    From old-mzmine3 with GNU General Public License v2.0 3 votes vote down vote up
public void initialize() {

    colorColumn.setCellFactory(column -> new ColorTableCell<ChromatogramPlotDataSet>(column));

    lineThicknessColumn
        .setCellFactory(column -> new SpinnerTableCell<ChromatogramPlotDataSet>(column, 1, 5));

    intensityScaleColumn.setCellFactory(TextFieldTableCell.forTableColumn(
        new NumberStringConverter(MZmineCore.getConfiguration().getIntensityFormat())));

    showDataPointsColumn
        .setCellFactory(column -> new CheckBoxTableCell<ChromatogramPlotDataSet, Boolean>());

  }