Revision 165

View differences:

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/DynObjectValueField.java
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.dynobject.DynObject;
37
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField;
38

  
39
/**
40
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
41
 * 
42
 */
43
public class DynObjectValueField implements ValueField {
44

  
45
    private final DynObject parent;
46
    private final String fieldName;
47

  
48
    /**
49
     * @param dynObject
50
     * @param name
51
     */
52
    public DynObjectValueField(DynObject dynObject, String fieldName) {
53
	parent = dynObject;
54
	this.fieldName = fieldName;
55
    }
56

  
57
    /*
58
     * (non-Javadoc)
59
     * 
60
     * @see
61
     * org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#getDefaultValue()
62
     */
63
    public Object getDefaultValue() {
64
	return parent.getDynClass().getDynField(fieldName).getDefaultValue();
65
    }
66

  
67
    /*
68
     * (non-Javadoc)
69
     * 
70
     * @see org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#getValue()
71
     */
72
    public Object getValue() {
73
	return parent.getDynValue(fieldName);
74
    }
75

  
76
    /*
77
     * (non-Javadoc)
78
     * 
79
     * @see
80
     * org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#setValue(java
81
     * .lang.Object)
82
     */
83
    public void setValue(Object value) {
84
	parent.setDynValue(fieldName, value);
85
    }
86

  
87
}
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/AbstractSwingServiceFactory.java
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.ToolsLocator;
37
import org.gvsig.tools.dynobject.DynClass;
38
import org.gvsig.tools.service.spi.AbstractServiceFactory;
39

  
40
/**
41
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
42
 * 
43
 */
44
public abstract class AbstractSwingServiceFactory extends
45
	AbstractServiceFactory {
46

  
47
    private DynClass dynClassParams;
48
    private DynObjectSwingServiceManager manager;
49

  
50
    /*
51
     * (non-Javadoc)
52
     * 
53
     * @see
54
     * org.gvsig.tools.service.spi.AbstractServiceFactory#createParametersDynClass
55
     * ()
56
     */
57
    protected DynClass getDynClassParams() {
58

  
59
	if (dynClassParams == null)
60
	    dynClassParams = ToolsLocator.getDynObjectManager().createDynClass(
61
		    this.getFactoryName(), this.getFactoryDescription());
62
	return dynClassParams;
63
    }
64

  
65
    /**
66
     * @return
67
     */
68

  
69
    public abstract String getFactoryDescription();
70

  
71
    /**
72
     * @return
73
     */
74
    public abstract String getFactoryName();
75

  
76
    /**
77
     * @return
78
     */
79
    public abstract String getFactorySubType();
80

  
81
    /**
82
     * @return
83
     */
84
    public abstract Integer getFactoryType();
85

  
86
    /**
87
     * @return
88
     */
89
    protected DynObjectSwingServiceManager getServiceManager() {
90
	if (manager == null)
91
	    manager = ToolsSwingServiceLocator.getServiceManager();
92
	return manager;
93

  
94
    }
95
}
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/DynObjectSwingServiceManager.java
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.dynobject.DynField;
37
import org.gvsig.tools.service.ServiceException;
38
import org.gvsig.tools.service.spi.ServiceManager;
39
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent;
40
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField;
41

  
42
/**
43
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
44
 * 
45
 */
46
public interface DynObjectSwingServiceManager extends ServiceManager {
47

  
48
    public static final String DEFAULT_FACTORY_SUBTYPE = "default";
49

  
50
    public JDynFieldComponent getJDynFieldComponent(ValueField parent,
51
	    DynField field, boolean getContainerType) throws ServiceException;
52

  
53
    /**
54
     * @param component
55
     * @return
56
     */
57
    public JDynFieldComponent getJSingleComboBoxDynFieldComponent(
58
	    JDynFieldComponent component, DynField field);
59

  
60
    // /**
61
    // * @param component
62
    // * @return
63
    // */
64
    // public JDynFieldComponent getJSingleReadOnlyDynFieldComponent(
65
    // JDynFieldComponent component, DynField field);
66

  
67
    public String getServiceName(int type, String subType);
68
}
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
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.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
}
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/AbstractDynObjectComponent.java
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 java.awt.Component;
37
import java.util.HashMap;
38
import java.util.Iterator;
39
import java.util.Map;
40

  
41
import org.gvsig.tools.dynobject.DynField;
42
import org.gvsig.tools.dynobject.DynObject;
43
import org.gvsig.tools.service.Manager;
44
import org.gvsig.tools.service.ServiceException;
45
import org.gvsig.tools.swing.api.ToolsSwingLocator;
46
import org.gvsig.tools.swing.api.dynobject.DynObjectModel;
47
import org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager;
48
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent;
49
import org.gvsig.tools.swing.api.dynobject.ValueChangedListener;
50
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent;
51
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField;
52

  
53
/**
54
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
55
 * 
56
 */
