EMMA Coverage Report (generated Sat Apr 14 15:01:05 EDT 2012)
[all classes][org.deduced.viewer.web.shared]

COVERAGE SUMMARY FOR SOURCE FILE [ComboBoxItemModel.java]

nameclass, %method, %block, %line, %
ComboBoxItemModel.java100% (1/1)100% (12/12)100% (92/92)100% (37/37)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ComboBoxItemModel100% (1/1)100% (12/12)100% (92/92)100% (37/37)
ComboBoxItemModel (): void 100% (1/1)100% (3/3)100% (2/2)
deleteChildModels (): void 100% (1/1)100% (5/5)100% (3/3)
deleteComponent (): void 100% (1/1)100% (10/10)100% (4/4)
getComponent (): WidgetModel 100% (1/1)100% (3/3)100% (1/1)
getText (): String 100% (1/1)100% (3/3)100% (1/1)
modelChanged (Model): void 100% (1/1)100% (3/3)100% (2/2)
propertyChanged (ChangeEvent): void 100% (1/1)100% (31/31)100% (11/11)
registerChildModels (): void 100% (1/1)100% (8/8)100% (3/3)
setComponent (WidgetModel): void 100% (1/1)100% (4/4)100% (2/2)
setText (String): void 100% (1/1)100% (4/4)100% (2/2)
updateComponent (WidgetModel): void 100% (1/1)100% (12/12)100% (3/3)
updateText (String): void 100% (1/1)100% (6/6)100% (3/3)

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 */
16package org.deduced.viewer.web.shared;
17 
18/**
19 * Combo Box Item Model
20 * 
21 * @author Steve McDuff
22 * 
23 */
24public class ComboBoxItemModel extends Model implements ModelContainer
25{
26 
27        /**
28         * serialVersionUID
29         */
30        private static final long serialVersionUID = 1410622635166688696L;
31 
32        /**
33         * tree node text. If the component field is null, this text will be
34         * displayed in the tree item.
35         */
36        private String text;
37 
38        /**
39         * widget to display in the tree node
40         */
41        private WidgetModel component;
42 
43        /**
44         * ComboBoxItemModel constructor
45         */
46        public ComboBoxItemModel()
47        {
48 
49        }
50 
51        /**
52         * (non-JSDoc)
53         * 
54         * @see org.deduced.viewer.web.shared.Model#registerChildModels()
55         */
56        @Override
57        protected void registerChildModels()
58        {
59                registerChildModel(getComponent(), this);
60                super.registerChildModels();
61        }
62 
63        /**
64         * (non-JSDoc)
65         * 
66         * @see org.deduced.viewer.web.shared.Model#deleteChildModels()
67         */
68        @Override
69        protected void deleteChildModels()
70        {
71                deleteComponent();
72                super.deleteChildModels();
73        }
74 
75        /**
76         * set the Component
77         * 
78         * @param widget the component in the tree item
79         */
80        public void setComponent(
81                WidgetModel widget)
82        {
83                component = widget;
84        }
85 
86        /**
87         * delete the Component in the tree item
88         */
89        private void deleteComponent()
90        {
91                if (component != null)
92                {
93                        component.delete();
94                        setComponent(null);
95                }
96        }
97 
98        /**
99         * (non-JSDoc)
100         * 
101         * @see org.deduced.viewer.web.shared.UserInterfaceModel#propertyChanged(org.deduced.viewer.web.shared.ChangeEvent)
102         */
103        @SuppressWarnings("unchecked")
104        @Override
105        public void propertyChanged(
106                ChangeEvent event)
107        {
108                String eventName = event.getName();
109                if (Utilities.equals(eventName, "component"))
110                {
111                        WidgetModel newComponent =
112                                (WidgetModel) event.getSerializableValue();
113                        updateComponent(newComponent);
114                }
115                else if (Utilities.equals(eventName, "text"))
116                {
117                        String newText = (String) event.getSerializableValue();
118                        updateText(newText);
119                }
120                else
121                {
122                        super.propertyChanged(event);
123                }
124        }
125 
126        /**
127         * update the component and register it
128         * 
129         * @param newComponent the new component
130         */
131        public void updateComponent(
132                WidgetModel newComponent)
133        {
134                setComponent(updateModel(newComponent, getComponent(), this));
135 
136                notifyParentThatModelChanged();
137        }
138 
139        /**
140         * text Changed
141         * 
142         * @param newText the new text
143         */
144        public void updateText(
145                String newText)
146        {
147                setText(newText);
148                notifyParentThatModelChanged();
149        }
150 
151        /**
152         * @return the component
153         */
154        public WidgetModel getComponent()
155        {
156                return component;
157        }
158 
159        /**
160         * @param setText the text to set
161         */
162        public void setText(
163                String setText)
164        {
165                text = setText;
166        }
167 
168        /**
169         * @return the text
170         */
171        public String getText()
172        {
173                return text;
174        }
175 
176        /**
177         * (non-JSDoc)
178         * 
179         * @see org.deduced.viewer.web.shared.ModelContainer#modelChanged(org.deduced.viewer.web.shared.Model)
180         */
181        @Override
182        public void modelChanged(
183                Model model)
184        {
185                notifyParentThatModelChanged();
186        }
187 
188}

[all classes][org.deduced.viewer.web.shared]
EMMA 2.0.9525 (unsupported private build) (C) Vladimir Roubtsov