Revision 8

View differences:

org.gvsig.attributeeditor/trunk/org.gvsig.attributeeditor/org.gvsig.attributeeditor.app/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
	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
	<parent>
5
		<groupId>org.gvsig</groupId>
6
		<artifactId>org.gvsig.attributeeditor</artifactId>
7
		<version>1.0.0-SNAPSHOT</version>
8
	</parent>
9
	<groupId>org.gvsig</groupId>
10
	<artifactId>org.gvsig.attributeeditor.app</artifactId>
11
	<version>1.0.0-SNAPSHOT</version>
12
	<packaging>pom</packaging>
13
	<name>org.gvsig.attributeeditor.app</name>
14
	<modules>
15
		<module>org.gvsig.attributeeditor.app.mainplugin</module>
16
	</modules>
17

  
18
</project>
org.gvsig.attributeeditor/trunk/org.gvsig.attributeeditor/org.gvsig.attributeeditor.app/org.gvsig.attributeeditor.app.mainplugin/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
  <parent>
4
    <groupId>org.gvsig</groupId>
5
    <artifactId>org.gvsig.attributeeditor.app</artifactId>
6
    <version>1.0.0-SNAPSHOT</version>
7
  </parent>
8
  <artifactId>org.gvsig.attributeeditor.app.mainplugin</artifactId>
9
  <name>org.gvsig.attributeeditor.app.mainplugin</name>
10
  <dependencies>
11
    <dependency>
12
        <groupId>org.gvsig</groupId>
13
        <artifactId>org.gvsig.app.mainplugin</artifactId>
14
        <scope>compile</scope>
15
    </dependency>
16
    <dependency>
17
    	<groupId>org.gvsig</groupId>
18
    	<artifactId>org.gvsig.featureform.swing.api</artifactId>
19
    </dependency>
20
    <dependency>
21
    	<groupId>org.gvsig</groupId>
22
    	<artifactId>org.gvsig.featureform.swing.impl</artifactId>
23
    </dependency>
24
    <dependency>
25
    	<groupId>org.gvsig</groupId>
26
    	<artifactId>org.gvsig.attributeeditor.mapcontrol</artifactId>
27
    </dependency>
28
  </dependencies>
29
</project>
org.gvsig.attributeeditor/trunk/org.gvsig.attributeeditor/org.gvsig.attributeeditor.app/org.gvsig.attributeeditor.app.mainplugin/buildNumber.properties
1
#Sun Oct 26 19:32:01 EDT 2014
2
buildNumber=1
org.gvsig.attributeeditor/trunk/org.gvsig.attributeeditor/org.gvsig.attributeeditor.app/org.gvsig.attributeeditor.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<!--
2

  
3
    gvSIG. Desktop Geographic Information System.
4

  
5
    Copyright (C) 2007-2014 gvSIG Association.
6

  
7
    This program is free software; you can redistribute it and/or
8
    modify it under the terms of the GNU General Public License
9
    as published by the Free Software Foundation; either version 3
10
    of the License, or (at your option) any later version.
11

  
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16

  
17
    You should have received a copy of the GNU General Public License
18
    along with this program; if not, write to the Free Software
19
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
    MA  02110-1301, USA.
21

  
22
    For any additional information, do not hesitate to contact us
23
    at info AT gvsig.com, or visit our website www.gvsig.com.
24

  
25
-->
26
<assembly>
27
  <id>gvsig-plugin-package</id>
28
  <formats>
29
    <format>zip</format>
30
  </formats>
31
  <baseDirectory>${project.artifactId}</baseDirectory>
32
  <includeBaseDirectory>true</includeBaseDirectory>
33
  <files>
34
    <file>
35
      <source>target/${project.artifactId}-${project.version}.jar</source>
36
      <outputDirectory>lib</outputDirectory>
37
    </file>
38
    <file>
39
      <source>target/package.info</source>
40
    </file>
41
  </files>
42

  
43
  <fileSets>
44
    <fileSet>
45
      <directory>src/main/resources-plugin</directory>
46
      <outputDirectory>.</outputDirectory>
47
    </fileSet>
48
  </fileSets>
49

  
50
  <dependencySets>
51
    <dependencySet>
52
      <useProjectArtifact>false</useProjectArtifact>
53
      <useTransitiveDependencies>false</useTransitiveDependencies>
54
      <outputDirectory>lib</outputDirectory>
55
      <includes>
56
        <include>org.gvsig:org.gvsig.featureform.swing.api</include>
57
        <include>org.gvsig:org.gvsig.featureform.swing.impl</include>
58
        <include>org.gvsig:org.gvsig.attributeeditor.mapcontrol</include>
59
      </includes>
60
    </dependencySet>
61
  </dependencySets>
62

  
63
</assembly>
64

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

  
25
import org.slf4j.Logger;
26
import org.slf4j.LoggerFactory;
27

  
28
import org.gvsig.andami.IconThemeHelper;
29
import org.gvsig.andami.plugins.Extension;
30
import org.gvsig.app.ApplicationLocator;
31
import org.gvsig.app.project.documents.view.ViewDocument;
32
import org.gvsig.app.project.documents.view.ViewManager;
33
import org.gvsig.app.project.documents.view.gui.IView;
34
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener;
35
import org.gvsig.fmap.mapcontext.layers.FLayer;
36
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
37
import org.gvsig.fmap.mapcontrol.MapControl;
38
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior;
39
import org.gvsig.fmap.mapcontrol.tools.Listeners.AttributeEditorBehavior;
40
import org.gvsig.fmap.mapcontrol.tools.Listeners.AttributeEditorPointListener;
41

  
42
/**
43
 * @author fdiaz
44
 *
45
 */
