use of javafx.util.Callback in project Gargoyle by callakrsos.
the class FXMLPreviewLoader method start.
/**
* @inheritDoc
*/
@Override
public void start(Stage primaryStage) throws Exception {
BorderPane borderPane = new BorderPane();
FXMLLoader loader = new FXMLLoader() {
};
// InputStream resourceAsStream =
// FXMLPreviewLoader.class.getResourceAsStream("lang_ko.properties");
//
// loader.setResources(new PropertyResourceBundle(new
// InputStreamReader(resourceAsStream, "UTF-8")) {
// /*
// * @inheritDoc
// */
// @Override
// public boolean containsKey(String key) {
// return true;
// }
//
// /*
// * @inheritDoc
// */
// @Override
// public Object handleGetObject(String key) {
// if (key == null) {
// return "";
// }
//
// Object result = null;
//
// try {
// result = super.handleGetObject(key);
// } catch (Exception e) {
// ;
// }
//
// return (result == null) ? key : result;
// }
// });
// loader.setLocation(/*FXMLPreviewLoader.class.getResource("ColumnExam3.fxml")*/url);
loader.setBuilderFactory(new BuilderFactory() {
@Override
public Builder<?> getBuilder(Class<?> param) {
return new JavaFXBuilderFactory().getBuilder(param);
}
});
loader.setControllerFactory(new Callback<Class<?>, Object>() {
@Override
public Object call(Class<?> param) {
return null;
}
});
FileInputStream inputStream = new FileInputStream(file);
InputStream is = null;
try {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
ByteArrayOutputStream out = new ByteArrayOutputStream();
FXMLSaxHandler handler = new FXMLSaxHandler(out);
sp.parse(inputStream, handler);
String string = out.toString("UTF-8");
string = ValueUtil.regexReplaceMatchs("<!\\[CDATA\\[[?<a-zA-Z. *?>]+]]>", string, str -> {
return ValueUtil.regexMatch("<\\?import [a-zA-Z.*?]+>", str);
});
System.out.println(string);
byte[] bytes = string.getBytes();
is = new ByteArrayInputStream(bytes);
} catch (Exception e) {
e.printStackTrace();
}
// FileInputStream inputStream = new FileInputStream(file);
borderPane.setCenter(loader.load(is));
Scene scene = new Scene(borderPane);
primaryStage.setScene(scene);
primaryStage.show();
}
use of javafx.util.Callback in project Gargoyle by callakrsos.
the class FxTableViewUtil method getValue.
/**
* 테이블컬럼의 row에 해당하는 데이터가 무엇인지 정의한 값을 리턴.
*
* StringConverter를 이용한 TableCell인경우 정의된 StringConvert를 이용한 데이터를 Excel의
* Cell에 쓰고, StringConverter를 이용하지않는 UI의 TableCell의 경우 데이터셋에 바인드된 값을 사용하게됨.
*
* 작성된 API내에서 적절한 값이 아니라고 판단되는경우 Ovrride해서 재정의하도록한다.
*
* @작성자 : KYJ
* @작성일 : 2016. 9. 9.
* @param table
* 사용자 화면에 정의된 tableView
* @param column
* 사용자 화면에 정의된 tableColumn
* @param columnIndex
* 사용자 화면에 정의된 tableColumn의 인덱스
* @param rowIndex
* 사용자 화면에 정의된 tableCell의 인덱스
* @return Object 테이블셀에 정의된 데이터를 리턴할 값으로, 리턴해주는 값이 엑셀에 write된다.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Object getValue(TableView<?> table, TableColumn<?, ?> column, int rowIndex) {
Callback cellFactory = column.getCellFactory();
if (cellFactory != null) {
TableCell cell = (TableCell) cellFactory.call(column);
if (cell != null) {
StringConverter converter = null;
if (cell instanceof TextFieldTableCell) {
TextFieldTableCell txtCell = (TextFieldTableCell) cell;
converter = txtCell.getConverter();
} else if (cell instanceof ComboBoxTableCell) {
ComboBoxTableCell txtCell = (ComboBoxTableCell) cell;
converter = txtCell.getConverter();
} else /* else 기본값. */
{
try {
Method m = cell.getClass().getMethod("converterProperty");
if (m != null) {
Object object = m.invoke(cell);
if (object != null && object instanceof ObjectProperty) {
ObjectProperty<StringConverter> convert = (ObjectProperty<StringConverter>) object;
converter = convert.get();
}
}
} catch (Exception e) {
// Nothing...
}
}
if (converter != null) {
Object cellData = column.getCellData(rowIndex);
return converter.toString(cellData);
}
}
}
return column.getCellData(rowIndex);
}
use of javafx.util.Callback in project jabref by JabRef.
the class ErrorConsoleController method createCellFactory.
private Callback<ListView<LogEventViewModel>, ListCell<LogEventViewModel>> createCellFactory() {
return cell -> new ListCell<LogEventViewModel>() {
private HBox graphic;
private Node icon;
private VBox message;
private Label heading;
private Label stacktrace;
{
graphic = new HBox(10);
heading = new Label();
stacktrace = new Label();
message = new VBox();
message.getChildren().setAll(heading, stacktrace);
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
}
@Override
public void updateItem(LogEventViewModel event, boolean empty) {
super.updateItem(event, empty);
if (event == null || empty) {
setGraphic(null);
} else {
icon = event.getIcon().getGraphicNode();
heading.setText(event.getDisplayText());
heading.getStyleClass().setAll(event.getStyleClass());
stacktrace.setText(event.getStackTrace().orElse(""));
graphic.getStyleClass().setAll(event.getStyleClass());
graphic.getChildren().setAll(icon, message);
setGraphic(graphic);
}
}
};
}
use of javafx.util.Callback in project SmartCity-Market by TechnionYP5777.
the class ManagePackagesTab method initialize.
@Override
public void initialize(URL location, ResourceBundle __) {
barcodeEventHandler.register(this);
barcodeTextField.textProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue.matches("\\d*"))
barcodeTextField.setText(newValue.replaceAll("[^\\d]", ""));
showScanCodePane(true);
resetParams();
searchCodeButton.setDisable(newValue.isEmpty());
});
editPackagesAmountSpinner.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL);
editPackagesAmountSpinner.valueProperty().addListener((obs, oldValue, newValue) -> {
if (newValue == null || newValue < 1)
editPackagesAmountSpinner.getValueFactory().setValue(oldValue);
enableRunTheOperationButton();
});
editPackagesAmountSpinner.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null && !newValue) {
editPackagesAmountSpinner.increment(0);
enableRunTheOperationButton();
}
});
final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() {
@Override
public DateCell call(final DatePicker __) {
return new DateCell() {
@Override
public void updateItem(LocalDate item, boolean empty) {
super.updateItem(item, empty);
if (!item.isBefore(LocalDate.now()))
return;
setDisable(true);
setStyle("-fx-background-color: #EEEEEE;");
}
};
}
};
datePicker.setDayCellFactory(dayCellFactory);
datePicker.setValue(LocalDate.now());
VBox vbox = new VBox();
vbox.setPadding(new Insets(10, 50, 50, 50));
vbox.setSpacing(10);
datePickerForSmartCode = new JFXDatePicker();
Label lbl = new Label("Choose Date");
vbox.getChildren().addAll(lbl, datePickerForSmartCode);
JFXPopup popup = new JFXPopup(vbox);
showDatePickerBtn.setOnMouseClicked(e -> popup.show(showDatePickerBtn, PopupVPosition.TOP, PopupHPosition.LEFT));
radioButtonContainerSmarcodeOperations.addRadioButtons(Arrays.asList(new RadioButton[] { printSmartCodeRadioButton, addPackageToStoreRadioButton, removePackageFromStoreRadioButton, removePackageFromWarhouseRadioButton }));
radioButtonContainerBarcodeOperations.addRadioButtons(Arrays.asList(new RadioButton[] { addPakageToWarhouseRadioButton }));
resetParams();
showScanCodePane(true);
}
use of javafx.util.Callback in project SmartCity-Market by TechnionYP5777.
the class CustomerMainScreen method initialize.
@Override
public void initialize(URL location, ResourceBundle __) {
AbstractApplicationScreen.fadeTransition(customerMainScreenPane);
barcodeEventHandler.register(this);
customer = TempCustomerPassingData.customer;
filteredProductList = new FilteredList<>(productsObservableList, s -> true);
searchField.textProperty().addListener(obs -> {
String filter = searchField.getText();
filteredProductList.setPredicate((filter == null || filter.length() == 0) ? s -> true : s -> s.getCatalogProduct().getName().contains(filter));
});
productsListView.setItems(filteredProductList);
productsListView.setCellFactory(new Callback<ListView<CartProduct>, ListCell<CartProduct>>() {
@Override
public ListCell<CartProduct> call(ListView<CartProduct> __) {
return new CustomerProductCellFormat();
}
});
productsListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<CartProduct>() {
@Override
public void changed(ObservableValue<? extends CartProduct> __, CartProduct oldValue, CartProduct newValue) {
updateProductInfoPaine(newValue.getCatalogProduct(), newValue.getTotalAmount(), ProductInfoPaneVisibleMode.PRESSED_PRODUCT);
}
});
productsListView.depthProperty().set(1);
productsListView.setExpanded(true);
setAbilityAndVisibilityOfProductInfoPane(false);
}
Aggregations