57
public abstract class AbstractDynObjectComponent implements
58
	JDynObjectComponent, ValueField {
59

  
60
    private static final long serialVersionUID = 4088620749911859250L;
61

  
62
    private final DynObject dynObject;
63

  
64
    private DynObjectModel model;
65

  
66
    private final DynObjectSwingManager manager;
67

  
68
    private Map<Component, JDynFieldComponent> componentField;
69

  
70
    /**
71
     * Constructor.
72
     * 
73
     * @param dynObject
74
     *            the {@link DynObject} to render
75
     */
76
    public AbstractDynObjectComponent(DynObject dynObject, DynObjectModel model) {
77
	this.dynObject = dynObject;
78
	if (model == null)
79
	    try {
80
		this.model = ToolsSwingLocator.getDynObjectSwingManager()
81
			.createDynObjectModel(dynObject.getDynClass());
82
	    } catch (ServiceException e) {
83
		// TODO Auto-generated catch block
84
		e.printStackTrace();
85
	    }
86
	else
87
	    this.model = model;
88
	manager = ToolsSwingLocator.getDynObjectSwingManager();
89
    }
90

  
91
    protected void addComponentToList(Component component,
92
	    JDynFieldComponent input) {
93
	this.getComponents().put(component, input);
94
    }
95

  
96
    private Map<Component, JDynFieldComponent> getComponents() {
97
	if (componentField == null) {
98
	    componentField = new HashMap<Component, JDynFieldComponent>();
99
	}
100
	return componentField;
101

  
102
    }
103

  
104
    /*
105
     * (non-Javadoc)
106
     * 
107
     * @see
108
     * org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#getDefaultValue()
109
     */
110
    public Object getDefaultValue() {
111
	return this.getDynObject();
112
    }
113

  
114
    /*
115
     * (non-Javadoc)
116
     * 
117
     * @see
118
     * org.gvsig.tools.swing.impl.dynobject.JDynbjectComponent#getDynObject()
119
     */
120
    public DynObject getDynObject() {
121
	return dynObject;
122
    }
123

  
124
    protected JDynFieldComponent getJDynFieldComponent(DynField field)
125
	    throws ServiceException {
126
	return this.getJDynFieldComponent(field, null);
127
    }
128

  
129
    /**
130
     * @return
131
     * @throws ServiceException
132
     */
133
    protected JDynFieldComponent getJDynFieldComponent(DynField field,
134
	    ValueChangedListener listener) throws ServiceException {
135
	ValueField valueItem = new DynObjectValueField(this.getDynObject(),
136
		field.getName());
137
	JDynFieldComponent jfield = ((DynObjectSwingManager) this.getManager())
138
		.createJDynFieldComponent(valueItem, field);
139
	if (listener != null) {
140
	    jfield.addValueChangedListener(this);
141
	    jfield.fireValueChangedEvent();
142
	}
143
	return jfield;
144
    }
145

  
146
    /*
147
     * (non-Javadoc)
148
     * 
149
     * @see org.gvsig.tools.service.Service#getManager()
150
     */
151
    public Manager getManager() {
152
	return manager;
153
    }
154

  
155
    /*
156
     * (non-Javadoc)
157
     * 
158
     * @see org.gvsig.tools.swing.impl.dynobject.JDynbjectComponent#getModel()
159
     */
160
    public DynObjectModel getModel() {
161
	return model;
162
    }
163

  
164
    public Object getValue() {
165
	return this.getDynObject();
166
    }
167

  
168
    public boolean isValid() {
169
	Map<Component, JDynFieldComponent> items = this.getComponents();
170
	for (JDynFieldComponent item : items.values()) {
171
	    if (!this.isValid(item))
172
		return false;
173
	}
174
	return true;
175
    }
176

  
177
    /**
178
     * @param component
179
     * @return
180
     */
181
    protected abstract boolean isValid(JDynFieldComponent component);
182

  
183
    public void saveStatus() {
184
	Iterator<JDynFieldComponent> componentFields = this.getComponents()
185
		.values().iterator();
186
	JDynFieldComponent comp;
187
	while (componentFields.hasNext()) {
188
	    comp = componentFields.next();
189
	    comp.saveStatus();
190
	}
191
    }
192

  
193
}
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/AbstractJDynField.java
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.dynobject.DynField;
37

  
38
/**
39
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
40
 * 
41
 */
42
public abstract class AbstractJDynField {
43

  
44
    private final DynField dynField;
45

  
46
    public AbstractJDynField(DynField dynField) {
47
	this.dynField = dynField;
48
    }
49

  
50
    /**
51
	 * 
52
	 */
53
    abstract protected void afterUI();
54

  
55
    /**
56
     * Returns the {@link DynField} being rendered.
57
     * 
58
     * @return the DynField
59
     */
60
    public DynField getDynField() {
61
	return dynField;
62
    }
63

  
64
    abstract protected Object getFieldValue();
65

  
66
    protected void init() {
67
	this.initData();
68
	this.initUI();
69
	if (this.getDynField().isReadOnly())
70
	    this.setReadOnly();
71
	this.setValue(this.getFieldValue());
72
	this.afterUI();
73
    }
74

  
75
    /**
76
	 * 
77
	 */
78
    abstract protected void initData();
79

  
80
    /**
81
	 * 
82
	 */
83
    abstract protected void initUI();
84

  
85
    /**
86
	 * 
87
	 */
88
    abstract protected void setReadOnly();
89

  
90
    abstract protected void setValue(Object value);
91

  
92
}
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/AbstractDynObjectFactory.java
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.DynObject;
39
import org.gvsig.tools.service.Service;
40
import org.gvsig.tools.service.ServiceException;
41
import org.gvsig.tools.service.spi.ServiceManager;
42
import org.gvsig.tools.swing.api.dynobject.DynObjectModel;
43
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent;
44
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponentFactory;
45

  
46
/**
47
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
48
 * 
49
 */
50
public abstract class AbstractDynObjectFactory extends
51
	AbstractSwingServiceFactory implements JDynObjectComponentFactory {
52

  
53
    /*
54
     * (non-Javadoc)
55
     * 
56
     * @see
57
     * org.gvsig.tools.service.spi.AbstractServiceFactory#createParametersDynClass
58
     * ()
59
     */
60
    @Override
61
    protected DynClass createParametersDynClass() {
62

  
63
	// DynObjectSwingManager manager = (DynObjectSwingManager) parameters
64
	// .getDynValue(JDynFieldComponent.PARAMETERS.MANAGER);
65
	DynClass dynClassParams = this.getDynClassParams();
66
	dynClassParams.addDynField(JDynObjectComponent.PARAMETERS.DYNOBJECT)
67
		.setType(DataTypes.OBJECT).setMandatory(true);
68
	dynClassParams.addDynField(JDynObjectComponent.PARAMETERS.DYNMODEL)
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
	DynObjectModel dynModel = (DynObjectModel) parameters
85
		.getDynValue(JDynObjectComponent.PARAMETERS.DYNMODEL);
86
	DynObject dynObject = (DynObject) parameters
87
		.getDynValue(JDynObjectComponent.PARAMETERS.DYNOBJECT);
88

  
89
	try {
90
	    return this.createJDynObjectComponent(dynObject, dynModel);
91
	} catch (ServiceException e) {
92
	    // TODO Auto-generated catch block
93
	    e.printStackTrace();
94
	    return null;
95
	}
96
    }
97

  
98
    /*
99
     * (non-Javadoc)
100
     * 
101
     * @see org.gvsig.tools.service.spi.ServiceFactory#initialize()
102
     */
103
    public void initialize() {
104
	// TODO Auto-generated method stub
105

  
106
    }
107
}
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/ToolsSwingServiceLocator.java
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
package org.gvsig.tools.swing.spi;
23

  
24
import org.gvsig.tools.locator.BaseLocator;
25
import org.gvsig.tools.service.spi.ServiceManager;
26
import org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager;
27

  
28
/**
29
 * Locator for the tools swing Library. Returns references to the library's main
30
 * utilities.
31
 * 
32
 * @author 2010- C?sar Ordi?ana - gvSIG team
33
 */
34
public class ToolsSwingServiceLocator extends BaseLocator {
35

  
36
    private static final String LOCATOR_NAME = "Tools.swing.service.locator";
37

  
38
    public static final String DYNOBJECT_SWING_SERVICE_MANAGER_NAME = "Tools.swing.service.manager";
39

  
40
    public static final String DYNOBJECT_SWING_SERVICE_MANAGER_DESCRIPTION = "Tools DynObject Swing Service Manager";
41

  
42
    /**
43
     * Unique instance.
44
     */
45
    private static final ToolsSwingServiceLocator instance = new ToolsSwingServiceLocator();
46

  
47
    /**
48
     * Return the singleton instance.
49
     * 
50
     * @return the singleton instance
51
     */
52
    public static ToolsSwingServiceLocator getInstance() {
53
	return instance;
54
    }
55

  
56
    /**
57
     * Gets the instance of the {@link DynObjectSwingManager} registered.
58
     * 
59
     * @return {@link DynObjectSwingManager}
60
     */
61
    public static DynObjectSwingServiceManager getServiceManager() {
62
	return (DynObjectSwingServiceManager) getInstance().get(
63
		DYNOBJECT_SWING_SERVICE_MANAGER_NAME);
64
    }
65

  
66
    /**
67
     * Registers the Class implementing the DynObjectSwingManager interface.
68
     * 
69
     * @param clazz
70
     *            implementing the DynObjectSwingManager interface
71
     */
72
    public static void registerDynObjectServiceManager(
73
	    Class<? extends ServiceManager> clazz) {
74
	getInstance().register(DYNOBJECT_SWING_SERVICE_MANAGER_NAME,
75
		DYNOBJECT_SWING_SERVICE_MANAGER_DESCRIPTION, clazz);
76
    }
77

  
78
    /**
79
     * Return the Locator's name
80
     * 
81
     * @return a String with the Locator's name
82
     */
83
    @Override
84
    public String getLocatorName() {
85
	return LOCATOR_NAME;
86
    }
87
}
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/NFieldValue.java
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.swing.api.dynobject.dynfield.ValueField;
37

  
38
/**
39
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
40
 * 
41
 */
42
public interface NFieldValue extends ValueField {
43

  
44
}
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/AbstractJDynFieldComponent.java
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
package org.gvsig.tools.swing.spi;
23

  
24
import java.awt.BorderLayout;
25
import java.awt.Component;
26
import java.util.ArrayList;
27
import java.util.List;
28

  
29
import javax.swing.BorderFactory;
30
import javax.swing.Box;
31
import javax.swing.BoxLayout;
32
import javax.swing.JPanel;
33

  
34
import org.gvsig.tools.ToolsLocator;
35
import org.gvsig.tools.dynobject.DynField;
36
import org.gvsig.tools.dynobject.DynObject;
37
import org.gvsig.tools.dynobject.exception.DynFieldValidateException;
38
import org.gvsig.tools.service.Manager;
39
import org.gvsig.tools.service.ServiceException;
40
import org.gvsig.tools.swing.api.ToolsSwingLocator;
41
import org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager;
42
import org.gvsig.tools.swing.api.dynobject.ValueChangedListener;
43
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent;
44
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField;
45

  
46
/**
47
 * Component which is able to render a {@link DynObject} attribute value.
48
 * 
49
 * @author 2010- C?sar Ordi?ana - gvSIG team
50
 */
