Skip to content

Commit

Permalink
All functions fully added and working
Browse files Browse the repository at this point in the history
- Added Checkout and tweaked UI
- Modified classpaths
  • Loading branch information
iamKunal committed Mar 22, 2017
1 parent 3751f0a commit 4a5ebe4
Show file tree
Hide file tree
Showing 16 changed files with 395 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/opencv"/>
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.40-bin.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/opencv"/>
<classpathentry kind="output" path="bin"/>
</classpath>
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/bin/

temp*
/imgdb/
/imgdb/
/src/visMan/Demo*
Binary file added lib/opencv/opencv-320.jar
Binary file not shown.
Binary file added lib/opencv/x64/opencv_java320.dll
Binary file not shown.
Binary file added lib/opencv/x86/opencv_java320.dll
Binary file not shown.
90 changes: 90 additions & 0 deletions src/visMan/CheckOut.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ButtonBar?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visMan.CheckOutController">
<children>
<BorderPane layoutX="251.0" layoutY="136.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<top>
<VBox alignment="CENTER" BorderPane.alignment="CENTER">
<BorderPane.margin>
<Insets left="10.0" right="10.0" top="10.0" />
</BorderPane.margin>
<children>
<Label alignment="CENTER" text="Checkout Visitor" underline="true">
<font>
<Font name="Arial" size="27.0" />
</font>
<VBox.margin>
<Insets bottom="20.0" top="20.0" />
</VBox.margin>
</Label>
<TextField fx:id="searchBar" onKeyReleased="#search" promptText="Enter VID or Name or Contact to Checkout...">
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</TextField>
</children>
</VBox>
</top>
<center>
<VBox BorderPane.alignment="CENTER">
<BorderPane.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</BorderPane.margin>
<children>
<Label text=" Visitor ID Name Contact Number">
<font>
<Font name="Lucida Console" size="16.0" />
</font>
<VBox.margin>
<Insets left="10.0" />
</VBox.margin>
<padding>
<Insets left="10.0" right="10.0" />
</padding>
</Label>
<StackPane>
<children>
<ListView fx:id="visitorListView">
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</ListView>
<Label fx:id="errorLabel" text="No results found..." visible="false">
<font>
<Font name="System Italic" size="15.0" />
</font>
</Label>
</children>
</StackPane>
</children>
</VBox>
</center>
<bottom>
<ButtonBar buttonMinWidth="100.0" prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<buttons>
<Button fx:id="checkoutButton" disable="true" mnemonicParsing="false" onAction="#checkout" text="Checkout" />
<Button fx:id="cancelButton" cancelButton="true" mnemonicParsing="false" onAction="#cancelExecute" text="Cancel" />
</buttons>
<BorderPane.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</BorderPane.margin>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</ButtonBar>
</bottom>
</BorderPane>
</children>
</AnchorPane>
170 changes: 170 additions & 0 deletions src/visMan/CheckOutController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
package visMan;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.beans.property.*;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.CheckBoxListCell;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;
import javafx.util.Callback;
import visMan.database.CheckOut;
import visMan.utils.Utils;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.ScrollBar;
import javafx.scene.control.ScrollToEvent;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;

public class CheckOutController implements Initializable {
private ObservableList<Visitor> toCheckOut;
private ObservableList<Visitor> checkOutList;
@FXML
private ListView<Visitor> visitorListView;
@FXML
private TextField searchBar;
@FXML
private Button cancelButton;
@FXML
private Button checkoutButton;
@FXML
private Label errorLabel;
@FXML
void cancelExecute() {
Stage currentStage = (Stage) cancelButton.getScene().getWindow();
// if(openStage!=null){
// openStage.close();
// openStage=null;
// }
currentStage.close();
}

@FXML
void checkout() {
Alert alert = new Alert(AlertType.CONFIRMATION, "", ButtonType.YES, ButtonType.CANCEL);
alert.setHeaderText("Do you wish to checkout the following visitors?");
String s="";
for(Visitor v: toCheckOut){
s+=v.getName()+"\n";
}
alert.setContentText(s);
alert.showAndWait();

if (alert.getResult() == ButtonType.YES) {
try{
CheckOut ch = new CheckOut();
ch.checkOut(toCheckOut);
visitorListView.setItems(ch.getCheckOutList());
toCheckOut.clear();
if(visitorListView.getItems().size()==0){
cancelExecute();
}
checkoutButton.setDisable(true);
}
catch (Exception e) {
// TODO: handle exception
}
}
}
@FXML
void search() {
visitorListView.setItems(findInList(searchBar.getText()));
if(visitorListView.getItems().size()==0)
errorLabel.setVisible(true);
else
errorLabel.setVisible(false);

}
ObservableList<Visitor> findInList(String query){
ObservableList<Visitor> list = FXCollections.observableArrayList();
for(Visitor v : checkOutList){
if(v.toString().toLowerCase().contains(query.toLowerCase())){
list.add(v);
}
}
return list;
}
@Override
public void initialize(URL location, ResourceBundle resources) {
toCheckOut = FXCollections.observableArrayList();
// scrollBar.valueProperty().addListener(new ChangeListener<Number>() {
// @Override
// public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
// // TODO Auto-generated method stub
// visitorIDListView.scrollTo(newValue.intValue());
// }
// });
checkOutList=FXCollections.observableArrayList();
visitorListView.setCellFactory(CheckBoxListCell.forListView(new Callback<Visitor, ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(Visitor item) {
BooleanProperty observable = new SimpleBooleanProperty();
observable.addListener((obs, wasSelected, isNowSelected) -> {
if(isNowSelected){
toCheckOut.add(item);
if(toCheckOut.size()>0){
checkoutButton.setDisable(false);
}
}
else{
toCheckOut.remove(item);
if(toCheckOut.size()==0){
checkoutButton.setDisable(true);
}
}
});
return observable ;
}
}));
searchBar.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
// TODO Auto-generated method stub
if(!newValue.isEmpty()){
String newString = newValue.substring(newValue.indexOf(newValue.trim()));
newString = newString.replaceAll(" ", " ");
searchBar.setText(newString);
if(newString.contains("|")){
searchBar.setText(oldValue);
}

}
}
});
visitorListView.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent click) {
if (click.getClickCount()>0) {
//Use ListView's getSelected Item
visitorListView.getSelectionModel().select(-1);
}
}
});
try{
CheckOut ch = new CheckOut();
checkOutList = ch.getCheckOutList();
visitorListView.setItems(checkOutList);
}

catch (Exception e) {
// TODO: handle exception
}


}

}
13 changes: 10 additions & 3 deletions src/visMan/Main.fxml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
Expand Down Expand Up @@ -37,11 +38,17 @@
</toggleGroup></RadioButton>
<VBox alignment="CENTER_LEFT" maxHeight="1.7976931348623157E308" maxWidth="400.0" prefHeight="200.0">
<children>
<RadioButton id="mainRadioButton" mnemonicParsing="false" text="New User">
<RadioButton id="mainRadioButton" mnemonicParsing="false" text="New Visitor">
<toggleGroup>
<ToggleGroup fx:id="user" />
</toggleGroup></RadioButton>
<RadioButton id="mainRadioButton" mnemonicParsing="false" text="Old User" toggleGroup="$user" />
</toggleGroup>
<VBox.margin>
<Insets bottom="5.0" />
</VBox.margin></RadioButton>
<RadioButton id="mainRadioButton" mnemonicParsing="false" text="Old Visitor" toggleGroup="$user">
<VBox.margin>
<Insets top="5.0" />
</VBox.margin></RadioButton>
</children>
</VBox>
</children>
Expand Down
1 change: 1 addition & 0 deletions src/visMan/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void run() {

public static void main(String[] args) {
// load the native OpenCV library

System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Database db = new Database();
launch(args);
Expand Down
Loading

0 comments on commit 4a5ebe4

Please sign in to comment.