Matthias,

I wonder if it might be worth checking out the current GeoTools code
for loading shapefiles, which already works with Charsets? I have done
some work on code that allows you to obtain JUMP feature objects from
th GeoTools shapefile driver.

It seems logical to store the last used charset with the project file.

Did we decide to set a default charset?

The Sunburned Surveyor

On Mon, Sep 6, 2010 at 3:01 PM, Matthias Scholz <m...@jammerhund.de> wrote:
> Hi Michaël,
> hi all other,
>
> sorry for my delay, but my internet connection was down at the weekend,
> so it was not possible for me to answer or commit any changes.
>
> 1. Charset setting for filednames
> I've seen, that my enhanchements do not include the fieldnames in the
> dbf header. To integrate the charset stuff for the filednames I had to
> change some method signatures (add Charset parameter). Because I do not
> know how is using the methods, I have build the "old"  methods as a
> wrapper which is calling the "new" one with charset option. I hope thats
> the right way. As example please see the constructor of
> org.geotools.dbffile.DbfFile.
> In DbfFile I've removed the get/setCharset methods because the
> filednames will be read within the constructor(DbfFile->init->for() loop
> at the end). And to read the fieldnames with one charset, then set an
> other one and read the data with that makes no sense for me.
>
>
> 2. Save dataset as shapefile with charset settings
> If we have an option while opening, we should have an equivalent one
> while saving. But the save mechanism is not so simple as the open
> wizard. So there are more code changes required.
> In org.geotools.dbffile.DbfFileWriter added charset stuff.
> In
> com.vividsolutions.jump.workbench.datasource.InstallStandardDataSourceQueryChoosersPlugIn.addFileDataSourceQueryChoosers()
> I've added a combobox for the charset if we saving shapefiles. I don't
> if this is the right place or if this is a little bit ugly. In the
> future we should go a uniform way for such options. For GML as example
> we have a separate installer plugin. I would suggest a kind of save
> wizard(as the open file wizard and FileLoader options) where you can add
> simply options for save.
>
>
> 3. org.openjump.OpenJumpConfiguration
> I've changed the key of the charset option. Now we use a non localized
> key. This is better for saving in the project configuration. On the
> other hand in
> org.openjump.core.ui.plugin.file.open.SelectFileOptionsPanel.addIndividualSettingsFields()
> there is a nice mechanism for translating the option keys.  But this was
> not used/activated in line 168. I hope no one have a problem with the
> change in line 168.
> As a consquence I had to change the language key from
> "org.openjump.core.ui.plugin.file.charset" to
> "org.openjump.core.ui.io.file.DataSourceFileLayerLoader.charset".
>
>
> 4. org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn
> I've added the view of the charset settings, if the datasource is a
> shapefile.
>
>
> 5. com.vividsolutions.jump.io.ShapefileReader
> In the read() method I've moved back the charset code outsite the "if (
> mydbf == null )" brunch,
> for reading the fieldnames with charset. The new code is "non-dbf" save
> too. I do not know before, that Shape files without Dbf files are
> possible. This was a new fact for me ;-)
> The getDbfFile() method I had to change for reading the fieldnames with
> a charset.
>
>
> 6. Save/restore charset setting to/from project configuration
> I had nothing to do for that. The Option mechanism for FileLayerLoaders
> in combination with the OpenFileWizard do this automatically, if you add
> an Option :-)
>
>
> Regards
>
> Matthias
>
>>   Hi Matthias,
>>
>> I just moved the setCharset statement of ShapefileReader after the dbf
>> != null test, because otherwise it broke the reading of shapefiles
>> without dbf (which is not a very common case, but still a nice feature)
>> If you want to check, I just commited.
>>
>> Michaël
>>
>> Le 03/09/2010 23:50, Michaël Michaud a écrit :
>>
>>>    Hi Matthias,
>>>
>>>
>>>> Can you give me some information about how it is supposed to work. Am I
>>>> supposed to get a panel with a charset option for any shapefile loading ?
>>>>
>>> Sorry for that question, I did not launch the new compiled version. I
>>> know get the charset choice dialog.
>>>
>>> Thanks,
>>>
>>> Michaël
>>>
>>>
>>>> 2) if we want to keep java 5 compatibility, you have to use new
>>>> String(byte[], int, int, String) instead of new String(byte[], int, int,
>>>> Charset) on line 264
>>>>
>>>> 3) about your proposition of saving the charset in the project when
>>>> different from default jvm charset : Seems a good idea to me.
>>>>
>>>> Michaël
>>>>
>>>> Le 03/09/2010 20:34, Matthias Scholz a écrit :
>>>>
>>>>> Hi,
>>>>>
>>>>> sorry my mistake. I have it only tested with open and open recent ;-) In
>>>>> the SVN it is fixed for the first time, but there is a general question
>>>>> and I want to hear the other developers/users. If I open a shapefile
>>>>> with a special charset setting for the first time, it would be logic for
>>>>> me, if we save the charset setting for this file in the project. So if
>>>>> the user opens this file again with the project, the file will be opened
>>>>> with the same charset.
>>>>> Should I implement this or have anyone an other suggestion?
>>>>>
>>>>> Regards
>>>>>
>>>>> Matthias
>>>>>
>>>>>> Nice feature, but it is going to take a little more work.  It
>>>>>> currently breaks shapefile loading from a project file and the
>>>>>> lright-click on layer legacy method "Load Dataset".  I think you need
>>>>>> to set a default charset on start up.
>>>>>>
>>>>>> regards,
>>>>>>
>>>>>> Larry
>>>>>>
>>>>>> java.lang.IllegalArgumentException: Null charset name
>>>>>>        at java.nio.charset.Charset.lookup(Charset.java:430)
>>>>>>        at java.nio.charset.Charset.forName(Charset.java:503)
>>>>>>        at
>>>>>> com.vividsolutions.jump.io.ShapefileReader.read(ShapefileReader.java:137)
>>>>>>        at
>>>>>> com.vividsolutions.jump.io.datasource.DelegatingCompressedFileHandler.read(DelegatingCompressedFileHandler.java:79)
>>>>>>        at
>>>>>> com.vividsolutions.jump.io.datasource.ReaderWriterFileDataSource$1.executeQuery(ReaderWriterFileDataSource.java:61)
>>>>>>        at
>>>>>> com.vividsolutions.jump.io.datasource.ReaderWriterFileDataSource$1.executeQuery(ReaderWriterFileDataSource.java:79)
>>>>>>        at
>>>>>> org.openjump.core.ui.plugin.file.open.OpenProjectWizard.executeQuery(OpenProjectWizard.java:282)
>>>>>>        at
>>>>>> org.openjump.core.ui.plugin.file.open.OpenProjectWizard.load(OpenProjectWizard.java:271)
>>>>>>        at
>>>>>> org.openjump.core.ui.plugin.file.open.OpenProjectWizard.loadLayers(OpenProjectWizard.java:208)
>>>>>>        at
>>>>>> org.openjump.core.ui.plugin.file.open.OpenProjectWizard.open(OpenProjectWizard.java:152)
>>>>>>        at
>>>>>> org.openjump.core.ui.plugin.file.open.OpenProjectWizard.open(OpenProjectWizard.java:107)
>>>>>>        at
>>>>>> org.openjump.core.ui.plugin.file.open.OpenProjectWizard.run(OpenProjectWizard.java:99)
>>>>>>        at
>>>>>> org.openjump.core.ui.plugin.AbstractWizardPlugin.run(AbstractWizardPlugin.java:71)
>>>>>>        at
>>>>>> com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager$TaskWrapper.run(TaskMonitorManager.java:151)
>>>>>>        at java.lang.Thread.run(Thread.java:619)
>>>>>>
>>>>>> On Fri, Sep 3, 2010 at 4:46 AM, Matthias Scholz<m...@jammerhund.de
>>>>>> <mailto:m...@jammerhund.de>>    wrote:
>>>>>>
>>>>>>        Hi,
>>>>>>
>>>>>>        I've commited some little changes for selecting an other charset 
>>>>>> while
>>>>>>        opening an ESRI shapefile.
>>>>>>        Thank you Michael and Stefan for your hints to the wizard 
>>>>>> framework.
>>>>>>        Thereby the code changes was very small and consitent :-) On the 
>>>>>> other
>>>>>>        hand Michael is right with his opinion about the wizard framework.
>>>>>>        Without good documentation you need many hours to understand and
>>>>>>        implement such options for file loading.
>>>>>>        Please take a look at my changes and tell me your opinion.
>>>>>>        In the language files (en and de) I've added a
>>>>>>        "org.openjump.core.ui.plugin.file.charset" key.
>>>>>>
>>>>>>        Regards
>>>>>>
>>>>>>        Matthias
>>>>>>        >      Le 30/08/2010 18:50, Stefan Steiniger a écrit :
>>>>>>        >
>>>>>>        >>    Hei,
>>>>>>        >>
>>>>>>        >>    not sure, but wasn't the idea of the wizard that several
>>>>>>        dialogs can be
>>>>>>        >>    displayed after each other?
>>>>>>        >>
>>>>>>        
>>>>>> http://sourceforge.net/apps/mediawiki/jump-pilot/index.php?title=How_to_Create_an_Open_Wizard
>>>>>>        >>
>>>>>>        >    You're right Stefan, this is the idea of this wizard
>>>>>>        >
>>>>>>        >>    wouldn't that work for you too?
>>>>>>        >>
>>>>>>        >    I found it was not very easy to use the wizard framework to 
>>>>>> add
>>>>>>        options
>>>>>>        >    to an open file dialog box, but I think this is the way to 
>>>>>> go if
>>>>>>        we want
>>>>>>        >    to have something consistent in OpenJUMP
>>>>>>        >
>>>>>>        >>    Though I am not sure which loader uses that option 
>>>>>> currently.
>>>>>>        But it
>>>>>>        >>    looks like the "WMS Layer" option does that. (you see not a
>>>>>>        "finish" but
>>>>>>        >>    a "next" button)
>>>>>>        >>
>>>>>>        >    I used it to make a text/csv/wkt format driver with some 
>>>>>> options.
>>>>>>        >    You can also find my code here :
>>>>>>        >
>>>>>>        
>>>>>> http://geo.michaelm.free.fr/OpenJUMP/resources/drivers/txt-driver-src-0.2.1.zip
>>>>>>        >
>>>>>>        >    Michaël
>>>>>>        >
>>>>>>        >>    stefan
>>>>>>        >>
>>>>>>        >>    Sunburned Surveyor wrote:
>>>>>>        >>
>>>>>>        >>>    I don't see any problems with your approach. Is the idea to
>>>>>>        allow the
>>>>>>        >>>    charset of the shapefile to be selected from the new 
>>>>>> JComboBox?
>>>>>>        >>>
>>>>>>        >>>    Landon
>>>>>>        >>>
>>>>>>        >>>    On Sat, Aug 28, 2010 at 3:03 AM, Matthias
>>>>>>        Scholz<m...@jammerhund.de<mailto:m...@jammerhund.de>>     wrote:
>>>>>>        >>>
>>>>>>        >>>>    Hi,
>>>>>>        >>>>
>>>>>>        >>>>    in the last few weeks i had some problems with different
>>>>>>        charsets in
>>>>>>        >>>>    shape/dbf files. In the openjump.bat or openjump.sh file I
>>>>>>        have inserted
>>>>>>        >>>>    the java system property "file.encoding=...". My problems 
>>>>>> are
>>>>>>        the german
>>>>>>        >>>>    "Umlaute" in the attributes.
>>>>>>        >>>>    I would like to add a JComboBox to the
>>>>>>        >>>>    org.openjump.core.ui.plugin.file.open.SelectFilesPanel.
>>>>>>        Because the
>>>>>>        >>>>    SelectFilesPanel extends  JFileChooser I don't know any
>>>>>>        possibility to
>>>>>>        >>>>    add any other widget. I would prefer to change
>>>>>>        >>>>
>>>>>>        >>>>    public class SelectFilesPanel extends JFileChooser 
>>>>>> implements
>>>>>>        WizardPanel
>>>>>>        >>>>
>>>>>>        >>>>    to
>>>>>>        >>>>
>>>>>>        >>>>    public class SelectFilesPanel extends JPanel implements
>>>>>>        WizardPanel
>>>>>>        >>>>
>>>>>>        >>>>    then add the JFileChooser and a JComboBox to the JPanel. I
>>>>>>        don't know if
>>>>>>        >>>>    this have impacts to other classes? Before I start to 
>>>>>> code, I
>>>>>>        would like
>>>>>>        >>>>    to hear from the other developers.
>>>>>>        >>>>
>>>>>>        >>>>
>>>>>>        >>>>    Regards
>>>>>>        >>>>
>>>>>>        >>>>    Matthias
>>>>>>        >>>>
>>>>>>        >>>>
>>>>>>        
>>>>>> ------------------------------------------------------------------------------
>>>>>>        >>>>    Sell apps to millions through the Intel(R) Atom(Tm) 
>>>>>> Developer
>>>>>>        Program
>>>>>>        >>>>    Be part of this innovative community and reach millions of
>>>>>>        netbook users
>>>>>>        >>>>    worldwide. Take advantage of special opportunities to
>>>>>>        increase revenue and
>>>>>>        >>>>    speed time-to-market. Join now, and jumpstart your future.
>>>>>>        >>>>    http://p.sf.net/sfu/intel-atom-d2d
>>>>>>        >>>>    _______________________________________________
>>>>>>        >>>>    Jump-pilot-devel mailing list
>>>>>>        >>>>    jump-pilot-de...@lists.sourceforge.net
>>>>>>        <mailto:Jump-pilot-devel@lists.sourceforge.net>
>>>>>>        >>>>    
>>>>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>>>>>        >>>>
>>>>>>        >>>>
>>>>>>        >>>
>>>>>>        
>>>>>> ------------------------------------------------------------------------------
>>>>>>        >>>    Sell apps to millions through the Intel(R) Atom(Tm) 
>>>>>> Developer
>>>>>>        Program
>>>>>>        >>>    Be part of this innovative community and reach millions of
>>>>>>        netbook users
>>>>>>        >>>    worldwide. Take advantage of special opportunities to 
>>>>>> increase
>>>>>>        revenue and
>>>>>>        >>>    speed time-to-market. Join now, and jumpstart your future.
>>>>>>        >>>    http://p.sf.net/sfu/intel-atom-d2d
>>>>>>        >>>    _______________________________________________
>>>>>>        >>>    Jump-pilot-devel mailing list
>>>>>>        >>>    jump-pilot-de...@lists.sourceforge.net
>>>>>>        <mailto:Jump-pilot-devel@lists.sourceforge.net>
>>>>>>        >>>    
>>>>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>>>>>        >>>
>>>>>>        >>>
>>>>>>        >>>
>>>>>>        >>
>>>>>>        
>>>>>> ------------------------------------------------------------------------------
>>>>>>        >>    This SF.net Dev2Dev email is sponsored by:
>>>>>>        >>
>>>>>>        >>    Show off your parallel programming skills.
>>>>>>        >>    Enter the Intel(R) Threading Challenge 2010.
>>>>>>        >>    http://p.sf.net/sfu/intel-thread-sfd
>>>>>>        >>    _______________________________________________
>>>>>>        >>    Jump-pilot-devel mailing list
>>>>>>        >>    jump-pilot-de...@lists.sourceforge.net
>>>>>>        <mailto:Jump-pilot-devel@lists.sourceforge.net>
>>>>>>        >>    
>>>>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>>>>>        >>
>>>>>>        >>
>>>>>>        >>
>>>>>>        >
>>>>>>        >
>>>>>>        >
>>>>>>        
>>>>>> ------------------------------------------------------------------------------
>>>>>>        >    This SF.net Dev2Dev email is sponsored by:
>>>>>>        >
>>>>>>        >    Show off your parallel programming skills.
>>>>>>        >    Enter the Intel(R) Threading Challenge 2010.
>>>>>>        >    http://p.sf.net/sfu/intel-thread-sfd
>>>>>>        >    _______________________________________________
>>>>>>        >    Jump-pilot-devel mailing list
>>>>>>        >    jump-pilot-de...@lists.sourceforge.net
>>>>>>        <mailto:Jump-pilot-devel@lists.sourceforge.net>
>>>>>>        >    https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>>>>>        >
>>>>>>
>>>>>>
>>>>>>        
>>>>>> ------------------------------------------------------------------------------
>>>>>>        This SF.net Dev2Dev email is sponsored by:
>>>>>>
>>>>>>        Show off your parallel programming skills.
>>>>>>        Enter the Intel(R) Threading Challenge 2010.
>>>>>>        http://p.sf.net/sfu/intel-thread-sfd
>>>>>>        _______________________________________________
>>>>>>        Jump-pilot-devel mailing list
>>>>>>        jump-pilot-de...@lists.sourceforge.net
>>>>>>        <mailto:Jump-pilot-devel@lists.sourceforge.net>
>>>>>>        https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> This SF.net Dev2Dev email is sponsored by:
>>>>>>
>>>>>> Show off your parallel programming skills.
>>>>>> Enter the Intel(R) Threading Challenge 2010.
>>>>>> http://p.sf.net/sfu/intel-thread-sfd
>>>>>> ------------------------------------------------------------------------
>>>>>>
>>>>>> _______________________________________________
>>>>>> Jump-pilot-devel mailing list
>>>>>> Jump-pilot-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>>>>>
>>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> This SF.net Dev2Dev email is sponsored by:
>>>>>
>>>>> Show off your parallel programming skills.
>>>>> Enter the Intel(R) Threading Challenge 2010.
>>>>> http://p.sf.net/sfu/intel-thread-sfd
>>>>> _______________________________________________
>>>>> Jump-pilot-devel mailing list
>>>>> Jump-pilot-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>>>>
>>>>>
>>>>>
>>>> ------------------------------------------------------------------------------
>>>> This SF.net Dev2Dev email is sponsored by:
>>>>
>>>> Show off your parallel programming skills.
>>>> Enter the Intel(R) Threading Challenge 2010.
>>>> http://p.sf.net/sfu/intel-thread-sfd
>>>> _______________________________________________
>>>> Jump-pilot-devel mailing list
>>>> Jump-pilot-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>>>
>>>>
>>>>
>>> ------------------------------------------------------------------------------
>>> This SF.net Dev2Dev email is sponsored by:
>>>
>>> Show off your parallel programming skills.
>>> Enter the Intel(R) Threading Challenge 2010.
>>> http://p.sf.net/sfu/intel-thread-sfd
>>> _______________________________________________
>>> Jump-pilot-devel mailing list
>>> Jump-pilot-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>>
>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> This SF.net Dev2Dev email is sponsored by:
>>
>> Show off your parallel programming skills.
>> Enter the Intel(R) Threading Challenge 2010.
>> http://p.sf.net/sfu/intel-thread-sfd
>> _______________________________________________
>> Jump-pilot-devel mailing list
>> Jump-pilot-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>
>
>
> ------------------------------------------------------------------------------
> This SF.net Dev2Dev email is sponsored by:
>
> Show off your parallel programming skills.
> Enter the Intel(R) Threading Challenge 2010.
> http://p.sf.net/sfu/intel-thread-sfd
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to