public void initLibrarianLayout() {
    ObservableList<Menu> menuList = this.menubar.getMenus();
    menuList.clear();

    Menu checkoutMenu = new Menu("Checkout");
    MenuItem checkoutBookItem = new MenuItem("checkout book");
    checkoutBookItem.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            showContentView(PUBLICATION_CHECKOUT);
          }
        });

    //        MenuItem recordItem = new MenuItem("checkout record");
    //        recordItem.setOnAction(new EventHandler<ActionEvent>() {
    //            @Override
    //            public void handle(ActionEvent event) {
    //                System.out.print("checkout record");
    //            }
    //        });

    ObservableList<MenuItem> itemList = checkoutMenu.getItems();
    itemList.add(checkoutBookItem);
    //        itemList.add(recordItem);
    menuList.add(checkoutMenu);
    showContentView(PUBLICATION_CHECKOUT);
  }
  @Override
  public void start(Stage stage) throws Exception {
    Parent root = createLayout();
    scene =
        SceneBuilder.create()
            .fill(new Color(0.5, 0.5, 0.5, 1.0))
            .root(root)
            .width(600)
            .height(400)
            .build();
    stage.setScene(scene);
    stage.show();

    // Add values to the spinner controls
    String[] months = new DateFormatSymbols().getMonths();
    ObservableList<String> dayList = FXCollections.observableArrayList();
    ObservableList<String> monthList = FXCollections.observableArrayList(months);
    ObservableList<String> yearList = FXCollections.observableArrayList();
    for (int i = 1; i <= 31; i++) {
      dayList.add(Integer.toString(i));
    }
    for (int i = 1970; i <= 2013; i++) {
      yearList.add(Integer.toString(i));
    }
    spinnerControlDay.setItems(dayList);
    spinnerControlMonth.setItems(monthList);
    spinnerControlYear.setItems(yearList);
  }
Example #3
0
  private ObservableList getYesNo() {
    ObservableList<String> YesNoList = FXCollections.observableArrayList();
    YesNoList.add("Yes");
    YesNoList.add("No");

    return YesNoList;
  }
 private void getusers() throws IOException {
   users.clear();
   int num = FromServer.readInt();
   for (int i = 0; i < num; i++) users.add(FromServer.readUTF());
   cbselectuser.getItems().clear();
   cbselectuser.getItems().addAll(users);
 }
 private void getgroupuser(String name) throws IOException {
   users.clear();
   ToServer.writeUTF("group_users");
   ToServer.writeUTF(repo);
   int num = FromServer.readInt();
   for (int i = 0; i < num; i++) users.add(FromServer.readUTF());
 }
  public void populateProdTypeValues() {
    try {

      Connection con = Main.dbConnection;
      if (!con.isValid(0)) {
        con = Main.reconnect();
      }
      productTypeValues.clear();
      PreparedStatement stmt =
          con.prepareStatement(
              "select value, code, seq, lov_lookup_id from lov_lookup where code='PRODUCT_TYPE' order by seq");
      ResultSet rs = stmt.executeQuery();
      while (rs.next()) {
        productTypeValues.add(rs.getString(1));
      }
      typeTF.getItems().addAll(productTypeValues);
    } catch (SQLException e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    } catch (Exception e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    }
  }
  private void updateSelection() {
    setItems();

    if (updating) return;
    updating = true;

    List<T> availableChoices = items.stream().collect(Collectors.toList());
    for (ChoiceBox<T> comboBox : comboBoxList) {
      if (comboBox.getValue() != null) {
        availableChoices.remove(comboBox.getValue());
      }
    }

    for (ChoiceBox<T> comboBox : comboBoxList) {
      T selectedValue = comboBox.getValue();
      ObservableList<T> items = comboBox.getItems();
      items.setAll(availableChoices);

      if (selectedValue != null) {
        items.add(selectedValue);
        comboBox.setValue(selectedValue);
      }
    }

    updating = false;
  }
Example #8
0
  @SuppressWarnings({"unchecked", "rawtypes"})
  public void initialize(URL url, ResourceBundle rb) {

    ObservableList<Medarbejder> data = FXCollections.observableArrayList();

    try {
      Connection con = dataaccess.getConnection();

      PreparedStatement prep =
          con.prepareStatement(
              "SELECT MEDARBEJDER.NAVN, EMAIL, MEDARBEJDER.AFDELING  FROM MEDARBEJDER");

      rs = prep.executeQuery();

      while (rs.next()) {

        data.add(
            new Medarbejder(rs.getString("navn"), rs.getString("email"), rs.getString("afdeling")));
      }

      viewNavn.setCellValueFactory(new PropertyValueFactory("navn"));
      viewEmail.setCellValueFactory(new PropertyValueFactory("email"));
      viewAfdeling.setCellValueFactory(new PropertyValueFactory("afdeling"));

      TableView.setItems(null);
      TableView.setItems(data);

    } catch (Exception e) {
      e.printStackTrace();
      System.out.println("Error on Building Data");
    }
  }
Example #9
0
  /**
   * Constructor
   *
   * @param eventBus
   */
  public CyclistController(EventBus eventBus) {
    this._eventBus = eventBus;
    _workspaces.add("/Users/yarden/software");
    _workspaces.add("/Users/yarden");

    load();
  }
  private void eliminar() {

    if (comboListar.getSelectionModel().getSelectedIndex() == 0) {
      eliminar(
          5,
          listaDatos.get(tablaResultados.getSelectionModel().getSelectedIndex()).getIdAutor(),
          6);
      txtfNombre.setText(null);
    }
    if (comboListar.getSelectionModel().getSelectedIndex() == 1) {
      eliminar(
          6,
          listaDatos.get(tablaResultados.getSelectionModel().getSelectedIndex()).getIdAutor(),
          7);
      txtfNombre.setText(null);
    }
    if (comboListar.getSelectionModel().getSelectedIndex() == 2) {
      eliminar(
          7,
          listaDatos.get(tablaResultados.getSelectionModel().getSelectedIndex()).getIdAutor(),
          8);
      txtfNombre.setText(null);
    }
    if (comboListar.getSelectionModel().getSelectedIndex() == 3) {
      eliminar(
          8,
          listaDatos.get(tablaResultados.getSelectionModel().getSelectedIndex()).getIdAutor(),
          5);
      txtfNombre.setText(null);
    }
  }
  private void initPane() {
    //		WebEngine engine = optionView.getEngine();
    try {
      Document document = Jsoup.connect(webView.getEngine().getLocation()).get();
      Element table =
          document.select("#normal_basket_" + document.select("[name=item_id]").val()).first();
      Element td = table.select("td").first();
      Elements spans = td.select("span");
      Elements selects = td.select("select");
      //			System.out.println(spans.size());
      cmb = new ArrayList<ComboBox>();
      for (int i = 0; i < spans.size(); i++) {

        ObservableList<ValuePair> obs = FXCollections.observableArrayList();
        Elements options = selects.get(i).select("option");
        for (int k = 0; k < options.size(); k++) {
          Element option = options.get(k);
          obs.add(new ValuePair("choice", option.text(), option.val()));
        }

        cmb.add(new ComboBox<ValuePair>(obs));
        optionArea.getChildren().addAll(new Text(spans.get(i).text()), cmb.get(i));
      }

    } catch (Exception e) {
      // TODO 自動生成された catch ブロック
      e.printStackTrace();
    }
  }
  public void editar(int opcion, int codigo, String campo, int lista) {

    if (tablaResultados.getSelectionModel().getSelectedItem() != null) {
      if (!nombre.equalsIgnoreCase(campo)) {
        consulta.editarGCJT(opcion, codigo, campo);
        if (consulta.getMensaje() != null) {
          Utilidades.mensajeAdvertencia(
              null, consulta.getMensaje(), "Error al editar la selección", "Error Guardar Cambios");
        } else {
          Utilidades.mensaje(
              null,
              "Los cambios se han guardado correctamente",
              "Editando Selección",
              "Actualización Exitosa");
          listaDatos.clear();
          listaDatos.addAll(consulta.llenarLista2(lista));
        }
      } else {
        Utilidades.mensaje(
            null, "No se han presentado cambios", "Editando Selección", "Editar Selección");
      }
    } else {
      Utilidades.mensaje(
          null, "Debe seleccionar un item de la lista", "Editando Selección", "Editar Selección");
    }
  }
  @FXML
  private void onTempModificationButtonClicked(MouseEvent event) throws IOException {
    PreparedStatement statement;
    ResultSet result;
    Connection connection;

    String insertStatement =
        "UPDATE ATRACAO SET DESCRICAO = \'"
            + textArea2.getText()
            + "\', CLASSIFICACAOETARIA = "
            + textField3.getText()
            + ",DATA = TO_DATE(\'"
            + textField6.getText()
            + "\',\'MM/DD/YYYY\')"
            + "WHERE ATRACAO.IDATRACAO = "
            + textField1.getText();
    System.out.println(insertStatement);
    try {
      Class.forName("oracle.jdbc.driver.OracleDriver");
      connection =
          DriverManager.getConnection(
              "jdbc:oracle:thin:@grad.icmc.usp.br:15215:orcl", "7960690", "a");
      System.out.println(insertStatement);
      statement = connection.prepareStatement(insertStatement);
      statement.executeUpdate();

      statement.close();
      connection.close();
      atracoes.get(currentSelectedRow).setDescricao(textArea2.getText());
      atracoes.get(currentSelectedRow).setClassificacaoEtaria(textField3.getText());
      atracoes.get(currentSelectedRow).setData(textField6.getText());
    } catch (SQLException | ClassNotFoundException ex) {
      Logger.getLogger(IncludeTupleController.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
  public PieChart fillChartPiePopBovinos() {

    HashMap<String, Integer> data = dataForChartEdadesySexo();
    int total = 0;
    Set<String> keySet = data.keySet();
    for (String key : keySet) {
      total = total + data.get(key);
    }
    ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList();

    System.out.println("total=" + total);
    int percent;
    double di;
    for (String key : keySet) {
      di = (double) data.get(key) / (double) total;
      percent = (int) (di * 100);
      pieChartData.add(new PieChart.Data(key, percent));
    }

    final PieChart chart = new PieChart(pieChartData);
    chart.setTitle("Población de Bovinos");

    // set it to pane
    return (chart);
  }
  public void btnRemoveAssistantOrProfessor_Pressed() {
    if (!listAssistantsOrProfessors.getSelectionModel().isEmpty()) {
      ObservableList<String> updatedElements = listAssistantsOrProfessors.getItems();

      String valueSelected = listAssistantsOrProfessors.getSelectionModel().getSelectedItem();
      String rut = valueSelected.split("-")[1];

      for (Professor professor : Manager.INSTANCE.professors) {
        if (rut.equals(professor.getRut())) {
          if (((Lecture) Manager.INSTANCE.currentEditignICourse)
              .getProfessors()
              .contains(professor)) {
            ((Lecture) Manager.INSTANCE.currentEditignICourse).removeProfessor(professor);
            updatedElements.remove(valueSelected);
            listAssistantsOrProfessors.setItems(updatedElements);
            break;
          } else {
            ViewUtilities.showAlert("El profesor no se encuentra registrado en la clase");
            break;
          }
        }
      }
    } else {
      ViewUtilities.showAlert("Primero debes seleccionar un profesor para quitar");
    }
  }
 public void SucheNachPolizist(int PersonenID) {
   Hauptprogramm.setMittlereAnsicht(getPolizistAnsicht());
   PolizistDatenListe.clear();
   ResultSet AnfrageAntwort;
   try {
     AnfrageAntwort =
         DH.getAnfrageObjekt()
             .executeQuery(
                 "SELECT PERSON.PersonenID, PERSON.Name, PERSON.Geburtsdatum, PERSON.Nationalität, PERSON.Geschlecht, PERSON.Todesdatum, POLIZIST.Dienstgrad "
                     + "FROM PERSON, POLIZIST WHERE PERSON.PersonenID = POLIZIST.PersonenID AND POLIZIST.PersonenID = "
                     + PersonenID);
     while (AnfrageAntwort.next()) {
       String Todesdatum = "";
       if (AnfrageAntwort.getObject(6) != null) {
         Todesdatum = AnfrageAntwort.getString(6);
       }
       PolizistDatenListe.add(
           new PolizistDaten(
               AnfrageAntwort.getInt(1),
               AnfrageAntwort.getString(2),
               AnfrageAntwort.getString(3),
               AnfrageAntwort.getString(4),
               AnfrageAntwort.getString(5),
               Todesdatum,
               AnfrageAntwort.getString(7)));
     }
   } catch (SQLException e) {
     IM.setErrorText("Unbekannter Fehler bei aktualisieren der Ansicht", e);
   }
 }
 @Override
 public void initialize(final URL url, final ResourceBundle resourceBundle) {
   final ObservableList<Node> children = content.getChildren();
   views.addAll(children);
   children.removeAll(views);
   children.add(views.get(0));
 }
 public void ZeigeSuchResultate(ResultSet R) {
   Hauptprogramm.setMittlereAnsicht(getPolizistAnsicht());
   PolizistDatenListe.clear();
   ResultSet AnfrageAntwort;
   try {
     AnfrageAntwort = R;
     while (AnfrageAntwort.next()) {
       String Todesdatum = "";
       if (AnfrageAntwort.getObject(6) != null) {
         Todesdatum = AnfrageAntwort.getString(6);
       }
       PolizistDatenListe.add(
           new PolizistDaten(
               AnfrageAntwort.getInt(1),
               AnfrageAntwort.getString(2),
               AnfrageAntwort.getString(3),
               AnfrageAntwort.getString(4),
               AnfrageAntwort.getString(5),
               Todesdatum,
               AnfrageAntwort.getString(7)));
     }
   } catch (SQLException e) {
     IM.setErrorText("Unbekannter Fehler bei aktualisieren der Ansicht", e);
   }
 }
  public void populateBillCategoryValues() {
    try {

      Connection con = Main.dbConnection;
      if (!con.isValid(0)) {
        con = Main.reconnect();
      }
      billCategoryValues = FXCollections.observableArrayList();
      PreparedStatement stmt =
          con.prepareStatement(
              "select distinct bill_category from point_name order by bill_category");
      ResultSet rs = stmt.executeQuery();
      while (rs.next()) {
        if (billCategoryValues != null && !billCategoryValues.contains(rs.getString(1)))
          billCategoryValues.add(rs.getString(1).toLowerCase());
      }
      billCategoryTF.setItems(billCategoryValues);
      new AutoCompleteComboBoxListener<>(billCategoryTF);
    } catch (SQLException e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    } catch (Exception e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    }
  }
  public static boolean writeFile(ObservableList<XYChart.Data> list, String path)
      throws FileNotFoundException {
    try {
      boolean newFile = false;
      File file = new File(path);
      System.out.println(file.exists());
      newFile = file.createNewFile();
      System.out.println(newFile);
      System.out.println(file.exists());
      PrintWriter printWriter;
      try {
        printWriter = new PrintWriter(new FileOutputStream(file));

        for (int i = 0; i < list.size(); i++) {
          String x = list.get(i).getXValue().toString();
          String y = list.get(i).getYValue().toString();
          String line = x + "\t" + y;
          printWriter.println(line);
        }
        printWriter.close();
      } catch (Exception ex) {
        return false;
      }
    } catch (IOException ex) {
      return false;
    }

    return true;
  }
 private void getgroupe() throws IOException {
   groups.clear();
   int num = FromServer.readInt();
   for (int i = 0; i < num; i++) groups.add(FromServer.readUTF());
   cbgroup.getItems().clear();
   cbgroup.getItems().addAll(groups);
 }
Example #22
0
  private void loadHistory() {
    history.clear();

    if (!Files.exists(streamPath, LinkOption.NOFOLLOW_LINKS)) {
      logger.debug("no stream exist ({})", streamPath);
      return;
    }
    logger.info("load history ({})", streamPath);

    try (InputStream inStream = Files.newInputStream(streamPath, StandardOpenOption.READ)) {
      try (ObjectInputStream oStream = new ObjectInputStream(inStream)) {
        Object o = null;
        while (inStream.available() > 0 && (o = oStream.readObject()) != null) {
          HistoryEntry dev = (HistoryEntry) o;
          logger.debug("read dev: {}", dev);
          if (!history.contains(dev)) {
            history.add(dev);
          } else {
            logger.error("device already exist ({})", dev);
          }
        }
      }
    } catch (Exception e) {
      logger.error(e.getMessage(), e);
      try {
        Files.deleteIfExists(streamPath);
      } catch (IOException e1) {
      }
    }
  }
 private void gettars() throws IOException {
   tars.clear();
   int num = FromServer.readInt();
   for (int i = 0; i < num; i++) tars.add(FromServer.readUTF());
   cbbackups.getItems().clear();
   cbbackups.getItems().addAll(tars);
 }
  /** Loads the name of all ingredients and puts them in ingredientlist. */
  public void updateIngredients() {
    ArrayList<ArrayList<String>> dataSet;
    ObservableList<String> itemList =
        FXCollections.observableArrayList(); // Observable arraylist for the listview

    try {
      System.out.println("- Main updateIngredientsRecipList");

      dataSet = fetchData("Ingredients", "Name"); // Gives the arraylist the ingredientnames

      for (ArrayList<String> element : dataSet) {
        itemList.add(element.get(0)); // For every element in the array, get name
      }

      System.out.println("- end of Main updateIngredientsRecipList");
    } catch (SQLException e) {
      e.printStackTrace();
    }
    recipeIngredients.setItems(itemList); // Sets the Listview to show the obs arraylist

    itemList.clear();
    try {
      dataSet = fetchData("Units", "*");

      for (ArrayList<String> element : dataSet) {
        itemList.add(element.get(1));
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    ingredientUnit.setItems(itemList);
  }
 /**
  * Generates a list of the macros that have been created.
  *
  * @return The list of macros.
  */
 public ObservableList<String> getMacroList() {
   ObservableList<String> macroNames = FXCollections.observableArrayList();
   for (String key : recordedTaskMacros.keySet()) {
     macroNames.add(key);
   }
   return macroNames;
 }
  private void setupStageLocation(Stage stage) {
    ObservableList<Screen> screens = Screen.getScreens();
    Screen screen =
        screens.size() <= screenNumber ? Screen.getPrimary() : screens.get(screenNumber);

    Rectangle2D bounds = screen.getBounds();
    boolean primary =
        screen.equals(
            Screen.getPrimary()); // WORKAROUND: this doesn't work nice in combination with full
    // screen, so this hack is used to prevent going fullscreen when
    // screen is not primary

    if (primary) {
      stage.setX(bounds.getMinX());
      stage.setY(bounds.getMinY());
      stage.setWidth(bounds.getWidth());
      stage.setHeight(bounds.getHeight());
      stage.setFullScreen(true);
    } else {
      stage.setX(bounds.getMinX());
      stage.setY(bounds.getMinY());
      stage.setWidth(bounds.getWidth());
      stage.setHeight(bounds.getHeight());
      stage.toFront();
    }
  }
Example #27
0
  private ObservableList getGender() {
    ObservableList<String> maritalStatus = FXCollections.observableArrayList();
    maritalStatus.add("Male");
    maritalStatus.add("Female");

    return maritalStatus;
  }
  public void btnAddAssistantOrProfessor_Pressed() {
    if (!chBxAssistantsOrProfessors.getSelectionModel().isEmpty()) {
      ObservableList<String> updatedElements = listAssistantsOrProfessors.getItems();

      String valueSelected = chBxAssistantsOrProfessors.getSelectionModel().getSelectedItem();
      String rut = valueSelected.split("-")[valueSelected.split("-").length - 1];

      for (Professor professor : Manager.INSTANCE.professors) {
        if (rut.equals(professor.getRut())) {
          if (!((Lecture) Manager.INSTANCE.currentEditignICourse)
              .getProfessors()
              .contains(professor)) {
            ((Lecture) Manager.INSTANCE.currentEditignICourse).addProfessor(professor);
            updatedElements.add(valueSelected);
            listAssistantsOrProfessors.setItems(FXCollections.observableArrayList(updatedElements));
            break;
          } else {
            ViewUtilities.showAlert("El profesor ya se encuentra en ese curso");
            break;
          }
        }
      }
    } else {
      ViewUtilities.showAlert("Select a professor to add");
    }
  }
Example #29
0
  // wyœwietla wszystkie playlisty
  private void drawPlaylists() {
    for (int i = 0; i < playlistList.size(); i++) {
      VBox vBox = new VBox(5);

      ImageView playlistCover =
          new ImageView(new Image(new File("temp_cover.png").toURI().toString()));
      playlistCover.setFitWidth(130);
      playlistCover.setPreserveRatio(true);
      playlistCover.setSmooth(true);

      int ext = playlistList.get(i).getName().lastIndexOf('.');
      Text playlistTitle = new Text(playlistList.get(i).getName().substring(0, ext));
      playlistTitle.getStyleClass().add("text");
      vBox.getChildren().addAll(playlistCover, playlistTitle);
      vBox.setAlignment(Pos.CENTER);

      vBox.setOnMouseClicked(
          e -> {
            Text tempText = (Text) vBox.getChildren().get(1);
            showCurrentPlaylist(new File("Playlists/" + tempText.getText() + ".fpl"));
          });

      flowPane.getChildren().add(vBox);
    }
  }
 public void load3(Event event) {
   f.clear();
   String extra;
   String[] extra1;
   HashMap<String, Integer> h = new HashMap<String, Integer>();
   try {
     BufferedReader x = new BufferedReader(new FileReader("./src/Expenses.txt"));
     extra = x.readLine();
     extra = x.readLine();
     extra = x.readLine();
     while ((extra = x.readLine()) != null) {
       extra1 = extra.split(" ");
       if (h.containsKey(extra1[0])) {
         h.put(extra1[0], h.get(extra1[0]) + Integer.parseInt(extra1[1]));
       }
       h.put(extra1[0], Integer.parseInt(extra1[1]));
     }
     Set<String> keys = h.keySet();
     for (String key : keys) {
       f.add(new PieChart.Data(key, h.get(key)));
     }
     x.close();
     chr.setData(f);
   } catch (IOException ex) {
     ex.printStackTrace();
   }
 }