Revision 958

View differences:

org.gvsig.tools/library/tags/org.gvsig.tools-3.0.12/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.12/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.12/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.12/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.12/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 org.gvsig.tools.dynobject.DynObject;
29
import org.gvsig.tools.dynobject.DynObjectSet;
30
import org.gvsig.tools.service.ServiceException;
31
import org.gvsig.tools.swing.api.Component;
32

  
33
public interface JDynFormSet  extends Component {
34

  
35
	public static final int USE_PLAIN = 0;
36
	public static final int USE_TABS = 1;
37
	public static final int USE_SEPARATORS = 2;
38
	
39
	public interface JDynFormSetListener {
40
		public void formMessage(String message);
41
		public void formClose();
42
		public void formMovedTo(int currentPosition);
43
		
44
		public void formBeforeSave() throws AbortActionException;
45
		public void formBeforeNew() throws AbortActionException;
46
		public void formBeforeDelete() throws AbortActionException;
47
		public void formBeforeSearch() throws AbortActionException;
48

  
49
		public void formAfterSave();
50
		public void formAfterNew();
51
		public void formAfterDelete();
52
		public void formAfterSearch();
53
	}
54
		
55
	public void setLayoutMode(int layoutMode);
56
	public int getLayoutMode();
57
	
58
	public void setValues(DynObjectSet values) throws ServiceException;
59
	public void setValues(List values) throws ServiceException;
60
	
61
	public void message();
62
	public void message(String msg);
63

  
64
	public void setReadOnly(boolean readOnly);
65
	public boolean isReadOnly();
66
	
67
	public void addListener(JDynFormSetListener listener);
68
	public void removeListener(JDynFormSetListener listener);
69
	
70
	public boolean isAutosave();
71
	public void setAutosave(boolean autosave);
72
	
73
	public boolean allowUpdate();
74
	public boolean allowDelete();
75
	public boolean allowNew();
76
	public boolean allowSearch();
77

  
78
	public void setAllowUpdate(boolean allowUpdate);
79
	public void setAllowDelete(boolean allowDelete);
80
	public void setAllowNew(boolean allowNew);
81
	public void setAllowSearch(boolean allowSearch);
82
	
83
	public void setFormSize(int width, int height);
84
	
85
	public DynObject get(int position);
86
	public int getCurrentIndex();
87
	public int countValues();
88
	public void setCurrentIndex(int index);
89
	
90
}
0 91

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.12/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.DynStruct;
30

  
31
@SuppressWarnings("rawtypes")
32
public interface DynFormDefinition {
33

  
34
	public String getName();
35
	
36
	public List getGroups();
37
	
38
	public List getSubgroups(String group);
39
	
40
	public List getDefinitions();
41

  
42
	public List getDefinitions(String group);
43
	
44
	public List getDefinitions(String group, String subgroup);
45
	
46
	public int getGroupOrder(String group);
47
	
48
	public void setGroupOrder(String group, int order);
49
	
50
	public void add(DynStruct definition);
51
	
52
	public DynFormFieldDefinition add(DynField definition);
53
	
54
	public DynFormFieldDefinition get(String name);
55
	
56
	public DynFormFieldDefinition get(int index);
57
	
58
	public void remove(String name);
59
	
60
	public int size();
61

  
62
}
0 63

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.12/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.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.swing.api.Component;
33

  
34
public interface JDynForm extends Component {
35

  
36
	public interface JDynFormListener {
37
		public void message(String message);
38
	}
39
	
40
	public static final int USE_PLAIN = 0;
41
	public static final int USE_TABS = 1;
42
	public static final int USE_SEPARATORS = 2;
43
	
44
	public void setLayoutMode(int layoutMode);
45
	public int getLayoutMode();
46
	
47
	public int getFormWidth();
48
	public int getFormHeight();
49
	public void setFormSize(int width, int height);
50
	
51
	public JDynFormField getField(String fieldName);
52
	
53
	public void setValues(DynObject values);
54
	public void getValues(DynObject values);
55
	
56
	public Object getValue(String fieldName);
57
	public void setValue(String fieldName, Object value);
58
	
59
	public boolean haveValidValues();
60
	public boolean haveValidValues(List<String> fieldsName);
61
	
62
	public void message();
63
	
64
	public void message(String msg);
65

  
66
	public void setReadOnly(boolean readOnly);
67
	public boolean isReadOnly();
68
	
69
	public void setShowMessageStatus(boolean showMessageStatus);
70
	
71
	public boolean isShowMessageStatus();
72

  
73
	public boolean isModified();
74
	
75
	public void addListener(JDynFormListener listener);
76
	public void removeListener(JDynFormListener listener);
77
	
78
	public void addActionToPopupMenu(DataType tipo, String name, Action action);
79
	public void addSeparatorToPopupMenu(DataType tipo);
80
}
0 81

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.12/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 JDynFormSet createJDynFormSet(DynFormDefinition definition) throws ServiceException;
45
	public JDynFormSet createJDynFormSet(DynStruct struct) throws ServiceException;
46
	public JDynFormSet createJDynFormSet(List data) throws ServiceException;
47
	public JDynFormSet createJDynFormSet(DynObjectSet data) throws ServiceException;
48

  
49
}
0 50

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.12/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

  
28
public interface DynFormFieldDefinition extends DynField {
29

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

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.12/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
}
0 79

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.12/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.12</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.12/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.12</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.12/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.12/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.12/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

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

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

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

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

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

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

  
200
	
201
	public class KeyAdapterRegEx extends KeyAdapter {
202

  
203
	    /**
204
	     * Key released on field.
205
	     */
206
	    public void keyReleased(KeyEvent e) {
207
	        String curText = ((JTextComponent) e.getSource()).getText();
208
	        curText = curText.replaceAll(getJTextFieldRegex(), "");
209

  
210
	        ((JTextComponent) e.getSource()).setText(curText);
211
	    }
212
	}
213
}
0 214

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.12/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynformfield/SupportPopupMenu.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

  
28
public interface SupportPopupMenu {
29
	public void addActionToPopupMenu(String name, Action action);
30
	public void addSeparatorToPopupMenu();
31
}
0 32

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.12/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynformfield/JProblemIndicator.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 org.gvsig.tools.swing.api.Component;
27

  
28
public interface JProblemIndicator extends Component {
29

  
30
	public void clear() ;
31
	public void set(String message) ;
32
	public void restore();
33

  
34
}
0 35

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.12/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynformfield/AbstractJDynFormFieldFactory.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 org.gvsig.tools.ToolsLocator;
27
import org.gvsig.tools.dynform.spi.DynFormSPIManager;
28
import org.gvsig.tools.dynform.spi.JDynFormFieldFactory;
29
import org.gvsig.tools.dynobject.DynField;
30
import org.gvsig.tools.dynobject.DynObject;
31
import org.gvsig.tools.dynobject.DynObjectManager;
32
import org.gvsig.tools.dynobject.DynStruct;
33
import org.gvsig.tools.service.Service;
34
import org.gvsig.tools.service.ServiceException;
35
import org.gvsig.tools.service.spi.ServiceManager;
36

  
37
public abstract class AbstractJDynFormFieldFactory implements JDynFormFieldFactory {
38

  
39
	protected String name = null;
40
	protected DynStruct parametersDefinition = null;
41
	
42
	public abstract String getName() ;
43

  
44
	public abstract Service create(DynObject parameters, ServiceManager serviceManager)
45
			throws ServiceException ;
46

  
47
	public DynObject createParameters() {
48
		return ToolsLocator.getDynObjectManager().createDynObject(parametersDefinition);
49
	}
50

  
51
	public void initialize() {
52
		if( this.parametersDefinition == null ) {
53
			String serviceName = this.getName();
54
    		DynObjectManager manager = ToolsLocator.getDynObjectManager();
55
    		this.parametersDefinition = manager.createDynClass(
56
    				serviceName, "Parameters definition for file fields in dynamic forms");
57
    		this.parametersDefinition.addDynFieldObject(DynFormSPIManager.FIELD_FIELDDEFINITION)
58
				.setClassOfValue(DynField.class).setMandatory(true);
59
    		this.parametersDefinition.addDynFieldObject(DynFormSPIManager.FIELD_VALUE)
60
				.setClassOfValue(DynField.class).setMandatory(true);
61
		}
62
	}
63

  
64
}
0 65

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.12/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynformfield/CustomSpinnerDateModel.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.SpinnerDateModel;
27

  
28
public class CustomSpinnerDateModel extends SpinnerDateModel{
29

  
30
	/**
31
	 * 
32
	 */
33
	private static final long serialVersionUID = 4389535440347616567L;
34
	
35
}
0 36

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.12/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynformfield/JCustomTextField.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

  
28
import javax.swing.Action;
29
import javax.swing.JPopupMenu;
30
import javax.swing.JTextField;
31
import javax.swing.UIManager;
32

  
33
import org.gvsig.tools.dynform.spi.DynFormSPILocator;
34

  
35
public class JCustomTextField extends JTextField  implements SupportPopupMenu{
36

  
37
	/**
38
	 * 
39
	 */
40
	private static final long serialVersionUID = 1575097883238348147L;
41
	private JPopupMenu popupMenu = null;
42
	private boolean hasEditor = true;
43
	private String title = null;
44
	
45
	private static Color backgroundColor = null; 
46
	
47
	public JCustomTextField(String title){
48
		super();
49
		if( backgroundColor == null ) {
50
			backgroundColor = UIManager.getLookAndFeel().getDefaults().getColor("TextField.background");
51
		}
52
		this.title = title;
53
		initContextMenu();
54
	}
55

  
56
	public JCustomTextField(String title, boolean withEditor){
57
		super();
58
		this.title = title;
59
		this.hasEditor   = withEditor;
60
		initContextMenu();
61
	}
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
	
77
	public void setEditable(boolean enabled){
78
		setActionEnabled("Cut", enabled);
79
		setActionEnabled("Paste", enabled);
80
		super.setEditable(enabled);
81
		this.setBackground(backgroundColor);
82
	}
83
	
84
	private void initContextMenu() {
85
		this.add(getJPopupMenu());
86
		this.setComponentPopupMenu(getJPopupMenu());
87
	}
88
	
89
	public JPopupMenu getJPopupMenu(){
90
		if(this.popupMenu == null){
91
			this.popupMenu = DynFormSPILocator.getDynFormSPIManager().createTextFieldPopupMenu(title, this, hasEditor);
92
		}
93
		return this.popupMenu;
94
	}
95
	
96
	public void addActionToPopupMenu(String name, Action action){
97
		if(name != null && !name.isEmpty()){
98
			action.putValue(Action.NAME, name);
99
		}
100
		getJPopupMenu().add(action);
101
	}
102
	
103
	public void addSeparatorToPopupMenu(){
104
		getJPopupMenu().addSeparator();
105
	}
106

  
107
}
0 108

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.12/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynformfield/JZoomDialog.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;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff