-
Notifications
You must be signed in to change notification settings - Fork 2
Working With Layouts
Michael Gentry edited this page Oct 11, 2016
·
2 revisions
- Create a new FXML file.
- Make sure the
Use fx:root Construct
is selected, but do not enter a controller name. This setting can be found in the lower left corner of Scene Builder's editor, under the Document/Controller section. - Create an
AnchorPane
as the top-level element. This is important due to the expectations of the Java supporting classes in the project. - Create the UI inside the
AnchorPane
. Typically aVBox
or some other container is placed inside theAnchorPane
. Look at existing*Layout.fxml
files for ideas. - Save the UI as
*Layout.fxml
undersrc/main/resources/layouts
.
- Open the existing FXML file.
- Edit as needed, but do not remove the top-level
AnchorPane
or de-selectUse fx:root Construct
.
- Create a new Java UI window controller file in
src/main/java/org/apache/cayenne/modeler/layout
and make sure the Java class name matches the name of the corresponding*Layout.fxml
file (with.fxml
being replaced with.java
, of course). - The layout should extend
AbstractWindowLayout
. - The layout's constructor should call the superclass constructor, passing in a
Stage
and the path to the matching*Layout.fxml
. See existing component layouts for examples.
- Create a new Java UI component controller file in
src/main/java/org/apache/cayenne/modeler/layout
and make sure the Java class name matches the name of the corresponding*Layout.fxml
file (with.fxml
being replaced with.java
, of course). - The layout should extend
AbstractViewLayout
and possibly implementDetailEditorSupport
if it is a detail editor. See existing layout controllers for examples. - The layout's constructor should call the superclass constructor, passing in the parent component (which can be the window) and the path to the matching
*Layout.fxml
. See existing window layouts for examples.
-
initializeLayout()
-- Called after FXML is loaded from the superclass constructor. Override if the controller needs to initialize settings after FXML is loaded. The overridden method should callsuper.initializeLayout()
which in turn callsloadChildLayouts()
allowing child layouts to load and initialize before the parent tries to use them. If the layout does not require initialization, this method can be omitted. -
loadChildLayouts()
-- Called byinitializeLayout()
to allow layout children to be loaded into the parent layout and subsequently initialized. Override if the controller has additional FXML components to load. If the layout does not have children to load, this method can be omitted. NOTE: The child layouts will go through their owninitializeLayout()
andloadChildLayouts()
lifecycle. This allows more complex UIs to be composited together via separate FXML files and Java controllers.
If the layout is a detail editor (implements DetailEditorSupport
), the following lifecycle is expected:
-
setPropertyAdapter(CayennePropertyAdapter propertyAdapter)
-- Called to tell the detail editor/view which property adapter is to be used for editing. -
beginEditing()
-- Called to tell the detail editor that editing should begin and it should bind UI elements to the property adapter. -
endEditing()
-- Called to tell the detail editor that editing should end and it should unbind UI elements from the property adapter.