|
@@ -1,152 +1,152 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.forms.client.nonpublic; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.commonfoundation.typeutils.*; |
5 |
|
- |
import org.litesoft.core.simpletypes.*; |
6 |
|
- |
import org.litesoft.ui.def.nonpublic.support.*; |
7 |
|
- |
|
8 |
|
- |
import java.io.*; |
9 |
|
- |
|
10 |
|
- |
public abstract class AbstractFormInstanceComponentHandler implements FormInstanceComponentHandler { |
11 |
|
- |
// Action Management |
12 |
|
- |
protected ActionAdapterManager mActionAdapters = new ActionAdapterManager(); |
13 |
|
- |
|
14 |
|
- |
abstract public FormDataRowKey getFormDataRowKey(); |
15 |
|
- |
|
16 |
|
- |
abstract public FormDataRowKey getParentFormDataRowKey(); |
17 |
|
- |
|
18 |
|
- |
public void addActionAdapter( FormActionAdapter pActionAdapter ) { |
19 |
|
- |
mActionAdapters.add( pActionAdapter ); |
20 |
|
- |
} |
21 |
|
- |
|
22 |
|
- |
protected void LLdisposeActions( UberFormInstanceComponentHandler pUberHandler ) { |
23 |
|
- |
mActionAdapters.dispose(); |
24 |
|
- |
mActionAdapters = null; |
25 |
|
- |
} |
26 |
|
- |
|
27 |
|
- |
// General |
28 |
|
- |
protected void LLdispose( UberFormInstanceComponentHandler pUberHandler ) { |
29 |
|
- |
LLdisposeActions( pUberHandler ); |
30 |
|
- |
} |
31 |
|
- |
|
32 |
|
- |
public void componentUpdatedValue( FormAttributeAdapter pAttributeAdapter, Serializable pCurrentValue ) { |
33 |
|
- |
getUberHandler().componentUpdatedValue( getFormDataRowKey(), pAttributeAdapter, pCurrentValue ); |
34 |
|
- |
} |
35 |
|
- |
|
36 |
|
- |
public void requestResourceKeyNameURLs( FormAttributeAdapter pAttributeAdapter, |
37 |
|
- |
ResourceKeyNameURLsAvailableCallback pCallback ) { |
38 |
|
- |
getUberHandler().requestResourceKeyNameURLs( getFormDataRowKey(), pAttributeAdapter, pCallback ); |
39 |
|
- |
} |
40 |
|
- |
|
41 |
|
- |
public void actionRequested( FormActionAdapter pActionAdapter, boolean pInputAction ) { |
42 |
|
- |
getUberHandler().actionRequested( getFormDataRowKey(), pActionAdapter, pInputAction, |
43 |
|
- |
getParentFormDataRowKey() ); |
44 |
|
- |
} |
45 |
|
- |
|
46 |
|
- |
public void componentErrorState( boolean pErrorState ) { |
47 |
|
- |
getUberHandler().componentErrorState( pErrorState ); |
48 |
|
- |
} |
49 |
|
- |
|
50 |
|
- |
public void componentChangedState( boolean pChangedState ) { |
51 |
|
- |
getUberHandler().componentChangedState( pChangedState ); |
52 |
|
- |
} |
53 |
|
- |
|
54 |
|
- |
private boolean mActive = true; |
55 |
|
- |
|
56 |
|
- |
public boolean isActive() { |
57 |
|
- |
return mActive; |
58 |
|
- |
} |
59 |
|
- |
|
60 |
|
- |
public final void dispose( UberFormInstanceComponentHandler pUberHandler ) { |
61 |
|
- |
if ( mActive ) { |
62 |
|
- |
mActive = false; |
63 |
|
- |
LLdispose( pUberHandler ); |
64 |
|
- |
} |
65 |
|
- |
} |
66 |
|
- |
|
67 |
|
- |
abstract protected void LLapplyOnChildren( ActionUpdateFormData[] pActionUpdates ); |
68 |
|
- |
|
69 |
|
- |
public void apply( ActionUpdateFormData[] pActionUpdates ) { |
70 |
|
- |
if ( isActive() && Objects.isNotNullOrEmpty( pActionUpdates ) ) { |
71 |
|
- |
mActionAdapters.apply( getFormDataRowKey(), pActionUpdates ); |
72 |
|
- |
LLapplyOnChildren( pActionUpdates ); |
73 |
|
- |
} |
74 |
|
- |
} |
75 |
|
- |
|
76 |
|
- |
abstract protected void LLupdateInputStateOnChildren( boolean pAnyChanged, boolean pAnyErrors ); |
77 |
|
- |
|
78 |
|
- |
public void updateInputState( boolean pAnyChanged, boolean pAnyErrors ) { |
79 |
|
- |
if ( isActive() ) { |
80 |
|
- |
mActionAdapters.updateInputState( pAnyChanged, pAnyErrors ); |
81 |
|
- |
LLupdateInputStateOnChildren( pAnyChanged, pAnyErrors ); |
82 |
|
- |
} |
83 |
|
- |
} |
84 |
|
- |
|
85 |
|
- |
abstract protected boolean LLsetActionDisabledOnChildren( FormDataRowKey pFormDataRowKey, |
86 |
|
- |
String pActionID, boolean pDisabled ); |
87 |
|
- |
|
88 |
|
- |
public boolean setActionDisabled( FormDataRowKey pFormDataRowKey, String pActionID, boolean pDisabled ) { |
89 |
|
- |
return isActive() && Objects.areNonArraysEqual( pFormDataRowKey, getFormDataRowKey() ) ? // |
90 |
|
- |
mActionAdapters.setActionDisabled( pActionID, pDisabled ) : // |
91 |
|
- |
LLsetActionDisabledOnChildren( pFormDataRowKey, pActionID, pDisabled ); |
92 |
|
- |
} |
93 |
|
- |
|
94 |
|
- |
abstract protected boolean LLsetInputDisabledOnUs( String pAttributeName, boolean pDisabled ); |
95 |
|
- |
|
96 |
|
- |
abstract protected boolean LLsetInputDisabledOnChildren( FormDataRowKey pFormDataRowKey, |
97 |
|
- |
String pAttributeName, boolean pDisabled ); |
98 |
|
- |
|
99 |
|
- |
public boolean setInputDisabled( FormDataRowKey pFormDataRowKey, String pAttributeName, |
100 |
|
- |
boolean pDisabled ) { |
101 |
|
- |
return isActive() && Objects.areNonArraysEqual( pFormDataRowKey, getFormDataRowKey() ) ? // |
102 |
|
- |
LLsetInputDisabledOnUs( pAttributeName, pDisabled ) : // |
103 |
|
- |
LLsetInputDisabledOnChildren( pFormDataRowKey, pAttributeName, pDisabled ); |
104 |
|
- |
} |
105 |
|
- |
|
106 |
|
- |
abstract protected void LLapplyOnUs( AttributeUpdateFormData[] pAttributeUpdates ); |
107 |
|
- |
|
108 |
|
- |
abstract protected void LLapplyOnChildren( AttributeUpdateFormData[] pAttributeUpdates ); |
109 |
|
- |
|
110 |
|
- |
public void apply( AttributeUpdateFormData[] pAttributeUpdates ) { |
111 |
|
- |
if ( isActive() && Objects.isNotNullOrEmpty( pAttributeUpdates ) ) { |
112 |
|
- |
LLapplyOnUs( pAttributeUpdates ); |
113 |
|
- |
LLapplyOnChildren( pAttributeUpdates ); |
114 |
|
- |
} |
115 |
|
- |
} |
116 |
|
- |
|
117 |
|
- |
abstract protected boolean LLanyUserInitiatedRowChangeOnUs(); |
118 |
|
- |
|
119 |
|
- |
abstract protected boolean LLanyUserInitiatedRowChangeOnChildren(); |
120 |
|
- |
|
121 |
|
- |
public boolean anyUserInitiatedRowChange() { |
122 |
|
- |
return isActive() && // Below: First Left than Right! |
123 |
|
- |
(LLanyUserInitiatedRowChangeOnUs() || LLanyUserInitiatedRowChangeOnChildren()); |
124 |
|
- |
} |
125 |
|
- |
|
126 |
|
- |
abstract protected boolean LLrecalcAnyAttributesOnUs( |
127 |
|
- |
FormAttributeAdapter.BooleanValueAccessor pValueAccessor ); |
128 |
|
- |
|
129 |
|
- |
abstract protected boolean LLrecalcAnyAttributesOnChildren( |
130 |
|
- |
FormAttributeAdapter.BooleanValueAccessor pValueAccessor ); |
131 |
|
- |
|
132 |
|
- |
public boolean recalcAnyAttributes( FormAttributeAdapter.BooleanValueAccessor pValueAccessor ) { |
133 |
|
- |
return isActive() && // Below: First Left than Right! |
134 |
|
- |
(LLrecalcAnyAttributesOnUs( pValueAccessor ) || |
135 |
|
- |
LLrecalcAnyAttributesOnChildren( pValueAccessor )); |
136 |
|
- |
} |
137 |
|
- |
|
138 |
|
- |
abstract protected void LLpublishAnyPendingAttributeChangesOnUs(); |
139 |
|
- |
|
140 |
|
- |
abstract protected void LLpublishAnyPendingAttributeChangesOnChildren(); |
141 |
|
- |
|
142 |
|
- |
public void publishAnyPendingAttributeChanges() { |
143 |
|
- |
if ( isActive() ) { |
144 |
|
- |
LLpublishAnyPendingAttributeChangesOnUs(); |
145 |
|
- |
LLpublishAnyPendingAttributeChangesOnChildren(); |
146 |
|
- |
} |
147 |
|
- |
} |
148 |
|
- |
|
149 |
|
- |
abstract public UberFormInstanceComponentHandler getUberHandler(); |
150 |
|
- |
|
151 |
|
- |
abstract public Integer getFormUniqueID(); |
152 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.forms.client.nonpublic; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.commonfoundation.base.*; |
|
5 |
+ |
import org.litesoft.core.simpletypes.*; |
|
6 |
+ |
import org.litesoft.ui.def.nonpublic.support.*; |
|
7 |
+ |
|
|
8 |
+ |
import java.io.*; |
|
9 |
+ |
|
|
10 |
+ |
public abstract class AbstractFormInstanceComponentHandler implements FormInstanceComponentHandler { |
|
11 |
+ |
// Action Management |
|
12 |
+ |
protected ActionAdapterManager mActionAdapters = new ActionAdapterManager(); |
|
13 |
+ |
|
|
14 |
+ |
abstract public FormDataRowKey getFormDataRowKey(); |
|
15 |
+ |
|
|
16 |
+ |
abstract public FormDataRowKey getParentFormDataRowKey(); |
|
17 |
+ |
|
|
18 |
+ |
public void addActionAdapter( FormActionAdapter pActionAdapter ) { |
|
19 |
+ |
mActionAdapters.add( pActionAdapter ); |
|
20 |
+ |
} |
|
21 |
+ |
|
|
22 |
+ |
protected void LLdisposeActions( UberFormInstanceComponentHandler pUberHandler ) { |
|
23 |
+ |
mActionAdapters.dispose(); |
|
24 |
+ |
mActionAdapters = null; |
|
25 |
+ |
} |
|
26 |
+ |
|
|
27 |
+ |
// General |
|
28 |
+ |
protected void LLdispose( UberFormInstanceComponentHandler pUberHandler ) { |
|
29 |
+ |
LLdisposeActions( pUberHandler ); |
|
30 |
+ |
} |
|
31 |
+ |
|
|
32 |
+ |
public void componentUpdatedValue( FormAttributeAdapter pAttributeAdapter, Serializable pCurrentValue ) { |
|
33 |
+ |
getUberHandler().componentUpdatedValue( getFormDataRowKey(), pAttributeAdapter, pCurrentValue ); |
|
34 |
+ |
} |
|
35 |
+ |
|
|
36 |
+ |
public void requestResourceKeyNameURLs( FormAttributeAdapter pAttributeAdapter, |
|
37 |
+ |
ResourceKeyNameURLsAvailableCallback pCallback ) { |
|
38 |
+ |
getUberHandler().requestResourceKeyNameURLs( getFormDataRowKey(), pAttributeAdapter, pCallback ); |
|
39 |
+ |
} |
|
40 |
+ |
|
|
41 |
+ |
public void actionRequested( FormActionAdapter pActionAdapter, boolean pInputAction ) { |
|
42 |
+ |
getUberHandler().actionRequested( getFormDataRowKey(), pActionAdapter, pInputAction, |
|
43 |
+ |
getParentFormDataRowKey() ); |
|
44 |
+ |
} |
|
45 |
+ |
|
|
46 |
+ |
public void componentErrorState( boolean pErrorState ) { |
|
47 |
+ |
getUberHandler().componentErrorState( pErrorState ); |
|
48 |
+ |
} |
|
49 |
+ |
|
|
50 |
+ |
public void componentChangedState( boolean pChangedState ) { |
|
51 |
+ |
getUberHandler().componentChangedState( pChangedState ); |
|
52 |
+ |
} |
|
53 |
+ |
|
|
54 |
+ |
private boolean mActive = true; |
|
55 |
+ |
|
|
56 |
+ |
public boolean isActive() { |
|
57 |
+ |
return mActive; |
|
58 |
+ |
} |
|
59 |
+ |
|
|
60 |
+ |
public final void dispose( UberFormInstanceComponentHandler pUberHandler ) { |
|
61 |
+ |
if ( mActive ) { |
|
62 |
+ |
mActive = false; |
|
63 |
+ |
LLdispose( pUberHandler ); |
|
64 |
+ |
} |
|
65 |
+ |
} |
|
66 |
+ |
|
|
67 |
+ |
abstract protected void LLapplyOnChildren( ActionUpdateFormData[] pActionUpdates ); |
|
68 |
+ |
|
|
69 |
+ |
public void apply( ActionUpdateFormData[] pActionUpdates ) { |
|
70 |
+ |
if ( isActive() && Currently.isNotNullOrEmpty( pActionUpdates ) ) { |
|
71 |
+ |
mActionAdapters.apply( getFormDataRowKey(), pActionUpdates ); |
|
72 |
+ |
LLapplyOnChildren( pActionUpdates ); |
|
73 |
+ |
} |
|
74 |
+ |
} |
|
75 |
+ |
|
|
76 |
+ |
abstract protected void LLupdateInputStateOnChildren( boolean pAnyChanged, boolean pAnyErrors ); |
|
77 |
+ |
|
|
78 |
+ |
public void updateInputState( boolean pAnyChanged, boolean pAnyErrors ) { |
|
79 |
+ |
if ( isActive() ) { |
|
80 |
+ |
mActionAdapters.updateInputState( pAnyChanged, pAnyErrors ); |
|
81 |
+ |
LLupdateInputStateOnChildren( pAnyChanged, pAnyErrors ); |
|
82 |
+ |
} |
|
83 |
+ |
} |
|
84 |
+ |
|
|
85 |
+ |
abstract protected boolean LLsetActionDisabledOnChildren( FormDataRowKey pFormDataRowKey, |
|
86 |
+ |
String pActionID, boolean pDisabled ); |
|
87 |
+ |
|
|
88 |
+ |
public boolean setActionDisabled( FormDataRowKey pFormDataRowKey, String pActionID, boolean pDisabled ) { |
|
89 |
+ |
return isActive() && Currently.areEqual( pFormDataRowKey, getFormDataRowKey() ) ? // |
|
90 |
+ |
mActionAdapters.setActionDisabled( pActionID, pDisabled ) : // |
|
91 |
+ |
LLsetActionDisabledOnChildren( pFormDataRowKey, pActionID, pDisabled ); |
|
92 |
+ |
} |
|
93 |
+ |
|
|
94 |
+ |
abstract protected boolean LLsetInputDisabledOnUs( String pAttributeName, boolean pDisabled ); |
|
95 |
+ |
|
|
96 |
+ |
abstract protected boolean LLsetInputDisabledOnChildren( FormDataRowKey pFormDataRowKey, |
|
97 |
+ |
String pAttributeName, boolean pDisabled ); |
|
98 |
+ |
|
|
99 |
+ |
public boolean setInputDisabled( FormDataRowKey pFormDataRowKey, String pAttributeName, |
|
100 |
+ |
boolean pDisabled ) { |
|
101 |
+ |
return isActive() && Currently.areEqual( pFormDataRowKey, getFormDataRowKey() ) ? // |
|
102 |
+ |
LLsetInputDisabledOnUs( pAttributeName, pDisabled ) : // |
|
103 |
+ |
LLsetInputDisabledOnChildren( pFormDataRowKey, pAttributeName, pDisabled ); |
|
104 |
+ |
} |
|
105 |
+ |
|
|
106 |
+ |
abstract protected void LLapplyOnUs( AttributeUpdateFormData[] pAttributeUpdates ); |
|
107 |
+ |
|
|
108 |
+ |
abstract protected void LLapplyOnChildren( AttributeUpdateFormData[] pAttributeUpdates ); |
|
109 |
+ |
|
|
110 |
+ |
public void apply( AttributeUpdateFormData[] pAttributeUpdates ) { |
|
111 |
+ |
if ( isActive() && Currently.isNotNullOrEmpty( pAttributeUpdates ) ) { |
|
112 |
+ |
LLapplyOnUs( pAttributeUpdates ); |
|
113 |
+ |
LLapplyOnChildren( pAttributeUpdates ); |
|
114 |
+ |
} |
|
115 |
+ |
} |
|
116 |
+ |
|
|
117 |
+ |
abstract protected boolean LLanyUserInitiatedRowChangeOnUs(); |
|
118 |
+ |
|
|
119 |
+ |
abstract protected boolean LLanyUserInitiatedRowChangeOnChildren(); |
|
120 |
+ |
|
|
121 |
+ |
public boolean anyUserInitiatedRowChange() { |
|
122 |
+ |
return isActive() && // Below: First Left than Right! |
|
123 |
+ |
(LLanyUserInitiatedRowChangeOnUs() || LLanyUserInitiatedRowChangeOnChildren()); |
|
124 |
+ |
} |
|
125 |
+ |
|
|
126 |
+ |
abstract protected boolean LLrecalcAnyAttributesOnUs( |
|
127 |
+ |
FormAttributeAdapter.BooleanValueAccessor pValueAccessor ); |
|
128 |
+ |
|
|
129 |
+ |
abstract protected boolean LLrecalcAnyAttributesOnChildren( |
|
130 |
+ |
FormAttributeAdapter.BooleanValueAccessor pValueAccessor ); |
|
131 |
+ |
|
|
132 |
+ |
public boolean recalcAnyAttributes( FormAttributeAdapter.BooleanValueAccessor pValueAccessor ) { |
|
133 |
+ |
return isActive() && // Below: First Left than Right! |
|
134 |
+ |
(LLrecalcAnyAttributesOnUs( pValueAccessor ) || |
|
135 |
+ |
LLrecalcAnyAttributesOnChildren( pValueAccessor )); |
|
136 |
+ |
} |
|
137 |
+ |
|
|
138 |
+ |
abstract protected void LLpublishAnyPendingAttributeChangesOnUs(); |
|
139 |
+ |
|
|
140 |
+ |
abstract protected void LLpublishAnyPendingAttributeChangesOnChildren(); |
|
141 |
+ |
|
|
142 |
+ |
public void publishAnyPendingAttributeChanges() { |
|
143 |
+ |
if ( isActive() ) { |
|
144 |
+ |
LLpublishAnyPendingAttributeChangesOnUs(); |
|
145 |
+ |
LLpublishAnyPendingAttributeChangesOnChildren(); |
|
146 |
+ |
} |
|
147 |
+ |
} |
|
148 |
+ |
|
|
149 |
+ |
abstract public UberFormInstanceComponentHandler getUberHandler(); |
|
150 |
+ |
|
|
151 |
+ |
abstract public Integer getFormUniqueID(); |
|
152 |
+ |
} |