コード例 #1
0
  @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();
          }
        });
  }
コード例 #2
0
  @Override
  public void initialize(URL location, ResourceBundle resources) {
    urlField.setOnAction(
        event -> {
          String text = urlField.getText();
          urlField.setText("tetetetetetetete");
          webView.getEngine().load(text);
        });

    webView
        .getEngine()
        .getLoadWorker()
        .stateProperty()
        .addListener(
            (ov, oldState, newState) -> {
              if (newState == State.SUCCEEDED) {
                String url = webView.getEngine().getLocation();
                urlField.setText(url);
                if (Pattern.compile("http://item.rakuten.co.jp/.*").matcher(url).find()) {
                  try {
                    Elements tmp;
                    Document document = Jsoup.connect(url).get();
                    tmp = document.select("input");
                    tmp = tmp.select("#etime");
                    if (tmp.size() != 0) {
                      if (!(Long.parseLong(tmp.first().val()) < new Date().getTime())) {
                        entryButton.setDisable(false);
                      }
                    } else {
                      entryButton.setDisable(false);
                    }
                  } catch (Exception e) {
                    // TODO 自動生成された catch ブロック
                    e.printStackTrace();
                  }
                }
              }
              ;
            });

    entryButton.setOnAction(
        event -> {
          urlField.setText("webView disable");
          sendEntryTaskController();
        });
  }
コード例 #3
0
ファイル: CollectorGui.java プロジェクト: MattPfenn/Java_work
  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();
  }