| 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.shared; |
| 17 | |
| 18 | import com.google.gwt.user.client.ui.Label; |
| 19 | import com.google.gwt.user.client.ui.UIObject; |
| 20 | |
| 21 | /** |
| 22 | * LabelModel |
| 23 | * |
| 24 | * @author Steve McDuff |
| 25 | */ |
| 26 | public class LabelModel extends WidgetModel |
| 27 | { |
| 28 | |
| 29 | /** |
| 30 | * serialVersionUID |
| 31 | */ |
| 32 | private static final long serialVersionUID = 4828975305265673569L; |
| 33 | |
| 34 | /** |
| 35 | * label text |
| 36 | */ |
| 37 | private String text; |
| 38 | |
| 39 | /** |
| 40 | * |
| 41 | * LabelModel constructor |
| 42 | */ |
| 43 | public LabelModel() |
| 44 | { |
| 45 | |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * (non-JSDoc) |
| 50 | * |
| 51 | * @see org.deduced.viewer.web.shared.WidgetModel#createUIObject() |
| 52 | */ |
| 53 | @Override |
| 54 | public UIObject createUIObject() |
| 55 | { |
| 56 | return new Label(); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * get Label |
| 61 | * |
| 62 | * @return the label |
| 63 | */ |
| 64 | public Label getLabel() |
| 65 | { |
| 66 | return (Label) getUIObject(); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * (non-JSDoc) |
| 71 | * |
| 72 | * @see org.deduced.viewer.web.shared.UserInterfaceModel#internalSynchronizeWithUI() |
| 73 | */ |
| 74 | @Override |
| 75 | public void internalSynchronizeWithUI() |
| 76 | { |
| 77 | super.internalSynchronizeWithUI(); |
| 78 | Label label = getLabel(); |
| 79 | |
| 80 | label.setText(getText()); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * (non-JSDoc) |
| 85 | * |
| 86 | * @see org.deduced.viewer.web.shared.UserInterfaceModel#propertyChanged(org.deduced.viewer.web.shared.ChangeEvent) |
| 87 | */ |
| 88 | @Override |
| 89 | public void propertyChanged( |
| 90 | ChangeEvent event) |
| 91 | { |
| 92 | if (Utilities.equals(event.getName(), "text")) |
| 93 | { |
| 94 | setText((String) event.getSerializableValue()); |
| 95 | synchronizeWithUI(); |
| 96 | } |
| 97 | else |
| 98 | { |
| 99 | super.propertyChanged(event); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * @param setText the text to set |
| 105 | */ |
| 106 | public void setText( |
| 107 | String setText) |
| 108 | { |
| 109 | text = setText; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * @return the text |
| 114 | */ |
| 115 | public String getText() |
| 116 | { |
| 117 | return text; |
| 118 | } |
| 119 | } |