oracc / nammu

Oracc GUI
GNU General Public License v3.0
12 stars 10 forks source link

Make JFileChooser allow only text files to be opened in Nammu #29

Open raquelalegre opened 9 years ago

raquelalegre commented 9 years ago

I've added a filter to prevent the user from clicking on files that are not "*.atf", but it is not working properly. Having these filter applied highlights the .atf files, but doesn't hide the non-atf files, which remain clickable and thus "openable".

        fileChooser = JFileChooser()
        filter = FileNameExtensionFilter("ATF files", ["atf"])
        fileChooser.setFileFilter(filter)
        status = fileChooser.showDialog(self.view, "Choose file")
raquelalegre commented 8 years ago

Change so it still shows everything, but non atf files are not clickable nor "openable".

raquelalegre commented 8 years ago

This is actually not true. Nammu still open text files with extensions other that ATF. For non text files, it doesn't open them because:

  File "__pyclasspath__/nammu/controller/NammuController.py", line 126, in openFile
  File "__pyclasspath__/nammu/controller/NammuController.py", line 141, in readTextFile
  File "/Users/raquelalegre/workspace/ORACC/nammu/target/nammu-0.1.jar/Lib/codecs$py.class", line 671, in read
  File "/Users/raquelalegre/workspace/ORACC/nammu/target/nammu-0.1.jar/Lib/codecs$py.class", line 477, in read
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 10-11: invalid data

Need to:

This will also help with #30

raquelalegre commented 8 years ago

Nice to have but no time before conference. Removing milestone.

raquelalegre commented 7 years ago

Currently it seems to ignore things that are not text files. Have a look into that and at least display a message saying this file can't be opened because it's not text.