Package com.intellij.openapi.fileChooser

Examples of com.intellij.openapi.fileChooser.FileSaverDialog


            }
        });
        results.getExportButton().addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                final FileSaverDescriptor descriptor = new FileSaverDescriptor("Save results to", "");
                final FileSaverDialog dialog = FileChooserFactory.getInstance().createSaveFileDialog(
                        descriptor, javaPuzzlersGame.getProject());
                VirtualFile base = javaPuzzlersGame.getProject().getBaseDir();

                final VirtualFileWrapper fileWrapper = dialog.save(base, "results.html");
                if (fileWrapper != null) {
                    ApplicationManager.getApplication().invokeLater(new Runnable() {
                        public void run() {
                            final VirtualFile fileToSave = fileWrapper.getVirtualFile(true);
                            assert fileToSave != null;
                            try {
                                fileToSave.setBinaryContent(results.exportResultsToXML(login.getLogin()).getBytes());
                            } catch (IOException e) {
                                e.printStackTrace(System.err);
                            }
                        }
                    });
                }

            }
        });
        results.getXsltButton().addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                final FileSaverDescriptor descriptor = new FileSaverDescriptor("Choose xsl file", "xsl");
                final FileChooserDialog dialog = FileChooserFactory.getInstance().createFileChooser(descriptor, javaPuzzlersGame.getProject());
                VirtualFile[] xsl = dialog.choose(null, javaPuzzlersGame.getProject());
                results.transformXML(javaPuzzlersGame.getProject(), login.getLogin(), xsl[0]);

            }
        });
View Full Code Here


            }
        });
        runButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                final FileSaverDescriptor descriptor = new FileSaverDescriptor("Save Main class to", "");
                final FileSaverDialog dialog = FileChooserFactory.getInstance().createSaveFileDialog(
                        descriptor, project);
                VirtualFile base = project.getBaseDir();
                try {
                    VirtualFile vf = base.findFileByRelativePath("src" + File.separator + "puzzlers");
                    if (vf == null || !vf.isDirectory()) {
                        VirtualFile sourceFolder = base.findChild("src");
                        if (sourceFolder == null) {
                            sourceFolder = vf.createChildDirectory(this, "src");
                        }
                        VirtualFile puzzlersFolder = sourceFolder.findChild("puzzlers");
                        if (puzzlersFolder == null) {
                            puzzlersFolder = sourceFolder.createChildDirectory(this, "puzzlers");
                        }
                        vf = puzzlersFolder;
                    }
                    base = vf;
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
                if (currentLanguage == null) {
                    return;
                }
                final VirtualFileWrapper fileWrapper = dialog.save(base, resolveClassName() + '.' + currentLanguage.getAssociatedFileType().getDefaultExtension());
                if (fileWrapper != null) {
                    ApplicationManager.getApplication().invokeLater(new Runnable() {
                        public void run() {
                            onFileToSaveChosen(fileWrapper);
                        }
View Full Code Here

    public void transformXML(final Project project, final String name, VirtualFile xsl) {
        try {

            final FileSaverDescriptor saverDescriptor = new FileSaverDescriptor("Save results to", "");
            final FileSaverDialog saverDialog = FileChooserFactory.getInstance().createSaveFileDialog(
                    saverDescriptor, project);
            VirtualFile base = project.getBaseDir();

            final VirtualFileWrapper fileWrapper = saverDialog.save(base, "");
            if (fileWrapper != null) {
                TransformerFactory tFactory = TransformerFactory.newInstance();

                final Transformer transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource(xsl.getInputStream()));
View Full Code Here

TOP

Related Classes of com.intellij.openapi.fileChooser.FileSaverDialog

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.