Skip to content

Commit

Permalink
#3 toluk ishtei elek
Browse files Browse the repository at this point in the history
  • Loading branch information
adik93 committed Dec 26, 2013
1 parent 7fadc7c commit 9868b7c
Show file tree
Hide file tree
Showing 22 changed files with 489 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package javafxapplication.Controller.District;

import javafx.fxml.Initializable;

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

public class ListDistrictController implements Initializable {

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

}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package javafxapplication.Controller.House;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafxapplication.Model.District;
import javafxapplication.Model.House;
import javafxapplication.Proxy.HouseProxy;

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

/**
* Created with IntelliJ IDEA.
* User: admin
* Date: 12/26/13
* Time: 6:04 PM
* To change this template use File | Settings | File Templates.
*/
public class ListHouseController implements Initializable {
public TableColumn user;
public TableColumn district;
public TableColumn price;
public TableColumn adress;
public TableView tableView;
public ComboBox districComboBox;
HouseProxy houseProxy = new HouseProxy();

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
user.setCellValueFactory(new PropertyValueFactory<House, String>("user"));
district.setCellValueFactory(new PropertyValueFactory<House, String>("district"));
price.setCellValueFactory(new PropertyValueFactory<House, String>("price"));
adress.setCellValueFactory(new PropertyValueFactory<House, String>("adress"));
}


@FXML
private void handleButtonAction(ActionEvent event) {
District district = (District)districComboBox.getValue();
// Integer count = Integer.valueOf(text3.getText());
// Double price = product.getPrice();
long districtId = (district!=null)? (long) district.getId() :0;

//WrittingOffProductRequest request = new WrittingOffProductRequest(productId,null,count,price);

//soldProductsProxy.writtingOffProduct(request);
}

public void textTolukta(ActionEvent actionEvent) {
List<House> houses = Arrays.asList(houseProxy.getHouseInfo());
tableView.getItems().setAll(houses);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ private void openControl(String controlPath) throws IOException {
public void listSeller(ActionEvent actionEvent) throws IOException {
openControl("/View/ListUserControl.fxml");
}

public void listHouses(ActionEvent actionEvent) throws IOException {
openControl("/View/ListHousesControl.fxml");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ public void initialize(URL url, ResourceBundle resourceBundle) {

}
}

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

public class District {
private long id;
private String districtName;

protected District() {}

public District(String districtName) {
this.districtName = districtName;
}


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

public String getDistrictName() {
return districtName;
}
public String toString()
{
return getDistrictName();

}

public void setDistrictName(String districtName) {
this.districtName = districtName;
}
}
61 changes: 61 additions & 0 deletions JavaFXApplication/src/main/java/javafxapplication/Model/House.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package javafxapplication.Model;

public class House {
private long id;
private String adress;
private Double price;
private District district;
private User user;

protected House() {}

public House(String adress, Double price, District district, User user) {
this.adress = adress;
this.price = price;
this.district = district;
this.user = user;
}


public String getAdress() {
return adress;
}

public void setAdress(String adress) {
this.adress = adress;
}

public Double getPrice() {
return price;
}

public void setPrice(Double price) {
this.price = price;
}

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


public District getDistrict() {
return district;
}

public void setDistrict(District district) {
this.district = district;
}

public User getUser() {
return user;
}

public void setUser(User user) {
this.user = user;
}
}

32 changes: 19 additions & 13 deletions JavaFXApplication/src/main/java/javafxapplication/Model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,39 @@

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 toString()
{
return getUsername();

}

public String getEmail() {
return email;
}

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

public long getId() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package javafxapplication.Proxy;

import javafxapplication.Model.District;

public class DistrictProxy extends Proxy {
public District[] getSellers() {
return restTemplate.getForObject(urlService.GetServerUrl("/districts/"), District[].class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package javafxapplication.Proxy;

import javafxapplication.Model.House;

public class HouseProxy extends Proxy {
public House[] getHouseInfo() {
return restTemplate.getForObject(urlService.GetServerUrl("/houses/"), House[].class);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* Time: 2:03
* To change this template use File | Settings | File Templates.
*/
public class UserProxy extends Proxy {

public class UserProxy extends Proxy {
public User[] getSellers() {
return restTemplate.getForObject(urlService.GetServerUrl("/users/"), User[].class);
}
}

24 changes: 24 additions & 0 deletions JavaFXApplication/src/main/resources/View/ListHousesControl.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>

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

<FlowPane prefHeight="500.0" prefWidth="496.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="javafxapplication.Controller.House.ListHouseController">
<children>
<TableView prefHeight="200.0" prefWidth="378.0">
<columns>
<TableColumn maxWidth="5000.0" minWidth="10.0" prefWidth="105.0" text="Колдонуучу" fx:id="user"/>
<TableColumn maxWidth="5000.0" minWidth="10.0" prefWidth="130.0" text="Жайгашкан район" fx:id="district" />
<TableColumn prefWidth="75.0" text="Баасы" fx:id="price" />
<TableColumn prefWidth="75.0" text="Адрес" fx:id="adress"/>
</columns>
</TableView>
<Button mnemonicParsing="false" onAction="#handleButtonAction" text="Фильтрлөө" />
<ComboBox fx:id="districComboBox" prefHeight="21.0" prefWidth="123.0" promptText="Район тандоо">
</ComboBox>
<Button mnemonicParsing="false" onAction="#textTolukta" text="Толукта" />
</children>
</FlowPane>
7 changes: 7 additions & 0 deletions JavaFXApplication/src/main/resources/View/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
<items>
<MenuItem mnemonicParsing="false" text="Колдонуучулардын тизмеси" onAction="#listSeller"/>
</items>

</Menu>
<Menu text="тизмесин чыгаруу">
<items>
<MenuItem mnemonicParsing="false" text="Квартираларын тизмесин чыгаруу" onAction="#listHouses"/>
</items>

</Menu>
</menus>
</MenuBar>
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/hello/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public DataSource dataSource() {
DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
driverManagerDataSource.setDriverClassName("com.mysql.jdbc.Driver");
driverManagerDataSource.setUsername("root");
driverManagerDataSource.setUrl("jdbc:mysql://localhost:3306/test");
driverManagerDataSource.setUrl("jdbc:mysql://localhost:3306/house");
driverManagerDataSource.setPassword("");
return driverManagerDataSource;
//return new EmbeddedDatabaseBuilder().setType(H2).build();
Expand Down
27 changes: 27 additions & 0 deletions server/src/main/java/hello/Controller/DistrictController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package hello.Controller;

import hello.Config;
import hello.Model.District;
import hello.Model.Repository.DistrictRepository;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Component
@Controller
public class DistrictController {
@RequestMapping(value = "/districts")
public @ResponseBody
Iterable<District> listDistricts() {

return getRepository().findAll();
}

public DistrictRepository getRepository() {
AbstractApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
return context.getBean(DistrictRepository.class);
}
}
28 changes: 28 additions & 0 deletions server/src/main/java/hello/Controller/HouseController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package hello.Controller;

import hello.Config;
import hello.Model.House;
import hello.Model.Repository.HouseRepository;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Component
@Controller
public class HouseController {
@RequestMapping(value = "/houses")
public @ResponseBody
Iterable<House> listHouses() {

return getRepository().findAll();
}

public HouseRepository getRepository() {
AbstractApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
return context.getBean(HouseRepository.class);
}
}

Loading

0 comments on commit 9868b7c

Please sign in to comment.