Revision 1167

View differences:

org.gvsig.tools/library/tags/org.gvsig.tools-3.0.42/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.42/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.42/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.42/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.42/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
}
0 36

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.42/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);
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);
53
		public void formAfterNew(JDynFormSet dynformSet);
54
		public void formAfterDelete(JDynFormSet dynformSet);
55
		public void formAfterSearch(JDynFormSet dynformSet);
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
	
107
}
0 108

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.42/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.42/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.42/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.42/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.42/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.42</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.42/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.42</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.42/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynformfield/AbstractJDynFormField.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.BorderLayout;
27
import java.awt.Color;
28
import java.util.ArrayList;
29
import java.util.HashSet;
30
import java.util.Iterator;
31
import java.util.List;
32
import java.util.Set;
33

  
34
import javax.swing.Action;
35
import javax.swing.JComboBox;
36
import javax.swing.JComponent;
37
import javax.swing.JLabel;
38
import javax.swing.JList;
39
import javax.swing.JPanel;
40
import javax.swing.JScrollPane;
41
import javax.swing.JSpinner;
42
import javax.swing.JTextField;
43
import javax.swing.JViewport;
44
import javax.swing.text.JTextComponent;
45

  
46
import org.gvsig.tools.dynform.DynFormFieldDefinition;
47
import org.gvsig.tools.dynform.JDynForm;
48
import org.gvsig.tools.dynform.JDynFormField;
49
import org.gvsig.tools.dynform.spi.DynFormSPIManager;
50
import org.gvsig.tools.dynobject.DynObject;
51
import org.gvsig.tools.service.Manager;
52
import org.gvsig.tools.service.spi.ServiceManager;
53
import org.slf4j.Logger;
54
import org.slf4j.LoggerFactory;
55

  
56
@SuppressWarnings({"rawtypes", "unchecked"})
57
public abstract class AbstractJDynFormField implements JDynFormField{
58

  
59
	protected static final Logger logger = LoggerFactory
60
			.getLogger(AbstractJDynFormField.class);
61
	
62
	private DynFormSPIManager manager = null;
63
	private DynFormFieldDefinition definition = null;
64
	private JLabel jlabel = null;
65
	private JPanel jlabelpanel = null;
66
	private Set listeners = null;
67
	private JProblemIndicator problemIndicator = null;
68

  
69
	protected DynObject parameters = null;
70
	protected JComponent contents = null;
71

  
72
	private boolean readOnly = false;
73
	private List customActions;
74
	protected boolean emptyToNull = false;
75
    private JDynForm form;
76

  
77

  
78
	public AbstractJDynFormField(DynObject parameters,
79
			ServiceManager serviceManager) {
80
		this.parameters = parameters;
81
		this.manager = (DynFormSPIManager) serviceManager;
82
		this.definition = this.getDefinition();
83
		this.listeners = new HashSet();
84
		this.readOnly = this.definition.isReadOnly();
85
		this.problemIndicator = this.manager.createProblemIndicator(this);
86
		this.customActions = new ArrayList<Action>();
87
	}
88

  
89
	public abstract void initComponent();
90
	public abstract Object getAssignedValue();
91

  
92
	public Object getParameterValue() {
93
		return this.parameters.getDynValue(DynFormSPIManager.FIELD_VALUE);
94
	}
95

  
96
	public JComponent asJComponent() {
97
		if (this.contents == null) {
98
			this.initComponent();
99
			if(!this.customActions.isEmpty()){
100
				addPopupComponents();
101
			}
102
			if( this.readOnly ) {
103
				this.setReadOnly(readOnly);
104
			}
105
		}
106
		return this.contents;
107
	}
108

  
109
	public String getName() {
110
		return this.definition.getName();
111
	}
112

  
113
	public String getLabel() {
114
		if(definition.getLabel() != null)
115
			return definition.getLabel();
116
		else
117
			return this.getName();
118
	}
119

  
120
	public JComponent getJLabel() {
121
		if (this.jlabel == null) {
122
			this.jlabel = new JLabel(this.getLabel());
123
			this.jlabel.setLabelFor(this.contents);
124
			if( this.getDefinition().isMandatory() ) {
125
				this.jlabel.setForeground(Color.red.darker());
126
			}
127
			this.jlabelpanel = new JPanel();
128
			this.jlabelpanel.setLayout(new BorderLayout());
129
			this.jlabelpanel.add(jlabel,BorderLayout.CENTER);
130
			this.jlabelpanel.add(problemIndicator.asJComponent(), BorderLayout.LINE_END);
131
		}
132
		return this.jlabelpanel;
133
	}
134

  
135
	public DynFormFieldDefinition getDefinition() {
136
		return (DynFormFieldDefinition) this.parameters
137
				.getDynValue(DynFormSPIManager.FIELD_FIELDDEFINITION);
138
	}
139

  
140
	public Manager getManager() {
141
		return this.manager;
142
	}
143
	
144
	public DynFormSPIManager getServiceManager(){
145
		return this.manager;
146
	}
147

  
148
	public void addListener(JDynFormFieldListener listener) {
149
		this.listeners.add(listener);
150
	}
151

  
152
	public void removeListener(JDynFormFieldListener listener) {
153
		this.listeners.remove(listener);
154
	}
155
	
156
	protected void fireFieldChangedEvent() {
157
		Iterator it = this.listeners.iterator();
158
		while (it.hasNext()) {
159
			JDynFormFieldListener listener = (JDynFormFieldListener) it.next();
160
			try {
161
				listener.fieldChanged(this);
162
			} catch (Exception ex) {
163
				logger.info("Error calling listener " + listener.toString()
164
						+ "(" + listener.getClass().getName() + ") from "
165
						+ this.toString() + "(" + this.getClass().getName()
166
						+ ").", ex);
167
			}
168
		}
169
	}
170

  
171
	protected void fireFieldEnterEvent() {
172
		Iterator it = this.listeners.iterator();
173
		while (it.hasNext()) {
174
			JDynFormFieldListener listener = (JDynFormFieldListener) it.next();
175
			try {
176
				listener.fieldEnter(this);
177
			} catch (Exception ex) {
178
				logger.info("Error calling listener " + listener.toString()
179
						+ "(" + listener.getClass().getName() + ") from "
180
						+ this.toString() + "(" + this.getClass().getName()
181
						+ ").", ex);
182
			}
183
		}
184
	}
185

  
186
	protected void fireFieldExitEvent() {
187
		Iterator it = this.listeners.iterator();
188
		while (it.hasNext()) {
189
			JDynFormFieldListener listener = (JDynFormFieldListener) it.next();
190
			try {
191
				listener.fieldExit(this);
192
			} catch (Exception ex) {
193
				logger.info("Error calling listener " + listener.toString()
194
						+ "(" + listener.getClass().getName() + ") from "
195
						+ this.toString() + "(" + this.getClass().getName()
196
						+ ").", ex);
197
			}
198
		}
199
	}
200
	
201
	public void fireMessageEvent(String message) {
202
		Iterator it = this.listeners.iterator();
203
		while (it.hasNext()) {
204
			JDynFormFieldListener listener = (JDynFormFieldListener) it.next();
205
			try {
206
				listener.message(this, message);
207
			} catch (Exception ex) {
208
				logger.info("Error calling listener " + listener.toString()
209
						+ "(" + listener.getClass().getName() + ") from "
210
						+ this.toString() + "(" + this.getClass().getName()
211
						+ ").", ex);
212
			}
213
		}
214
	}
215

  
216
	public boolean isReadOnly() {
217
		return this.readOnly ;
218
	}
219
	
220
	public void setReadOnly(boolean readonly) {
221
		// FIXME: Implememtacion por defecto, sobreescribirla en las subclases
222
		// segun convenga para cada componente.
223
		JTextComponent x = null;
224
				
225
		this.readOnly = readonly;
226
		if(jlabel != null){
227
			this.jlabel.setEnabled(!readonly);
228
		}
229
		if( this.contents != null ) {
230
			if( this.contents instanceof JTextComponent ) {
231
				x = (JTextComponent) this.contents;
232
				x.setEditable(!readonly);
233
			} else if( this.contents instanceof JScrollPane ) {
234
				try {
235
					JViewport port = ((JScrollPane)this.contents).getViewport();
236
					x = (JTextComponent)  port.getView();
237
					x.setEditable(!readonly);
238
				} catch(Exception ex) {
239
					this.contents.setEnabled(!readOnly);
240
				}
241
			} else {
242
				this.contents.setEnabled(!readOnly);
243
			}
244
		}
245
	}
246

  
247
	public JProblemIndicator problemIndicator() {
248
		return this.problemIndicator;
249
	}
250

  
251
	public class IllegalFieldValue extends RuntimeException {
252
		
253
		/**
254
		 * 
255
		 */
256
		private static final long serialVersionUID = -4409236610055983438L;
257

  
258
		public IllegalFieldValue(JDynFormField field, String message) {
259
			super("The value of field '"+field.getLabel()+"' is not valid. " + message);
260
		}
261
	}
262
	
263
	public String toString() {
264
		return super.toString() + "{" + this.getName() + "}";
265
	}
266
	
267
	public boolean isModified() {
268
		boolean modified = false;
269
		try {
270
			if( !this.isReadOnly() ) {
271
				Object value = this.getValue();
272
				if( value == null ) {
273
					if( value != this.getAssignedValue() ) {
274
						modified = true;
275
					}
276
				} else {
277
					if( ! value.equals(this.getAssignedValue()) ) {
278
						modified = true;
279
					}
280
				}
281
			}
282
		} catch(IllegalFieldValue ex) {
283
			// Si es incorrecto el valor del campo decimos a capom que esta modificado.
284
			modified = true;
285
		}
286
		return modified;
287
	}
288
	
289
	private void addPopupComponents(){
290
		Iterator it = this.customActions.iterator();
291
		while(it.hasNext()){
292
			Object obj = it.next();
293
			if(obj!=null){
294
				Action act = (Action) obj;
295
				if(contents instanceof SupportPopupMenu) {
296
					DynFormFieldAction sact = new DynFormFieldAction(this, act);
297
					((SupportPopupMenu) this.contents).addActionToPopupMenu(
298
						sact.getName(), 
299
						sact);
300
				}
301
			}else{
302
				if(contents instanceof SupportPopupMenu) {
303
					((SupportPopupMenu) this.contents).addSeparatorToPopupMenu();
304
				}	
305
			}
306
			
307
		}
308
	}
309

  
310
	public void addActionToPopupMenu(String name, Action action) {
311
		if(contents != null){
312
			if(contents instanceof SupportPopupMenu ) {
313
				DynFormFieldAction sact = new DynFormFieldAction(this,action);
314
				((SupportPopupMenu) this.contents).addActionToPopupMenu(
315
						sact.getName(), 
316
						sact);
317
			}
318
		}else{
319
			this.customActions.add(action);
320
		}
321
	}
322

  
323
	public void addSeparatorToPopupMenu() {
324
		if(contents != null){
325
			if( contents instanceof SupportPopupMenu ) {
326
				((SupportPopupMenu) this.contents).addSeparatorToPopupMenu();
327
			}
328
		}else{
329
			this.customActions.add(null);
330
		}
331
	}
332
	
333
	public void setTranslateEmptyToNull(boolean emptyToNull) {
334
	  this.emptyToNull = emptyToNull;
335
	}
336
	
337
	public boolean translateEmptyToNull() {
338
	  return this.emptyToNull;
339
	}
340

  
341
    public void clear() {
342
        if( this.contents == null ) {
343
            return;
344
        }
345
        if( this.contents instanceof JTextField ) {
346
            Object value = this.getDefinition().getDefaultValue();
347
            if( value != null ) {
348
                value = value.toString();
349
            } else {
350
                value = "";
351
            }
352
            ((JTextField)this.contents).setText((String)value);
353
            return;
354
        }
355
        if( this.contents instanceof JSpinner ) {
356
            Object value = this.getDefinition().getDefaultValue();
357
            if( value != null ) {
358
                value = value.toString();
359
            }
360
            ((JSpinner)this.contents).setValue(value);
361
            return;
362
        }
363
        if( this.contents instanceof JList ) {
364
            ((JList)this.contents).setSelectedIndex(-1);
365
            return;
366
        }
367
        if( this.contents instanceof JComboBox ) {
368
            ((JComboBox)this.contents).setSelectedIndex(-1);
369
            return;
370
        }
371
    }
372

  
373
    public void setForm(JDynForm form) {
374
        this.form = form;
375
    }
376
    
377
    public JDynForm getForm() {
378
        return this.form;
379
    }
380
}
0 381

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.42/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynformfield/DynFormFieldAction.java
1
package org.gvsig.tools.dynform.spi.dynformfield;
2

  
3
import java.awt.event.ActionEvent;
4
import java.beans.PropertyChangeListener;
5

  
6
import javax.swing.Action;
7

  
8
import org.gvsig.tools.dynform.JDynFormField;
9

  
10
class DynFormFieldAction implements Action{
11

  
12
	private JDynFormField field;
13
	private Action action;
14
	
15
	public DynFormFieldAction(JDynFormField field, Action act){
16
		this.field = field;
17
		this.action = act;
18
	}
19

  
20
	public Action getAction() {
21
		return this.action;
22
	}
23

  
24
	public void actionPerformed(ActionEvent arg0) {
25
		if(this.field != null)
26
			arg0.setSource(this.field);
27
		this.getAction().actionPerformed(arg0);
28
	}
29

  
30
	public String getName() {
31
		return (String) this.getAction().getValue(Action.NAME);
32
	}
33

  
34
	public void addPropertyChangeListener(PropertyChangeListener arg0) {
35
		this.action.addPropertyChangeListener(arg0);
36
	}
37

  
38
	public Object getValue(String arg0) {
39
		return this.action.getValue(arg0);
40
	}
41

  
42
	public boolean isEnabled() {
43
		return this.action.isEnabled();
44
	}
45

  
46
	public void putValue(String arg0, Object arg1) {
47
		this.action.putValue(arg0,arg1);
48
	}
49

  
50
	public void removePropertyChangeListener(PropertyChangeListener arg0) {
51
		this.action.removePropertyChangeListener(arg0);
52
	}
53

  
54
	public void setEnabled(boolean arg0) {
55
		this.action.setEnabled(arg0);
56
	}
57

  
58
}
59

  
0 60

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.42/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.42/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.
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff