Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
idatt1002_2023_9
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Kluge Svendsrud
idatt1002_2023_9
Commits
5b575727
Commit
5b575727
authored
1 year ago
by
Harry Linrui XU
Browse files
Options
Downloads
Patches
Plain Diff
Added error msg to income and expenses in case of
IOexceptions
parent
d49e796f
No related branches found
No related tags found
3 merge requests
!43
Merging frontend-testing into master
,
!38
"Made progressbar dynamic in accordance to spending. Added balance field....
,
!37
Made the sub progress bars respond to changes in expense
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/no/ntnu/idatt1002/demo/controller/IncomeExpenseController.java
+41
-25
41 additions, 25 deletions
...nu/idatt1002/demo/controller/IncomeExpenseController.java
src/main/resources/view/IncomeAndExpenses.fxml
+16
-11
16 additions, 11 deletions
src/main/resources/view/IncomeAndExpenses.fxml
with
57 additions
and
36 deletions
src/main/java/no/ntnu/idatt1002/demo/controller/IncomeExpenseController.java
+
41
−
25
View file @
5b575727
...
...
@@ -108,6 +108,9 @@ public class IncomeExpenseController implements FinanceController {
@FXML
private
Label
title
;
@FXML
private
Label
errorMsg
;
@FXML
private
MenuItem
editIncomeMenu
;
...
...
@@ -136,31 +139,37 @@ public class IncomeExpenseController implements FinanceController {
@FXML
private
PieChart
incomePieChart
;
FileHandling
fileHandling
;
@FXML
public
void
initialize
()
throws
IOException
{
public
void
initialize
()
{
fileHandling
=
new
FileHandling
();
//Initialize columns
setColumns
();
//Initialize registers and tableview
incomeRegister
=
loadIncomeDataFromFile
(
"Income"
);
income
=
FXCollections
.
observableArrayList
(
incomeRegister
.
getItems
());
incomeTableView
.
setItems
(
income
);
try
{
//Initialize registers and tableview
incomeRegister
=
loadIncomeDataFromFile
(
"Income"
);
income
=
FXCollections
.
observableArrayList
(
incomeRegister
.
getItems
());
incomeTableView
.
setItems
(
income
);
expenseRegister
=
loadExpenseDataFromFile
(
"Expense"
);
expenses
=
FXCollections
.
observableArrayList
(
expenseRegister
.
getItems
());
expenseTableView
.
setItems
(
expenses
);
expenseRegister
=
loadExpenseDataFromFile
(
"Expense"
);
expenses
=
FXCollections
.
observableArrayList
(
expenseRegister
.
getItems
());
expenseTableView
.
setItems
(
expenses
);
//Setting pie chart values to correspond with the registers
incomePieChart
.
setLegendSide
(
Side
.
RIGHT
);
//Setting pie chart values to correspond with the registers
incom
ePieChart
.
setL
egendSide
(
Side
.
RIGHT
);
expensePieChart
.
setLegendSide
(
Side
.
RIGHT
);
expens
ePieChart
.
setL
abelLineLength
(
10
);
expensePieChart
.
setLegendSide
(
Side
.
RIGHT
);
expensePieChart
.
setLabelLineLength
(
10
);
refreshPieCharts
();
}
catch
(
IOException
ioe
)
{
errorMsg
.
setOpacity
(
1
);
}
refreshPieCharts
();
refreshProgress
();
formatDatePicker
();
...
...
@@ -320,7 +329,8 @@ public class IncomeExpenseController implements FinanceController {
// Set the Dialog's content to the loaded FXML file
dialog
.
getDialogPane
().
setContent
(
loader
.
load
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
errorMsg
.
setText
(
"Error in loading in dialog box"
);
errorMsg
.
setOpacity
(
1
);
}
// Get the controller for the loaded FXML file
...
...
@@ -355,7 +365,8 @@ public class IncomeExpenseController implements FinanceController {
// Set the Dialog's content to the loaded FXML file
dialog
.
getDialogPane
().
setContent
(
loader
.
load
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
errorMsg
.
setText
(
"Error in loading in dialog box"
);
errorMsg
.
setOpacity
(
1
);
}
// Get the controller for the loaded FXML file
...
...
@@ -544,18 +555,23 @@ public class IncomeExpenseController implements FinanceController {
/**
* Switches scenes back to main menu, by loading a new FXML file and setting the scene to this location.
* @param event A button click on the return to main menu button
* @throws IOException If an error occurs with loading any of the FXML files.
*/
@FXML
public
void
returnToMainMenu
(
javafx
.
event
.
ActionEvent
event
)
throws
IOException
{
saveDataToFile
();
FXMLLoader
loader
=
new
FXMLLoader
();
loader
.
setLocation
(
getClass
().
getResource
(
"/view/MainMenuNew.fxml"
));
public
void
returnToMainMenu
(
javafx
.
event
.
ActionEvent
event
)
{
try
{
saveDataToFile
();
FXMLLoader
loader
=
new
FXMLLoader
();
loader
.
setLocation
(
getClass
().
getResource
(
"/view/MainMenuNew.fxml"
));
Parent
root
=
loader
.
load
();
Stage
stage
=
(
Stage
)
((
Node
)
event
.
getSource
()).
getScene
().
getWindow
();
Scene
scene
=
new
Scene
(
root
);
stage
.
setScene
(
scene
);
stage
.
show
();
}
catch
(
IOException
ioe
)
{
errorMsg
.
setText
(
"Error in saving to file"
);
errorMsg
.
setOpacity
(
1
);
}
Parent
root
=
loader
.
load
();
Stage
stage
=
(
Stage
)
((
Node
)
event
.
getSource
()).
getScene
().
getWindow
();
Scene
scene
=
new
Scene
(
root
);
stage
.
setScene
(
scene
);
stage
.
show
();
}
}
This diff is collapsed.
Click to expand it.
src/main/resources/view/IncomeAndExpenses.fxml
+
16
−
11
View file @
5b575727
...
...
@@ -63,11 +63,16 @@
</Pane>
</left>
<center>
<Label
fx:id=
"title"
text=
"INCOME AND EXPENSES"
textAlignment=
"CENTER"
BorderPane.alignment=
"CENTER"
>
<font>
<Font
name=
"Lucida Console"
size=
"48.0"
/>
</font>
</Label>
<Pane
BorderPane.alignment=
"CENTER"
>
<children>
<Label
fx:id=
"title"
layoutX=
"100.0"
layoutY=
"47.0"
text=
"INCOME AND EXPENSES"
textAlignment=
"CENTER"
>
<font>
<Font
name=
"Lucida Console"
size=
"48.0"
/>
</font>
</Label>
<Label
fx:id=
"errorMsg"
layoutX=
"309.0"
layoutY=
"112.0"
opacity=
"0.0"
text=
"Couldn't load saved data"
textAlignment=
"CENTER"
textFill=
"#f20808"
/>
</children>
</Pane>
</center>
<VBox.margin>
<Insets
left=
"15.0"
/>
...
...
@@ -155,11 +160,6 @@
</ContextMenu>
</contextMenu>
</TableView>
<Label
fx:id=
"inSum"
text=
"Sum: "
>
<font>
<Font
name=
"Lucida Console"
size=
"14.0"
/>
</font>
</Label>
</children>
</VBox>
<Pane
GridPane.columnIndex=
"1"
GridPane.rowIndex=
"1"
>
...
...
@@ -179,6 +179,11 @@
<Font
name=
"Lucida Console"
size=
"14.0"
/>
</font>
</Text>
<Label
fx:id=
"inSum"
layoutX=
"64.0"
layoutY=
"4.0"
text=
"Sum: "
>
<font>
<Font
name=
"Lucida Console"
size=
"14.0"
/>
</font>
</Label>
</children>
</Pane>
<VBox
GridPane.rowIndex=
"3"
>
...
...
@@ -205,7 +210,7 @@
</TableView>
<Label
fx:id=
"expSum"
text=
"Sum: "
>
<font>
<Font
name=
"Lucida Console"
size=
"1
4
.0"
/>
<Font
name=
"Lucida Console"
size=
"1
2
.0"
/>
</font>
</Label>
</children>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment