List of usage examples for javafx.collections FXCollections observableArrayList
public static <E> ObservableList<E> observableArrayList(Collection<? extends E> col)
From source file:com.properned.application.ManageLocaleController.java
public void initializeList() { logger.info("Initialize locale list"); list = FXCollections.observableArrayList(multiLanguageProperties.getMapPropertiesByLocale().keySet()); SortedList<Locale> sortedList = new SortedList<>(list, new Comparator<Locale>() { @Override/*w w w . j a v a2s. c om*/ public int compare(Locale o1, Locale o2) { return o1.toString().compareTo(o2.toString()); } }); localeList.setItems(sortedList); localeList.setCellFactory(c -> new LocaleListCell(multiLanguageProperties, this)); list.addListener(new ListChangeListener<Locale>() { @Override public void onChanged(Change<? extends Locale> c) { if (c.next()) { if (c.wasAdded()) { List<? extends Locale> addedSubList = c.getAddedSubList(); for (Locale locale : addedSubList) { try { MultiLanguageProperties.getInstance().addLocale(locale); } catch (IOException e) { Properned.getInstance().showError( MessageReader.getInstance().getMessage("manageLocale.error.errorAddLocale"), e); } } } } } }); }
From source file:edu.mit.lib.handbag.Controller.java
public void initialize() { Image wfIm = new Image(getClass().getResourceAsStream("/SiteMap.png")); workflowLabel.setGraphic(new ImageView(wfIm)); workflowLabel.setContentDisplay(ContentDisplay.BOTTOM); workflowChoiceBox.addEventHandler(ActionEvent.ACTION, event -> { if (workflowChoiceBox.getItems().size() != 0) { return; }/*from www. j a va 2 s .c o m*/ ObservableList<Workflow> wflowList = FXCollections.observableArrayList(loadWorkflows()); workflowChoiceBox.setItems(wflowList); workflowChoiceBox.getSelectionModel().selectedIndexProperty().addListener((ov, value, new_value) -> { int newVal = (int) new_value; if (newVal != -1) { Workflow newSel = workflowChoiceBox.getItems().get(newVal); if (newSel != null) { workflowLabel.setText(newSel.getName()); generateBagName(newSel.getBagNameGenerator()); bagLabel.setText(bagName); sendButton.setText(newSel.getDestinationName()); setMetadataList(newSel); } } }); }); Image bagIm = new Image(getClass().getResourceAsStream("/Bag.png")); bagLabel.setGraphic(new ImageView(bagIm)); bagLabel.setContentDisplay(ContentDisplay.BOTTOM); Image sendIm = new Image(getClass().getResourceAsStream("/Cabinet.png")); sendButton.setGraphic(new ImageView(sendIm)); sendButton.setContentDisplay(ContentDisplay.BOTTOM); sendButton.setDisable(true); sendButton.setOnAction(e -> transmitBag()); Image trashIm = new Image(getClass().getResourceAsStream("/Bin.png")); trashButton.setGraphic(new ImageView(trashIm)); trashButton.setContentDisplay(ContentDisplay.BOTTOM); trashButton.setDisable(true); trashButton.setOnAction(e -> reset(false)); TreeItem<PathRef> rootItem = new TreeItem<>(new PathRef("", Paths.get("data"))); rootItem.setExpanded(true); payloadTreeView.setRoot(rootItem); payloadTreeView.setOnDragOver(event -> { if (event.getGestureSource() != payloadTreeView && event.getDragboard().getFiles().size() > 0) { event.acceptTransferModes(TransferMode.COPY_OR_MOVE); } event.consume(); }); payloadTreeView.setOnDragDropped(event -> { Dragboard db = event.getDragboard(); boolean success = false; if (db.getFiles().size() > 0) { for (File dragFile : db.getFiles()) { if (dragFile.isDirectory()) { // explode directory and add expanded relative paths to tree relPathSB = new StringBuilder(); try { Files.walkFileTree(dragFile.toPath(), new SimpleFileVisitor<Path>() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { relPathSB.append(dir.getFileName()).append("/"); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { payloadTreeView.getRoot().getChildren() .add(new TreeItem<>(new PathRef(relPathSB.toString(), file))); bagSize += Files.size(file); return FileVisitResult.CONTINUE; } }); } catch (IOException ioe) { } } else { payloadTreeView.getRoot().getChildren() .add(new TreeItem<>(new PathRef("", dragFile.toPath()))); bagSize += dragFile.length(); } } bagSizeLabel.setText(scaledSize(bagSize, 0)); success = true; updateButtons(); } event.setDropCompleted(success); event.consume(); }); metadataPropertySheet.setModeSwitcherVisible(false); metadataPropertySheet.setDisable(false); metadataPropertySheet.addEventHandler(KeyEvent.ANY, event -> { checkComplete(metadataPropertySheet.getItems()); event.consume(); }); }
From source file:de.micromata.mgc.javafx.launcher.gui.generic.LoggingConfigTabController.java
@Override public void initializeWithModel() { if (isFallback() == true) { passToLog4JPane.setVisible(false); }/*ww w . j av a 2s .co m*/ loggingDescriptions = LsLoggingLocalSettingsConfigModel.getAvailableServices(); // List<String> list = loggingDescriptions.stream().map(e -> e.name()).collect(Collectors.toList()); loggingType.setItems(FXCollections.observableArrayList(loggingDescriptions)); loggingType.setOnAction(event -> onChangeLogType()); fromModel(); onChangeLogType(); if (jdbcController != null) { JdbcLocalSettingsConfigModel jdbcconfig = model.getJdbcConfig(); if (jdbcconfig != null) { jdbcController.fromModel(); } } }
From source file:com.rcs.shoe.shop.fx.controller.ui.ProductsController.java
public void initialize(URL url, ResourceBundle rb) { TableColumn firstCol = (TableColumn) productsTable.getColumns().get(0); PropertyValueFactory p1 = new PropertyValueFactory<>("productNum"); firstCol.setCellValueFactory(p1);//from www.ja v a2 s . c o m TableColumn secCol = (TableColumn) productsTable.getColumns().get(1); PropertyValueFactory p2 = new PropertyValueFactory<>("productCode"); secCol.setCellValueFactory(p2); TableColumn thirdCol = (TableColumn) productsTable.getColumns().get(2); PropertyValueFactory p3 = new PropertyValueFactory<>("quantity"); thirdCol.setCellValueFactory(p3); productsTable.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> { if (newSelection != null && newSelection instanceof V_Products) { V_Products selectedProd = (V_Products) newSelection; selProductCode.textProperty().setValue(selectedProd.getProductCode()); selProductNum.textProperty().setValue(selectedProd.getProductNum().toString()); } }); ObservableList<V_Products> prod = FXCollections.observableArrayList(productService.findAll()); products = new FilteredList<>(prod, p -> true); productsTable.setItems(products); initVisibility(); }
From source file:com.github.tddts.jet.view.fx.controller.LoginController.java
@PostConstruct private void init() { loginChoiceBox.setConverter(messageProvider.getConverter(AuthorizationType.values())); loginChoiceBox.setItems(FXCollections.observableArrayList(AuthorizationType.values())); loginChoiceBox.getSelectionModel().selectedItemProperty() .addListener((obs, oldval, val) -> processLoginTypeChange(val)); loginChoiceBox.getSelectionModel().selectFirst(); loginButton.setOnAction(event -> processLogin()); dataSourceBox.setConverter(messageProvider.getConverter(RestDataSource.values())); dataSourceBox.setItems(FXCollections.observableArrayList(RestDataSource.values())); dataSourceBox.getSelectionModel().selectedItemProperty() .addListener((obs, oldval, val) -> processDataSourceChange(val)); dataSourceBox.getSelectionModel().selectFirst(); loginChoiceBox.managedProperty().bind(loginChoiceBox.visibleProperty()); loginButton.managedProperty().bind(loginButton.visibleProperty()); }
From source file:de.micromata.mgc.application.webserver.config.JettyConfigTabController.java
@Override public void initializeWithModel() { sslChildPane = sslPane.getChildren().get(0); fromModel();//from ww w . ja v a 2 s . co m List<String> hosts = getListenHosts(); hosts.add(0, ""); listenHost.setItems(FXCollections.observableArrayList(hosts)); port.textProperty().addListener((tc, oldVal, newVal) -> { String oldUrl = publicUrl.getText(); String sc = contextPath.getText(); String tu = "http://localhost:" + oldVal + sc; if (StringUtils.equals(oldUrl, tu) == true) { String nu = "http://localhost:" + newVal + sc; publicUrl.setText(nu); } }); sslEnabled.setOnAction(event -> { onSslEnabled(sslEnabled.isSelected()); }); onSslEnabled(model.isSslEnabled()); generateSslCert.setOnAction(event -> { createSsl(); }); }
From source file:com.mycompany.pfinanzaspersonales.BuscadorController.java
/** * Initializes the controller class./*from w w w.jav a2 s . co m*/ */ @Override public void initialize(URL url, ResourceBundle rb) { tipo.add(new Combobox("Todo", "0")); tipo.add(new Combobox("Ingresos", "Ingresos")); tipo.add(new Combobox("Gastos", "Gasto")); cbb_tipo.setItems(FXCollections.observableArrayList(tipo)); cargarComboboxPagos(); cbb_tipo.getSelectionModel().selectFirst(); cbb_pago.getSelectionModel().selectFirst(); }
From source file:de.micromata.genome.gwiki.launcher.config.GWikiFilesystemController.java
@Override public void initializeWithModel() { MgcApplicationInfo info = MgcLauncher.get().getApplication().getApplicationInfo(); info.getName();/* www . j av a2s. c o m*/ Pair<Pane, JdbcConfigTabController> jdbc = ControllerService.get() .loadControlWithModel(JdbcConfigTabController.class, Pane.class, model.getJdbcConfigModel(), this); jdbcPane = jdbc.getFirst(); jdbcController = jdbc.getSecond(); jdbcMasterPane.getChildren().add(jdbcPane); jdbcPane.setLayoutY(30); fromModel(); storageType.setItems(FXCollections.observableArrayList(model.getAvailableFileSystemTypes())); storageType.setOnAction(event -> switchToStoragetype(storageType.getValue().equals("Database"))); storageFilePathSelector.setOnAction(e -> { DirectoryChooser fileChooser = new DirectoryChooser(); fileChooser.setInitialDirectory(getDefaultStorageFilePath()); File res = fileChooser.showDialog(getConfigDialog().getStage()); if (res != null) { storageFilePath.setText(res.getAbsolutePath()); } }); useContextXml.setOnAction(event -> switchContextXml(useContextXml.isSelected())); contextXmlFileSelector.setOnAction(event -> { FileChooser chooser = new FileChooser(); chooser.setInitialDirectory(new File(".")); chooser.getExtensionFilters().add(new ExtensionFilter("XML File", "*.xml")); File res = chooser.showOpenDialog(getConfigDialog().getStage()); if (res != null) { contextXml.setText(res.getAbsolutePath()); } }); }
From source file:br.com.ajaio.midas.desktop.controller.BancoCrudFXMLController.java
public void consultar() { try {//from ww w . j a v a2s . co m BancoEntity filtro = new BancoEntity(); BancoService bancoService = (BancoService) context.getBean("bancoService"); Iterable<BancoEntity> bancos = bancoService.findAll(); Iterator itBanco = bancos.iterator(); ArrayList<Banco> bancosDM = new ArrayList<Banco>(); for (BancoEntity b : bancos) { Banco banco = new Banco(b); bancosDM.add(banco); } final ObservableList<Banco> data = FXCollections.observableArrayList(bancosDM); tbBancos.setItems(data); } catch (Exception e) { tratarExcecao(e); } }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsModel.java
public void readReports() { int start = getData().size() - 1; if (start < 0) { start = 0;// w w w .j a va 2 s .c o m } int count = reports_loaded; ObservableList<ReportRow> rows = FXCollections.observableArrayList(new ArrayList<>()); String baseDir = ReportGenerator.getReportsFolder(); File reportsDir = new File(baseDir); if (reportsDir.exists()) { String[] directories = reportsDir.list((current, name) -> new File(current, name).isDirectory()); Arrays.sort(directories, Collections.reverseOrder()); int index = 0; for (int i = 0; i < directories.length; i++) { String reportDay = directories[i]; File reportsDay = new File(baseDir + "/" + reportDay); String[] directories2 = reportsDay.list((current, name) -> new File(current, name).isDirectory()); // Convert to ints for ordering Integer[] int_directories = new Integer[directories2.length]; for (int j = 0; j < directories2.length; j++) { try { int_directories[j] = Integer.parseInt(directories2[j]); } catch (Exception ex) { context.send(BasicConfig.MODULE_MESSAGE, new LogMessage(getClass(), Level.DEBUG, bundle.getString("incorrectReport") + ": " + directories2[j])); int_directories[j] = -1; } } Arrays.sort(int_directories, Collections.reverseOrder()); if (index + directories2.length >= start) { String[] available_formats = { "html", "xml", "json", "pdf" }; for (int j = 0; j < int_directories.length; j++) { if (int_directories[j] < 0) continue; String reportDir = String.valueOf(int_directories[j]); if (index >= start && index < start + count) { ReportRow rr = null; File reportXml = new File(baseDir + "/" + reportDay + "/" + reportDir + "/summary.xml"); File reportJson = new File( baseDir + "/" + reportDay + "/" + reportDir + "/summary.json"); File reportHtml = new File( baseDir + "/" + reportDay + "/" + reportDir + "/report.html"); File reportPdf = new File(baseDir + "/" + reportDay + "/" + reportDir + "/report.pdf"); if (reportXml.exists() && reportXml.length() > 0) { rr = ReportRow.createRowFromXml(reportDay, reportXml, getBundle()); } if (rr == null && reportJson.exists() && reportJson.length() > 0) { rr = ReportRow.createRowFromJson(reportDay, reportJson, getBundle()); } if (rr == null && reportHtml.exists() && reportHtml.length() > 0) { rr = ReportRow.createRowFromHtml(reportDay, reportHtml, getBundle()); } if (rr == null && reportPdf.exists() && reportPdf.length() > 0) { rr = ReportRow.createRowFromPdf(reportDay, reportPdf, getBundle()); } if (rr != null) { // Add formats for (String format : available_formats) { File report; if (format == "json" || format == "xml") { report = new File( baseDir + "/" + reportDay + "/" + reportDir + "/summary." + format); } else { report = new File( baseDir + "/" + reportDay + "/" + reportDir + "/report." + format); } if (report.exists() && report.length() > 0) { rr.addFormat(format, report.getPath()); } } // Add mets File folder = new File(baseDir + "/" + reportDay + "/" + reportDir + "/"); if (folder.exists() && folder.isDirectory()) { String[] filter = { "mets.xml" }; Collection<File> childs = FileUtils.listFiles(folder, filter, false); if (childs.size() > 0) { rr.addFormat("mets", folder.getPath()); } } rows.add(rr); index++; } // Check if all done if (i == directories.length - 1 && j == directories2.length - 1) { all_reports_loaded = true; } } else { index++; } } } else { index += directories2.length; } } } data.addAll(rows); }