Resolved the conflicts. We should check if the JavaDoc is still in the right place, because it looked a little weird while resolving the conflicts
Merge branch 'master' into 'fix/checkstyleAndComments' # Conflicts: # src/Client/src/main/java/greenify/client/controller/DashBoardController.java # src/Server/src/main/java/greenify/server/data/model/User.java # src/Server/src/main/java/greenify/server/service/UserService.java # src/Server/src/test/java/greenify/server/data/model/UserTest.java # src/Server/src/test/java/greenify/server/service/UserServiceTest.java
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
package greenify.client.controller;
|
||||
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.Slider;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
@Controller
|
||||
public class CalculatorController {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@FXML
|
||||
private Button calculatorGetStartedButton;
|
||||
@FXML
|
||||
private Button calculatorTravelButton;
|
||||
@FXML
|
||||
private Button calculatorHomeButton;
|
||||
@FXML
|
||||
private Button calculatorFoodButton;
|
||||
@FXML
|
||||
private Button calculatorShoppingButton;
|
||||
@FXML
|
||||
private AnchorPane getStartedPane;
|
||||
@FXML
|
||||
private ScrollPane travelPane;
|
||||
@FXML
|
||||
private AnchorPane homePane;
|
||||
@FXML
|
||||
private AnchorPane foodPane;
|
||||
@FXML
|
||||
private AnchorPane shoppingPane;
|
||||
@FXML
|
||||
private Slider peopleInHouseholdSLider;
|
||||
@FXML
|
||||
private Label peopleInHouseHoldLabel;
|
||||
@FXML
|
||||
private Slider annualIncomeSlider;
|
||||
@FXML
|
||||
private Label annualIncomeLabel;
|
||||
@FXML
|
||||
private Button saveButton;
|
||||
@FXML
|
||||
private Button getStartedNextButton;
|
||||
|
||||
/**
|
||||
* initializes the window, performs some actions before loading all other things.
|
||||
* it sets the sliders to snap to the ticks
|
||||
* it adds listeners to all the sliders for updating the label next to them
|
||||
*/
|
||||
public void initialize() {
|
||||
peopleInHouseholdSLider.setSnapToTicks(true);
|
||||
annualIncomeSlider.setSnapToTicks(true);
|
||||
//add listener to slider for amount of people in household
|
||||
peopleInHouseholdSLider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
peopleInHouseHoldLabel.setText("" + newValue.intValue());
|
||||
}
|
||||
});
|
||||
|
||||
//add listener to slider for annual income
|
||||
annualIncomeSlider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
annualIncomeLabel.setText("" + (newValue.intValue() * 1000));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'get started' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the button
|
||||
*/
|
||||
public void displayGetStarted(ActionEvent event) {
|
||||
getStartedPane.setVisible(true);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'travel' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the button
|
||||
*/
|
||||
public void displayTravel(ActionEvent event) {
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(true);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'home' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the button
|
||||
*/
|
||||
public void displayHome(ActionEvent event) {
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(true);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'food' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the button
|
||||
*/
|
||||
public void displayFood(ActionEvent event) {
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(true);
|
||||
shoppingPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'shopping' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the button
|
||||
*/
|
||||
public void displayShopping(ActionEvent event) {
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package greenify.client.controller;
|
||||
|
||||
import com.sun.javafx.scene.control.skin.ButtonSkin;
|
||||
import greenify.client.Application;
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.animation.PathTransition;
|
||||
@@ -8,10 +9,13 @@ import javafx.animation.ScaleTransition;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.shape.Line;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -55,6 +59,9 @@ public class DashBoardController {
|
||||
private AnchorPane menuBar;
|
||||
@FXML
|
||||
private Button addNewActivityButton;
|
||||
@FXML
|
||||
private Button calculateFootPrintButton;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -71,6 +78,12 @@ public class DashBoardController {
|
||||
activitiesButton.setSkin(new MyButtonSkin(activitiesButton));
|
||||
userButton.setSkin(new MyButtonSkin(userButton));
|
||||
friendsButton.setSkin(new MyButtonSkin(friendsButton));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public UserService getUserService() {
|
||||
return userService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +152,6 @@ public class DashBoardController {
|
||||
userPane.setVisible(false);
|
||||
activitiesPane.setVisible(false);
|
||||
friendsPane.setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
//sets the slide in transition for startup
|
||||
@@ -148,6 +160,18 @@ public class DashBoardController {
|
||||
pathTrans.play();
|
||||
}
|
||||
|
||||
public void openCalculator() throws IOException {
|
||||
Parent calc = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/calculator.fxml"));
|
||||
Scene scene = new Scene(calc);
|
||||
scene.getStylesheets().add(getClass().getClassLoader().getResource("stylesheets/calculatorStyle.css").toExternalForm());
|
||||
Stage calcStage = new Stage();
|
||||
|
||||
calcStage.setScene(scene);
|
||||
calcStage.setTitle("Calculate CO2 footprint - " + userService.currentUser.getName());
|
||||
calcStage.show();
|
||||
}
|
||||
|
||||
//class for the animations on the navigation buttons
|
||||
public class MyButtonSkin extends ButtonSkin {
|
||||
/**
|
||||
@@ -172,5 +196,6 @@ public class DashBoardController {
|
||||
scaleDown.setToX(1.0);
|
||||
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,4 +98,18 @@ public class UserService {
|
||||
return this.restTemplate.getForObject(builder.build()
|
||||
.encode().toUri(), String.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
public String addFriend(String name, String friend) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/addFriend")
|
||||
.queryParam("name", name)
|
||||
.queryParam("friend",friend);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
String result = this.restTemplate.getForObject(builder.build()
|
||||
.encode().toUri(), String.class);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user