Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IT1901
todo-list-example
Commits
368e7874
Commit
368e7874
authored
Sep 25, 2020
by
Hallvard Trætteberg
Browse files
Font awesome support
parent
42dec364
Changes
3
Hide whitespace changes
Inline
Side-by-side
todolist/fxui/pom.xml
View file @
368e7874
...
...
@@ -11,6 +11,15 @@
<artifactId>
fxui
</artifactId>
<!--
<repositories>
<repository>
<id>bintray</id>
<url>https://dl.bintray.com/jerady/maven</url>
</repository>
</repositories>
-->
<dependencies>
<dependency>
...
...
@@ -37,6 +46,21 @@
<version>
14.0.2
</version>
</dependency>
<!--
<dependency>
<groupId>de.jensd</groupId>
<artifactId>fontawesomefx-fontawesome</artifactId>
<version>4.7.0-11</version>
</dependency>
-->
<!-- https://mvnrepository.com/artifact/de.jensd/fontawesomefx-controls -->
<dependency>
<groupId>
de.jensd
</groupId>
<artifactId>
fontawesomefx-fontawesome
</artifactId>
<version>
4.7.0-9.1.2
</version>
</dependency>
<dependency>
<groupId>
org.junit.jupiter
</groupId>
<artifactId>
junit-jupiter-api
</artifactId>
...
...
@@ -66,6 +90,24 @@
</dependency>
</dependencies>
<profiles>
<profile>
<id>
fontawesome
</id>
<build>
<plugins>
<plugin>
<groupId>
org.openjfx
</groupId>
<artifactId>
javafx-maven-plugin
</artifactId>
<version>
0.0.4
</version>
<configuration>
<mainClass>
de.jensd.fx.glyphs.fontawesome.demo.FontAwesomeIconsDemoApp
</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
...
...
@@ -79,7 +121,7 @@
<groupId>
org.openjfx
</groupId>
<artifactId>
javafx-maven-plugin
</artifactId>
<version>
0.0.4
</version>
<configuration>
<configuration>
<options>
<!--
<option>dash dash enable-preview</option>
...
...
todolist/fxui/src/main/java/todolist/ui/TodoController.java
View file @
368e7874
...
...
@@ -15,8 +15,11 @@ import java.nio.file.Paths;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.function.Predicate
;
import
javafx.fxml.FXML
;
import
javafx.scene.Node
;
import
javafx.scene.control.Button
;
import
javafx.scene.control.ListCell
;
import
javafx.scene.control.ListView
;
import
javafx.scene.control.TextField
;
import
todolist.core.TodoItem
;
...
...
@@ -136,6 +139,34 @@ public class TodoController {
for
(
Button
button
:
selectionButtons
)
{
button
.
setDisable
(
disable
);
}
double
rowLayoutY
=
getRowLayoutY
(
todoListView
,
listCell
->
isSelected
(
todoListView
,
listCell
),
0
);
System
.
out
.
println
(
rowLayoutY
);
}
private
boolean
isSelected
(
ListView
<?>
listView
,
ListCell
<?>
listCell
)
{
return
isSelected
(
listView
,
listCell
.
getItem
());
}
private
boolean
isSelected
(
ListView
<?>
listView
,
Object
item
)
{
return
todoListView
.
getSelectionModel
().
getSelectedItems
().
contains
(
item
);
}
@SuppressWarnings
(
"unchecked"
)
private
<
T
>
double
getRowLayoutY
(
ListView
<
T
>
listView
,
Predicate
<
ListCell
<
T
>>
test
,
int
num
)
{
for
(
Node
child
:
listView
.
lookupAll
(
".list-cell"
))
{
if
(
child
instanceof
ListCell
)
{
ListCell
<
T
>
listCell
=
(
ListCell
<
T
>)
child
;
if
(
test
.
test
(
listCell
)
&&
num
--
==
0
)
{
double
dy
=
0
;
Node
node
=
listCell
;
while
(
node
!=
todoListView
)
{
dy
+=
node
.
getLayoutY
();
node
=
node
.
getParent
();
}
return
dy
;
}
}
}
return
-
1
;
}
@FXML
...
...
todolist/fxui/src/main/resources/todolist/ui/Todo.fxml
View file @
368e7874
...
...
@@ -4,21 +4,38 @@
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Tooltip?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.ListView?>
<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
<VBox
xmlns:fx=
"http://javafx.com/fxml/1"
fx:controller=
"todolist.ui.TodoController"
>
<fx:define>
<String
fx:id=
"userTodoListPath"
fx:value=
"todolist.json"
/>
<String
fx:id=
"sampleTodoListResource"
fx:value=
"sample-todolist.json"
/>
</fx:define>
<HBox>
<Button
fx:id=
"newTodoItemButton"
text=
"New Item"
onAction=
"#handleNewTodoItemAction"
/>
<Button
fx:id=
"newTodoItemButton"
onAction=
"#handleNewTodoItemAction"
>
<graphic>
<FontAwesomeIconView
glyphName=
"PLUS"
size=
"18px"
glyphStyle=
"-fx-fill: green"
/>
</graphic>
<tooltip>
<Tooltip
text=
"New Item"
/>
</tooltip>
</Button>
<TextField
fx:id=
"newTodoItemText"
promptText=
"Skriv inn tekst her"
onAction=
"#handleNewTodoItemAction"
/>
</HBox>
<ListView
fx:id=
"todoListView"
>
</ListView>
<HBox>
<Button
fx:id=
"deleteTodoItemButton"
text=
"Delete Item"
onAction=
"#handleDeleteItemAction"
/>
<Button
fx:id=
"deleteTodoItemButton"
onAction=
"#handleDeleteItemAction"
>
<graphic>
<FontAwesomeIconView
glyphName=
"TIMES_CIRCLE_ALT"
size=
"18px"
glyphStyle=
"-fx-fill: red"
/>
</graphic>
<tooltip>
<Tooltip
text=
"Delete Item"
/>
</tooltip>
</Button>
</HBox>
</VBox>
Hallvard Trætteberg
@hal
mentioned in issue
#11
·
Sep 25, 2020
mentioned in issue
#11
mentioned in issue #11
Toggle commit list
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment