Revision 41980

View differences:

tags/org.gvsig.desktop-2.0.80/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/buildNumber.properties
1
#Sun Jan 25 18:06:09 CET 2015
2
buildNumber=109
0 3

  
tags/org.gvsig.desktop-2.0.80/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/test/resources/README.txt
1
Put into this folder the resources needed by your test classes.
2

  
3
This folder is added to the Tests classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your tests classes.
0 9

  
tags/org.gvsig.desktop-2.0.80/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
7

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

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

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

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

  
26
-->
27
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
28

  
29
<!-- 
30
Log4J configuration file for unit tests execution.
31
 -->
32
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
33

  
34
	<!-- Appender configuration to show logging messages through the console -->
35
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
36
		<layout class="org.apache.log4j.PatternLayout">
37
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
38
		</layout>
39
	</appender>
40

  
41
	<!-- 
42
	Activate logging messages of DEBUG level of higher only for the
43
	org.gvsig.tools packages.
44
	You can put full classes names or packages instead, to configure
45
	logging for all the classes and subpackages of the package.
46
	-->
47
	<category name="org.gvsig.tools">
48
		<priority value="DEBUG" />
49
	</category>
50
	<category name="org.gvsig.app.document.table">
51
		<priority value="DEBUG" />
52
	</category>
53

  
54
	<!-- 
55
	By default, show only logging messages of INFO level or higher, 
56
	through the previously configured CONSOLE appender. 
57
	-->
58
	<root>
59
		<priority value="INFO" />
60
		<appender-ref ref="CONSOLE" />
61
	</root>
62
</log4j:configuration>
0 63

  
tags/org.gvsig.desktop-2.0.80/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/swing/FilesystemExplorerTableWizardPanel.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

  
25
package org.gvsig.fmap.dal.serverexplorer.filesystem.swing;
26

  
27
import java.awt.Window;
28
import java.util.ArrayList;
29
import java.util.HashSet;
30
import java.util.List;
31
import java.util.Set;
32

  
33
import javax.swing.JOptionPane;
34

  
35
import org.cresques.cts.IProjection;
36
import org.slf4j.Logger;
37
import org.slf4j.LoggerFactory;
38

  
39
import org.gvsig.andami.PluginServices;
40
import org.gvsig.andami.messages.NotificationManager;
41
import org.gvsig.app.ApplicationLocator;
42
import org.gvsig.app.ApplicationManager;
43
import org.gvsig.app.prepareAction.PrepareContext;
44
import org.gvsig.app.project.Project;
45
import org.gvsig.app.project.ProjectManager;
46
import org.gvsig.app.project.documents.table.TableDocument;
47
import org.gvsig.app.project.documents.table.TableManager;
48
import org.gvsig.fmap.dal.DALLocator;
49
import org.gvsig.fmap.dal.DataManager;
50
import org.gvsig.fmap.dal.DataStoreParameters;
51
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
52
import org.gvsig.fmap.dal.feature.FeatureStore;
53
import org.gvsig.i18n.Messages;
54
import org.gvsig.tools.dynobject.exception.DynFieldRequiredValueException;
55
import org.gvsig.tools.dynobject.exception.DynObjectValidateException;
56

  
57
public class FilesystemExplorerTableWizardPanel extends
58
    FilesystemExplorerWizardPanel {
59

  
60
    private static final long serialVersionUID = 8469934188826417698L;
61
    private static final Logger LOG = LoggerFactory.getLogger(
62
        FilesystemExplorerTableWizardPanel.class);
63

  
64
    private PrepareContext prepareDSContext = null;
65

  
66
    @Override
67
    public void execute() {
68
        executeWizard();
69
    }
70

  
71
    public Object executeWizard() {
72
        FeatureStore store;
73
        TableDocument table;
74

  
75
        ApplicationManager manager = ApplicationLocator.getManager();
76
        Project project = manager.getCurrentProject();
77

  
78
        PrepareContext context = this.getPrepareDataStoreContext();
79
        DataStoreParameters[] parameters = this.getParameters();
80
        List<TableDocument> tabledocs =
81
            new ArrayList<TableDocument>(parameters.length);
82
        
83
        Set<String> not_valid = new HashSet<String>();
84
        
85
        for (DataStoreParameters params : parameters) {
86
            store = null;
87
            
88
            /*
89
             * Try to validate.
90
             */
91
            try {
92
                params.validate();
93
            } catch (ValidateDataParametersException ecx) {
94
                StringBuffer buffer = new StringBuffer();
95
                if( ecx.getCause() instanceof DynObjectValidateException ) {
96
                    DynObjectValidateException exceptions = (DynObjectValidateException) ecx.getCause();
97
                    for( int i=0; i<exceptions.size(); i++ ) {
98
                        if( exceptions.get(i) instanceof DynFieldRequiredValueException ) {
99
                            DynFieldRequiredValueException exx = (DynFieldRequiredValueException) exceptions.get(i);
100
                            if( buffer.length()>0 ) {
101
                                buffer.append(", ");
102
                            }
103
                            buffer.append(exx.getMessage());
104
                        }
105
                        
106
                    }
107
                }
108
                String msg = params.getDataStoreName();
109
                if( buffer.length()>0 ) {
110
                    msg = msg + ": "+buffer.toString();
111
                }
112
                LOG.info("Unable to validate params: " + msg);
113
                not_valid.add(msg);
114
                continue;
115
            }
116
            
117
            try {
118

  
119
                DataManager dataManager = DALLocator.getDataManager();
120
                store =
121
                    (FeatureStore) dataManager.openStore(
122
                        params.getDataStoreName(), params);
123
                manager.pepareOpenDataSource(store, context);
124

  
125
                table =
126
                    (TableDocument) ProjectManager.getInstance()
127
                        .createDocument(TableManager.TYPENAME);
128
                table.setName(store.getName());
129
                table.setStore(store);
130

  
131
                // project.add(table);
132
                tabledocs.add(table);
133
            } catch (Exception e) {
134
                if (store != null) {
135
                    store.dispose();
136
                }
137
                NotificationManager.addError(e);
138
            }
139

  
140
        }
141
        
142
        if (not_valid.size() > 0) {
143
            String not_str = not_valid.toString();
144
            JOptionPane.showMessageDialog(
145
                this,
146
                Messages.getText("_These_sources_were_not_loaded")
147
                + ": " + not_str, // not_valid,
148
                Messages.getText("_Load_error"),
149
                JOptionPane.WARNING_MESSAGE);
150
        }
151
        return tabledocs;
152
    }
153

  
154
    @Override
155
    protected PrepareContext getPrepareDataStoreContext() {
156
        if (this.prepareDSContext == null) {
157
            this.prepareDSContext = new PrepareContext() {
158

  
159
                public Window getOwnerWindow() {
160
                    return null;
161
                }
162
                
163
                public IProjection getViewProjection() {
164
                	return null;
165
                }
166

  
167
            };
168
        }
169
        return this.prepareDSContext;
170
    }
171

  
172
    public String getTabName() {
173
        return PluginServices.getText(this, "File");
174
    }
175

  
176
}
0 177

  
tags/org.gvsig.desktop-2.0.80/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/swing/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
7

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

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

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

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

  
26
-->
27
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
28
<html xmlns="http://www.w3.org/1999/xhtml">
29
<head>
30
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
31
<title>org.gvsig.landregistryviewer package documentation</title>
32
</head>
33
<body>
34

  
35
	<p>Open table document from file support</p>
36
	
37
</body>
38
</html>
0 39

  
tags/org.gvsig.desktop-2.0.80/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/FieldSelectionModel.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.app.project.documents.table;
25

  
26
import java.util.ArrayList;
27
import java.util.Iterator;
28
import java.util.List;
29

  
30
import org.gvsig.fmap.dal.exception.DataException;
31
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
32
import org.gvsig.fmap.dal.feature.FeatureStore;
33
import org.gvsig.tools.dataTypes.DataTypes;
34
import org.gvsig.utils.swing.objectSelection.ObjectSelectionModel;
35
import org.gvsig.utils.swing.objectSelection.SelectionException;
36

  
37
/**
38
 * @author Fernando Gonz?lez Cort?s
39
 */
40
public class FieldSelectionModel implements ObjectSelectionModel {
41

  
42
    // final static private Logger logger =
43
    // LoggerFactory.getLogger(FieldSelectionModel.class);
44

  
45
    private FeatureStore fs;
46
    private String msg;
47
    private int type = DataTypes.INVALID;
48
    private boolean selectAll = false;
49

  
50
    /**
51
     * Crea un nuevo FirstFieldSelectionModel.
52
     * 
53
     */
54
    public FieldSelectionModel(FeatureStore fs, String msg, int type) {
55
        this.fs = fs;
56
        this.msg = msg;
57
        this.type = type;
58
    }
59

  
60
    public FieldSelectionModel(FeatureStore fs, String msg) {
61
        this(fs, msg, DataTypes.UNKNOWN);
62
        selectAll = true;
63
    }
64

  
65
    @SuppressWarnings("unchecked")
66
    public Object[] getObjects() throws SelectionException {
67

  
68
        List<String> fields = new ArrayList<String>();
69
        Iterator<FeatureAttributeDescriptor> iterator = null;
70
        try {
71
            iterator = fs.getDefaultFeatureType().iterator();
72
        } catch (DataException e) {
73
            throw new SelectionException(
74
                "Can't create iterator for the atribute of feature type", e);
75
        }
76
        while (iterator.hasNext()) {
77
            FeatureAttributeDescriptor descriptor = iterator.next();
78
            if (type != DataTypes.INVALID) {
79
                if ((descriptor.getType() == type) || selectAll) {
80
                    fields.add(descriptor.getName());
81
                }
82
            } else {
83
                fields.add(descriptor.getName());
84
            }
85
        }
86

  
87
        return (String[]) fields.toArray(new String[fields.size()]);
88
    }
89

  
90
    /**
91
     * @see org.gvsig.utils.swing.objectSelection.ObjectSelectionModel#getMsg()
92
     */
93
    public String getMsg() {
94
        return msg;
95
    }
96
}
0 97

  
tags/org.gvsig.desktop-2.0.80/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/TableOperations.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.app.project.documents.table;
25

  
26
import java.awt.Component;
27
import java.awt.event.ActionEvent;
28
import java.awt.event.ActionListener;
29
import java.text.ParseException;
30
import java.util.ArrayList;
31
import java.util.Iterator;
32
import java.util.List;
33

  
34
import javax.swing.JOptionPane;
35
import javax.swing.event.TableModelListener;
36

  
37
import org.slf4j.Logger;
38
import org.slf4j.LoggerFactory;
39

  
40
import org.gvsig.andami.PluginServices;
41
import org.gvsig.andami.messages.NotificationManager;
42
import org.gvsig.app.ApplicationLocator;
43
import org.gvsig.app.project.documents.table.gui.CreateNewAttributePanel;
44
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
45
import org.gvsig.editing.EditingNotification;
46
import org.gvsig.editing.EditingNotificationManager;
47
import org.gvsig.fmap.dal.DataTypes;
48
import org.gvsig.fmap.dal.exception.DataException;
49
import org.gvsig.fmap.dal.feature.EditableFeature;
50
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
51
import org.gvsig.fmap.dal.feature.EditableFeatureType;
52
import org.gvsig.fmap.dal.feature.Feature;
53
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
54
import org.gvsig.fmap.dal.feature.FeatureSelection;
55
import org.gvsig.fmap.dal.feature.FeatureSet;
56
import org.gvsig.fmap.dal.feature.FeatureStore;
57
import org.gvsig.fmap.dal.feature.FeatureType;
58
import org.gvsig.fmap.dal.feature.exception.StoreUpdateFeatureTypeException;
59
import org.gvsig.fmap.mapcontrol.MapControlLocator;
60
import org.gvsig.fmap.mapcontrol.dal.feature.swing.FeatureTable;
61
import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.FeatureTableModel;
62
import org.gvsig.i18n.Messages;
63
import org.gvsig.tools.dispose.DisposableIterator;
64

  
65
/**
66
 * Feature Table Operations.
67
 * 
68
 * @author Vicente Caballero Navarro
69
 * 
70
 */
71
public class TableOperations {
72

  
73
    private static Logger logger = LoggerFactory.getLogger(TableOperations.class);
74
    
75
    public static final int MAX_FIELD_LENGTH = 254;
76
    private static TableOperations fto = null;
77
    private ArrayList<Feature> selectedFeatures = new ArrayList<Feature>();
78
    private boolean cutting = false;
79
    
80
    private FeatureTableDocumentPanel tablePanel = null;
81
    private FeatureStore featureStore;
82

  
83
    public static TableOperations getInstance() {
84
        if (fto == null) {
85
            fto = new TableOperations();
86
        }
87
        return fto;
88
    }
89

  
90
    public void setTablePanel(FeatureTableDocumentPanel tp) {
91
        tablePanel = tp;
92
        featureStore = tp.getModel().getStore();
93
    }
94

  
95
    public void copyFeatures() throws DataException {
96
        cutting = false;
97
        copy();
98
    }
99

  
100
    public boolean hasSelection() {
101
        return !selectedFeatures.isEmpty();
102
    }
103

  
104
    public void pasteFeatures() throws DataException {
105
        if (cutting) {
106
            delete();
107
            cutting = false;
108
        }
109
        Iterator<Feature> features = selectedFeatures.iterator();
110
        while (features.hasNext()) {
111
            Feature feature = features.next();
112
            if( !insertFeature(feature.getEditable()) ) {
113
                break;
114
            }
115
        }
116
    }
117

  
118
    public void cutFeatures() throws DataException {
119
        cutting = true;
120
        copy();
121
    }
122

  
123
    private void copy() throws DataException {
124
        DisposableIterator features = null;
125
        try {
126
            features =
127
                ((FeatureSelection) featureStore.getSelection()).fastIterator();
128
            selectedFeatures.clear();
129
            while (features.hasNext()) {
130
                Feature feature = (Feature) features.next();
131
                selectedFeatures.add(feature);
132
            }
133
        } finally {
134
            if (features != null) {
135
                features.dispose();
136
            }
137
        }
138
    }
139

  
140
    private void delete() throws DataException {
141
        Iterator<Feature> features = selectedFeatures.iterator();
142
        while (features.hasNext()) {
143
            Feature feature = features.next();
144
            if( !deleteFeature(feature) ) {
145
                break;
146
            }
147
        }
148
    }
149

  
150
    public void deleteFeatures() throws DataException {
151
        
152
        FeatureTableModel _ftm = this.tablePanel.getTablePanel().getTableModel();
153
        List<TableModelListener> tmll = removeTableModelListeners(_ftm);
154
        DisposableIterator feat_iter = null;
155
        Feature feat = null;
156
        try {
157
        	
158
        	
159
            FeatureSelection selection = featureStore.createFeatureSelection();
160
            selection.select((FeatureSet) featureStore.getSelection());
161
            feat_iter = selection.fastIterator();
162
            while (feat_iter.hasNext()) {
163
                feat = (Feature) feat_iter.next();
164
                if( !deleteFeature(feat) ) {
165
                    return;
166
                }
167
            }
168

  
169

  
170
        } finally {
171
            if (feat_iter != null) {
172
            	feat_iter.dispose();
173
            }
174
            
175
            addTableModelListeners(_ftm, tmll);
176
        }
177
    }
178

  
179
    /**
180
     * @param _ftm
181
     * @param tmll
182
     */
183
    private void addTableModelListeners(
184
        FeatureTableModel _model,
185
        List<TableModelListener> _list) {
186
        
187
        Iterator<TableModelListener> iter = _list.iterator();
188
        while (iter.hasNext()) {
189
            _model.addTableModelListener(iter.next());
190
        }
191
        _model.fireTableDataChanged();
192
    }
193

  
194
    /**
195
     * @param ftm
196
     * @param class1
197
     * @return
198
     */
199
    private List<TableModelListener> removeTableModelListeners(FeatureTableModel ftm) {
200
        
201
        TableModelListener[] ll = ftm.getListeners(TableModelListener.class);
202
        List<TableModelListener> resp = new ArrayList<TableModelListener>();
203
        
204
        int n = ll.length;
205
        for (int i=0; i<n; i++) {
206
            resp.add(ll[i]);
207
            ftm.removeTableModelListener(ll[i]);
208
        }
209

  
210
        return resp;
211
    }
212

  
213
    public void insertNewFeature() throws DataException {
214
        EditableFeature feature = featureStore.createNewFeature();
215
        insertFeature(feature);
216
    }
217

  
218
    /*
219
     * Return false if the operation is canceled.
220
     */
221
    private boolean insertFeature(EditableFeature feature) throws DataException {
222
        EditingNotificationManager editingNotificationManager = MapControlLocator.getEditingNotificationManager();
223
        EditingNotification notification = editingNotificationManager.notifyObservers(
224
                this,
225
                EditingNotification.BEFORE_INSERT_FEATURE,
226
                tablePanel.getDocument(),
227
                featureStore,
228
                feature);
229
        if ( notification.isCanceled() ) {
230
            return false;
231
        }
232
        if( notification.shouldValidateTheFeature() ) {
233
            if ( !editingNotificationManager.validateFeature(feature) ) {
234
                return false;
235
            }
236
        }
237
        featureStore.insert(feature);
238
        editingNotificationManager.notifyObservers(
239
                this,
240
                EditingNotification.AFTER_INSERT_FEATURE,
241
                tablePanel.getDocument(),
242
                featureStore,
243
                feature);
244
        return true;
245
    }
246

  
247
    private boolean deleteFeature(Feature feature) throws DataException {
248
        EditingNotificationManager editingNotification = MapControlLocator.getEditingNotificationManager();
249
        EditingNotification notification = editingNotification.notifyObservers(
250
                this,
251
                EditingNotification.BEFORE_REMOVE_FEATURE,
252
                tablePanel.getDocument(),
253
                featureStore,
254
                feature);
255
        if ( notification.isCanceled() ) {
256
            return false;
257
        }
258
        featureStore.delete(feature);
259
        editingNotification.notifyObservers(
260
                this,
261
                EditingNotification.AFTER_REMOVE_FEATURE,
262
                tablePanel.getDocument(),
263
                featureStore,
264
                feature);
265
        return true;
266
    }
267
    
268
    private boolean updateFeatureType(EditableFeatureType featureType) throws DataException {
269
        
270
        EditingNotificationManager editingNotification = MapControlLocator.getEditingNotificationManager();
271
        EditingNotification notification = editingNotification.notifyObservers(
272
                this,
273
                EditingNotification.BEFORE_UPDATE_FEATURE_TYPE,
274
                tablePanel.getDocument(),
275
                featureStore,
276
                featureType);
277
        if ( notification.isCanceled() ) {
278
            return false;
279
        }
280
        featureStore.update(featureType);
281
        editingNotification.notifyObservers(
282
                this,
283
                EditingNotification.AFTER_UPDATE_FEATURE_TYPE,
284
                tablePanel.getDocument(),
285
                featureStore,
286
                featureType);
287
        return true;
288
    }
289

  
290
    public void deleteAttributes(FeatureTable table) throws DataException {
291
        EditableFeatureType eft =
292
            featureStore.getDefaultFeatureType().getEditable();
293
        FeatureAttributeDescriptor[] selecteds =
294
            table.getSelectedColumnsAttributeDescriptor();
295
        for (int i = 0; i < selecteds.length; i++) {
296
            eft.remove(selecteds[i].getName());
297
        }
298
        featureStore.update(eft);
299
    }
300

  
301
    public void insertAttributes(FeatureTable table) throws DataException {
302
    	
303
		EditableFeatureType eft = featureStore.getDefaultFeatureType().getEditable();
304

  
305
		List<String> tmpfnames = new ArrayList<String>();
306
		int size = eft.size();
307
		for (int i = 0; i < size; i++) {
308
			FeatureAttributeDescriptor ad = (FeatureAttributeDescriptor) eft.get(i);
309
			tmpfnames.add(ad.getName());
310
		}
311

  
312
		CreateNewAttributePanel panelNewField = new CreateNewAttributePanel();
313
		panelNewField.setCurrentFieldNames(tmpfnames.toArray(new String[0]));
314
		panelNewField.setOkAction(new NewFieldActionListener(panelNewField, eft));
315
		ApplicationLocator.getManager().getUIManager().addWindow(panelNewField);
316
		featureStore.update(eft);
317
    }
318

  
319
    public void renameAttributes(FeatureTable table) throws DataException {
320
        
321
        FeatureType _ft = featureStore.getDefaultFeatureType();
322

  
323
        FeatureAttributeDescriptor[] selecteds =
324
            table.getSelectedColumnsAttributeDescriptor();
325

  
326
        for (int i = selecteds.length - 1; i >= 0; i--) {
327
            String newName =
328
                JOptionPane.showInputDialog((Component) PluginServices
329
                    .getMDIManager().getActiveWindow(),
330
                    PluginServices.getText(
331
                    this, "_Please_insert_new_field_name"),
332
                    selecteds[i]
333
                    .getName());
334
            if (newName == null || newName.length() == 0) {
335
                continue;
336
            }
337
            if (_ft.getIndex(newName) != -1) {
338
                NotificationManager.showMessageInfo(
339
                		Messages.getText("field_already_exists"), null);
340
                return;
341
            }
342
            
343
            renameAttribute(featureStore, selecteds[i].getName(), newName);
344
        }
345
        
346
        // featureStore.finishEditing();
347
        // featureStore.edit(FeatureStore.MODE_FULLEDIT);
348
    }
349

  
350
    /**
351
     * This method renames a field in three steps:
352
     * 
353
     * (1) add new field using type and size of old field.
354
     * (2) copy value from old field to new field.
355
     * (3) remove old field.
356
     * 
357
     * @param fs
358
     * @param name
359
     * @param newName
360
     * @return true if the change took place
361
     */
362
    private static boolean renameAttribute(FeatureStore fs, String name, String newName) {
363

  
364
        EditableFeatureType eft = null;
365
        FeatureType dft = null;
366
        try {
367
            dft = fs.getDefaultFeatureType();
368
            
369
            if (dft instanceof EditableFeatureType) {
370
                eft = (EditableFeatureType) dft;
371
            } else {
372
                eft = dft.getEditable();
373
            }
374
            
375
            EditableFeatureAttributeDescriptor efad =
376
                (EditableFeatureAttributeDescriptor) eft.getAttributeDescriptor(name);
377
            efad.setName(newName);
378
            fs.update(eft);
379
            
380
        } catch (DataException de) {
381
            
382
            Component root_comp =
383
                ApplicationLocator.getManager().getRootComponent();
384

  
385
            JOptionPane.showMessageDialog(
386
                root_comp,
387
                Messages.getText("_Unable_to_rename_attribute") +
388
                ": " + de.getMessage(),
389
                Messages.getText("_Unable_to_rename_attribute"),
390
                JOptionPane.ERROR_MESSAGE);
391
            return false;
392
        }
393
        return true;
394

  
395
        /*
396
        try {
397
            // ========== add new field
398
            eft = fs.getDefaultFeatureType().getEditable();
399
            FeatureAttributeDescriptor fad = eft.getAttributeDescriptor(name);
400
            eft.add(newName, fad.getType(), fad.getSize());
401
            fs.update(eft);
402
        } catch (DataException ex) {
403
            logger.info("Unable to rename attribute (" + name + " --> " + newName + ")", ex);
404
            ApplicationLocator.getManager().message(
405
                Messages.getText("_Unable_to_rename_attribute"),
406
                JOptionPane.ERROR_MESSAGE);
407
            // did not even add new field
408
            return false;
409
        }
410
        
411
        boolean error_when_inserting = false;
412
        try {
413
            // ========== copy value old field -> new field
414
            FeatureSet fset = fs.getFeatureSet();
415
            DisposableIterator diter = fset.fastIterator();
416
            Feature feat = null;
417
            Object val = null;
418
            EditableFeature efeat = null;
419
            while (diter.hasNext()) {
420
                feat = (Feature) diter.next();
421
                val = feat.get(name);
422
                efeat = feat.getEditable();
423
                efeat.set(newName, val);
424
                fset.update(efeat);
425
            }
426
            diter.dispose();
427
            
428
            // Closing editing to check that store admits new field
429
            fs.finishEditing();
430
        } catch (DataException ex) {
431
            
432
            logger.info("Error while renaming att to: " + newName, ex);
433
            String final_msg = getLastMessage(ex);
434
            JOptionPane.showMessageDialog(
435
                root_comp,
436
                Messages.getText("_Unable_to_rename_attribute")
437
                + ": " + final_msg,
438
                Messages.getText("_Rename_column"),
439
                JOptionPane.ERROR_MESSAGE);
440
            error_when_inserting = true;
441
        }
442
        
443
        if (error_when_inserting) {
444
            try {
445
                // Trying to remove new field and leave table as it was
446
                eft.remove(newName);
447
                fs.update(eft);
448
            } catch (DataException ex) {
449
                // Unable to remove added field but user was
450
                // already notified that something went wrong
451
            }
452
            // Not changed
453
            return false;
454
        }
455
            
456

  
457
        try {
458
            // Finally reopen editing and delete old field
459
            fs.edit(FeatureStore.MODE_FULLEDIT);
460
            eft = fs.getDefaultFeatureType().getEditable();
461
            eft.remove(name);
462
            fs.update(eft);
463
            
464
        } catch (DataException ex) {
465
            logger.info("Unable to rename attribute (" + name + " --> " + newName + ")", ex);
466
            ApplicationLocator.getManager().message(
467
                Messages.getText("_Unable_to_rename_attribute"),
468
                JOptionPane.ERROR_MESSAGE);
469
            return false;
470
        }
471
        return true;
472
        */
473

  
474
    }
475
    
476

  
477

  
478
    /**
479
     * Renames field in feature store
480
     * 
481
     * @param fs
482
     * @param oldname
483
     * @param newname
484
     * @return 
485
     * @throws DataException
486
     */
487
    public static void renameColumn(FeatureStore fs,
488
        String oldname, String newname) throws DataException {
489
        
490
        FeatureType _ft = fs.getDefaultFeatureType();
491
        if (_ft.getIndex(newname) != -1) {
492
            throw new StoreUpdateFeatureTypeException(
493
                new Exception("Attribute name already existed."),
494
                fs.getName());
495
        }
496
        renameAttribute(fs, oldname, newname);
497
        // fs.finishEditing();
498
    }
499
    
500
    public class NewFieldActionListener implements ActionListener {
501

  
502
    	private CreateNewAttributePanel panel = null;
503
    	private EditableFeatureType eft = null;
504
    	
505
    	public NewFieldActionListener(CreateNewAttributePanel p, EditableFeatureType t) {
506
    		eft = t;
507
    		panel = p;
508
    	}
509
    	
510
		public void actionPerformed(ActionEvent e) {
511
            try {
512
                EditableFeatureAttributeDescriptor ead = panel.loadFieldDescription(eft);
513
                if (ead == null) {
514
                    return;
515
                }
516
                if (ead.getType() == DataTypes.STRING
517
                    && ead.getSize() > TableOperations.MAX_FIELD_LENGTH) {
518
                    NotificationManager.showMessageInfo(
519
                        PluginServices.getText(this,
520
                            "max_length_is")
521
                            + ":"
522
                            + TableOperations.MAX_FIELD_LENGTH,
523
                        null);
524
                    ead.setSize(TableOperations.MAX_FIELD_LENGTH);
525
                }
526
                PluginServices.getMDIManager().closeWindow(panel);
527
            } catch (ParseException e2) {
528
                NotificationManager.addError(e2);
529
            }
530
			
531
		}
532
    	
533
    }
534

  
535
}
0 536

  
tags/org.gvsig.desktop-2.0.80/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/ExportStatisticsFile.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.app.project.documents.table;
25

  
26
import java.awt.Component;
27
import java.io.File;
28
import java.io.FileWriter;
29
import java.io.IOException;
30
import java.util.Hashtable;
31
import java.util.Iterator;
32
import java.util.List;
33

  
34
import javax.swing.JFileChooser;
35
import javax.swing.JOptionPane;
36
import javax.swing.filechooser.FileFilter;
37

  
38
import org.gvsig.andami.PluginServices;
39
import org.gvsig.andami.messages.NotificationManager;
40
import org.gvsig.app.project.documents.table.gui.CSVSeparatorOptionsPanel;
41
import org.gvsig.app.project.documents.table.gui.Statistics.MyObjectStatistics;
42
import org.gvsig.fmap.dal.DALLocator;
43
import org.gvsig.fmap.dal.DataManager;
44
import org.gvsig.fmap.dal.DataServerExplorerParameters;
45
import org.gvsig.fmap.dal.DataStoreParameters;
46
import org.gvsig.fmap.dal.DataTypes;
47
import org.gvsig.fmap.dal.exception.DataException;
48
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
49
import org.gvsig.fmap.dal.feature.EditableFeature;
50
import org.gvsig.fmap.dal.feature.EditableFeatureType;
51
import org.gvsig.fmap.dal.feature.FeatureStore;
52
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
53
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
54
import org.slf4j.Logger;
55
import org.slf4j.LoggerFactory;
56

  
57
/**
58
 * Class to create dbf and csv files at disk with the statistics group generated
59
 * from a table.
60
 * 
61
 * dbf -> Data Base File
62
 * csv -> Comma Separated Value
63
 * 
64
 * @author ?ngel Fraile Gri??n e-mail: angel.fraile@iver.es
65
 * 
66
 */
67

  
68
public class ExportStatisticsFile {
69

  
70
    private static final Logger logger = LoggerFactory
71
        .getLogger(ExportStatisticsFile.class);
72

  
73
    private String lastPath = null;
74
    private Hashtable<String, MyFileFilter> dbfExtensionsSupported; // Supported
75
                                                                    // extensions.
76
    private Hashtable<String, MyFileFilter> csvExtensionsSupported;
77

  
78
    public ExportStatisticsFile(List<MyObjectStatistics> valores) {
79

  
80
        JFileChooser jfc = new JFileChooser(lastPath);
81
        jfc.removeChoosableFileFilter(jfc.getAcceptAllFileFilter());
82

  
83
        // Adding required extensions (dbf, csv)
84
        dbfExtensionsSupported = new Hashtable<String, MyFileFilter>();
85
        csvExtensionsSupported = new Hashtable<String, MyFileFilter>();
86
        dbfExtensionsSupported.put("dbf", new MyFileFilter("dbf",
87
            PluginServices.getText(this, "Ficheros_dbf"), "dbf"));
88
        csvExtensionsSupported.put("csv", new MyFileFilter("csv",
89
            PluginServices.getText(this, "Ficheros_csv"), "csv"));
90

  
91
        Iterator<MyFileFilter> iter =
92
            csvExtensionsSupported.values().iterator();
93
        while (iter.hasNext()) {
94
            jfc.addChoosableFileFilter(iter.next());
95
        }
96

  
97
        iter = dbfExtensionsSupported.values().iterator();
98
        while (iter.hasNext()) {
99
            jfc.addChoosableFileFilter(iter.next());
100
        }
101

  
102
        // Opening a JFileCooser
103
        if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) {
104
            File endFile = jfc.getSelectedFile();
105
            if (endFile.exists()) {// File exists in the directory.
106
                int resp =
107
                    JOptionPane.showConfirmDialog(
108
                        (Component) PluginServices.getMainFrame(),
109
                        PluginServices.getText(this,
110
                            "fichero_ya_existe_seguro_desea_guardarlo")
111
                            + "\n"
112
                            + endFile.getAbsolutePath(), PluginServices
113
                            .getText(this, "guardar"),
114
                        JOptionPane.YES_NO_OPTION);// Informing the user
115
                if (resp != JOptionPane.YES_OPTION) {// cancel pressed.
116
                    return;
117
                }
118
            }// end if exits.
119
            MyFileFilter filter = (MyFileFilter) jfc.getFileFilter();// dbf, csv
120
            endFile = filter.normalizeExtension(endFile);// "name" + "." +
121
                                                         // "dbf", "name" + "."
122
                                                         // + "csv"
123

  
124
            if (filter.getExtensionOfAFile(endFile).toLowerCase()
125
                .compareTo("csv") == 0) { // csv file
126
                exportToCSVFile(valores, endFile); // export to csv format
127
            } else
128
                if (filter.getExtensionOfAFile(endFile).toLowerCase()
129
                    .compareTo("dbf") == 0) {// dbf file
130
                    try {
131
                        exportToDBFFile(valores, endFile);
132
                    } catch (Exception e) {
133
                        NotificationManager.addError(e);
134
                    } // export to dbf format
135
                }
136
        }// end if aprove option.
137
    }
138

  
139
    /**
140
     * Creating cvs format file with the statistics.
141
     * Option to select the two columns separator.
142
     * 
143
     * Example with semicolon: Name;data\n
144
     * Name2;data2\n
145
     * 
146
     * @param valores
147
     *            - Pairs: String name (key) + Double value (
148
     * @param endFile
149
     *            - File to write the information
150
     */
151

  
152
    private void exportToCSVFile(List<MyObjectStatistics> valores, File endFile) {
153

  
154
        try {
155
            CSVSeparatorOptionsPanel csvSeparatorOptions =
156
                new CSVSeparatorOptionsPanel();
157
            PluginServices.getMDIManager().addWindow(csvSeparatorOptions);
158

  
159
            String separator = csvSeparatorOptions.getSeparator();
160

  
161
            if (separator != null) {
162

  
163
                FileWriter fileCSV = new FileWriter(endFile);
164

  
165
                fileCSV.write(PluginServices.getText(this, "Nombre")
166
                    + separator + PluginServices.getText(this, "Valor") + "\n");
167

  
168
                Iterator<MyObjectStatistics> iterador = valores.listIterator();
169

  
170
                while (iterador.hasNext()) {// Writing value,value\n
171
                    MyObjectStatistics data = iterador.next();
172
                    fileCSV.write(data.getKey() + separator + (data.getValue())
173
                        + "\n");
174
                }
175
                fileCSV.close();
176
                JOptionPane.showMessageDialog(
177
                    null,
178
                    PluginServices.getText(this, "fichero_creado_en") + " "
179
                        + endFile.getAbsolutePath(),
180
                    PluginServices.getText(this, "fichero_creado_en_formato")
181
                        + " csv "
182
                        + PluginServices.getText(this, "mediante_el_separador")
183
                        + " \"" + separator + "\"",
184
                    JOptionPane.INFORMATION_MESSAGE);// Informing the user
185
            } else {
186
                return;
187
            }
188

  
189
        } catch (IOException e) {// Informing the user
190
            logger.error("Error exportando a formato csv");
191
            JOptionPane.showMessageDialog(
192
                null,
193
                PluginServices.getText(this,
194
                    "Error_exportando_las_estadisticas")
195
                    + " "
196
                    + endFile.getAbsolutePath(), PluginServices.getText(this,
197
                    "Error"), JOptionPane.ERROR_MESSAGE);
198
        }
199

  
200
    }