46
public class AttributeEditorExtension extends Extension {
47
    private static Logger logger = LoggerFactory.getLogger(
48
        AttributeEditorExtension.class);
49

  
50

  
51
    public void execute(String actionCommand) {
52

  
53
        if (actionCommand.compareToIgnoreCase("attribute-editor") != 0) {
54
            return;
55
        }
56

  
57
        IView vw = (IView) ApplicationLocator.getManager().getActiveComponent(ViewDocument.class);
58

  
59
        if (vw != null) {
60

  
61
            FLayer[] act_lyr = vw.getMapControl().getMapContext().getLayers().getActives();
62
            if (act_lyr == null || act_lyr.length != 1
63
                    || !(act_lyr[0] instanceof FLyrVect)) {
64
                //do nothing
65

  
66
            } else {
67

  
68
                FLyrVect lyr = (FLyrVect)act_lyr[0];
69
                MapControl mapControl = vw.getMapControl();
70
                if (!mapControl.hasTool(AttributeEditorPointListener.ATTRIBUTE_EDITOR_TOOL_NAME)){
71
                    StatusBarListener sbl = new StatusBarListener(mapControl);
72

  
73
                    AttributeEditorBehavior attributeEditorBehavior = new AttributeEditorBehavior(mapControl);
74
                    attributeEditorBehavior.addMapBehavior(new MouseMovementBehavior(sbl), false);
75
                    mapControl.addBehavior(AttributeEditorPointListener.ATTRIBUTE_EDITOR_TOOL_NAME, attributeEditorBehavior);
76
                }
77

  
78
                mapControl.setTool(AttributeEditorPointListener.ATTRIBUTE_EDITOR_TOOL_NAME);
79

  
80
            }
81
        }
82

  
83
    }
84

  
85
    public void initialize() {
86

  
87
        IconThemeHelper.registerIcon("action", "attribute-editor", this);
88
    }
89

  
90
    public boolean isEnabled() {
91

  
92
        /*
93
         * It's enabled if there is exactly one vector layer in the active view
94
         * and it has a selection
95
         */
96

  
97
        ViewDocument vw = actWin();
98

  
99
        if (vw != null) {
100

  
101
//            IView vw = (IView) actw;
102
            FLayer[] act_lyr = vw.getMapContext().getLayers().getActives();
103
            if (act_lyr == null || act_lyr.length != 1
104
                    || !(act_lyr[0] instanceof FLyrVect)) {
105
                return false;
106

  
107
            } else {
108
                FLyrVect vect = (FLyrVect) act_lyr[0];
109
                if (!vect.isAvailable()) {
110
                    /*
111
                     * This can happen when opening a persisted project
112
                     * and there is a "slow" layer (GeoDB)
113
                     */
114
                    return false;
115
                }
116
//                MapControl mapControl = vw.getMapControl();
117
//                if(mapControl.getCurrentTool().equalsIgnoreCase(AttributeEditorPointListener.ATTRIBUTE_EDITOR_TOOL_NAME)){
118
//                    return false;
119
//                }
120
                return true;
121
            }
122

  
123
        } else {
124
            return false;
125
        }
126
    }
127

  
128
    public boolean isVisible() {
129

  
130
        return actWin() != null;
131
    }
132

  
133

  
134
    /**
135
     * Gets active window
136
     * @return
137
     */
138
    private ViewDocument actWin() {
139
        return (ViewDocument) ApplicationLocator.getManager().getActiveDocument(ViewManager.TYPENAME);
140
    }
141
}
org.gvsig.attributeeditor/trunk/org.gvsig.attributeeditor/org.gvsig.attributeeditor.app/org.gvsig.attributeeditor.app.mainplugin/src/main/resources-plugin/i18n/text.properties
1
# Resource bundle texts for the Spanish language locale (es)
2
attribute_editor=Editor de atributos
3
error_saving_data_will_not_save=Se ha producido un error intentando guardar los datos. Los datos no se guardar\u00e1n.
4
cant_edit_the store_XstorenameX=No se ha podido poner en edici\u00f3n el store '%(storename)'
5
cant_get_the_associated_feature_to_index_XindexX=No se ha podido obtener la feature asociada al index '%(index)'
6
cant_update_the_feature_XindexX_in_the_store_XstorenameX=No se ha podido actualizar la feature '%(index)' en el store '%(storename)'
7
cant_finish_the_edition_of_the_store_XstorenameX=No se ha podido finalizar la edici\u00f3n del store '%(storename)'
8
There_is_no_one_and_only_one_active_layer.=No hay una y solo una capa activa.
9
Cant_show_attribute_information_for_layer_%1_on_point=No se ha podido mostrar la informaci\u00f3n de los atributos de la capa %1 sobre este punto.
org.gvsig.attributeeditor/trunk/org.gvsig.attributeeditor/org.gvsig.attributeeditor.app/org.gvsig.attributeeditor.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties
1
# Resource bundle texts for the English language locale (en)
2
attribute_editor=Attribute editor
3
error_saving_data_will_not_save=There was an error trying to save the data. The data will not be saved.
4
cant_edit_the store_XstorenameX=Can't edit the store '%(storename)'
5
cant_get_the_associated_feature_to_index_XindexX=Can't get the associated feature to index '%(index)'
6
cant_update_the_feature_XindexX_in_the_store_XstorenameX=Can't update the feature '%(index)' in the store '%(storename)'
7
cant_finish_the_edition_of_the_store_XstorenameX=Can't finish the edition of the store '%(storename)'
8
There_is_no_one_and_only_one_active_layer=There is no one and only one active layer
9
Cant_show_attribute_information_for_layer_%1_on_point=Can't show the attribute information for layer %1 on this point.
org.gvsig.attributeeditor/trunk/org.gvsig.attributeeditor/org.gvsig.attributeeditor.app/org.gvsig.attributeeditor.app.mainplugin/src/main/resources-plugin/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2014
3
	gvSIG Association. This program is free software; you can redistribute it
