-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All functions fully added and working
- Added Checkout and tweaked UI - Modified classpaths
- Loading branch information
Showing
16 changed files
with
395 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/bin/ | ||
|
||
temp* | ||
/imgdb/ | ||
/imgdb/ | ||
/src/visMan/Demo* |
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,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> |
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,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 | ||
} | ||
|
||
|
||
} | ||
|
||
} |
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
Oops, something went wrong.