Пример #1
0
  public static Tuple2<Label, VBox> getTradeInputBox(HBox amountValueBox, String descriptionText) {
    Label descriptionLabel = new Label(descriptionText);
    descriptionLabel.setId("input-description-label");
    descriptionLabel.setPrefWidth(170);

    VBox box = new VBox();
    box.setSpacing(4);
    box.getChildren().addAll(descriptionLabel, amountValueBox);
    return new Tuple2<>(descriptionLabel, box);
  }
Пример #2
0
  public static Tuple3<HBox, InputTextField, Label> getValueCurrencyBox(String promptText) {
    InputTextField input = new InputTextField();
    input.setPrefWidth(170);
    input.setAlignment(Pos.CENTER_RIGHT);
    input.setId("text-input-with-currency-text-field");
    input.setPromptText(promptText);

    Label currency = new Label();
    currency.setId("currency-info-label");

    HBox box = new HBox();
    box.getChildren().addAll(input, currency);
    return new Tuple3<>(box, input, currency);
  }
Пример #3
0
  @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();
  }
  public entryView(Object object) {
    getChildren().clear();
    getStylesheets().add("css/entryView.css");
    giveNode(object);

    BorderPane mainpane = new BorderPane();
    BorderPane centerpane = new BorderPane();
    BorderPane bottompane = new BorderPane();
    GridPane divgrid = new GridPane();
    GridPane maingrid = new GridPane();
    Label emptylab = new Label();
    Label divlab = new Label();
    VBox options = new VBox();
    VBox tlist = new VBox();
    Button ok = new Button("ok");
    Periods periods = new Periods();
    TList loadteacher = new TList();
    DatePicker date = new DatePicker();
    BorderPane datepane = new BorderPane();
    BorderPane nextpane = new BorderPane();
    Button next = new Button("next");

    options.setId("options");
    tlist.setId("tlist");
    divgrid.setId("divgrid");
    bottompane.setId("bottompane");
    periods.setId("period");
    divlab.setId("divlabel");
    datepane.setId("datepane");
    nextpane.setId("nextpane");

    emptylab.setPrefHeight(100);
    bottompane.setStyle("-fx-background-color:#ecf0f1;");

    StringConverter converter =
        new StringConverter<LocalDate>() {
          DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");

          @Override
          public String toString(LocalDate date) {
            if (date != null) {
              return dateFormatter.format(date);
            } else {
              return "";
            }
          }

          @Override
          public LocalDate fromString(String string) {
            if (string != null && !string.isEmpty()) {
              return LocalDate.parse(string, dateFormatter);
            } else {
              return null;
            }
          }
        };
    date.setConverter(converter);
    date.setPromptText("dd-MM-yyyy".toLowerCase());

    date.setValue(LocalDate.now());

    maingrid = div.loadDiv();
    list = (ListView) div.takelist();
    periods.period();
    list.getSelectionModel().select(0);
    divlab.setText((String) list.getItems().get(0));
    list.setOnMouseClicked(
        e -> {
          divlab.setText((String) list.getSelectionModel().getSelectedItem());
          periods.getChildren().clear();
          periods.period();
        });
    final Node node = maingrid.getChildren().get(0);
    Platform.runLater(
        new Runnable() {
          @Override
          public void run() {
            node.requestFocus();
          }
        });
    next.setOnAction(
        e -> {
          //			list.getSelectionModel().getSelectedIndex()+1
          list.getSelectionModel().select(list.getSelectionModel().getSelectedIndex() + 1);
          divlab.setText((String) list.getSelectionModel().getSelectedItem());
        });

    nextpane.setRight(next);
    datepane.setRight(date);
    options.getChildren().clear();
    options.getChildren().add(maingrid);
    divgrid.setHgap(5);
    //		divgrid.add(emptylab, 0, 1);
    divgrid.add(datepane, 1, 0);
    divgrid.add(divlab, 0, 2);
    divgrid.add(periods, 1, 2);
    divgrid.add(nextpane, 1, 3);
    divgrid.setAlignment(Pos.TOP_CENTER);
    mainpane.setCenter(centerpane);
    mainpane.setLeft(options);
    mainpane.setRight(loadteacher);
    centerpane.setCenter(divgrid);
    centerpane.setBottom(bottompane);
    bottompane.setRight(ok);

    addCloseButton cb = new addCloseButton();
    cb.addxb(1);
    setTop(cb);
    setCenter(mainpane);
  }