List of usage examples for javafx.util StringConverter StringConverter
StringConverter
From source file:Main.java
@Override public void start(Stage stage) { String pattern = "yyyy-MM-dd"; VBox vbox = new VBox(20); Scene scene = new Scene(vbox, 400, 400); stage.setScene(scene);/*from w w w .java2 s. c o m*/ DatePicker checkInDatePicker = new DatePicker(); StringConverter<LocalDate> converter = new StringConverter<LocalDate>() { DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(pattern); @Override public String toString(LocalDate date) { if (date != null) { return dateFormatter.format(date); } else { return ""; } } @Override public LocalDate fromString(String string) { if (string != null && !string.isEmpty()) { return LocalDate.parse(string, dateFormatter); } else { return null; } } }; checkInDatePicker.setConverter(converter); checkInDatePicker.setPromptText(pattern.toLowerCase()); vbox.getChildren().add(checkInDatePicker); checkInDatePicker.requestFocus(); stage.show(); }
From source file:Main.java
public static void setupXAxis(NumberAxis numberAxis, long min, long max) { numberAxis.setAutoRanging(false);/*from w ww.j av a 2s . co m*/ numberAxis.setTickUnit((max - min) / 20); numberAxis.setLowerBound(min); numberAxis.setUpperBound(max); numberAxis.setTickLabelFormatter(new StringConverter<Number>() { private final SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy\nHH:mm:ss,SSS"); @Override public String toString(Number object) { return format.format(new Date(object.longValue())); } @Override public Number fromString(String string) { return null; } }); }
From source file:retsys.client.controller.UserController.java
/** * Initializes the controller class./*from w w w . j a va 2 s . c o m*/ */ @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.VendorController.java
/** * Initializes the controller class./*from w w w. java2s . c o m*/ */ @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.ProductController.java
/** * Initializes the controller class.// w w w . j a va2s. c om */ @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.INVENTORY_REPORTController.java
/** * Initializes the controller class./* w w w. java2s . 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:retsys.client.controller.ClientController.java
/** * Initializes the controller class./* w w w . j a v a2 s . 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:de.serverfrog.pw.ui.MainViewController.java
/** * Initializes the controller class.//from w w w . j a v a 2 s .com * * @param url url * @param rb rb */ @Override public void initialize(URL url, ResourceBundle rb) { websiteTypeComboBox.setItems(new ImmutableObservableList<>(WebsiteType.values())); websiteTypeComboBox.setValue(WebsiteType.values()[0]); websiteTypeComboBox.setConverter(new StringConverter<WebsiteType>() { @Override public String toString(WebsiteType object) { return object.getName(); } @Override public WebsiteType fromString(String string) { return WebsiteType.getByName(string); } }); }
From source file:acmi.l2.clientmod.bytecode_editor.calc.CalcController.java
@Override public void initialize(URL location, ResourceBundle resources) { BooleanBinding disable = unrealPackageProperty().isNull(); bytes.disableProperty().bind(disable); tokens.disableProperty().bind(disable); bytes.textProperty().bindBidirectional(tokens.textProperty(), new StringConverter<String>() { @Override/*from w ww .ja v a2 s. co m*/ public String fromString(String string) { string = string.replaceAll("\\s", ""); if (string.length() % 2 == 1) return ""; try { BytecodeContext context = new BytecodeContext(getUnrealPackage()); ObjectInputStream<BytecodeContext> ois = new ObjectInputStream<>( new ByteArrayInputStream(DatatypeConverter.parseHexBinary(string)), getUnrealPackage().getFile().getCharset(), tokenSerializer, context); Token token = ois.readObject(Token.class); size.setText(String.valueOf(token.getSize(context))); return token.toString(); } catch (UncheckedIOException ignore) { } catch (IllegalArgumentException e) { return e.getMessage(); } return ""; } @Override public String toString(String object) { try { Token token = (Token) shell.evaluate("def methodMissing(String name, args) {\n" + "Class.forName(\"acmi.l2.clientmod.unreal.bytecode.token.$name\").newInstance(args)\n" + "}\n" + object); ByteArrayOutputStream baos = new ByteArrayOutputStream(); BytecodeContext context = new BytecodeContext(getUnrealPackage()); size.setText(String.valueOf(token.getSize(context))); ObjectOutputStream<BytecodeContext> oos = new ObjectOutputStream<>(baos, getUnrealPackage().getFile().getCharset(), tokenSerializer, context); oos.write(token); return DatatypeConverter.printHexBinary(baos.toByteArray()); } catch (Exception ignore) { return ""; } } }); }
From source file:retsys.client.controller.ProjectController.java
/** * Initializes the controller class.//w w w . ja v a2 s.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", "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."); } }); }