Source code: com/flexstor/common/data/ejb/display/layout/DisplayLayoutDataBuild.java
1 /*
2 * DisplayLayoutDataBuild.java
3 *
4 * Copyright $Date: 2003/08/11 02:22:50 $ FLEXSTOR.net Inc.
5 *
6 * This work is licensed for use and distribution under license terms found at
7 * http://www.flexstor.org/license.html
8 *
9 */
10
11 package com.flexstor.common.data.ejb.display.layout;
12
13 import java.util.Vector;
14
15 import com.flexstor.common.data.ejb.display.field.DisplayFieldData;
16 import com.flexstor.common.keys.ejb.DisplayLayoutKey;
17
18
19 /**
20 * This will be the Client "Read" object for
21 * retrieving Data from the object. This will be
22 * passed to the client when they do a
23 * Home.create().getDataObject(key)
24 *
25 * @author Daniel J. Nickel 2/10/99
26 * @version 1.0
27 * @since FlexDB 3.0
28 * @see com.flexstor.ejb.Data
29 */
30
31 public class DisplayLayoutDataBuild
32 extends DisplayLayoutData
33 {
34
35 /* MKS Identifier */
36 public final static String IDENTIFIER="$Id: DisplayLayoutDataBuild.java,v 1.3 2003/08/11 02:22:50 aleric Exp $";
37 static final long serialVersionUID = -6822511507755251022L;
38
39 /**
40 * Set unique Id for Row in Database
41 *
42 * @return boolean
43 * @since FlexDB 3.0
44 */
45 public boolean setId(int iId)
46 {
47 id = iId;
48 return true;
49 }
50
51
52 /**
53 * This will set the Layout Name for this
54 * object.
55 *
56 * @return java.lang.String
57 * @since FlexDB 3.0
58 * @see java.lang.String
59 */
60
61 public boolean setName(String sLabel)
62 {
63 label = sLabel;
64 return true;
65 }
66
67 /**
68 * This will set a collection of Display Fields
69 *
70 * @return boolean
71 * @since FlexDB 3.0
72 * @see java.util.Vector
73 */
74
75 public boolean setDisplayFieldDataObjects(Vector vFields)
76 {
77 fields = vFields;
78 return true;
79 }
80
81
82 /**
83 * This is a helper function that will
84 * take the display fields and order them
85 * by position. It uses a bubble sort algorithm
86 * which is slow for large Vectors, but should be
87 * acceptable because of the small number of
88 * displayable fields for a layout.
89 *
90 * @return boolean
91 * @since FlexDB 3.0
92 * @see com.flexstor.ejb.dataobject.DisplayFieldData
93 */
94 public boolean orderDisplayFields()
95 {
96 int iVectorLen = 0;
97
98 if ( fields == null )
99 return true;
100
101 iVectorLen = fields.size();
102
103 for ( int iPos1 = 0; iPos1 < iVectorLen ; iPos1++ )
104 {
105
106 for ( int iPos2 = iPos1 + 1 ; iPos2 < iVectorLen ; iPos2++ )
107 {
108 DisplayFieldData dis1 = (DisplayFieldData) fields.elementAt(iPos1);
109 DisplayFieldData dis2 = (DisplayFieldData) fields.elementAt(iPos2);
110
111 if ( dis1.getPosition() > dis2.getPosition() )
112 {
113 fields.setElementAt( dis2 , iPos1 );
114 fields.setElementAt( dis1 , iPos2 );
115 }
116
117 }
118 }
119
120 return true;
121 }
122
123 /**
124 * This will set the key for this object
125 *
126 * @return boolean
127 * @since FlexDB 3.0
128 * @see com.flexstor.ejb.key.DisplayLayoutKey
129 */
130
131 public boolean setKey(DisplayLayoutKey key)
132 {
133 this.key = key;
134 return true;
135 }
136
137 /**
138 * Set Position for this layout
139 *
140 * @param int - Position of Layout
141 * @since FlexDB 3.0
142 */
143 public void setPosition( int pos )
144 {
145 position = pos;
146 }
147
148 /**
149 * This will set a list of properties
150 *
151 * @param java.util.Vector - List of PropertyData Objects
152 * @since FlexDB 3.0
153 * @see java.util.Vector
154 * @see com.flexstor.ejb.dataobject.PropertyData
155 */
156 public void setPropertyDataObjects( Vector props )
157 {
158 properties = props;
159 }
160
161
162 }