Revision 2653

View differences:

org.gvsig.tools/library/tags/org.gvsig.tools-3.0.303/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.303/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
//        public boolean hasLabel();
37
	
38
	public DynField setLabel(String label);
39
	public void setGroups(String groups);
40
	
41
}
0 42

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.303/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
import org.gvsig.tools.dynobject.DynObject;
29

  
30
import org.gvsig.tools.swing.api.Component;
31

  
32
public interface JDynFormField extends Component {
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 useEmptyLabel();
50
        
51
        public String getSeparatorTitleToUseBefore();
52
        
53
	public boolean hasValidValue();
54
	
55
	public void setValue(Object value);
56
	
57
	public boolean isModified();
58
	
59
	/**
60
	 * Get the value of field from the form.
61
	 * 
62
	 * Throw an exception if the value of form is not valid
63
	 * for this field.
64
	 * 
65
	 * @return value of field 
66
	 */
67
	public Object getValue();
68
        
69
        /**
70
         * Get the value from field and put it in the container.
71
         * 
72
         * @param container 
73
         */
74
        public void fetch(DynObject container);
75
	
76
	public void addListener(JDynFormFieldListener listener);
77
	
78
	public void removeListener(JDynFormFieldListener listener);
79
	
80
	public void setReadOnly(boolean readonly);
81
	
82
	public boolean isReadOnly();
83
	
84
	public void addActionToPopupMenu(String name, Action action);
85

  
86
	public void addSeparatorToPopupMenu();
87

  
88
	public void fireMessageEvent(String message);
89
        
90
        public void clear();
91
        
92
        public JDynForm getForm();
93
        
94
        public double getResizeWeight();
95
}
0 96

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.303/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.303/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.303/org.gvsig.tools.dynform/org.gvsig.tools.dynform.api/src/main/java/org/gvsig/tools/dynform/JDynFormFieldListenerAdapter.java
1
package org.gvsig.tools.dynform;
2

  
3
/**
4
 *
5
 * @author jjdelcerro
6
 */
