Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
course-material
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
IT1901
course-material
Commits
4f111ca8
Commit
4f111ca8
authored
Oct 11, 2019
by
George Adrian Stoica
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed the cell UI to be generated with code and dropped the fxml
parent
b168dca5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
214 additions
and
143 deletions
+214
-143
simpleexample2/fxui/src/main/java/simpleex/ui/FxApp.java
simpleexample2/fxui/src/main/java/simpleex/ui/FxApp.java
+102
-97
simpleexample2/fxui/src/main/java/simpleex/ui/LatLongCell.java
...eexample2/fxui/src/main/java/simpleex/ui/LatLongCell.java
+1
-1
simpleexample2/fxui/src/main/java/simpleex/ui/LatLongCellController.java
...fxui/src/main/java/simpleex/ui/LatLongCellController.java
+111
-45
No files found.
simpleexample2/fxui/src/main/java/simpleex/ui/FxApp.java
View file @
4f111ca8
...
...
@@ -90,6 +90,11 @@ public class FxApp extends Application {
+
" tortor maximus tristique. Vestibulum at mauris massa. Nulla laoreet, velit eu lobortis efficitur, "
+
"tortor sem molestie massa, at pellentesque tortor elit a nibh. In vel orci vitae magna rhoncus pulvinar "
+
"sit amet id erat."
);
latLongWithMetaData
.
getMetaData
().
addTags
(
"tag 1"
,
"tag 2"
,
"a much longer tag 3"
);
latLongWithMetaData
.
getMetaData
().
setProperty
(
"custom property 1"
,
"this is the value for custom property 1"
);
latLongWithMetaData
.
getMetaData
().
setIntegerProperty
(
"custom property 2 (int)"
,
13
);
latLongWithMetaData
.
getMetaData
().
setDoubleProperty
(
"custom property 3 (double)"
,
35.13
);
latLongWithMetaData
.
getMetaData
().
setBooleanProperty
(
"custom property 4 (boolean)"
,
false
);
latLongs
.
addLatLong
(
latLongWithMetaData
);
return
latLongs
;
}
...
...
simpleexample2/fxui/src/main/java/simpleex/ui/LatLongCell.java
View file @
4f111ca8
...
...
@@ -21,7 +21,7 @@ public class LatLongCell extends ListCell<LatLong> {
}
else
{
LatLongCellController
latLongCellController
=
new
LatLongCellController
();
latLongCellController
.
setLatLong
(
location
);
setGraphic
(
latLongCellController
.
getCellView
());
setGraphic
(
latLongCellController
.
getCellView
(
this
.
isSelected
()
));
setPrefHeight
(
Region
.
USE_COMPUTED_SIZE
);
//setPrefHeight(50.0);
...
...
simpleexample2/fxui/src/main/java/simpleex/ui/LatLongCellController.java
View file @
4f111ca8
package
simpleex.ui
;
import
java.io.IOException
;
import
javafx.fxml.FXML
;
import
javafx.fxml.FXMLLoader
;
import
java.util.Iterator
;
import
javafx.geometry.Insets
;
import
javafx.scene.control.Button
;
import
javafx.scene.control.Label
;
import
javafx.scene.layout.HBox
;
import
javafx.scene.layout.Region
;
import
javafx.scene.layout.VBox
;
import
simpleex.core.LatLong
;
import
simpleex.core.MetaData
;
/**
* The controller for the renderer in the ListView cells
* containing the locations
* @author Adrian Stoica
*
*/
public
class
LatLongCellController
{
@FXML
/**
* The main container of the cell UI
*/
private
Region
root
;
/**
* the horizontal box containing the coordinates
* and the add/edit button
*/
private
HBox
hBox
;
/**
* The button that will allow opening the editor
* for the selected item
*/
private
Button
editMetadataButton
;
/**
* container for the additional metadata
*/
private
VBox
vBox
;
@FXML
/**
* the label for the name property
*/
private
Label
nameLabel
;
@FXML
/**
* the label for the coordinates
*/
private
Label
coordinatesLabel
;
@FXML
/**
* the label for the description
*/
private
Label
descriptionLabel
;
/**
* the current LatLong object that needs to be displayed
*/
private
LatLong
latLong
;
/**
* create a new controller for managing a LatLong list cell
*/
public
LatLongCellController
()
{
FXMLLoader
fxmlLoader
=
new
FXMLLoader
(
getClass
().
getResource
(
"LatLongCell.fxml"
));
fxmlLoader
.
setController
(
this
);
try
{
vBox
=
fxmlLoader
.
load
();
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
super
();
}
/**
* set the location object
* @param latLong the reference to the object to be displayed
*/
public
void
setLatLong
(
LatLong
latLong
)
{
this
.
latLong
=
latLong
;
if
(
latLong
!=
null
)
{
coordinatesLabel
.
setText
(
latLong
.
toString
());
if
(
this
.
latLong
.
hasMetaData
())
{
}
/**
* prepare the cell UI
* @param selected flag indicating that the item is selected
*/
protected
void
prepareView
(
boolean
selected
)
{
this
.
hBox
=
new
HBox
();
this
.
coordinatesLabel
=
new
Label
(
this
.
latLong
.
toString
());
coordinatesLabel
.
setPrefWidth
(
200.0
);
this
.
hBox
.
getChildren
().
add
(
coordinatesLabel
);
if
(
selected
)
{
this
.
editMetadataButton
=
new
Button
(
"..."
);
this
.
hBox
.
getChildren
().
add
(
editMetadataButton
);
}
if
(
this
.
latLong
.
hasMetaData
())
{
this
.
vBox
=
new
VBox
();
MetaData
metaData
=
this
.
latLong
.
getMetaData
();
if
(
metaData
.
hasProperty
(
MetaData
.
NAME_PROPERTY
))
{
nameLabel
=
new
Label
();
nameLabel
.
setText
(
metaData
.
getProperty
(
MetaData
.
NAME_PROPERTY
));
vBox
.
getChildren
().
add
(
nameLabel
);
}
else
{
nameLabel
.
setMaxHeight
(
0.0
);
}
vBox
.
getChildren
().
add
(
this
.
hBox
);
if
(
metaData
.
hasProperty
(
MetaData
.
DESCRIPTION_PROPERTY
))
{
descriptionLabel
=
new
Label
();
descriptionLabel
.
setText
(
metaData
.
getProperty
(
MetaData
.
DESCRIPTION_PROPERTY
));
descriptionLabel
.
setWrapText
(
true
);
descriptionLabel
.
setMaxHeight
(
50.0
);
descriptionLabel
.
setManaged
(
true
);
descriptionLabel
.
setMaxWidth
(
200.0
);
}
else
{
descriptionLabel
.
setMaxHeight
(
0.0
);
vBox
.
getChildren
().
add
(
descriptionLabel
);
}
vBox
.
autosize
();
}
else
{
nameLabel
.
setVisible
(
false
);
descriptionLabel
.
setVisible
(
false
);
//nameLabel.setMaxHeight(0.0);
//descriptionLabel.setMaxHeight(0.0);
vBox
.
setPrefHeight
(
30.0
);
final
Iterator
<
String
>
tags
=
metaData
.
tags
();
if
(
tags
.
hasNext
())
{
HBox
tagsBox
=
new
HBox
();
tagsBox
.
setSpacing
(
5.0
);
while
(
tags
.
hasNext
())
{
Label
tagLabel
=
new
Label
(
tags
.
next
());
tagLabel
.
setStyle
(
"-fx-background-color: #43464b; \r\n"
+
" -fx-text-fill: white;\r\n"
+
" -fx-border-radius: 3 3 3 3; \r\n"
+
" -fx-background-radius: 3 3 3 03; "
);
tagLabel
.
setPadding
(
new
Insets
(
0.0
,
3.0
,
0.0
,
3.0
));
tagsBox
.
getChildren
().
add
(
tagLabel
);
}
vBox
.
getChildren
().
add
(
tagsBox
);
}
this
.
root
=
this
.
vBox
;
}
else
{
this
.
root
=
this
.
hBox
;
}
}
public
Region
getCellView
()
{
return
this
.
vBox
;
/**
* get the UI for the cell based on selection and
* the available info in the latLong object
* @param selected flag indicating that the item is selected
* @return the root container for the cell UI
*/
public
Region
getCellView
(
boolean
selected
)
{
prepareView
(
selected
);
return
this
.
root
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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