Statistics
| Revision:

gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.main / src / main / java / org / gvsig / tools / main / dynobject / DynObjectComponentAction.java @ 101

History | View | Annotate | Download (2.84 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
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {}  {{Task}}
26
 */
27
package org.gvsig.tools.main.dynobject;
28

    
29
import javax.swing.JComponent;
30
import javax.swing.JTabbedPane;
31

    
32
import org.gvsig.tools.ToolsLocator;
33
import org.gvsig.tools.dynobject.DynClass;
34
import org.gvsig.tools.dynobject.DynObject;
35
import org.gvsig.tools.dynobject.DynObjectManager;
36
import org.gvsig.tools.main.MainAction;
37
import org.gvsig.tools.swing.api.ToolsSwingLocator;
38
import org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager;
39
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent;
40

    
41
/**
42
 * Action used to show the DynObject components panel
43
 * 
44
 * @author 2010- C?sar Ordi?ana - gvSIG team
45
 */
46
public class DynObjectComponentAction extends MainAction {
47

    
48
        private static final long serialVersionUID = -3386010046112585198L;
49

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

    
54
        /**
55
         * @see MainAction#MainAction(JTabbedPane)
56
         */
57
        public DynObjectComponentAction(JTabbedPane tabbedPane) {
58
                super("DynObject", tabbedPane);
59
                putValue(SHORT_DESCRIPTION, "DynObject viewer components");
60
        }
61

    
62
        @Override
63
        protected JComponent createComponent() {
64
                DynObject dynObject = createDynObject();
65
                JDynObjectComponent dynObjectView = swingManager
66
                                .createJDynObjectComponent(dynObject);
67
                return dynObjectView;
68
        }
69

    
70
        @Override
71
        protected String getComponentTitle() {
72
                return "DynObject";
73
        }
74

    
75
        private DynObject createDynObject() {
76
                DynObject dynObject = dynManager.createDynObject(createDynClass());
77

    
78
                dynObject.setDynValue("text", "some text");
79
                dynObject.setDynValue("integer", 12345);
80
                dynObject.setDynValue("float", 12345.321f);
81

    
82
                return dynObject;
83
        }
84

    
85
        private DynClass createDynClass() {
86
                DynClass dynClass = dynManager.add("test", "test dynclass");
87
                dynClass.addDynFieldString("text");
88
                dynClass.addDynFieldInt("integer");
89
                dynClass.addDynFieldFloat("float");
90
                return dynClass;
91
        }
92

    
93
}