Skip to content

Commit

Permalink
Merge pull request #17 from AdvProg2020/final-debug2
Browse files Browse the repository at this point in the history
last fix
  • Loading branch information
amirarab888 authored Jun 26, 2020
2 parents 49a763e + 1b36811 commit cb4a8b2
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 14 deletions.
7 changes: 4 additions & 3 deletions src/main/java/Model/Category.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Category extends SaveAble {
private static ArrayList<Category> allCategories = new ArrayList<>();
private String name;
private ArrayList<String> tags;
private ArrayList<String> subCategories;
private ArrayList<String> subCategories = new ArrayList<>();
private ArrayList<String> products;

public Category(String name, ArrayList<String> tags, ArrayList<String> products, ArrayList<String> subCategories) {
Expand All @@ -20,6 +20,7 @@ public Category(String name, ArrayList<String> tags, ArrayList<String> products,
this.subCategories = subCategories;
this.products = products;
for (String product: products) {
System.out.println(Product.getProductWithBarcode(product));
Product.getProductWithBarcode(product).setCategoryTags(tags);
}
allCategories.add(this);
Expand Down Expand Up @@ -49,8 +50,8 @@ public String getName() {
return name;
}

public ArrayList<String> getTags() {
return tags;
public String getTags() {
return tags.toString();
}

public String getSubCategories() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Model/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public static String givenUsingPlainJava_whenGeneratingRandomStringUnbounded_the
}

public void setCategoryTags(ArrayList<String> categoryTags) {
this.categoryTags.addAll(categoryTags);
this.tags.addAll(categoryTags);
}


Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/example/ProductPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static void setProduct(Product product) {
}

public void addToCart() {

Controller.getOurController().requestAddProductToCart(product.getProductBarcode());
}

Expand Down Expand Up @@ -81,6 +82,7 @@ public void initialize() {
}
for (MenuItem menuItem : menuItems) {
sellers.getItems().add(menuItem);

menuItem.setOnAction(event -> Controller.getOurController().setNameOfSellerOfProductAddedToCart(menuItem.getText()));
}

Expand Down
22 changes: 15 additions & 7 deletions src/main/java/org/example/ProductsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public void initialize() {
max = product.getCost();
}
slider.setMax(max + 20);
slider.setValue(max + 20);
slider.valueProperty().addListener(
new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number > observable, Number oldValue, Number newValue)
Expand Down Expand Up @@ -154,18 +155,21 @@ private void activeAvailable( CheckBox checkBox) {

private void categoryCheckBoxInitialize(int i, int y, HashSet tags) {
for (Product product : Product.getAllProducts()) {
if (product.getCategory() == null) {
continue;
}
if (tags.contains(product.getCategory())) {
continue;
}
Category category;
CheckBox checkBox;
if((category = Category.getCategoryByName(product.getCategory())) == null){
if((category = Category.getCategoryByName(product.getCategory())) != null && product.getCategory() !=null){
checkBox = new CheckBox("catgory :" + product.getCategory() + "subcat" + category.getSubCategories() + "tags" + category.getTags());
}else {
}else{
checkBox = new CheckBox("catgory :" + product.getCategory());
}
checkBox.setLayoutX(i);
i += 50;
i += 500;
checkBox.setLayoutY(y);
mainAnchorPane.getChildren().add(checkBox);
tags.add(product.getCategory());
Expand All @@ -184,12 +188,16 @@ private void categoryActive(String catName, CheckBox checkBox) {
return;
}
if(checkBox.isSelected()){
for (String categoryTag : category.getTags()) {
filters.add(categoryTag);
for (String categoryTag : category.getTags().substring(category.getTags().indexOf("[") +1, category.getTags().lastIndexOf("]")).split(",")) {
// System.out.println(categoryTag);
// categoryTag = categoryTag.substring(categoryTag.indexOf("\""), categoryTag.lastIndexOf("\""));
// System.out.println(categoryTag);
filters.add(categoryTag.trim());
}
}else{
for (String categoryTag : category.getTags()) {
filters.remove(categoryTag);
for (String categoryTag : category.getTags().substring(category.getTags().indexOf("[") +1, category.getTags().lastIndexOf("]")).split(",")) {
// categoryTag = categoryTag.substring(categoryTag.indexOf("\""), categoryTag.lastIndexOf("\""));
filters.remove(categoryTag.trim());
}
}
fullFilter();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/org/example/ProductsPage.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
<ListView fx:id="sortList" layoutX="699.0" layoutY="40.0" onMouseClicked="#sortAction" prefHeight="275.0" prefWidth="247.0" />
<Button fx:id="reverseButton" layoutX="630.0" layoutY="47.0" onAction="#reverse" text="increase" />
<Button layoutX="74.0" layoutY="15.0" mnemonicParsing="false" onAction="#switchToAccountPage" text="Account" />
<Slider fx:id="slider" layoutX="150" showTickMarks="true" showTickLabels="true" minorTickCount="5" majorTickUnit="50" layoutY="317" />
<Slider fx:id="slider" layoutX="150" showTickMarks="true" showTickLabels="true" minorTickCount="5" majorTickUnit="200" layoutY="317" />
<Label text="Cost filter" layoutX="190" alignment="CENTER" layoutY="300"/>
</AnchorPane>
1 change: 0 additions & 1 deletion src/main/resources/org/example/manager-products.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
</columns>
</TableView>
<Button fx:id="removeButton" layoutX="573.0" layoutY="285.0" mnemonicParsing="false" onAction="#remove" text="remove" />
<TextField fx:id="descriptionField" layoutX="18.0" layoutY="285.0" prefHeight="25.0" prefWidth="234.0" promptText="description" />
<Button layoutX="14.0" layoutY="361.0" mnemonicParsing="false" onAction="#switchToAccountPage" text="Account" />
</children>
</AnchorPane>
2 changes: 1 addition & 1 deletion src/main/resources/org/example/users-managing.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<children>
<TableView fx:id="table" layoutX="7.0" layoutY="9.0" prefHeight="286.0" prefWidth="590.0">
<columns>
<TableColumn fx:id="userName" editable="false" prefWidth="75.0" text="OffCode barcode" />
<TableColumn fx:id="userName" editable="false" prefWidth="75.0" text="userName" />
</columns>
</TableView>
<TextField fx:id="user" layoutX="7.0" layoutY="305.0" prefHeight="25.0" prefWidth="68.0" promptText="userName" />
Expand Down

0 comments on commit cb4a8b2

Please sign in to comment.