private void createActions() {
private void createActions(boolean adminState) {
    private void createActions() {        actOptions = new AbstractAction() {            public void actionPerformed(java.awt.event.ActionEvent e) {                OptionsWin ow = new OptionsWin(myopts, mainwin.this);                ow.setModal(true);                ow.setVisible(true);                if (ow.getModalResult())                     ReloadSettings();            }        };        actOptions.putValue(Action.NAME, _("Options") + "...");        actOptions.putValue(Action.SHORT_DESCRIPTION, _("Shows the Options dialog"));        actOptions.putValue(Action.SMALL_ICON, utils.loadIcon("general/Preferences"));                actSend = new AbstractAction() {            public void actionPerformed(java.awt.event.ActionEvent e) {                SendWin sw = new SendWin(hyfc, mainwin.this);                sw.setModal(true);                sw.setVisible(true);                reloadTables();            }        };        actSend.putValue(Action.NAME, _("Send") + "...");        actSend.putValue(Action.SHORT_DESCRIPTION, _("Shows the send fax dialog"));        actSend.putValue(Action.SMALL_ICON, utils.loadIcon("general/SendMail"));                actPoll = new AbstractAction() {            public void actionPerformed(java.awt.event.ActionEvent e) {                SendWin sw = new SendWin(hyfc, mainwin.this, true);                sw.setModal(true);                sw.setVisible(true);            }        };        actPoll.putValue(Action.NAME, _("Poll") + "...");        actPoll.putValue(Action.SHORT_DESCRIPTION, _("Shows the poll fax dialog"));        actPoll.putValue(Action.SMALL_ICON, utils.loadIcon("general/Import"));                actDelete = new AbstractAction() {            public void actionPerformed(ActionEvent e) {                TooltipJTable selTable = (TooltipJTable)((JScrollPane)TabMain.getSelectedComponent()).getViewport().getView();                                String msgText;                                if (selTable == TableSending)                    msgText = _("Do you really want to cancel the selected fax jobs?");                else                    msgText = _("Do you really want to delete the selected faxes?");                                if (JOptionPane.showConfirmDialog(mainwin.this, msgText, _("Delete faxes"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {                    for (int i : selTable.getSelectedRows()) {                        YajJob yj = null;                        try {                            yj = selTable.getJobForRow(i);                            yj.delete(hyfc);                        } catch (Exception e1) {                            if (yj == null)                                msgText = _("Error deleting a fax:\n");                            else                                msgText = MessageFormat.format(_("Error deleting the fax \"{0}\":\n"), yj.getIDValue());                            //JOptionPane.showMessageDialog(mainwin.this, msgText + e1.getMessage(), _("Error"), JOptionPane.ERROR_MESSAGE);                            ExceptionDialog.showExceptionDialog(mainwin.this, msgText, e1);                        }                    }                    reloadTables();                }            };        };        actDelete.putValue(Action.NAME, _("Delete"));        actDelete.putValue(Action.SHORT_DESCRIPTION, _("Deletes the selected fax"));        actDelete.putValue(Action.SMALL_ICON, utils.loadIcon("general/Delete"));                actShow = new AbstractAction() {            public void actionPerformed(java.awt.event.ActionEvent e) {                TooltipJTable selTable = (TooltipJTable)((JScrollPane)TabMain.getSelectedComponent()).getViewport().getView();                                int sMin = Integer.MAX_VALUE, sMax = Integer.MIN_VALUE;                for (int i : selTable.getSelectedRows()) {                    YajJob yj = null;                    try {                        yj = selTable.getJobForRow(i);                        List<HylaServerFile> serverFiles = yj.getServerFilenames(hyfc);                        if (serverFiles.size() == 0) {                            JOptionPane.showMessageDialog(mainwin.this, MessageFormat.format(_("No document files available for the fax \"{0}\"."), yj.getIDValue()), _("Display fax"), JOptionPane.INFORMATION_MESSAGE);                        } else {                            for(HylaServerFile hsf : serverFiles) {                                try {                                    hsf.view(hyfc, myopts);                                } catch (Exception e1) {                                    //JOptionPane.showMessageDialog(mainwin.this, MessageFormat.format(_("An error occured displaying the file {0} (job {1}):\n"), hsf.getPath(), yj.getIDValue()) + e1.getMessage() , _("Error"), JOptionPane.ERROR_MESSAGE);                                    ExceptionDialog.showExceptionDialog(mainwin.this, MessageFormat.format(_("An error occured displaying the file {0} (job {1}):\n"), hsf.getPath(), yj.getIDValue()), e1);                                }                            }                        }                        if (yj instanceof RecvYajJob) {                            ((RecvYajJob)yj).setRead(true);                            if (i < sMin)                                sMin = i;                            if (i > sMax)                                sMax = i;                        }                    } catch (Exception e1) {                        //JOptionPane.showMessageDialog(mainwin.this, MessageFormat.format(_("An error occured displaying the fax \"{0}\":\n"), yj.getIDValue()) + e1.getMessage(), _("Error"), JOptionPane.ERROR_MESSAGE);                        ExceptionDialog.showExceptionDialog(mainwin.this, MessageFormat.format(_("An error occured displaying the fax \"{0}\":"), yj.getIDValue()), e1);                    }                }                if (sMax >= 0 && selTable == TableRecv) {                    TableRecv.getSorter().fireTableRowsUpdated(sMin, sMax);                    actFaxRead.putValue(ActionJCheckBoxMenuItem.SELECTED_PROPERTY, true);                }                            }        };        actShow.putValue(Action.NAME, _("Show") + "...");        actShow.putValue(Action.SHORT_DESCRIPTION, _("Displays the selected fax"));        actShow.putValue(Action.SMALL_ICON, utils.loadIcon("general/Zoom"));                actExit = new AbstractAction() {            public void actionPerformed(ActionEvent e) {                dispose();                //System.exit(0);            }        };        actExit.putValue(Action.NAME, _("Exit"));        actExit.putValue(Action.SHORT_DESCRIPTION, _("Exits the application"));        actExit.putValue(Action.SMALL_ICON, utils.loadIcon("general/Stop"));                actAbout = new AbstractAction() {            public void actionPerformed(ActionEvent e) {                //JOptionPane.showMessageDialog(aboutMenuItem.getComponent(), utils.AppName + "\n\n" + _("by Jonas Wolz"), _("About"), JOptionPane.INFORMATION_MESSAGE);                AboutDialog aDlg = new AboutDialog(mainwin.this);                aDlg.setMode(AboutDialog.Mode.ABOUT);                aDlg.setVisible(true);            }        };        actAbout.putValue(Action.NAME, _("About") +  "...");        actAbout.putValue(Action.SHORT_DESCRIPTION, _("Shows the about dialog"));        actAbout.putValue(Action.SMALL_ICON, utils.loadIcon("general/About"));                actPhonebook = new AbstractAction() {            public void actionPerformed(ActionEvent e) {                PhoneBookWin pbw = new PhoneBookWin(mainwin.this);                pbw.setModal(true);                pbw.setVisible(true);            }        };        actPhonebook.putValue(Action.NAME, _("Phone book") +  "...");        actPhonebook.putValue(Action.SHORT_DESCRIPTION, _("Display/edit the phone book"));        actPhonebook.putValue(Action.SMALL_ICON, utils.loadIcon("general/Bookmarks"));                actReadme = new AbstractAction() {            public void actionPerformed(ActionEvent e) {                AboutDialog aDlg = new AboutDialog(mainwin.this);                aDlg.setMode(AboutDialog.Mode.READMES);                aDlg.setVisible(true);            }        };        actReadme.putValue(Action.NAME, _("Documentation") +  "...");        actReadme.putValue(Action.SHORT_DESCRIPTION, _("Shows the README files"));        actReadme.putValue(Action.SMALL_ICON, utils.loadIcon("general/Help"));                actFaxRead = new AbstractAction() {            public void actionPerformed(ActionEvent e) {                Boolean state = (Boolean)getValue(ActionJCheckBoxMenuItem.SELECTED_PROPERTY);                boolean newState;                if (state == null)                    newState = true;                else                    newState = !state;                                if (TabMain.getSelectedComponent() == scrollRecv) { // TableRecv                    int sMin = Integer.MAX_VALUE, sMax = Integer.MIN_VALUE;                    for (int i:TableRecv.getSelectedRows()) {                        ((RecvYajJob)TableRecv.getJobForRow(i)).setRead(newState);                        if (i < sMin)                            sMin = i;                        if (i > sMax)                            sMax = i;                    }                    if (sMax >= 0)                        TableRecv.getSorter().fireTableRowsUpdated(sMin, sMax);                    actFaxRead.putValue(ActionJCheckBoxMenuItem.SELECTED_PROPERTY, newState);                }            };        };        actFaxRead.putValue(Action.NAME, _("Marked as read"));        actFaxRead.putValue(Action.SHORT_DESCRIPTION, _("Marks the selected fax as read/unread"));        actFaxRead.putValue(ActionJCheckBoxMenuItem.SELECTED_PROPERTY, true);                actFaxSave = new AbstractAction() {            public void actionPerformed(ActionEvent e) {                TooltipJTable selTable = (TooltipJTable)((JScrollPane)TabMain.getSelectedComponent()).getViewport().getView();                                if (selTable.getSelectedRowCount() == 1) {                    JFileChooser jfc = new JFileChooser();                                        try {                        YajJob yj = selTable.getJobForRow(selTable.getSelectedRow());                        List<HylaServerFile> serverFiles = yj.getServerFilenames(hyfc);                        if (serverFiles.size() == 0) {                            JOptionPane.showMessageDialog(mainwin.this, MessageFormat.format(_("No document files available for the fax \"{0}\"."), yj.getIDValue()), _("Display fax"), JOptionPane.INFORMATION_MESSAGE);                        } else {                            for(HylaServerFile hsf : serverFiles) {                                try {                                    String filename = hsf.getPath();                                    int seppos = filename.lastIndexOf('/');                                    if (seppos < 0)                                        seppos = filename.lastIndexOf(File.separatorChar);                                    if (seppos >= 0)                                        filename = filename.substring(seppos + 1);                                    jfc.setDialogTitle(MessageFormat.format(_("Save {0} to"), hsf.getPath()));                                    jfc.setSelectedFile(new File(filename));                                                                        jfc.resetChoosableFileFilters();                                    ExampleFileFilter curFilter = new ExampleFileFilter(hsf.getType(), hsf.getType() + _(" files"));                                    jfc.addChoosableFileFilter(curFilter);                                    jfc.setFileFilter(curFilter);                                                                        if (jfc.showSaveDialog(mainwin.this) == JFileChooser.APPROVE_OPTION)                                        hsf.download(hyfc, jfc.getSelectedFile());                                } catch (Exception e1) {                                    //JOptionPane.showMessageDialog(mainwin.this, MessageFormat.format(_("An error occured saving the file {0} (job {1}):\n"), hsf.getPath(), yj.getIDValue()) + e1.getMessage() , _("Error"), JOptionPane.ERROR_MESSAGE);                                    ExceptionDialog.showExceptionDialog(mainwin.this, MessageFormat.format(_("An error occured saving the file {0} (job {1}):"), hsf.getPath(), yj.getIDValue()), e1);                                }                                                           }                        }                    } catch (Exception e1) {                        //JOptionPane.showMessageDialog(mainwin.this, _("An error occured saving the fax:\n")  + e1.getMessage(), _("Error"), JOptionPane.ERROR_MESSAGE);                        ExceptionDialog.showExceptionDialog(mainwin.this, _("An error occured saving the fax:"), e1);                    }                } else {                    JFileChooser jfc = new JFileChooser();                    jfc.setDialogTitle(_("Select a directory to save the faxes in"));                    jfc.setApproveButtonText(_("Select"));                    jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);                    if (jfc.showOpenDialog(mainwin.this) == JFileChooser.APPROVE_OPTION) {                        int fileCounter = 0;                                                for (int i : selTable.getSelectedRows()) {                            YajJob yj = null;                            try {                                yj = selTable.getJobForRow(i);                                for(HylaServerFile hsf : yj.getServerFilenames(hyfc)) {                                    try {                                        String filename = hsf.getPath();                                        int seppos = filename.lastIndexOf('/');                                        if (seppos < 0)                                            seppos = filename.lastIndexOf(File.separatorChar);                                        if (seppos >= 0)                                            filename = filename.substring(seppos + 1);                                                                                File target = new File(jfc.getSelectedFile(), filename);                                        hsf.download(hyfc, target);                                        fileCounter++;                                    } catch (Exception e1) {                                        //JOptionPane.showMessageDialog(mainwin.this, MessageFormat.format(_("An error occured saving the file {0} (job {1}):\n"), hsf.getPath(), yj.getIDValue()) + e1.getMessage() , _("Error"), JOptionPane.ERROR_MESSAGE);                                        ExceptionDialog.showExceptionDialog(mainwin.this, MessageFormat.format(_("An error occured saving the file {0} (job {1}):"), hsf.getPath(), yj.getIDValue()), e1);                                    }                                }                                                            } catch (Exception e1) {                                //JOptionPane.showMessageDialog(mainwin.this, _("An error occured saving the fax:\n") + e1.getMessage(), _("Error"), JOptionPane.ERROR_MESSAGE);                                ExceptionDialog.showExceptionDialog(mainwin.this, _("An error occured saving the fax:"), e1);                            }                        }                                                JOptionPane.showMessageDialog(mainwin.this, MessageFormat.format(_("{0} files saved to directory {1}."), fileCounter, jfc.getSelectedFile().getPath()), _("Faxes saved"), JOptionPane.INFORMATION_MESSAGE);                    }                }            };        };        actFaxSave.putValue(Action.NAME, _("Save fax..."));        actFaxSave.putValue(Action.SHORT_DESCRIPTION, _("Saves the selected fax on disk"));        actFaxSave.putValue(Action.SMALL_ICON, utils.loadIcon("general/SaveAs"));                actForward = new AbstractAction() {            public void actionPerformed(ActionEvent e) {                if (TabMain.getSelectedComponent() != scrollRecv || TableRecv.getSelectedRow() < 0)                    return;                                String filename;                try {                    filename = TableRecv.getJobForRow(TableRecv.getSelectedRow()).getServerFilenames(hyfc).get(0).getPath();                } catch (Exception e1) {                    //JOptionPane.showMessageDialog(mainwin.this, _("Couldn't get a filename for the fax:\n") + e1.getMessage(), _("Error"), JOptionPane.ERROR_MESSAGE);                    ExceptionDialog.showExceptionDialog(mainwin.this, _("Couldn't get a filename for the fax:"), e1);                    return;                }                                SendWin sw = new SendWin(hyfc, mainwin.this);                sw.setModal(true);                sw.addServerFile(filename);                sw.setVisible(true);                reloadTables();            }        };        actForward.putValue(Action.NAME, _("Forward fax..."));        actForward.putValue(Action.SHORT_DESCRIPTION, _("Forwards the fax"));        actForward.putValue(Action.SMALL_ICON, utils.loadIcon("general/Redo"));                actAdminMode = new AbstractAction() {            public void actionPerformed(ActionEvent e) {                Boolean state = (Boolean)getValue(ActionJCheckBoxMenuItem.SELECTED_PROPERTY);                boolean newState;                if (state == null)                    newState = false;                else                    newState = !state;                actAdminMode.putValue(ActionJCheckBoxMenuItem.SELECTED_PROPERTY, newState);                                ReloadSettings();            };        };        actAdminMode.putValue(Action.NAME, _("Admin mode"));        actAdminMode.putValue(Action.SHORT_DESCRIPTION, _("Connect to the server in admin mode (e.g. to delete faxes)"));        actAdminMode.putValue(ActionJCheckBoxMenuItem.SELECTED_PROPERTY, false);                actChecker = new ActionEnabler();    }