public void openFileAction() {
        int nA, nO;
        int i, selected;
        String sName;
        NSObject o;
        NSRelation or;
        TclSnippet s;

        JFileChooser fch = new JFileChooser(this.lastpath);
        fch.setDialogTitle(Messages.tr("script_open"));
        selected = fch.showOpenDialog(this.getContentPane());
        if (selected == JFileChooser.APPROVE_OPTION) {
            this.updateLastPath(fch.getSelectedFile());
            this.model.newModel();
            try {
                Reader reader = new InputStreamReader(
                        new FileInputStream(fch.getSelectedFile()), "utf-8");
                BufferedReader br = new BufferedReader(reader);

                // Read arrays
                nA = Integer.parseInt(br.readLine());
                for (i = 0; i < nA; i++) {
                    this.model.addArray(br.readLine(), Integer.parseInt(br.readLine()));
                }

                // Read objects (gulp)
                nO = Integer.parseInt(br.readLine());
                br.readLine(); // Skip snippet and name information
                ((NSObject) this.model.getObjectAt(0)).setName(br.readLine());
                ((NSEntity) this.model.getObjectAt(0)).fromString(br);
                for (i = 1; i < nO; i++) {
                    sName = br.readLine();
                    s = this.libManager.getSnippet(sName);
                    if (s == null) {
                        s = this.searchLibAction(sName);
                    }
                    if (s == null) {
                        this.model.newModel();
                        this.model.updateAllViews(false);
                        this.model.setDirty(false);
                        return;
                    }
                    if (s.isRelation()) {
                        or = new NSRelation(s, br.readLine(), null, null);
                        s.instantiateNSObject(or);
                        or.fromString(br, this.model);
                        this.model.addObject(or);
                    } else {
                        o = new NSEntity(s, br.readLine(), 0.0, 0.0);
                        s.instantiateNSObject(o);
                        o.fromString(br);
                        this.model.addObject(o);
                    }
                }
                this.model.updateAllViews(false);
                this.model.setDirty(false);
            } catch (FileNotFoundException e) {
                LOG.log(Level.SEVERE, "{0} {1}", new Object[]{
                            Messages.tr("file_open_error"), e.toString()});
            } catch (IOException ioe) {
                LOG.log(Level.SEVERE, "{0} {1}", new Object[]{
                            Messages.tr("file_write_error"), ioe.toString()});
            }
        }
    }