Skip to content

Commit 421c2b8

Browse files
refactor(view): enhance documentation and clarify method responsibilities
1 parent 6670fb2 commit 421c2b8

33 files changed

+1702
-293
lines changed

platform/core/viewers/src/main/java/tools/dynamia/viewers/View.java

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,58 +20,96 @@
2020
import java.io.Serializable;
2121

2222
/**
23-
* Interface representing a view with a value and descriptor.
23+
* Core abstraction for a UI view that holds a typed value and is driven by a {@link ViewDescriptor}.
2424
*
25-
* @param <T> the type of value managed by the view
25+
* <p>A {@code View} is the runtime representation of a UI component built by a {@link ViewRenderer}.
26+
* It is parameterized by the type {@code T} of the domain object (or value) it displays or edits.
27+
* The structure and behaviour of the view are defined by its associated {@link ViewDescriptor}.</p>
28+
*
29+
* <p>Views can be nested: a view may have a parent view, allowing composite UI hierarchies to be
30+
* constructed (e.g., a sub-form embedded inside a main form).</p>
31+
*
32+
* <p>Typical lifecycle:
33+
* <ol>
34+
* <li>A {@link ViewDescriptor} is resolved by {@link ViewDescriptorFactory}.</li>
35+
* <li>A {@code View} instance is created by {@link ViewFactory} using a {@link ViewRenderer}.</li>
36+
* <li>A value is set via {@link #setValue(Object)}, causing the view to reflect the domain object.</li>
37+
* </ol>
38+
* </p>
39+
*
40+
* @param <T> the type of the domain object (value) managed by this view
41+
* @see ViewDescriptor
42+
* @see ViewFactory
43+
* @see ViewRenderer
2644
*/
2745
public interface View<T> extends Serializable {
2846

2947
/**
30-
* Gets the value of the view.
48+
* Returns the current value held by this view.
3149
*
32-
* @return the value
50+
* @return the current value, or {@code null} if no value has been set
3351
*/
3452
T getValue();
3553

3654
/**
37-
* Sets the value of the view.
55+
* Sets the value to be displayed or edited by this view.
56+
*
57+
* <p>Implementations should update the visual state of the view to reflect the new value.</p>
3858
*
39-
* @param value the new value
59+
* @param value the new value; may be {@code null}
4060
*/
4161
void setValue(T value);
4262

4363
/**
44-
* Sets the view descriptor.
64+
* Assigns the {@link ViewDescriptor} that defines the structure and metadata of this view.
4565
*
46-
* @param viewDescriptor the new view descriptor
66+
* <p>This is typically called once during view construction by the {@link ViewFactory}.</p>
67+
*
68+
* @param viewDescriptor the descriptor to associate with this view; must not be {@code null}
4769
*/
4870
void setViewDescriptor(ViewDescriptor viewDescriptor);
4971

5072
/**
51-
* Gets the view descriptor.
73+
* Returns the {@link ViewDescriptor} that describes the structure and metadata of this view.
5274
*
53-
* @return the view descriptor
75+
* @return the view descriptor; may be {@code null} if not yet initialized
5476
*/
5577
ViewDescriptor getViewDescriptor();
5678

5779
/**
58-
* Gets the parent view.
80+
* Returns the parent view that contains this view, if any.
81+
*
82+
* <p>Used to navigate composite view hierarchies.</p>
5983
*
60-
* @return the parent view
84+
* @return the parent {@link View}, or {@code null} if this is a top-level view
6185
*/
6286
View getParentView();
6387

6488
/**
65-
* Sets the parent view.
89+
* Sets the parent view that contains this view.
6690
*
67-
* @param view the new parent view
91+
* @param view the parent {@link View}; may be {@code null} for top-level views
6892
*/
6993
void setParentView(View view);
7094

95+
/**
96+
* Sets an arbitrary source object associated with this view.
97+
*
98+
* <p>The source can represent the originating controller, component, or context object.
99+
* The default implementation is a no-op; subclasses may override to store the value.</p>
100+
*
101+
* @param source the source object; may be {@code null}
102+
*/
71103
default void setSource(Object source) {
72-
73104
}
74105

106+
/**
107+
* Returns the source object previously set via {@link #setSource(Object)}.
108+
*
109+
* <p>The default implementation always returns {@code null}; subclasses may override.</p>
110+
*
111+
* @return the source object, or {@code null} if not set
112+
*/
75113
default Object getSource() {
76114
return null;
77115
}

platform/core/viewers/src/main/java/tools/dynamia/viewers/ViewAction.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,21 @@
33
import tools.dynamia.actions.AbstractAction;
44

55
/**
6-
* Represents an action associated with a viewer
6+
* Base class for actions that are contextually bound to a {@link View}.
7+
*
8+
* <p>A {@code ViewAction} extends {@link AbstractAction} to provide all standard action
9+
* capabilities (id, label, icon, enabled/visible state, execution) in a viewer-aware context.
10+
* Subclasses are typically registered with a view or a {@link ViewDescriptor} via
11+
* {@link ViewDescriptor#getActions()} and rendered as toolbar buttons, menu items, or
12+
* inline controls by the {@link ViewRenderer}.</p>
13+
*
14+
* <p>Because view actions inherit from {@link AbstractAction}, they participate in the same
15+
* action lifecycle (enable/disable, show/hide, execute with an
16+
* {@link tools.dynamia.actions.ActionEvent}) as any other framework action, but can also
17+
* interact directly with the hosting view.</p>
18+
*
19+
* @see AbstractAction
20+
* @see ViewDescriptor#getActions()
721
*/
822
public abstract class ViewAction extends AbstractAction {
923
}

platform/core/viewers/src/main/java/tools/dynamia/viewers/ViewCustomizer.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,38 @@
2020
import java.io.Serializable;
2121

2222
/**
23-
* Interface for customizing a view after it is created.
23+
* Post-processing hook applied to a {@link View} immediately after it is constructed by a
24+
* {@link ViewRenderer}.
2425
*
25-
* @param <T> the type of view to customize
26+
* <p>A {@code ViewCustomizer} allows framework users to programmatically adjust a view's
27+
* appearance or behaviour without subclassing the renderer. Typical uses include:
28+
* <ul>
29+
* <li>Attaching event listeners to form components.</li>
30+
* <li>Applying dynamic styles or CSS classes.</li>
31+
* <li>Changing field visibility based on runtime conditions.</li>
32+
* <li>Injecting additional child components.</li>
33+
* </ul>
34+
* </p>
35+
*
36+
* <p>The concrete customizer class is declared in the {@link ViewDescriptor} via
37+
* {@link ViewDescriptor#getViewCustomizerClass()} and is instantiated by the framework
38+
* after the view is fully built. Implementations must be serializable and have a
39+
* public no-arg constructor.</p>
40+
*
41+
* @param <T> the concrete {@link View} subtype this customizer operates on
42+
* @see ViewDescriptor#getViewCustomizerClass()
43+
* @see ViewRenderer
2644
*/
2745
public interface ViewCustomizer<T extends View> extends Serializable {
2846

2947
/**
30-
* Customizes the given view.
48+
* Applies custom post-processing logic to the given view.
49+
*
50+
* <p>This method is called once per view construction, after the {@link ViewRenderer}
51+
* has finished building all components. Modifications made here are reflected in the
52+
* final UI presented to the user.</p>
3153
*
32-
* @param view the view to customize
54+
* @param view the fully constructed view to customize; never {@code null}
3355
*/
3456
void customize(T view);
3557
}

0 commit comments

Comments
 (0)