private void deleteKuuntelee() {
        koodiTable.addListener(SWT.Selection, new Listener() {
            
            
            public void handleEvent(final Event event) {
                viiteTable.setVisible(true);
                viiteTable.dispose();
                viiteTable = new Table(shell, SWT.BORDER);
                viiteTable.setSize(200, 300);
                viiteTable.setLocation(400, 50);
                
                File file = new File("Bibtex data/Viitteet.bib");
                Scanner scanner = null;
                try {
                    scanner = new Scanner(file);
                } catch (FileNotFoundException ex) {
                    Logger.getLogger(Gui.class.getName()).log(Level.SEVERE, null, ex);
                }
                String line = "";
                ulompi: while (true) {
                    line = scanner.nextLine();
                    if (line.contains(event.item.toString().substring(11, event.item.toString().length() - 1))) {
                        TableItem item = new TableItem(viiteTable, SWT.NONE);
                        item.setText(line);
                        sisempi: while (scanner.hasNextLine()) {
                            line = scanner.nextLine();
                            if (line.equals("")) {
                                break ulompi;
                            } else {
                                item = new TableItem(viiteTable, SWT.NONE);
                                item.setText(line);
                            }
                        }
                    }
                }
                delete.addSelectionListener(new SelectionListener() {
                    public void widgetSelected(SelectionEvent eventt) {
                        viiteTable.setVisible(false);
                        String koodi = event.item.toString().substring(11, event.item.toString().length() - 1);
                        event.item.dispose();
                        System.out.println(koodi);
                        mappi.remove(koodi);
                        File file = new File("Bibtex data/Viitteet.bib");
                        File file2 = new File("Bibtex data/Koodit.bib");
                        try {
                            PrintWriter writer = new PrintWriter(file);
                            writer.print("");
                            writer.close();
                            PrintWriter writer2 = new PrintWriter(file2);
                            writer2.print("");
                            writer2.close();
                        } catch (FileNotFoundException ex) {
                            Logger.getLogger(Gui.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        Set<String> avaimet = mappi.keySet();

                        for (String avain : avaimet) {
                            String[] options = mappi.get(avain).getOptions();
                            try {
                                bibtex.convert(mappi.get(avain).getTyyppi(), avain, options, file, true);
                            } catch (IOException ex) {
                                Logger.getLogger(Gui.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }

                    }

                    public void widgetDefaultSelected(SelectionEvent event) {
                    }
                });
            }

            public void handleDefaultEvent(Event event) {
                throw new UnsupportedOperationException("Not supported yet.");
            }
        });
    }