Skip to content

Commit 1ca139d

Browse files
committed
Initial Commit
Initial Commit of JavaFX/Spring Integrated Project
1 parent c060594 commit 1ca139d

28 files changed

Lines changed: 1621 additions & 0 deletions

‎.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@
44
*.jar
55
*.war
66
*.ear
7+
*.bak
8+
9+
*.iml
10+
*/.idea
11+
*/target

‎client/pom.xml‎

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>steveonjava</groupId>
6+
<artifactId>javafx-spring-client</artifactId>
7+
<name>Spring client for JavaFX/Spring sample application.</name>
8+
<packaging>jar</packaging>
9+
<version>1.0.0</version>
10+
11+
<properties>
12+
<java-version>1.6</java-version>
13+
<org.springframework-version>3.1.0.RELEASE</org.springframework-version>
14+
</properties>
15+
<dependencies>
16+
<dependency>
17+
<groupId>org.slf4j</groupId>
18+
<artifactId>slf4j-api</artifactId>
19+
<version>1.5.6</version>
20+
</dependency>
21+
<dependency>
22+
<groupId>org.slf4j</groupId>
23+
<artifactId>slf4j-log4j12</artifactId>
24+
<version>1.5.6</version>
25+
<scope>compile</scope>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.codehaus.jackson</groupId>
29+
<artifactId>jackson-mapper-asl</artifactId>
30+
<version>1.9.9</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>cglib</groupId>
34+
<artifactId>cglib</artifactId>
35+
<version>2.2.2</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.springframework.security</groupId>
39+
<artifactId>spring-security-core</artifactId>
40+
<version>${org.springframework-version}</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.springframework.security</groupId>
44+
<artifactId>spring-security-config</artifactId>
45+
<version>${org.springframework-version}</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.springframework</groupId>
49+
<artifactId>spring-web</artifactId>
50+
<version>${org.springframework-version}</version>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.springframework</groupId>
54+
<artifactId>spring-core</artifactId>
55+
<version>${org.springframework-version}</version>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.springframework</groupId>
59+
<artifactId>spring-beans</artifactId>
60+
<version>${org.springframework-version}</version>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.springframework</groupId>
64+
<artifactId>spring-expression</artifactId>
65+
<version>${org.springframework-version}</version>
66+
</dependency>
67+
</dependencies>
68+
<repositories>
69+
<!-- For testing against latest Spring snapshots -->
70+
<repository>
71+
<id>org.springframework.maven.snapshot</id>
72+
<name>Spring Maven Snapshot Repository</name>
73+
<url>http://maven.springframework.org/snapshot</url>
74+
<releases>
75+
<enabled>false</enabled>
76+
</releases>
77+
<snapshots>
78+
<enabled>true</enabled>
79+
</snapshots>
80+
</repository>
81+
<!-- For developing against latest Spring milestones -->
82+
<repository>
83+
<id>org.springframework.maven.milestone</id>
84+
<name>Spring Maven Milestone Repository</name>
85+
<url>http://maven.springframework.org/milestone</url>
86+
<snapshots>
87+
<enabled>false</enabled>
88+
</snapshots>
89+
</repository>
90+
<!-- For JPA and Hibernate artifacts -->
91+
<repository>
92+
<id>JBoss Repo</id>
93+
<url>https://repository.jboss.org/nexus/content/repositories/releases</url>
94+
<name>JBoss Repo</name>
95+
</repository>
96+
</repositories>
97+
<pluginRepositories>
98+
<pluginRepository>
99+
<id>repository.springframework.maven.milestone</id>
100+
<name>Spring Framework Maven Milestone Repository</name>
101+
<url>http://maven.springframework.org/milestone</url>
102+
</pluginRepository>
103+
</pluginRepositories>
104+
<build>
105+
<plugins>
106+
<plugin>
107+
<groupId>org.apache.maven.plugins</groupId>
108+
<artifactId>maven-compiler-plugin</artifactId>
109+
<version>2.3.2</version>
110+
<configuration>
111+
<source>${java-version}</source>
112+
<target>${java-version}</target>
113+
</configuration>
114+
</plugin>
115+
</plugins>
116+
</build>
117+
</project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import java.lang.*?>
4+
<?import java.util.*?>
5+
<?import javafx.scene.control.*?>
6+
<?import javafx.scene.layout.*?>
7+
<?import javafx.scene.paint.*?>
8+
<?import javafx.scene.text.*?>
9+
10+
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="233.999755859375" prefWidth="371.999755859375" style="-fx-background-color: #EEEEEE" xmlns:fx="http://javafx.com/fxml" fx:controller="steveonjava.client.AddCustomerController">
11+
<children>
12+
<GridPane id="GridPane" layoutY="95.0" AnchorPane.leftAnchor="50.0" AnchorPane.rightAnchor="40.0">
13+
<children>
14+
<Label text="First Name:" GridPane.columnIndex="0" GridPane.rowIndex="0" />
15+
<Label text="Last Name:" GridPane.columnIndex="0" GridPane.rowIndex="1" />
16+
<TextField fx:id="firstName" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="0" />
17+
<TextField fx:id="lastName" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
18+
</children>
19+
<columnConstraints>
20+
<ColumnConstraints hgrow="NEVER" minWidth="10.0" />
21+
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
22+
</columnConstraints>
23+
<hgap>
24+
<Long fx:value="10" />
25+
</hgap>
26+
<rowConstraints>
27+
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
28+
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
29+
</rowConstraints>
30+
<vgap>
31+
<Long fx:value="10" />
32+
</vgap>
33+
</GridPane>
34+
<Label layoutX="50.0" layoutY="28.0" text="Add New Customer">
35+
<font>
36+
<Font size="28.0" />
37+
</font>
38+
</Label>
39+
<Button defaultButton="true" mnemonicParsing="false" onAction="#add" text="Add" AnchorPane.bottomAnchor="23.0" AnchorPane.rightAnchor="41.0" />
40+
<Button cancelButton="true" mnemonicParsing="false" onAction="#cancel" text="Cancel" AnchorPane.bottomAnchor="23.0" AnchorPane.rightAnchor="108.0" />
41+
<Separator layoutX="22.0" layoutY="74.0" prefWidth="329.0" />
42+
<Separator layoutX="22.0" layoutY="165.0" prefWidth="329.0" />
43+
</children>
44+
</AnchorPane>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (c) 2012, Stephen Chin
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the <organization> nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL STEPHEN CHIN OR ORACLE CORPORATION BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
package steveonjava.client;
29+
30+
import javafx.fxml.FXML;
31+
import javafx.scene.control.TextField;
32+
import org.springframework.beans.factory.annotation.Autowired;
33+
34+
public class AddCustomerController implements DialogController {
35+
@Autowired
36+
private CustomerModel model;
37+
private AutowireFXMLDialog dialog;
38+
39+
public void setDialog(AutowireFXMLDialog dialog) {
40+
this.dialog = dialog;
41+
}
42+
43+
@FXML
44+
TextField firstName;
45+
@FXML
46+
TextField lastName;
47+
48+
@FXML
49+
public void add() {
50+
model.addCustomer(firstName.getText(), lastName.getText());
51+
dialog.close();
52+
}
53+
54+
@FXML
55+
public void cancel() {
56+
dialog.close();
57+
}
58+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright (c) 2012, Stephen Chin
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the <organization> nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL STEPHEN CHIN OR ORACLE CORPORATION BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
package steveonjava.client;
29+
30+
import javafx.fxml.FXMLLoader;
31+
import javafx.scene.Parent;
32+
import javafx.scene.Scene;
33+
import javafx.stage.Modality;
34+
import javafx.stage.Stage;
35+
import javafx.stage.StageStyle;
36+
import javafx.stage.Window;
37+
import org.springframework.beans.factory.annotation.Autowired;
38+
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
39+
import org.springframework.context.ApplicationContext;
40+
41+
import javax.annotation.PostConstruct;
42+
import java.io.IOException;
43+
import java.net.URL;
44+
45+
public class AutowireFXMLDialog extends Stage {
46+
@Autowired
47+
private ApplicationContext context;
48+
49+
protected final Object controller;
50+
51+
public AutowireFXMLDialog(URL fxml, Window owner) {
52+
this(fxml, owner, StageStyle.DECORATED);
53+
}
54+
55+
public AutowireFXMLDialog(URL fxml, Window owner, StageStyle style) {
56+
super(style);
57+
initOwner(owner);
58+
initModality(Modality.WINDOW_MODAL);
59+
FXMLLoader loader = new FXMLLoader(fxml);
60+
try {
61+
setScene(new Scene((Parent) loader.load()));
62+
controller = loader.getController();
63+
if (controller instanceof DialogController) {
64+
((DialogController) controller).setDialog(this);
65+
}
66+
} catch (IOException e) {
67+
throw new RuntimeException(e);
68+
}
69+
}
70+
71+
@PostConstruct
72+
private void postConstruct() {
73+
context.getAutowireCapableBeanFactory().autowireBeanProperties(controller, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
74+
}
75+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2012, Stephen Chin
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the <organization> nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL STEPHEN CHIN OR ORACLE CORPORATION BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
package steveonjava.client;
29+
30+
import javafx.application.Application;
31+
import javafx.stage.Stage;
32+
import org.springframework.context.ApplicationContext;
33+
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
34+
35+
public class CustomerApp extends Application {
36+
public static void main(String[] args) {
37+
launch(args);
38+
}
39+
40+
@Override
41+
public void start(Stage stage) throws Exception {
42+
ApplicationContext context = new AnnotationConfigApplicationContext(CustomerAppConfiguration.class);
43+
ScreensConfiguration screens = context.getBean(ScreensConfiguration.class);
44+
screens.setPrimaryStage(stage);
45+
screens.loginDialog().show();
46+
}
47+
}

0 commit comments

Comments
 (0)