51
public abstract class AbstractJDynFieldComponent extends AbstractJDynField
52
	implements JDynFieldComponent {
53

  
54
    private static final long serialVersionUID = 7833217085675382320L;
55

  
56
    private final DynObjectSwingManager manager;
57

  
58
    private final List<ValueChangedListener> listeners;
59

  
60
    private final ValueField fieldValue;
61

  
62
    /**
63
     * Constructor.
64
     * 
65
     * @param dynField
66
     *            the field of the {@link DynObject} to render
67
     * @param dynObject
68
     *            the {@link DynObject} with the attribute to render
69
     */
70
    public AbstractJDynFieldComponent(DynField dynField, ValueField value)
71
	    throws ServiceException {
72
	super(dynField);
73
	fieldValue = value;
74
	listeners = new ArrayList<ValueChangedListener>();
75
	// this.dynObject = dynObject.getDynObject();
76
	manager = ToolsSwingLocator.getDynObjectSwingManager();
77
	this.init();
78
    }
79

  
80
    /*
81
     * (non-Javadoc)
82
     * 
83
     * @seeorg.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#
84
     * addValueChangedListener
85
     * (org.gvsig.tools.swing.api.dynobject.ValueChangedListener)
86
     */
87
    public void addValueChangedListener(ValueChangedListener listener) {
88
	// If it was the first item, we need to
89
	// initialize Component listeners
90
	// add listener to the dynfield set of listeners
91
	listeners.add(listener);
92
	// set supplementary listeners.
93
	this.setJDynFieldComponentListeners();
94
    }
95

  
96
    protected JPanel createBoxLayout(Component component1,
97
	    Component component2, Integer marginLeft, Integer marginRight,
98
	    JPanel container) {
99
	return this.createBoxRowPanel(container, component1, component2,
100
		marginLeft, marginRight);
101
    }
102

  
103
    /*
104
     * (non-Javadoc)
105
     * 
106
     * @see
107
     * org.gvsig.tools.swing.api.usability.UsabilitySwingManager#createBoxRowPanel
108
     * (javax.swing.JPanel, java.awt.Component, java.awt.Component,
109
     * java.lang.Integer, java.lang.Integer)
110
     */
111
    public JPanel createBoxRowPanel(JPanel panel, Component labelComponent,
112
	    Component fieldLabel, Integer marginLeft, Integer marginRight) {
113

  
114
	// Create a panel that uses GridLayout.
115
	JPanel pane = new JPanel();
116
	pane.setLayout(new BoxLayout(pane, BoxLayout.LINE_AXIS));
117
	pane.add(labelComponent);
118
	if (marginLeft != null)
119
	    pane.add(Box.createHorizontalStrut(marginLeft));
120
	// pane.add(new JSeparator(SwingConstants.VERTICAL));
121
	if (marginRight != null)
122
	    pane.add(Box.createHorizontalStrut(marginRight));
123
	pane.add(fieldLabel, BorderLayout.NORTH);
124
	// if (buttonComponent!=null)
125
	// pane.add(buttonComponent);
126
	pane.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
127
	return pane;
128
    }
129

  
130
    /*
131
     * (non-Javadoc)
132
     * 
133
     * @seeorg.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#
134
     * raiseValueChangedEvent()
135
     */
136
    public void fireValueChangedEvent() {
137
	for (ValueChangedListener listener : listeners)
138
	    listener.handleValueChanged(this);
139
    }
140

  
141
    /**
142
     * Returns the default value of the {@link DynObject}'s field to manage.
143
     * 
144
     * @return the default field's value if any, else null
145
     */
146
    protected Object getDefaultFieldValue() {
147
	return this.getDynField().getDefaultValue();
148
    }
149

  
150
    /*
151
     * (non-Javadoc)
152
     * 
153
     * @see
154
     * org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#getDefaultValue()
155
     */
156
    public Object getDefaultValue() {
157
	return fieldValue.getDefaultValue();
158
    }
159

  
160
    protected String getFieldName() {
161
	return this.getDynField().getName();
162
    }
163

  
164
    /**
165
     * @return
166
     */
167
    @Override
168
    public Object getFieldValue() {
169
	Object value = fieldValue.getValue();
170
	if (value == null)
171
	    return fieldValue.getDefaultValue();
172
	return value;
173
    }
174

  
175
    /**
176
     * Returns the value of the {@link DynObject}'s field to manage.
177
     * 
178
     * @return the field's value
179
     */
180
    protected Object getFieldValue(ValueField fieldValue) {
181
	return fieldValue.getValue();
182
    }
183

  
184
    /*
185
     * (non-Javadoc)
186
     * 
187
     * @see org.gvsig.tools.service.Service#getManager()
188
     */
189
    public Manager getManager() {
190
	return manager;
191
    }
192

  
193
    public boolean isMandatory() {
194
	return this.getDynField().isMandatory();
195
    }
196

  
197
    /**
198
     * @return
199
     */
200
    protected boolean isReadOnly() {
201
	return this.getDynField().isReadOnly();
202
    }
203

  
204
    /*
205
     * (non-Javadoc)
206
     * 
207
     * @see
208
     * org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#isValid()
209
     */
210
    public boolean isValid() {
211
	// Object value = getValue();
212
	// if ((value==null)||(value.equals("")))
213
	// if (isMandatory())
214
	// return false;
215
	// else if (value==null)
216
	// return true;
217
	return this.validate(this.getValue());
218
    }
219

  
220
    /**
221
     * Stores the edited data into the DynObject field.
222
     */
223
    public void saveStatus() {
224
	this.setFieldValue(this.getValue());
225
    }
226

  
227
    /**
228
     * Sets the value of the {@link DynObject}'s field to manage.
229
     * 
230
     * @param value
231
     *            the value for the field
232
     */
233
    public void setFieldValue(Object value) {
234
	fieldValue.setValue(value);
235
    }
236

  
237
    /**
238
	 * 
239
	 */
240
    protected abstract void setJDynFieldComponentListeners();
241

  
242
    protected String translate(String text) {
243
	return ToolsLocator.getI18nManager().getTranslation(text);
244
    }
245

  
246
    /**
247
     * @param value
248
     */
249
    private boolean validate(Object value) {
250
	try {
251
	    this.getDynField().validate(this.getValue());
252
	    return true;
253
	} catch (DynFieldValidateException e) {
254
	    return false;
255
	}
256
    }
257

  
258
}
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/DelegatedJFieldComponent.java
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 java.util.ArrayList;
37
import java.util.List;
38

  
39
import javax.swing.DefaultListModel;
40

  
41
import org.gvsig.tools.dynobject.DynField;
42
import org.gvsig.tools.service.Manager;
43
import org.gvsig.tools.service.ServiceException;
44
import org.gvsig.tools.swing.api.ToolsSwingLocator;
45
import org.gvsig.tools.swing.api.dynobject.ValueChangedListener;
46
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent;
47
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField;
48

  
49
/**
50
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
51
 * 
52
 */
53
public abstract class DelegatedJFieldComponent extends AbstractJDynField
54
	implements JDynFieldComponent {
55

  
56
    public class NValueField implements NFieldValue {
57

  
58
	private final DefaultListModel model;
59
	private final DynField field;
60
	private int selectedIndex;
61

  
62
	/**
63
	 * @param parent
64
	 */
65
	public NValueField(ValueField parent, DynField field) {
66
	    this.field = field;
67
	    this.model = new DefaultListModel();
68
	    this.selectedIndex = -1;
69
//	    elems = new ArrayList<Object>();
70

  
71
	    // Object value = parent.getValue();
72
	    // if (value==null)
73
	    // value = parent.getDefaultValue();
74
	    // if (value==null)
75
	    // this.elems = new ArrayList<Object>();
76
	    // else
77
	    // this.elems = (List) value;
78
	}
79

  
80
	public void addItem(int index, Object element) {
81
	    model.add(index, element);
82
	}
83

  
84
	/*
85
	 * (non-Javadoc)
86
	 * 
87
	 * @see
88
	 * org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#getDefaultValue
89
	 * ()
90
	 */
91
	public Object getDefaultValue() {
92
	    return field.getDefaultValue();
93
	}
94

  
95
	public DefaultListModel getModel() {
96
	    return model;
97
	}
98

  
99
	/*
100
	 * (non-Javadoc)
101
	 * 
102
	 * @see
103
	 * org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#getValue()
104
	 */
105
	public Object getValue() {
106
	    if (model.isEmpty())
107
		return null;
108
	    if ((selectedIndex < 0) || (selectedIndex >= model.getSize()))
109
		return null;
110
	    return model.get(selectedIndex);
111
	}
112

  
113
	public void removeItem(int index) {
114
	    model.remove(index);
115
	}
116

  
117
	public void setSelectedIndex(int index) {
118
	    selectedIndex = index;
119
	}
120

  
121
	/*
122
	 * (non-Javadoc)
123
	 * 
124
	 * @see
125
	 * org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#setValue(
126
	 * java.lang.Object)
127
	 */
128
	public void add(Object value) {
129
	    setValue(value);
130
	}
131
	
132
	public void setValue(Object value) {
133
	    model.add(model.getSize(), value);
134
	}
135

  
136
	/**
137
	 * @param index
138
	 * @param value
139
	 */
140
	public void add(Integer index, Object value) {
141
	    model.add(index, value);
142
	}
143

  
144
	/**
145
	 * @return
146
	 */
147
	public Object toArray() {
148
	    return model.toArray();
149
	}
150
    }
151

  
152
    protected JDynFieldComponent component;
153
    private NValueField simpleValueField;
154

  
155
    private ValueField parent;
156

  
157
    public DelegatedJFieldComponent(DynField dynField) {
158
	super(dynField);
159
	this.init();
160
    }
161

  
162
    /**
163
     * @param component2
164
     * @param dynField2
165
     */
166
    public DelegatedJFieldComponent(JDynFieldComponent component,
167
	    DynField dynField) {
168
	super(dynField);
169
	this.initComponent(component);
170
	this.init();
171
    }
172

  
173
    /**
174
     * @param parent
175
     * @param dynField2
176
     */
177
    public DelegatedJFieldComponent(ValueField parent, DynField dynField) {
178
	super(dynField);
179
	try {
180
	    simpleValueField = new NValueField(parent, dynField);
181

  
182
	    this.initComponent(ToolsSwingLocator.getDynObjectSwingManager()
183
		    .createJDynFieldComponent(simpleValueField,
184
			    dynField.getElementsType()));
185
	    this.parent = parent;
186

  
187
	    this.init();
188
	} catch (ServiceException e) {
189
	    // TODO Auto-generated catch block
190
	    e.printStackTrace();
191
	}
192
    }
193

  
194
    /*
195
     * (non-Javadoc)
196
     * 
197
     * @seeorg.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#
198
     * addValueChangedListener
199
     * (org.gvsig.tools.swing.api.dynobject.ValueChangedListener)
200
     */
201
    public void addValueChangedListener(ValueChangedListener listener) {
202
	component.addValueChangedListener(listener);
203
    }
204

  
205
    /*
206
     * (non-Javadoc)
207
     * 
208
     * @seeorg.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#
209
     * raiseValueChangedEvent()
210
     */
211
    public void fireValueChangedEvent() {
212
	component.fireValueChangedEvent();
213
    }
214

  
215
    /*
216
     * (non-Javadoc)
217
     * 
218
     * @see
219
     * org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#getDefaultValue()
220
     */
221
    public Object getDefaultValue() {
222
	return parent.getDefaultValue();
223
    }
224

  
225
    // /* (non-Javadoc)
226
    // * @see
227
    // org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#getDynObject()
228
    // */
229
    // public DynObject getDynObject() {
230
    // return this.component.getDynObject();
231
    // }
232

  
233
    /*
234
     * (non-Javadoc)
235
     * 
236
     * @see
237
     * org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#getFieldValue
238
     * ()
239
     */
240
    @Override
241
    public Object getFieldValue() {
242
	Object value = parent.getValue();
243
	if (value != null)
244
	    return value;
245
	return parent.getDefaultValue();
246
    }
247

  
248
    /*
249
     * (non-Javadoc)
250
     * 
251
     * @see org.gvsig.tools.service.Service#getManager()
252
     */
253
    public Manager getManager() {
254
	return component.getManager();
255
    }
256

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff