Revision 101 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

View differences:

DefaultDynObjectSwingManager.java
1 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
*/
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 22

  
23 23
/*
24
* AUTHORS (In addition to CIT):
25
* 2010 {}  {{Task}}
26
*/
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {}  {{Task}}
26
 */
27 27
package org.gvsig.tools.swing.impl.dynobject;
28 28

  
29
import java.util.HashMap;
30
import java.util.Map;
31

  
32
import org.gvsig.tools.dynobject.DynField;
29 33
import org.gvsig.tools.dynobject.DynObject;
30 34
import org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager;
31 35
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent;
36
import org.gvsig.tools.swing.api.dynobject.dynfield.DynFieldComponentFactory;
37
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent;
32 38

  
33 39
/**
34 40
 * Default {@link DynObjectSwingManager} implementation.
......
41 47
 */
42 48
public class DefaultDynObjectSwingManager implements DynObjectSwingManager {
43 49

  
50
	private Map<Integer, DynFieldComponentFactory> fieldFactories = new HashMap<Integer, DynFieldComponentFactory>(
51
			10);
52

  
44 53
	public JDynObjectComponent createJDynObjectComponent(DynObject dynObject) {
45 54
		return createJDynObjectComponent(dynObject, MODE_FORM);
46 55
	}
......
50 59
		return new DefaultJDynObjectComponent(dynObject);
51 60
	}
52 61

  
62
	public JDynFieldComponent createJDynFieldComponent(DynField field,
63
			DynObject dynObject) {
64
		DynFieldComponentFactory factory = getFactoryFor(field.getType());
65
		return (factory == null) ? null : factory.createJDynFieldComponent(
66
				field, dynObject);
67
	}
68

  
69
	public void registerDynFieldComponentFactory(
70
			DynFieldComponentFactory factory, int dataType) {
71
		fieldFactories.put(dataType, factory);
72
	}
73

  
74
	private DynFieldComponentFactory getFactoryFor(int dataType) {
75
		return fieldFactories.get(dataType);
76
	}
77

  
53 78
}

Also available in: Unified diff