public void initProviders() throws DataBaseException { providers = dao.getProviders(); selectProviderCb.getItems().clear(); for (Provider provider : providers) { selectProviderCb.getItems().add(provider.getName()); } selectProviderCb.setValue(providers.get(0).getName()); }
public void init() { /* Image img1 = new Image(TermProjectMain.class.getResourceAsStream("bkash.png")); bkash.setImage(img1); Image img2 = new Image(TermProjectMain.class.getResourceAsStream("sure cash.png")); sureCash.setImage(img2); Image img3 = new Image(TermProjectMain.class.getResourceAsStream("dutch bangla.png")); DBBL.setImage(img3); Image img4 = new Image(TermProjectMain.class.getResourceAsStream("mastercard.png")); masterCard.setImage(img4); Image img5 = new Image(TermProjectMain.class.getResourceAsStream("visa.png")); visa.setImage(img5); */ // fromBoxList.setAll(options); // toBoxList.setAll(options); // fromComboBox.getItems().addAll(fromBoxList); c = new clientInfo(); fromComboBox.getItems().addAll(options); // toComboBox.getItems().addAll(toBoxList); toComboBox.getItems().addAll(options); fromComboBox.setVisibleRowCount(4); toComboBox.setVisibleRowCount(4); // the code fragment below ensures that no day before today is selected from the datePicker by // disabling the selecting option for those days and marking them in pink color final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() { @Override public DateCell call(final DatePicker datePicker) { return new DateCell() { @Override public void updateItem(LocalDate item, boolean empty) { super.updateItem(item, empty); if (item.isBefore(LocalDate.now())) { setDisable(true); setStyle("-fx-background-color: #ffc0cb;"); } } }; } }; datePick.setDayCellFactory(dayCellFactory); datePick.setEditable(false); final ToggleGroup group = new ToggleGroup(); ACradioButton.setToggleGroup(group); nonACradioButton.setToggleGroup(group); }
public void iniciarCategorias() { cruds = new CRUDArticulos(); categorias = cruds.traerCategorias(); for (int i = 0; i < categorias.size(); i++) { cmbCategorias.getItems().add(categorias.get(i).getNombre()); } }
@Override protected void activate() { currencyComboBox.setItems(model.getTradeCurrencies()); currencyComboBox.getSelectionModel().select(model.getTradeCurrency()); currencyComboBox.setVisibleRowCount(Math.min(currencyComboBox.getItems().size(), 25)); currencyComboBox.setOnAction( e -> { model.onSetTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem()); updateChartData(); }); model.getOfferBookListItems().addListener(changeListener); tradeCurrencySubscriber = EasyBind.subscribe( model.tradeCurrency, newValue -> { String code = newValue.getCode(); areaChart.setTitle("Offer book for " + newValue.getName()); priceColumnLabel.set("Price (" + code + "/BTC)"); volumeColumnLabel.set("Volume (" + code + ")"); xAxis.setLabel(priceColumnLabel.get()); xAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(xAxis, "", "")); }); buyOfferTableView.setItems(model.getBuyOfferList()); sellOfferTableView.setItems(model.getSellOfferList()); updateChartData(); }
private void initializeAssignmentListViewAndFilters() { final ListBinding<PersonnelAssignment> filteredAssignementBinding = new ListBinding<PersonnelAssignment>() { final ObjectBinding<ObservableList<PersonnelAssignment>> internalBinding = Bindings.select( assignmentsFilterComboBox.getSelectionModel().selectedItemProperty(), "assignments"); { bind(internalBinding); } @Override protected ObservableList<PersonnelAssignment> computeValue() { return internalBinding.get(); } @Override public Spliterator<PersonnelAssignment> spliterator() { return super.spliterator(); } }; assigmentsListView.itemsProperty().bind(filteredAssignementBinding); assigmentsListView.setCellFactory( new PropertyListCellFactory<PersonnelAssignment>("name", null)); assignmentsFilterComboBox.getItems().clear(); assignmentsFilterComboBox.getItems().addAll(assignementFilters); assignmentsFilterComboBox.setCellFactory( new PropertyListCellFactory<AssignementFilter>("name", null)); assignmentsFilterComboBox.setButtonCell( new ListCell<AssignementFilter>() { @Override protected void updateItem(AssignementFilter item, boolean empty) { super.updateItem(item, empty); if (textProperty().isBound()) { textProperty().unbind(); } if (item != null || !empty) { textProperty().bind(item.nameProperty()); } } }); }
public void addStationsToCB() throws IOException { File f = new File("config"); FileReader fr1 = new FileReader(f); LineNumberReader ln = new LineNumberReader(fr1); int count = 0; while (ln.readLine() != null) { count++; } ln.close(); fr1.close(); FileReader fr2 = new FileReader(f); BufferedReader br = new BufferedReader(fr2); for (int i = 0; i < count; i++) { cbStations.getItems().add(br.readLine()); } br.close(); fr2.close(); }
public void initGrains() { grains = new ArrayList<>(); grains.add(new Wheat()); grains.add(new Rice()); for (Grain grain : grains) { selectGrainCb.getItems().add(grain.getDescription()); } selectGrainCb .valueProperty() .addListener( new ChangeListener<String>() { @Override public void changed(ObservableValue ov, String t, String t1) { grain = getGrain(t1); initProperties(grain); } }); selectGrainCb.setValue(grains.get(0).getDescription()); }
public void addQuantityToCB() throws IOException { temperatureSerie.removeAll(); pressureSerie.removeAll(); windSerie.removeAll(); rainfallSerie.removeAll(); humiditySerie.removeAll(); cbQuantity.getItems().clear(); String station = (String) cbStations.getValue(); File f = new File("database\\" + station + "\\data.txt"); FileReader fr1 = new FileReader(f); LineNumberReader ln = new LineNumberReader(fr1); int count = 0; while (ln.readLine() != null) { count++; } ln.close(); fr1.close(); FileReader fr2 = new FileReader(f); BufferedReader br = new BufferedReader(fr2); boolean wsFlag = false; boolean prFlag = false; boolean teFlag = false; boolean huFlag = false; boolean rrFlag = false; for (int i = 0; i < count; i++) { String line = br.readLine(); String[] words = line.split(" "); for (int j = 0; j < words.length; j++) { if (words[0].equals("") == false) { long timeValue = Long.parseLong(words[0]); if (words[j].equals("WS")) { windData.add(new XYChart.Data<Long, Number>(timeValue, Integer.parseInt(words[j + 2]))); if (wsFlag == false) { cbQuantity.getItems().add("Wind Speed"); wsFlag = true; } } else if (words[j].equals("PR")) { pressureData.add( new XYChart.Data<Long, Number>(timeValue, Integer.parseInt(words[j + 2]))); if (prFlag == false) { cbQuantity.getItems().add("Pressure"); prFlag = true; } } else if (words[j].equals("TE")) { temperatureData.add( new XYChart.Data<Long, Number>(timeValue, Integer.parseInt(words[j + 2]))); if (teFlag == false) { cbQuantity.getItems().add("Temperature"); teFlag = true; } } else if (words[j].equals("HU")) { humidityData.add( new XYChart.Data<Long, Number>(timeValue, Integer.parseInt(words[j + 2]))); if (huFlag == false) { cbQuantity.getItems().add("Humidity"); huFlag = true; } } else if (words[j].equals("RR")) { rainfallData.add( new XYChart.Data<Long, Number>(timeValue, Integer.parseInt(words[j + 2]))); if (rrFlag == false) { cbQuantity.getItems().add("Rainfall Rate"); rrFlag = true; } } } } } br.close(); fr2.close(); }
private void updateSelectedEntry() { ObservableList<PolizistDaten> Nutzerauswahl = Tabelle.getSelectionModel().getSelectedItems(); if (Nutzerauswahl.size() != 1) { IM.setErrorText("Es muss genau ein Element ausgewählt werden"); return; } PolizistDaten Auswahl = Nutzerauswahl.get(0); // Jetzt erzeugen wir ein PopUp zum veraendern des Eintrags Stage PopUp = new Stage(); PopUp.initModality(Modality.APPLICATION_MODAL); PopUp.setTitle("Neuer Eintrag"); PopUp.setAlwaysOnTop(true); PopUp.setResizable(false); GridPane Gitter = new GridPane(); Gitter.setHgap(10); Gitter.setVgap(10); Label LabelA = new Label("PersonenID"); Label LabelAWert = new Label(Integer.toString(Auswahl.getPersonenID())); Label LabelB = new Label("Name"); TextField LabelBWert = new TextField(); Label LabelC = new Label("Geburtsdatum"); DatePicker LabelCWert = new DatePicker(); Label LabelD = new Label("Nationalität"); TextField LabelDWert = new TextField(); Label LabelE = new Label("Geschlecht"); ComboBox LabelEWert = new ComboBox(); Label LabelF = new Label("Todesdatum"); DatePicker LabelFWert = new DatePicker(); Label LabelG = new Label("Dienstgrad"); TextField LabelGWert = new TextField(); final Callback<DatePicker, DateCell> TagesZellenFabtrik = new Callback<DatePicker, DateCell>() { @Override public DateCell call(final DatePicker DP) { return new DateCell() { @Override public void updateItem(LocalDate item, boolean empty) { super.updateItem(item, empty); if (item.isBefore(LabelCWert.getValue().plusDays(1))) { setDisable(true); setStyle("-fx-background-color: #ffc0cb;"); } } }; } }; LabelFWert.setDayCellFactory(TagesZellenFabtrik); LabelEWert.getItems().addAll("m", "w"); LabelEWert.setValue(Auswahl.getGeschlecht()); LabelBWert.setText(Auswahl.getName()); LabelCWert.setValue(LocalDate.parse(Auswahl.getGebDatum())); // TODO exception LabelDWert.setText(Auswahl.getNation()); if (!Auswahl.getTodDatum().isEmpty()) { LabelFWert.setValue(LocalDate.parse(Auswahl.getTodDatum())); // TODO exception } LabelGWert.setText(Auswahl.getDienstgrad()); Button ButtonFort = new Button("Fortfahren"); Button ButtonAbb = new Button("Abbrechen"); ButtonFort.defaultButtonProperty(); ButtonAbb.cancelButtonProperty(); ButtonFort.setMaxWidth(Double.MAX_VALUE); ButtonAbb.setMaxWidth(Double.MAX_VALUE); Gitter.addColumn(0, LabelA, LabelB, LabelC, LabelD, LabelE, LabelF, LabelG); Gitter.addColumn( 1, LabelAWert, LabelBWert, LabelCWert, LabelDWert, LabelEWert, LabelFWert, LabelGWert); VBox AussenBox = new VBox(10); HBox InnenBox = new HBox(); AussenBox.setSpacing(10); AussenBox.setPadding(new Insets(10)); InnenBox.setSpacing(10); AussenBox.setAlignment(Pos.CENTER); InnenBox.setAlignment(Pos.BOTTOM_CENTER); AussenBox.getChildren().addAll(Gitter, InnenBox); InnenBox.getChildren().addAll(ButtonFort, ButtonAbb); ButtonAbb.setOnAction(event -> PopUp.close()); ButtonFort.setOnAction( event -> { String SQLString; if (LabelFWert.getEditor().getText().isEmpty()) { SQLString = "UPDATE PERSON SET Name=?, Geburtsdatum=?, Nationalität=?, Geschlecht=?, Todesdatum=NULL WHERE PersonenID = " + Auswahl.getPersonenID(); } else { SQLString = "UPDATE PERSON SET Name=?, Geburtsdatum=?, Nationalität=?, Geschlecht=?, Todesdatum=? WHERE PersonenID = " + Auswahl.getPersonenID(); } try { PreparedStatement InsertStatement = DH.prepareStatement(SQLString); InsertStatement.setString(1, LabelBWert.getText()); InsertStatement.setString(2, LabelCWert.getValue().toString()); // TODO exception InsertStatement.setString(3, LabelDWert.getText()); InsertStatement.setString(4, LabelEWert.getValue().toString()); if (LabelFWert.getValue() != null && !LabelFWert.getEditor().getText().isEmpty()) { InsertStatement.setString(5, LabelFWert.getValue().toString()); } InsertStatement.executeUpdate(); SQLString = "UPDATE POLIZIST SET Dienstgrad = ? WHERE PersonenID = " + Auswahl.getPersonenID(); InsertStatement = DH.prepareStatement(SQLString); InsertStatement.setString(1, LabelGWert.getText()); InsertStatement.execute(); IM.setInfoText("Änderung durchgeführt"); } catch (SQLException e) { IM.setErrorText("Ändern Fehlgeschlagen", e); } refreshPolizistAnsicht(); PopUp.close(); }); PopUp.setScene(new Scene(AussenBox)); PopUp.showAndWait(); }
private void insertNewEntry() { Stage PopUp = new Stage(); PopUp.initModality(Modality.APPLICATION_MODAL); PopUp.setTitle("Neuer Eintrag"); PopUp.setAlwaysOnTop(true); PopUp.setResizable(false); GridPane Gitter = new GridPane(); Gitter.setHgap(10); Gitter.setVgap(10); Label LabelB = new Label("Name"); TextField LabelBWert = new TextField(); Label LabelC = new Label("Geburtsdatum"); DatePicker LabelCWert = new DatePicker(); Label LabelD = new Label("Nationalität"); TextField LabelDWert = new TextField(); Label LabelE = new Label("Geschlecht"); ComboBox LabelEWert = new ComboBox(); Label LabelF = new Label("Todesdatum"); DatePicker LabelFWert = new DatePicker(); Label LabelG = new Label("Dienstgrad"); TextField LabelGWert = new TextField(); final Callback<DatePicker, DateCell> TagesZellenFabtrik = new Callback<DatePicker, DateCell>() { @Override public DateCell call(final DatePicker DP) { return new DateCell() { @Override public void updateItem(LocalDate item, boolean empty) { super.updateItem(item, empty); if (item.isBefore(LabelCWert.getValue().plusDays(1))) { setDisable(true); setStyle("-fx-background-color: #ffc0cb;"); } } }; } }; LabelFWert.setDayCellFactory(TagesZellenFabtrik); LabelEWert.getItems().addAll("m", "w"); LabelEWert.setValue("m"); Button ButtonFort = new Button("Fortfahren"); Button ButtonAbb = new Button("Abbrechen"); ButtonFort.defaultButtonProperty(); ButtonAbb.cancelButtonProperty(); ButtonFort.setMaxWidth(Double.MAX_VALUE); ButtonAbb.setMaxWidth(Double.MAX_VALUE); Gitter.addColumn(0, LabelB, LabelC, LabelD, LabelE, LabelF, LabelG); Gitter.addColumn(1, LabelBWert, LabelCWert, LabelDWert, LabelEWert, LabelFWert, LabelGWert); VBox AussenBox = new VBox(10); HBox InnenBox = new HBox(); AussenBox.setSpacing(10); AussenBox.setPadding(new Insets(10)); InnenBox.setSpacing(10); AussenBox.setAlignment(Pos.CENTER); InnenBox.setAlignment(Pos.BOTTOM_CENTER); AussenBox.getChildren().addAll(Gitter, InnenBox); InnenBox.getChildren().addAll(ButtonFort, ButtonAbb); ButtonAbb.setOnAction(event -> PopUp.close()); ButtonFort.setOnAction( event -> { String SQLString; if (LabelFWert.getValue() != null) { SQLString = "INSERT INTO PERSON (Name, Geburtsdatum, Nationalität, Geschlecht, Todesdatum) VALUES (?, ?, ?, ?, ?)"; } else { SQLString = "INSERT INTO PERSON (Name, Geburtsdatum, Nationalität, Geschlecht) VALUES (?, ?, ?, ?)"; } try { PreparedStatement InsertStatement = DH.prepareStatement(SQLString); InsertStatement.setString(1, LabelBWert.getText()); InsertStatement.setString(2, LabelCWert.getValue().toString()); // TODO exception InsertStatement.setString(3, LabelDWert.getText()); InsertStatement.setString(4, LabelEWert.getValue().toString()); if (LabelFWert.getValue() != null) { InsertStatement.setString(5, LabelFWert.getValue().toString()); // TODO exception } InsertStatement.executeUpdate(); ResultSet PersID = DH.getAnfrageObjekt().executeQuery("SELECT last_insert_rowid();"); if (!PersID.next()) { IM.setErrorText("Konnte Primärschlüssel nicht mehr bestimmen."); } SQLString = "INSERT INTO POLIZIST (PersonenID, Dienstgrad) VALUES (?, ?)"; InsertStatement = DH.prepareStatement(SQLString); InsertStatement.setInt(1, PersID.getInt(1)); // TODO das hier verifizieren InsertStatement.setString(2, LabelGWert.getText()); InsertStatement.executeUpdate(); IM.setInfoText("Einfügen durchgeführt"); } catch (SQLException e) { IM.setErrorText("Einfügen Fehlgeschlagen", e); } refreshPolizistAnsicht(); PopUp.close(); }); PopUp.setScene(new Scene(AussenBox)); PopUp.showAndWait(); }
@Override public void start(Stage stage) throws Exception { // ----------MENU---------- MenuBar menuBar = new MenuBar(); Menu menuFile = new Menu("File"); MenuItem menuItemPurchase = new MenuItem("New Purchase"); MenuItem menuItemStore = new MenuItem("New Store"); MenuItem menuItemCategory = new MenuItem("New Category"); MenuItem menuItemExit = new MenuItem("Exit"); menuFile.getItems().addAll(menuItemPurchase, menuItemStore, menuItemCategory, menuItemExit); Menu menuHelp = new Menu("Help"); menuBar.getMenus().addAll(menuFile, menuHelp); // ----------TOOLBAR---------- ToolBar toolBar = new ToolBar(); Button buttonPurchase = new Button(); Button buttonStore = new Button(); Button buttonCategory = new Button(); buttonPurchase.setGraphic(new ImageView("/pictures/purchase.png")); buttonStore.setGraphic(new ImageView("/pictures/store.png")); buttonCategory.setGraphic(new ImageView("/pictures/category.png")); toolBar.getItems().addAll(buttonPurchase, buttonStore, buttonCategory); buttonStore.setOnAction( new EventHandler<ActionEvent>() { public void handle(ActionEvent actionEvent) { Stage stage = new Stage(); try { new StoreWindows().start(stage); } catch (Exception e) { e.printStackTrace(); } } }); // ----------WORKSPACE---------- GridPane gridPane = new GridPane(); gridPane.setAlignment(Pos.CENTER); gridPane.setVgap(10); gridPane.setHgap(10); gridPane.setPadding(new Insets(0, 25, 25, 0)); Label storeLabel = new Label("Store: "); storeLabel.setId("simpleLabel"); gridPane.add(storeLabel, 0, 1); final ComboBox<String> stores = new ComboBox<String>(); gridPane.add(stores, 1, 1); Label categoryLabel = new Label("Category: "); categoryLabel.setId("simpleLabel"); gridPane.add(categoryLabel, 2, 1); final ComboBox<String> categories = new ComboBox<String>(); gridPane.add(categories, 3, 1); Button bCount = new Button("Count"); HBox hBox = new HBox(10); hBox.setAlignment(Pos.BOTTOM_RIGHT); hBox.getChildren().add(bCount); gridPane.add(hBox, 4, 1); FlowPane flowPane1 = new FlowPane(); flowPane1.setAlignment(Pos.CENTER); flowPane1.setPadding(new Insets(10, 25, 25, 10)); final Text spentTitle = new Text("SPENT: "); spentTitle.setId("headline"); flowPane1.getChildren().add(spentTitle); // ----------DATABASE---------- Label statusLabel = new Label(); DaoFactory daoFactory = new MySQLDaoFactory(); try { Connection connection = daoFactory.getConnection(); statusLabel.setText("Database connection: success"); StoreDao storeDao = new MySQLStoreDao(connection); ArrayList<Store> storeList = (ArrayList) storeDao.getStores(); for (Store store : storeList) { stores.getItems().add(store.getName()); } CategoryDao categoryDao = new MySQLCategoryDao(connection); ArrayList<Category> categoryList = (ArrayList) categoryDao.getCategories(); for (Category category : categoryList) { categories.getItems().add(category.getTitle()); } } catch (SQLException e) { statusLabel.setText("Database connection: failed"); } FlowPane footer = new FlowPane(); footer.setPadding(new Insets(10, 10, 10, 10)); footer.getChildren().add(statusLabel); bCount.setOnAction( new EventHandler<ActionEvent>() { public void handle(ActionEvent actionEvent) { try { PurchaseDao purchaseDao = new MySQLPurchaseDao(new MySQLDaoFactory().getConnection()); spentTitle.setText( "SPENT: " + purchaseDao.showSpent(stores.getValue(), categories.getValue())); } catch (SQLException e) { e.printStackTrace(); } } }); // ----------VIEW---------- Scene scene = new Scene(new VBox(), 800, 600); scene.getStylesheets().add("css/style.css"); ((VBox) scene.getRoot()).getChildren().addAll(menuBar, toolBar, gridPane, flowPane1, footer); stage.setScene(scene); stage.setTitle("Cash Organizer"); stage.getIcons().add(new Image("pictures/icon.png")); stage.show(); }
/** * Creates popup menu based on menu button selected * * @param type type of menu button selected */ @SuppressWarnings({"unchecked", "rawtypes"}) private void genericPopup(String type) { int length = 0; int width = 0; String title = new String(); Stage secondaryStage = new Stage(); // Create a GridPane container GridPane grid = new GridPane(); grid.setPadding(new Insets(10, 10, 10, 10)); grid.setVgap(5); grid.setHgap(5); Button submit = new Button("Submit"); GridPane.setConstraints(submit, 1, 0); grid.getChildren().add(submit); if (type.equals("customer")) { final TextField name = new TextField(); name.setPrefColumnCount(17); GridPane.setConstraints(name, 0, 0); grid.getChildren().add(name); submit.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (!name.getText().isEmpty()) { if (myController.getRestClient().selectCustomer(name.getText(), name)) { secondaryStage.close(); } } else { name.setPromptText("Enter customer username."); } updateAccountsWindow(); } }); length = 50; width = 285; title = "Select Customer"; } else if (type.equals("create")) { final ComboBox accountTypeCB = new ComboBox(); accountTypeCB .getItems() .addAll("SELECT TYPE", "CHECKING", "SAVINGS", "MONEY MARKET", "MORTGAGE", "CREDIT"); accountTypeCB.setValue("SELECT TYPE"); GridPane.setConstraints(accountTypeCB, 0, 0); grid.getChildren().add(accountTypeCB); submit.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (accountTypeCB.getValue().toString().equals("SELECT TYPE")) { accountTypeCB.setValue("SELECT TYPE"); } else { Account.TYPE thisType = Account.TYPE.CHECKING; if (accountTypeCB.getValue().toString().equals("SAVINGS")) { thisType = Account.TYPE.SAVINGS; } else if (accountTypeCB.getValue().toString().equals("MONEY MARKET")) { thisType = Account.TYPE.MONEY_MARKET; } else if (accountTypeCB.getValue().toString().equals("MORTGAGE")) { thisType = Account.TYPE.MORTGAGE; } else if (accountTypeCB.getValue().toString().equals("CREDIT")) { thisType = Account.TYPE.CREDIT; } if (myController.getRestClient().addAccount(thisType, 0.0f, 0.0f)) { secondaryStage.close(); } else { accountTypeCB.setValue("SELECT TYPE"); } } updateAccountsWindow(); } }); length = 50; width = 285; title = "Create Account"; } else if (type.equals("delete")) { final ComboBox accountsCB = new ComboBox(); if (myController.getRestClient().getUserAccounts() != null) { Iterator it = myController.getRestClient().getUserAccounts().entrySet().iterator(); while (it.hasNext()) { Map.Entry me = (Map.Entry) it.next(); accountsCB.getItems().add(me.getKey()); } } accountsCB.setValue("SELECT ACCOUNT"); GridPane.setConstraints(accountsCB, 0, 0); grid.getChildren().add(accountsCB); submit.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (accountsCB.getValue().equals("SELECT ACCOUNT")) { accountsCB.setValue("SELECT ACCOUNT"); } else { if (myController.getRestClient().deleteAccount((int) accountsCB.getValue())) { secondaryStage.close(); } else { accountsCB.setValue("SELECT ACCOUNT"); } } updateAccountsWindow(); } }); length = 50; width = 285; title = "Delete Account"; } else if (type.equals("deposit")) { final ComboBox accountsCB = new ComboBox(); final TextField amount = new TextField(); amount.setPrefColumnCount(10); amount.setPromptText("Deposit Amount"); if (myController.getRestClient().getUserAccounts() != null) { Iterator it = myController.getRestClient().getUserAccounts().entrySet().iterator(); while (it.hasNext()) { Map.Entry me = (Map.Entry) it.next(); accountsCB.getItems().add(me.getKey()); } } accountsCB.setValue("SELECT ACCOUNT"); GridPane.setConstraints(accountsCB, 0, 0); grid.getChildren().add(accountsCB); GridPane.setConstraints(amount, 0, 1); grid.getChildren().add(amount); submit.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (accountsCB.getValue().equals("SELECT ACCOUNT")) { accountsCB.setValue("SELECT ACCOUNT"); } else if (!accountsCB.getValue().equals("SELECT ACCOUNT") && !amount.getText().isEmpty()) { if (myController .getRestClient() .makeDeposit((int) accountsCB.getValue(), Float.valueOf(amount.getText()))) { secondaryStage.close(); } else { accountsCB.setValue("SELECT ACCOUNT"); amount.setPromptText("Deposit Amount"); } } else { accountsCB.setValue("SELECT ACCOUNT"); amount.setPromptText("Deposit Amount"); } updateAccountsWindow(); } }); length = 100; width = 285; title = "Make Deposit"; } else if (type.equals("withdraw")) { final ComboBox accountsCB = new ComboBox(); final TextField amount = new TextField(); amount.setPrefColumnCount(10); amount.setPromptText("Withdraw Amount"); if (myController.getRestClient().getUserAccounts() != null) { Iterator it = myController.getRestClient().getUserAccounts().entrySet().iterator(); while (it.hasNext()) { Map.Entry me = (Map.Entry) it.next(); accountsCB.getItems().add(me.getKey()); } } accountsCB.setValue("SELECT ACCOUNT"); GridPane.setConstraints(accountsCB, 0, 0); grid.getChildren().add(accountsCB); GridPane.setConstraints(amount, 0, 1); grid.getChildren().add(amount); submit.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (accountsCB.getValue().equals("SELECT ACCOUNT")) { accountsCB.setValue("SELECT ACCOUNT"); } else if (!accountsCB.getValue().equals("SELECT ACCOUNT") && !amount.getText().isEmpty()) { if (myController .getRestClient() .makeWithdrawal((int) accountsCB.getValue(), Float.valueOf(amount.getText()))) { secondaryStage.close(); } else { accountsCB.setValue("SELECT ACCOUNT"); amount.setPromptText("Withdraw Amount"); } } else { accountsCB.setValue("SELECT ACCOUNT"); amount.setPromptText("Withdraw Amount"); } updateAccountsWindow(); } }); length = 100; width = 285; title = "Make Deposit"; } else if (type.equals("transfer")) { final ComboBox srcAccountsCB = new ComboBox(); final ComboBox dstAccountsCB = new ComboBox(); final TextField amount = new TextField(); amount.setPrefColumnCount(10); amount.setPromptText("Transfer Amount"); if (myController.getRestClient().getUserAccounts() != null) { Iterator it = myController.getRestClient().getUserAccounts().entrySet().iterator(); while (it.hasNext()) { Map.Entry me = (Map.Entry) it.next(); srcAccountsCB.getItems().add(me.getKey()); dstAccountsCB.getItems().add(me.getKey()); } } srcAccountsCB.setValue("SELECT FROM ACCOUNT"); dstAccountsCB.setValue("SELECT TO ACCOUNT"); GridPane.setConstraints(srcAccountsCB, 0, 0); GridPane.setConstraints(srcAccountsCB, 0, 1); GridPane.setConstraints(amount, 0, 2); grid.getChildren().add(srcAccountsCB); grid.getChildren().add(dstAccountsCB); grid.getChildren().add(amount); submit.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (srcAccountsCB.getValue().equals("SELECT FROM ACCOUNT")) { srcAccountsCB.setValue("SELECT FROM ACCOUNT"); } else if (dstAccountsCB.getValue().equals("SELECT TO ACCOUNT")) { dstAccountsCB.setValue("SELECT TO ACCOUNT"); } else if (!srcAccountsCB.getValue().equals("SELECT FROM ACCOUNT") && !dstAccountsCB.getValue().equals("SELECT TO ACCOUNT") && !amount.getText().isEmpty()) { if (myController .getRestClient() .makeTransfer( (int) srcAccountsCB.getValue(), (int) dstAccountsCB.getValue(), Float.valueOf(amount.getText()))) { secondaryStage.close(); } else { srcAccountsCB.setValue("SELECT FROM ACCOUNT"); dstAccountsCB.setValue("SELECT TO ACCOUNT"); amount.setPromptText("Transfer Amount"); } } else { srcAccountsCB.setValue("SELECT FROM ACCOUNT"); dstAccountsCB.setValue("SELECT TO ACCOUNT"); amount.setPromptText("Transfer Amount"); } updateAccountsWindow(); } }); length = 125; width = 285; title = "Transfer Funds"; } else if (type.equals("transaction")) { final ComboBox accountsCB = new ComboBox(); if (myController.getRestClient().getUserAccounts() != null) { Iterator it = myController.getRestClient().getUserAccounts().entrySet().iterator(); while (it.hasNext()) { Map.Entry me = (Map.Entry) it.next(); accountsCB.getItems().add(me.getKey()); } } accountsCB.setValue("SELECT ACCOUNT"); GridPane.setConstraints(accountsCB, 0, 0); grid.getChildren().add(accountsCB); submit.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (accountsCB.getValue().equals("SELECT ACCOUNT")) { accountsCB.setValue("SELECT ACCOUNT"); } else if (!accountsCB.getValue().equals("SELECT ACCOUNT")) { if (myController.getRestClient().getUserAccounts() != null) { Iterator it = myController.getRestClient().getUserAccounts().entrySet().iterator(); while (it.hasNext()) { Map.Entry me = (Map.Entry) it.next(); if (accountsCB.getSelectionModel().getSelectedItem() == me.getKey()) { updateTransactionWindow((Account) me.getValue()); } } secondaryStage.close(); } else { accountsCB.setValue("SELECT ACCOUNT"); } } else { accountsCB.setValue("SELECT ACCOUNT"); } updateAccountsWindow(); } }); length = 100; width = 285; title = "View Transactions"; } Scene scene = new Scene(grid, width, length); secondaryStage.setScene(scene); secondaryStage.setTitle(title); secondaryStage.show(); }
public IndividualLifeBarTitledPane(final IndividualLifeBar individualLifeBar) { this.individualLifeBar = individualLifeBar; setText("Configuração LifeBar de Objeto"); VBox layout = new VBox(); GridPane gridPane = new GridPane(); ColumnConstraints col1 = new ColumnConstraints(); col1.setPercentWidth(40); ColumnConstraints col2 = new ColumnConstraints(); col2.setPercentWidth(30); ColumnConstraints col3 = new ColumnConstraints(); col3.setPercentWidth(30); gridPane.getColumnConstraints().addAll(col1, col2, col3); Label label = new Label("Objeto"); gridPane.add(label, 0, 0); boxLabelObjects = new ComboBox<String>(); boxLabelObjects.getItems().addAll(individualLifeBar.getWorld().getObjectIds()); if (individualLifeBar.getOwnerId() != null) { boxLabelObjects.getSelectionModel().select(individualLifeBar.getOwnerId()); } boxLabelObjects.setOnMouseClicked( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { for (String label : individualLifeBar.getWorld().getObjectIds()) { if (!boxLabelObjects.getItems().contains(label)) { boxLabelObjects.getItems().add(label); } } } }); boxLabelObjects.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { individualLifeBar.setOwner(boxLabelObjects.getValue()); } }); gridPane.add(boxLabelObjects, 1, 0); layout.getChildren().add(gridPane); Separator separator = new Separator(Orientation.HORIZONTAL); separator.setPadding(new Insets(5, 0, 5, 0)); layout.getChildren().add(separator); layout.setPadding(new Insets(5)); lifeBarPane = new LifebarPane(individualLifeBar); layout.getChildren().add(lifeBarPane); ScrollPane scroll = new ScrollPane(layout); scroll.setFitToWidth(true); setContent(scroll); }
ModelDeviceTypeInfo() { routeComboBox = new ComboBox<>(); routeComboBox.getItems().addAll(I.caucasus(), I.moscow(), I.transContinental(), I.infinity()); routeComboBox.getSelectionModel().selectFirst(); vBox = new VBox(new Label(I.route()), routeComboBox); }
private void initializeSkillFilterTab() { skillFilterComboBox.getItems().addAll(skills); PropertyListCellFactory<Skill> propertyListCellFactory = new PropertyListCellFactory<>("name", null); skillFilterComboBox.setButtonCell( new ListCell<Skill>() { @Override protected void updateItem(Skill arg0, boolean arg1) { super.updateItem(arg0, arg1); if (arg1 || arg0 == null) { this.setText(null); } else { this.setText(arg0.getName()); } } }); skillFilterComboBox.setCellFactory(propertyListCellFactory); skillFiltersNameColumn.setCellValueFactory( new Callback<CellDataFeatures<SkillFilter, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<SkillFilter, String> arg0) { return Bindings.selectString(arg0.getValue().skillProperty(), "name"); } }); skillFilterMinValueColumn.setCellValueFactory( new PropertyValueFactory<SkillFilter, Integer>("minValue")); skillFilterMaxValueColumn.setCellValueFactory( new PropertyValueFactory<SkillFilter, Integer>("maxValue")); skillFiltersTableView .getItems() .addListener( new ListChangeListener<SkillFilter>() { @Override public void onChanged(Change<? extends SkillFilter> arg0) { while (arg0.next()) { for (SkillFilter skillFilter : arg0.getAddedSubList()) { final Skill skill = skillFilter.getSkill(); TableColumn<Official, Number> skillColumn = new TableColumn<>(skill.getName()); skillColumn.setCellValueFactory( new Callback< CellDataFeatures<Official, Number>, ObservableValue<Number>>() { @Override public ObservableValue<Number> call( CellDataFeatures<Official, Number> arg0) { Official official = arg0.getValue(); IntegerBinding selectInteger = Bindings.selectInteger( official.skillLevelsProperty().valueAt(skill), "level"); selectInteger.addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> arg0, Number arg1, Number arg2) { updateOfficialFiltersResult(); } }); return selectInteger; } }); officialsFilteredTableView.getColumns().add(skillColumn); skillFiltersColumn.put(skill, skillColumn); } for (SkillFilter skillFilter : arg0.getRemoved()) { final Skill skill = skillFilter.getSkill(); TableColumn<Official, Number> column = skillFiltersColumn.remove(skill); if (column != null) { officialsFilteredTableView.getColumns().remove(column); } } } } }); Bindings.bindContent(skillFiltersMatcher.getMatchers(), skillFiltersTableView.getItems()); }
private BorderPane webViewScene() { url = new TextField(); url.setPrefWidth(800); browser = new WebView(); engine = browser.getEngine(); url.setText(fileUrl); engine.load(fileUrl); history = browser.getEngine().getHistory(); backButton = new Button(null, new ImageView(new Image("res/BrowserIcons/back.png"))); backButton.setOnAction( (ActionEvent e) -> { if (!checkIntConnection(defaultUrl)) { alert(); } else browser.getEngine().load(goBack()); }); backButton.addEventHandler( MouseEvent.MOUSE_ENTERED, event -> backButton.setEffect(new DropShadow())); backButton.addEventHandler(MouseEvent.MOUSE_EXITED, event -> backButton.setEffect(null)); forwardButton = new Button(null, new ImageView(new Image("res/BrowserIcons/forward.png"))); forwardButton.setOnAction( (ActionEvent e) -> { if (!checkIntConnection(defaultUrl)) { alert(); } else browser.getEngine().load(goForward()); }); forwardButton.addEventHandler( MouseEvent.MOUSE_ENTERED, event -> forwardButton.setEffect(new DropShadow())); forwardButton.addEventHandler(MouseEvent.MOUSE_EXITED, event -> forwardButton.setEffect(null)); reloadButton = new Button(null, new ImageView(new Image("res/BrowserIcons/reload.png"))); reloadButton.setOnAction( event -> { if (!checkIntConnection(defaultUrl)) { alert(); } else browser.getEngine().reload(); }); reloadButton.addEventHandler( MouseEvent.MOUSE_ENTERED, event -> reloadButton.setEffect(new DropShadow())); reloadButton.addEventHandler(MouseEvent.MOUSE_EXITED, event -> reloadButton.setEffect(null)); goButton = new Button(null, new ImageView(new Image("res/BrowserIcons/go.jpg"))); goButton.setOnAction( event -> { // adding the http or https prefix if user didn't type it if (!checkIntConnection(defaultUrl)) { alert(); } else { if (url.getText().length() > 7 && (url.getText(0, 7).equals("http://") || url.getText(0, 8).equals("https://"))) { browser.getEngine().load(url.getText()); } else if (url.getText().length() > 7 && !url.getText(0, 7).equals("http://")) { browser.getEngine().load("http://" + url.getText()); } else { browser.getEngine().load("https://" + url.getText()); } } }); goButton.addEventHandler( MouseEvent.MOUSE_ENTERED, event -> goButton.setEffect(new DropShadow())); goButton.addEventHandler(MouseEvent.MOUSE_EXITED, event -> goButton.setEffect(null)); webHistoryComboBox = new ComboBox(); webHistoryComboBox.setPromptText("Web History"); webHistoryComboBox.setPrefWidth(200); webHistoryComboBox.setOnAction( event -> { // Navigate to the link in the history index int offset = webHistoryComboBox.getSelectionModel().getSelectedIndex() - history.getCurrentIndex(); history.go(offset); }); // Displying browse history in a combo box history .getEntries() .addListener( (ListChangeListener<WebHistory.Entry>) c -> { c.next(); for (WebHistory.Entry e : c.getRemoved()) webHistoryComboBox.getItems().remove(e.getUrl()); for (WebHistory.Entry e : c.getAddedSubList()) webHistoryComboBox.getItems().add(e.getUrl()); }); // Enabling and Disabling back and forward buttons browser .getEngine() .getLoadWorker() .stateProperty() .addListener( (observable, oldValue, newValue) -> { if (!browser.getEngine().getHistory().getEntries().isEmpty()) { int index = browser.getEngine().getHistory().getCurrentIndex(); url.setText(browser.getEngine().getHistory().getEntries().get(index).getUrl()); if (index == 0) { backButton.setDisable(true); } else { backButton.setDisable(false); } if (browser.getEngine().getHistory().getEntries().size() == 1) { forwardButton.setDisable(true); } else if (index < browser.getEngine().getHistory().getEntries().size() - 2) { forwardButton.setDisable(false); } else if (index < browser.getEngine().getHistory().getEntries().size() - 1) { forwardButton.setDisable(false); } else if (index == browser.getEngine().getHistory().getEntries().size() - 1) { forwardButton.setDisable(true); } } }); progress.setPrefSize(25, 25); progress.visibleProperty().bind(browser.getEngine().getLoadWorker().runningProperty()); BorderPane border = new BorderPane(); HBox topBar = new HBox(); topBar.setAlignment(Pos.CENTER); topBar.setSpacing(10); topBar.setPadding(new Insets(10, 10, 10, 10)); topBar .getChildren() .addAll( progress, reloadButton, url, goButton, backButton, forwardButton, webHistoryComboBox); border.setTop(topBar); border.setCenter(browser); border.setPrefHeight(Screen.getPrimary().getVisualBounds().getHeight()); border.setPrefWidth(Screen.getPrimary().getVisualBounds().getWidth()); return border; }