javafx.util.converter.DefaultStringConverter Java Examples

The following examples show how to use javafx.util.converter.DefaultStringConverter. 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: PACETableCell.java    From phoebus with 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 File: PacketTableView.java    From trex-stateless-gui with 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 File: TableFactory.java    From AsciidocFX with 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 File: TableAutoCommitCell.java    From MyBox with 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 File: PVTable.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
public PVNameTableCell()
{
    super(new DefaultStringConverter());
}
 
Example #6
Source File: PVTable.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
public AlarmTableCell()
{
    super(new DefaultStringConverter());
}
 
Example #7
Source File: ScansTable.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
public TextCopyCell()
{
    super(new DefaultStringConverter());
}
 
Example #8
Source File: OptionsDialog.java    From DeskChan with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static <S> Callback<TableColumn<S, String>, TableCell<S, String>> forTableColumn() {
	return forTableColumn(new DefaultStringConverter());
}
 
Example #9
Source File: PersonTypeCellFactory.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 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 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 #11
Source File: TextFieldTableCellFixed.java    From ARMStrong with 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 File: TextFieldTableCell.java    From AsciidocFX with 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());
}