Revision 1235

View differences:

org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.api/src/main/java/org/gvsig/tools/dynform/DynFormLocator.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform;
25

  
26
import org.gvsig.tools.locator.AbstractLocator;
27
import org.gvsig.tools.locator.Locator;
28
import org.gvsig.tools.locator.LocatorException;
29

  
30
@SuppressWarnings("rawtypes")
31
public class DynFormLocator extends AbstractLocator {
32

  
33
	private static final String LOCATOR_NAME = "DynFormsLocator";
34
	
35
	public static final String DYNFORM_MANAGER_NAME =
36
			"org.gvsig.tools.dynform.manager";
37

  
38
	private static final String DYNFORM_MANAGER_DESCRIPTION =
39
			"Persistence Manager of gvSIG";
40
	
41
	private static final DynFormLocator instance = new DynFormLocator();
42

  
43
	private DynFormLocator() {
44

  
45
	}
46

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

  
56
	public String getLocatorName() {
57
		return LOCATOR_NAME;
58
	}
59

  
60
	/**
61
	 * Return a reference to DynFormManager.
62
	 * 
63
	 * @return a reference to DynFormManager
64
	 * @throws LocatorException
65
	 *             if there is no access to the class or the class cannot be
66
	 *             instantiated
67
	 * @see Locator#get(String)
68
	 */
69
	public static DynFormManager getDynFormManager()
70
			throws LocatorException {
71
		return (DynFormManager) getInstance().get(DYNFORM_MANAGER_NAME);
72
	}
73

  
74
	/**
75
	 * Registers the Class implementing the DynFormManager interface.
76
	 * 
77
	 * @param clazz
78
	 *            implementing the DynFormManager interface
79
	 */
80
	public static void registerDynFormManager(Class clazz) {
81
		getInstance().register(DYNFORM_MANAGER_NAME,
82
				DYNFORM_MANAGER_DESCRIPTION, clazz);
83
	}
84

  
85
	public static void registerDefaultDynFormManager(Class clazz) {
86
		getInstance().registerDefault(DYNFORM_MANAGER_NAME,
87
				DYNFORM_MANAGER_DESCRIPTION, clazz);
88
	}
89

  
90

  
91
}
0 92

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.api/src/main/java/org/gvsig/tools/dynform/DynFormLibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform;
25

  
26
import org.gvsig.tools.ToolsLibrary;
27
import org.gvsig.tools.library.AbstractLibrary;
28
import org.gvsig.tools.library.LibraryException;
29
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
30

  
31
public class DynFormLibrary extends AbstractLibrary {
32

  
33
	public void doRegistration() {
34
		super.doRegistration();
35
		registerAsAPI(DynFormLibrary.class);
36
		this.require(ToolsLibrary.class);
37
	}
38
	
39
	protected void doInitialize() throws LibraryException {
40
		
41
	}
42

  
43
	protected void doPostInitialize() throws LibraryException {
44
		  // Validate there is any implementation registered.
45
        DynFormManager manager = DynFormLocator.getDynFormManager();
46
        if (manager == null) {
47
            throw new ReferenceNotRegisteredException(
48
            		DynFormLocator.DYNFORM_MANAGER_NAME, DynFormLocator
49
                    .getInstance());
50
        }
51
        
52
	}
53

  
54
}
0 55

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.api/src/main/java/org/gvsig/tools/dynform/AbortActionException.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform;
25

  
26
import org.gvsig.tools.exception.BaseException;
27

  
28
public class AbortActionException extends BaseException {
29

  
30
	/**
31
	 * 
32
	 */ 
33
	private static final long serialVersionUID = 3461167266495124406L;
34

  
35
        protected AbortActionException(String message, String key, long code){
36
            super(message, key, code);
37
        }
38
        
39
        protected AbortActionException(String message, Throwable cause, String key, long code) {
40
            super(message, cause, key, code);
41
        }
42
}
0 43

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.api/src/main/java/org/gvsig/tools/dynform/JDynFormSet.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform;
25

  
26
import java.util.List;
27

  
28
import javax.swing.Action;
29

  
30
import org.gvsig.tools.dataTypes.DataType;
31
import org.gvsig.tools.dynobject.DynObject;
32
import org.gvsig.tools.dynobject.DynObjectSet;
33
import org.gvsig.tools.service.ServiceException;
34
import org.gvsig.tools.swing.api.Component;
35

  
36
public interface JDynFormSet  extends Component {
37

  
38
	public static final int USE_PLAIN = 0;
39
	public static final int USE_TABS = 1;
40
	public static final int USE_SEPARATORS = 2;
41

  
42
	public interface JDynFormSetListener {
43
		public void formMessage(String message);
44
		public void formClose();
45
		public void formMovedTo(int currentPosition) throws AbortActionException;
46

  
47
		public void formBeforeSave(JDynFormSet dynformSet) throws AbortActionException;
48
		public void formBeforeNew(JDynFormSet dynformSet) throws AbortActionException;
49
		public void formBeforeDelete(JDynFormSet dynformSet) throws AbortActionException;
50
		public void formBeforeSearch(JDynFormSet dynformSet) throws AbortActionException;
51

  
52
		public void formAfterSave(JDynFormSet dynformSet) throws AbortActionException;
53
		public void formAfterNew(JDynFormSet dynformSet) throws AbortActionException;
54
		public void formAfterDelete(JDynFormSet dynformSet) throws AbortActionException;
55
		public void formAfterSearch(JDynFormSet dynformSet) throws AbortActionException;
56
	}
57

  
58
	public void setLayoutMode(int layoutMode);
59
	public int getLayoutMode();
60

  
61
	public boolean hasValidValues();
62
	public boolean hasValidValues(List<String> fieldsName);
63

  
64
	public void setValues(DynObjectSet values) throws ServiceException;
65
	public void setValues(List values) throws ServiceException;
66

  
67
        public List getValues();
68

  
69
	public void message();
70
	public void message(String msg);
71

  
72
	public void setReadOnly(boolean readOnly);
73
	public boolean isReadOnly();
74

  
75
	public void addListener(JDynFormSetListener listener);
76
	public void removeListener(JDynFormSetListener listener);
77

  
78
	public boolean isAutosave();
79
	public void setAutosave(boolean autosave);
80

  
81
	public boolean allowUpdate();
82
	public boolean allowDelete();
83
	public boolean allowNew();
84
	public boolean allowSearch();
85
	public boolean allowClose();
86

  
87
	public void setAllowUpdate(boolean allowUpdate);
88
	public void setAllowDelete(boolean allowDelete);
89
	public void setAllowNew(boolean allowNew);
90
	public void setAllowSearch(boolean allowSearch);
91
	public void setAllowClose(boolean allowClose);
92

  
93
	public void setFormSize(int width, int height);
94

  
95
	public DynObject get(int position);
96
	public int getCurrentIndex();
97
	public int countValues();
98
	public void setCurrentIndex(int index);
99

  
100
	public void addActionToPopupMenu(DataType tipo, String name, Action action);
101
	public void addSeparatorToPopupMenu(DataType tipo);
102

  
103
	public void setUseScrollBars(boolean usesScrolls);
104
	public boolean getUseScrollBars();
105

  
106
	public void getFormValues(DynObject values);
107

  
108

  
109
}
0 110

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.api/src/main/java/org/gvsig/tools/dynform/DynFormDefinition.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform;
25

  
26
import java.util.List;
27

  
28
import org.gvsig.tools.dynobject.DynField;
29
import org.gvsig.tools.dynobject.DynObject;
30
import org.gvsig.tools.dynobject.DynStruct;
31
import org.gvsig.tools.dynobject.Tags;
32

  
33
@SuppressWarnings("rawtypes")
34
public interface DynFormDefinition {
35

  
36
	public String getName();
37
	
38
        /**
39
         * Return the list of groups names ordered,
40
         * 
41
         * @return list of groups names
42
         */
43
	public List getGroups();
44
	
45
	public List getSubgroups(String group);
46
	
47
	public List getDefinitions();
48

  
49
	public List getDefinitions(String group);
50
	
51
	public List getDefinitions(String group, String subgroup);
52
	
53
	public int getGroupOrder(String group);
54
	
55
	public void setGroupOrder(String group, int order);
56
	
57
	public void add(DynStruct definition);
58
	
59
	public DynFormFieldDefinition add(DynField definition);
60
	
61
	public DynFormFieldDefinition get(String name);
62
	
63
	public DynFormFieldDefinition get(int index);
64
	
65
	public void remove(String name);
66
	
67
	public int size();
68
	
69
	public Tags getTags();
70

  
71
	public DynObject createElement();
72
	
73
	public void setElementsType(DynStruct struct);
74

  
75
	public DynStruct getElementsType();
76

  
77
}
0 78

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.api/src/main/java/org/gvsig/tools/dynform/JDynForm.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform;
25

  
26
import java.util.Collection;
27
import java.util.List;
28

  
29
import javax.swing.Action;
30

  
31
import org.gvsig.tools.dataTypes.DataType;
32
import org.gvsig.tools.dynobject.DynObject;
33
import org.gvsig.tools.swing.api.Component;
34

  
35
public interface JDynForm extends Component {
36

  
37
	public interface JDynFormListener {
38
		public void message(String message);
39
                /**
40
                 * This event is fired when a field of the form is changed by the user.
41
                 * 
42
                 * Now this is not yet implemented.
43
                 * 
44
                 * @param field 
45
                 */
46
		public void fieldChanged(JDynFormField field);
47
	}
48
	
49
	public static final int USE_PLAIN = 0;
50
	public static final int USE_TABS = 1;
51
	public static final int USE_SEPARATORS = 2;
52
	public static final int USE_TREE = 3;
53
	
54
	public void setLayoutMode(int layoutMode);
55
	public int getLayoutMode();
56
	
57
	public int getFormWidth();
58
	public int getFormHeight();
59
	public void setFormSize(int width, int height);
60
	
61
	public JDynFormField getField(String fieldName);
62
        
63
        public Collection getShowFields();
64
	
65
	public DynFormDefinition getDefinition();
66
	
67
	public void setValues(DynObject values);
68
	public void getValues(DynObject values);
69
	
70
	public Object getValue(String fieldName);
71
	public void setValue(String fieldName, Object value);
72
	
73
	public boolean hasValidValues();
74
	public boolean hasValidValues(List<String> fieldsName);
75
	
76
	public void message();
77
	
78
	public void message(String msg);
79

  
80
	public void setReadOnly(boolean readOnly);
81
	public boolean isReadOnly();
82
	
83
	public void setShowMessageStatus(boolean showMessageStatus);
84
	
85
	public boolean isShowMessageStatus();
86
	
87
	public void setUseScrollBars(boolean usesScrolls);
88
	public boolean getUseScrollBars();
89
	
90
	public boolean isModified();
91
	
92
	public void addListener(JDynFormListener listener);
93
	public void removeListener(JDynFormListener listener);
94
	
95
	public void addActionToPopupMenu(DataType tipo, String name, Action action);
96
	public void addSeparatorToPopupMenu(DataType tipo);
97
        
98
        public void clear();
99
}
0 100

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.api/src/main/java/org/gvsig/tools/dynform/DynFormManager.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform;
25

  
26
import java.util.List;
27

  
28
import org.gvsig.tools.dynobject.DynObject;
29
import org.gvsig.tools.dynobject.DynObjectSet;
30
import org.gvsig.tools.dynobject.DynStruct;
31
import org.gvsig.tools.service.Manager;
32
import org.gvsig.tools.service.ServiceException;
33

  
34
public interface DynFormManager extends Manager {
35

  
36
	public DynFormDefinition getDefinition(String name);
37
	public DynFormDefinition getDefinition(DynStruct definition);
38
	public DynFormDefinition getDefinition(DynObject obj);
39
	
40
	public JDynForm createJDynForm(DynFormDefinition definition) throws ServiceException;
41
	public JDynForm createJDynForm(DynStruct struct) throws ServiceException;
42
	public JDynForm createJDynForm(DynObject obj) throws ServiceException;
43
	
44
        public String getDefaultJDynFormSetName();
45
        public void setDefaultJDynFormSetName(String name);
46
        
47
	public JDynFormSet createJDynFormSet(DynFormDefinition definition) throws ServiceException;
48
	public JDynFormSet createJDynFormSet(DynStruct struct) throws ServiceException;
49
	public JDynFormSet createJDynFormSet(List data) throws ServiceException;
50
	public JDynFormSet createJDynFormSet(DynObjectSet data) throws ServiceException;	
51
        
52
        public JDynFormSet createJDynFormSet(String type, DynFormDefinition definition) throws ServiceException;
53
	public JDynFormSet createJDynFormSet(String type, DynStruct struct) throws ServiceException;
54
	public JDynFormSet createJDynFormSet(String type, List data) throws ServiceException;
55
	public JDynFormSet createJDynFormSet(String type, DynObjectSet data) throws ServiceException;
56

  
57
}
0 58

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.api/src/main/java/org/gvsig/tools/dynform/DynFormFieldDefinition.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform;
25

  
26
import org.gvsig.tools.dynobject.DynField;
27
import org.gvsig.tools.dynobject.DynField_v2;
28

  
29
public interface DynFormFieldDefinition extends DynField_v2 {
30

  
31
	public String getGroup();
32
	public String getSubgroup();
33
	
34
	public String getGroups();
35
	public String getLabel();
36
	
37
	public DynField setLabel(String label);
38
	public void setGroups(String groups);
39
	
40
}
0 41

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.api/src/main/java/org/gvsig/tools/dynform/JDynFormField.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform;
25

  
26
import javax.swing.Action;
27
import javax.swing.JComponent;
28

  
29
import org.gvsig.tools.service.Service;
30
import org.gvsig.tools.swing.api.Component;
31

  
32
public interface JDynFormField extends Component, Service {
33
	
34
	public interface JDynFormFieldListener {
35
		public void fieldEnter(JDynFormField field);
36
		public void fieldExit(JDynFormField field);
37
		public void fieldChanged(JDynFormField field);
38
		public void message(JDynFormField field, String message);
39
	}
40
	
41
	public DynFormFieldDefinition getDefinition();
42
	
43
	public String getName();
44
	
45
	public String getLabel();
46
	
47
	public JComponent getJLabel();
48

  
49
	public boolean hasValidValue();
50
	
51
	public void setValue(Object value);
52
	
53
	public boolean isModified();
54
	
55
	/**
56
	 * Get the value of field from the form.
57
	 * 
58
	 * Throw an exception if the value of form is not valid
59
	 * for this field.
60
	 * 
61
	 * @return value of field 
62
	 */
63
	public Object getValue();
64
	
65
	public void addListener(JDynFormFieldListener listener);
66
	
67
	public void removeListener(JDynFormFieldListener listener);
68
	
69
	public void setReadOnly(boolean readonly);
70
	
71
	public boolean isReadOnly();
72
	
73
	public void addActionToPopupMenu(String name, Action action);
74

  
75
	public void addSeparatorToPopupMenu();
76

  
77
	public void fireMessageEvent(String message);
78
        
79
        public void clear();
80
        
81
        public JDynForm getForm();
82
}
0 83

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.tools.dynform.DynFormLibrary
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.api/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
  <modelVersion>4.0.0</modelVersion>
