Skip to content
Snippets Groups Projects
Commit c7cf7a9b authored by alec.schmidt's avatar alec.schmidt
Browse files

Almost done, only search still doesn't work

parent 93e387b7
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ public class App extends Application {
@Override
public void start(Stage stage) throws IOException {
scene = new Scene(loadFXML("main"), 640, 480);
scene = new Scene(loadFXML("main"), 1149, 559);
stage.setScene(scene);
stage.show();
}
......
......@@ -10,7 +10,6 @@ import ch.hepia.controller.Serializer;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ListView;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
......@@ -31,7 +30,7 @@ public class FXMLController {
private TextField firstNameBox;
@FXML
private TextField AddressBox;
private TextField addressBox;
@FXML
private TextField phoneBox;
......@@ -63,9 +62,6 @@ public class FXMLController {
@FXML
private Button btnSearch;
@FXML
private Button btnPrintCLI;
@FXML
private Button btnDelete;
......@@ -102,7 +98,16 @@ public class FXMLController {
initColumn("Relation", "relation", 100.0));
}
private void clearAllTextFields(){
nameBox.clear();
firstNameBox.clear();
addressBox.clear();
mailBox.clear();
phoneBox.clear();
socialBox.clear();
jobBox.clear();
relationBox.clear();
}
@FXML
protected void printCLI() {
......@@ -140,13 +145,14 @@ public class FXMLController {
c.setName(nameBox.getText());
c.setFirstNames(Arrays.asList(firstNameBox.getText().split(",")));
c.setAddresses(Arrays.asList(AddressBox.getText().split(",")));
c.setAddresses(Arrays.asList(addressBox.getText().split(",")));
c.setMails(Arrays.asList(mailBox.getText().split(",")));
c.setPhones(Arrays.asList(phoneBox.getText().split(",")));
c.setSocials(Arrays.asList(socialBox.getText().split(",")));
this.contacts.append(c);
tView.getItems().setAll(contacts.getList());
tView.getItems().setAll(this.contacts.getList());
clearAllTextFields();
}
@FXML
......@@ -158,12 +164,23 @@ public class FXMLController {
protected void loadLocalSave() {
contacts = Serializer.deserialize();
tView.getItems().setAll(contacts.getList());
tView.getItems().setAll(this.contacts.getList());
}
@FXML
protected void deleteEntry() {
contacts.removeContact(tView.getSelectionModel().getSelectedItem());
tView.getItems().setAll(contacts.getList());
tView.getItems().setAll(this.contacts.getList());
}
@FXML
protected void searchAction() {
ContactController searchResult = contacts.search(searchBox.getText());
tView.getItems().setAll(searchResult.getList());
}
@FXML
protected void homeAction() {
tView.getItems().setAll(this.contacts.getList());
}
}
\ No newline at end of file
......@@ -35,57 +35,14 @@
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SeparatorMenuItem?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="580.0" prefWidth="1149.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.hepia.FXMLController">
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="552.0" prefWidth="1149.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.hepia.FXMLController">
<children>
<MenuBar VBox.vgrow="NEVER">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" text="New" />
<MenuItem mnemonicParsing="false" text="Open…" />
<Menu mnemonicParsing="false" text="Open Recent" />
<SeparatorMenuItem mnemonicParsing="false" />
<MenuItem mnemonicParsing="false" text="Close" />
<MenuItem mnemonicParsing="false" text="Save" />
<MenuItem mnemonicParsing="false" text="Save As…" />
<MenuItem mnemonicParsing="false" text="Revert" />
<SeparatorMenuItem mnemonicParsing="false" />
<MenuItem mnemonicParsing="false" text="Preferences…" />
<SeparatorMenuItem mnemonicParsing="false" />
<MenuItem mnemonicParsing="false" text="Quit" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem mnemonicParsing="false" text="Undo" />
<MenuItem mnemonicParsing="false" text="Redo" />
<SeparatorMenuItem mnemonicParsing="false" />
<MenuItem mnemonicParsing="false" text="Cut" />
<MenuItem mnemonicParsing="false" text="Copy" />
<MenuItem mnemonicParsing="false" text="Paste" />
<MenuItem mnemonicParsing="false" text="Delete" />
<SeparatorMenuItem mnemonicParsing="false" />
<MenuItem mnemonicParsing="false" text="Select All" />
<MenuItem mnemonicParsing="false" text="Unselect All" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" text="About MyHelloApp" />
</items>
</Menu>
</menus>
</MenuBar>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="559.0" prefWidth="1149.0" VBox.vgrow="ALWAYS">
<children>
<TextField fx:id="nameBox" layoutX="14.0" layoutY="463.0" />
......@@ -95,10 +52,9 @@
<TextField fx:id="mailBox" layoutX="14.0" layoutY="521.0" />
<TextField fx:id="socialBox" layoutX="185.0" layoutY="521.0" />
<Button layoutX="760.0" layoutY="521.0" mnemonicParsing="false" onAction="#doneEditing" text="Add" />
<Button fx:id="btnSave" layoutX="1085.0" layoutY="2.0" mnemonicParsing="false" onAction="#saveLocally" text="Save" />
<Button fx:id="btnSave" layoutX="1086.0" layoutY="2.0" mnemonicParsing="false" onAction="#saveLocally" text="Save" />
<TextField layoutX="11.0" layoutY="2.0" promptText="Type here to search" />
<Button layoutX="191.0" layoutY="2.0" mnemonicParsing="false" text="Search" />
<Button layoutX="1051.0" layoutY="521.0" mnemonicParsing="false" onAction="#printCLI" text="PrintCLI" />
<Button layoutX="191.0" layoutY="2.0" mnemonicParsing="false" onAction="#searchAction" text="Search" />
<Button fx:id="btnLoad" layoutX="1021.0" layoutY="2.0" mnemonicParsing="false" onAction="#loadLocalSave" text="Load" />
<ComboBox fx:id="cBoxType" layoutX="707.0" layoutY="463.0" onAction="#selectType" prefWidth="150.0" />
<TableView fx:id="tView" layoutY="36.0" prefHeight="402.0" prefWidth="1149.0">
......@@ -115,9 +71,10 @@
<Label layoutX="185.0" layoutY="505.0" text="Socials" />
<TextField fx:id="jobBox" disable="true" layoutX="356.0" layoutY="521.0" />
<Label layoutX="356.0" layoutY="505.0" text="Job" />
<Button fx:id="btnDelete" layoutX="264.0" layoutY="2.0" mnemonicParsing="false" onAction="#deleteEntry" text="Delete" />
<Button fx:id="btnDelete" layoutX="347.0" layoutY="2.0" mnemonicParsing="false" onAction="#deleteEntry" text="Delete" />
<TextField fx:id="relationBox" disable="true" layoutX="527.0" layoutY="521.0" />
<Label layoutX="527.0" layoutY="505.0" text="Relation" />
<Button layoutX="271.0" layoutY="2.0" mnemonicParsing="false" onAction="#homeAction" text="Home" />
</children>
</AnchorPane>
</children>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment