litesoft
@ 804
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt package org.litesoft.ui.def.nonpublic.support; import java.util.*; import org.litesoft.core.typeutils.*; import org.litesoft.core.util.*; import org.litesoft.ui.def.nonpublic.*; import org.litesoft.ui.support.*; public class FormMetaData implements UiMetaData { public static final long serialVersionUID = -7237653476576348111L; // Basic Base Form private String mRootType = null; // Basic Sub Form private String mRelAttributeRef = null; // Shared private Integer mUniqueID; private IntendedUse mIntendedUse; /** * @deprecated GWT ONLY */ public FormMetaData() { } public FormMetaData( FormUsage pUsage ) { mRootType = pUsage.getRootType(); mRelAttributeRef = pUsage.getRelAttributeRef(); mUniqueID = pUsage.getUniqueID(); mIntendedUse = pUsage.getIntendedUse(); } public Integer getUniqueID() { return mUniqueID; } public IntendedUse getIntendedUse() { return mIntendedUse; } public boolean isBaseForm() { return (getRootType() != null); } public String getRelAttributeRef() { return mRelAttributeRef; } public String getRootType() { return mRootType; } private Map<String, LabelMetaData> mLabels = new HashMap<String, LabelMetaData>(); public void addLabel( LabelMetaData pMetaData ) { if ( pMetaData != null ) { mLabels.put( pMetaData.getLabelID(), pMetaData ); } } public LabelMetaData getLabel( UiLabelSource pSource ) { return (pSource != null) ? (LabelMetaData) mLabels.get( pSource.getLabelID() ) : null; } private Map<String, ActionMetaData> mActions = new HashMap<String, ActionMetaData>(); public void addAction( ActionMetaData pMetaData ) { if ( pMetaData != null ) { mActions.put( pMetaData.getActionID(), pMetaData ); } } public ActionMetaData getAction( UiActionable pActionable ) { return (pActionable != null) ? getAction( pActionable.getActionID() ) : null; } public ActionMetaData getAction( String pActionID ) { return (pActionID != null) ? (ActionMetaData) mActions.get( pActionID ) : null; } private Map<Integer, AttributeMetaData> mAttributes = new HashMap<Integer, AttributeMetaData>(); public void addAttribute( AttributeMetaData pMetaData ) { if ( pMetaData != null ) { mAttributes.put( pMetaData.getUniqueID(), pMetaData ); } } public AttributeMetaData getAttribute( UiAttributeBacked pAttributeBacked ) { return (pAttributeBacked != null) ? // getAttribute( pAttributeBacked.getAttributeUniqueID() ) : // null; } public AttributeMetaData getAttribute( Integer pAttributeUniqueID ) { return (pAttributeUniqueID != null) ? // (AttributeMetaData) mAttributes.get( pAttributeUniqueID ) : // null; } private Map<Integer, FormMetaData> mRelSubForms = new HashMap<Integer, FormMetaData>(); public void addRelSubForm( FormMetaData pMetaData ) { if ( pMetaData != null ) { mRelSubForms.put( pMetaData.getUniqueID(), pMetaData ); } } public FormMetaData getRelSubForm( UiRelSubFormDef pRelSubFormDef ) { return (pRelSubFormDef != null) ? // (FormMetaData) mRelSubForms.get( pRelSubFormDef.getFormUniqueID() ) : // null; } public boolean equals( Object o ) { return (this == o) || ((o instanceof FormMetaData) && equals( (FormMetaData) o )); } public boolean equals( FormMetaData them ) { return (this == them) || // ((them != null) // && Objects.areNonArraysEqual( this.mUniqueID, them.mUniqueID ) // && Objects.areNonArraysEqual( this.mRootType, them.mRootType ) // && Objects.areNonArraysEqual( this.mRelAttributeRef, them.mRelAttributeRef ) // ); } public int hashCode() { return mUniqueID.hashCode(); } public int compareTo( FormMetaData pThem ) { Compare zCompare = isBaseForm() ? // Compare.first( this.getRootType(), pThem.getRootType() ) : // Compare.first( this.getRelAttributeRef(), pThem.getRelAttributeRef() ); zCompare = zCompare.then( this.getUniqueID(), pThem.getUniqueID() ); return zCompare.result(); } public int compareTo( Object pObject ) { return compareTo( (FormMetaData) pObject ); } public String toString() { return toStringBuilder( new StringBuilder().append( "FormMetaData-" ), 0 ).toString(); } public StringBuilder toStringBuilder( StringBuilder pSB, int pDepth ) { if ( isBaseForm() ) { pSB.append( '@' ).append( mRootType ); } else { pSB.append( mRootType ).append( "->" ); } pSB.append( '(' ).append( mUniqueID ).append( ')' ); if ( anyChildren() ) { pSB.append( ":" ); int subDepth = pDepth + 1; if ( !mLabels.isEmpty() ) { add( pSB, subDepth, "Labels", mLabels.values() ); } if ( !mActions.isEmpty() ) { add( pSB, subDepth, "Actions", mActions.values() ); } if ( !mAttributes.isEmpty() ) { add( pSB, subDepth, "Attributes", mAttributes.values() ); } if ( !mRelSubForms.isEmpty() ) { add( pSB, subDepth, "RelSubForms", mRelSubForms.values() ); } } return pSB; } private boolean anyChildren() { return !mLabels.isEmpty() || !mActions.isEmpty() || !mAttributes.isEmpty() || !mRelSubForms.isEmpty(); } protected static void add( StringBuilder pSB, int pDepth, String pWhat, Collection pBuilders ) { ArrayList list = new ArrayList( pBuilders ); Collections.sort( list ); LineIndentUtil.newLine( pSB, pDepth++ ).append( pWhat ).append( ':' ); for ( int i = 0; i < list.size(); i++ ) { ToStringBuilder md = (ToStringBuilder) list.get( i ); md.toStringBuilder( LineIndentUtil.newLine( pSB, pDepth ), pDepth ); } } } |