javafx.scene.control.TableRow#getItem ( )源码实例Demo

下面列出了javafx.scene.control.TableRow#getItem ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: phoebus   文件: SampleView.java
@Override
protected void updateItem(final String item, final boolean empty)
{
    super.updateItem(item, empty);
    final TableRow<PlotSample> row = getTableRow();
    if (empty  ||  row == null  ||  row.getItem() == null)
        setText("");
    else
    {
        setText(item);
        setTextFill(SeverityColors.getTextColor(org.phoebus.core.vtypes.VTypeHelper.getSeverity(row.getItem().getVType())));
    }
}
 
源代码2 项目: phoebus   文件: JobViewer.java
@Override
protected void updateItem(final Boolean ignored, final boolean empty)
{
    super.updateItem(ignored, empty);

    boolean running = ! empty;

    TableRow<JobInfo> row = null;
    if (running)
    {
        row = getTableRow();
        if (row == null)
            running = false;
    }

    if (running)
    {
        setAlignment(Pos.CENTER_RIGHT);
        final JobInfo info = row.getItem();
        final Button cancel = new Button(Messages.JobCancel, new ImageView(ABORT));
        cancel.setOnAction(event -> info.job.cancel());
        cancel.setMaxWidth(Double.MAX_VALUE);
        setGraphic(cancel);
    }
    else
        setGraphic(null);
}
 
源代码3 项目: logbook-kai   文件: AirBaseController.java
@Override
protected void updateItem(Integer itemId, boolean empty) {
    super.updateItem(itemId, empty);

    this.getStyleClass().removeAll("change");

    if (!empty) {
        Map<Integer, SlotItem> itemMap = SlotItemCollection.get()
                .getSlotitemMap();

        SlotItem item = itemMap.get(itemId);

        if (item != null) {
            this.setGraphic(new ImageView(Items.itemImage(item)));
            this.setText(Items.name(item));
        } else {
            this.setGraphic(null);
            this.setText("未配備");
        }

        @SuppressWarnings("unchecked")
        TableRow<Plane> row = this.getTableRow();
        if (row != null) {
            Plane plane = row.getItem();
            if (plane != null && plane.getPlaneInfo() != null) {
                PlaneInfo planeInfo = plane.getPlaneInfo();
                if (planeInfo.getState() != 1) {
                    this.getStyleClass().add("change");
                }
            }
        }
    } else {
        this.setGraphic(null);
        this.setText(null);
    }
}
 
源代码4 项目: logbook-kai   文件: AirBaseController.java
@Override
protected void updateItem(Integer count, boolean empty) {
    super.updateItem(count, empty);

    this.getStyleClass().removeAll("lowsupply");

    if (!empty) {
        if (count != null) {
            @SuppressWarnings("unchecked")
            TableRow<Plane> row = this.getTableRow();
            if (row != null) {
                Plane plane = row.getItem();
                if (plane != null && plane.getPlaneInfo() != null) {
                    PlaneInfo planeInfo = plane.getPlaneInfo();
                    if (planeInfo.getCount() != null && !planeInfo.getCount().equals(planeInfo.getMaxCount())) {
                        this.getStyleClass().add("lowsupply");
                    }
                }
            }
            this.setText(String.valueOf(count));
        } else {
            this.setText(null);
        }
    } else {
        this.setText(null);
    }
}
 
@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());					
	}
}
     };
 }
 
@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());					
	}
}
     };
 }
 
 同类方法