Example usage for javafx.util Callback Callback

List of usage examples for javafx.util Callback Callback

Introduction

In this page you can find the example usage for javafx.util Callback Callback.

Prototype

Callback

Source Link

Usage

From source file:retsys.client.controller.UserController.java

/**
 * Initializes the controller class./*  ww w . j a  v  a  2 s.  c  om*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
    AutoCompletionBinding<User> txt_name = TextFields.bindAutoCompletion(name,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<User>>() {

                @Override
                public Collection<User> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<User> list = null;
                    HttpHelper helper = new HttpHelper();
                    try {
                        LovHandler lovHandler = new LovHandler("users", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<User>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<User>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(UserController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }

            }, new StringConverter<User>() {

                @Override
                public String toString(User object) {
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public User fromString(String string) {
                    throw new UnsupportedOperationException("Not supported yet.");
                }
            });

    //event handler for setting other Client fields with values from selected Client object
    //fires after autocompletion
    txt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<User>>() {

        @Override
        public void handle(AutoCompletionBinding.AutoCompletionEvent<User> event) {
            User user = event.getCompletion();
            //fill other item related fields
            id.setText(splitId(name.getText()) + "");
            name.setText(user.getName());
            password.setText(user.getPassword());
            if ("N".equals(user.getUsertype()))
                usertype.getSelectionModel().select(1);
            else if ("A".equals(user.getUsertype()))
                usertype.getSelectionModel().select(2);
            else
                usertype.getSelectionModel().clearSelection();
            populateAuditValues(user);
        }
    });
}

From source file:retsys.client.controller.ProductController.java

/**
 * Initializes the controller class./*  w ww.  j  a  va2s  . c o m*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {

    AutoCompletionBinding<Product> txt_name = TextFields.bindAutoCompletion(name,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Product>>() {

                @Override
                public Collection<Product> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Product> list = null;
                    HttpHelper helper = new HttpHelper();
                    try {
                        LovHandler lovHandler = new LovHandler("products", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Product>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Product>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProductController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }

            }, new StringConverter<Product>() {

                @Override
                public String toString(Product object) {
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Product fromString(String string) {
                    throw new UnsupportedOperationException("Not supported yet.");
                }
            });

    //event handler for setting other Client fields with values from selected Client object
    //fires after autocompletion
    txt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Product>>() {

        @Override
        public void handle(AutoCompletionBinding.AutoCompletionEvent<Product> event) {
            Product product = event.getCompletion();
            //fill other item related fields
            id.setText(String.valueOf(product.getId()));
            name.setText(product.getName());
            productDesc.setText(product.getProdDesc());
            remarks.setText(product.getRemarks());
            //desc.setText(product.getDesc());

            populateAuditValues(product);
        }
    });
}

From source file:retsys.client.controller.VendorController.java

/**
 * Initializes the controller class./*from  w  w  w .  j  av  a2s  . com*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {

    AutoCompletionBinding<Vendor> txt_name = TextFields.bindAutoCompletion(name,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Vendor>>() {

                @Override
                public Collection<Vendor> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Vendor> list = null;
                    HttpHelper helper = new HttpHelper();
                    try {
                        LovHandler lovHandler = new LovHandler("vendors", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Vendor>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Vendor>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(VendorController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }

            }, new StringConverter<Vendor>() {

                @Override
                public String toString(Vendor object) {
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Vendor fromString(String string) {
                    throw new UnsupportedOperationException("Not supported yet.");
                }
            });

    //event handler for setting other Client fields with values from selected Client object
    //fires after autocompletion
    txt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Vendor>>() {

        @Override
        public void handle(AutoCompletionBinding.AutoCompletionEvent<Vendor> event) {
            Vendor vendor = event.getCompletion();
            //fill other item related fields
            id.setText(splitId(name.getText()) + "");
            name.setText(vendor.getName());
            address.setText(vendor.getAddress());
            phone.setText(vendor.getPhone());
            mobile.setText(vendor.getMobile());
            remarks.setText(vendor.getRemarks());
            email.setText(vendor.getEmail());

            populateAuditValues(vendor);
        }
    });
}

From source file:retsys.client.controller.INVENTORY_REPORTController.java

/**
 * Initializes the controller class./*from ww  w  .  j  a  va2s.  c  o m*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {

    AutoCompletionBinding<Project> txt_name = TextFields.bindAutoCompletion(name,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Project>>() {

                @Override
                public Collection<Project> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Project> list = null;
                    HttpHelper helper = new HttpHelper();
                    try {
                        LovHandler lovHandler = new LovHandler("projects", "PROJECT");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Project>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Project>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }

            }, new StringConverter<Project>() {

                @Override
                public String toString(Project object) {
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Project fromString(String string) {
                    throw new UnsupportedOperationException("Not supported yet.");
                }
            });

    //event handler for setting other Client fields with values from selected Client object
    //fires after autocompletion
    txt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Project>>() {

        @Override
        public void handle(AutoCompletionBinding.AutoCompletionEvent<Project> event) {
            Project project = event.getCompletion();
            //fill other item related fields

            PROJECT.setText(splitName(name.getText()));

            //populateAuditValues(client);
        }
    });
    // TODO
}

From source file:Main.java

private ListView<Person> createLeaderListView(ObservableList<Person> leaders) {
    final ListView<Person> leaderListView = new ListView<>(leaders);
    leaderListView.setPrefWidth(150);/*from   ww  w  . ja va 2 s .  com*/
    leaderListView.setMaxWidth(Double.MAX_VALUE);
    leaderListView.setPrefHeight(150);

    leaderListView.setCellFactory(new Callback<ListView<Person>, ListCell<Person>>() {
        @Override
        public ListCell<Person> call(ListView<Person> param) {
            Tooltip tooltip = new Tooltip();

            ListCell<Person> cell = new ListCell<Person>() {
                @Override
                public void updateItem(Person item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null) {
                        // leadLbl.setText(item.getAliasName());
                        setText(item.getFirstName() + " " + item.getLastName());
                        tooltip.setText(item.getAliasName());
                        setTooltip(tooltip);
                    }
                }
            };
            return cell;
        }
    });

    return leaderListView;
}

From source file:caillou.company.clonemanager.gui.customComponent.settings.SettingsController.java

@Override
public void initialize(URL location, ResourceBundle resources) {
    languageComboBoxId.setCellFactory(new Callback<ListView<Language>, ListCell<Language>>() {
        @Override//  ww  w. j  ava  2 s.c o  m
        public ListCell<Language> call(ListView<Language> language) {
            return new LanguageListCell();
        }
    });

    languageComboBoxId.setButtonCell(new LanguageListCell());

    Language frenchLanguage = new Language(Locale.FRENCH);
    Language englishLanguage = new Language(Locale.ENGLISH);
    ObservableList<Language> languages = FXCollections.observableArrayList();
    languages.add(englishLanguage);
    languages.add(frenchLanguage);
    languageComboBoxId.setItems(languages);

    Locale currentLocale = SpringFxmlLoader.getLocale();
    if (currentLocale.equals(Locale.FRENCH)) {
        languageComboBoxId.setValue(frenchLanguage);
    } else {
        languageComboBoxId.setValue(englishLanguage);
    }

    languageComboBoxId.valueProperty().addListener(new ChangeListener<Language>() {

        @Override
        public void changed(ObservableValue<? extends Language> observable, Language oldValue,
                Language newValue) {
            SpringFxmlLoader.changeLocale(newValue.getLocale());
        }
    });
}

From source file:retsys.client.controller.ClientController.java

/**
 * Initializes the controller class.//from w  w w  .ja va2s. co  m
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    //  TextFields.bindAutoCompletion(name, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Client>>() 
    AutoCompletionBinding<Client> txt_name = TextFields.bindAutoCompletion(name,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Client>>() {

                @Override
                public Collection<Client> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Client> list = null;
                    HttpHelper helper = new HttpHelper();
                    try {
                        LovHandler lovHandler = new LovHandler("clients", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Client>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Client>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ClientController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }

            }, new StringConverter<Client>() {

                @Override
                public String toString(Client object) {
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Client fromString(String string) {
                    throw new UnsupportedOperationException("Not supported yet.");
                }
            });

    //event handler for setting other Client fields with values from selected Client object
    //fires after autocompletion
    txt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Client>>() {

        @Override
        public void handle(AutoCompletionBinding.AutoCompletionEvent<Client> event) {
            Client client = event.getCompletion();
            //fill other item related fields
            id.setText(splitId(name.getText()) + "");
            name.setText(splitName(name.getText()));
            phone.setText(client.getPhone());
            address.setText(client.getAddress());
            mobile.setText(client.getMobile());
            remarks.setText(client.getRemarks());
            email.setText(client.getEmail());

            populateAuditValues(client);
        }
    });
}

From source file:retsys.client.controller.ProjectController.java

/**
 * Initializes the controller class./*from  ww  w.j a v  a 2  s  .  c  om*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {

    AutoCompletionBinding<Project> txt_name = TextFields.bindAutoCompletion(name,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Project>>() {

                @Override
                public Collection<Project> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Project> list = null;
                    HttpHelper helper = new HttpHelper();
                    try {
                        LovHandler lovHandler = new LovHandler("projects", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Project>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Project>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ItemController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }

            }, new StringConverter<Project>() {

                @Override
                public String toString(Project object) {
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Project fromString(String string) {
                    throw new UnsupportedOperationException("Not supported yet.");
                }
            });

    //event handler for setting other Client fields with values from selected Client object
    //fires after autocompletion
    txt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Project>>() {

        @Override
        public void handle(AutoCompletionBinding.AutoCompletionEvent<Project> event) {
            Project project = event.getCompletion();
            //fill other item related fields
            id.setText(splitId(name.getText()) + "");
            name.setText(project.getName());
            projectDesc.setText(project.getProjectDesc());
            remarks.setText(project.getRemarks());

            client.setText(project.getClient().getName() + " (ID:" + project.getClient().getId() + ")");

            populateAuditValues(project);

        }
    });

    TextFields.bindAutoCompletion(client,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Client>>() {

                @Override
                public Collection<Client> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Client> list = null;
                    HttpHelper helper = new HttpHelper();
                    try {
                        LovHandler lovHandler = new LovHandler("clients", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Client>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Client>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }
            }, new StringConverter<Client>() {

                @Override
                public String toString(Client object) {
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Client fromString(String string) {
                    throw new UnsupportedOperationException("Not supported yet.");
                }
            });
}

From source file:com.sunkur.springjavafxcontroller.screen.ScreensContoller.java

public void loadScreen(String fxml) {
    BaseScreenController oldScreenController = this.getCurrentController();
    try {/*from   www . jav  a 2s .  c  om*/

        Class controllerClass = FXMLUtils.getControllerClass(fxml);
        final BaseScreenController fxmlController = (BaseScreenController) applicationContext
                .getBean(controllerClass);

        if (this.screens.get(fxmlController.getScreenId()) == null) {
            FXMLLoader loader = new FXMLLoader(getClass().getResource(fxml));
            loader.setControllerFactory(new Callback<Class<?>, Object>() {
                @Override
                public Object call(Class<?> aClass) {
                    return fxmlController;
                }
            });
            Parent root = loader.load();
            fxmlController.setRoot(root);
            this.screens.put(fxmlController.getScreenId(), fxmlController);
        }

        this.currentScreenId = fxmlController.getScreenId();
        swapScreen(getCurrentController().getRoot());
        if (oldScreenController != null) {
            if (oldScreenController.getClass().isAnnotationPresent(ScreenScoped.class)) {
                this.screens.remove(oldScreenController.getScreenId());
                this.screenScope.remove(oldScreenController.getScreenId());
            }
        }

    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.pdfsam.ui.selection.multiple.PaceColumn.java

@Override
public Callback<TableColumn<SelectionTableRowData, String>, TableCell<SelectionTableRowData, String>> cellFactory() {
    return new Callback<TableColumn<SelectionTableRowData, String>, TableCell<SelectionTableRowData, String>>() {
        @Override/*from   w  ww.  ja  v a2 s .  c  o m*/
        public TableCell<SelectionTableRowData, String> call(TableColumn<SelectionTableRowData, String> param) {
            return new TooltippedTextFieldTableCell(DefaultI18nContext.getInstance().i18n(
                    "Double click to set the number of pages after which the task will switch to the next file"));
        }
    };
}