3
  <packaging>jar</packaging>
4
  <artifactId>org.gvsig.tools.dynform.api</artifactId>
5
  <name>org.gvsig.tools.dynform.api</name>
6
  <description>DynForms API</description>
7
  <parent>
8
    <groupId>org.gvsig</groupId>
9
    <artifactId>org.gvsig.tools.dynform</artifactId>
10
    <version>3.0.57</version>
11
  </parent>
12
  <dependencies>
13
  	<dependency>
14
  		<groupId>org.gvsig</groupId>
15
  		<artifactId>org.gvsig.tools.lib</artifactId>
16
  	</dependency>
17
  	<dependency>
18
  		<groupId>org.gvsig</groupId>
19
  		<artifactId>org.gvsig.tools.swing.api</artifactId>
20
  	</dependency>
21
  </dependencies>
22
</project>
0 23

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
	<modelVersion>4.0.0</modelVersion>
4
	<artifactId>org.gvsig.tools.dynform</artifactId>
5
	<packaging>pom</packaging>
6
	<name>org.gvsig.tools.dynform</name>
7
	<description>Add support to DynForms</description>
8
	<parent>
9
		<groupId>org.gvsig</groupId>
10
		<artifactId>org.gvsig.tools</artifactId>
11
		<version>3.0.57</version>
12
	</parent>
13

  
14
	<modules>
15
		<module>org.gvsig.tools.dynform.api</module>
16
		<module>org.gvsig.tools.dynform.spi</module>
17
		<module>org.gvsig.tools.dynform.services</module>
18
		<module>org.gvsig.tools.dynform.impl</module>
19
	</modules>
20
</project>
0 21

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/DynFormSPILocator.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform.spi;
25

  
26
import org.gvsig.tools.locator.AbstractLocator;
27
import org.gvsig.tools.locator.Locator;
28
import org.gvsig.tools.locator.LocatorException;
29

  
30
@SuppressWarnings("rawtypes")
31
public class DynFormSPILocator extends AbstractLocator {
32

  
33
	private static final String LOCATOR_NAME = "DynFormsSPILocator";
34
	
35
	public static final String DYNFORM_SPI_MANAGER_NAME =
36
			"org.gvsig.tools.dynform.spi.manager";
37

  
38
	private static final String DYNFORM_SPI_MANAGER_DESCRIPTION =
39
			"SPI manager for gvSIG's DynForms";
40
	
41
	private static final DynFormSPILocator instance = new DynFormSPILocator();
42

  
43
	private DynFormSPILocator() {
44

  
45
	}
46

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

  
56
	public String getLocatorName() {
57
		return LOCATOR_NAME;
58
	}
59

  
60
	/**
61
	 * Return a reference to DynFormManager.
62
	 * 
63
	 * @return a reference to DynFormManager
64
	 * @throws LocatorException
65
	 *             if there is no access to the class or the class cannot be
66
	 *             instantiated
67
	 * @see Locator#get(String)
68
	 */
69
	public static DynFormSPIManager getDynFormSPIManager()
70
			throws LocatorException {
71
		return (DynFormSPIManager) getInstance().get(DYNFORM_SPI_MANAGER_NAME);
72
	}
73

  
74
	/**
75
	 * Registers the Class implementing the DynFormManager interface.
76
	 * 
77
	 * @param clazz
78
	 *            implementing the DynFormManager interface
79
	 */
80
	public static void registerDynFormSPIManager(Class clazz) {
81
		getInstance().register(DYNFORM_SPI_MANAGER_NAME,
82
				DYNFORM_SPI_MANAGER_DESCRIPTION, clazz);
83
	}
84

  
85
	public static void registerDefaultDynFormSPIManager(Class clazz) {
86
		getInstance().registerDefault(DYNFORM_SPI_MANAGER_NAME,
87
				DYNFORM_SPI_MANAGER_DESCRIPTION, clazz);
88
	}
89

  
90

  
91
}
0 92

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/DynFormSPILibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform.spi;
25

  
26
import org.gvsig.tools.dynform.DynFormLibrary;
27
import org.gvsig.tools.library.AbstractLibrary;
28
import org.gvsig.tools.library.LibraryException;
29

  
30
public class DynFormSPILibrary extends AbstractLibrary {
31

  
32
	public void doRegistration() {
33
		super.doRegistration();
34
		registerAsServiceOf(DynFormLibrary.class);
35
	}
36
	
37
	protected void doInitialize() throws LibraryException {
38
		
39
	}
40

  
41
	protected void doPostInitialize() throws LibraryException {
42
		
43
	}
44

  
45
}
0 46

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynformfield/JCustomTextArea.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform.spi.dynformfield;
25

  
26
import java.awt.Color;
27
import java.awt.event.ActionEvent;
28

  
29
import javax.swing.AbstractAction;
30
import javax.swing.Action;
31
import javax.swing.JPopupMenu;
32
import javax.swing.JTextArea;
33
import javax.swing.UIManager;
34

  
35
import org.gvsig.tools.dynform.spi.DynFormSPILocator;
36

  
37
public class JCustomTextArea extends JTextArea implements  SupportPopupMenu {
38

  
39
	/**
40
	 * 
41
	 */
42
	private static final long serialVersionUID = -6180702611660178166L;
43
	private JPopupMenu popupMenu = null;
44
	private boolean hasEditor = true;
45
	private static Color backgroundColor = null; 
46
	private String title = null;
47
	
48
	public JCustomTextArea(String title){
49
		this(title, true);
50
	}
51
	
52
	public JCustomTextArea(String title, boolean withEditor){
53
		super();
54
		this.title = title;
55
		this.hasEditor  = withEditor;
56
		if( backgroundColor == null ) {
57
			backgroundColor = UIManager.getLookAndFeel().getDefaults().getColor("TextField.background");
58
		}
59
		initComponent();
60
	}
61

  
62
	private void initComponent() {
63
		this.add(getJPopupMenu());
64
		this.setComponentPopupMenu(getJPopupMenu());
65
		this.addSeparatorToPopupMenu();
66
		DynFormFieldAction sact = new DynFormFieldAction(null, new AbstractAction() {
67
			public void actionPerformed(ActionEvent arg0) {
68
				toggleWrapMode();
69
			}
70
		});
71
		this.addActionToPopupMenu("Toggle wrap mode", sact);
72
	}
73
	
74
	private void toggleWrapMode() {
75
		this.setLineWrap(!this.getLineWrap() );
76
	}
77
	
78
	private void setActionEnabled(String name, boolean enabled) {
79
		Action action = this.getActionMap().get(name);
80
		if( action != null ) {
81
			action.setEnabled(enabled);
82
		}
83
	}
84
	
85
	public void setEnabled(boolean enabled){
86
		setActionEnabled("Cut", enabled);
87
		setActionEnabled("Paste", enabled);
88
		super.setEnabled(enabled);
89
	}
90

  
91
	
92
	public void setEditable(boolean enabled){
93
		setActionEnabled("Cut", enabled);
94
		setActionEnabled("Paste", enabled);
95
		super.setEditable(enabled);
96
		this.setBackground(backgroundColor);
97
	}
98
	
99
	public JPopupMenu getJPopupMenu(){
100
		if(this.popupMenu == null){
101
			this.popupMenu = DynFormSPILocator.getDynFormSPIManager().createTextFieldPopupMenu(title, this, hasEditor);
102
		}
103
		return this.popupMenu;
104
	}
105
	
106
	public void addActionToPopupMenu(String name, Action action){
107
		if(name != null && !name.isEmpty()){
108
			action.putValue(Action.NAME, name);
109
		}
110
		getJPopupMenu().add(action);
111
	}
112
	
113
	public void addSeparatorToPopupMenu(){
114
		getJPopupMenu().addSeparator();
115
	}
116

  
117
}
0 118

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynformfield/JCustomSpinner.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform.spi.dynformfield;
25

  
26
import javax.swing.Action;
27
import javax.swing.JPopupMenu;
28
import javax.swing.JSpinner;
29
import javax.swing.text.JTextComponent;
30

  
31
import org.gvsig.tools.dynform.spi.DynFormSPILocator;
32

  
33
public class JCustomSpinner extends JSpinner{
34

  
35
	/**
36
	 *  First approximation to a JSpinner that allows null values.
37
	 */
38
	private static final long serialVersionUID = -3949965102298015698L;
39
	private boolean allowNull = false;
40
	private JPopupMenu popupMenu = null;
41
	private JTextComponent jtext = null;
42
	private String title = null;
43
	
44
	public JCustomSpinner(String title){
45
        super(new CustomSpinnerDateModel());
46
        this.title = title;
47
        this.allowNull  = false;
48
        initComponents();
49
    }
50
	 
51
	public JCustomSpinner(String title, boolean allowNull){
52
        super();
53
        this.allowNull  = allowNull;
54
    }
55
	 
56
	public void setAllowNull(boolean allow){
57
		this.allowNull = allow;
58
	}
59
	 
60
	public boolean allowNull(){
61
		return this.allowNull;
62
	}
63
	private void setActionEnabled(String name, boolean enabled) {
64
		Action action = this.getActionMap().get(name);
65
		if( action != null ) {
66
			action.setEnabled(enabled);
67
		}
68
	}
69
		
70
	public void setEnabled(boolean enabled){
71
		setActionEnabled("Cut", enabled);
72
		setActionEnabled("Paste", enabled);
73
		super.setEnabled(enabled);
74
	}
75
	
76
	public void setEditable(boolean enabled){
77
		setActionEnabled("Cut", enabled);
78
		setActionEnabled("Paste", enabled);
79
		if( this.jtext != null ) {
80
			this.jtext.setEditable(enabled); // Parece que esto no funciona
81
				// Asi que nos limitaremos a usar setEnabled.
82
		}
83
		super.setEnabled(enabled);
84
	}
85
	
86
	private void initComponents() {
87
        try {
88
        	DefaultEditor x = (DefaultEditor) this.getEditor();
89
        	this.jtext = x.getTextField();
90
        } catch(Exception ex) {
91
        	// Do norhing
92
        }
93
        if( this.jtext != null ) { // Parece que esto no funciona, los menus no se a?aden.
94
        	this.add(getJPopupMenu());
95
        	this.setComponentPopupMenu(getJPopupMenu());
96
        }
97
	}
98
	
99
	public JPopupMenu getJPopupMenu(){
100
		if(this.popupMenu == null){
101
			this.popupMenu = DynFormSPILocator.getDynFormSPIManager().createTextFieldPopupMenu(title, this.jtext, false);
102
		}
103
		return this.popupMenu;
104
	}
105
	
106
	public void addActionToPopupMenu(String name, Action action){
107
		if(name != null && !name.isEmpty()){
108
			action.putValue(Action.NAME, name);
109
		}
110
		getJPopupMenu().add(action);
111
	}
112
	
113
	public void addSeparatorToPopupMenu(){
114
		getJPopupMenu().addSeparator();
115
	}			 
116
//	 
117
//	 private boolean valid = true;
118
//
119
//		@Override
120
//		public void setValue(Object val){
121
//			 if (val != null){
122
//	            try{
123
//	                valid = true;
124
//	                super.setValue(val);
125
//	                return;
126
//	            }
127
//	            catch (Exception e){}
128
//	        }
129
//	        valid = false;
130
//		 }
131
//		 
132
//		@Override
133
//		 public Object getValue(){
134
//			 if (valid){
135
//	            return super.getValue();
136
//	        }else{
137
//	        	this.setValue(null);
138
//	            return null;
139
//	        }
140
//		 }
141
//		 
142
//		@Override
143
//		 public Object getPreviousValue(){
144
//			 if(getValue()==null){
145
//				 return null;
146
//			 }else{
147
//				 return super.getPreviousValue();
148
//			 }
149
//		 }
150
//		 
151
//		@Override
152
//		 public Object getNextValue(){
153
//			 if(getValue()==null){
154
//				 return null;
155
//			 }else{
156
//				 return super.getNextValue();
157
//			 }
158
//		 }
159
}
0 160

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.57/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynformfield/AbstractJDynFormFieldWithValueList.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform.spi.dynformfield;
25

  
26
import java.awt.event.FocusEvent;
27
import java.awt.event.FocusListener;
28
import java.awt.event.KeyAdapter;
29
import java.awt.event.KeyEvent;
30

  
31
import javax.swing.JComboBox;
32
import javax.swing.JTextField;
33
import javax.swing.text.JTextComponent;
34
import org.apache.commons.lang3.StringUtils;
35

  
36
import org.gvsig.tools.dataTypes.CoercionException;
37
import org.gvsig.tools.dynform.JDynFormField;
38
import org.gvsig.tools.dynform.spi.dynformfield.AbstractJDynFormField.IllegalFieldValue;
39
import org.gvsig.tools.dynobject.DynObject;
40
import org.gvsig.tools.dynobject.DynObjectValueItem;
41
import org.gvsig.tools.dynobject.exception.DynFieldValidateException;
42
import org.gvsig.tools.service.spi.ServiceManager;
43

  
44
public abstract class AbstractJDynFormFieldWithValueList extends AbstractJDynFormField implements JDynFormField, FocusListener {
45
	
46
	protected Object assignedValue  = null;
47
	
48
	public AbstractJDynFormFieldWithValueList(DynObject parameters,
49
			ServiceManager serviceManager) {
50
		super(parameters, serviceManager);
51
		this.assignedValue = this.getParameterValue();
52
	}
53

  
54
	public Object getAssignedValue() {
55
		return this.assignedValue;
56
	}
57

  
58
	protected JTextField getJTextField() {
59
		return (JTextField) this.contents;
60
	}
61
	
62
	protected JComboBox getJComboBox() {
63
		return (JComboBox) this.contents;
64
	}
65
		
66
	public void initComponent() {
67
		DynObjectValueItem[] availableValues = this.getDefinition().getAvailableValues();
68
		if( availableValues==null ) {
69
			this.contents = new JCustomTextField(this.getLabel());
70
			//this.contents.addKeyListener(new KeyAdapterRegEx());
71
			this.contents.addFocusListener(this);
72
			if( this.getDefinition().isReadOnly() ) {
73
				this.getJTextField().setEditable(false);;
74
			}
75
		} else {
76
			this.contents = new JComboBox(availableValues);
77
			if( availableValues.length>0 ) {
78
				this.getJComboBox().setSelectedIndex(0);
79
			}
80
			this.contents.addFocusListener(this);
81
			if( this.getDefinition().isReadOnly() ) {
82
				this.getJComboBox().setEditable(false);
83
			}
84
		}
85
		this.setValue(this.assignedValue);
86
	}
87
	
88
	protected String getValueFromJComponent() {
89
		String s = null;
90
		if( this.contents instanceof JTextField ) {
91
			s = this.getJTextField().getText();
92
		} else {
93
			int selected =  this.getJComboBox().getSelectedIndex();
94
			if( selected <0 ) {
95
				s = null;
96
			} else {
97
				DynObjectValueItem value = (DynObjectValueItem) this.getJComboBox().getModel().getElementAt(selected);
98
				s = value.getValue().toString();
99
			}
100
		}
101
                if( StringUtils.isEmpty(s) && this.translateEmptyToNull() ) {
102
                    return null;
103
                }
104
		return s;
105
	}
106
	
107
	public void setValue(Object value) {
108
		String s = null;
109
		if( value == null ) {
110
		  this.setTranslateEmptyToNull(true);
111
			value = this.getDefinition().getDefaultValue();
112
			if( value == null ) {
113
				s = this.getDefaultValue();
114
			} else {
115
				s = value.toString();
116
			}
117
		} else {
118
		  this.setTranslateEmptyToNull(false);
119
			s = value.toString();
120
			try {
121
				this.getDefinition().validate(value);
122
				this.problemIndicator().clear();
123
			} catch (DynFieldValidateException e) {
124
				this.problemIndicator().set(e.getLocalizedMessage());
125
			}
126
		}
127
		if( this.contents instanceof JTextField ) {
128
			this.getJTextField().setText(s);
129
		} else {
130
			DynObjectValueItem item = null; 
131
			for(int i = 0; i< this.getJComboBox().getModel().getSize(); i++){
132
				item = (DynObjectValueItem) this.getJComboBox().getModel().getElementAt(i);
133
				if( item.getValue().equals(value)){
134
					break;
135
				}
136
			}
137
			if(item!=null) {
138
				this.getJComboBox().getModel().setSelectedItem(item);
139
			}
140
		}
141
		this.assignedValue = value;
142
	}
143
	
144
	/* 
145
	 * M?todos espec?ficos de cada tipo de datos
146
	 */
147
	protected String getDefaultValue(){
148
		return "";
149
	}
150
	
151
	public Object getValue() {
152
		Object value = null;
153
		String s = this.getValueFromJComponent();
154
                try {
155
                        value = this.getDefinition().coerce(s);
156
                } catch (CoercionException e) {
157
                        throw new IllegalFieldValue(this,"Can't convert value '"+s+"' to '"+ this.getDefinition().getDataType().getName() + "'.");
158
                }
159
		this.problemIndicator().clear();
160
		return value;
161
	}
162
	
163
	@SuppressWarnings("unused")
164
	public boolean hasValidValue() {
165
		try {
166
			Object value = this.getValue();
167
		} catch(Exception e) {
168
			return false;
169
		}
170
		return true;
171
	}
172

  
173
	public void focusGained(FocusEvent arg0) {
174
		fireFieldEnterEvent();
175
		this.problemIndicator().restore();
176
	}
177

  
178
	public void focusLost(FocusEvent arg0) {
179
		if( this.hasValidValue() ) {
180
			this.problemIndicator().clear();
181
		} else {
182
			try {
183
				Object value = this.getValue();
184
			} catch(Exception e) {
185
				this.problemIndicator().set(e.getLocalizedMessage());
186
			}
187
		}
188
		fireFieldExitEvent();
189
	}
190
	
191
	/**
192
	 * Este m?todo es por si se quiere a?adir una expresi?n regular al JTextField
193
	 * Por defecto, se puede escribir cualquier cosa, pero se puede sobreescribir este
194
	 * m?todo en la clase que lo requiera para a?adir restricciones (p.ej: en los num?ricos)
195
	 * @return expresi?n regular que filtra el contenido del JTextField
196
	 */
197
	public String getJTextFieldRegex(){
198
		return "[*]";
199
	}
200

  
201
	
202
	public class KeyAdapterRegEx extends KeyAdapter {
203

  
204
	    /**
205
	     * Key released on field.
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff