| 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.PopupPanel; |
| 22 | import org.deduced.viewer.model.implementation.PopupPanelImplementation; |
| 23 | import org.deduced.viewer.web.shared.Model; |
| 24 | import org.deduced.viewer.web.shared.PopupPanelModel; |
| 25 | import org.deduced.viewer.web.shared.WidgetModel; |
| 26 | |
| 27 | /** |
| 28 | * PanelModel Serializer |
| 29 | * |
| 30 | * @author Steve McDuff |
| 31 | * |
| 32 | */ |
| 33 | public class PopupPanelModelSerializer extends SimplePanelModelSerializer |
| 34 | { |
| 35 | /** |
| 36 | * fill PopupPanelModel |
| 37 | * |
| 38 | * @param model model to serialize |
| 39 | * @param popupPanelModel model to fill |
| 40 | * @param masterSerializer master serializer used to serialize child |
| 41 | * objects. |
| 42 | */ |
| 43 | @SuppressWarnings({"unchecked", "boxing"}) |
| 44 | private static void fillPopupPanelModel( |
| 45 | PropertyCollection<?, ?> model, PopupPanelModel popupPanelModel, |
| 46 | MasterWebSerializer masterSerializer) |
| 47 | { |
| 48 | PropertyCollection<?, ?> content = |
| 49 | (PropertyCollection<?, ?>) model |
| 50 | .getPropertyValue(PopupPanel.COMPONENT_INSTANCE.getKey()); |
| 51 | |
| 52 | popupPanelModel.setComponent((WidgetModel) masterSerializer |
| 53 | .serialize(content)); |
| 54 | |
| 55 | popupPanelModel.setIsModal(PopupPanelImplementation.isModal(model)); |
| 56 | popupPanelModel.setIsAutoHideEnabled(PopupPanelImplementation |
| 57 | .isAutoHideEnabled(model)); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * (non-JSDoc) |
| 62 | * |
| 63 | * @see org.deduced.viewer.web.serializer.PanelModelSerializer#createSerializedObject(org.deduced.PropertyCollection) |
| 64 | */ |
| 65 | @Override |
| 66 | public Model createSerializedObject( |
| 67 | PropertyCollection<?, ?> collection) |
| 68 | { |
| 69 | return new PopupPanelModel(); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * (non-JSDoc) |
| 74 | * |
| 75 | * @see org.deduced.viewer.web.serializer.CellPanelModelSerializer#fillSerializedObject(java.io.Serializable, |
| 76 | * org.deduced.PropertyCollection, |
| 77 | * org.deduced.viewer.web.serializer.MasterWebSerializer) |
| 78 | */ |
| 79 | @Override |
| 80 | public void fillSerializedObject( |
| 81 | Serializable serializedObject, PropertyCollection<?, ?> collection, |
| 82 | MasterWebSerializer masterSerializer) |
| 83 | { |
| 84 | fillPopupPanelModel(collection, (PopupPanelModel) serializedObject, |
| 85 | masterSerializer); |
| 86 | |
| 87 | super.fillSerializedObject(serializedObject, collection, |
| 88 | masterSerializer); |
| 89 | } |
| 90 | } |