-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lenovo
committed
Jul 24, 2020
1 parent
ed7984c
commit 34f9ef2
Showing
89 changed files
with
1,083 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/graphicView/userRegion/userAccount/managerAccount/AddCategoryPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package graphicView.userRegion.userAccount.managerAccount; | ||
|
||
import graphicView.userRegion.userAccount.PurchaserAccountPage; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.stage.Stage; | ||
import main.Main; | ||
|
||
import java.io.IOException; | ||
|
||
public class AddCategoryPage { | ||
static Stage primaryStage; | ||
|
||
public static void display() throws IOException { | ||
Main.setMediaPlayer("The Swimmer.mp3"); | ||
primaryStage = new Stage(); | ||
Parent root = FXMLLoader.load(AddCategoryPage.class.getResource("/graphicView/userRegion/userAccount/managerAccount/AddCategory.fxml")); | ||
primaryStage.setTitle("Hello World"); | ||
Scene scene = new Scene(root); | ||
primaryStage.setScene(scene); | ||
primaryStage.setMaximized(true); | ||
Main.setAccountRegionStage(primaryStage); | ||
primaryStage.show(); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...ain/java/graphicView/userRegion/userAccount/managerAccount/AddCategoryPageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package graphicView.userRegion.userAccount.managerAccount; | ||
|
||
import controller.LoginPageController; | ||
import controller.ManagerAccountController; | ||
import exception.CategoryNotExistsException; | ||
import graphicView.mainMenu.MainMenu; | ||
import graphicView.userRegion.loginPanel.LoginPanelController; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.TextField; | ||
import javafx.scene.paint.Color; | ||
import main.Main; | ||
|
||
import java.io.IOException; | ||
|
||
public class AddCategoryPageController { | ||
public TextField categoryName; | ||
public TextField parentName; | ||
public TextField imageName; | ||
public Label alertMessage; | ||
|
||
@FXML | ||
public void logout() throws IOException { | ||
AddCategoryPage.primaryStage.close(); | ||
LoginPageController.logout(); | ||
LoginPanelController.setLoggedInAccount(null); | ||
MainMenu.display(Main.window); | ||
} | ||
@FXML | ||
public void back() throws IOException { | ||
AddCategoryPage.primaryStage.close(); | ||
ViewAllCategoriesPage.display(); | ||
} | ||
@FXML | ||
public void add(){ | ||
String name = categoryName.getText(); | ||
String parent = parentName.getText(); | ||
String image = imageName.getText(); | ||
try { | ||
ManagerAccountController.processAddCategoryEach(name,parent,image); | ||
alertMessage.setTextFill(Color.GREEN); | ||
alertMessage.setText("Add Category successful!"); | ||
} catch (CategoryNotExistsException e) { | ||
alertMessage.setTextFill(Color.RED); | ||
alertMessage.setText(e.getMessage()); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/graphicView/userRegion/userAccount/managerAccount/AddManagerPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package graphicView.userRegion.userAccount.managerAccount; | ||
|
||
import graphicView.userRegion.userAccount.PurchaserAccountPage; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.stage.Stage; | ||
import main.Main; | ||
|
||
import java.io.IOException; | ||
|
||
public class AddManagerPage { | ||
static Stage primaryStage; | ||
|
||
public static void display() throws IOException { | ||
Main.setMediaPlayer("The Swimmer.mp3"); | ||
primaryStage = new Stage(); | ||
Parent root = FXMLLoader.load(PurchaserAccountPage.class.getResource("/graphicView/userRegion/userAccount/managerAccount/AddManager.fxml")); | ||
primaryStage.setTitle("Hello World"); | ||
Scene scene = new Scene(root); | ||
primaryStage.setScene(scene); | ||
primaryStage.setMaximized(true); | ||
Main.setAccountRegionStage(primaryStage); | ||
primaryStage.show(); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
...main/java/graphicView/userRegion/userAccount/managerAccount/AddManagerPageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package graphicView.userRegion.userAccount.managerAccount; | ||
|
||
import controller.LoginPageController; | ||
import graphicView.mainMenu.MainMenu; | ||
import graphicView.userRegion.loginPanel.LoginPanelController; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.TextField; | ||
import main.Main; | ||
import model.account.Manager; | ||
|
||
import java.io.IOException; | ||
|
||
import static javafx.scene.paint.Color.GREEN; | ||
|
||
public class AddManagerPageController { | ||
public TextField newFirstName; | ||
public TextField newLastName; | ||
public TextField newUserName; | ||
public TextField newPassWord; | ||
public TextField newEmail; | ||
public TextField newPhoneNumber; | ||
public Label alertMessage; | ||
|
||
@FXML | ||
public void addManager(){ | ||
String firstName = newFirstName.getText(); | ||
String lastName = newLastName.getText(); | ||
String userName = newUserName.getText(); | ||
String passWord = newPassWord.getText(); | ||
String email = newEmail.getText(); | ||
String phoneNumber = newPhoneNumber.getText(); | ||
if(!firstName.matches("[a-zA-Z]+")){ | ||
alertMessage.setText("Please enter a valid first name!"); | ||
return; | ||
} | ||
if(!lastName.matches("[a-zA-Z]+")){ | ||
alertMessage.setText("Please enter a valid last name!"); | ||
return; | ||
} | ||
if (!userName.matches("\\w{8,}")) { | ||
alertMessage.setText("Please enter a valid username!"); | ||
return; | ||
} | ||
if (!passWord.matches("\\w{8,}")) { | ||
alertMessage.setText("Please enter a valid password!"); | ||
return; | ||
} | ||
if (!email.matches("\\w+[@]\\w+[.]\\w+")) { | ||
alertMessage.setText("Please enter a valid email!"); | ||
return; | ||
} | ||
if(!phoneNumber.matches("09\\d\\d\\d\\d\\d\\d\\d\\d\\d")){ | ||
alertMessage.setText("Please enter a valid tel!"); | ||
return; | ||
} | ||
Manager manager = new Manager(userName,firstName,lastName,email,phoneNumber,passWord); | ||
alertMessage.setText(""); | ||
alertMessage.setTextFill(GREEN); | ||
alertMessage.setText("create new manager successful"); | ||
} | ||
@FXML | ||
public void logout() throws IOException { | ||
AddManagerPage.primaryStage.close(); | ||
LoginPageController.logout(); | ||
LoginPanelController.setLoggedInAccount(null); | ||
MainMenu.display(Main.window); | ||
} | ||
@FXML | ||
public void back() throws IOException { | ||
AddManagerPage.primaryStage.close(); | ||
ManagerAccountPage.display(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/graphicView/userRegion/userAccount/managerAccount/CategoryPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package graphicView.userRegion.userAccount.managerAccount; | ||
|
||
import graphicView.userRegion.userAccount.PurchaserAccountPage; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.stage.Stage; | ||
import main.Main; | ||
|
||
import java.io.IOException; | ||
|
||
public class CategoryPage { | ||
static Stage primaryStage; | ||
|
||
public static void display() throws IOException { | ||
Main.setMediaPlayer("The Swimmer.mp3"); | ||
primaryStage = new Stage(); | ||
Parent root = FXMLLoader.load(CategoryPage.class.getResource("/graphicView/userRegion/userAccount/managerAccount/CategoryPage.fxml")); | ||
primaryStage.setTitle("Hello World"); | ||
Scene scene = new Scene(root); | ||
primaryStage.setScene(scene); | ||
primaryStage.setMaximized(true); | ||
Main.setAccountRegionStage(primaryStage); | ||
primaryStage.show(); | ||
} | ||
} |
117 changes: 117 additions & 0 deletions
117
src/main/java/graphicView/userRegion/userAccount/managerAccount/CategoryPageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package graphicView.userRegion.userAccount.managerAccount; | ||
|
||
import controller.LoginPageController; | ||
import graphicView.mainMenu.MainMenu; | ||
import graphicView.userRegion.loginPanel.LoginPanelController; | ||
import javafx.beans.property.SimpleStringProperty; | ||
import javafx.beans.property.StringProperty; | ||
import javafx.collections.FXCollections; | ||
import javafx.collections.ObservableList; | ||
import javafx.fxml.FXML; | ||
import javafx.fxml.Initializable; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.TableColumn; | ||
import javafx.scene.control.TableView; | ||
import javafx.scene.control.cell.PropertyValueFactory; | ||
import main.Main; | ||
import model.Category; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.util.ResourceBundle; | ||
|
||
public class CategoryPageController implements Initializable { | ||
private static Category currentCategory; | ||
@FXML | ||
public Label categoryName; | ||
@FXML | ||
public TableView<Attribute> attributesTable; | ||
@FXML | ||
public TableColumn<Attribute, StringProperty> attributesColumn; | ||
@FXML | ||
public TableView<Product> subProductsTable; | ||
@FXML | ||
public TableColumn<Product, StringProperty> subProductsColumn; | ||
|
||
|
||
public static void setCurrentCategory(Category currentCategory) { | ||
CategoryPageController.currentCategory = currentCategory; | ||
} | ||
|
||
public static Category getCurrentCategory() { | ||
return currentCategory; | ||
} | ||
|
||
ObservableList<Attribute> getAttributes() { | ||
ObservableList<Attribute> allAttributes = FXCollections.observableArrayList(); | ||
for (String attribute : CategoryPageController.currentCategory.getAttributes()) { | ||
allAttributes.add(new Attribute(attribute)); | ||
} | ||
return allAttributes; | ||
} | ||
|
||
ObservableList<Product> getProducts() { | ||
ObservableList<Product> allProducts = FXCollections.observableArrayList(); | ||
for (model.product.Product subProduct : CategoryPageController.currentCategory.getAllSubProducts()) { | ||
allProducts.add(new Product(subProduct.getName())); | ||
} | ||
return allProducts; | ||
} | ||
|
||
@Override | ||
public void initialize(URL url, ResourceBundle resourceBundle) { | ||
categoryName.setText(CategoryPageController.currentCategory.getName()); | ||
attributesColumn.setCellValueFactory(new PropertyValueFactory<>("attributes")); | ||
attributesTable.setItems(getAttributes()); | ||
subProductsColumn.setCellValueFactory(new PropertyValueFactory<>("subProducts")); | ||
subProductsTable.setItems(getProducts()); | ||
} | ||
|
||
@FXML | ||
public void logout() throws IOException { | ||
LoginPageController.logout(); | ||
LoginPanelController.setLoggedInAccount(null); | ||
CategoryPage.primaryStage.close(); | ||
MainMenu.display(Main.window); | ||
} | ||
|
||
@FXML | ||
public void back() throws IOException { | ||
CategoryPage.primaryStage.close(); | ||
ViewAllCategoriesPage.display(); | ||
} | ||
|
||
@FXML | ||
public void edit() throws IOException { | ||
CategoryPage.primaryStage.close(); | ||
EditCategoryPage.display(); | ||
} | ||
|
||
public class Attribute { | ||
private final StringProperty attributes; | ||
|
||
public Attribute(String attributes) { | ||
this.attributes = new SimpleStringProperty(attributes); | ||
} | ||
|
||
public StringProperty attributesProperty() { | ||
return attributes; | ||
} | ||
} | ||
|
||
public class Product { | ||
private final StringProperty subProducts; | ||
|
||
public Product(String productName) { | ||
this.subProducts = new SimpleStringProperty(productName); | ||
} | ||
|
||
public String getSubProducts() { | ||
return subProducts.get(); | ||
} | ||
|
||
public StringProperty subProductsProperty() { | ||
return subProducts; | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/graphicView/userRegion/userAccount/managerAccount/EditCategoryPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package graphicView.userRegion.userAccount.managerAccount; | ||
|
||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.stage.Stage; | ||
import main.Main; | ||
|
||
import java.io.IOException; | ||
|
||
public class EditCategoryPage { | ||
static Stage primaryStage; | ||
|
||
public static void display() throws IOException { | ||
Main.setMediaPlayer("The Swimmer.mp3"); | ||
primaryStage = new Stage(); | ||
Parent root = FXMLLoader.load(EditCategoryPage.class.getResource("/graphicView/userRegion/userAccount/managerAccount/EditCategory.fxml")); | ||
primaryStage.setTitle("Hello World"); | ||
Scene scene = new Scene(root); | ||
primaryStage.setScene(scene); | ||
primaryStage.setMaximized(true); | ||
Main.setAccountRegionStage(primaryStage); | ||
primaryStage.show(); | ||
} | ||
} |
Oops, something went wrong.