4
	and/or modify it under the terms of the GNU General Public License as published
5
	by the Free Software Foundation; either version 3 of the License, or (at
6
	your option) any later version. This program is distributed in the hope that
7
	it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
8
	of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
9
	Public License for more details. You should have received a copy of the GNU
10
	General Public License along with this program; if not, write to the Free
11
	Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
12
	USA. For any additional information, do not hesitate to contact us at info
13
	AT gvsig.com, or visit our website www.gvsig.com. -->
14
<plugin-config>
15
	<depends plugin-name="org.gvsig.app.mainplugin" />
16
	<resourceBundle name="text" />
17
	<libraries library-dir="lib"/>
18
	<extensions>
19
		<extension
20
			class-name="org.gvsig.app.mainplugin.extension.AttributeEditorExtension"
21
			description="" active="true" priority="1">
22

  
23
			<action name="attribute-editor" label="attribute_editor"
24
				tooltip="attribute_editor" position="300300000" action-command="attribute-editor"
25
				icon="attribute-editor" accelerator="" />
26

  
27
			<menu name="attribute-editor" text="Layer/attribute-editor" position="600550100" action-command="attribute-editor"/>
28

  
29
			<tool-bar name="attribute-editor">
30
				<selectable-tool name="attribute-editor" />
31
			</tool-bar>
32

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

  
25
import java.awt.Dimension;
26

  
27
import javax.swing.JComponent;
28

  
29
import org.slf4j.Logger;
30
import org.slf4j.LoggerFactory;
31

  
32
import org.gvsig.featureform.swing.JFeatureForm;
33
import org.gvsig.fmap.dal.DALLocator;
34
import org.gvsig.fmap.dal.exception.DataException;
35
import org.gvsig.fmap.dal.feature.EditableFeature;
36
import org.gvsig.fmap.dal.feature.Feature;
37
import org.gvsig.fmap.dal.feature.FeatureQuery;
38
import org.gvsig.fmap.dal.feature.FeatureStore;
39
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper;
40
import org.gvsig.tools.ToolsLocator;
41
import org.gvsig.tools.dynform.AbortActionException;
42
import org.gvsig.tools.dynform.DynFormLocator;
43
import org.gvsig.tools.dynform.DynFormManager;
44
import org.gvsig.tools.dynform.JDynForm;
45
import org.gvsig.tools.dynform.JDynFormSet;
46
import org.gvsig.tools.dynform.JDynFormSet.JDynFormSetListener;
47
import org.gvsig.tools.dynobject.DynObject;
48
import org.gvsig.tools.exception.BaseException;
49
import org.gvsig.tools.i18n.I18nManager;
50
import org.gvsig.tools.locator.LocatorException;
51
import org.gvsig.tools.service.ServiceException;
52
import org.gvsig.tools.swing.api.ToolsSwingLocator;
53
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
54
import org.gvsig.tools.swing.api.windowmanager.WindowManager.MODE;
55

  
56
/**
57
 * @author fdiaz
58
 *
59
 */
60
public class DefaultJFeatureForm implements JFeatureForm, JDynFormSetListener {
61

  
62
    private static final Logger LOGGER = LoggerFactory
63
        .getLogger(DefaultJFeatureForm.class);
64

  
65
    private static final int PAGE_SIZE = 500;
66
    private JDynFormSet formset;
67
    private FeatureStore store;
68
    private FeaturePagingHelper ph;
69

  
70
    /**
71
     *
72
     */
73
    public DefaultJFeatureForm() {
74
        // TODO Auto-generated constructor stub
75
    }
76

  
77
    /*
78
     * (non-Javadoc)
79
     *
80
     * @see
81
     * org.gvsig.attributeeditor.swing.JFeatureForm#setPreferredSize(java.awt
82
     * .Dimension)
83
     */
84
    public void setPreferredSize(Dimension dimension) {
85
        if (formset != null) {
86
            formset.setFormSize(dimension.width, dimension.height);
87
        }
88
    }
89

  
90
    public JComponent asJComponent() {
91
        return formset.asJComponent();
92
    }
93

  
94
    /*
95
     * (non-Javadoc)
96
     *
97
     * @see
98
     * org.gvsig.attributeeditor.swing.JFeatureForm#bind(org.gvsig.fmap.dal.
99
     * feature.FeatureStore)
100
     */
101
    public void bind(FeatureStore store) throws ServiceException, DataException {
102
        if (this.store == store) {
103
            return;
104
        }
105
        this.store = store;
106
        DynFormManager formManager = DynFormLocator.getDynFormManager();
107
        formset = formManager.createJDynFormSet(store.getDefaultFeatureType());
108

  
109
        formset.setLayoutMode(JDynForm.USE_SEPARATORS);
110
        formset.setReadOnly(false);
111
        formset.setAllowClose(true);
112
        formset.setAllowDelete(false);
113
        formset.setAllowNew(false);
114
        formset.setAllowSearch(false);
115
        formset.setAllowUpdate(true);
116
        formset.setAutosave(true);
117

  
118
        formset.addListener(this);
119
        this.ph = null;
120

  
121
    }
122

  
123
    /*
124
     * (non-Javadoc)
125
     *
126
     * @see
127
     * org.gvsig.attributeeditor.swing.JFeatureForm#setQuery(org.gvsig.fmap.
128
     * dal.feature.FeatureQuery)
129
     */
130
    public void setQuery(FeatureQuery query) throws LocatorException,
131
        BaseException {
132
        if (this.ph != null) {
133
            if (this.formset != null && this.formset.isAutosave()
134
                && this.formset.countValues() > 0
135
                && this.formset.asJComponent().isVisible()) {
136
                if (!store.isEditing()) {
137
                    try {
138
                        store.edit();
139
                    } catch (DataException e1) {
140
                        throw new StoreEditException(e1, store.getName());
141
                    }
142
                }
143
                saveChanges(this.formset);
144
            }
145
        }
146
        this.ph =
147
            DALLocator.getDataManager().createFeaturePagingHelper(store, query,
148
                PAGE_SIZE);
149
        this.formset.setReadOnly(false);
150
        this.formset.setValues(ph.asListOfDynObjects());
151
    }
152

  
153
    /*
154
     * (non-Javadoc)
155
     *
156
     * @see org.gvsig.attributeeditor.swing.JFeatureForm#hideForm()
157
     */
158
    public void hideForm() {
159
        formset.asJComponent().setVisible(false);
160

  
161
    }
162

  
163
    /*
164
     * (non-Javadoc)
165
     *
166
     * @see org.gvsig.attributeeditor.swing.JFeatureForm#showForm()
167
     */
168
    public void showForm(MODE mode) {
169
        WindowManager winmgr = ToolsSwingLocator.getWindowManager();
170
        winmgr.showWindow(formset.asJComponent(), store.getName(), mode);
171
        formset.asJComponent().setVisible(true);
172
    }
173

  
174
    public void formMessage(String message) {
175
        // TODO Auto-generated method stub
176

  
177
    }
178

  
179
    public void formClose() {
180
        this.hideForm();
181
    }
182

  
183
    public void formMovedTo(int currentPosition) throws AbortActionException {
184
        LOGGER.info("formMovedTo " + currentPosition);
185
    }
186

  
187
    class StoreEditException extends AbortActionException {
188

  
189
        /**
190
         *
191
         */
192
        private static final long serialVersionUID = -7682017811778577130L;
193

  
194
        public StoreEditException(Throwable cause, String storename) {
195
            super("Can't edit the store '%(storename)'", cause,
196
                "cant_edit_the store_XstorenameX", serialVersionUID);
197
            setValue("storename", storename);
198
        }
199
    }
200

  
201
    public void formBeforeSave(JDynFormSet dynformSet)
202
        throws AbortActionException {
203
        LOGGER.info("formBeforeSave");
204
        if (!store.isEditing()) {
205
            try {
206
                store.edit();
207
            } catch (DataException e1) {
208
                throw new StoreEditException(e1, store.getName());
209
            }
210
        }
211
    }
212

  
213
    public void formBeforeNew(JDynFormSet dynformSet)
214
        throws AbortActionException {
215
        LOGGER.info("formBeforeNew");
216
    }
217

  
218
    public void formBeforeDelete(JDynFormSet dynformSet)
219
        throws AbortActionException {
220
        LOGGER.info("formBeforeDelete");
221
    }
222

  
223
    class GetFeatureException extends AbortActionException {
224

  
225
        /**
226
         *
227
         */
228
        private static final long serialVersionUID = -3545660152672760731L;
229

  
230
        public GetFeatureException(Throwable cause, int index) {
231
            super("Can't get the associated feature to index '%(index)'",
232
                cause, "cant_get_the_associated_feature_to_index_XindexX",
233
                serialVersionUID);
234
            setValue("index", index);
235
        }
236
    }
237

  
238
    class UpdateFeatureException extends AbortActionException {
239

  
240
        /**
241
         *
242
         */
243
        private static final long serialVersionUID = 6473287361543242618L;
244

  
245
        public UpdateFeatureException(Throwable cause, int index,
246
            String storename) {
247
            super(
248
                "Can't update the feature '%(index)' in the store '%(storename)'",
249
                cause,
250
                "cant_update_the_feature_XindexX_in_the_store_XstorenameX",
251
                serialVersionUID);
252
            setValue("storename", storename);
253
            setValue("index", index);
254
        }
255
    }
256

  
257
    public void formAfterSave(JDynFormSet dynformSet)
258
        throws AbortActionException {
259

  
260
        LOGGER.info("formAfterSave");
261
        saveChanges(dynformSet);
262
    }
263

  
264
    private void saveChanges(JDynFormSet dynformSet)
265
        throws AbortActionException {
266
        int index = dynformSet.getCurrentIndex();
267
        DynObject dynObject = dynformSet.get(index);
268
        dynformSet.getFormValues(dynObject);
269
        Feature feat = store.getFeature(dynObject);
270
        if (feat == null) {
271
            LOGGER.warn("Can't get the associated feature index " + index);
272
            I18nManager i18nManager = ToolsLocator.getI18nManager();
273
            dynformSet.message(i18nManager
274
                .getTranslation("error_saving_data_will_not_save"));
275
            throw new GetFeatureException(null, index);
276
        }
277

  
278
        try {
279
            ph.update((EditableFeature) feat);
280
        } catch (BaseException e) {
281
            throw new UpdateFeatureException(null, index, store.getName());
282
        }
283
    }
284

  
285
    public void saveChanges() throws BaseException {
286
        if (this.formset != null && this.formset.countValues() > 0
287
            && this.formset.asJComponent().isVisible()) {
288
            this.saveChanges(this.formset);
289
        }
290
    }
291

  
292
    class FinishEditingException extends AbortActionException {
293

  
294
        /**
295
         *
296
         */
297
        private static final long serialVersionUID = -2281299673602420199L;
298

  
299
        public FinishEditingException(Throwable cause, String storename) {
300
            super("Can't finish the edition of the store '%(storename)'",
301
                cause, "cant_finish_the_edition_of_the_store_XstorenameX",
302
                serialVersionUID);
303
            setValue("storename", storename);
304
        }
305
    }
306

  
307
    public void formAfterNew(JDynFormSet dynformSet)
308
        throws AbortActionException {
309
        LOGGER.info("formAfterNew");
310
    }
311

  
312
    public void formAfterDelete(JDynFormSet dynformSet)
313
        throws AbortActionException {
314
        LOGGER.info("formAfterDelete");
315
    }
316

  
317
    public void formBeforeSearch(JDynFormSet dynformSet)
318
        throws AbortActionException {
319
        LOGGER.info("formBeforeSearch");
320
    }
321

  
322
    public void formAfterSearch(JDynFormSet dynformSet)
323
        throws AbortActionException {
324
        LOGGER.info("formAfterSearch");
325
    }
326

  
327
    public long getDataSetSize() {
328
        if (this.ph != null) {
329
            return ph.getTotalSize();
330
        }
331
        return 0;
332
    }
333
}
org.gvsig.attributeeditor/trunk/org.gvsig.attributeeditor/org.gvsig.featureform.swing/org.gvsig.featureform.swing.impl/src/main/java/org/gvsig/featureform/swing/impl/FeatureFormSwingImplLibrary.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2014 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.featureform.swing.impl;
24

  
25
import org.gvsig.featureform.swing.FeatureFormSwingLibrary;
26
import org.gvsig.featureform.swing.FeatureFormSwingLocator;
27
import org.gvsig.tools.library.AbstractLibrary;
28
import org.gvsig.tools.library.LibraryException;
29

  
30

  
31
/**
32
 * @author fdiaz
33
 *
34
 */
35
public class FeatureFormSwingImplLibrary extends AbstractLibrary {
36

  
37
    /**
38
     *
39
     */
40
    public FeatureFormSwingImplLibrary() {
41
        // TODO Auto-generated constructor stub
42
    }
43

  
44
    @Override
45
    public void doRegistration() {
46
        super.doRegistration();
47
        registerAsImplementationOf(FeatureFormSwingLibrary.class);
48
    }
49

  
50

  
51
    /* (non-Javadoc)
52
     * @see org.gvsig.tools.library.AbstractLibrary#doInitialize()
53
     */
54
    @Override
55
    protected void doInitialize() throws LibraryException {
56
        FeatureFormSwingLocator.registerSwingManager(DefaultFeatureFormSwingManager.class);
57
    }
58

  
59
    /* (non-Javadoc)
60
     * @see org.gvsig.tools.library.AbstractLibrary#doPostInitialize()
61
     */
62
    @Override
63
    protected void doPostInitialize() throws LibraryException {
64
        // TODO Auto-generated method stub
65

  
66
    }
67

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

  
25
import org.gvsig.featureform.swing.CreateJFeatureFormException;
26
import org.gvsig.featureform.swing.FeatureFormSwingManager;
27
import org.gvsig.featureform.swing.JFeatureForm;
28
import org.gvsig.fmap.dal.exception.DataException;
29
import org.gvsig.fmap.dal.feature.FeatureQuery;
30
import org.gvsig.fmap.dal.feature.FeatureStore;
31
import org.gvsig.tools.exception.BaseException;
32
import org.gvsig.tools.service.ServiceException;
33

  
34

  
35
/**
36
 * @author fdiaz
37
 *
38
 */
39
public class DefaultFeatureFormSwingManager implements
40
FeatureFormSwingManager {
41

  
42
    public JFeatureForm createJFeatureForm(FeatureStore store) throws CreateJFeatureFormException {
43
        DefaultJFeatureForm form = new DefaultJFeatureForm();
44
        try {
45
            form.bind(store);
46
        } catch (ServiceException e) {
47
            throw new CreateJFeatureFormException(e);
48
        } catch (DataException e) {
49
            throw new CreateJFeatureFormException(e);
50
        }
51
        return form;
52
    }
53

  
54

  
55

  
56
}
org.gvsig.attributeeditor/trunk/org.gvsig.attributeeditor/org.gvsig.featureform.swing/org.gvsig.featureform.swing.impl/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
  <parent>
4
    <groupId>org.gvsig</groupId>
5
    <artifactId>org.gvsig.featureform.swing</artifactId>
6
    <version>1.0.0-SNAPSHOT</version>
7
  </parent>
8
  <artifactId>org.gvsig.featureform.swing.impl</artifactId>
9
  <name>org.gvsig.attributeeditor.swing.impl</name>
10
  <dependencies>
11
  	<dependency>
12
  		<groupId>org.gvsig</groupId>
13
  		<artifactId>org.gvsig.featureform.swing.api</artifactId>
14
  	</dependency>
15
  	<dependency>
16
  		<groupId>org.gvsig</groupId>
17
  		<artifactId>org.gvsig.tools.dynform.api</artifactId>
18
  	</dependency>
19

  
20
  </dependencies>
21
  <version>1.0.0-SNAPSHOT</version>
22
  <groupId>org.gvsig</groupId>
23
</project>
org.gvsig.attributeeditor/trunk/org.gvsig.attributeeditor/org.gvsig.featureform.swing/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
	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
	<parent>
5
		<groupId>org.gvsig</groupId>
6
		<artifactId>org.gvsig.attributeeditor</artifactId>
7
		<version>1.0.0-SNAPSHOT</version>
8
	</parent>
9
	<groupId>org.gvsig</groupId>
10
	<artifactId>org.gvsig.featureform.swing</artifactId>
11
	<version>1.0.0-SNAPSHOT</version>
12
	<name>org.gvsig.featureform.swing</name>
13
	<packaging>pom</packaging>
14

  
15
	<modules>
16
		<module>org.gvsig.featureform.swing.api</module>
17
		<module>org.gvsig.featureform.swing.impl</module>
18
	</modules>
19

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

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

  
27

  
28
/**
29
 * @author fdiaz
30
 *
31
 */
32
public class CreateJFeatureFormException extends BaseException {
33

  
34
    /**
35
     *
36
     */
37
    private static final long serialVersionUID = -447463757561352194L;
38
    private final static String MESSAGE_FORMAT = "Exception creating JFeatureForm.";
39
    private final static String MESSAGE_KEY = "create_JFeatureForm_Exception";
40

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

  
25
import org.gvsig.tools.library.AbstractLibrary;
26
import org.gvsig.tools.library.LibraryException;
27
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
28

  
29

  
30
/**
31
 * @author fdiaz
32
 *
33
 */
34
public class FeatureFormSwingLibrary  extends AbstractLibrary{
35

  
36

  
37
    @Override
38
    public void doRegistration() {
39
        registerAsAPI(FeatureFormSwingLibrary.class);
40
    }
41

  
42
    @Override
43
    protected void doInitialize() throws LibraryException {
44
        // TODO Auto-generated method stub
45

  
46
    }
47

  
48
    @Override
49
    protected void doPostInitialize() throws LibraryException {
50
        // Validate there is any implementation registered.
51
        FeatureFormSwingManager manager =
52
            FeatureFormSwingLocator.getSwingManager();
53
        if (manager == null) {
54
            throw new ReferenceNotRegisteredException(
55
                FeatureFormSwingLocator.SWING_MANAGER_NAME,
56
                FeatureFormSwingLocator.getInstance());
57
        }
58
    }
59

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

  
25
import org.gvsig.fmap.dal.feature.FeatureStore;
26

  
27
/**
28
 * @author fdiaz
29
 *
30
 */
31
public interface FeatureFormSwingManager {
32

  
33
    public JFeatureForm createJFeatureForm(FeatureStore store) throws CreateJFeatureFormException;
34

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

  
25
import java.awt.Dimension;
26

  
27
import javax.swing.JComponent;
28

  
29
import org.gvsig.fmap.dal.exception.DataException;
30
import org.gvsig.fmap.dal.feature.FeatureQuery;
31
import org.gvsig.fmap.dal.feature.FeatureStore;
32
import org.gvsig.tools.exception.BaseException;
33
import org.gvsig.tools.locator.LocatorException;
34
import org.gvsig.tools.service.ServiceException;
35
import org.gvsig.tools.swing.api.windowmanager.WindowManager.MODE;
36

  
37
/**
38
 * @author fdiaz
39
 *
40
 */
41
public interface JFeatureForm {
42

  
43
    public void setPreferredSize(Dimension dimension);
44

  
45
    public void bind(FeatureStore store) throws ServiceException, DataException;
46

  
47
    public void setQuery(FeatureQuery query) throws LocatorException, BaseException;
48

  
49
    public long getDataSetSize();
50

  
51
    public void showForm(MODE mode);
52

  
53
    public void hideForm();
54

  
55
    public JComponent asJComponent();
56

  
57
    public void saveChanges() throws BaseException;
58

  
59

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

  
25
import org.gvsig.tools.locator.BaseLocator;
26

  
27

  
28
/**
29
 * @author fdiaz
30
 *
31
 */
32
public class FeatureFormSwingLocator  extends BaseLocator{
33

  
34
    /**
35
     * AttributeEditor swing manager name.
36
     */
37
    public static final String SWING_MANAGER_NAME =
38
        "AttributeEditor.swing.manager";
39

  
40
    /**
41
     * AttributeEditor swing manager description.
42
     */
43
    public static final String SWING_MANAGER_DESCRIPTION =
44
        "AttributeEditor UIManager";
45

  
46
    private static final String LOCATOR_NAME = "AttributeEditor.swing.locator";
47

  
48
    /**
49
     * Unique instance.
50
     */
51
    private static final FeatureFormSwingLocator INSTANCE =
52
        new FeatureFormSwingLocator();
53

  
54
    /**
55
     * Return the singleton instance.
56
     *
57
     * @return the singleton instance
58
     */
59
    public static FeatureFormSwingLocator getInstance() {
60
        return INSTANCE;
61
    }
62

  
63
    /**
64
     * Return the Locator's name
65
     *
66
     * @return a String with the Locator's name
67
     */
68
    public final String getLocatorName() {
69
        return LOCATOR_NAME;
70
    }
71

  
72
    /**
73
     * Registers the Class implementing the PersistenceManager interface.
74
     *
75
     * @param clazz
76
     *            implementing the SwingManager interface
77
     */
78
    public static void registerSwingManager(
79
        Class<? extends FeatureFormSwingManager> clazz) {
80
        getInstance().register(SWING_MANAGER_NAME, SWING_MANAGER_DESCRIPTION,
81
            clazz);
82
    }
83

  
84
    /**
85
     * Gets the instance of the {@link FeatureFormSwingManager} registered.
86
     *
87
     * @return {@link FeatureFormSwingManager}
88
     */
89
    public static FeatureFormSwingManager getSwingManager() {
90
        return (FeatureFormSwingManager) getInstance()
91
            .get(SWING_MANAGER_NAME);
92
    }
93

  
94
}
org.gvsig.attributeeditor/trunk/org.gvsig.attributeeditor/org.gvsig.featureform.swing/org.gvsig.featureform.swing.api/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
	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
	<parent>
5
		<groupId>org.gvsig</groupId>
6
		<artifactId>org.gvsig.featureform.swing</artifactId>
7
		<version>1.0.0-SNAPSHOT</version>
8
	</parent>
9
	<artifactId>org.gvsig.featureform.swing.api</artifactId>
10
	<name>org.gvsig.attributeeditor.swing.api</name>
11
	<dependencies>
12
		<dependency>
13
			<groupId>org.gvsig</groupId>
14
			<artifactId>org.gvsig.tools.swing.api</artifactId>
15
		</dependency>
16
		<dependency>
17
			<groupId>org.gvsig</groupId>
18
			<artifactId>org.gvsig.fmap.dal.api</artifactId>
19
		</dependency>
20
		<dependency>
21
			<groupId>org.gvsig</groupId>
22
			<artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
23
		</dependency>
24

  
25
	</dependencies>
26
</project>
org.gvsig.attributeeditor/trunk/org.gvsig.attributeeditor/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
	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
	<parent>
5
		<groupId>org.gvsig</groupId>
6
		<artifactId>org.gvsig.desktop</artifactId>
7
		<version>2.0.68-SNAPSHOT</version>
8
	</parent>
9
	<groupId>org.gvsig</groupId>
10
	<artifactId>org.gvsig.attributeeditor</artifactId>
11
	<version>1.0.0-SNAPSHOT</version>
12
	<packaging>pom</packaging>
13
	<name>org.gvsig.attributeeditor</name>
14
	<description>This plugins allows to edit the alphanumeric attributes of a layer.</description>
15

  
16
	<repositories>
17
		<repository>
18
			<id>gvsig-public-http-repository</id>
19
			<name>gvSIG maven public HTTP repository</name>
20
			<url>http://devel.gvsig.org/m2repo/j2se</url>
21
			<releases>
22
				<enabled>true</enabled>
23
				<updatePolicy>daily</updatePolicy>
24
				<checksumPolicy>warn</checksumPolicy>
25
			</releases>
26
			<snapshots>
27
				<enabled>true</enabled>
28
				<updatePolicy>daily</updatePolicy>
29
				<checksumPolicy>warn</checksumPolicy>
30
			</snapshots>
31
		</repository>
32
	</repositories>
33

  
34
	<scm>
35
		<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-attributeeditor/org.gvsig.attributeeditor/trunk/org.gvsig.downloader</connection>
36
		<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-attributeeditor/org.gvsig.attributeeditor/trunk/org.gvsig.attributeeditor</developerConnection>
37
		<url>https://devel.gvsig.org/redmine/projects/gvsig-attributeeditor/repository/show/org.gvsig.attributeeditor/trunk/org.gvsig.attributeeditor</url>
38
	</scm>
39

  
40

  
41
	<dependencyManagement>
42
		<dependencies>
43
			<dependency>
44
				<groupId>org.gvsig</groupId>
45
				<artifactId>
46
    				org.gvsig.featureform.swing.api
47
    			</artifactId>
48
				<version>1.0.0-SNAPSHOT</version>
49
			</dependency>
50
			<dependency>
51
				<groupId>org.gvsig</groupId>
52
				<artifactId>
53
    				org.gvsig.featureform.swing.impl
54
    			</artifactId>
55
				<version>1.0.0-SNAPSHOT</version>
56
			</dependency>
57
			<dependency>
58
				<groupId>org.gvsig</groupId>
59
				<artifactId>
60
    				org.gvsig.attributeeditor.app.mainplugin
61
    			</artifactId>
62
				<version>1.0.0-SNAPSHOT</version>
63
			</dependency>
64
			<dependency>
65
				<groupId>org.gvsig</groupId>
66
				<artifactId>
67
    				org.gvsig.attributeeditor.mapcontrol
68
    			</artifactId>
69
				<version>1.0.0-SNAPSHOT</version>
70
			</dependency>
71
		</dependencies>
72
	</dependencyManagement>
73

  
74
	<modules>
75
		<module>org.gvsig.featureform.swing</module>
76
		<module>org.gvsig.attributeeditor.mapcontrol</module>
77
		<module>org.gvsig.attributeeditor.app</module>
78
	</modules>
79

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

  
25
import java.awt.Image;
26

  
27
import org.gvsig.fmap.mapcontrol.MapControl;
28
import org.gvsig.fmap.mapcontrol.tools.CompoundBehavior;
29
import org.gvsig.fmap.mapcontrol.tools.PanListenerImpl;
30
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
31
import org.gvsig.fmap.mapcontrol.tools.Behavior.MoveBehavior;
32
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior;
33

  
34

  
35
/**
36
 * @author fdiaz
37
 *
38
 */
39
public class AttributeEditorBehavior extends CompoundBehavior {
40

  
41
    AttributeEditorPointListener attributeEditorPointListener;
42

  
43
    /**
44
     * @param behaviors
45
     */
46
    public AttributeEditorBehavior(MapControl mapControl) {
47
        super(new Behavior[0]);
48
        PanListener pl = new PanListenerImpl(mapControl);
49
        this.attributeEditorPointListener =
50
            new AttributeEditorPointListener(mapControl);
51

  
52
        this.addMapBehavior(new MoveBehavior(pl), true);
53
        this.addMapBehavior(new PointBehavior(attributeEditorPointListener), false);
54

  
55
    }
56

  
57
    public Image getImageCursor() {
58
        return this.attributeEditorPointListener.getImageCursor();
59
    }
60

  
61
    public ToolListener getListener(){
62
        return this.attributeEditorPointListener;
63
    }
64

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

  
24
package org.gvsig.fmap.mapcontrol.tools.Listeners;
25

  
26
import java.awt.Dimension;
27
import java.awt.event.InputEvent;
28
import java.awt.event.MouseEvent;
29

  
30
import javax.swing.JOptionPane;
31

  
32
import org.cresques.cts.IProjection;
33
import org.slf4j.Logger;
34
import org.slf4j.LoggerFactory;
35

  
36
import org.gvsig.featureform.swing.CreateJFeatureFormException;
37
import org.gvsig.featureform.swing.FeatureFormSwingLocator;
38
import org.gvsig.featureform.swing.FeatureFormSwingManager;
39
import org.gvsig.featureform.swing.JFeatureForm;
40
import org.gvsig.fmap.dal.exception.DataException;
41
import org.gvsig.fmap.dal.feature.FeatureQuery;
42
import org.gvsig.fmap.dal.feature.FeatureStore;
43
import org.gvsig.fmap.dal.feature.FeatureType;
44
import org.gvsig.fmap.geom.Geometry;
45
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
46
import org.gvsig.fmap.geom.Geometry.TYPES;
47
import org.gvsig.fmap.geom.GeometryLocator;
48
import org.gvsig.fmap.geom.GeometryManager;
49
import org.gvsig.fmap.geom.exception.CreateGeometryException;
50
import org.gvsig.fmap.geom.primitive.Circle;
51
import org.gvsig.fmap.geom.primitive.Point;
52
import org.gvsig.fmap.mapcontext.ViewPort;
53
import org.gvsig.fmap.mapcontext.layers.FLayer;
54
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
55
import org.gvsig.fmap.mapcontext.layers.vectorial.IntersectsGeometryEvaluator;
56
import org.gvsig.fmap.mapcontrol.MapControl;
57
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
58
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent;
59
import org.gvsig.tools.ToolsLocator;
60
import org.gvsig.tools.exception.BaseException;
61
import org.gvsig.tools.i18n.I18nManager;
62
import org.gvsig.tools.locator.LocatorException;
63
import org.gvsig.tools.service.ServiceException;
64
import org.gvsig.tools.swing.api.ToolsSwingLocator;
65
import org.gvsig.tools.swing.api.windowmanager.WindowManager.MODE;
66

  
67
/**
68
 * @author fdiaz
69
 *
70
 */
71
public class AttributeEditorPointListener extends AbstractPointListener{
72

  
73
    private static Logger logger = LoggerFactory.getLogger(AttributeEditorPointListener.class);
74

  
75
    public static final String ATTRIBUTE_EDITOR_TOOL_NAME = "attributeEditorTool";
76
    private static final String ATTRIBUTE_EDITOR_FORM_NAME = "attributeEditorForm";
77
    private MapControl mapControl;
78
    private JFeatureForm form;
79
    private FLyrVect currentLayer = null;
80
    /**
81
     * Radius as tolerance around the selected point, the area will be used to
82
     * look for information.
83
     */
84
    private static int TOL = 7;
85

  
86
    public AttributeEditorPointListener(MapControl mapControl,
87
        JFeatureForm form) {
88
        super();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff