-
Notifications
You must be signed in to change notification settings - Fork 18
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
0 parents
commit 36cfc0f
Showing
15 changed files
with
395 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/> | ||
<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.39-bin.jar"/> | ||
<classpathentry kind="lib" path="lib/jgrapht-core-0.9.1.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>Esame_20170123</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
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,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.8 |
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 @@ | ||
/it/ |
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,8 @@ | ||
<?xml version="1.0" encoding="ASCII"?> | ||
<anttasks:AntTask xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:anttasks="http://org.eclipse.fx.ide.jdt/1.0" buildDirectory="${project}/build"> | ||
<deploy> | ||
<application name="Esame_20170123"/> | ||
<info/> | ||
</deploy> | ||
<signjar/> | ||
</anttasks:AntTask> |
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,50 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.geometry.Insets?> | ||
<?import javafx.scene.control.Button?> | ||
<?import javafx.scene.control.ComboBox?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.TextArea?> | ||
<?import javafx.scene.control.TextField?> | ||
<?import javafx.scene.layout.BorderPane?> | ||
<?import javafx.scene.layout.HBox?> | ||
<?import javafx.scene.layout.VBox?> | ||
<?import javafx.scene.text.Font?> | ||
|
||
|
||
<BorderPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.65" fx:controller="it.polito.tdp.borders.BordersController"> | ||
<top> | ||
<Label text="Country Borders (appello 23/01/2017)" BorderPane.alignment="CENTER"> | ||
<font> | ||
<Font size="18.0" /> | ||
</font> | ||
</Label> | ||
</top> | ||
<center> | ||
<VBox spacing="5.0" BorderPane.alignment="CENTER"> | ||
<children> | ||
<HBox alignment="CENTER_LEFT" spacing="5.0"> | ||
<children> | ||
<Label prefWidth="60.0" text="Anno:" /> | ||
<TextField fx:id="txtAnno" alignment="TOP_LEFT" prefWidth="150.0" /> | ||
<Button mnemonicParsing="false" onAction="#doCalcolaConfini" text="Calcola confini" /> | ||
</children> | ||
<VBox.margin> | ||
<Insets top="5.0" /> | ||
</VBox.margin> | ||
</HBox> | ||
<HBox alignment="CENTER_LEFT" spacing="5.0"> | ||
<children> | ||
<Label prefWidth="60.0" text="Nazione:" /> | ||
<ComboBox fx:id="boxNazione" prefWidth="150.0" /> | ||
<Button mnemonicParsing="false" onAction="#doSimula" text="Simula" /> | ||
</children> | ||
</HBox> | ||
<TextArea fx:id="txtResult" editable="false" wrapText="true" /> | ||
</children> | ||
<padding> | ||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> | ||
</padding> | ||
</VBox> | ||
</center> | ||
</BorderPane> |
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,49 @@ | ||
/** | ||
* Skeleton for 'Borders.fxml' Controller Class | ||
*/ | ||
|
||
package it.polito.tdp.borders; | ||
|
||
import java.net.URL; | ||
import java.util.ResourceBundle; | ||
import javafx.event.ActionEvent; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.ComboBox; | ||
import javafx.scene.control.TextArea; | ||
import javafx.scene.control.TextField; | ||
|
||
public class BordersController { | ||
|
||
@FXML // ResourceBundle that was given to the FXMLLoader | ||
private ResourceBundle resources; | ||
|
||
@FXML // URL location of the FXML file that was given to the FXMLLoader | ||
private URL location; | ||
|
||
@FXML // fx:id="txtAnno" | ||
private TextField txtAnno; // Value injected by FXMLLoader | ||
|
||
@FXML // fx:id="boxNazione" | ||
private ComboBox<?> boxNazione; // Value injected by FXMLLoader | ||
|
||
@FXML // fx:id="txtResult" | ||
private TextArea txtResult; // Value injected by FXMLLoader | ||
|
||
@FXML | ||
void doCalcolaConfini(ActionEvent event) { | ||
|
||
} | ||
|
||
@FXML | ||
void doSimula(ActionEvent event) { | ||
|
||
} | ||
|
||
@FXML // This method is called by the FXMLLoader when initialization is complete | ||
void initialize() { | ||
assert txtAnno != null : "fx:id=\"txtAnno\" was not injected: check your FXML file 'Borders.fxml'."; | ||
assert boxNazione != null : "fx:id=\"boxNazione\" was not injected: check your FXML file 'Borders.fxml'."; | ||
assert txtResult != null : "fx:id=\"txtResult\" was not injected: check your FXML file 'Borders.fxml'."; | ||
|
||
} | ||
} |
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,30 @@ | ||
package it.polito.tdp.borders; | ||
|
||
import javafx.application.Application; | ||
import javafx.stage.Stage; | ||
import javafx.scene.Scene; | ||
import javafx.scene.layout.BorderPane; | ||
import javafx.fxml.FXMLLoader; | ||
|
||
|
||
public class Main extends Application { | ||
@Override | ||
public void start(Stage primaryStage) { | ||
try { | ||
|
||
FXMLLoader loader = new FXMLLoader(getClass().getResource("Borders.fxml")) ; | ||
BorderPane root = (BorderPane)loader.load(); | ||
BordersController controller = loader.getController() ; | ||
Scene scene = new Scene(root); | ||
//scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); | ||
primaryStage.setScene(scene); | ||
primaryStage.show(); | ||
} catch(Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
launch(args); | ||
} | ||
} |
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 @@ | ||
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */ |
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,63 @@ | ||
package it.polito.tdp.borders.db; | ||
|
||
import it.polito.tdp.borders.model.Country; | ||
|
||
import java.sql.Connection; | ||
import java.sql.PreparedStatement; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
public class BordersDAO { | ||
|
||
public List<Country> loadAllCountries() { | ||
|
||
String sql = | ||
"SELECT ccode,StateAbb,StateNme " + | ||
"FROM country " + | ||
"ORDER BY StateAbb " ; | ||
|
||
try { | ||
Connection conn = DBConnect.getConnection() ; | ||
|
||
PreparedStatement st = conn.prepareStatement(sql) ; | ||
|
||
ResultSet rs = st.executeQuery() ; | ||
|
||
List<Country> list = new LinkedList<Country>() ; | ||
|
||
while( rs.next() ) { | ||
|
||
Country c = new Country( | ||
rs.getInt("ccode"), | ||
rs.getString("StateAbb"), | ||
rs.getString("StateNme")) ; | ||
|
||
list.add(c) ; | ||
} | ||
|
||
conn.close() ; | ||
|
||
return list ; | ||
|
||
|
||
} catch (SQLException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
|
||
return null ; | ||
} | ||
|
||
public static void main(String[] args) { | ||
List<Country> list ; | ||
BordersDAO dao = new BordersDAO() ; | ||
list = dao.loadAllCountries() ; | ||
for(Country c: list) { | ||
System.out.println(c); | ||
} | ||
} | ||
|
||
|
||
} |
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,34 @@ | ||
package it.polito.tdp.borders.db; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.SQLException; | ||
|
||
/** | ||
* Handle the JDBC connection to the database | ||
* This class has package-level visibility: only DAO object may call it | ||
* @author Fulvio | ||
* | ||
*/ | ||
class DBConnect { | ||
|
||
private static String url = "jdbc:mysql://localhost/countries?user=root&password=root"; | ||
|
||
/** | ||
* Restituisce una nuova connessione, con i parametri a lui noti | ||
* @return la nuova java.sql.Connection, oppure null se si verificano | ||
* errori di connessione | ||
*/ | ||
public static Connection getConnection() { | ||
Connection conn; | ||
try { | ||
conn = DriverManager.getConnection(url); | ||
return conn ; | ||
} catch (SQLException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
return null ; | ||
} | ||
|
||
} |
Oops, something went wrong.