equal
deleted
inserted
replaced
168 private Vector commands = new Vector(); |
168 private Vector commands = new Vector(); |
169 private ItemCommandListener itemCommandListener; |
169 private ItemCommandListener itemCommandListener; |
170 private ItemControlStateChangeListener controlListener; |
170 private ItemControlStateChangeListener controlListener; |
171 |
171 |
172 private Command defaultCommand; |
172 private Command defaultCommand; |
173 private WeakReference wParent; |
173 private Screen iParent = null; |
174 |
174 |
175 private int layout; |
175 private int layout; |
176 private int lockedPrefWidth = -1; |
176 private int lockedPrefWidth = -1; |
177 private int lockedPrefHeight = -1; |
177 private int lockedPrefHeight = -1; |
178 |
178 |
186 * Sets the parent of this Item. |
186 * Sets the parent of this Item. |
187 * @param parent new Parent. If null, current parent is to be removed. |
187 * @param parent new Parent. If null, current parent is to be removed. |
188 */ |
188 */ |
189 void setParent(Screen parent) |
189 void setParent(Screen parent) |
190 { |
190 { |
191 if(parent != null) |
191 if(parent != null) |
192 { |
192 { |
193 wParent = new WeakReference(parent); |
193 iParent = parent; |
194 } |
194 } |
195 else |
195 else |
196 { |
196 { |
197 clearParent(); |
197 clearParent(); |
198 } |
198 } |
199 } |
199 } |
200 |
200 |
201 /** |
201 /** |
202 * Gets the Item's parent. |
202 * Gets the Item's parent. |
203 * |
203 * |
204 * @return the Item's parent or null if it has none. |
204 * @return the Item's parent or null if it has none. |
205 */ |
205 */ |
206 Screen getParent() |
206 Screen getParent() |
207 { |
207 { |
208 if(wParent != null) |
208 if(iParent != null) |
209 { |
209 { |
210 return (Screen)wParent.get(); |
210 return iParent; |
211 } |
211 } |
212 else |
212 else |
213 { |
213 { |
214 return null; |
214 return null; |
215 } |
215 } |
216 } |
216 } |
217 |
217 |
218 /** |
218 /** |
219 * Clears the Item's parent. |
219 * Clears the Item's parent. |
220 * |
220 * |
221 */ |
221 */ |
222 void clearParent() |
222 void clearParent() |
223 { |
223 { |
224 if(wParent != null) |
224 if(iParent != null) |
225 { |
225 { |
226 wParent.clear(); |
226 iParent = null; |
227 wParent = null; |
227 } |
228 } |
|
229 } |
228 } |
230 |
229 |
231 /** |
230 /** |
232 * Sets the label of the item. |
231 * Sets the label of the item. |
233 * |
232 * |
239 if(isContainedInAlert()) |
238 if(isContainedInAlert()) |
240 { |
239 { |
241 throw new IllegalStateException( |
240 throw new IllegalStateException( |
242 MsgRepository.ITEM_EXCEPTION_OWNED_BY_ALERT); |
241 MsgRepository.ITEM_EXCEPTION_OWNED_BY_ALERT); |
243 } |
242 } |
244 if((newLabel == null) && (label == null)) |
243 if((newLabel == null) && (label == null)) |
245 { |
244 { |
246 return; |
245 return; |
247 } |
246 } |
248 label = newLabel; |
247 label = newLabel; |
249 updateParent(UPDATE_LABEL | UPDATE_SIZE_CHANGED); |
248 updateParent(UPDATE_LABEL | UPDATE_SIZE_CHANGED); |
250 } |
249 } |
251 |
250 |
252 /** |
251 /** |
568 { |
567 { |
569 throw new IllegalStateException( |
568 throw new IllegalStateException( |
570 MsgRepository.ITEM_EXCEPTION_NOT_OWNED_BY_FORM); |
569 MsgRepository.ITEM_EXCEPTION_NOT_OWNED_BY_FORM); |
571 } |
570 } |
572 // Notify item state listener |
571 // Notify item state listener |
573 ((Form) getParent()).notifyItemStateChanged(this); |
572 ((Form) iParent).notifyItemStateChanged(this); |
574 } |
573 } |
575 |
574 |
576 /** |
575 /** |
577 * Is this item's size locked. |
576 * Is this item's size locked. |
578 */ |
577 */ |
628 /** |
627 /** |
629 * If the item is owned by an Alert. |
628 * If the item is owned by an Alert. |
630 */ |
629 */ |
631 boolean isContainedInAlert() |
630 boolean isContainedInAlert() |
632 { |
631 { |
633 return ((wParent != null) && (getParent() instanceof Alert)); |
632 return ((iParent != null) && (iParent instanceof Alert)); |
634 } |
633 } |
635 |
634 |
636 /** |
635 /** |
637 * If the item is owned by an Form. |
636 * If the item is owned by an Form. |
638 */ |
637 */ |
639 boolean isContainedInForm() |
638 boolean isContainedInForm() |
640 { |
639 { |
641 return ((wParent != null) && (getParent() instanceof Form)); |
640 return ((iParent != null) && (iParent instanceof Form)); |
642 } |
641 } |
643 |
642 |
644 /** |
643 /** |
645 * Return internal layout with optional custom flags. |
644 * Return internal layout with optional custom flags. |
646 * |
645 * |
670 { |
669 { |
671 invalidateCachedSizes(); |
670 invalidateCachedSizes(); |
672 } |
671 } |
673 if(isContainedInForm()) |
672 if(isContainedInForm()) |
674 { |
673 { |
675 ((Form) getParent()).updateItemState(this, updateReason, param); |
674 ((Form) iParent).updateItemState(this, updateReason, param); |
676 } |
675 } |
677 } |
676 } |
678 |
677 |
679 boolean hasLayout(int aLayout) |
678 boolean hasLayout(int aLayout) |
680 { |
679 { |