public void open() throws IOException { paneCenter.getChildren().clear(); String station = (String) cbStations.getValue(); File f = new File("database\\" + station + "\\status.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); paneCenter.add(new Label("Last seen : " + (br.readLine())), 0, 0); for (int i = 1; i < count; i++) { paneCenter.add(new Label(br.readLine()), 0, i); } br.close(); fr2.close(); addQuantityToCB(); }
@Override public void initialize(URL location, ResourceBundle resources) { // TODO 自動生成されたメソッド・スタブ addOption.setOnAction( event -> { for (int i = 0; i < cmb.size(); i++) { // System.out.println(cmb.get(i).getValue()); if (cmb.get(i).getValue() == null) { break; } else if (i == cmb.size() - 1) { addTask.setDisable(false); } } }); addTask.setOnAction( event -> { try { String url = webView.getEngine().getLocation(); System.out.println(url); Document document = Jsoup.connect(url).get(); Elements input = document.select("input"); Map params = new HashMap<String, String>(); for (ComboBox cmbx : cmb) { ValuePair vp = (ValuePair) cmbx.getValue(); params.put(vp.getName(), vp.getvalue()); } // System.out.println(input.select("[name=shop_bid]").first()); // System.out.println(input.select("[name=shop_bid]").first().val()); params.put("shop_bid", input.select("[name=shop_bid]").first().val()); params.put("item_id", input.select("[name=item_id]").first().val()); params.put("__event", input.select("[name=__event]").first().val()); params.put("units", "1"); Map map = new HashMap<String, Long>(); // System.out.println(document.select("#stime").size()); if (document.select("#stime").size() != 0) { System.out.println(document.select("#stime")); map.put("stime", Long.parseLong((input.select("#stime").first().val()))); map.put("etime", Long.parseLong((input.select("#etime").first().val()))); } else { map = null; } BuyTask task = new BuyTask(url, params, map); task.call(); this.getScene().getWindow().hide(); } catch (Exception e) { // TODO 自動生成された catch ブロック e.printStackTrace(); } }); }
public void showGraph() { Stage secondaryStage = new Stage(); String quantity = (String) cbQuantity.getValue().toString(); secondaryStage.setTitle(quantity); LineChart<Long, Number> lc = null; switch (quantity) { case "Wind Speed": windSerie.add(new XYChart.Series<>("Wind Speed", windData)); lc = new LineChart<>(new DateAxis(), new NumberAxis("Value", 0, 130, 10), windSerie); break; case "Temperature": temperatureSerie.add(new XYChart.Series<>("Temperature", temperatureData)); lc = new LineChart<>(new DateAxis(), new NumberAxis("Value", 0, 50, 10), temperatureSerie); break; case "Rainfall Rate": rainfallSerie.add(new XYChart.Series<>("Rainfall Rate", rainfallData)); lc = new LineChart<>(new DateAxis(), new NumberAxis("Value", 0, 100, 10), rainfallSerie); break; case "Humidity": humiditySerie.add(new XYChart.Series<>("Humidity", humidityData)); lc = new LineChart<>(new DateAxis(), new NumberAxis("Value", 0, 100, 10), humiditySerie); break; case "Pressure": pressureSerie.add(new XYChart.Series<>("Pressure", pressureData)); lc = new LineChart<>(new DateAxis(), new NumberAxis("Value", 0, 20, 10), pressureSerie); break; } graphic = new Scene(lc, 500, 250); secondaryStage.setScene(graphic); secondaryStage.show(); }
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(); }