201

  
202
    public void exportToDBFFile(List<MyObjectStatistics> valores, File endFile)
203
        throws DataException, ValidateDataParametersException {
204
        DataManager datamanager = DALLocator.getDataManager();
205

  
206
        //
207
        // Averigua el proveedor en funcion del fichero
208
        // preguntandoselo al FilesystemServerExplorer.
209
        DataServerExplorerParameters no_params =
210
            (DataServerExplorerParameters) datamanager
211
                .createServerExplorerParameters(FilesystemServerExplorer.NAME);
212
        
213
        FilesystemServerExplorer explorer =
214
            (FilesystemServerExplorer) datamanager.openServerExplorer(
215
                FilesystemServerExplorer.NAME, no_params // empty params
216
                );
217
        String providerName = explorer.getProviderName(endFile);
218

  
219
        try {
220
            if (endFile.exists()) {
221
                endFile.delete();
222
            }
223
            endFile.createNewFile();
224
            
225
            DataStoreParameters dsp =
226
                explorer.createStoreParameters(endFile, providerName);
227
            NewFeatureStoreParameters parameters =
228
                (NewFeatureStoreParameters) datamanager
229
                    .createNewStoreParameters(FilesystemServerExplorer.NAME,
230
                        providerName);
231
            
232
            parameters.delegate(dsp);
233
            
234
            EditableFeatureType type =
235
                parameters.getDefaultFeatureType(); // .getEditable();
236
            type.add(PluginServices.getText(this, "Nombre"), DataTypes.STRING,
237
                50);
238
            type.add(PluginServices.getText(this, "Valor"), DataTypes.DOUBLE,
239
                100).setPrecision(25);
240

  
241
            parameters.setDefaultFeatureType(type);
242
            datamanager.newStore(FilesystemServerExplorer.NAME, providerName,
243
                parameters, true);
244

  
245
            FeatureStore target =
246
                (FeatureStore) datamanager.openStore(providerName, parameters);
247
            target.edit(FeatureStore.MODE_APPEND);
248
            Iterator<MyObjectStatistics> iterador = valores.listIterator();
249
            while (iterador.hasNext()) {
250
                MyObjectStatistics data = iterador.next();
251
                EditableFeature ef = target.createNewFeature().getEditable();
252
                ef.set(PluginServices.getText(this, "Nombre"), data.getKey());
253
                ef.set(PluginServices.getText(this, "Valor"), data.getValue());
254
                target.insert(ef);
255
            }
256
            target.finishEditing();
257
            target.dispose();
258
            JOptionPane.showMessageDialog(
259
                (Component) PluginServices.getMainFrame(),
260
                PluginServices.getText(this, "fichero_creado_en") + " "
261
                    + endFile.getAbsolutePath(),
262
                PluginServices.getText(this, "fichero_creado_en_formato")
263
                    + " dbf", JOptionPane.INFORMATION_MESSAGE);// Informing the
264
                                                               // user
265
        } catch (Exception e) {
266
            e.printStackTrace();
267
        }
268
    }
