update project.

This commit is contained in:
2026-02-18 15:05:18 -05:00
parent c86bc67c5e
commit de52126ab1
19 changed files with 274 additions and 58 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="bin/main" path="src/main/java"> <classpathentry kind="src" output="bin/main" path="src/main/resources">
<attributes> <attributes>
<attribute name="gradle_scope" value="main"/> <attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/> <attribute name="gradle_used_by_scope" value="main,test"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/resources"> <classpathentry kind="src" output="bin/main" path="src/main/java">
<attributes> <attributes>
<attribute name="gradle_scope" value="main"/> <attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/> <attribute name="gradle_used_by_scope" value="main,test"/>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+6 -6
View File
@@ -1,13 +1,13 @@
arguments= arguments=--init-script /home/sherwinp/.config/VSCodium/User/globalStorage/redhat.java/1.50.0/config_linux/org.eclipse.osgi/58/0/.cp/gradle/init/init.gradle --init-script /home/sherwinp/.config/VSCodium/User/globalStorage/redhat.java/1.50.0/config_linux/org.eclipse.osgi/58/0/.cp/gradle/protobuf/init.gradle
auto.sync=false auto.sync=true
build.scans.enabled=false build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir= connection.project.dir=
eclipse.preferences.version=1 eclipse.preferences.version=1
gradle.user.home= gradle.user.home=
java.home= java.home=/usr/lib/jvm/java-25-openjdk
jvm.arguments= jvm.arguments=
offline.mode=false offline.mode=false
override.workspace.settings=false override.workspace.settings=true
show.console.view=false show.console.view=true
show.executions.view=false show.executions.view=true
+9 -2
View File
@@ -4,18 +4,25 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{
"type": "java",
"name": "View",
"request": "launch",
"mainClass": "edu.bookocontacts.AppSceneView",
"projectName": "bookocontacts"
},
{ {
"type": "java", "type": "java",
"name": "Windows Current File", "name": "Windows Current File",
"request": "launch", "request": "launch",
"mainClass": "${file}", "mainClass": "edu.bookocontacts.AppSceneView",
"vmArgs": " --module-path 'C://Program Files//javafx-25//lib' --add-modules ALL-MODULE-PATH --enable-native-access=javafx.graphics" "vmArgs": " --module-path 'C://Program Files//javafx-25//lib' --add-modules ALL-MODULE-PATH --enable-native-access=javafx.graphics"
}, },
{ {
"type": "java", "type": "java",
"name": "Linux Current File", "name": "Linux Current File",
"request": "launch", "request": "launch",
"mainClass": "${file}", "mainClass": "edu.bookocontacts.AppSceneView",
"vmArgs": " --module-path '/home/sherwinp/workspace/javafx-sdk/lib/' --add-modules ALL-MODULE-PATH --enable-native-access=javafx.graphics" "vmArgs": " --module-path '/home/sherwinp/workspace/javafx-sdk/lib/' --add-modules ALL-MODULE-PATH --enable-native-access=javafx.graphics"
} }
] ]
+4 -1
View File
@@ -23,7 +23,7 @@ repositories {
} }
application { application {
mainClass = 'edu.bookocontacts.View' mainClass = 'edu.bookocontacts.AppSceneView'
} }
sourceSets { sourceSets {
@@ -44,6 +44,9 @@ dependencies {
implementation("ch.qos.logback:logback-classic:1.5.26") implementation("ch.qos.logback:logback-classic:1.5.26")
implementation("org.aspectj:aspectjrt:1.9.25") implementation("org.aspectj:aspectjrt:1.9.25")
implementation 'org.xerial:sqlite-jdbc:3.51.2.0'
implementation 'jakarta.activation:jakarta.activation-api:2.1.4'
implementation 'org.openjfx:javafx-base:25.0.2' implementation 'org.openjfx:javafx-base:25.0.2'
implementation 'org.openjfx:javafx-fxml:25.0.2' implementation 'org.openjfx:javafx-fxml:25.0.2'
implementation 'org.openjfx:javafx-controls:25.0.2' implementation 'org.openjfx:javafx-controls:25.0.2'
View File
@@ -15,7 +15,7 @@ import javafx.stage.Stage;
/** /**
* *
*/ */
public class View extends Application { public class AppSceneView extends Application {
private Stage stage; private Stage stage;
@Override @Override
@@ -47,6 +47,9 @@ public class View extends Application {
in.close(); in.close();
} }
} }
DATASET.FINDDATA();
} catch (Exception ex) { } catch (Exception ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex); Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
} }
@@ -0,0 +1,79 @@
package edu.bookocontacts;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.TextField;
import javafx.util.Callback;
import edu.bookocontacts.model.Address;
public class ControlDDXDialog extends Dialog<Address> {
@FXML
private TextField tfStreet;
@FXML
private TextField tfCity;
@FXML
private TextField tfState;
@FXML
private TextField tfZip;
public ControlDDXDialog() {
super();
String fxml = "/media/ControlAddressDDXDialog.fxml";
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource(fxml));
fxmlLoader.setController(this);
fxmlLoader.setLocation(getClass().getResource(fxml));
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
getDialogPane().setContent(fxmlLoader.getRoot());
getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
setTitle("Contact Address Dialog");
setHeaderText("Enter Details");
setPropertyBindings();
setResultConverter();
}
private void setPropertyBindings() {
Logger.getLogger(getClass().getName()).log(Level.INFO, "setPropertyBindings called.");
}
private void setResultConverter() {
Logger.getLogger(getClass().getName()).log(Level.INFO, "setResultConverter called.");
Callback<ButtonType, Address> aRC = (buttonType) -> {
if (buttonType == ButtonType.OK) {
if (getStreet().isEmpty() || getCity().isEmpty() || getState().isEmpty() || getZip().isEmpty()) {
return null;
}
return new Address(getStreet(), getCity(), getState(), getZip());
}
return null;
};
setResultConverter(aRC);
}
private String getZip() {
return tfZip.getText();
}
private String getState() {
return tfState.getText();
}
private String getCity() {
return tfCity.getText();
}
private String getStreet() {
return tfStreet.getText();
}
}
@@ -0,0 +1,38 @@
package edu.bookocontacts;
import java.io.File;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.util.ListIterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.sqlite.SQLiteDataSource;
import edu.bookocontacts.model.Contact;
public final class DATASET {
public final static ListIterator<Contact> FINDDATA() {
try {
File rootDir = new File(String.format("%s", DataRepositoryConfig.getPath()));
Files.createDirectories(rootDir.toPath());
SQLiteDataSource dataSource = new SQLiteDataSource();
dataSource.setUrl(String.format("jdbc:sqlite:%ssample.db", DataRepositoryConfig.getPath()));
dataSource.getConnection();
} catch (Exception ex) {
Logger.getLogger(DATASET.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
public final static class DataRepositoryConfig {
public final static String getPath() {
String home = System.getenv("HOME") != null ? System.getenv("HOME")
: System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH");
return home.replace('\\', '/') + "/workspace/bookocontacts/db/";
}
}
}
@@ -7,12 +7,15 @@ package edu.bookocontacts;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import edu.bookocontacts.model.Factory;
import edu.bookocontacts.model.Person; import edu.bookocontacts.model.Person;
import edu.bookocontacts.model.PersonFactory; import edu.bookocontacts.model.Address;
import edu.bookocontacts.model.Contact;
import java.net.URL; import java.net.URL;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Optional;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import javafx.beans.value.ChangeListener; import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
@@ -75,10 +78,9 @@ public class ViewController implements Initializable {
/** /**
* Initializes the controller class. * Initializes the controller class.
*/ */
@Override public void initialize(URL location, ResourceBundle resources) {
public void initialize(URL url, ResourceBundle rb) {
log("initialize"); log("initialize");
persons = FXCollections.observableArrayList(PersonFactory.getAllPersons()); persons = FXCollections.observableArrayList(Factory.getAll(new Person()));
log(String.format("Person size: %d", persons.size())); log(String.format("Person size: %d", persons.size()));
sort(); sort();
@@ -100,12 +102,22 @@ public class ViewController implements Initializable {
save.setOnAction(new javafx.event.EventHandler<javafx.event.ActionEvent>() { save.setOnAction(new javafx.event.EventHandler<javafx.event.ActionEvent>() {
@Override @Override
public void handle(javafx.event.ActionEvent t) { public void handle(javafx.event.ActionEvent t) {
persons.add(new Person(idTxt.getText(), nameTxt.getText(), Integer.valueOf(ageTxt.getText())));
sort(); ControlDDXDialog dialog = new ControlDDXDialog();
updatePersonView();
idTxt.setText(null); Optional<Address> result = dialog.showAndWait();
nameTxt.setText(null);
ageTxt.setText(null); if (result.isPresent()) {
System.out.println("result is present.");
// add to storage
// persons.add((Address) result.get());
// bind to model
// tvInventory.refresh();
//
// sort();
// updatePersonView();
}
} }
}); });
@@ -137,7 +149,11 @@ public class ViewController implements Initializable {
public void updatePersonView() { public void updatePersonView() {
log("updatePersonView"); log("updatePersonView");
personView.getItems().setAll(persons.subList(currentPageIndex * itemsPerPage, ((currentPageIndex * itemsPerPage + itemsPerPage <= persons.size()) ? currentPageIndex * itemsPerPage + itemsPerPage : persons.size()))); personView.getItems()
.setAll(persons.subList(currentPageIndex * itemsPerPage,
((currentPageIndex * itemsPerPage + itemsPerPage <= persons.size())
? currentPageIndex * itemsPerPage + itemsPerPage
: persons.size())));
} }
private void initializeTable() { private void initializeTable() {
@@ -148,7 +164,8 @@ public class ViewController implements Initializable {
personViewNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("Name")); personViewNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("Name"));
personViewNameCol.sortTypeProperty().addListener(new ChangeListener<SortType>() { personViewNameCol.sortTypeProperty().addListener(new ChangeListener<SortType>() {
@Override @Override
public void changed(ObservableValue<? extends SortType> paramObservableValue, SortType paramT1, SortType paramT2) { public void changed(ObservableValue<? extends SortType> paramObservableValue, SortType paramT1,
SortType paramT2) {
log("NAME Clicked -- sortType = " + paramT1 + ", SortType=" + paramT2); log("NAME Clicked -- sortType = " + paramT1 + ", SortType=" + paramT2);
id.setGraphic(null); id.setGraphic(null);
} }
@@ -181,4 +198,5 @@ public class ViewController implements Initializable {
log("floatCount=" + floatCount + ", intCount=" + intCount); log("floatCount=" + floatCount + ", intCount=" + intCount);
return ((floatCount > intCount) ? ++intCount : intCount); return ((floatCount > intCount) ? ++intCount : intCount);
} }
} }
@@ -10,9 +10,17 @@ import java.util.List;
/** /**
* *
*/ */
public class PersonFactory { public class Factory {
static int id=0; static int id=0;
public static List<Person> getAll(Person clazz){
return getAllPersons();
}
public static List<Contact> getAll(Contact clazz){
return getAllContacts();
}
public static List<Person> getAllPersons() { public static List<Person> getAllPersons() {
ArrayList<Person> list = new ArrayList<>(); ArrayList<Person> list = new ArrayList<>();
list.add(createPerson("John", 40)); list.add(createPerson("John", 40));
@@ -35,4 +43,14 @@ public class PersonFactory {
static Person createPerson(String _name, int _age) { static Person createPerson(String _name, int _age) {
return new Person(Integer.toString(id++),_name, _age); return new Person(Integer.toString(id++),_name, _age);
} }
public static List<Contact> getAllContacts() {
ArrayList<Contact> list = new ArrayList<>();
return list;
}
static Person createContact(String _name, int _age) {
return new Person(Integer.toString(id++),_name, _age);
}
} }
@@ -8,49 +8,40 @@ package edu.bookocontacts.model;
* *
*/ */
public class Person { public class Person {
String id; String Id; String Name; int Age;
String name;
int age; public Person(final String Id, final String Name, final int Age) {
this.Id=Id;
this.Name = Name;
this.Age = Age;
}
public Person() { public Person() {
this("", "", 0);
} }
public Person(String id, String name, int age) {
this.id = id;
this.name = name;
this.age = age;
}
public String getId() { public String getId() {
return id; return Id;
} }
public void setId(String id) { public void setId(final String id) {
this.id = id; Id = id;
} }
public String getName() { public String getName() {
return name; return Name;
} }
public void setName(String name) { public void setName(final String name) {
this.name = name; Name = name;
} }
public int getAge() { public int getAge() {
return age; return Age;
} }
public void setAge(int age) { public void setAge(final int age) {
this.age = age; Age = age;
} }
@Override
public String toString() {
return "Person{" + "id=" + id + ", name=" + name + ", age=" + age + '}';
}
} }
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ButtonBar?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="364.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/25.0.1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="294.0" minWidth="-Infinity" prefWidth="168.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="477.0" minWidth="10.0" prefWidth="432.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="128.0" minHeight="10.0" prefHeight="43.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="189.0" minHeight="10.0" prefHeight="48.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="309.0" minHeight="10.0" prefHeight="180.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label prefHeight="18.0" prefWidth="165.0" text="Email:" />
<TextField promptText="email address" GridPane.columnIndex="1" />
<Label prefHeight="18.0" prefWidth="165.0" text="Phone Number:" GridPane.rowIndex="1" />
<Label prefHeight="18.0" prefWidth="165.0" text="Mailing Address:" GridPane.rowIndex="2" />
<TextField promptText="phone number" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<VBox prefHeight="180.0" prefWidth="432.0" GridPane.columnIndex="1" GridPane.rowIndex="2">
<children>
<Label text="Street" />
<TextField fx:id="tfStreet" promptText="street"/>
<GridPane prefHeight="90.0" prefWidth="432.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="210.0" minWidth="10.0" prefWidth="151.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="295.0" minWidth="10.0" prefWidth="123.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="295.0" minWidth="10.0" prefWidth="159.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="40.0" minHeight="10.0" prefHeight="33.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="66.0" minHeight="10.0" prefHeight="48.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="66.0" minHeight="10.0" prefHeight="54.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="10.0" prefHeight="17.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="State" GridPane.columnIndex="1" />
<Label text="City" />
<Label text="Zip" GridPane.columnIndex="2" />
<TextField fx:id="tfCity" prefHeight="38.0" prefWidth="150.0" GridPane.rowIndex="1" />
<TextField fx:id="tfState" prefHeight="38.0" prefWidth="120.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField fx:id="tfZip" prefHeight="38.0" prefWidth="159.0" GridPane.columnIndex="2" GridPane.rowIndex="1" />
</children>
</GridPane>
<ButtonBar prefHeight="38.0" prefWidth="429.0">
<buttons/>
</ButtonBar>
</children>
</VBox>
</children>
</GridPane>