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
9a1e752e
Commit
9a1e752e
authored
1 year ago
by
Harry Linrui XU
Browse files
Options
Downloads
Patches
Plain Diff
Added event filter to okBtn. Brings up error message if no budget is selected
parent
618d4c45
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!43
Merging frontend-testing into master
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/no/ntnu/idatt1002/demo/controller/SelectBudgetController.java
+17
-1
17 additions, 1 deletion
...tnu/idatt1002/demo/controller/SelectBudgetController.java
src/main/resources/view/SelectBudget.fxml
+8
-3
8 additions, 3 deletions
src/main/resources/view/SelectBudget.fxml
with
25 additions
and
4 deletions
src/main/java/no/ntnu/idatt1002/demo/controller/SelectBudgetController.java
+
17
−
1
View file @
9a1e752e
...
...
@@ -6,6 +6,8 @@ import javafx.collections.ObservableList;
import
javafx.event.ActionEvent
;
import
javafx.fxml.FXML
;
import
javafx.scene.Node
;
import
javafx.scene.control.Button
;
import
javafx.scene.control.Label
;
import
javafx.scene.control.ListView
;
import
javafx.scene.input.MouseButton
;
import
javafx.stage.Stage
;
...
...
@@ -16,6 +18,12 @@ import no.ntnu.idatt1002.demo.data.Budget.FileHandlingSelectedBudget;
public
class
SelectBudgetController
{
@FXML
Button
okBtn
;
@FXML
private
Label
errorMsg
;
@FXML
private
ListView
<
String
>
budgetListView
;
...
...
@@ -25,6 +33,14 @@ public class SelectBudgetController {
@FXML
public
void
initialize
()
throws
IOException
{
okBtn
.
addEventFilter
(
ActionEvent
.
ACTION
,
event
->
{
if
(
budgetListView
.
getSelectionModel
().
getSelectedItem
()
==
null
)
{
errorMsg
.
setOpacity
(
1
);
event
.
consume
();
}
});
try
{
if
(
FileHandlingBudgetArchive
.
isBudgetRegisterEmpty
())
{
budgetRegister
=
new
BudgetRegister
();
...
...
@@ -59,7 +75,7 @@ public class SelectBudgetController {
@FXML
public
void
exitWindow
(
ActionEvent
event
)
throws
IOException
{
FileHandlingSelectedBudget
.
update
SelectedBudget
(
""
);
FileHandlingSelectedBudget
.
clear
SelectedBudget
();
final
Node
source
=
(
Node
)
event
.
getSource
();
((
Stage
)
source
.
getScene
().
getWindow
()).
close
();
}
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/view/SelectBudget.fxml
+
8
−
3
View file @
9a1e752e
...
...
@@ -10,7 +10,7 @@
<DialogPane
prefHeight=
"300.0"
prefWidth=
"400.0"
xmlns=
"http://javafx.com/javafx/19"
xmlns:fx=
"http://javafx.com/fxml/1"
fx:controller=
"no.ntnu.idatt1002.demo.controller.SelectBudgetController"
>
<content>
<VBox
alignment=
"CENTER"
prefWidth=
"362.0"
>
<VBox
alignment=
"CENTER"
prefWidth=
"362.0"
spacing=
"5.0"
>
<children>
<Label
text=
"Select budget project"
>
<font>
...
...
@@ -18,15 +18,20 @@
</font>
</Label>
<ListView
fx:id=
"budgetListView"
prefHeight=
"200.0"
prefWidth=
"200.0"
/>
<Label
fx:id=
"errorMsg"
opacity=
"0.0"
text=
"Please select a budget"
textFill=
"#e60707"
>
<font>
<Font
name=
"Lucida Console"
size=
"14.0"
/>
</font>
</Label>
<HBox
alignment=
"CENTER"
prefHeight=
"100.0"
prefWidth=
"200.0"
spacing=
"5.0"
>
<children>
<Button
mnemonicParsing=
"false"
onAction=
"#exitWindow"
prefWidth=
"70.0"
text=
"Cancel"
/>
<Button
mnemonicParsing=
"false"
onAction=
"#selectBudget"
prefWidth=
"70.0"
text=
"OK"
/>
<Button
fx:id=
"okBtn"
mnemonicParsing=
"false"
onAction=
"#selectBudget"
prefWidth=
"70.0"
text=
"OK"
/>
</children>
</HBox>
<Label
text=
"Click on an entry to select it"
>
<font>
<Font
size=
"14.0"
/>
<Font
name=
"Lucida Console"
size=
"14.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