gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.swing / org.gvsig.tools.swing.spi / src / main / java / org / gvsig / tools / swing / spi / AbstractJDynFieldComponentFactory.java @ 270
History | View | Annotate | Download (5.08 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.tools.swing.spi; |
35 |
|
36 |
import org.gvsig.tools.dataTypes.DataTypes; |
37 |
import org.gvsig.tools.dynobject.DynClass; |
38 |
import org.gvsig.tools.dynobject.DynField; |
39 |
import org.gvsig.tools.dynobject.DynObject; |
40 |
import org.gvsig.tools.service.Service; |
41 |
import org.gvsig.tools.service.ServiceException; |
42 |
import org.gvsig.tools.service.spi.ServiceManager; |
43 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent; |
44 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponentFactory; |
45 |
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField; |
46 |
|
47 |
/**
|
48 |
* @author <a href="mailto:reinhold@uji.es">cmartin</a>
|
49 |
*
|
50 |
*/
|
51 |
public abstract class AbstractJDynFieldComponentFactory extends |
52 |
AbstractSwingServiceFactory implements JDynFieldComponentFactory {
|
53 |
|
54 |
/*
|
55 |
* (non-Javadoc)
|
56 |
*
|
57 |
* @see
|
58 |
*
|
59 |
* org.gvsig.tools.service.spi.AbstractServiceFactory#createParametersDynClass
|
60 |
* ()
|
61 |
*/
|
62 |
@Override
|
63 |
protected DynClass createParametersDynClass() {
|
64 |
|
65 |
DynClass dynClassParams = this.getDynClassParams();
|
66 |
|
67 |
dynClassParams.addDynField(JDynFieldComponent.PARAMETERS.PARENT) |
68 |
.setType(DataTypes.OBJECT).setMandatory(true);
|
69 |
dynClassParams.addDynField(JDynFieldComponent.PARAMETERS.DYNFIELD) |
70 |
.setType(DataTypes.OBJECT).setMandatory(true);
|
71 |
return dynClassParams;
|
72 |
} |
73 |
|
74 |
/*
|
75 |
* (non-Javadoc)
|
76 |
*
|
77 |
* @see
|
78 |
* org.gvsig.tools.service.spi.AbstractServiceFactory#doCreate(org.gvsig
|
79 |
* .tools.dynobject.DynObject, org.gvsig.tools.service.spi.ServiceManager)
|
80 |
*/
|
81 |
@Override
|
82 |
protected Service doCreate(DynObject parameters,
|
83 |
ServiceManager serviceManager) { |
84 |
|
85 |
DynField child = |
86 |
(DynField) parameters |
87 |
.getDynValue(JDynFieldComponent.PARAMETERS.DYNFIELD); |
88 |
ValueField valueField = |
89 |
(ValueField) parameters |
90 |
.getDynValue(JDynFieldComponent.PARAMETERS.PARENT); |
91 |
//
|
92 |
// JDynObjectComponent parent = (JDynObjectComponent) parameters
|
93 |
// .getDynValue(JDynFieldComponent.PARAMETERS.PARENT);
|
94 |
//
|
95 |
// ValueField valueField = new
|
96 |
// DynObjectValueField(parent.getDynObject(), child.getName());
|
97 |
//
|
98 |
try {
|
99 |
JDynFieldComponent comp = |
100 |
this.createJDynFieldComponent(child, valueField);
|
101 |
|
102 |
return this.getSuitableComponent(comp, child); |
103 |
|
104 |
} catch (ServiceException e) {
|
105 |
// TODO Auto-generated catch block
|
106 |
e.printStackTrace(); |
107 |
return null; |
108 |
} |
109 |
} |
110 |
|
111 |
/*
|
112 |
* (non-Javadoc)
|
113 |
*
|
114 |
* @see
|
115 |
* org.gvsig.tools.swing.spi.AbstractSwingServiceFactory#getFactoryName()
|
116 |
*/
|
117 |
@Override
|
118 |
public String getFactoryName() { |
119 |
return this.getName(); |
120 |
} |
121 |
|
122 |
/*
|
123 |
* (non-Javadoc)
|
124 |
*
|
125 |
* @see
|
126 |
* org.gvsig.tools.swing.spi.AbstractSwingServiceFactory#getFactoryName()
|
127 |
*/
|
128 |
@Override
|
129 |
public String getName() { |
130 |
return this.getServiceManager().getServiceName(this.getFactoryType(), |
131 |
this.getFactorySubType());
|
132 |
} |
133 |
|
134 |
private JDynFieldComponent getSuitableComponent(
|
135 |
JDynFieldComponent component, DynField field) { |
136 |
|
137 |
// if (field.isMultiple())
|
138 |
// comp = new JNDynFieldComponent(component, field);
|
139 |
|
140 |
// if ((field.isReadOnly()&&(field.getType()==DataTypes.STRING))){
|
141 |
// return
|
142 |
// this.getServiceManager().getJSingleReadOnlyDynFieldComponent(component,
|
143 |
// field);
|
144 |
// }
|
145 |
if ((!field.isContainer()) && ((field.getAvailableValues() != null))) |
146 |
return this.getServiceManager() |
147 |
.getJSingleComboBoxDynFieldComponent(component, field); |
148 |
return component;
|
149 |
} |
150 |
|
151 |
/*
|
152 |
* (non-Javadoc)
|
153 |
*
|
154 |
* @see org.gvsig.tools.service.spi.ServiceFactory#initialize()
|
155 |
*/
|
156 |
public void initialize() { |
157 |
} |
158 |
|
159 |
} |