Revision 47347

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.app/org.gvsig.xml2db.app.mainplugin/src/main/resources-plugin/i18n/text.properties
18 18
_Name_for_the_repository=Nombre para el repositorio
19 19
_Register_connection=Registrar conexi\u00f3n
20 20
_Connect_to_repository=Conectar al repositorio
21
_Language=Idioma
22
_Overwrite_database=Sobrescribir base de datos
23
_XML_file_is_required=Es necesario un archivo XML
24
_Analize_XML_required=Es necesario analizar el XML
25
_Database_file_already_exists=El archivo de base de datos ya existe
26
_No_tables_recognized_in_the_XML=No se han reconocido tablas en el XML
27
_Database_file_is_required=Es necesario un archivo de base de datos
28
_Removing_existing_database=Borrando base de datos existente...
29
_Problems_processing_XML_file=Problemas prosensado el archivo XML
30
_Xml2db_Create_database_from_xml=Crear base de datos a partir de un XML
31
_XML_file_not_exists=El archivo XML no existe
32
_Repository_name_is_required=Es requierido el nombre de un repositorio
33
_Xml2db_Column_manager=Gestor de columnas
34
_Copy_xml_to_database=Copiar xml a base de datos
35
_Copying_XML_data=Copiando datos del XML...
36
_Reading_xml=Leyendo xml...
37
_Identifying_tables=Identificando tablas...
38
_Fixing_table_names=Arreglando nombres de tablas...
39
_Identifying_foreign_keys=Identificando claves ajenas...
40
_Creating_table_definitions=Creando definiciones de tablas...
41
_Calculating_lines=Calculando l\u00edneas...
42
_Creating_database=Creando base de datos...
43
_Creating_tables=Creando tablas...
44
_Registering_tables_in_the_repository=Registrando tablas en el repositorio...
45
_Copying=Copiando...
46
_Removing_existing_database=Borrando bases de datos existente...
47
_Detect_projection=Detectar proyecci\u00f3n
48
_Detect_charset=Detectar juego de caracteres
21 49

  
22 50

  
51

  
52

  
53

  
54

  
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.app/org.gvsig.xml2db.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties
18 18
_Name_for_the_repository=Name for the repository
19 19
_Register_connection=Register connection
20 20
_Connect_to_repository=Connect to repository
21
_Language=Language
22
_Overwrite_database=Overwrite database
23
_XML_file_is_required= XML file is required
24
_Analize_XML_required=Analize XML is required
25
_Database_file_already_exists=Database file already exists
26
_No_tables_recognized_in_the_XML=No tables recognized in the XML
27
_Database_file_is_required=Database file is required
28
_Removing_existing_database=Removing existing database...
29
_Problems_processing_XML_file=Problems processing XML file
30
_XML_file_not_exists=XML file not exists
31
_Repository_name_is_required=Repository name is required
32
_Xml2db_Column_manager=Column manager
33
_Copy_xml_to_database=Copy xml to database
34
_Copying_XML_data=Copying XML data...
35
_Reading_xml=Reading xml...
36
_Identifying_tables=Identifying tables...
37
_Fixing_table_names=Fixing table names...
38
_Identifying_foreign_keys=Identifying foreign keys...
39
_Creating_table_definitions=Creating table definitions...
40
_Calculating_lines=Calculating lines...
41
_Creating_database=Creating database...
42
_Creating_tables=Creating tables...
43
_Registering_tables_in_the_repository=Registering tables in the repository...
44
_Copying=Copying...
45
_Removing_existing_database=Removing existing database
46
_Detect_projection=Detect projection
47
_Detect_charset=Detect charset
48

  
49

  
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/main/java/org/gvsig/xml2db/lib/impl/StructureExtractorImpl.java
30 30
import org.gvsig.fmap.dal.feature.EditableFeatureType;
31 31
import org.gvsig.fmap.dal.feature.EditableForeingKey;
32 32
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
33
import org.gvsig.tools.ToolsLocator;
33 34
import org.gvsig.tools.dynobject.DynField_v2;
35
import org.gvsig.tools.i18n.I18nManager;
34 36
import org.gvsig.tools.task.SimpleTaskStatus;
35 37
import org.gvsig.xml2db.lib.api.xmlinfo.XMLAttributeInfo;
36 38
import org.gvsig.xml2db.lib.api.xmlinfo.XMLInfo;
37 39
import org.gvsig.xml2db.lib.api.xmlinfo.XMLTableInfo;
38 40
import org.gvsig.xml2db.lib.impl.xmlinfo.XMLInfoImpl;
41
import org.slf4j.Logger;
42
import org.slf4j.LoggerFactory;
39 43
import org.xml.sax.Attributes;
40 44
import org.xml.sax.InputSource;
41 45
import org.xml.sax.Locator;
......
48 52
 */
