Search in sources :

Example 21 with Callback

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();
}
Also used : JavaFXBuilderFactory(javafx.fxml.JavaFXBuilderFactory) FXMLSaxHandler(com.kyj.fx.voeditor.visual.framework.parser.FXMLSaxHandler) FXMLSaxHandler(com.kyj.fx.voeditor.visual.framework.parser.FXMLSaxHandler) Scene(javafx.scene.Scene) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JavaFXBuilderFactory(javafx.fxml.JavaFXBuilderFactory) SAXParserFactory(javax.xml.parsers.SAXParserFactory) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) FileInputStream(java.io.FileInputStream) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) Application(javafx.application.Application) Matcher(java.util.regex.Matcher) ByteArrayInputStream(java.io.ByteArrayInputStream) Stage(javafx.stage.Stage) FXMLLoader(javafx.fxml.FXMLLoader) SAXParser(javax.xml.parsers.SAXParser) Pattern(java.util.regex.Pattern) BorderPane(javafx.scene.layout.BorderPane) BuilderFactory(javafx.util.BuilderFactory) Callback(javafx.util.Callback) Builder(javafx.util.Builder) InputStream(java.io.InputStream) BorderPane(javafx.scene.layout.BorderPane) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Builder(javafx.util.Builder) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) JavaFXBuilderFactory(javafx.fxml.JavaFXBuilderFactory) BuilderFactory(javafx.util.BuilderFactory) FileInputStream(java.io.FileInputStream) FileNotFoundException(java.io.FileNotFoundException) ByteArrayInputStream(java.io.ByteArrayInputStream) SAXParser(javax.xml.parsers.SAXParser) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Example 22 with Callback

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);
}
Also used : ObjectProperty(javafx.beans.property.ObjectProperty) Callback(javafx.util.Callback) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) TableCell(javafx.scene.control.TableCell) ComboBoxTableCell(javafx.scene.control.cell.ComboBoxTableCell) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) Method(java.lang.reflect.Method) StringConverter(javafx.util.StringConverter) ComboBoxTableCell(javafx.scene.control.cell.ComboBoxTableCell)

Example 23 with Callback

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);
            }
        }
    };
}
Also used : Button(javafx.scene.control.Button) KeyBindingRepository(org.jabref.gui.keyboard.KeyBindingRepository) HBox(javafx.scene.layout.HBox) Label(javafx.scene.control.Label) ListView(javafx.scene.control.ListView) ListCell(javafx.scene.control.ListCell) AbstractController(org.jabref.gui.AbstractController) Node(javafx.scene.Node) DialogService(org.jabref.gui.DialogService) IconTheme(org.jabref.gui.IconTheme) KeyEvent(javafx.scene.input.KeyEvent) VBox(javafx.scene.layout.VBox) Inject(javax.inject.Inject) FXML(javafx.fxml.FXML) SelectionMode(javafx.scene.control.SelectionMode) ListChangeListener(javafx.collections.ListChangeListener) ClipBoardManager(org.jabref.gui.ClipBoardManager) ObservableList(javafx.collections.ObservableList) Callback(javafx.util.Callback) ContentDisplay(javafx.scene.control.ContentDisplay) KeyBinding(org.jabref.gui.keyboard.KeyBinding) BuildInfo(org.jabref.logic.util.BuildInfo) HBox(javafx.scene.layout.HBox) ListCell(javafx.scene.control.ListCell) Node(javafx.scene.Node) Label(javafx.scene.control.Label) VBox(javafx.scene.layout.VBox)

Example 24 with Callback

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);
}
Also used : JFXDatePicker(com.jfoenix.controls.JFXDatePicker) JFXPopup(com.jfoenix.controls.JFXPopup) Callback(javafx.util.Callback) Insets(javafx.geometry.Insets) Label(javafx.scene.control.Label) DatePicker(javafx.scene.control.DatePicker) JFXDatePicker(com.jfoenix.controls.JFXDatePicker) RadioButton(javafx.scene.control.RadioButton) JFXRadioButton(com.jfoenix.controls.JFXRadioButton) DateCell(javafx.scene.control.DateCell) LocalDate(java.time.LocalDate) VBox(javafx.scene.layout.VBox)

Example 25 with Callback

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);
}
Also used : Button(javafx.scene.control.Button) TempCustomerPassingData(CustomerGuiHelpers.TempCustomerPassingData) Initializable(javafx.fxml.Initializable) ListView(javafx.scene.control.ListView) URL(java.net.URL) ListCell(javafx.scene.control.ListCell) MouseEvent(javafx.scene.input.MouseEvent) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) IConfiramtionDialog(UtilsContracts.IConfiramtionDialog) ICustomer(CustomerContracts.ICustomer) Logger(org.apache.log4j.Logger) CatalogProduct(BasicCommonClasses.CatalogProduct) ResourceBundle(java.util.ResourceBundle) BarcodeEventHandler(UtilsImplementations.BarcodeEventHandler) Subscribe(com.google.common.eventbus.Subscribe) Callback(javafx.util.Callback) CustomerProductCellFormat(CustomerGuiHelpers.CustomerProductCellFormat) GridPane(javafx.scene.layout.GridPane) CartProduct(BasicCommonClasses.CartProduct) Label(javafx.scene.control.Label) MalformedURLException(java.net.MalformedURLException) SmartCode(BasicCommonClasses.SmartCode) StackTraceUtil(UtilsImplementations.StackTraceUtil) JFXListView(com.jfoenix.controls.JFXListView) FilteredList(javafx.collections.transformation.FilteredList) SMException(SMExceptions.SMException) DialogMessagesService(GuiUtils.DialogMessagesService) File(java.io.File) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) InjectionFactory(UtilsImplementations.InjectionFactory) ActionEvent(javafx.event.ActionEvent) IBarcodeEventHandler(UtilsContracts.IBarcodeEventHandler) Stage(javafx.stage.Stage) ImageView(javafx.scene.image.ImageView) LocalDate(java.time.LocalDate) SmartcodeScanEvent(UtilsContracts.SmartcodeScanEvent) ObservableValue(javafx.beans.value.ObservableValue) ObservableList(javafx.collections.ObservableList) AbstractApplicationScreen(GuiUtils.AbstractApplicationScreen) ChangeListener(javafx.beans.value.ChangeListener) Image(javafx.scene.image.Image) JFXTextField(com.jfoenix.controls.JFXTextField) ListView(javafx.scene.control.ListView) JFXListView(com.jfoenix.controls.JFXListView) ListCell(javafx.scene.control.ListCell) CartProduct(BasicCommonClasses.CartProduct) CustomerProductCellFormat(CustomerGuiHelpers.CustomerProductCellFormat)

Aggregations

Callback (javafx.util.Callback)43 Inject (javax.inject.Inject)27 FxmlView (io.bitsquare.gui.common.view.FxmlView)26 javafx.scene.control (javafx.scene.control)25 Popup (io.bitsquare.gui.main.overlays.popups.Popup)24 ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)23 ObservableList (javafx.collections.ObservableList)22 FXML (javafx.fxml.FXML)22 VBox (javafx.scene.layout.VBox)21 HyperlinkWithIcon (io.bitsquare.gui.components.HyperlinkWithIcon)20 BSFormatter (io.bitsquare.gui.util.BSFormatter)20 SortedList (javafx.collections.transformation.SortedList)19 ImageView (javafx.scene.image.ImageView)18 ChangeListener (javafx.beans.value.ChangeListener)17 GUIUtil (io.bitsquare.gui.util.GUIUtil)16 FXCollections (javafx.collections.FXCollections)16 Insets (javafx.geometry.Insets)15 AwesomeIcon (de.jensd.fx.fontawesome.AwesomeIcon)13 UserThread (io.bitsquare.common.UserThread)13 ActivatableView (io.bitsquare.gui.common.view.ActivatableView)13