gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.swing / org.gvsig.tools.swing.impl / src / main / java / org / gvsig / tools / swing / impl / dynobject / DefaultDynObjectSwingManager.java @ 168
History | View | Annotate | Download (5.43 KB)
1 | 93 | cordinyana | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | 101 | cordinyana | *
|
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 | 93 | cordinyana | |
23 | /*
|
||
24 | 101 | cordinyana | * AUTHORS (In addition to CIT):
|
25 | * 2010 {} {{Task}}
|
||
26 | */
|
||
27 | 93 | cordinyana | package org.gvsig.tools.swing.impl.dynobject; |
28 | |||
29 | 168 | cmartin | import org.gvsig.tools.dynobject.DynClass; |
30 | 101 | cordinyana | import org.gvsig.tools.dynobject.DynField; |
31 | 93 | cordinyana | import org.gvsig.tools.dynobject.DynObject; |
32 | 168 | cmartin | import org.gvsig.tools.service.AbstractMultiServiceImplManager; |
33 | import org.gvsig.tools.service.Service; |
||
34 | import org.gvsig.tools.service.ServiceException; |
||
35 | import org.gvsig.tools.swing.api.dynobject.DynObjectModel; |
||
36 | 93 | cordinyana | import org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager; |
37 | import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent; |
||
38 | 101 | cordinyana | import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent; |
39 | 168 | cmartin | import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField; |
40 | import org.gvsig.tools.swing.spi.DynObjectSwingServiceManager; |
||
41 | import org.gvsig.tools.swing.spi.ToolsSwingServiceLocator; |
||
42 | 93 | cordinyana | |
43 | /**
|
||
44 | * Default {@link DynObjectSwingManager} implementation.
|
||
45 | * <p>
|
||
46 | * <strong>NOTE:</strong> initial dummy implementation to be replaced with a
|
||
47 | * more complete one.
|
||
48 | * </p>
|
||
49 | *
|
||
50 | * @author 2010- C?sar Ordi?ana - gvSIG team
|
||
51 | */
|
||
52 | 168 | cmartin | public class DefaultDynObjectSwingManager extends |
53 | AbstractMultiServiceImplManager implements DynObjectSwingManager {
|
||
54 | 93 | cordinyana | |
55 | 101 | cordinyana | |
56 | 168 | cmartin | //
|
57 | // private Map<Integer, DynFieldComponentFactory> fieldFactories = new
|
||
58 | // HashMap<Integer, DynFieldComponentFactory>(
|
||
59 | // 10);
|
||
60 | 93 | cordinyana | |
61 | 168 | cmartin | /**
|
62 | * @param serviceManager
|
||
63 | */
|
||
64 | public DefaultDynObjectSwingManager() {
|
||
65 | super(ToolsSwingServiceLocator.getServiceManager());
|
||
66 | } |
||
67 | 93 | cordinyana | |
68 | 168 | cmartin | /* (non-Javadoc)
|
69 | * @see org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager#createJDynObjectModel(org.gvsig.tools.dynobject.DynClass)
|
||
70 | */
|
||
71 | public DynObjectModel createDynObjectModel(DynClass dynClass)
|
||
72 | throws ServiceException {
|
||
73 | return new DefaultDynObjectModel(dynClass, true); |
||
74 | } |
||
75 | 101 | cordinyana | |
76 | 168 | cmartin | /* (non-Javadoc)
|
77 | * @see org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager#createEmptyDynObjectModel(org.gvsig.tools.dynobject.DynClass)
|
||
78 | */
|
||
79 | public DynObjectModel createEmptyDynObjectModel(DynClass dynClass)
|
||
80 | throws ServiceException {
|
||
81 | return new DefaultDynObjectModel(dynClass, false); |
||
82 | } |
||
83 | 101 | cordinyana | |
84 | 168 | cmartin | /* (non-Javadoc)
|
85 | * @see org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager#createJDynFieldComponent(org.gvsig.tools.dynobject.DynField, org.gvsig.tools.dynobject.DynObject)
|
||
86 | */
|
||
87 | public JDynFieldComponent createJDynFieldComponent(ValueField parent, DynField field) throws ServiceException { |
||
88 | JDynFieldComponent component; |
||
89 | if (field.getElementsType()!=null) |
||
90 | component = ((DynObjectSwingServiceManager) this.getServiceManager()).getJDynFieldComponent(parent,field, true); |
||
91 | else
|
||
92 | component = ((DynObjectSwingServiceManager) this.getServiceManager()).getJDynFieldComponent(parent,field, false); |
||
93 | return component;
|
||
94 | } |
||
95 | 101 | cordinyana | |
96 | 168 | cmartin | public JDynObjectComponent createJDynObjectComponent(DynObject dynObject) throws ServiceException { |
97 | return createJDynObjectComponent(dynObject, createDynObjectModel(dynObject.getDynClass()));
|
||
98 | } |
||
99 | |||
100 | public JDynObjectComponent createJDynObjectComponent(DynObject dynObject,
|
||
101 | DynObjectModel model) throws ServiceException {
|
||
102 | return createJDynObjectComponent(dynObject, model, MODE_FORM);
|
||
103 | } |
||
104 | |||
105 | |||
106 | |||
107 | // /*
|
||
108 | // * (non-Javadoc)
|
||
109 | // *
|
||
110 | // * @see
|
||
111 | // * org.gvsig.tools.service.Manager#createServiceParameters(java.lang.String)
|
||
112 | // */
|
||
113 | // public DynObject createServiceParameters(String serviceName)
|
||
114 | // throws ServiceException {
|
||
115 | //
|
||
116 | // return ToolsLocator.getDynObjectManager().createDynObject(serviceName);
|
||
117 | // }
|
||
118 | |||
119 | public JDynObjectComponent createJDynObjectComponent(DynObject dynObject,
|
||
120 | DynObjectModel model, String mode) throws ServiceException { |
||
121 | DynObject serviceParams = this.createServiceParameters(getServiceName(dynObject,mode));
|
||
122 | |||
123 | serviceParams |
||
124 | .setDynValue(JDynObjectComponent.PARAMETERS.DYNMODEL, model); |
||
125 | serviceParams.setDynValue(JDynObjectComponent.PARAMETERS.DYNOBJECT, |
||
126 | dynObject); |
||
127 | |||
128 | return (JDynObjectComponent) this.getService(serviceParams); |
||
129 | |||
130 | } |
||
131 | |||
132 | public JDynObjectComponent createJDynObjectComponent(DynObject dynObject,
|
||
133 | String mode) throws ServiceException { |
||
134 | return createJDynObjectComponent(dynObject, createDynObjectModel(dynObject.getDynClass()));
|
||
135 | } |
||
136 | |||
137 | /* (non-Javadoc)
|
||
138 | * @see org.gvsig.tools.service.Manager#getService(org.gvsig.tools.dynobject.DynObject)
|
||
139 | */
|
||
140 | public Service getService(DynObject serviceParams) throws ServiceException { |
||
141 | return this.getServiceManager().createService(serviceParams); |
||
142 | } |
||
143 | |||
144 | /**
|
||
145 | * @param dynObject
|
||
146 | * @param mode
|
||
147 | * @return
|
||
148 | */
|
||
149 | private String getServiceName(DynObject dynObject, String mode) { |
||
150 | return mode;
|
||
151 | } |
||
152 | 93 | cordinyana | } |