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 @ 202
History | View | Annotate | Download (4.73 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 |
* org.gvsig.tools.service.spi.AbstractServiceFactory#createParametersDynClass
|
59 |
* ()
|
60 |
*/
|
61 |
@Override
|
62 |
protected DynClass createParametersDynClass() {
|
63 |
|
64 |
DynClass dynClassParams = this.getDynClassParams();
|
65 |
|
66 |
dynClassParams.addDynField(JDynFieldComponent.PARAMETERS.PARENT) |
67 |
.setType(DataTypes.OBJECT).setMandatory(true);
|
68 |
dynClassParams.addDynField(JDynFieldComponent.PARAMETERS.DYNFIELD) |
69 |
.setType(DataTypes.OBJECT).setMandatory(true);
|
70 |
return dynClassParams;
|
71 |
} |
72 |
|
73 |
/*
|
74 |
* (non-Javadoc)
|
75 |
*
|
76 |
* @see
|
77 |
* org.gvsig.tools.service.spi.AbstractServiceFactory#doCreate(org.gvsig
|
78 |
* .tools.dynobject.DynObject, org.gvsig.tools.service.spi.ServiceManager)
|
79 |
*/
|
80 |
@Override
|
81 |
protected Service doCreate(DynObject parameters,
|
82 |
ServiceManager serviceManager) { |
83 |
|
84 |
DynField child = (DynField) parameters |
85 |
.getDynValue(JDynFieldComponent.PARAMETERS.DYNFIELD); |
86 |
ValueField valueField = (ValueField) parameters |
87 |
.getDynValue(JDynFieldComponent.PARAMETERS.PARENT); |
88 |
//
|
89 |
// JDynObjectComponent parent = (JDynObjectComponent) parameters
|
90 |
// .getDynValue(JDynFieldComponent.PARAMETERS.PARENT);
|
91 |
//
|
92 |
// ValueField valueField = new
|
93 |
// DynObjectValueField(parent.getDynObject(), child.getName());
|
94 |
//
|
95 |
try {
|
96 |
JDynFieldComponent comp = this.createJDynFieldComponent(child,
|
97 |
valueField); |
98 |
|
99 |
return this.getSuitableComponent(comp, child); |
100 |
|
101 |
} catch (ServiceException e) {
|
102 |
// TODO Auto-generated catch block
|
103 |
e.printStackTrace(); |
104 |
return null; |
105 |
} |
106 |
} |
107 |
|
108 |
/*
|
109 |
* (non-Javadoc)
|
110 |
*
|
111 |
* @see
|
112 |
* org.gvsig.tools.swing.spi.AbstractSwingServiceFactory#getFactoryName()
|
113 |
*/
|
114 |
@Override
|
115 |
public String getFactoryName() { |
116 |
return this.getName(); |
117 |
} |
118 |
|
119 |
/*
|
120 |
* (non-Javadoc)
|
121 |
*
|
122 |
* @see
|
123 |
* org.gvsig.tools.swing.spi.AbstractSwingServiceFactory#getFactoryName()
|
124 |
*/
|
125 |
@Override
|
126 |
public String getName() { |
127 |
return this.getServiceManager().getServiceName(this.getFactoryType(), |
128 |
this.getFactorySubType());
|
129 |
} |
130 |
|
131 |
private JDynFieldComponent getSuitableComponent(
|
132 |
JDynFieldComponent component, DynField field) { |
133 |
|
134 |
// if (field.isMultiple())
|
135 |
// comp = new JNDynFieldComponent(component, field);
|
136 |
|
137 |
// if ((field.isReadOnly()&&(field.getType()==DataTypes.STRING))){
|
138 |
// return
|
139 |
// this.getServiceManager().getJSingleReadOnlyDynFieldComponent(component,
|
140 |
// field);
|
141 |
// }
|
142 |
if ((!field.isContainer())&&((field.getAvailableValues() != null))) |
143 |
return this.getServiceManager() |
144 |
.getJSingleComboBoxDynFieldComponent(component, field); |
145 |
return component;
|
146 |
} |
147 |
|
148 |
/*
|
149 |
* (non-Javadoc)
|
150 |
*
|
151 |
* @see org.gvsig.tools.service.spi.ServiceFactory#initialize()
|
152 |
*/
|
153 |
public void initialize() { |
154 |
} |
155 |
|
156 |
} |