7
abstract class JDynFormFieldListenerAdapter implements JDynFormField.JDynFormFieldListener {
8

  
9
    @Override
10
    public void fieldEnter(JDynFormField jdff) {
11
    }
12

  
13
    @Override
14
    public void fieldExit(JDynFormField jdff) {
15
    }
16

  
17
    @Override
18
    public void fieldChanged(JDynFormField jdff) {
19
    }
20

  
21
    @Override
22
    public void message(JDynFormField jdff, String string) {
23
    }
24

  
25
}
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.303/org.gvsig.tools.dynform/org.gvsig.tools.dynform.api/src/main/java/org/gvsig/tools/dynform/AbortActionException.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynform;
25

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

  
28
public class AbortActionException extends BaseException {
29

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

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

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.303/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
import javax.swing.JComponent;
30

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

  
36
public interface JDynFormSet  extends Component {
37

  
38
        public static final String ACTION_FIRST = "first";
39
        public static final String ACTION_PREVIOUS = "previous";
40
        public static final String ACTION_NEXT = "next";
41
        public static final String ACTION_LAST = "last";
42
        public static final String ACTION_SAVE = "save";
43
        public static final String ACTION_NEW = "new";
44
        public static final String ACTION_CANCEL_NEW = "cancel-new";
45
        public static final String ACTION_DELETE = "delete";
46
        public static final String ACTION_SEARCH = "search";
47
        public static final String ACTION_CLOSE = "close";
48
        public static final String ACTION_SET_CURRENT_RECORD = "set-current-record";
49

  
50
        public static final String ACTION_NAVIGATION = "#navigation";
51
        
52
	public interface JDynFormSetListener {
53
		public void formMessage(String message);
54
		public void formClose();
55
		public void formMovedTo(int currentPosition) throws AbortActionException;
56

  
57
		public void formBeforeSave(JDynFormSet dynformSet) throws AbortActionException;
58
		public void formBeforeNew(JDynFormSet dynformSet) throws AbortActionException;
59
		public void formBeforeCancelNew(JDynFormSet dynformSet) throws AbortActionException;
60
		public void formBeforeDelete(JDynFormSet dynformSet) throws AbortActionException;
61
		public void formBeforeSearch(JDynFormSet dynformSet) throws AbortActionException;
62

  
63
		public void formAfterSave(JDynFormSet dynformSet) throws AbortActionException;
64
		public void formAfterNew(JDynFormSet dynformSet) throws AbortActionException;
65
		public void formAfterCancelNew(JDynFormSet dynformSet) throws AbortActionException;
66
		public void formAfterDelete(JDynFormSet dynformSet) throws AbortActionException;
67
		public void formAfterSearch(JDynFormSet dynformSet) throws AbortActionException;
68
	}
69

  
70
	public void setLayoutMode(int layoutMode);
71
	public int getLayoutMode();
72

  
73
	public boolean hasValidValues();
74
	public boolean hasValidValues(List<String> fieldsName);
75

  
76
	public void setValues(DynObjectSet values);
77
	public void setValues(List values);
78

  
79
        public List getValues();
80

  
81
	public void message();
82
	public void message(String msg);
83

  
84
	public void setReadOnly(boolean readOnly);
85
	public boolean isReadOnly();
86

  
87
	public void addListener(JDynFormSetListener listener);
88
	public void removeListener(JDynFormSetListener listener);
89

  
90
	public boolean isAutosave();
91
	public void setAutosave(boolean autosave);
92

  
93
	public boolean allowUpdate();
94
	public boolean allowDelete();
95
	public boolean allowNew();
96
	public boolean allowSearch();
97
	public boolean allowClose();
98

  
99
	public void setAllowUpdate(boolean allowUpdate);
100
	public void setAllowDelete(boolean allowDelete);
101
	public void setAllowNew(boolean allowNew);
102
	public void setAllowSearch(boolean allowSearch);
103
	public void setAllowClose(boolean allowClose);
104

  
105
	public void setFormSize(int width, int height);
106

  
107
	public DynObject get(int position);
108
	public int getCurrentIndex();
109
	public int countValues();
110
        
111
        /**
112
         * Set the current element of form.
113
         * If the form is modified, the changes will be lost.
114
         * @param index 
115
         */
116
	public void setCurrentIndex(int index);
117
        public boolean isInNewState();
118

  
119
        public void addAction(Action action);
120
        public Action getAction(String actionId);
121
        public List<Action> getActions();
122
        public void setActionVisible(String action, boolean visible);
123
        public void setActionEnabled(String action, boolean enabled);
124
        public boolean isActionVisible(String action);
125
        public boolean isActionEnabled(String action);
126
        public JComponent getActionButton(String action);
127
        public void fireEvent(String action, Object value);
128
        
129
	public void addActionToPopupMenu(DataType tipo, String name, Action action);
130
	public void addSeparatorToPopupMenu(DataType tipo);
131

  
132
	public void setUseScrollBars(boolean usesScrolls);
133
	public boolean getUseScrollBars();
134

  
135
	public void getFormValues(DynObject values);
136

  
137
        public JDynForm getForm();
138

  
139

  
140
}
0 141

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.303/org.gvsig.tools.dynform/org.gvsig.tools.dynform.api/src/main/java/org/gvsig/tools/dynform/JDynFormSetAdapter.java
1
package org.gvsig.tools.dynform;
2

  
3
import org.gvsig.tools.dynform.JDynFormSet.JDynFormSetListener;
4

  
5
/**
6
 *
7
 * @author gvSIG Team
8
 */
9
public abstract class JDynFormSetAdapter implements JDynFormSetListener {
10

  
11
    @Override
12
    public void formMessage(String message) {
13
    }
14

  
15
    @Override
16
    public void formClose() {
17
    }
18

  
19
    @Override
20
    public void formMovedTo(int currentPosition) throws AbortActionException {
21
    }
22

  
23
    @Override
24
    public void formBeforeSave(JDynFormSet dynformSet) throws AbortActionException {
25
    }
26

  
27
    @Override
28
    public void formBeforeNew(JDynFormSet dynformSet) throws AbortActionException {
29
    }
30

  
31
    @Override
32
    public void formBeforeCancelNew(JDynFormSet dynformSet) throws AbortActionException {
33
    }
34

  
35
    @Override
36
    public void formBeforeDelete(JDynFormSet dynformSet) throws AbortActionException {
37
    }
38

  
39
    @Override
40
    public void formBeforeSearch(JDynFormSet dynformSet) throws AbortActionException {
41
    }
42

  
43
    @Override
44
    public void formAfterSave(JDynFormSet dynformSet) throws AbortActionException {
45
    }
46

  
47
    @Override
48
    public void formAfterNew(JDynFormSet dynformSet) throws AbortActionException {
49
    }
50

  
51
    @Override
52
    public void formAfterCancelNew(JDynFormSet dynformSet) throws AbortActionException {
53
    }
54

  
55
    @Override
56
    public void formAfterDelete(JDynFormSet dynformSet) throws AbortActionException {
57
    }
58

  
59
    @Override
60
    public void formAfterSearch(JDynFormSet dynformSet) throws AbortActionException {
61
    }
62
    
63
}
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.303/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
public interface DynFormDefinition extends Iterable<DynFormFieldDefinition> {
34

  
35
	public String getName();
36
	
37
        public String getLabel();
38
        
39
        public void setLabel(String label);
40
        /**
41
         * Return the list of groups names ordered,
42
         * 
43
         * @return list of groups names
44
         */
45
	public List<String> getGroups();
46
	
47
	public List<String> getSubgroups(String group);
48
	
49
	public List<DynFormFieldDefinition> getDefinitions();
50

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

  
73
	public DynObject createElement();
74
	
75
	public void setElementsType(DynStruct struct);
76

  
77
	public DynStruct getElementsType();
78

  
79
}
0 80

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.303/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
import javax.swing.JComponent;
30

  
31
import org.gvsig.tools.dataTypes.DataType;
32
import org.gvsig.tools.dynobject.DynObject;
33
import org.gvsig.tools.swing.api.Component;
34
import org.gvsig.tools.util.PropertiesSupport;
35
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
36
import org.gvsig.tools.script.Script;
37
import org.gvsig.tools.script.ScriptManager;
38

  
39
public interface JDynForm extends Component, PropertiesSupport {
40

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

  
90
	public void setReadOnly(boolean readOnly);
91
	public boolean isReadOnly();
92
	
93
	public void setShowMessageStatus(boolean showMessageStatus);
94
	
95
	public boolean isShowMessageStatus();
96
	
97
	public void setUseScrollBars(boolean usesScrolls);
98
	public boolean getUseScrollBars();
99
	
100
	public boolean isModified();
101
	
102
	public void addListener(JDynFormListener listener);
103
	public void removeListener(JDynFormListener listener);
104
	
105
	public void addActionToPopupMenu(DataType tipo, String name, Action action);
106
	public void addSeparatorToPopupMenu(DataType tipo);
107
        
108
        public JComponent getFieldsContainer();
109
        
110
        public void clear();
111
        
112
        public DynFormContext getContext();
113
        
114
        public void setContext(DynFormContext context);
115

  
116
        public Script getScript();
117
        
118
        public Object callUserFunction(String function, Object...args) throws Exception;
119
        
120
}
0 121

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

  
27
import org.gvsig.tools.dynobject.DynObject;
28
import org.gvsig.tools.dynobject.DynStruct;
29
import org.gvsig.tools.dynform.JDynForm.DynFormContext;
30
import org.gvsig.tools.dynobject.DynObjectSet;
31
import org.gvsig.tools.dynobject.Tags;
32

  
33
public interface DynFormManager { //extends Manager {
34

  
35
        public DynFormDefinition createDefinition(DynStruct definition);
36
	public DynFormDefinition getDefinition(String name);
37
	public DynFormDefinition getDefinition(DynStruct definition);
38
	public DynFormDefinition getDefinition(DynObject obj);
39
        public void removeDefinition(String name);
40
	
41
	public JDynForm createJDynForm(DynFormDefinition definition) ;
42
	public JDynForm createJDynForm(DynStruct struct) ;
43
	public JDynForm createJDynForm(DynObject obj) ;
44
	
45
	public JDynForm createJDynForm(DynFormContext context, DynFormDefinition definition) ;
46
	public JDynForm createJDynForm(DynFormContext context, DynStruct struct) ;
47
	public JDynForm createJDynForm(DynFormContext context, DynObject obj) ;
48
	
49
	public JDynFormSet createJDynFormSet(DynFormContext context, DynFormDefinition definition);
50
	public JDynFormSet createJDynFormSet(DynFormContext context, DynFormDefinition definition, Tags contextTags);
51
	public JDynFormSet createJDynFormSet(DynFormContext context, DynObjectSet data);
52
        
53
}
0 54

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.303/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.303</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.303/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.303</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.303/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.tools.dynform.spi.DynFormSPILibrary
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.303/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/DynFormSPIManager.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 modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.tools.dynform.spi;
24

  
25
import java.util.List;
26
import javax.swing.Action;
27
import javax.swing.JButton;
28
import javax.swing.JCheckBox;
29
import javax.swing.JComboBox;
30
import javax.swing.JLabel;
31
import javax.swing.JList;
32
import org.gvsig.tools.dynform.spi.dynformfield.JDynFormFieldFactory;
33
import org.gvsig.tools.dynform.spi.dynform.JDynFormFactory;
34
import org.gvsig.tools.dynform.spi.dynformset.JDynFormSetFactory;
35
import javax.swing.JPopupMenu;
36
import javax.swing.JScrollPane;
37
import javax.swing.JSpinner;
38
import javax.swing.JTable;
39
import javax.swing.JTextArea;
40
import javax.swing.text.JTextComponent;
41
import org.gvsig.tools.dynform.DynFormDefinition;
42

  
43
import org.gvsig.tools.dynform.DynFormFieldDefinition;
44
import org.gvsig.tools.dynform.DynFormManager;
45
import org.gvsig.tools.dynform.JDynForm.DynFormContext;
46
import org.gvsig.tools.dynform.JDynFormField;
47
import org.gvsig.tools.dynform.spi.dynformfield.JProblemIndicator;
48
import org.gvsig.tools.dynform.spi.dynformfield.JZoomDialog;
49
import org.gvsig.tools.dynobject.Tags;
50
import org.gvsig.tools.service.spi.NotRegisteredException;
51

  
52
public interface DynFormSPIManager {
53

  
54
    public interface PopupMenuActionFactory {
55
        public String getName();
56
        public boolean isApplicable(JDynFormField jfield);
57
        public Action create(JDynFormField jfield);
58
    }
59

  
60
    public interface ComponentsFactory {
61
        public interface ScrolledComponent<T> {
62
            public  JScrollPane getScrollPane();
63
            public T getComponent();
64
        }
65
        public boolean containsComponents(DynFormFieldDefinition definition);
66
        public boolean containsJComboBox(DynFormFieldDefinition definition, String prefix);
67
        public boolean containsJLabel(DynFormFieldDefinition definition, String prefix);
68
        public boolean containsJSpinner(DynFormFieldDefinition definition, String prefix);
69
        public boolean containsJTextField(DynFormFieldDefinition definition, String prefix);
70
        public boolean containsJButton(DynFormFieldDefinition definition, String prefix);
71
        
72
        public JButton getJButton(DynFormFieldDefinition definition, String prefix);
73
        public ScrolledComponent<JTable> getJTable(DynFormFieldDefinition definition, String prefix);
74
        public JCheckBox getJCheckBox(DynFormFieldDefinition definition, String prefix);
75
        public JLabel getJLabel(DynFormFieldDefinition definition, String prefix);
76
        public JComboBox getJComboBox(DynFormFieldDefinition definition, String prefix);
77
        public JTextComponent getJTextField(DynFormFieldDefinition definition, String prefix);
78
        public JTextComponent getJPasswordField(DynFormFieldDefinition definition, String prefix);
79
        public JSpinner getJSpinner(DynFormFieldDefinition definition, String prefix);
80
        public ScrolledComponent<JTextArea> getJTextArea(DynFormFieldDefinition definition, String prefix);
81
        public ScrolledComponent<JList> getJList(DynFormFieldDefinition definition, String prefix);
82
    }
83
    
84
    public static final String USERCODE_FORM_ONLOAD = "form_onLoad";
85
    public static final String USERCODE_FORM_ONSETVALUES = "form_onSetvalues";
86
    public static final String USERCODE_FORM_ONFIELDENTER = "form_onFieldEnter";
87
    public static final String USERCODE_FORM_ONFIELDEXIT = "form_onFieldExit";
88
    public static final String USERCODE_FORM_ONFIELDCHANGED = "form_onFieldChanged";
89
    public static final String USERCODE_FORM_VALIDATE = "form_validate";
90
    public static final String USERCODE_FORM_CLEAR = "form_clear";
91
    public static final String USERCODE_FORM_ISREADONLY = "form_isReadOnly";
92
    public static final String USERCODE_FORM_ISMODIFIED = "form_isModified";
93

  
94
    public static final String TAG_DYNFORM_ABEILLE_FORM = "dynform.abeille.form.resource";
95
    public static final String TAG_DYNFORM_LAYOUTMODE = "dynform.layoutmode";
96
    public static final String TAG_DYNFORM_LAYOUTMODE_VALUE_TABS = "tabs";
97
    public static final String TAG_DYNFORM_LAYOUTMODE_VALUE_PLAIN = "plain";
98
    public static final String TAG_DYNFORM_LAYOUTMODE_VALUE_SEPARATORS = "separators";
99
    
100
    public static final String TAG_DYNFORM_AUTOSAVE = "dynform.autosave";
101
    public static final String TAG_DYNFORM_BORDER = "dynform.border";
102
    public static final String TAG_DYNFORM_VIEWMODE = "dynform.viewmode";
103
    public static final String TAG_DYNFORM_HEIGHT = "dynform.height";
104
    public static final String TAG_DYNFORM_WIDTH = "dynform.width";
105
    public static final String TAG_DYNFORM_LABEL_EMPTY = "dynform.label.empty";
106
    public static final String TAG_DYNFORM_ACTION_NEW = "dynform.action.new";
107
    public static final String TAG_DYNFORM_ACTION_UPDATE = "dynform.action.update";
108
    public static final String TAG_DYNFORM_ACTION_DELETE = "dynform.action.delete";
109
    public static final String TAG_DYNFORM_ACTION_SEARCH = "dynform.action.search";
110
    public static final String TAG_DYNFORM_ACTION_CLOSE = "dynform.action.close";
111
    public static final String TAG_DYNFORM_ROWS = "dynform.rows";
112
    public static final String TAG_DYNFORM_USESCROLLBARS = "dynform.useScrollBars";
113
    public static final String TAG_DYNFORM_READONLY = "dynform.readonly";
114
    public static final String TAG_DYNFORM_TRANSLATE_EMPTY_TO_NULL = "dynform.translateEmptyToNull";
115
    public static final String TAG_DYNFORM_SEPARATOR = "dynform.separator";
116
    public static final String TAG_DYNFORM_DROPDOWN = "dynform.dropdown";
117
    public static final String TAG_DYNFORM_RESIZEWEIGHT = "dynform.resizeWeight";
118

  
119
    public void registerDynFieldFactory(JDynFormFieldFactory factory);
120
    
121
    public void registerDynFormFactory(JDynFormFactory factory);
122
    
123
    public void registerDynFormSetFactory(JDynFormSetFactory factory);
124
    
125
    public JDynFormFactory getJDynFormFactory(DynFormContext context, DynFormDefinition definition) throws NotRegisteredException;
126
    
127
    public JDynFormSetFactory getJDynFormSetFactory(DynFormContext context, DynFormDefinition definition, Tags contextTags) throws NotRegisteredException;
128
    
129
    public JDynFormFieldFactory getJDynFormFieldFactory(DynFormContext context, DynFormFieldDefinition definition) throws NotRegisteredException;
130
    
131
    public JDynFormFieldFactory getJDynFormFieldFactory(String name);
132
    
133
    public List<JDynFormFieldFactory> getJDynFormFieldFactories();
134

  
135
    public DynFormManager getDynFormManager();
136

  
137
    public JZoomDialog createJZoomDialog(String title, String message, String text);
138

  
139
    public JProblemIndicator createProblemIndicator(JDynFormField field);
140

  
141
    public JPopupMenu createTextFieldPopupMenu(String title, JTextComponent component, boolean zoom);
142
    
143
    public ComponentsFactory createDefaultComponentsFactory();
144
    
145
    public void configurePopupMenu(JDynFormField jfield);
146
    
147
    public Iterable<PopupMenuActionFactory> getPopupMenuActionFactories();
148
    
149
    public void addPopupMenuAction(PopupMenuActionFactory factory);
150
    
151
}
0 152

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.303/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynformset/DefaultVisitableSet.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.dynformset;
25

  
26
import java.util.HashSet;
27
import java.util.Iterator;
28

  
29
import org.gvsig.tools.dynform.AbortActionException;
30
import org.gvsig.tools.dynform.spi.dynformfield.VisitableSet;
31
import org.gvsig.tools.exception.BaseException;
32
import org.gvsig.tools.visitor.Visitor;
33
import org.slf4j.Logger;
34
import org.slf4j.LoggerFactory;
35

  
36
public class DefaultVisitableSet extends HashSet implements VisitableSet {
37

  
38
	public static final Logger logger = LoggerFactory.getLogger(DefaultVisitableSet.class);
39
	/**
40
	 * 
41
	 */
42
	private static final long serialVersionUID = -5771630108958038764L;
43

  
44
	public void accept(Visitor visitor) throws BaseException {
45
		Iterator it = this.iterator();
46
		while (it.hasNext()) {
47
			Object value = it.next();
48
			try {
49
				visitor.visit(value);
50
			} catch (AbortActionException ex) {
51
				throw ex;
52
			} catch (Exception ex) {
53
				logger.info("Error visiting " + value.toString()
54
						+ "(" + value.getClass().getName() + ") with "
55
						+ visitor.toString() + "(" + visitor.getClass().getName()
56
						+ ").", ex);
57
			}
58
		}
59
	}
60

  
61
}
0 62

  
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.303/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynformset/AbstractJDynFormSet.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.tools.dynform.spi.dynformset;
7

  
8
import java.util.ArrayList;
9
import java.util.List;
10
import javax.swing.Action;
11
import javax.swing.JComponent;
12
import javax.swing.JOptionPane;
13
import org.gvsig.tools.dataTypes.CoercionException;
14
import org.gvsig.tools.dataTypes.DataType;
15
import org.gvsig.tools.dispose.DisposableIterator;
16
import org.gvsig.tools.dynform.DynFormDefinition;
17
import org.gvsig.tools.dynform.JDynForm;
18
import org.gvsig.tools.dynform.JDynForm.DynFormContext;
19
import static org.gvsig.tools.dynform.JDynForm.USE_PLAIN;
20
import static org.gvsig.tools.dynform.JDynForm.USE_SEPARATORS;
21
import org.gvsig.tools.dynform.JDynFormSet;
22
import org.gvsig.tools.dynform.spi.DynFormSPIManager;
23
import static org.gvsig.tools.dynform.spi.dynform.AbstractJDynForm.getLayoutFromTags;
24
import org.gvsig.tools.dynform.spi.dynformfield.VisitableSet;
25
import org.gvsig.tools.dynobject.DynObject;
26
import org.gvsig.tools.dynobject.DynObjectSet;
27
import org.gvsig.tools.dynobject.Tags;
28
import org.gvsig.tools.exception.BaseException;
29
import org.gvsig.tools.service.ServiceException;
30
import org.gvsig.tools.visitor.VisitCanceledException;
31
import org.gvsig.tools.visitor.Visitor;
32
import org.slf4j.Logger;
33
import org.slf4j.LoggerFactory;
34

  
35
public abstract class AbstractJDynFormSet implements JDynFormSet {
36

  
37
    protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractJDynFormSet.class);
38

  
39
    private final DynFormSPIManager manager;
40
    private final JDynFormSetFactory factory;
41
    private final DynFormDefinition definition;
42

  
43
    protected JComponent contents = null;
44

  
45
    protected List<DynObject> values = null;
46
    protected VisitableSet listeners = null;
47
    protected boolean readOnly = false;
48

  
49
    protected boolean autosave = true;
50

  
51
    protected int layoutMode = USE_PLAIN;
52

  
53
    protected int formWidth = -1;
54
    protected int formHeight = -1;
55

  
56
    protected List<ActionStore> actionsBuffer = new ArrayList<>();
57

  
58
    private boolean useScrollBars = true;
59
    private boolean _allowUpdate;
60
    private boolean _allowDelete;
61
    private boolean _allowNew;
62
    private boolean _allowSearch;
63
    private boolean _allowClose;
64
    
65
    private boolean _isInNewState = false;
66
    private final JDynForm.DynFormContext context;
67
    private final Tags contextTags;
68

  
69
    public AbstractJDynFormSet(
70
            DynFormSPIManager manager, 
71
            JDynFormSetFactory factory,
72
            JDynForm.DynFormContext context,
73
            DynFormDefinition definition,
74
            Tags contextTags
75
        ) {
76
        this.manager = manager;
77
        this.factory = factory;
78
        this.context = context;
79
        this.definition = definition;
80
        this.contextTags = contextTags;
81
        this.listeners = new DefaultVisitableSet();
82
    }
83
    
84
    @Override
85
    public JDynForm getForm() {
86
        return null;
87
    }
88

  
89
    @Override
90
    public void fireEvent(String action, Object value) {
91
    }
92
     
93
    protected JDynFormSetFactory getFactory() {
94
        return this.factory;
95
    }
96
    
97
    protected DynFormDefinition getDefinition() {
98
        return this.definition;
99
    }
100

  
101
    protected DynFormContext getContext() {
102
        return this.context;
103
    }
104

  
105
    public DynFormSPIManager getManager() {
106
        return this.manager;
107
    }
108
    
109
    public void loadDefaultValueFromTags(Tags tags) {
110
        this.setLayoutMode(getLayoutFromTags(tags));
111
        
112
        this.formWidth = tags.getInt(DynFormSPIManager.TAG_DYNFORM_WIDTH, this.formWidth);
113
        this.formHeight = tags.getInt(DynFormSPIManager.TAG_DYNFORM_HEIGHT, this.formHeight);
114
        this.readOnly = tags.getBoolean(DynFormSPIManager.TAG_DYNFORM_READONLY, this.readOnly);
115
        this.autosave = tags.getBoolean(DynFormSPIManager.TAG_DYNFORM_AUTOSAVE, this.autosave);
116
        this.useScrollBars = tags.getBoolean(DynFormSPIManager.TAG_DYNFORM_USESCROLLBARS, this.useScrollBars);
117
        this.setAllowNew( tags.getBoolean(DynFormSPIManager.TAG_DYNFORM_ACTION_NEW, this._allowNew));
118
        this.setAllowUpdate(tags.getBoolean(DynFormSPIManager.TAG_DYNFORM_ACTION_UPDATE, this._allowNew));
119
        this.setAllowDelete(tags.getBoolean(DynFormSPIManager.TAG_DYNFORM_ACTION_DELETE, this._allowNew));
120
        this.setAllowSearch(tags.getBoolean(DynFormSPIManager.TAG_DYNFORM_ACTION_SEARCH, this._allowNew));
121
        this.setAllowClose(tags.getBoolean(DynFormSPIManager.TAG_DYNFORM_ACTION_CLOSE, this._allowNew));
122
    }
123

  
124
    public boolean isInNewState() {
125
        return this._isInNewState;
126
    }
127
    
128
    protected void enterStateNew() {
129
        this._isInNewState = true;
130
    }
131
    
132
    protected void leaveTheNewState() {
133
        this._isInNewState = false;
134
    }
135
    
136
    public void addListener(JDynFormSetListener listener) {
137
        this.listeners.add(listener);
138
    }
139

  
140
    public void removeListener(JDynFormSetListener listener) {
141
        this.listeners.remove(listener);
142
    }
143

  
144
    protected void fireMessageEvent(final String message) {
145
        try {
146
            this.listeners.accept(new Visitor() {
147
                public void visit(Object listener) throws VisitCanceledException, BaseException {
148
                    ((JDynFormSetListener) listener).formMessage(message);
149
                }
150
            });
151

  
152
        } catch (Exception e) {
153
            LOGGER.info("Error calling to the form message event.", e);
154
        }
155
    }
156

  
157
    protected void fireCloseEvent() {
158
        try {
159
            this.listeners.accept(new Visitor() {
160
                public void visit(Object listener) throws VisitCanceledException, BaseException {
161
                    ((JDynFormSetListener) listener).formClose();
162
                }
163
            });
164
        } catch (Exception e) {
165
            LOGGER.info("Error calling to the form close event.", e);
166
        }
167
    }
168

  
169
    protected void fireFormMovedToEvent(final int position) {
170
        try {
171
            this.listeners.accept(new Visitor() {
172
                public void visit(Object listener) throws VisitCanceledException, BaseException {
173
                    ((JDynFormSetListener) listener).formMovedTo(position);
174
                }
175
            });
176
        } catch (Exception e) {
177
            LOGGER.info("Error calling to the form moved to event.", e);
178
        }
179
    }
180

  
181
    public int getLayoutMode() {
182
        return this.layoutMode;
183
    }
184

  
185
    public void setLayoutMode(int layoutMode) {
186
        if ( layoutMode < 0 || layoutMode > USE_SEPARATORS ) {
187
            throw new IllegalArgumentException("layoutMode (" + layoutMode + ") out of range. Valid values are 0 .. " + USE_SEPARATORS + ".");
188
        }
189
        this.layoutMode = layoutMode;
190
    }
191

  
192
    public boolean isReadOnly() {
193
        return readOnly;
194
    }
195

  
196
    public void setReadOnly(boolean readOnly) {
197
        this.readOnly = readOnly;
198
    }
199

  
200
    public boolean isAutosave() {
201
        return this.autosave;
202
    }
203

  
204
    public void setAutosave(boolean autosave) {
205
        this.autosave = autosave;
206
    }
207

  
208
    protected int confirmDialog(final String message, final String title, final int optionType,
209
            final int messageType) {
210
        return JOptionPane.showConfirmDialog(
211
                this.contents, message, title, optionType, messageType);
212
    }
213

  
214
    public void setFormSize(int width, int height) {
215
        this.formHeight = height;
216
        this.formWidth = width;
217
    }
218

  
219
    public int countValues() {
220
        return this.values.size();
221
    }
222

  
223
    public void setValues(DynObjectSet values) {
224
        List x = new ArrayList();
225
        DisposableIterator it;
226
        try {
227
            it = values.iterator();
228
        } catch (BaseException e) {
229
            LOGGER.info("Uf! o se que hacer con este error, lo relanzo sin mas.", e);
230
            throw new RuntimeException(e);
231
        }
232
        while ( it.hasNext() ) {
233
            DynObject obj = (DynObject) it.next();
234
            if ( obj instanceof org.gvsig.tools.lang.Cloneable ) {
235
                try {
236
                    obj = (DynObject) ((org.gvsig.tools.lang.Cloneable) obj).clone();
237
                } catch (CloneNotSupportedException e) {
238
                    // Do nothing
239
                }
240
            }
241
            x.add(obj);
242
        }
243
        this.values = x;
244
    }
245

  
246
    public void setValues(List values) {
247
//        this.values = new ArrayList<DynObject>();
248
//        this.values.addAll(values);
249
        this.values = values;
250
    }
251

  
252
    public DynObject get(int position) {
253
        return (DynObject) this.values.get(position);
254
    }
255

  
256
    public void addActionToPopupMenu(DataType tipo, String name, Action action) {
257
        try {
258
            this.actionsBuffer.add(new ActionStore(tipo, name, action));
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff