Example usage for javax.swing JFileChooser DIRECTORIES_ONLY

List of usage examples for javax.swing JFileChooser DIRECTORIES_ONLY

Introduction

In this page you can find the example usage for javax.swing JFileChooser DIRECTORIES_ONLY.

Prototype

int DIRECTORIES_ONLY

To view the source code for javax.swing JFileChooser DIRECTORIES_ONLY.

Click Source Link

Document

Instruction to display only directories.

Usage

From source file:coreferenceresolver.gui.MainGUI.java

private void trainingBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_trainingBtnActionPerformed
    // TODO add your handling code here:
    JFileChooser inputFileChooser = new JFileChooser(defaulPath);
    inputFileChooser.setDialogTitle("Choose where your training file saved");
    inputFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    if (inputFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
        trainingFilePathTF/*w  ww  .  j a v a2 s  .  c om*/
                .setText(inputFileChooser.getSelectedFile().getAbsolutePath() + File.separator + "train.arff");
        noteTF.setText("Create training file waiting ...");
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    TrainingMain.run(inputFilePathTF.getText(), markupFilePathTF.getText(),
                            trainingFilePathTF.getText(), true);
                    noteTF.setText("Create training file done!");
                    String folderPathOpen = trainingFilePathTF.getText().substring(0,
                            trainingFilePathTF.getText().lastIndexOf(File.separatorChar));
                    Desktop.getDesktop().open(new File(folderPathOpen));
                } catch (Exception ex) {
                    Logger.getLogger(MainGUI.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }).start();
    } else {
        noteTF.setText("No training file location selected");
    }
}

From source file:de.ist.clonto.Ontogui.java

private void backupOntologyButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_backupOntologyButtonActionPerformed
    JFileChooser fc = new JFileChooser();
    fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int returnVal = fc.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {//from w w  w . j  a  va2  s . c  om
            FileUtils.cleanDirectory(fc.getSelectedFile());
            FileUtils.copyDirectory(ontoPath.toFile(), fc.getSelectedFile());
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this, "Loading ontology failed");
        }
        JOptionPane.showMessageDialog(this, "Created Backup files!");
    } else {
        JOptionPane.showMessageDialog(this, "Loading ontology failed");
    }

}

From source file:com.gnadenheimer.mg.frames.admin.FrameConfigAdmin.java

private void cmdDatadirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdDatadirActionPerformed
    try {//from w w  w.j  a  va2s. co  m
        JFileChooser chooser = new JFileChooser();
        chooser.setCurrentDirectory(new java.io.File("."));
        chooser.setDialogTitle("Eligir ubicacin de la base de datos.");
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        chooser.setAcceptAllFileFilterUsed(false);

        if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
            txtDatadir.setText(chooser.getSelectedFile().getPath());
        }
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null,
                Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage());
        LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex);
    }
}

From source file:com.igormaznitsa.sciareto.ui.MainFrame.java

private void menuOpenProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuOpenProjectActionPerformed
    final JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileView(new FileView() {
        private Icon KNOWLEDGE_FOLDER_ICO = null;

        @Override/*  w w  w .  ja  v a 2  s . c o  m*/
        public Icon getIcon(final File f) {
            if (f.isDirectory()) {
                final File knowledge = new File(f, ".projectKnowledge");
                if (knowledge.isDirectory()) {
                    if (KNOWLEDGE_FOLDER_ICO == null) {
                        final Icon icon = UIManager.getIcon("FileView.directoryIcon");
                        if (icon != null) {
                            KNOWLEDGE_FOLDER_ICO = new ImageIcon(
                                    UiUtils.makeBadgedRightBottom(UiUtils.iconToImage(fileChooser, icon),
                                            Icons.MMDBADGE.getIcon().getImage()));
                        }
                    }
                    return KNOWLEDGE_FOLDER_ICO;
                } else {
                    return super.getIcon(f);
                }
            } else if (f.isFile() && f.getName().toLowerCase(Locale.ENGLISH).endsWith(".mmd")) {
                return Icons.DOCUMENT.getIcon();
            } else {
                return super.getIcon(f);
            }
        }
    });
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setDialogTitle("Open project folder");

    if (fileChooser.showOpenDialog(Main.getApplicationFrame()) == JFileChooser.APPROVE_OPTION) {
        openProject(fileChooser.getSelectedFile(), false);
    }
}

From source file:org.apache.jmeter.visualizers.CreateReport.java

@Override
public void actionPerformed(ActionEvent ev) {
    /*/*from  ww  w.  j a  v  a  2  s  .  c o m*/
     if(ev.equals(SAVEASCSV))
      {
         saveAsCsv.setSelected(true);
      }
      else if (ev.equals(SAVEASPDF)
      {
         saveAsPdf.setSelected(true);
      }
     */

    String action = ev.getActionCommand();

    if (action.equals(BROWSE)) {

        JFileChooser j = new JFileChooser();
        j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int returnVal = j.showOpenDialog(this);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            basepath.setText(j.getSelectedFile().getAbsolutePath());
            BASEPATH = basepath.getText().trim();
            JOptionPane.showMessageDialog(null, "alert", basepath.getText(), JOptionPane.OK_OPTION);

        }
        if (ev.getSource() == saveTable) {
            JFileChooser chooser = FileDialoger.promptToSaveFile("summary.csv");//$NON-NLS-1$
            if (chooser == null) {
                return;
            }
            FileWriter writer = null;
            try {
                writer = new FileWriter(chooser.getSelectedFile());
                CSVSaveService.saveCSVStats(model, writer, saveHeaders.isSelected());
            } catch (FileNotFoundException e) {
                log.warn(e.getMessage());
            } catch (IOException e) {
                log.warn(e.getMessage());
            } finally {
                JOrphanUtils.closeQuietly(writer);
            }
        }
    }

}

From source file:UI.SecurityDashboard.java

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
    //Saving location where to get CSV files from                                              
    selectDatabaseLocation = new JFileChooser();
    selectDatabaseLocation.setCurrentDirectory(new java.io.File("."));
    selectDatabaseLocation.setDialogTitle(databaseFileLocationDialogTitle);
    selectDatabaseLocation.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    selectDatabaseLocation.setAcceptAllFileFilterUsed(false);

    if (selectDatabaseLocation.showDialog(sourceFolder,
            databaseFileLocationDialogButton) == JFileChooser.APPROVE_OPTION) {
        System.out.println("getCurrentDirectory(): " + selectDatabaseLocation.getCurrentDirectory());
        System.out.println("getSelectedFile() : " + selectDatabaseLocation.getSelectedFile());
    } else {//  ww w  .ja  va  2  s .  c o m
        System.out.println("No Selection ");
    }
    //
    //        TreeModel model = new FileTreeModel((new File("/")));
    //        final JTree tree = new JTree(model);
    //        final JFrame treeFrame = new JFrame();
    //        JScrollPane scrollPane = new JScrollPane(tree);
    //        JPanel treePanel = new JPanel();
    //        treePanel.setLayout(new BorderLayout());
    //        treePanel.add(scrollPane, BorderLayout.CENTER);
    //
    //        treeFrame.setAlwaysOnTop(true);
    //        JButton selectButton = new JButton();
    //        selectButton.setText("Select");
    //        selectButton.addActionListener(new ActionListener() {
    //
    //            public void actionPerformed(ActionEvent e)
    //            {
    //                //Execute when button is pressed
    //                treeFrame.setVisible(false);
    //                TreePath s = tree.getSelectionPath();
    //                System.out.println(s.toString());
    //            }
    //        });
    //        treeFrame.add(selectButton, BorderLayout.SOUTH);
    //        treeFrame.add(treePanel);
    //        treeFrame.setVisible(true);
    //        treeFrame.setSize(400, 400);
    //

    System.out.println(selectDatabaseLocation.getCurrentDirectory().getPath());
    File currentFile = selectDatabaseLocation.getCurrentDirectory();

    Properties prop = new Properties();
    OutputStream output = null;

    try {

        output = new FileOutputStream("config.properties");

        // set the properties value
        prop.setProperty("location", currentFile.getAbsolutePath());

        // save properties to project root folder
        prop.store(output, null);

    } catch (IOException io) {
        io.printStackTrace();
    } finally {
        if (output != null) {
            try {
                output.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }

}

From source file:au.org.ala.delta.editor.ui.image.ImageSettingsDialog.java

@Action
public void addToImagePath() {
    JFileChooser chooser = new JFileChooser(_imageSettings.getDataSetPath());
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int result = chooser.showDialog(this, _resources.getString("okImageSettingsChanges.Action.text"));
    if (result == JFileChooser.APPROVE_OPTION) {
        _imageSettings.addToResourcePath(chooser.getSelectedFile());
        imagePathTextField.setText(_imageSettings.getResourcePath());
    }//from  w  w w.  ja va2  s.c  o  m
}

From source file:ispd.gui.JResultados.java

private void jButtonSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalvarActionPerformed
    JFileChooser jFileChooser = new JFileChooser();
    jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int returnVal = jFileChooser.showSaveDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = jFileChooser.getSelectedFile();
        salvarHTML(file);//from   w w w  . j av  a2  s. co  m
        try {
            HtmlPane.openDefaultBrowser(new URL("file://" + file.getAbsolutePath() + "/result.html"));
        } catch (MalformedURLException ex) {
            Logger.getLogger(JResultados.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:me.paddingdun.gen.code.gui.view.dbtable.TableView.java

private void btnGenActionPerformed(java.awt.event.ActionEvent evt) {
    if (model != null) {
        fileChooser.setFileSelectionMode(JFileChooser.SAVE_DIALOG | JFileChooser.DIRECTORIES_ONLY);
        fileChooser.setCurrentDirectory(new File("D:\\home\\Desktop"));
        int opt = fileChooser.showSaveDialog(null);
        // ?;/*from   w ww. j av  a2s.  c o m*/
        if (JFileChooser.APPROVE_OPTION == opt) {
            TaskHelper.runInNonEDT(new Callable<Integer[]>() {
                public Integer[] call() throws Exception {
                    File saveFile = fileChooser.getSelectedFile();
                    if (!saveFile.exists())
                        saveFile.mkdirs();
                    // ;
                    // ModelHelper.complexGetAndSimpleSet(TableView.this,
                    // model);

                    //?EditViewModel;
                    EditView ev = perspective.getEditView();
                    ev.setModelValue();
                    EditViewModel evm = ev.getModel();

                    // model;ok
                    ModelHelper.processTableViewModel(model, evm);

                    String baseJavaContent = VelocityHelper.baseEntityBean(model);
                    // System.out.println(javaContent);
                    FileHelper.genBasePojoJavaFile(saveFile.getAbsolutePath(), model.getPojoFullPackageName(),
                            model.getEntity().getEntityBeanName(), baseJavaContent);

                    String javaContent = VelocityHelper.entityBean(model);
                    // System.out.println(javaContent);
                    FileHelper.genPojoJavaFile(saveFile.getAbsolutePath(), model.getPojoFullPackageName(),
                            model.getEntity().getEntityBeanName(), javaContent);

                    String sqlMapBaseContent = VelocityHelper.sqlBaseMap(model);
                    FileHelper.genSqlMapBaseXmlFile(saveFile.getAbsolutePath(),
                            model.getEntity().getEntityBeanName(), sqlMapBaseContent);

                    String sqlMapContent = VelocityHelper.sqlMap(model);
                    FileHelper.genSqlMapXmlFile(saveFile.getAbsolutePath(),
                            model.getEntity().getEntityBeanName(), sqlMapContent);
                    // System.out.println(sqlMapContent);

                    String sqlMapBaseIDaoContent = VelocityHelper.sqlMapIDao(model);
                    FileHelper.genSqlMapIDaoJavaFile(saveFile.getAbsolutePath(), model.getDaoFullPackageName(),
                            model.getEntity().getEntityBeanName(), sqlMapBaseIDaoContent);

                    String sqlMapIDaoContent = VelocityHelper.sqlMapBaseDao(model);
                    FileHelper.genSqlMapBaseDaoJavaFile(saveFile.getAbsolutePath(),
                            model.getDaoFullPackageName(), model.getEntity().getEntityBeanName(),
                            sqlMapIDaoContent);

                    if (!VelocityHelper.isMybtis()) {
                        String sqlMapDaoImplContent = VelocityHelper.sqlMapDaoImpl(model);
                        FileHelper.genSqlMapDaoImplJavaFile(saveFile.getAbsolutePath(),
                                model.getDaoImplFullPackageName(), model.getEntity().getEntityBeanName(),
                                sqlMapDaoImplContent);
                    }

                    String sqlMapBaseServiceContent = VelocityHelper.sqlMapBaseService(model);
                    FileHelper.genSqlMapBaseServiceJavaFile(saveFile.getAbsolutePath(),
                            model.getServiceFullPackageName(), model.getEntity().getEntityBeanName(),
                            sqlMapBaseServiceContent);

                    String sqlMapIServiceContent = VelocityHelper.sqlMapIService(model);
                    FileHelper.genSqlMapIServiceJavaFile(saveFile.getAbsolutePath(),
                            model.getServiceFullPackageName(), model.getEntity().getEntityBeanName(),
                            sqlMapIServiceContent);

                    String sqlMapBaseServiceImplContent = VelocityHelper.sqlMapBaseServiceImpl(model);
                    FileHelper.genSqlMapBaseServiceImplJavaFile(saveFile.getAbsolutePath(),
                            model.getServiceImplFullPackageName(), model.getEntity().getEntityBeanName(),
                            sqlMapBaseServiceImplContent);

                    String sqlMapServiceImplContent = VelocityHelper.sqlMapServiceImpl(model);
                    FileHelper.genSqlMapServiceImplJavaFile(saveFile.getAbsolutePath(),
                            model.getServiceImplFullPackageName(), model.getEntity().getEntityBeanName(),
                            sqlMapServiceImplContent);

                    String springWebActionContent = VelocityHelper.springWebAction(model);
                    FileHelper.genSpringWebActionJavaFile(saveFile.getAbsolutePath(),
                            model.getWebActionFullPackageName(), model.getEntity().getEntityBeanName(),
                            springWebActionContent);

                    //                   String bootstrapDataTableJspContent =
                    //                  VelocityHelper.bootstrapDataTableJsp(model);
                    //                  FileHelper.genBootstrapDataTableJspFile(saveFile.getAbsolutePath(),
                    //                  model.getJspWebinfAfterDir(),
                    //                  model.getEntity().getEntityBeanName(),
                    //                  bootstrapDataTableJspContent);

                    String easyuiListJspContent = VelocityHelper.easyuiListJsp(model);
                    FileHelper.genEasyuiListJspFile(saveFile.getAbsolutePath(), model.getJspWebinfAfterDir(),
                            model.getEntity().getEntityBeanName(), easyuiListJspContent);

                    String easyuiEditJspContent = VelocityHelper.easyuiEditJsp(model);
                    FileHelper.genEasyuiEditJspFile(saveFile.getAbsolutePath(), model.getJspWebinfAfterDir(),
                            model.getEntity().getEntityBeanName(), easyuiEditJspContent);

                    EventQueue.invokeLater(new Runnable() {
                        public void run() {
                            JOptionPane.showMessageDialog(null, "??!");
                        }
                    });
                    return null;
                }
            });
        }
    }
}

From source file:eu.apenet.dpt.standalone.gui.DataPreparationToolGUI.java

private void wireUp() {
    fileItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            if (actionEvent.getSource() == fileItem) {
                currentLocation = new File(retrieveFromDb.retrieveOpenLocation());
                fileChooser.setCurrentDirectory(currentLocation);
                int returnedVal = fileChooser.showOpenDialog(getParent());

                if (returnedVal == JFileChooser.APPROVE_OPTION) {
                    currentLocation = fileChooser.getCurrentDirectory();
                    retrieveFromDb.saveOpenLocation(currentLocation.getAbsolutePath());

                    RootPaneContainer root = (RootPaneContainer) getRootPane().getTopLevelAncestor();
                    root.getGlassPane().setCursor(WAIT_CURSOR);
                    root.getGlassPane().setVisible(true);

                    File[] files = fileChooser.getSelectedFiles();
                    for (File file : files) {
                        if (file.isDirectory()) {
                            File[] fileArray = file.listFiles();
                            Arrays.sort(fileArray, new FileNameComparator());
                            for (File children : fileArray) {
                                if (isCorrect(children)) {
                                    xmlEadListModel.addFile(children);
                                }//from   w w w  .  ja  v  a 2  s  .  co  m
                            }
                        } else {
                            if (isCorrect(file)) {
                                xmlEadListModel.addFile(file);
                            }
                        }
                    }

                    root.getGlassPane().setCursor(DEFAULT_CURSOR);
                    root.getGlassPane().setVisible(false);
                }
            }
        }
    });
    repositoryCodeItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            createOptionPaneForRepositoryCode();
        }
    });
    countryCodeItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            createOptionPaneForCountryCode();
        }
    });
    checksLoadingFilesItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            createOptionPaneForChecksLoadingFiles();
        }
    });
    createEag2012FromExistingEag2012.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser eagFileChooser = new JFileChooser();
            eagFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            eagFileChooser.setMultiSelectionEnabled(false);
            eagFileChooser.setCurrentDirectory(new File(retrieveFromDb.retrieveOpenLocation()));
            if (eagFileChooser.showOpenDialog(getParent()) == JFileChooser.APPROVE_OPTION) {
                currentLocation = eagFileChooser.getCurrentDirectory();
                retrieveFromDb.saveOpenLocation(currentLocation.getAbsolutePath());

                File eagFile = eagFileChooser.getSelectedFile();
                if (!Eag2012Frame.isUsed()) {
                    try {
                        if (ReadXml.isXmlFile(eagFile, "eag")) {
                            new Eag2012Frame(eagFile, getContentPane().getSize(),
                                    (ProfileListModel) getXmlEadList().getModel(), labels);
                        } else {
                            JOptionPane.showMessageDialog(rootPane,
                                    labels.getString("eag2012.errors.notAnEagFile"));
                        }
                    } catch (SAXException ex) {
                        if (ex instanceof SAXParseException) {
                            JOptionPane.showMessageDialog(rootPane,
                                    labels.getString("eag2012.errors.notAnEagFile"));
                        }
                        java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName())
                                .log(java.util.logging.Level.SEVERE, null, ex);
                    } catch (IOException ex) {
                        java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName())
                                .log(java.util.logging.Level.SEVERE, null, ex);
                    } catch (ParserConfigurationException ex) {
                        java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName())
                                .log(java.util.logging.Level.SEVERE, null, ex);
                    } catch (Exception ex) {
                        try {
                            JOptionPane.showMessageDialog(rootPane, labels.getString(ex.getMessage()));
                        } catch (Exception ex1) {
                            JOptionPane.showMessageDialog(rootPane, "Error...");
                        }
                    }
                }
            }
        }
    });
    createEag2012FromScratch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (!Eag2012Frame.isUsed()) {
                new Eag2012Frame(getContentPane().getSize(), (ProfileListModel) getXmlEadList().getModel(),
                        labels, retrieveFromDb.retrieveCountryCode(), retrieveFromDb.retrieveRepositoryCode());
            }
        }
    });
    digitalObjectTypeItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (!DigitalObjectAndRightsOptionFrame.isInUse()) {
                JFrame DigitalObjectAndRightsOptionFrame = new DigitalObjectAndRightsOptionFrame(labels,
                        retrieveFromDb);

                DigitalObjectAndRightsOptionFrame.setPreferredSize(new Dimension(
                        getContentPane().getWidth() * 3 / 8, getContentPane().getHeight() * 3 / 4));
                DigitalObjectAndRightsOptionFrame.setLocation(getContentPane().getWidth() / 8,
                        getContentPane().getHeight() / 8);

                DigitalObjectAndRightsOptionFrame.pack();
                DigitalObjectAndRightsOptionFrame.setVisible(true);
            }
        }
    });
    defaultSaveFolderItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            JFileChooser defaultSaveFolderChooser = new JFileChooser();
            defaultSaveFolderChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            defaultSaveFolderChooser.setMultiSelectionEnabled(false);
            defaultSaveFolderChooser.setCurrentDirectory(new File(retrieveFromDb.retrieveDefaultSaveFolder()));
            if (defaultSaveFolderChooser.showOpenDialog(getParent()) == JFileChooser.APPROVE_OPTION) {
                File directory = defaultSaveFolderChooser.getSelectedFile();
                if (directory.canWrite() && DirectoryPermission.canWrite(directory)) {
                    retrieveFromDb.saveDefaultSaveFolder(directory + "/");
                } else {
                    createErrorOrWarningPanel(new Exception(labels.getString("error.directory.nowrites")),
                            false, labels.getString("error.directory.nowrites"), getContentPane());
                }
            }
        }
    });
    listDateConversionRulesItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            JDialog dateConversionRulesDialog = new DateConversionRulesDialog(labels, retrieveFromDb);

            dateConversionRulesDialog.setPreferredSize(
                    new Dimension(getContentPane().getWidth() * 3 / 8, getContentPane().getHeight() * 7 / 8));
            dateConversionRulesDialog.setLocation(getContentPane().getWidth() / 8,
                    getContentPane().getHeight() / 8);

            dateConversionRulesDialog.pack();
            dateConversionRulesDialog.setVisible(true);

        }
    });
    edmGeneralOptionsItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (!EdmGeneralOptionsFrame.isInUse()) {
                JFrame edmGeneralOptionsFrame = new EdmGeneralOptionsFrame(labels, retrieveFromDb);

                edmGeneralOptionsFrame.setPreferredSize(new Dimension(getContentPane().getWidth() * 3 / 8,
                        getContentPane().getHeight() * 3 / 8));
                edmGeneralOptionsFrame.setLocation(getContentPane().getWidth() / 8,
                        getContentPane().getHeight() / 8);

                edmGeneralOptionsFrame.pack();
                edmGeneralOptionsFrame.setVisible(true);
            }
        }
    });
    closeSelectedItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            xmlEadListModel.removeFiles(xmlEadList.getSelectedValues());
        }
    });
    saveSelectedItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String defaultOutputDirectory = retrieveFromDb.retrieveDefaultSaveFolder();
            boolean isMultipleFiles = xmlEadList.getSelectedIndices().length > 1;

            RootPaneContainer root = (RootPaneContainer) getRootPane().getTopLevelAncestor();
            root.getGlassPane().setCursor(WAIT_CURSOR);
            root.getGlassPane().setVisible(true);

            for (Object selectedValue : xmlEadList.getSelectedValues()) {
                File selectedFile = (File) selectedValue;
                String filename = selectedFile.getName();
                FileInstance fileInstance = fileInstances.get(filename);
                String filePrefix = fileInstance.getFileType().getFilePrefix();

                //todo: do we really need this?
                filename = filename.startsWith("temp_") ? filename.replace("temp_", "") : filename;

                filename = !filename.endsWith(".xml") ? filename + ".xml" : filename;

                if (!fileInstance.isValid()) {
                    filePrefix = "NOT_" + filePrefix;
                }

                if (fileInstance.getLastOperation().equals(FileInstance.Operation.EDIT_TREE)) {
                    TreeTableModel treeTableModel = tree.getTreeTableModel();
                    Document document = (Document) treeTableModel.getRoot();
                    try {
                        File file2 = new File(defaultOutputDirectory + filePrefix + "_" + filename);
                        File filetemp = new File(Utilities.TEMP_DIR + "temp_" + filename);
                        TransformerFactory tf = TransformerFactory.newInstance();
                        Transformer output = tf.newTransformer();
                        output.setOutputProperty(javax.xml.transform.OutputKeys.INDENT, "yes");
                        output.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");

                        DOMSource domSource = new DOMSource(document.getFirstChild());
                        output.transform(domSource, new StreamResult(filetemp));
                        output.transform(domSource, new StreamResult(file2));

                        fileInstance.setLastOperation(FileInstance.Operation.SAVE);
                        fileInstance.setCurrentLocation(filetemp.getAbsolutePath());
                    } catch (Exception ex) {
                        createErrorOrWarningPanel(ex, true, labels.getString("errorSavingTreeXML"),
                                getContentPane());
                    }
                } else if (fileInstance.isConverted()) {
                    try {
                        File newFile = new File(defaultOutputDirectory + filePrefix + "_" + filename);
                        FileUtils.copyFile(new File(fileInstance.getCurrentLocation()), newFile);
                        fileInstance.setLastOperation(FileInstance.Operation.SAVE);
                        //                            fileInstance.setCurrentLocation(newFile.getAbsolutePath());
                    } catch (IOException ioe) {
                        LOG.error("Error when saving file", ioe);
                    }
                } else {
                    try {
                        File newFile = new File(defaultOutputDirectory + filePrefix + "_" + filename);
                        FileUtils.copyFile(selectedFile, newFile);
                        fileInstance.setLastOperation(FileInstance.Operation.SAVE);
                        //                            fileInstance.setCurrentLocation(newFile.getAbsolutePath());
                    } catch (IOException ioe) {
                        LOG.error("Error when saving file", ioe);
                    }
                }
            }

            root.getGlassPane().setCursor(DEFAULT_CURSOR);
            root.getGlassPane().setVisible(false);

            if (isMultipleFiles) {
                JOptionPane.showMessageDialog(getContentPane(),
                        MessageFormat.format(labels.getString("filesInOutput"), defaultOutputDirectory) + ".",
                        labels.getString("fileSaved"), JOptionPane.INFORMATION_MESSAGE, Utilities.icon);
            } else {
                JOptionPane.showMessageDialog(getContentPane(),
                        MessageFormat.format(labels.getString("fileInOutput"), defaultOutputDirectory) + ".",
                        labels.getString("fileSaved"), JOptionPane.INFORMATION_MESSAGE, Utilities.icon);
            }
            xmlEadList.updateUI();
        }
    });
    saveMessageReportItem.addActionListener(
            new MessageReportActionListener(retrieveFromDb, this, fileInstances, labels, this));
    sendFilesWebDAV.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    quitItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    xsltItem.addActionListener(new XsltAdderActionListener(this, labels));
    xsdItem.addActionListener(new XsdAdderActionListener(this, labels, retrieveFromDb));
    if (Utilities.isDev) {
        databaseItem.addActionListener(new DatabaseCheckerActionListener(retrieveFromDb, getContentPane()));
    }
    xmlEadList.addMouseListener(new ListMouseAdapter(xmlEadList, xmlEadListModel, deleteFileItem, this));
    xmlEadList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                if (xmlEadList.getSelectedValues() != null && xmlEadList.getSelectedValues().length != 0) {
                    if (xmlEadList.getSelectedValues().length > 1) {
                        //                            convertAndValidateBtn.setEnabled(true);
                        //                            validateSelectionBtn.setEnabled(true);
                        //                            if (isValidated(xmlEadList)) {
                        //                                convertEdmSelectionBtn.setEnabled(true);
                        //                            } else {
                        //                                convertEdmSelectionBtn.setEnabled(false);
                        //                            }
                        //                            disableAllBtnAndItems();
                        saveMessageReportItem.setEnabled(true);
                        changeInfoInGUI("");
                    } else {
                        //                            convertAndValidateBtn.setEnabled(false);
                        //                            validateSelectionBtn.setEnabled(false);
                        //                            convertEdmSelectionBtn.setEnabled(false);
                        changeInfoInGUI(((File) xmlEadList.getSelectedValue()).getName());
                        if (apePanel.getApeTabbedPane().getSelectedIndex() == APETabbedPane.TAB_EDITION) {
                            apePanel.getApeTabbedPane()
                                    .createEditionTree(((File) xmlEadList.getSelectedValue()));
                            if (tree != null) {
                                FileInstance fileInstance = fileInstances
                                        .get(((File) getXmlEadList().getSelectedValue()).getName());
                                tree.addMouseListener(new PopupMouseListener(tree, getDataPreparationToolGUI(),
                                        getContentPane(), fileInstance));
                            }
                        }
                        disableTabFlashing();
                    }
                    checkHoldingsGuideButton();
                } else {
                    //                        convertAndValidateBtn.setEnabled(false);
                    //                        validateSelectionBtn.setEnabled(false);
                    //                        convertEdmSelectionBtn.setEnabled(false);
                    createHGBtn.setEnabled(false);
                    analyzeControlaccessBtn.setEnabled(false);
                    changeInfoInGUI("");
                }
            }
        }

        private boolean isValidated(JList xmlEadList) {
            for (Object selectedValue : xmlEadList.getSelectedValues()) {
                File selectedFile = (File) selectedValue;
                String filename = selectedFile.getName();
                FileInstance fileInstance = fileInstances.get(filename);
                if (!fileInstance.isValid()) {
                    return false;
                }
            }
            return true;
        }
    });

    summaryWindowItem.addActionListener(new TabItemActionListener(apePanel, APETabbedPane.TAB_SUMMARY));
    validationWindowItem.addActionListener(new TabItemActionListener(apePanel, APETabbedPane.TAB_VALIDATION));
    conversionWindowItem.addActionListener(new TabItemActionListener(apePanel, APETabbedPane.TAB_CONVERSION));
    edmConversionWindowItem.addActionListener(new TabItemActionListener(apePanel, APETabbedPane.TAB_EDM));
    editionWindowItem.addActionListener(new TabItemActionListener(apePanel, APETabbedPane.TAB_EDITION));

    internetApexItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            BareBonesBrowserLaunch.openURL("http://www.apex-project.eu/");
        }
    });

    /**
     * Option Edit apeEAC-CPF file in the menu
     */

    this.editEacCpfFile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser eacFileChooser = new JFileChooser();
            eacFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            eacFileChooser.setMultiSelectionEnabled(false);
            eacFileChooser.setCurrentDirectory(new File(retrieveFromDb.retrieveOpenLocation()));
            if (eacFileChooser.showOpenDialog(getParent()) == JFileChooser.APPROVE_OPTION) {
                currentLocation = eacFileChooser.getCurrentDirectory();
                retrieveFromDb.saveOpenLocation(currentLocation.getAbsolutePath());

                File eacFile = eacFileChooser.getSelectedFile();
                if (!EacCpfFrame.isUsed()) {
                    try {
                        if (ReadXml.isXmlFile(eacFile, "eac-cpf")) {
                            new EacCpfFrame(eacFile, true, getContentPane().getSize(),
                                    (ProfileListModel) getXmlEadList().getModel(), labels);
                        } else {
                            JOptionPane.showMessageDialog(rootPane,
                                    labels.getString("eaccpf.error.notAnEacCpfFile"));
                        }
                    } catch (SAXException ex) {
                        if (ex instanceof SAXParseException) {
                            JOptionPane.showMessageDialog(rootPane,
                                    labels.getString("eaccpf.error.notAnEacCpfFile"));
                        }
                        java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName())
                                .log(java.util.logging.Level.SEVERE, null, ex);
                    } catch (IOException ex) {
                        java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName())
                                .log(java.util.logging.Level.SEVERE, null, ex);
                    } catch (ParserConfigurationException ex) {
                        java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName())
                                .log(java.util.logging.Level.SEVERE, null, ex);
                    } catch (Exception ex) {
                        try {
                            JOptionPane.showMessageDialog(rootPane, labels.getString(ex.getMessage()));
                        } catch (Exception ex1) {
                            JOptionPane.showMessageDialog(rootPane, "Error...");
                        }
                    }
                }
            }
        }
    });

    /**
     * Option Create apeEAC-CPF in the menu
     */
    this.createEacCpf.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (!EacCpfFrame.isUsed()) {
                EacCpfFrame eacCpfFrame = new EacCpfFrame(getContentPane().getSize(),
                        (ProfileListModel) getXmlEadList().getModel(), labels,
                        retrieveFromDb.retrieveCountryCode(), retrieveFromDb.retrieveRepositoryCode(), null,
                        null, null);
            }
        }
    });

}