Skip to content

Commit

Permalink
Updated package structure of the Fx Controllers and also created the …
Browse files Browse the repository at this point in the history
…Update Modal for Visits Module .
  • Loading branch information
BilalAM committed Aug 25, 2019
1 parent f5685dd commit 449d4de
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 17 deletions.
12 changes: 12 additions & 0 deletions erpapplication/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@
<mainClass>zong.Main</mainClass>
</configuration>
</plugin>

<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<configuration>
<directories>
<directory>${project.build.sourceDirectory}</directory>
<directory>${project.build.directory}/generated-sources</directory>
</directories>
</configuration>
</plugin>

</plugins>
</build>
</project>
8 changes: 8 additions & 0 deletions ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@
<artifactId>jfxtras-labs</artifactId>
<version>8.0-r6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.controlsfx/controlsfx -->
<!-- https://mvnrepository.com/artifact/org.controlsfx/controlsfx -->
<dependency>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>9.0.0</version>
</dependency>


</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package self.erp.ui.controllers;
package self.erp.ui.controllers.visit;

import javafx.animation.FadeTransition;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import jfxtras.scene.control.LocalDateTimeTextField;
import jfxtras.scene.control.LocalTimePicker;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -69,6 +75,9 @@ public class VisitModuleController {
@FXML
private TableView<Visit> visitGrid;

@FXML
private AnchorPane visitStage;

@FXML
public void initialize() {
todayDateLabel.setText(LocalDate.now().format(DATE_FORMAT));
Expand All @@ -79,10 +88,22 @@ public void initialize() {
visitGrid.getColumns().get(1).setCellValueFactory(new PropertyValueFactory<>("fromDate"));
visitGrid.getColumns().get(2).setCellValueFactory(new PropertyValueFactory<>("endDate"));
visitGrid.getColumns().get(3).setCellValueFactory(new PropertyValueFactory<>("visitPurpose"));
int lastVisitID = (Integer) restfulHelper.get("http://localhost:8880/erp/visit/lastVisitID", Integer.class);

}

@FXML
private void updateVisitModal() throws Exception {
Stage stage = new Stage();
FXMLLoader loader = new FXMLLoader();
loader.setLocation(this.getClass().getResource("/fxmls/visits-update.fxml"));
Parent root = loader.load();
stage.setScene(new Scene(root));
stage.setTitle("My modal window");
stage.initModality(Modality.WINDOW_MODAL);
stage.initOwner((visitStage.getScene().getWindow()));
stage.show();
}

/**
* Displays a green label message if the response is 200 (added successfully). Displays a red label message if the
* response is not 200 (not added).
Expand Down
32 changes: 32 additions & 0 deletions ui/src/main/java/self/erp/ui/fxutils/ComponentUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

import javafx.animation.FadeTransition;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextInputControl;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.Duration;

/**
Expand Down Expand Up @@ -47,4 +53,30 @@ public static void clearTextboxes(TextInputControl... textInputControls) {
textInputControl.clear();
}
}

/**
* Creates a standard update modal for any type of module . The size and the fields to include will be implemented
* by the end user. This just creates a standard modal and freezes the background UI .
*
* @param parentStage
* : The parent stage on which this modal is used .
* @return : The modal as a Stage .
*/
@Deprecated
public static Stage createUpdateModal(AnchorPane parentStage) {
Stage updateModal = new Stage();
Button closeButton = new Button("Exit");
closeButton.setMaxSize(50, 50);
closeButton.setCancelButton(true);
updateModal.setWidth(500);
updateModal.setHeight(250);
updateModal.setX(parentStage.getWidth() / 2 + updateModal.getWidth() / 6);
updateModal.setY(parentStage.getHeight() / 2 - updateModal.getHeight() / 2);
updateModal.initOwner(parentStage.getScene().getWindow());
updateModal.initModality(Modality.APPLICATION_MODAL);
updateModal.initStyle(StageStyle.UNDECORATED);
Scene scene = new Scene(closeButton, 500, 250);
updateModal.setScene(scene);
return updateModal;
}
}
27 changes: 17 additions & 10 deletions ui/src/main/resources/fxmls/visits-update.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.shape.Rectangle?>
<?import javafx.scene.text.*?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="460.0" prefWidth="499.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<AnchorPane fx:id="visitUpdateAnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="504.0" prefWidth="499.0" xmlns="http://javafx.com/javafx/8.0.172-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="self.erp.ui.controllers.visit.VisitUpdateController">
<children>
<Label layoutX="14.0" layoutY="51.0" prefHeight="16.0" prefWidth="95.0" text="Visitor">
<font>
Expand All @@ -21,28 +21,35 @@
<Font size="20.0" />
</font>
</Label>
<TextField fx:id="visitorNameField1" layoutX="132.0" layoutY="96.0" prefHeight="33.0" prefWidth="204.0" promptText="Visitor Name" />
<TextField fx:id="visitorNameField11" layoutX="132.0" layoutY="47.0" prefHeight="33.0" prefWidth="204.0" promptText="Visitor Name" />
<TextField fx:id="visitorNameField12" layoutX="132.0" layoutY="146.0" prefHeight="33.0" prefWidth="204.0" promptText="Visitor Name" />
<Label layoutX="14.0" layoutY="200.0" prefHeight="25.0" prefWidth="122.0" text="Visited At">
<TextField fx:id="visitorNameUpdate" layoutX="132.0" layoutY="96.0" prefHeight="33.0" prefWidth="204.0" />
<TextField fx:id="visitorPurposeUpdate" layoutX="132.0" layoutY="47.0" prefHeight="33.0" prefWidth="204.0" />
<TextField fx:id="visitorAtUpdate" layoutX="132.0" layoutY="146.0" prefHeight="33.0" prefWidth="204.0" />
<Label layoutX="14.0" layoutY="200.0" prefHeight="25.0" prefWidth="122.0" text="Visited Till">
<font>
<Font size="20.0" />
</font>
</Label>
<TextField fx:id="visitorNameField121" layoutX="132.0" layoutY="196.0" prefHeight="33.0" prefWidth="204.0" promptText="Visitor Name" />
<Label layoutX="16.0" layoutY="256.0" prefHeight="25.0" prefWidth="166.0" text="Further Notes">
<TextField fx:id="visitorTillUpdate" layoutX="132.0" layoutY="196.0" prefHeight="33.0" prefWidth="204.0" />
<Label layoutX="16.0" layoutY="304.0" prefHeight="25.0" prefWidth="166.0" text="Further Notes">
<font>
<Font size="20.0" />
</font>
</Label>
<TextArea fx:id="visitorVisitPurposeDescriptionField" layoutX="16.0" layoutY="295.0" prefHeight="90.0" prefWidth="467.0" promptText="Further Description..if any" />
<Button fx:id="saveBtn" layoutX="33.0" layoutY="400.0" mnemonicParsing="false" onAction="#updateVisitModal" prefHeight="34.0" prefWidth="153.0" text="CANCEL" />
<Button fx:id="saveBtn1" layoutX="313.0" layoutY="400.0" mnemonicParsing="false" onAction="#updateVisitModal" prefHeight="34.0" prefWidth="153.0" text="SAVE" />
<TextArea fx:id="visitorVisitDescriptionUpdate" layoutX="16.0" layoutY="343.0" prefHeight="90.0" prefWidth="467.0" />
<Button fx:id="cancelUpdateBtn" layoutX="33.0" layoutY="448.0" mnemonicParsing="false" prefHeight="34.0" prefWidth="153.0" text="CANCEL" onAction="#cancelUpdate" />
<Button fx:id="saveUpdateBtn" layoutX="313.0" layoutY="448.0" mnemonicParsing="false" prefHeight="34.0" prefWidth="153.0" text="SAVE" />
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="33.0" layoutX="-1.0" stroke="BLACK" strokeType="INSIDE" width="500.0" />
<Label layoutX="182.0" layoutY="8.0" text="Update Record" textFill="WHITE">
<font>
<Font name="System Bold Italic" size="14.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="250.0" prefHeight="25.0" prefWidth="122.0" text="Status">
<font>
<Font size="20.0" />
</font>
</Label>
<RadioButton fx:id="completedFlagUpdate" layoutX="130.0" layoutY="254.0" mnemonicParsing="false" text="Completed" />
<RadioButton fx:id="inProgressFlagUpdate" layoutX="248.0" layoutY="254.0" mnemonicParsing="false" text="In Progress" />
</children>
</AnchorPane>
7 changes: 2 additions & 5 deletions ui/src/main/resources/fxmls/visits.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.*?>
<?import jfxtras.scene.control.LocalDateTimeTextField?>
<?import jfxtras.scene.control.LocalTimePicker?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="593.0" prefWidth="725.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="self.erp.ui.controllers.VisitModuleController">
<AnchorPane fx:id="visitStage" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="593.0" prefWidth="725.0" xmlns="http://javafx.com/javafx/8.0.172-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="self.erp.ui.controllers.visit.VisitModuleController">
<children>
<TableView fx:id="visitGrid" editable="true" layoutX="11.0" layoutY="308.0" prefHeight="271.0" prefWidth="703.0" tableMenuButtonVisible="true">
<columns>
Expand All @@ -23,9 +22,7 @@
<TextArea fx:id="visitorVisitPurposeDescriptionField" layoutX="354.0" layoutY="117.0" prefHeight="90.0" prefWidth="357.0" promptText="Further Description..if any" />
<RadioButton fx:id="completedFlag" layoutX="397.0" layoutY="61.0" mnemonicParsing="false" text="Completed" />
<RadioButton fx:id="inProgressFlag" layoutX="533.0" layoutY="61.0" mnemonicParsing="false" text="In Progress" />
<Button fx:id="saveBtn" layoutX="267.0" layoutY="251.0" mnemonicParsing="false" onAction="#addVisitAction" prefHeight="34.0" prefWidth="153.0" text="SAVE" />
<LocalDateTimeTextField fx:id="fromDateField" layoutX="486.0" layoutY="219.0" prefHeight="26.0" prefWidth="204.0" promptText="Visit started at" />
<LocalDateTimeTextField fx:id="toDateField" layoutX="486.0" layoutY="255.0" prefHeight="26.0" prefWidth="204.0" promptText="Visit ended at" />
<Button fx:id="saveBtn" layoutX="267.0" layoutY="251.0" mnemonicParsing="false" onAction="#updateVisitModal" prefHeight="34.0" prefWidth="153.0" text="SAVE" />
<Label fx:id="errorMsgLabel" layoutX="55.0" layoutY="251.0" text="Failed To Add Record" textFill="RED" visible="false">
<font>
<Font name="Droid Sans" size="15.0" />
Expand Down

0 comments on commit 449d4de

Please sign in to comment.