Skip to content

Commit

Permalink
#5
Browse files Browse the repository at this point in the history
  • Loading branch information
pe4en committed Dec 26, 2013
1 parent 7fadc7c commit 1101c88
Show file tree
Hide file tree
Showing 13 changed files with 412 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
import java.net.URL;
import java.util.ResourceBundle;

/**
*
* @author Akim
*/

public class MainController implements Initializable {

public VBox vbox;
Expand All @@ -29,7 +26,10 @@ private void openControl(String controlPath) throws IOException {
vbox.getChildren().add(control);
}

public void listSeller(ActionEvent actionEvent) throws IOException {
public void listUser(ActionEvent actionEvent) throws IOException {
openControl("/View/ListUserControl.fxml");
}
public void addUser(ActionEvent actionEvent) throws IOException {
openControl("/View/AddUserControl.fxml");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package javafxapplication.Controller.User;


import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.StackPane;
import javafxapplication.Proxy.UserProxy;
import javafxapplication.Model.RequestDto.AddUserRequest;
//import javafxapplication.Model.Shop;
//import main.java.javafxapplication.Proxy.UserProxy;
//import javafxapplication.Proxy.ShopProxy;
import javafx.stage.Stage;

import java.net.URL;
import java.util.ResourceBundle;


/**
* Created with IntelliJ IDEA.
* User: admin
* Date: 26.12.13
* Time: 14:04
* To change this template use File | Settings | File Templates.
*/
public class AddUserController implements Initializable{

@FXML
private TextField text1;
@FXML
private TextField text2;
@FXML
private TextField text3;


UserProxy userProxy = new UserProxy();

@FXML
private void handleButtonAction(ActionEvent actionEvent) {

String userName, email, password;
userName = text1.getText();
email=text2.getText();
password=text3.getText();


AddUserRequest request = new AddUserRequest( userName, email,password);

userProxy.addUser(request);
text1.setText("");
text2.setText("");
text3.setText("");
}
@FXML
private void textTazala(ActionEvent event){
text1.setText("");
text2.setText("");
text3.setText("");
}

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
//To change body of implemented methods use File | Settings | File Templates.
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
package javafxapplication.Controller.User;

import javafx.fxml.Initializable;

import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.event.ActionEvent;
import javafx.scene.control.cell.PropertyValueFactory;
import javafxapplication.Model.User;
import javafxapplication.Proxy.UserProxy;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.ResourceBundle;

/**
*
* @author Akim
*/
public class ListUserController implements Initializable {


public TableColumn<User, String> userName;
public TableColumn<User, String> email;

public TableView<User> UserListTableView;

UserProxy userProxy = new UserProxy();

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
public void initialize(URL url, ResourceBundle rb) {

userName.setCellValueFactory(new PropertyValueFactory<User, String>("userName"));
email.setCellValueFactory(new PropertyValueFactory<User, String>("email"));
}

public void textTolukta(ActionEvent actionEvent) {
List<User> users = Arrays.asList(userProxy.getUsers());


UserListTableView.getItems().setAll(users);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package javafxapplication.Model.RequestDto;

import java.io.Serializable;
/**
* Created with IntelliJ IDEA.
* User: admin
* Date: 26.12.13
* Time: 14:10
* To change this template use File | Settings | File Templates.
*/
public class AddUserRequest implements Serializable{

private long id;
private String userName;
private String email;
private String password;

public AddUserRequest()
{

}
public AddUserRequest(String userName, String email, String password)
{
this.userName = userName;
this.email = email;
this.password = password;
}

public String getName() {
return userName;
}

public void setName(String name) {
this.userName = name;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}
}
34 changes: 13 additions & 21 deletions JavaFXApplication/src/main/java/javafxapplication/Model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,33 @@

public class User {
private long id;
private String fullName;
private String login;
private String userName;
private String email;
private String password;

protected User() {}

public User(String firstName, String lastName, String password) {
this.fullName = firstName;
this.login = lastName;
public User(String userName, String email, String password) {
this.userName = userName;
this.email = email;
this.password = password;
}


public String getFullName() {
return fullName;
public String getUserName() {
return userName;
}

public void setFullName(String fullName) {
this.fullName = fullName;
public void setUserName(String userName) {
this.userName = userName;
}

public String getLogin() {
return login;
public String getEmail() {
return email;
}

public void setLogin(String login) {
this.login = login;
}

public long getId() {
return id;
}
public void setId(long Id)
{
this.id = Id;
public void setEmail(String email) {
this.email = email;
}

public String getPassword() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package javafxapplication.Proxy;

import javafxapplication.Model.RequestDto.AddUserRequest;
import javafxapplication.Model.RequestDto.AddUserRequest;
import javafxapplication.Model.User;

/**
Expand All @@ -11,4 +13,20 @@
*/
public class UserProxy extends Proxy {

public boolean addUser(AddUserRequest userAddRequest)
{
try {
restTemplate.postForObject(urlService.GetServerUrl("/addUser/"), userAddRequest, User.class);
}
catch (Exception e)
{
return false;
}
return true;

}

public User[] getUsers() {
return restTemplate.getForObject(urlService.GetServerUrl("/users/"), User[].class);
}
}
29 changes: 29 additions & 0 deletions JavaFXApplication/src/main/resources/View/AddUserControl.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import javafx.collections.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>

<AnchorPane prefHeight="500.0" prefWidth="392.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="javafxapplication.Controller.User.AddUserController">
<children>
<Label layoutX="112.0" layoutY="14.0" minHeight="16.0" minWidth="69.0" text="Жаңы колдонуучу кошуу" textFill="#00ff5b">
<font>
<Font size="20.0" />
</font>
</Label>
<Label layoutX="22.0" layoutY="99.0" text="Колдонуучунун аты:" textFill="RED">
<font>
<Font size="14.0" fx:id="x1" />
</font>
</Label>
<Label font="$x1" layoutX="22.0" layoutY="131.0" text="Электронндук дареги:" textFill="RED" />
<Label font="$x1" layoutX="22.0" layoutY="171.0" text="Сыр соз:" textFill="RED" />
<TextField fx:id="text1" layoutX="161.0" layoutY="94.0" prefHeight="27.0" prefWidth="200.0" />
<TextField fx:id="text2" layoutX="161.0" layoutY="131.0" prefHeight="27.0" prefWidth="200.0" />
<PasswordField fx:id="text3" layoutX="161.0" layoutY="171.0" prefHeight="27.0" prefWidth="200.0" promptText="Пароль" />
<Button layoutX="161.0" layoutY="217.0" mnemonicParsing="false" onAction="#textTazala" prefHeight="27.0" prefWidth="88.0" text="Тазала" />
<Button layoutX="273.0" layoutY="217.0" onAction="#handleButtonAction" prefHeight="27.0" prefWidth="88.0" text="OK" />
</children>
</AnchorPane>
18 changes: 17 additions & 1 deletion JavaFXApplication/src/main/resources/View/ListUserControl.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,21 @@
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<FlowPane prefHeight="500.0" prefWidth="392.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="javafxapplication.Controller.User.ListUserController">
<FlowPane prefHeight="500.0" prefWidth="392.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="javafxapplication.Controller.User.ListUserController">
<children>
<Button mnemonicParsing="false" onAction="#textTolukta" prefHeight="27.0" prefWidth="88.0" text="Толукта">
<FlowPane.margin>
<Insets bottom="15.0" />
</FlowPane.margin>
</Button>
<TableView fx:id="UserListTableView" prefHeight="200.0" prefWidth="392.0">
<columns>
<TableColumn fx:id="userName" prefWidth="110.0" text="Колдонуучунун аты" />
<TableColumn fx:id="email" prefWidth="110.0" text="Электрондук адреси" />
</columns>
<FlowPane.margin>
<Insets right="15.0" />
</FlowPane.margin>
</TableView>
</children>
</FlowPane>
39 changes: 20 additions & 19 deletions JavaFXApplication/src/main/resources/View/MainWindow.fxml
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<?import javafx.geometry.Insets?>
<VBox id="AnchorPane" prefHeight="500.0" prefWidth="392.0" xmlns="http://javafx.com/javafx/8"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="javafxapplication.Controller.MainController">
<children>
<MenuBar>
<menus>
<Menu text="Колдонуучулар">
<items>
<MenuItem mnemonicParsing="false" text="Колдонуучулардын тизмеси" onAction="#listSeller"/>
</items>
</Menu>
</menus>
</MenuBar>
<VBox fx:id="vbox">
<VBox.margin>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0"/>
</VBox.margin>
</VBox>
</children>
<VBox id="AnchorPane" prefHeight="500.0" prefWidth="392.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="javafxapplication.Controller.MainController">
<children>
<MenuBar>
<menus>
<Menu text="Колдонуучулар">
<items>
<MenuItem mnemonicParsing="false" onAction="#listUser" text="Колдонуучулардын тизмеси" />
<MenuItem mnemonicParsing="false" onAction="#addUser" text="Колдонуучу кошуууу-уу" />
</items>
</Menu>
</menus>
</MenuBar>
<VBox fx:id="vbox" prefWidth="363.0001220703125">
<VBox.margin>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
</VBox.margin>
</VBox>
</children>
</VBox>
Loading

0 comments on commit 1101c88

Please sign in to comment.