Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / tools / swing / serv / field / dynobject / test / AddressDynObjectTest.java @ 33622

History | View | Annotate | Download (3.63 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22
/*
23
 * AUTHORS (In addition to CIT):
24
 * 2010 Institute of New Imaging Technologies (INIT): 
25
 *   http://www.init.uji.es
26
 * Geographic Information research group: 
27
 *   http://www.geoinfo.uji.es
28
 * Universitat Jaume I, Spain
29
 */
30

    
31
/**
32
 * 
33
 */
34
package org.gvsig.app.tools.swing.serv.field.dynobject.test;
35

    
36
import org.gvsig.tools.ToolsLocator;
37
import org.gvsig.tools.dynobject.DynObjectManager;
38
import org.gvsig.tools.dynobject.impl.DefaultDynClass;
39
import org.gvsig.tools.service.ServiceException;
40
import org.gvsig.tools.swing.api.ToolsSwingLocator;
41
import org.gvsig.tools.swing.api.dynobject.DynObjectModel;
42
import org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager;
43

    
44
/**
45
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
46
 */
47
public class AddressDynObjectTest extends DefaultDynClass {
48

    
49
    private static DynObjectSwingManager swingManager = ToolsSwingLocator.getDynObjectSwingManager();
50
    private static DynObjectManager dynManager = ToolsLocator.getDynObjectManager();
51

    
52
    private static String DYNNAME = "Address";
53
    private static String DYNDESCRIPTION = "This is an address dynObject";
54
    
55
    /**
56
     * @param name
57
     * @param description
58
     * @return
59
     */
60
    // private static DynStruct getDynClass(String name, String description) {
61
    // DynObjectManager dynManager = ToolsLocator.getDynObjectManager();
62
    // return createDynClass(dynManager.add(name,
63
    // description));
64
    // }
65

    
66
    public static void registerDynObject() {
67
        ToolsLocator.getDynObjectManager().add(new AddressDynObjectTest());
68
    }
69

    
70
    /**
71
     * 
72
     */
73
    public AddressDynObjectTest() {
74
       super(dynManager, DYNNAME, DYNDESCRIPTION);
75
       initDynClass();
76
    }
77
    
78
    /**
79
     * @param dynName
80
     * @param dynDescription
81
     */
82
    public AddressDynObjectTest(String dynName, String dynDescription) {
83
        super (dynManager, dynName, dynDescription);
84
        initDynClass();
85
    }
86

    
87
    /**
88
     * @param add
89
     * @return
90
     */
91
    private void initDynClass() {
92
        this.addDynFieldString("Street").setMandatory(true);
93
        this.addDynFieldInt("Number");
94
        this.addDynFieldString("CP");
95
        this.addDynFieldString("State");
96
        this.addDynFieldString("Country").setDefaultFieldValue("Spain");
97
    }
98

    
99
    public DynObjectModel createModel() {
100
        DynObjectModel model = null;
101
        try {
102
            model = swingManager.createEmptyDynObjectModel(this);
103
            model.add("Street");
104
            model.add("Number");
105
            model.add("CP");
106
            model.add("State");
107
            model.add("Country");
108
        } catch (ServiceException e) {
109
            e.printStackTrace();
110
        }
111
        return model;
112
    }
113

    
114
}