use of javafx.beans.value.ObservableValue in project dwoss by gg-net.
the class ShipmentUpdateStage method init.
private void init(Shipment s) {
okButton.setOnAction((ActionEvent event) -> {
shipment = getShipment();
if (isValid())
close();
});
cancelButton.setOnAction((ActionEvent event) -> {
close();
});
idField = new TextField(Long.toString(s.getId()));
idField.setDisable(true);
shipIdField = new TextField(s.getShipmentId());
Callback<ListView<TradeName>, ListCell<TradeName>> cb = new Callback<ListView<TradeName>, ListCell<TradeName>>() {
@Override
public ListCell<TradeName> call(ListView<TradeName> param) {
return new ListCell<TradeName>() {
@Override
protected void updateItem(TradeName item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty)
setText("Hersteller wählen...");
else
setText(item.getName());
}
};
}
};
Set<TradeName> contractors = Dl.local().lookup(CachedMandators.class).loadContractors().all();
ownerBox = new ComboBox<>(FXCollections.observableArrayList(contractors));
ownerBox.setMaxWidth(MAX_VALUE);
ownerBox.setCellFactory(cb);
ownerBox.getSelectionModel().selectedItemProperty().addListener((ObservableValue<? extends TradeName> observable, TradeName oldValue, TradeName newValue) -> {
if (newValue == null)
return;
shipment.setContractor(newValue);
manufacturerBox.getSelectionModel().select(newValue.getManufacturer());
});
ObservableList<TradeName> manufacturers = FXCollections.observableArrayList(TradeName.getManufacturers());
manufacturerBox = new ComboBox<>(manufacturers);
manufacturerBox.setMaxWidth(MAX_VALUE);
manufacturerBox.setCellFactory(cb);
SingleSelectionModel<TradeName> sm = ownerBox.getSelectionModel();
if (s.getContractor() == null)
sm.selectFirst();
else
sm.select(s.getContractor());
if (shipment.getDefaultManufacturer() != null)
manufacturerBox.getSelectionModel().select(shipment.getDefaultManufacturer());
statusBox = new ComboBox<>(FXCollections.observableArrayList(Shipment.Status.values()));
statusBox.setMaxWidth(MAX_VALUE);
statusBox.getSelectionModel().select(s.getStatus() == null ? OPENED : s.getStatus());
GridPane grid = new GridPane();
grid.addRow(1, new Label("ID:"), idField);
grid.addRow(2, new Label("Shipment ID:"), shipIdField);
grid.addRow(3, new Label("Besitzer:"), ownerBox);
grid.addRow(4, new Label("Hersteller:"), manufacturerBox);
grid.addRow(5, new Label("Status"), statusBox);
grid.setMaxWidth(MAX_VALUE);
grid.vgapProperty().set(2.);
grid.getColumnConstraints().add(0, new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.SOMETIMES, HPos.LEFT, false));
grid.getColumnConstraints().add(1, new ColumnConstraints(100, 150, Double.MAX_VALUE, Priority.ALWAYS, HPos.LEFT, true));
HBox hButtonBox = new HBox(okButton, cancelButton);
hButtonBox.alignmentProperty().set(Pos.TOP_RIGHT);
errorLabel.setWrapText(true);
BorderPane rootPane = new BorderPane(grid, errorLabel, null, hButtonBox, null);
this.setTitle(s.getId() > 0 ? "Shipment bearbeiten" : "Shipment anlegen");
this.setScene(new Scene(rootPane));
this.setResizable(false);
}
use of javafx.beans.value.ObservableValue in project dwoss by gg-net.
the class TreeTableController method initialize.
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
TreeItem<DataWrapper> root = new TreeItem<>(new DataWrapper() {
@Override
public String getName() {
return "Root";
}
});
view.setRoot(root);
root.setExpanded(true);
view.setShowRoot(false);
root.getChildren().addAll(getTradeNames());
overview.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<DataWrapper, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<DataWrapper, String> param) {
return new ReadOnlyStringWrapper(param.getValue().getValue().getName());
}
});
amount.setCellValueFactory(new Callback<CellDataFeatures<DataWrapper, Integer>, ObservableValue<Integer>>() {
@Override
public ObservableValue<Integer> call(CellDataFeatures<DataWrapper, Integer> param) {
DataWrapper dw = param.getValue().getValue();
SimpleObjectProperty<Integer> result;
if (dw instanceof ProductGroupWrapper) {
result = new SimpleObjectProperty<>(amountOfCategoryProducts(((ProductGroupWrapper) dw).getTradeName(), ((ProductGroupWrapper) dw).getProductGroup()));
return result;
}
if (dw instanceof CategoryProductWrapper) {
result = new SimpleObjectProperty<>(amountOfProducts(((CategoryProductWrapper) dw).getCategoryProductId()));
return result;
}
if (dw instanceof ProductWrapper) {
result = new SimpleObjectProperty<>(amountOfUnitCollections(((ProductWrapper) dw).getProductId()));
return result;
}
if (dw instanceof UnitCollectionWrapper) {
result = new SimpleObjectProperty<>(amountOfUnits(((UnitCollectionWrapper) dw).getUnitCollectionId()));
return result;
}
result = new SimpleObjectProperty<>(0);
return result;
}
});
}
use of javafx.beans.value.ObservableValue in project azure-tools-for-java by Microsoft.
the class JobViewFxUtil method startFx.
public static Object startFx(Object composite, final String webUrl, Object jobUtils) {
try {
Class compositeClass = Class.forName("org.eclipse.swt.widgets.Composite");
Class[] paramTypes = { compositeClass, int.class };
Constructor con = FXCanvas.class.getConstructor(paramTypes);
Object[] parames = { composite, 1 << 16 };
final FXCanvas canvas = (FXCanvas) con.newInstance(parames);
Platform.setImplicitExit(false);
Platform.runLater(new Runnable() {
@Override
public void run() {
final WebView webView = new WebView();
Scene scene = new Scene(webView);
canvas.setScene(scene);
WebEngine webEngine = webView.getEngine();
webEngine.load(webUrl);
webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() {
@Override
public void changed(ObservableValue<? extends Worker.State> ov, Worker.State oldState, Worker.State newState) {
if (newState == Worker.State.SUCCEEDED) {
JSObject win = (JSObject) webEngine.executeScript("window");
win.setMember("JobUtils", new JobUtilsForEclipse());
}
}
});
}
});
return canvas;
} catch (Exception e) {
return e;
}
}
use of javafx.beans.value.ObservableValue in project trex-stateless-gui by cisco-system-traffic-generator.
the class ImportedPacketTableView method initTableRowsColumns.
/**
* Initialize table rows and columns
*/
private void initTableRowsColumns() {
selectedColumn.setCellValueFactory(new PropertyValueFactory<>("selected"));
selectedColumn.setCellFactory(CheckBoxTableCell.forTableColumn(selectedColumn));
selectAll = new CheckBox();
selectAll.getStyleClass().add("selectAll");
selectAll.setSelected(true);
selectAll.selectedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
selectAllRows();
});
selectedColumn.setGraphic(selectAll);
nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
nameColumn.setCellFactory(new TextFieldTableViewCell());
packetNumColumn.setCellValueFactory(new PropertyValueFactory<>("index"));
lengthColumn.setCellValueFactory(new PropertyValueFactory<>("length"));
macSrcColumn.setCellValueFactory(new PropertyValueFactory<>("macSrc"));
macDstColumn.setCellValueFactory(new PropertyValueFactory<>("macDst"));
ipSrcColumn.setCellValueFactory(new PropertyValueFactory<>("ipSrc"));
ipDstColumn.setCellValueFactory(new PropertyValueFactory<>("ipDst"));
packetTypeColumn.setCellValueFactory(new PropertyValueFactory<>("packetType"));
importedStreamTable.setRowFactory(highlightedRowFactory);
}
use of javafx.beans.value.ObservableValue in project trex-stateless-gui by cisco-system-traffic-generator.
the class CheckBoxTableViewCell method call.
/**
* @param p
* @return
*/
@Override
public TableCell call(TableColumn p) {
return new TableCell<Object, Boolean>() {
private final CheckBox checkBox;
{
checkBox = new CheckBox();
checkBox.selectedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
if (checkboxChangeHandler != null) {
checkboxChangeHandler.stateChanged(getTableRow().getIndex(), newValue);
}
});
this.setGraphic(checkBox);
this.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
this.setEditable(true);
}
@Override
public void updateItem(Boolean item, boolean empty) {
super.updateItem(item, empty);
if (!empty) {
checkBox.setSelected(item);
setGraphic(checkBox);
} else {
this.setGraphic(null);
}
}
};
}
Aggregations