Skip to content

Commit

Permalink
damn bug
Browse files Browse the repository at this point in the history
  • Loading branch information
smmhatami committed Jun 26, 2020
1 parent 27d3d1f commit b583b2a
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/main/java/database.txt

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions src/main/java/newViewBagheri/ProductMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@

import controller.ProductController;
import controller.userControllers.UserController;
import javafx.event.ActionEvent;
import javafx.fxml.Initializable;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import newViewNedaei.MenuController;

import java.net.URL;
import java.nio.file.Paths;
import java.util.*;

public class ProductMenu implements Initializable {
Expand All @@ -34,6 +40,7 @@ public class ProductMenu implements Initializable {
public GridPane featuresListPain;
public VBox commentsList;
public Label errorLabelForAddComment;
public MediaView mediaView;
public GridPane SimilarProductsListPain;

public static String getFxmlFilePath() {
Expand All @@ -44,6 +51,7 @@ public static String getFxmlFilePath() {
public void initialize(URL location, ResourceBundle resources) {
addProductInformation();
addImage();
addVideo();
addDefaultSellerInfo();
addSellersList();
addFeaturesList();
Expand All @@ -64,6 +72,15 @@ private void addImage() {
// productImageView.setImage(new Image(convertPhotoPath(productController.getActiveProduct().getImageAddress())));
}

private void addVideo() {
String path = productController.getActiveProduct().getVideoAddress();
if (path == null)
return;
Media media = new Media(Paths.get(path).toUri().toString());
mediaView.setMediaPlayer(new MediaPlayer(media));
mediaView.getMediaPlayer().setOnEndOfMedia(mediaView.getMediaPlayer().getOnRepeat());
}

private void addDefaultSellerInfo() {
HashMap<String, String> defaultSellerInfo = productController.getActiveSellInfo();
sellerNameLabel.setText("seller: " + defaultSellerInfo.get("sellerUsername"));
Expand Down Expand Up @@ -180,6 +197,16 @@ private VBox createProductInfoVBox(HashMap<String, String> productInfo) {
return productInfoVBox;
}



public void videoClicked(MouseEvent mouseEvent) {
mediaView.getMediaPlayer().play();
}

public void puaseVideo(ActionEvent actionEvent) {
mediaView.getMediaPlayer().pause();
}

private void setLabelStyle(Label label, int prefWidth, int prefHeight) {
label.setPrefWidth(prefWidth);
label.setPrefHeight(prefHeight);
Expand Down
9 changes: 6 additions & 3 deletions src/main/resources/AddProductPanel.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<Label fx:id="existingError" prefHeight="25.0" prefWidth="200.0" textFill="red" GridPane.columnIndex="1" GridPane.rowIndex="3" />
</children>
</GridPane>
<GridPane fx:id="newPane" layoutY="25.0" prefHeight="275.0" prefWidth="400.0">
<GridPane fx:id="newPane" layoutY="25.0" prefHeight="309.0" prefWidth="400.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="100.0" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
Expand All @@ -43,10 +43,11 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="25.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Button mnemonicParsing="false" onMouseClicked="#sendNew" prefHeight="25.0" prefWidth="100.0" text="Send Request" GridPane.columnIndex="2" GridPane.rowIndex="6" />
<Button mnemonicParsing="false" onMouseClicked="#sendNew" prefHeight="25.0" prefWidth="100.0" text="Send Request" GridPane.columnIndex="2" GridPane.rowIndex="7" />
<Label alignment="CENTER" prefHeight="50.0" prefWidth="100.0" text="Product Name" />
<Label alignment="CENTER" prefHeight="50.0" prefWidth="100.0" text="Category Name" GridPane.rowIndex="1" />
<Label alignment="CENTER" prefHeight="50.0" prefWidth="100.0" text="Description" GridPane.rowIndex="2" />
Expand All @@ -57,9 +58,11 @@
<TextField fx:id="description" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<ValidatorField fx:id="newPrice" onKeyReleased="#validate" validation="naturalNumber" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<ValidatorField fx:id="newStock" onKeyReleased="#validate" validation="naturalNumber" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<Label fx:id="newError" prefHeight="25.0" prefWidth="200.0" textFill="red" GridPane.columnIndex="1" GridPane.rowIndex="6" />
<Label fx:id="newError" prefHeight="25.0" prefWidth="200.0" textFill="red" GridPane.columnIndex="1" GridPane.rowIndex="7" />
<Label alignment="CENTER" prefHeight="37.0" prefWidth="110.0" text="photo" GridPane.rowIndex="5" />
<Button mnemonicParsing="false" onAction="#pickPhoto" prefHeight="26.0" prefWidth="84.0" text="browse" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<Label alignment="CENTER" layoutX="10.0" layoutY="219.0" prefHeight="37.0" prefWidth="110.0" text="video" GridPane.rowIndex="6" />
<Button layoutX="110.0" layoutY="224.0" mnemonicParsing="false" onAction="#pickVideo" prefHeight="26.0" prefWidth="84.0" text="browse" GridPane.columnIndex="1" GridPane.rowIndex="6" />
</children>
</GridPane>
</children>
Expand Down
24 changes: 10 additions & 14 deletions src/main/resources/ProductMenu.fxml
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.media.MediaView?>
<?import javafx.scene.text.Text?>

<AnchorPane prefHeight="600.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="newViewBagheri.ProductMenu">
<AnchorPane prefHeight="600.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="newViewBagheri.ProductMenu">
<children>
<VBox layoutX="227.0" layoutY="86.0" prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
Expand Down Expand Up @@ -65,15 +55,21 @@
</GridPane>
<Label text="Description:" GridPane.rowIndex="3" />
<Text fx:id="descriptionText" GridPane.rowIndex="4" />
<MediaView fx:id="mediaView" fitHeight="200.0" fitWidth="200.0" onMouseClicked="#videoClicked" GridPane.columnIndex="2" GridPane.rowIndex="5" />
<Button mnemonicParsing="false" onAction="#puaseVideo" text="puase" GridPane.columnIndex="2" GridPane.rowIndex="6" />
<columnConstraints>
<ColumnConstraints />
<ColumnConstraints />
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
</rowConstraints>
</GridPane>
</center>
Expand Down
Binary file added src/main/resources/photos/1.mp4
Binary file not shown.
Binary file added src/main/resources/photos/19.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/photos/2.mp4
Binary file not shown.
Binary file added src/main/resources/photos/21.mp4
Binary file not shown.
Binary file added src/main/resources/photos/3.mp4
Binary file not shown.
Binary file added src/main/resources/photos/4.mp4
Binary file not shown.
Binary file added src/main/resources/photos/5.mp4
Binary file not shown.

0 comments on commit b583b2a

Please sign in to comment.