49 53
public class StructureExtractorImpl {
50 54

  
55
        private static final Logger LOGGER = LoggerFactory.getLogger(StructureExtractorImpl.class);
56

  
51 57
    @SuppressWarnings("UseSpecificCatch")
52 58
    private void extractTags(XMLInfoImpl xmlinfo, Reader reader, SimpleTaskStatus status) {
53 59
        if( reader == null ) {
......
55 61
        }
56 62
        try {
57 63
            final DataManager dataManager = DALLocator.getDataManager();
58
            
59
            status.message("Reading xml 1/5...");
64
            I18nManager i18n = ToolsLocator.getI18nManager();
65
            status.message(i18n.getTranslation("_Reading_xml")+" 1/5");
60 66
            status.setRangeOfValues(0, xmlinfo.getCountLines());
61 67
            
62 68
            SAXParserFactory spf = SAXParserFactory.newInstance();
......
127 133
                        info.setLastChildID(infoChild.getName(), idvalueChild);
128 134
                        infoChild.addValue(value);
129 135
                        if( xmlinfo.getSrid() ==  null && StringUtils.containsIgnoreCase(infoChild.getName(), "srid") ) {
130
                            IProjection proj = getProyection(value);
136
                            IProjection proj = getProjection(value);
131 137
                            if( proj!=null ) {
132 138
                                xmlinfo.setSrid(proj);
133 139
                            }
......
174 180
                        String value = this.chars.toString();
175 181
                        info.addValue(value);
176 182
                        if( StringUtils.containsIgnoreCase(info.getName(), "srid") ) {
177
                            IProjection proj = getProyection(value);
183
                            IProjection proj = getProjection(value);
178 184
                            if( proj!=null ) {
179 185
                                xmlinfo.setSrid(proj);
180 186
                            }
......
204 210
        }
205 211
    }
206 212
    
207
    private IProjection getProyection(String value) {
213
    private IProjection getProjection(String value) {
208 214
        if( StringUtils.isBlank(value) ) {
209 215
            return null;
210 216
        }
......
282 288
    }
283 289

  
284 290
    private void buildTablesFromTags(XMLInfoImpl xmlinfo, SimpleTaskStatus status) {
285
        status.message("Identifying tables 2/5...");
291
        I18nManager i18n = ToolsLocator.getI18nManager();
292
        status.message(i18n.getTranslation("_Identifying_tables")+" 2/5");
286 293
        status.setRangeOfValues(0, xmlinfo.getTagsPaths().size());
287 294
        
288 295
        for (String tagPath : xmlinfo.getTagsPaths()) {
289 296
            XMLAttributeInfoImpl tag1Info = xmlinfo.getTagInfo(tagPath);
290
            System.out.println(tag1Info.getPath());
297
//            System.out.println(tag1Info.getPath());
291 298
            XMLTableInfoImpl tableInfo = new XMLTableInfoImpl(tagPath, tag1Info);
292 299
            for (String tagPath2 : xmlinfo.getTagsPaths()) {
293 300
                if( tagPath.equals(tagPath2) ) {
......
309 316
    }
310 317
    
311 318
    private void removeDuplicateTableNames(XMLInfoImpl xmlinfo, SimpleTaskStatus status) {
312
        status.message("Fixing table names 3/5...");
319
        I18nManager i18n = ToolsLocator.getI18nManager();
320
        status.message(i18n.getTranslation("_Fixing_table_names")+" 3/5");
313 321
        status.setRangeOfValues(0, xmlinfo.size());
314 322

  
315 323
        // Tratamos de corregir nombres duplicados en las tablas.
316 324
        for (XMLTableInfo tableInfo01 : xmlinfo) {
317 325
            XMLTableInfoImpl tableInfo1 = (XMLTableInfoImpl) tableInfo01;
318 326
            
319
            status.message("Fixing table names 3/5 ("+tableInfo1.getName()+")...");
327
            status.message(i18n.getTranslation("_Fixing_table_names")+" 3/5 ("+tableInfo1.getName()+")");
320 328

  
321 329
            boolean renombrar = false;
322 330
            for (XMLTableInfo tableInfo02 : xmlinfo) {
......
348 356
    }
349 357
    
350 358
    private void createPrimaryKeyAndForeignKeys(XMLInfoImpl xmlinfo, SimpleTaskStatus status) {
351
        status.message("Identifying foreign keys 4/5...");
359
        I18nManager i18n = ToolsLocator.getI18nManager();
360
        status.message(i18n.getTranslation("_Identifying_foreign_keys")+" 4/5");
352 361
        status.setRangeOfValues(0, xmlinfo.size());
353 362

  
354 363
        for (XMLTableInfo tableInfo0 : xmlinfo) {
355 364
            XMLTableInfoImpl tableInfo = (XMLTableInfoImpl) tableInfo0;
356 365
            
357
            status.message("Identifying foreign keys 4/5 ("+tableInfo.getName()+")...");
366
            status.message(i18n.getTranslation("_Identifying_foreign_keys")+" 4/5 ("+tableInfo.getName()+")");
358 367

  
359 368
            String[] fieldkeys = tableInfo.getPath().split("/");
360 369
            for (int i = 0; i < fieldkeys.length; i++) {
......
403 412
    }
404 413
    
405 414
    private void createFeatureTypes(XMLInfoImpl xmlinfo, SimpleTaskStatus status) {
406
        status.message("Creating table definitions 5/5...");
415
        I18nManager i18n = ToolsLocator.getI18nManager();
416
        status.message(i18n.getTranslation("_Creating_table_definitions")+" 5/5");
407 417
        status.setRangeOfValues(0, xmlinfo.size());
408 418

  
409 419
        DataManager dataManager = DALLocator.getDataManager();
......
411 421
        for (XMLTableInfo tableInfo0 : xmlinfo) {
412 422
            XMLTableInfoImpl tableInfo = (XMLTableInfoImpl) tableInfo0;
413 423

  
414
            status.message("Creating table definitions 5/5 "+(tableInfo.getName())+"...");
424
            status.message(i18n.getTranslation("_Creating_table_definitions")+" 5/5 ("+tableInfo.getName()+")");
415 425
            
416 426
            EditableFeatureType ft = dataManager.createFeatureType();
417 427
            ft.setLabel(tableInfo.getName());
......
421 431
            for (XMLAttributeInfo attrinfo0 : tableInfo) {
422 432
                XMLAttributeInfoImpl attrinfo = (XMLAttributeInfoImpl) attrinfo0;
423 433
                if( ft.get(attrinfo.getName())!=null ) {
424
                    System.out.println("WARN: attribute '"+attrinfo.getName()+"' duplicated in '"+tableInfo.getName()+"'.");
434
                    LOGGER.warn("Duplicated attribute '"+attrinfo.getName()+"' in '"+tableInfo.getName()+"'.");
425 435
                }
426 436
                if(  attrinfo.isAggregate() ) {
427 437
                    continue;
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/main/java/org/gvsig/xml2db/lib/impl/Xml2dbCommons.java
1 1
package org.gvsig.xml2db.lib.impl;
2 2

  
3
import static com.vividsolutions.jts.geom.CoordinateSequence.M;
3 4
import java.io.BufferedInputStream;
4 5
import java.io.BufferedReader;
5 6
import java.io.File;
......
19 20
import org.apache.tika.detect.AutoDetectReader;
20 21
import org.apache.tika.detect.EncodingDetector;
21 22
import org.apache.tika.metadata.Metadata;
23
import org.gvsig.tools.ToolsLocator;
24
import org.gvsig.tools.i18n.I18nManager;
22 25
import org.gvsig.tools.task.SimpleTaskStatus;
23 26
import org.xml.sax.InputSource;
24 27

  
......
29 32
@SuppressWarnings("UseSpecificCatch")
30 33
public class Xml2dbCommons {
31 34

  
32
    public static Charset detectCharset(InputStream is) {   
33
        EncodingDetector encodingDetector = TikaConfig.getDefaultConfig().getEncodingDetector();
34
        BufferedInputStream bis = null;
35
        try {
36
            bis = new BufferedInputStream(CloseShieldInputStream.wrap(is));
37
            Charset charset = encodingDetector.detect(bis, new Metadata());
38
            return charset;
39
        } catch (Exception ex) {
35
    public static Charset detectCharset(InputStream is) { 
36
        try {            
37
            AutoDetectReader reader = new AutoDetectReader(is);
38
            return reader.getCharset();
39
        } catch(Throwable t) {
40 40
            return null;
41
        } finally {
42
            IOUtils.closeQuietly(bis);
43 41
        }
44 42
    }
45 43
    
......
126 124
                is = openReader(is);
127 125
                br = new BufferedReader(is.getCharacterStream());
128 126
                int n = 1;
127
                I18nManager i18n = ToolsLocator.getI18nManager();
129 128
                while( br.readLine()!=null ) {
130 129
                    if(count%n == 0){
131
                        status.message("Calculating lines...");
130
                        status.message(i18n.getTranslation("_Calculating_lines"));
132 131
                        status.setCurValue(count);
133 132
                    }
134 133
//                    status.incrementCurrentValue();
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/main/java/org/gvsig/xml2db/lib/impl/CopyXML2dbImpl.java
15 15
import org.apache.commons.lang3.mutable.MutableInt;
16 16
import org.gvsig.fmap.dal.DALLocator;
17 17
import org.gvsig.fmap.dal.DataManager;
18
import org.gvsig.fmap.dal.DataQuery;
18 19
import org.gvsig.fmap.dal.DataStoreParameters;
19 20
import org.gvsig.fmap.dal.feature.EditableFeature;
20 21
import org.gvsig.fmap.dal.feature.Feature;
21 22
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
23
import org.gvsig.fmap.dal.feature.FeatureQuery;
22 24
import org.gvsig.fmap.dal.feature.FeatureStore;
23 25
import org.gvsig.fmap.dal.feature.FeatureType;
24 26
import org.gvsig.fmap.dal.feature.ForeingKey;
25 27
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
26 28
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
27 29
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer;
30
import org.gvsig.tools.ToolsLocator;
28 31
import org.gvsig.tools.dispose.DisposeUtils;
32
import org.gvsig.tools.i18n.I18nManager;
29 33
import org.gvsig.tools.task.SimpleTaskStatus;
30 34
import org.gvsig.xml2db.lib.impl.xmlinfo.XMLTableInfoImpl;
31 35
import org.slf4j.Logger;
......
60 64
            this.tables = tables;
61 65
            this.openStoreParams = openStoreParams;
62 66
            this.tableName = openStoreParams.getTable();
63
            this.pkcounter = 1;
67
            this.pkcounter = -1;
64 68

  
65 69
            FeatureStore theStore = null;
66 70
            try {
......
78 82

  
79 83
        }
80 84
        
85
        private int getNextPkValue() {
86
            FeatureStore theStore = null;
87
            try {
88
                DataManager dataManager = DALLocator.getDataManager();
89
                theStore = (FeatureStore) dataManager.openStore(
90
                        this.openStoreParams.getProviderName(),
91
                        openStoreParams
92
                );
93
                FeatureQuery query = theStore.createFeatureQuery();
94
                String pkName = this.featureType.getPrimaryKey()[0].getName();
95
                query.addAggregate("MAX", pkName);
96
                Feature f = theStore.findFirst(query);
97
                if(f != null){
98
                    Object x = f.get(pkName);
99
                    if(x != null){
100
                        return ((Number)x).intValue()+1;
101
                    }
102
                }
103
                return 1;
104
            } catch (Throwable t) {
105
                throw new RuntimeException("Can't get path from store '" + this.getTableName() + "'.", t);
106
            } finally {
107
                DisposeUtils.disposeQuietly(theStore);
108
            }
109
            
110
            
111
        }
112
        
81 113
        public void close() {
82 114
            try {
83 115
                this.insert();
......
118 150

  
119 151
        private void createRow() {
120 152
            try {
153
                if(this.pkcounter < 0){
154
                    this.pkcounter = getNextPkValue();
155
                }
121 156
                FeatureStore theStore = this.getStore();
122 157
//                System.out.println("###: create row("+this.tableName+")");
123 158
                this.current_row = theStore.createNewFeature();
......
209 244
        } catch (Exception ex) {
210 245
            throw new IllegalArgumentException("Can't open target database", ex);
211 246
        }
247
        I18nManager i18n = ToolsLocator.getI18nManager();
212 248
        MutableInt line = new MutableInt(0);
213 249
        MutableInt column = new MutableInt(0);
214 250
        try {
215
            taskStatus.message("Copying...");
251
            taskStatus.message(i18n.getTranslation("_Copying"));
216 252
            taskStatus.setRangeOfValues(0, countLines);
217 253
            
218 254
            SAXParserFactory spf = SAXParserFactory.newInstance();
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/main/java/org/gvsig/xml2db/lib/impl/DefaultXml2dbManager.java
24 24
package org.gvsig.xml2db.lib.impl;
25 25

  
26 26
import java.io.File;
27
import java.io.FileInputStream;
27 28
import java.io.FileNotFoundException;
28 29
import java.io.IOException;
29 30
import java.io.InputStream;
30 31
import java.io.Reader;
31 32
import java.nio.charset.Charset;
32 33
import java.util.Locale;
34
import java.util.logging.Level;
35
import java.util.logging.Logger;
33 36
import org.apache.commons.io.FilenameUtils;
37
import org.apache.commons.io.IOUtils;
34 38
import org.apache.commons.lang3.StringUtils;
35 39
import org.cresques.cts.IProjection;
36 40
import org.gvsig.fmap.dal.DALLocator;
......
39 43
import org.gvsig.fmap.dal.DatabaseWorkspaceManager;
40 44
import org.gvsig.fmap.dal.feature.FeatureStore;
41 45
import org.gvsig.fmap.dal.feature.FeatureType;
46
import org.gvsig.fmap.dal.store.h2.H2SpatialUtils;
42 47
import org.gvsig.fmap.dal.store.jdbc.JDBCNewStoreParameters;
43 48
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
44 49
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
45 50
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer;
51
import org.gvsig.tools.ToolsLocator;
52
import org.gvsig.tools.i18n.I18nManager;
46 53
import org.gvsig.tools.task.SimpleTaskStatus;
47 54
import org.gvsig.tools.util.HasAFile;
48 55
import org.gvsig.xml2db.lib.api.Xml2dbManager;
......
103 110
                repoID = FilenameUtils.getBaseName(dbfile.getName());
104 111
            }
105 112
            
106
            taskStatus.message("Creating database...");
113
            I18nManager i18n = ToolsLocator.getI18nManager();
114
            
115
            taskStatus.message(i18n.getTranslation("_Creating_database"));
107 116
            taskStatus.setIndeterminate();
108 117
            
109 118
            JDBCServerExplorerParameters serverParams = (JDBCServerExplorerParameters) dataManager.createServerExplorerParameters(FeatureStore.H2SPATIAL_PROVIDER_NAME);
110 119
            ((HasAFile)serverParams).setFile(dbfile);
111 120
            
112 121
            DatabaseWorkspaceManager dbworkspace = dataManager.createDatabaseWorkspaceManager(serverParams);
122
            JDBCServerExplorer server = (JDBCServerExplorer) dbworkspace.getServerExplorer();
123
            if( !H2SpatialUtils.existsH2db(dbfile) ) {
124
                server.dropCaches();
125
            }
126

  
113 127
            dbworkspace.create(repoID, null);
114 128
            
115
            JDBCServerExplorer server = (JDBCServerExplorer) dbworkspace.getServerExplorer();
116 129

  
117
            taskStatus.message("Creating tables...");
130
            taskStatus.message(i18n.getTranslation("_Creating_tables"));
118 131
            taskStatus.setRangeOfValues(0, xmlinfo.size());
119 132
            for (XMLTableInfo tableInfo : xmlinfo) {
120 133
                String tablename = tableInfo.getName();
......
125 138
                server.add(tableParams.getProviderName(), tableParams, false);
126 139
                taskStatus.incrementCurrentValue();
127 140
            }
128
            taskStatus.message("Registering tables in the repository...");
141
            taskStatus.message(i18n.getTranslation("_Registering_tables_in_the_repository"));
129 142
            taskStatus.setRangeOfValues(0, xmlinfo.size());
130 143
            for (DataStoreParameters storeParams : server.list()) {
131 144
                JDBCStoreParameters featureStoreParams = (JDBCStoreParameters)storeParams;
......
140 153
            throw new RuntimeException("Can't create databse '"+dbfile.getAbsolutePath()+"'.", ex);
141 154
        }
142 155
    }
156

  
157
    @Override
158
    public Charset detectCharset(InputStream is) {
159
        return Xml2dbCommons.detectCharset(is);
160
    }
161

  
162
    @Override
163
    public Charset detectCharset(File file) {
164
        FileInputStream is = null;
165
        try {
166
            is = new FileInputStream(file);
167
            return detectCharset(is);
168
        } catch (Exception ex) {
169
            return null;
170
        } finally {
171
            IOUtils.closeQuietly(is);
172
        }
173
    }
143 174
    
175
    public IProjection detectProjection(File file, SimpleTaskStatus status) {
176
        return new ProjectionExtractorImpl().extractProjection(file, null, status);
177
    }
144 178
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/main/java/org/gvsig/xml2db/lib/impl/ProjectionExtractorImpl.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.xml2db.lib.impl;
7

  
8
import java.io.File;
9
import java.io.FileNotFoundException;
10
import java.io.IOException;
11
import java.io.InputStream;
12
import java.io.Reader;
13
import java.nio.charset.Charset;
14
import java.util.ArrayList;
15
import java.util.List;
16
import javax.xml.parsers.SAXParser;
17
import javax.xml.parsers.SAXParserFactory;
18
import org.apache.commons.lang3.StringUtils;
19
import org.apache.commons.lang3.mutable.MutableObject;
20
import org.cresques.cts.IProjection;
21
import org.gvsig.fmap.crs.CRSFactory;
22
import org.gvsig.fmap.dal.DALLocator;
23
import org.gvsig.fmap.dal.DataManager;
24
import org.gvsig.tools.ToolsLocator;
25
import org.gvsig.tools.i18n.I18nManager;
26
import org.gvsig.tools.task.SimpleTaskStatus;
27
import org.slf4j.Logger;
28
import org.slf4j.LoggerFactory;
29
import org.xml.sax.Attributes;
30
import org.xml.sax.InputSource;
31
import org.xml.sax.Locator;
32
import org.xml.sax.SAXException;
33
import org.xml.sax.helpers.DefaultHandler;
34

  
35
/**
36
 *
37
 * @author jjdelcerro
38
 */
39
public class ProjectionExtractorImpl {
40

  
41
    private static final Logger LOGGER = LoggerFactory.getLogger(ProjectionExtractorImpl.class);
42
    
43
    private static class ProjectionExtractorException extends RuntimeException {
44
        
45
    }
46
    
47
    private IProjection extractProjection(InputSource is, SimpleTaskStatus status) {
48
        if( is == null || is.getCharacterStream() == null ) {
49
            throw new IllegalArgumentException("input source is null");
50
        }
51
        MutableObject<IProjection> proj = new MutableObject<>();
52
        try {
53
            final DataManager dataManager = DALLocator.getDataManager();
54
            I18nManager i18n = ToolsLocator.getI18nManager();
55
            status.message(i18n.getTranslation("_Reading_xml"));
56
            status.setIndeterminate();
57
            
58
            SAXParserFactory spf = SAXParserFactory.newInstance();
59
            spf.setNamespaceAware(true);
60
            SAXParser saxParser = spf.newSAXParser();
61
            
62
            List<String> path = new ArrayList<>();
63
            
64
            saxParser.parse(is, new DefaultHandler() {
65
                private Locator locator;
66
                int size;
67
                int refreshInterval = 1;
68
                StringBuilder chars = new StringBuilder();
69
                
70
                @Override
71
                public void setDocumentLocator(Locator locator) {
72
                    this.locator = locator;
73
                }
74
                
75
                @Override
76
                public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
77
                    for (int i = 0; i < attributes.getLength(); i++) {
78
                        String name = attributes.getLocalName(i);                        
79
                        String value = attributes.getValue(i);
80
                        if( StringUtils.containsIgnoreCase(name, "srid") ) {
81
                            proj.setValue(getProjection(value));
82
                            if( proj.getValue() !=null ) {
83
                                throw new ProjectionExtractorException();
84
                            }
85
                        }
86
                    }
87
                    chars.setLength(0);
88
                }
89
                
90
                @Override
91
                public void endElement(String uri, String localName, String qName) throws SAXException {
92
                    String value = this.chars.toString();
93
                    if (StringUtils.containsIgnoreCase(localName, "srid")) {
94
                        proj.setValue(getProjection(value));
95
                        if (proj.getValue() != null) {
96
                            throw new ProjectionExtractorException();
97
                        }
98
                    }
99
                    chars.setLength(0);
100
                }
101
                
102
                @Override
103
                public void characters(char[] ch, int start, int length) throws SAXException {
104
                    this.chars.append(ch, start, length);
105
                }
106
                
107
                
108
            });
109
            return null;
110
        } catch (ProjectionExtractorException ex) {
111
            return proj.getValue();
112
        } catch (Exception ex) {
113
            throw new RuntimeException("Can't extract projection.", ex);
114
        }
115
    }
116
    
117
    private IProjection getProjection(String value) {
118
        if( StringUtils.isBlank(value) ) {
119
            return null;
120
        }
121
        IProjection proj = null;
122
        try {
123
            proj = CRSFactory.getCRS(value);
124
        } catch(Throwable t) {
125
            
126
        }
127
        if( proj != null ) {
128
            return proj;
129
        }
130
        try {
131
            proj = CRSFactory.getCRS("EPSG:"+value);
132
        } catch(Throwable t) {
133
            
134
        }
135
        return proj;
136
    }
137
    
138
    public IProjection extractProjection(File xml, Charset charset, SimpleTaskStatus status) {
139
        InputSource is = Xml2dbCommons.openReader(xml,charset);
140
        return extractProjection(is, status);
141
    }
142
    
143
    public IProjection extractProjection(InputStream xml, Charset charset, SimpleTaskStatus status)  {
144
        InputSource is = Xml2dbCommons.openReader(xml, charset);
145
        return extractProjection(is, status);
146
    }
147
    
148
    public IProjection extractProjection(Reader reader, SimpleTaskStatus status) {
149
        InputSource is = new InputSource(reader);
150
        return extractProjection(is, status);
151
    }
152
    
153
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/src/main/java/org/gvsig/xml2db/lib/impl/xmlinfo/XMLTableInfoImpl.java
16 16
import org.gvsig.fmap.dal.feature.EditableFeatureType;
17 17
import org.gvsig.fmap.dal.feature.FeatureType;
18 18
import org.gvsig.xml2db.lib.api.xmlinfo.XMLAttributeInfo;
19
import org.slf4j.Logger;
20
import org.slf4j.LoggerFactory;
19 21

  
20 22
/**
21 23
 *
......
23 25
 */
24 26
public class XMLTableInfoImpl implements XMLTableInfo {
25 27
    
28
    private static final Logger LOGGER = LoggerFactory.getLogger(XMLTableInfoImpl.class);
29
    
26 30
    private final String path;
27 31
    private final List<XMLAttributeInfo> attributes;
28 32
    private final XMLAttributeInfoImpl tagInfo;
......
48 52
    }
49 53

  
50 54
    public void add(XMLAttributeInfoImpl attrinfo) {
51
        // FIXME: comprobar si ya existe.
55
        // Comprobar si ya existe.
52 56
        for (XMLAttributeInfo info : attributes) {
53 57
            if (StringUtils.equalsIgnoreCase(attrinfo.getName(), info.getName())) {
54
                System.out.println("WARN: Tabla '" + this.getName() + "' campo '" + info.getName() + "' duplicado (" + attrinfo.getPath() + "," + info.getPath() + ")");
58
                LOGGER.warn("Duplicated field '" + info.getName() +" in Table '" + this.getName() + "' (" + attrinfo.getPath() + "," + info.getPath() + ")");
55 59
            }
56 60
        }
57 61
        this.attributes.add(attrinfo);
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.impl/pom.xml
73 73
        <dependency>
74 74
            <groupId>org.gvsig</groupId>
75 75
            <artifactId>org.gvsig.h2spatial.h2gis132.provider</artifactId>
76
            <scope>test</scope>
77 76
        </dependency>
78 77
        <dependency>
79 78
            <groupId>org.gvsig</groupId>
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.lib/org.gvsig.xml2db.lib.api/src/main/java/org/gvsig/xml2db/lib/api/Xml2dbManager.java
53 53
    public void copyXml2Db(File xml, Charset encoding, JDBCServerExplorerParameters dbparams, SimpleTaskStatus taskStatus);
54 54

  
55 55
    public void copyXml2Db(InputStream xml, Charset encoding, JDBCServerExplorerParameters dbparams, SimpleTaskStatus taskStatus);
56
    
57
    public Charset detectCharset(InputStream is);
58
    
59
    public Charset detectCharset(File file);
60

  
61
    public IProjection detectProjection(File file, SimpleTaskStatus status);
62

  
56 63
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.swing/org.gvsig.xml2db.swing.impl/src/main/java/org/gvsig/xml2db/swing/impl/createdbfromxml/CreatedbFromXmlPanel.java
168 168
        
169 169
        this.pickerXMLFile = toolsSwingManager.createFilePickerController(
170 170
                this.txtXMLFile, 
171
                this.btnXMLFile
171
                this.btnXMLFile,
172
                null,
173
                "Xml2db_xmlFile",
174
                null,
175
                true
176

  
172 177
        );
173 178
        this.pickerXMLFile.addChangeListener((ChangeEvent e) -> {
174 179
            doChangeXMLfile();
......
239 244
        toolsSwingManager.translate(this.btnAnalizeXML);
240 245
        toolsSwingManager.translate(this.btnViewTableStructure);
241 246
        toolsSwingManager.translate(this.lblRegisterConnection);
247
        toolsSwingManager.translate(this.lblOverwriteDatabase);
242 248
        toolsSwingManager.translate(this.lblLocale);
243 249
        
244 250
    }
......
269 275
        this.pickerCharset.setEnabled(true);
270 276
        this.pickerProjection.setEnabled(true);
271 277
        
278
        I18nManager i18n = ToolsLocator.getI18nManager();
272 279
        File xmlfile = this.pickerXMLFile.get();
273 280
        if( xmlfile == null || !xmlfile.exists() ) {
274 281
            if( xmlfile==null ) {
275
                this.message("_XML_file_is_required", JOptionPane.WARNING_MESSAGE);
282
                this.message(i18n.getTranslation("_XML_file_is_required"), JOptionPane.WARNING_MESSAGE);
276 283
            } else {
277
                this.message("_XML_file_not_exists", JOptionPane.WARNING_MESSAGE);
284
                this.message(i18n.getTranslation("_XML_file_not_exists"), JOptionPane.WARNING_MESSAGE);
278 285
            }
279 286
            this.btnAnalizeXML.setEnabled(false);
280 287
            this.lstTables.setEnabled(false);
......
287 294
        this.btnAnalizeXML.setEnabled(true);
288 295
        if( this.lstTables.getModel().getSize()<1 ) {
289 296
            if( this.xmlinfo == null ) {
290
                this.message("_Analize_XML_required", JOptionPane.WARNING_MESSAGE);
297
                this.message(i18n.getTranslation("_Analize_XML_required"), JOptionPane.WARNING_MESSAGE);
291 298
            } else {
292
                this.message("_No_tables_recognized_in_the_XML", JOptionPane.WARNING_MESSAGE);
299
                this.message(i18n.getTranslation("_No_tables_recognized_in_the_XML"), JOptionPane.WARNING_MESSAGE);
293 300
            }
294 301
            this.btnViewTableStructure.setEnabled(false);
295 302
            if( this.dialog!=null ) {
......
310 317
        this.btnViewTableStructure.setEnabled(true);
311 318
        File dbfile = this.pickerDbfile.get();
312 319
        if( dbfile == null ) {
313
            this.message("_Database_file_is_required", JOptionPane.WARNING_MESSAGE);
320
            this.message(i18n.getTranslation("_Database_file_is_required"), JOptionPane.WARNING_MESSAGE);
314 321
            if( this.dialog!=null ) {
315 322
                this.dialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, false);
316 323
            }
317 324
            return;
318 325
        }
319 326
        if( H2SpatialUtils.existsH2db(dbfile) && !this.chkOverwriteDatabase.isSelected() ) {
320
            this.message("_Database_file_already_exists", JOptionPane.WARNING_MESSAGE);
327
            this.message(i18n.getTranslation("_Database_file_already_exists"), JOptionPane.WARNING_MESSAGE);
321 328
            if( this.dialog!=null ) {
322 329
                this.dialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, false);
323 330
            }
324 331
            return;
325 332
        }
326 333
        if( StringUtils.isBlank(this.txtRepositoryName.getText()) ) {
327
            this.message("_Repository_name_is_required", JOptionPane.WARNING_MESSAGE);
334
            this.message(i18n.getTranslation("_Repository_name_is_required"), JOptionPane.WARNING_MESSAGE);
328 335
            if( this.dialog!=null ) {
329 336
                this.dialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, false);
330 337
            }
......
369 376
        
370 377
        Xml2dbManager manager = Xml2dbLocator.getXml2dbManager();
371 378
        
379
        I18nManager i18n = ToolsLocator.getI18nManager();
372 380
        if( H2SpatialUtils.existsH2db(dbfile) ) {
373 381
            if( !this.chkOverwriteDatabase.isSelected() ) {
374
                message("Database already exists", JOptionPane.WARNING_MESSAGE);
382
                message(i18n.getTranslation("Database already exists"), JOptionPane.WARNING_MESSAGE);
375 383
                return;
376 384
            }
377 385
        }        
378 386
        
379 387
        this.lastTask = new Task(                
380 388
                "Xml2db_Creating_database", 
381
                "Create databse", 
389
                i18n.getTranslation("_Create_database"), 
382 390
                this::updateStateComponents, 
383 391
                taskStatusController
384 392
            ) {
......
386 394
            protected void task(SimpleTaskStatus taskStatus) throws Throwable{
387 395
                try {
388 396
                    if( H2SpatialUtils.existsH2db(dbfile) ) {
389
                        taskStatus.message("Removing existing database...");
397
                        taskStatus.message(i18n.getTranslation("_Removing_existing_database"));
390 398
                        H2SpatialUtils.server_stop();
391 399
                        H2SpatialUtils.removeH2db(dbfile);
392 400
                        H2SpatialUtils.server_start();
......
428 436
        IProjection proj = this.pickerProjection.get();
429 437
        Charset charset = this.pickerCharset.get();
430 438
        Locale locale = this.pickerLocale.get();
439
        
440
        I18nManager i18n = ToolsLocator.getI18nManager();
431 441

  
432 442
        this.lastTask = new Task(                
433 443
                "Xml2db_AnalizeXML", 
434
                "Analize XML", 
444
                i18n.getTranslation("_Analize_xml"), 
435 445
                this::updateStateComponents, 
436 446
                taskStatusController
437 447
            ) {
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.swing/org.gvsig.xml2db.swing.impl/src/main/java/org/gvsig/xml2db/swing/impl/copyxml2db/CopyXml2dbPanelView.xml
25 25
    <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
26 26
   </super>
27 27
   <at name="id">/home/fdiaz/projects/gvSIG/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.swing/org.gvsig.xml2db.swing.impl/src/main/java/org/gvsig/xml2db/swing/impl/copyxml2db/CopyXml2dbPanelView.xml</at>
28
   <at name="path">projects/gvSIG/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.swing/org.gvsig.xml2db.swing.impl/src/main/java/org/gvsig/xml2db/swing/impl/copyxml2db/CopyXml2dbPanelView.xml</at>
28 29
   <at name="rowspecs">CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE</at>
29 30
   <at name="colspecs">FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE</at>
30 31
   <at name="components">
......
389 390
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
390 391
         <at name="cellconstraints">
391 392
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
392
           <at name="column">4</at>
393
           <at name="row">4</at>
394
           <at name="colspan">1</at>
395
           <at name="rowspan">1</at>
396
           <at name="halign">default</at>
397
           <at name="valign">default</at>
398
           <at name="insets" object="insets">0,0,0,0</at>
399
          </object>
400
         </at>
401
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
402
        </super>
403
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
404
        <at name="beanclass">javax.swing.JComboBox</at>
405
        <at name="beanproperties">
406
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
407
          <at name="classname">javax.swing.JComboBox</at>
408
          <at name="properties">
409
           <object classname="com.jeta.forms.store.support.PropertyMap">
410
            <at name="border">
411
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
412
              <super classname="com.jeta.forms.store.properties.BorderProperty">
413
               <at name="name">border</at>
414
              </super>
415
              <at name="borders">
416
               <object classname="java.util.LinkedList">
417
                <item >
418
                 <at name="value">
419
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
420
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
421
                    <at name="name">border</at>
422
                   </super>
423
                  </object>
424
                 </at>
425
                </item>
426
               </object>
427
              </at>
428
             </object>
429
            </at>
430
            <at name="name">cboCharset</at>
431
            <at name="width">1244</at>
432
            <at name="items">
433
             <object classname="com.jeta.forms.store.properties.ItemsProperty">
434
              <at name="name">items</at>
435
             </object>
436
            </at>
437
            <at name="height">23</at>
438
           </object>
439
          </at>
440
         </object>
441
        </at>
442
       </object>
443
      </at>
444
     </item>
445
     <item >
446
      <at name="value">
447
       <object classname="com.jeta.forms.store.memento.BeanMemento">
448
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
449
         <at name="cellconstraints">
450
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
451 393
           <at name="column">2</at>
452 394
           <at name="row">14</at>
453 395
           <at name="colspan">1</at>
......
861 803
         </at>
862 804
         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
863 805
        </super>
864
        <at name="id">embedded.85857317</at>
806
        <at name="id">embedded.1607532145</at>
865 807
        <at name="rowspecs">CENTER:DEFAULT:NONE</at>
866 808
        <at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE</at>
867 809
        <at name="components">
......
997 939
              </at>
998 940
             </object>
999 941
            </at>
1000
            <at name="name"/>
942
            <at name="name"></at>
1001 943
            <at name="fill">
1002 944
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
1003 945
              <at name="name">fill</at>
......
1079 1021
         </at>
1080 1022
         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
1081 1023
        </super>
1082
        <at name="id">embedded.558568929</at>
1024
        <at name="id">embedded.755604414</at>
1083 1025
        <at name="rowspecs">CENTER:DEFAULT:NONE</at>
1084 1026
        <at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE</at>
1085 1027
        <at name="components">
......
1297 1239
         </at>
1298 1240
         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
1299 1241
        </super>
1300
        <at name="id">embedded.1771557635</at>
1242
        <at name="id">embedded.1522030949</at>
1301 1243
        <at name="rowspecs">CENTER:DEFAULT:NONE</at>
1302
        <at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE</at>
1244
        <at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE</at>
1303 1245
        <at name="components">
1304 1246
         <object classname="java.util.LinkedList">
1305 1247
          <item >
......
1347 1289
                  </object>
1348 1290
                 </at>
1349 1291
                 <at name="name">txtProjection</at>
1350
                 <at name="width">1211</at>
1292
                 <at name="width">1179</at>
1351 1293
                 <at name="height">21</at>
1352 1294
                </object>
1353 1295
               </at>
......
1416 1358
            </object>
1417 1359
           </at>
1418 1360
          </item>
1361
          <item >
1362
           <at name="value">
1363
            <object classname="com.jeta.forms.store.memento.BeanMemento">
1364
             <super classname="com.jeta.forms.store.memento.ComponentMemento">
1365
              <at name="cellconstraints">
1366
               <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
1367
                <at name="column">5</at>
1368
                <at name="row">1</at>
1369
                <at name="colspan">1</at>
1370
                <at name="rowspan">1</at>
1371
                <at name="halign">default</at>
1372
                <at name="valign">default</at>
1373
                <at name="insets" object="insets">0,0,0,0</at>
1374
               </object>
1375
              </at>
1376
              <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
1377
             </super>
1378
             <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
1379
             <at name="beanclass">javax.swing.JButton</at>
1380
             <at name="beanproperties">
1381
              <object classname="com.jeta.forms.store.memento.PropertiesMemento">
1382
               <at name="classname">javax.swing.JButton</at>
1383
               <at name="properties">
1384
                <object classname="com.jeta.forms.store.support.PropertyMap">
1385
                 <at name="border">
1386
                  <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
1387
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
1388
                    <at name="name">border</at>
1389
                   </super>
1390
                   <at name="borders">
1391
                    <object classname="java.util.LinkedList">
1392
                     <item >
1393
                      <at name="value">
1394
                       <object classname="com.jeta.forms.store.properties.EmptyBorderProperty">
1395
                        <super classname="com.jeta.forms.store.properties.BorderProperty">
1396
                         <at name="name">border</at>
1397
                        </super>
1398
                        <at name="top">2</at>
1399
                        <at name="left">2</at>
1400
                        <at name="bottom">2</at>
1401
                        <at name="right">2</at>
1402
                       </object>
1403
                      </at>
1404
                     </item>
1405
                    </object>
1406
                   </at>
1407
                  </object>
1408
                 </at>
1409
                 <at name="actionCommand">...</at>
1410
                 <at name="icon">
1411
                  <object classname="com.jeta.forms.store.properties.IconProperty">
1412
                   <at name="embedded">false</at>
1413
                   <at name="path">projects/gvSIG/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.swing/org.gvsig.xml2db.swing.impl/src/main/resources/org/gvsig/xml2db/swing/impl/images/detect-crs.png</at>
1414
                   <at name="description">detect-crs.png</at>
1415
                   <at name="width">16</at>
1416
                   <at name="height">16</at>
1417
                  </object>
1418
                 </at>
1419
                 <at name="name">btnDetectProjection</at>
1420
                 <at name="width">20</at>
1421
                 <at name="toolTipText">_Detect_projection</at>
1422
                 <at name="height">20</at>
1423
                </object>
1424
               </at>
1425
              </object>
1426
             </at>
1427
            </object>
1428
           </at>
1429
          </item>
1419 1430
         </object>
1420 1431
        </at>
1421 1432
        <at name="properties">
......
1475 1486
          <at name="rows">
1476 1487
           <object classname="[Ljava.lang.Object;" size="1">
1477 1488
            <at name="item" index="0">
1478
             <object classname="[Ljava.lang.Object;" size="3"/>
1489
             <object classname="[Ljava.lang.Object;" size="5"/>
1479 1490
            </at>
1480 1491
           </object>
1481 1492
          </at>
......
1515 1526
         </at>
1516 1527
         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
1517 1528
        </super>
1518
        <at name="id">embedded.428774731</at>
1529
        <at name="id">embedded.1755156374</at>
1519 1530
        <at name="rowspecs">CENTER:MAX(12DLU;DEFAULT):NONE,CENTER:MAX(12DLU;DEFAULT):NONE,CENTER:MAX(12DLU;DEFAULT):NONE</at>
1520 1531
        <at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE</at>
1521 1532
        <at name="components">
......
1841 1852
       </object>
1842 1853
      </at>
1843 1854
     </item>
1855
     <item >
1856
      <at name="value">
1857
       <object classname="com.jeta.forms.store.memento.FormMemento">
1858
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
1859
         <at name="cellconstraints">
1860
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
1861
           <at name="column">4</at>
1862
           <at name="row">4</at>
1863
           <at name="colspan">1</at>
1864
           <at name="rowspan">1</at>
1865
           <at name="halign">default</at>
1866
           <at name="valign">default</at>
1867
           <at name="insets" object="insets">0,0,0,0</at>
1868
          </object>
1869
         </at>
1870
         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
1871
        </super>
1872
        <at name="id">embedded.1899537280</at>
1873
        <at name="rowspecs">CENTER:DEFAULT:NONE</at>
1874
        <at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE</at>
1875
        <at name="components">
1876
         <object classname="java.util.LinkedList">
1877
          <item >
1878
           <at name="value">
1879
            <object classname="com.jeta.forms.store.memento.BeanMemento">
1880
             <super classname="com.jeta.forms.store.memento.ComponentMemento">
1881
              <at name="cellconstraints">
1882
               <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
1883
                <at name="column">3</at>
1884
                <at name="row">1</at>
1885
                <at name="colspan">1</at>
1886
                <at name="rowspan">1</at>
1887
                <at name="halign">default</at>
1888
                <at name="valign">default</at>
1889
                <at name="insets" object="insets">0,0,0,0</at>
1890
               </object>
1891
              </at>
1892
              <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
1893
             </super>
1894
             <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
1895
             <at name="beanclass">javax.swing.JButton</at>
1896
             <at name="beanproperties">
1897
              <object classname="com.jeta.forms.store.memento.PropertiesMemento">
1898
               <at name="classname">javax.swing.JButton</at>
1899
               <at name="properties">
1900
                <object classname="com.jeta.forms.store.support.PropertyMap">
1901
                 <at name="border">
1902
                  <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
1903
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
1904
                    <at name="name">border</at>
1905
                   </super>
1906
                   <at name="borders">
1907
                    <object classname="java.util.LinkedList">
1908
                     <item >
1909
                      <at name="value">
1910
                       <object classname="com.jeta.forms.store.properties.EmptyBorderProperty">
1911
                        <super classname="com.jeta.forms.store.properties.BorderProperty">
1912
                         <at name="name">border</at>
1913
                        </super>
1914
                        <at name="top">2</at>
1915
                        <at name="left">2</at>
1916
                        <at name="bottom">2</at>
1917
                        <at name="right">2</at>
1918
                       </object>
1919
                      </at>
1920
                     </item>
1921
                    </object>
1922
                   </at>
1923
                  </object>
1924
                 </at>
1925
                 <at name="actionCommand">...</at>
1926
                 <at name="icon">
1927
                  <object classname="com.jeta.forms.store.properties.IconProperty">
1928
                   <at name="embedded">false</at>
1929
                   <at name="path">projects/gvSIG/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.swing/org.gvsig.xml2db.swing.impl/src/main/resources/org/gvsig/xml2db/swing/impl/images/detect-charset.png</at>
1930
                   <at name="description">detect-charset.png</at>
1931
                   <at name="width">16</at>
1932
                   <at name="height">16</at>
1933
                  </object>
1934
                 </at>
1935
                 <at name="name">btnDetectCharset</at>
1936
                 <at name="width">20</at>
1937
                 <at name="toolTipText">_Detect_charset</at>
1938
                 <at name="height">20</at>
1939
                </object>
1940
               </at>
1941
              </object>
1942
             </at>
1943
            </object>
1944
           </at>
1945
          </item>
1946
          <item >
1947
           <at name="value">
1948
            <object classname="com.jeta.forms.store.memento.BeanMemento">
1949
             <super classname="com.jeta.forms.store.memento.ComponentMemento">
1950
              <at name="cellconstraints">
1951
               <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
1952
                <at name="column">1</at>
1953
                <at name="row">1</at>
1954
                <at name="colspan">1</at>
1955
                <at name="rowspan">1</at>
1956
                <at name="halign">default</at>
1957
                <at name="valign">default</at>
1958
                <at name="insets" object="insets">0,0,0,0</at>
1959
               </object>
1960
              </at>
1961
              <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
1962
             </super>
1963
             <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
1964
             <at name="beanclass">javax.swing.JComboBox</at>
1965
             <at name="beanproperties">
1966
              <object classname="com.jeta.forms.store.memento.PropertiesMemento">
1967
               <at name="classname">javax.swing.JComboBox</at>
1968
               <at name="properties">
1969
                <object classname="com.jeta.forms.store.support.PropertyMap">
1970
                 <at name="border">
1971
                  <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
1972
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
1973
                    <at name="name">border</at>
1974
                   </super>
1975
                   <at name="borders">
1976
                    <object classname="java.util.LinkedList">
1977
                     <item >
1978
                      <at name="value">
1979
                       <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
1980
                        <super classname="com.jeta.forms.store.properties.BorderProperty">
1981
                         <at name="name">border</at>
1982
                        </super>
1983
                       </object>
1984
                      </at>
1985
                     </item>
1986
                    </object>
1987
                   </at>
1988
                  </object>
1989
                 </at>
1990
                 <at name="name">cboCharset</at>
1991
                 <at name="width">1207</at>
1992
                 <at name="items">
1993
                  <object classname="com.jeta.forms.store.properties.ItemsProperty">
1994
                   <at name="name">items</at>
1995
                  </object>
1996
                 </at>
1997
                 <at name="height">23</at>
1998
                </object>
1999
               </at>
2000
              </object>
2001
             </at>
2002
            </object>
2003
           </at>
2004
          </item>
2005
         </object>
2006
        </at>
2007
        <at name="properties">
2008
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
2009
          <at name="classname">com.jeta.forms.gui.form.GridView</at>
2010
          <at name="properties">
2011
           <object classname="com.jeta.forms.store.support.PropertyMap">
2012
            <at name="border">
2013
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
2014
              <super classname="com.jeta.forms.store.properties.BorderProperty">
2015
               <at name="name">border</at>
2016
              </super>
2017
              <at name="borders">
2018
               <object classname="java.util.LinkedList"/>
2019
              </at>
2020
             </object>
2021
            </at>
2022
            <at name="name"></at>
2023
            <at name="fill">
2024
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
2025
              <at name="name">fill</at>
2026
             </object>
2027
            </at>
2028
            <at name="scollBars">
2029
             <object classname="com.jeta.forms.store.properties.ScrollBarsProperty">
2030
              <at name="name">scollBars</at>
2031
              <at name="verticalpolicy">21</at>
2032
              <at name="horizontalpolicy">31</at>
2033
              <at name="border">
2034
               <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
2035
                <super classname="com.jeta.forms.store.properties.BorderProperty">
2036
                 <at name="name">border</at>
2037
                </super>
2038
                <at name="borders">
2039
                 <object classname="java.util.LinkedList">
2040
                  <item >
2041
                   <at name="value">
2042
                    <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
2043
                     <super classname="com.jeta.forms.store.properties.BorderProperty">
2044
                      <at name="name">border</at>
2045
                     </super>
2046
                    </object>
2047
                   </at>
2048
                  </item>
2049
                 </object>
2050
                </at>
2051
               </object>
2052
              </at>
2053
             </object>
2054
            </at>
2055
           </object>
2056
          </at>
2057
         </object>
2058
        </at>
2059
        <at name="cellpainters">
2060
         <object classname="com.jeta.forms.store.support.Matrix">
2061
          <at name="rows">
2062
           <object classname="[Ljava.lang.Object;" size="1">
2063
            <at name="item" index="0">
2064
             <object classname="[Ljava.lang.Object;" size="3"/>
2065
            </at>
2066
           </object>
2067
          </at>
2068
         </object>
2069
        </at>
2070
        <at name="rowgroups">
2071
         <object classname="com.jeta.forms.store.memento.FormGroupSet">
2072
          <at name="groups">
2073
           <object classname="java.util.HashMap"/>
2074
          </at>
2075
         </object>
2076
        </at>
2077
        <at name="colgroups">
2078
         <object classname="com.jeta.forms.store.memento.FormGroupSet">
2079
          <at name="groups">
2080
           <object classname="java.util.HashMap"/>
2081
          </at>
2082
         </object>
2083
        </at>
2084
       </object>
2085
      </at>
2086
     </item>
1844 2087
    </object>
1845 2088
   </at>
1846 2089
   <at name="properties">
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.swing/org.gvsig.xml2db.swing.impl/src/main/java/org/gvsig/xml2db/swing/impl/copyxml2db/CopyXml2dbPanelView.java
28 28
   JTextField txtRepositoryName = new JTextField();
29 29
   JLabel lblProjection = new JLabel();
30 30
   JLabel lblCharset = new JLabel();
31
   JComboBox cboCharset = new JComboBox();
32 31
   JLabel lblRegisterConnection = new JLabel();
33 32
   JCheckBox chkRegisterConnection = new JCheckBox();
34 33
   JLabel lblConnectToRepository = new JLabel();
......
42 41
   JTextField txtDatabaseFile = new JTextField();
43 42
   JTextField txtProjection = new JTextField();
44 43
   JButton btnProjection = new JButton();
44
   JButton btnDetectProjection = new JButton();
45 45
   JLabel lblStatusCaption = new JLabel();
46 46
   JLabel lblStatusMsg = new JLabel();
47 47
   JProgressBar pbStatus = new JProgressBar();
48 48
   JComboBox cboLocale = new JComboBox();
49
   JButton btnDetectCharset = new JButton();
50
   JComboBox cboCharset = new JComboBox();
49 51

  
50 52
   /**
51 53
    * Default constructor
......
164 166
      lblCharset.setText("_Charset");
165 167
      jpanel1.add(lblCharset,cc.xy(2,4));
166 168

  
167
      cboCharset.setName("cboCharset");
168
      jpanel1.add(cboCharset,cc.xy(4,4));
169

  
170 169
      lblRegisterConnection.setName("lblRegisterConnection");
171 170
      lblRegisterConnection.setText("_Register_connection");
172 171
      jpanel1.add(lblRegisterConnection,cc.xy(2,14));
......
199 198
      cboLocale.setName("cboLocale");
200 199
      jpanel1.add(cboLocale,cc.xy(4,6));
201 200

  
201
      jpanel1.add(createPanel5(),cc.xy(4,4));
202 202
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21 });
203 203
      return jpanel1;
204 204
   }
......
248 248
   public JPanel createPanel3()
249 249
   {
250 250
      JPanel jpanel1 = new JPanel();
251
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
251
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
252 252
      CellConstraints cc = new CellConstraints();
253 253
      jpanel1.setLayout(formlayout1);
254 254

  
......
262 262
      btnProjection.setBorder(emptyborder1);
263 263
      jpanel1.add(btnProjection,cc.xy(3,1));
264 264

  
265
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
265
      btnDetectProjection.setActionCommand("...");
266
      btnDetectProjection.setIcon(loadImage("projects/gvSIG/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.swing/org.gvsig.xml2db.swing.impl/src/main/resources/org/gvsig/xml2db/swing/impl/images/detect-crs.png"));
267
      btnDetectProjection.setName("btnDetectProjection");
268
      btnDetectProjection.setToolTipText("_Detect_projection");
269
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
270
      btnDetectProjection.setBorder(emptyborder2);
271
      jpanel1.add(btnDetectProjection,cc.xy(5,1));
272

  
273
      addFillComponents(jpanel1,new int[]{ 2,4 },new int[0]);
266 274
      return jpanel1;
267 275
   }
268 276

  
......
287 295
      return jpanel1;
288 296
   }
289 297

  
298
   public JPanel createPanel5()
299
   {
300
      JPanel jpanel1 = new JPanel();
301
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
302
      CellConstraints cc = new CellConstraints();
303
      jpanel1.setLayout(formlayout1);
304

  
305
      btnDetectCharset.setActionCommand("...");
306
      btnDetectCharset.setIcon(loadImage("projects/gvSIG/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.swing/org.gvsig.xml2db.swing.impl/src/main/resources/org/gvsig/xml2db/swing/impl/images/detect-charset.png"));
307
      btnDetectCharset.setName("btnDetectCharset");
308
      btnDetectCharset.setToolTipText("_Detect_charset");
309
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
310
      btnDetectCharset.setBorder(emptyborder1);
311
      jpanel1.add(btnDetectCharset,cc.xy(3,1));
312

  
313
      cboCharset.setName("cboCharset");
314
      jpanel1.add(cboCharset,cc.xy(1,1));
315

  
316
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
317
      return jpanel1;
318
   }
319

  
290 320
   /**
291 321
    * Initializer
292 322
    */
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.swing/org.gvsig.xml2db.swing.impl/src/main/java/org/gvsig/xml2db/swing/impl/copyxml2db/CopyXml2dbPanel.java
22 22
 */
23 23
package org.gvsig.xml2db.swing.impl.copyxml2db;
24 24

  
25
import org.gvsig.xml2db.swing.impl.Task;
26 25
import java.awt.Color;
26
import java.awt.event.ActionEvent;
27 27
import java.io.File;
28
import java.nio.charset.Charset;
28 29
import java.util.ArrayList;
29 30
import java.util.List;
31
import java.util.Locale;
30 32
import javax.swing.AbstractListModel;
33
import javax.swing.ImageIcon;
31 34
import javax.swing.JComponent;
32
import org.cresques.cts.IProjection;
33
import java.nio.charset.Charset;
34
import java.util.Locale;
35 35
import javax.swing.JOptionPane;
36 36
import javax.swing.SwingUtilities;
37 37
import javax.swing.event.ChangeEvent;
38 38
import org.apache.commons.io.FilenameUtils;
39 39
import org.apache.commons.lang3.StringUtils;
40
import org.cresques.cts.IProjection;
40 41
import org.gvsig.fmap.dal.DALLocator;
41 42
import org.gvsig.fmap.dal.DataManager;
42 43
import org.gvsig.fmap.dal.store.h2.H2SpatialUtils;
......
44 45
import org.gvsig.fmap.dal.swing.DALSwingLocator;
45 46
import org.gvsig.fmap.dal.swing.DataSwingManager;
46 47
import org.gvsig.fmap.dal.swing.ProjectionPickerController;
48
import org.gvsig.tools.ToolsLocator;
49
import org.gvsig.tools.i18n.I18nManager;
47 50
import org.gvsig.tools.swing.api.ToolsSwingLocator;
48 51
import org.gvsig.tools.swing.api.ToolsSwingManager;
49 52
import org.gvsig.tools.swing.api.ToolsSwingUtils;
......
61 64
import org.gvsig.xml2db.lib.api.xmlinfo.XMLInfo;
62 65
import org.gvsig.xml2db.lib.api.xmlinfo.XMLTableInfo;
63 66
import org.gvsig.xml2db.swing.Xml2dbPanel;
67
import org.gvsig.xml2db.swing.impl.Task;
64 68
import org.gvsig.xml2db.swing.impl.Xml2dbSwingCommons;
65 69
import org.slf4j.Logger;
66 70
import org.slf4j.LoggerFactory;
......
155 159
        
156 160
        this.pickerXMLFile = toolsSwingManager.createFilePickerController(
157 161
                this.txtXMLFile, 
158
                this.btnXMLFile
162
                this.btnXMLFile,
163
                null,
164
                "Xml2db_xmlFile",
165
                null,
166
                true
159 167
        );
160 168
        this.pickerXMLFile.addChangeListener((ChangeEvent e) -> {
161 169
            doChangeXMLfile();
......
166 174
                this.cboCharset
167 175
        );
168 176
        
177
        this.btnDetectCharset.addActionListener((ActionEvent e) -> {
178
            doDetectCharset();
179
        });
180
        
169 181
        this.pickerProjection = dataSwingManager.createProjectionPickerController(
170 182
                this.txtProjection, 
171 183
                this.btnProjection
172 184
        );
173 185
        
186
        this.btnDetectProjection.addActionListener((ActionEvent e) -> {
187
            doDetectProjection();
188
        });
189
        
174 190
        this.pickerDbfile = toolsSwingManager.createFilePickerController(
175 191
                this.txtDatabaseFile, 
176 192
                this.btnDataBaseFile
......
197 213
        
198 214
        SwingUtilities.invokeLater(() -> { updateStateComponents(); });
199 215
        
200
        ToolsSwingUtils.ensureRowsCols(this, 14, 80, 16, 100);
216
        ToolsSwingUtils.ensureRowsCols(this, 15, 80, 17, 100);
201 217
    }
202 218

  
203 219
    private void translate() {
......
212 228
        toolsSwingManager.translate(this.lblConnectToRepository);
213 229
        toolsSwingManager.translate(this.lblOverwriteDatabase);
214 230
        toolsSwingManager.translate(this.lblLocale);
231
        toolsSwingManager.translate(this.btnDetectProjection);
232
        toolsSwingManager.translate(this.btnDetectCharset);
233
        
215 234
    }
216 235
    
217 236
    private boolean isProcessing() {
......
227 246
            this.pickerXMLFile.setEnabled(false);
228 247
            this.pickerCharset.setEnabled(false);
229 248
            this.pickerProjection.setEnabled(false);
249
            this.btnDetectCharset.setEnabled(false);
250
            this.btnDetectProjection.setEnabled(false);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff