Skip to content

Commit 20c706e

Browse files
committed
Add parameters to composer
1 parent 722737b commit 20c706e

4 files changed

Lines changed: 21 additions & 24 deletions

File tree

patternfx-mvp/src/main/java/com/techsenger/patternfx/mvp/AbstractParentFxView.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ public abstract class AbstractParentFxView<P extends ParentPresenter<?, ?>>
3535

3636
public class Composer implements ParentFxView.Composer {
3737

38+
private ComposeParameters parameters = createParameters();
39+
3840
private final AbstractParentFxView<?> view = AbstractParentFxView.this;
3941

4042
@Override
41-
public void compose(ComposeParameters params) {
43+
public void compose() {
4244
// empty
4345
}
4446

@@ -88,6 +90,15 @@ public String toTreeString() {
8890
public String toTreeString(BiConsumer<ParentPort, StringBuilder> appender) {
8991
return view.toTreeString(depthFirstIterator(), appender);
9092
}
93+
94+
@Override
95+
public ComposeParameters getParameters() {
96+
return this.parameters;
97+
}
98+
99+
protected ComposeParameters createParameters() {
100+
return null;
101+
}
91102
}
92103

93104
private final ObservableList<ChildFxView<?>> modifiableChildren = FXCollections.observableArrayList();

patternfx-mvp/src/main/java/com/techsenger/patternfx/mvp/AbstractParentPresenter.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,8 @@ public abstract class AbstractParentPresenter<V extends ParentView, C extends Pa
3131

3232
private C composer;
3333

34-
private ComposeParameters parameters;
35-
3634
public AbstractParentPresenter(V view) {
3735
super(view);
38-
this.parameters = createParameters();
3936
}
4037

4138
@Override
@@ -70,25 +67,10 @@ public void requestFocus() {
7067
@Override
7168
protected void postInitialize() {
7269
super.postInitialize();
73-
this.composer.compose(parameters);
74-
this.parameters = null;
70+
this.composer.compose();
7571
}
7672

7773
protected void setComposer(ParentComposer composer) {
7874
this.composer = (C) composer;
7975
}
80-
81-
/**
82-
* Creates the parameters to be passed to {@link ParentComposer#compose(ComposerParameters)} during the static
83-
* composition phase. After composition completes, the instance is set to {@code null} and is no longer accessible.
84-
*
85-
* @return the parameters for composition, or {@code null} if no parameters are required
86-
*/
87-
protected ComposeParameters createParameters() {
88-
return null;
89-
}
90-
91-
protected ComposeParameters getParameters() {
92-
return parameters;
93-
}
9476
}

patternfx-mvp/src/main/java/com/techsenger/patternfx/mvp/ComposeParameters.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
package com.techsenger.patternfx.mvp;
1818

1919
/**
20-
* Marker interface for parameters passed to {@link ParentComposer#compose(Parameters)}.
21-
* Implementations carry initialization data required by child components during static composition.
2220
*
2321
* @author Pavel Castornii
2422
*/

patternfx-mvp/src/main/java/com/techsenger/patternfx/mvp/ParentComposer.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
*/
2727
public interface ParentComposer {
2828

29+
/**
30+
* Returns the parameters of the composer.
31+
*
32+
* @return the parameters or null.
33+
*/
34+
ComposeParameters getParameters();
35+
2936
/**
3037
* Composes the static structure of this component by creating and adding its default child components. This
3138
* method is intended for static composition, where child components are created once during component
@@ -36,9 +43,8 @@ public interface ParentComposer {
3643
* that all child components are properly initialized and integrated into the component tree before the parent
3744
* component starts its normal operation.
3845
*
39-
* @param params the parameters to be used during composition, or {@code null} if no parameters are required
4046
*/
41-
void compose(ComposeParameters params);
47+
void compose();
4248

4349
/**
4450
* Returns an unmodifiable observable list of child components.

0 commit comments

Comments
 (0)