1 | /** |
2 | * Copyright 2005-2011 Steve McDuff d-duff@users.sourceforge.net |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | package org.deduced.viewer.web.serializer; |
17 | |
18 | import java.io.Serializable; |
19 | |
20 | import org.deduced.PropertyCollection; |
21 | import org.deduced.viewer.model.combobox.implementation.ComboBoxItemImplementation; |
22 | import org.deduced.viewer.web.shared.ComboBoxItemModel; |
23 | import org.deduced.viewer.web.shared.Model; |
24 | import org.deduced.viewer.web.shared.WidgetModel; |
25 | |
26 | /** |
27 | * ComboBoxItemModel Serializer |
28 | * |
29 | * @author Steve McDuff |
30 | * |
31 | */ |
32 | public class ComboBoxItemModelSerializer extends ModelSerializer |
33 | { |
34 | |
35 | /** |
36 | * fill ComboBoxItemModel |
37 | * |
38 | * @param model collection to serialize |
39 | * @param comboBoxItemModel model to fill |
40 | * @param masterSerializer master serializer to serialize child objects. |
41 | */ |
42 | @SuppressWarnings("unchecked") |
43 | public static void fillComboBoxItemModel( |
44 | PropertyCollection<?, ?> model, ComboBoxItemModel comboBoxItemModel, |
45 | MasterWebSerializer masterSerializer) |
46 | { |
47 | comboBoxItemModel.setText(ComboBoxItemImplementation.getText(model)); |
48 | PropertyCollection component = |
49 | ComboBoxItemImplementation.getComponent(model); |
50 | comboBoxItemModel.setComponent((WidgetModel) masterSerializer |
51 | .serialize(component)); |
52 | } |
53 | |
54 | /** |
55 | * (non-JSDoc) |
56 | * |
57 | * @see org.deduced.viewer.web.serializer.WebSerializer#createSerializedObject(org.deduced.PropertyCollection) |
58 | */ |
59 | @Override |
60 | public Model createSerializedObject( |
61 | PropertyCollection<?, ?> collection) |
62 | { |
63 | return new ComboBoxItemModel(); |
64 | } |
65 | |
66 | /** |
67 | * (non-JSDoc) |
68 | * |
69 | * @see org.deduced.viewer.web.serializer.UserInterfaceModelSerializer#fillSerializedObject(java.io.Serializable, |
70 | * org.deduced.PropertyCollection, |
71 | * org.deduced.viewer.web.serializer.MasterWebSerializer) |
72 | */ |
73 | @Override |
74 | public void fillSerializedObject( |
75 | Serializable serializedObject, PropertyCollection<?, ?> collection, |
76 | MasterWebSerializer masterSerializer) |
77 | { |
78 | fillComboBoxItemModel(collection, (ComboBoxItemModel) serializedObject, |
79 | masterSerializer); |
80 | |
81 | super.fillSerializedObject(serializedObject, collection, |
82 | masterSerializer); |
83 | } |
84 | } |