Java Code Examples for javafx.util.converter.DefaultStringConverter

The following examples show how to use javafx.util.converter.DefaultStringConverter. These examples are extracted from open source projects. 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 Project: phoebus   Source File: PACETableCell.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public PACETableCell()
{
    super(new DefaultStringConverter());

    // Computing the tool tip text as well as updating a tool tip (popup scene)
    // is relatively expensive.
    // --> Keep one tool tip, only setting its text when shown
    tooltip.setHideDelay(Duration.seconds(10));
    tooltip.setOnShowing(event ->  tooltip.setText(cell == null ? "" : cell.getInfo()) );
}
 
Example 2
Source Project: trex-stateless-gui   Source File: PacketTableView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * initialize packet table columns
 */
private void initializeTableColumn() {

    // add enable column
    streamPacketTableView.getColumns().add(createStaticTableColumn("", "enabledProperty", 30, true));

    // index column
    streamPacketTableView.getColumns().add(createStaticTableColumn("Index", "indexProperty", 50, false));

    TableColumn<TableProfileStream, String> nameColumn = createTableColumn("Name", "nameProperty", .17);
    nameColumn.setCellFactory(column -> new CallbackEditCell<>(this::renameProfile, new DefaultStringConverter()));
    nameColumn.setEditable(true);
    streamPacketTableView.getColumns().add(nameColumn);

    streamPacketTableView.getColumns().add(createTableColumn("Packet Type", "packetTypeProperty", .24));
    TableColumn lengthColumn = createTableColumn("Length", "lengthProperty", .105);
    lengthColumn.setId("alignedColumn");
    streamPacketTableView.getColumns().add(lengthColumn);
    streamPacketTableView.getColumns().add(createTableColumn("Mode", "modeProperty", .145));
    TableColumn rateColumn = createTableColumn("Rate", "rateProperty", .195);
    rateColumn.setId("alignedColumn");
    streamPacketTableView.getColumns().add(rateColumn);

    TableColumn nextStreamCol = createTableColumn("Next Stream", "nextStreamProperty", .144);
    nextStreamCol.setCellFactory(new ImageCellFactory());
    streamPacketTableView.getColumns().add(nextStreamCol);

}
 
Example 3
Source Project: AsciidocFX   Source File: TableFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public FXFormNode call(Void param) {
    tableView.setEditable(true);
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

    return new FXFormNodeWrapper(new VBox(3, tableView, new HBox(5, addButton, removeButton)), tableView.itemsProperty()) {

        @Override
        public void init(Element element, AbstractFXForm fxForm) {
            super.init(element, fxForm);
            Class wrappedType = element.getWrappedType();
            List<Field> fields = ReflectionUtils.listFields(wrappedType);
            for (Field field : fields) {
                TableColumn col = new TableColumn(field.getName());
                col.setCellValueFactory(new PropertyValueFactory(field.getName()));
                col.setCellFactory(list -> new TextFieldTableCell(new DefaultStringConverter()));

                tableView.getColumns().add(col);

            }

            addButton.setOnAction(event -> {
                try {
                    tableView.getItems().add(element.getWrappedType().newInstance());
                    tableView.edit(tableView.getItems().size() - 1, (TableColumn) tableView.getColumns().get(0));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });

            removeButton.setOnAction(event -> {
                tableView.getItems().removeAll(tableView.getSelectionModel().getSelectedItems());
            });
        }
    };
}
 
Example 4
Source Project: MyBox   Source File: TableAutoCommitCell.java    License: Apache License 2.0 4 votes vote down vote up
public static <S> Callback<TableColumn<S, String>, TableCell<S, String>> forTableColumn() {
    return forTableColumn(new DefaultStringConverter());
}
 
Example 5
Source Project: phoebus   Source File: PVTable.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public PVNameTableCell()
{
    super(new DefaultStringConverter());
}
 
Example 6
Source Project: phoebus   Source File: PVTable.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public AlarmTableCell()
{
    super(new DefaultStringConverter());
}
 
Example 7
Source Project: phoebus   Source File: ScansTable.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public TextCopyCell()
{
    super(new DefaultStringConverter());
}
 
Example 8
public static <S> Callback<TableColumn<S, String>, TableCell<S, String>> forTableColumn() {
	return forTableColumn(new DefaultStringConverter());
}
 
Example 9
@Override
 public TableCell<Person, String> call(TableColumn<Person, String> param) {

     return new ComboBoxTableCell<Person, String>(new DefaultStringConverter()) {      
     	
     	{
         	ContextMenu cm = new ContextMenu();
         	MenuItem deletePersonsMenuItem = new MenuItem("Delete");
         	deletePersonsMenuItem.setOnAction( PersonTypeCellFactory.this.deletePersonsHandler );
         	cm.getItems().add(deletePersonsMenuItem);
         	this.setContextMenu(cm);    
         	
         	this.getItems().addAll( "Friend", "Co-worker", "Other" );
         	
         	this.setEditable(true);
     	}
     	
         @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 10
Source Project: examples-javafx-repos1   Source File: PersonsCellFactory.java    License: 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 11
Source Project: ARMStrong   Source File: TextFieldTableCellFixed.java    License: Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Provides a {@link TextField} that allows editing of the cell content when
 * the cell is double-clicked, or when
 * {@link TableView#edit(int, javafx.scene.control.TableColumn)} is called.
 * This method will only  work on {@link TableColumn} instances which are of
 * type String.
 *
 * @param <S> The type of the TableView generic type
 * @return A {@link Callback} that can be inserted into the
 *      {@link TableColumn#cellFactoryProperty() cell factory property} of a
 *      TableColumn, that enables textual editing of the content.
 */
public static <S> Callback<TableColumn<S,String>, TableCell<S,String>> forTableColumn() {
    return forTableColumn(new DefaultStringConverter());
}
 
Example 12
Source Project: AsciidocFX   Source File: TextFieldTableCell.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Provides a {@link TextField} that allows editing of the cell content when
 * the cell is double-clicked, or when
 * {@link TableView#edit(int, javafx.scene.control.TableColumn)} is called.
 * This method will only  work on {@link TableColumn} instances which are of
 * type String.
 *
 * @return A {@link Callback} that can be inserted into the
 * {@link TableColumn#cellFactoryProperty() cell factory property} of a
 * TableColumn, that enables textual editing of the content.
 */
public static <S> Callback<TableColumn<S, String>, TableCell<S, String>> forTableColumn() {
    return forTableColumn(new DefaultStringConverter());
}