269
}
270

  
271
/**
272
 * @author ?ngel Fraile Gri??n e-mail: angel.fraile@iver.es
273
 * 
274
 *         Class to work with the file extensions.
275
 */
276
class MyFileFilter extends FileFilter {
277

  
278
    private String[] extensiones = new String[1];
279
    private String description;
280
    private boolean dirs = true;
281
    private String info = null;
282

  
283
    public MyFileFilter(String[] ext, String desc) {
284
        extensiones = ext;
285
        description = desc;
286
    }
287

  
288
    public MyFileFilter(String[] ext, String desc, String info) {
289
        extensiones = ext;
290
        description = desc;
291
        this.info = info;
292
    }
293

  
294
    public MyFileFilter(String ext, String desc) {
295
        extensiones[0] = ext;
296
        description = desc;
297
    }
298

  
299
    public MyFileFilter(String ext, String desc, String info) {
300
        extensiones[0] = ext;
301
        description = desc;
302
        this.info = info;
303
    }
304

  
305
    public MyFileFilter(String ext, String desc, boolean dirs) {
306
        extensiones[0] = ext;
307
        description = desc;
308
        this.dirs = dirs;
309
    }
310

  
311
    public MyFileFilter(String ext, String desc, boolean dirs, String info) {
312
        extensiones[0] = ext;
313
        description = desc;
314
        this.dirs = dirs;
315
        this.info = info;
316
    }
317

  
318
    public boolean accept(File f) {
319
        if (f.isDirectory()) {
320
            if (dirs) {
321
                return true;
322
            } else {
323
                return false;
324
            }
325
        }
326
        for (int i = 0; i < extensiones.length; i++) {
327
            if (extensiones[i].equals("")) {
328
                continue;
329
            }
330
            if (getExtensionOfAFile(f).equalsIgnoreCase(extensiones[i])) {
331
                return true;
332
            }
333
        }
334
        return false;
335
    }
336

  
337
    public String getDescription() {
338
        return description;
339
    }
340

  
341
    public String[] getExtensions() {
342
        return extensiones;
343
    }
344

  
345
    public boolean isDirectory() {
346
        return dirs;
347
    }
348

  
349
    public String getExtensionOfAFile(File file) {
350
        String name;
351
        int dotPos;
352
        name = file.getName();
353
        dotPos = name.lastIndexOf(".");
354
        if (dotPos < 1) {
355
            return "";
356
        }
357
        return name.substring(dotPos + 1);
358
    }
359

  
360
    public File normalizeExtension(File file) {
361
        String ext = getExtensionOfAFile(file);
362
        if (ext.equals("") || !(this.accept(file))) {
363
            return new File(file.getAbsolutePath() + "." + extensiones[0]);
364
        }
365
        return file;
366
    }
367

  
368
    public String getInfo() {
369
        return this.info;
370
    }
371

  
372
    public void setInfo(String info) {
373
        this.info = info;
374
    }
375
}
0 376

  
tags/org.gvsig.desktop-2.0.80/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/TableSelectionModel.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.app.project.documents.table;
25

  
26
import org.gvsig.utils.swing.objectSelection.ObjectSelectionModel;
27

  
28
/**
29
 * @author Fernando Gonz?lez Cort?s
30
 */
31
public class TableSelectionModel implements ObjectSelectionModel {
32

  
33
    private TableDocument[] tables;
34
    private String msg;
35

  
36
    public TableSelectionModel(TableDocument[] tables, String msg) {
37
        this.tables = tables;
38
        this.msg = msg;
39
    }
40

  
41
    /**
42
     * @see org.gvsig.app.project.documents.table.TableSelectionModel#getTables()
43
     */
44
    public Object[] getObjects() {
45
        return tables;
46
    }
47

  
48
    /**
49
     * @see org.gvsig.utils.swing.objectSelection.ObjectSelectionModel#getMsg()
50
     */
51
    public String getMsg() {
52
        return msg;
53
    }
54

  
55
}
0 56

  
tags/org.gvsig.desktop-2.0.80/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
7

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

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

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

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

  
26
-->
27
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
28
<html xmlns="http://www.w3.org/1999/xhtml">
29
<head>
30
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
31
<title>org.gvsig.landregistryviewer package documentation</title>
32
</head>
33
<body>
34

  
35
	<p>Table document support</p>
36

  
37
</body>
38
</html>
0 39

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff