| 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.implementation.SplitPanelImplementation; |
| 22 | import org.deduced.viewer.web.shared.Model; |
| 23 | import org.deduced.viewer.web.shared.SplitPanelModel; |
| 24 | import org.deduced.viewer.web.shared.WidgetModel; |
| 25 | |
| 26 | /** |
| 27 | * SplitPanelModel Serializer |
| 28 | * |
| 29 | * @author Steve McDuff |
| 30 | * |
| 31 | */ |
| 32 | public class SplitPanelModelSerializer extends PanelModelSerializer |
| 33 | { |
| 34 | |
| 35 | /** |
| 36 | * fill SplitPanelModel |
| 37 | * |
| 38 | * @param model collection to serialize |
| 39 | * @param splitPanelModel model to fill |
| 40 | * @param masterSerializer master serializer used to serialize child |
| 41 | * objects. |
| 42 | */ |
| 43 | public static void fillSplitPanelModel( |
| 44 | PropertyCollection<?, ?> model, SplitPanelModel splitPanelModel, |
| 45 | MasterWebSerializer masterSerializer) |
| 46 | { |
| 47 | splitPanelModel |
| 48 | .setBottomRightComponent((WidgetModel) masterSerializer |
| 49 | .serialize(SplitPanelImplementation |
| 50 | .getBottomRightComponent(model))); |
| 51 | |
| 52 | splitPanelModel.setTopLeftComponent((WidgetModel) masterSerializer |
| 53 | .serialize(SplitPanelImplementation.getTopLeftComponent(model))); |
| 54 | |
| 55 | splitPanelModel.setDividerLocation(SplitPanelImplementation |
| 56 | .getDividerLocation(model).intValue()); |
| 57 | |
| 58 | splitPanelModel.setResizeWeight(SplitPanelImplementation |
| 59 | .getResizeWeight(model).doubleValue()); |
| 60 | |
| 61 | splitPanelModel.setVertical(SplitPanelImplementation.isVertical(model) |
| 62 | .booleanValue()); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * (non-JSDoc) |
| 67 | * |
| 68 | * @see org.deduced.viewer.web.serializer.WidgetModelSerializer#createSerializedObject(org.deduced.PropertyCollection) |
| 69 | */ |
| 70 | @Override |
| 71 | public Model createSerializedObject( |
| 72 | PropertyCollection<?, ?> collection) |
| 73 | { |
| 74 | return new SplitPanelModel(); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * (non-JSDoc) |
| 79 | * |
| 80 | * @see org.deduced.viewer.web.serializer.UserInterfaceModelSerializer#fillSerializedObject(java.io.Serializable, |
| 81 | * org.deduced.PropertyCollection, |
| 82 | * org.deduced.viewer.web.serializer.MasterWebSerializer) |
| 83 | */ |
| 84 | @Override |
| 85 | public void fillSerializedObject( |
| 86 | Serializable serializedObject, PropertyCollection<?, ?> collection, |
| 87 | MasterWebSerializer masterSerializer) |
| 88 | { |
| 89 | fillSplitPanelModel(collection, (SplitPanelModel) serializedObject, |
| 90 | masterSerializer); |
| 91 | |
| 92 | super.fillSerializedObject(serializedObject, collection, |
| 93 | masterSerializer); |
| 94 | } |
| 95 | } |