Search in sources :

Example 1 with ProgressMonitor

use of javax.swing.ProgressMonitor in project jadx by skylot.

the class MainWindow method saveAll.

private void saveAll(boolean export) {
    settings.setExportAsGradleProject(export);
    if (export) {
        settings.setSkipSources(false);
        settings.setSkipResources(false);
    }
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    fileChooser.setToolTipText(NLS.str("file.save_all_msg"));
    String currentDirectory = settings.getLastSaveFilePath();
    if (!currentDirectory.isEmpty()) {
        fileChooser.setCurrentDirectory(new File(currentDirectory));
    }
    int ret = fileChooser.showDialog(mainPanel, NLS.str("file.select"));
    if (ret == JFileChooser.APPROVE_OPTION) {
        settings.setLastSaveFilePath(fileChooser.getCurrentDirectory().getPath());
        ProgressMonitor progressMonitor = new ProgressMonitor(mainPanel, NLS.str("msg.saving_sources"), "", 0, 100);
        progressMonitor.setMillisToPopup(0);
        wrapper.saveAll(fileChooser.getSelectedFile(), progressMonitor);
    }
}
Also used : ProgressMonitor(javax.swing.ProgressMonitor) JFileChooser(javax.swing.JFileChooser) ResourceFile(jadx.api.ResourceFile) File(java.io.File)

Example 2 with ProgressMonitor

use of javax.swing.ProgressMonitor in project pcgen by PCGen.

the class NotesView method writeNotesFile.

/**
	 *  Writes out a GMN file
	 *
	 *@param  exportFile       file to export to
	 *@param  node             node to export
	 *@exception  IOException  file write failed for some reason
	 */
private void writeNotesFile(File exportFile, NotesTreeNode node) throws IOException {
    File dir = node.getDir();
    ZipOutputStream out = new ZipOutputStream(new FileOutputStream(exportFile));
    int max = fileCount(dir);
    ProgressMonitor pm = new ProgressMonitor(GMGenSystem.inst, "Writing out Notes Export", "Writing", 0, max);
    try {
        writeNotesDir(out, dir, dir, pm, 0);
    } finally // Always close the streams, even if exceptions were thrown
    {
        try {
            out.close();
        } catch (IOException e) {
        //TODO: Should this really be ignored?
        }
    }
    pm.close();
}
Also used : ProgressMonitor(javax.swing.ProgressMonitor) ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) Point(java.awt.Point)

Example 3 with ProgressMonitor

use of javax.swing.ProgressMonitor in project CFLint by cflint.

the class CFLintTask method execute.

@Override
public void execute() {
    FileInputStream fis = null;
    try {
        CFLintConfiguration config = null;
        if (configFile != null) {
            if (configFile.getName().toLowerCase().endsWith(".xml")) {
                config = ConfigUtils.unmarshal(new FileInputStream(configFile), CFLintConfig.class);
            } else {
                config = ConfigUtils.unmarshalJson(new FileInputStream(configFile), CFLintConfig.class);
            }
        }
        CFLintConfiguration cmdLineConfig = null;
        if ((excludeRule != null && excludeRule.trim().length() > 0) || (includeRule != null && includeRule.trim().length() > 0)) {
            cmdLineConfig = new CFLintConfig();
            if (includeRule != null && includeRule.trim().length() > 0) {
                for (final String code : includeRule.trim().split(",")) {
                    cmdLineConfig.addInclude(new PluginMessage(code));
                }
            }
            if (excludeRule != null && excludeRule.trim().length() > 0) {
                for (final String code : excludeRule.trim().split(",")) {
                    cmdLineConfig.addExclude(new PluginMessage(code));
                }
            }
        }
        // TODO combine configs
        final CFLint cflint = new CFLint(config);
        cflint.setVerbose(verbose);
        cflint.setQuiet(quiet);
        if (extensions != null && extensions.trim().length() > 0) {
            cflint.setAllowedExtensions(Arrays.asList(extensions.trim().split(",")));
        }
        CFLintFilter filter = CFLintFilter.createFilter(verbose);
        if (filterFile != null) {
            final File ffile = filterFile;
            if (ffile.exists()) {
                fis = new FileInputStream(ffile);
                final byte[] b = new byte[fis.available()];
                fis.read(b);
                filter = CFLintFilter.createFilter(new String(b), verbose);
            }
        }
        cflint.getBugs().setFilter(filter);
        if (xmlFile == null && htmlFile == null && textFile == null) {
            xmlFile = new File("cflint-result.xml");
        }
        if (xmlFile != null) {
            if (verbose) {
                System.out.println("Style:" + xmlStyle);
            }
            if ("findbugs".equalsIgnoreCase(xmlStyle)) {
                new XMLOutput().outputFindBugs(cflint.getBugs(), createWriter(xmlFile, StandardCharsets.UTF_8), showStats);
            } else {
                new DefaultCFlintResultMarshaller().output(cflint.getBugs(), createWriter(xmlFile, StandardCharsets.UTF_8), showStats);
            }
        }
        if (textFile != null) {
            final Writer textwriter = textFile != null ? new FileWriter(textFile) : new OutputStreamWriter(System.out);
            new TextOutput().output(cflint.getBugs(), textwriter, showStats);
        }
        if (htmlFile != null) {
            try {
                new HTMLOutput(htmlStyle).output(cflint.getBugs(), new FileWriter(htmlFile), showStats);
            } catch (final TransformerException e) {
                throw new IOException(e);
            }
        }
        for (final FileSet fileset : filesets) {
            int progress = 1;
            // 3
            final DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
            final ProgressMonitor progressMonitor = showProgress && !filesets.isEmpty() ? new ProgressMonitor(null, "CFLint", "", 1, ds.getIncludedFilesCount()) : null;
            final String[] includedFiles = ds.getIncludedFiles();
            for (final String includedFile : includedFiles) {
                if (progressMonitor.isCanceled()) {
                    throw new RuntimeException("CFLint scan cancelled");
                }
                final String filename = ds.getBasedir() + File.separator + includedFile;
                progressMonitor.setNote("scanning " + includedFile);
                cflint.scan(filename);
                progressMonitor.setProgress(progress++);
            }
        }
    } catch (final Exception e) {
        throw new RuntimeException(e);
    } finally {
        try {
            if (fis != null) {
                fis.close();
            }
        } catch (final IOException e) {
        }
    }
}
Also used : TextOutput(com.cflint.TextOutput) CFLintConfiguration(com.cflint.config.CFLintConfiguration) FileWriter(java.io.FileWriter) XMLOutput(com.cflint.XMLOutput) CFLint(com.cflint.CFLint) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) PluginMessage(com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage) DefaultCFlintResultMarshaller(com.cflint.xml.stax.DefaultCFlintResultMarshaller) TransformerException(javax.xml.transform.TransformerException) FileSet(org.apache.tools.ant.types.FileSet) HTMLOutput(com.cflint.HTMLOutput) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) CFLint(com.cflint.CFLint) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) ProgressMonitor(javax.swing.ProgressMonitor) CFLintConfig(com.cflint.config.CFLintConfig) CFLintFilter(com.cflint.tools.CFLintFilter) OutputStreamWriter(java.io.OutputStreamWriter) File(java.io.File) OutputStreamWriter(java.io.OutputStreamWriter) FileWriter(java.io.FileWriter) Writer(java.io.Writer)

Example 4 with ProgressMonitor

use of javax.swing.ProgressMonitor in project ACS by ACS-Community.

the class LogEntryTable method zoomTotalFileToRead.

/* (non-Javadoc)
	 * @see alma.acs.logging.archive.zoom.ZoomProgressListener#zoomTotalFileToRead(int)
	 */
@Override
public void zoomTotalFileToRead(int num) {
    zoomTotFiles = num;
    zoomProgressMonitor = new ProgressMonitor(this, "Zoom", null, 0, num);
    System.out.println("" + num + " files to read while zoom");
}
Also used : ProgressMonitor(javax.swing.ProgressMonitor)

Example 5 with ProgressMonitor

use of javax.swing.ProgressMonitor in project pcgen by PCGen.

the class NotesView method openGMN.

/**
	 *  Opens a .gmn file
	 *
	 *@param  notesFile  .gmn file to open
	 */
private void openGMN(File notesFile) {
    try {
        Object obj = notesTree.getLastSelectedPathComponent();
        if (obj instanceof NotesTreeNode) {
            NotesTreeNode node = (NotesTreeNode) obj;
            if (node != root) {
                int choice = JOptionPane.showConfirmDialog(this, "Importing note " + notesFile.getName() + " into a node other then root, Continue?", "Importing to a node other then root", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (choice == JOptionPane.NO_OPTION) {
                    return;
                }
            }
            InputStream in = new BufferedInputStream(new FileInputStream(notesFile));
            ZipInputStream zin = new ZipInputStream(in);
            ZipEntry e;
            ProgressMonitor pm = new ProgressMonitor(GMGenSystem.inst, "Reading Notes Export", "Reading", 1, 1000);
            int progress = 1;
            while ((e = zin.getNextEntry()) != null) {
                unzip(zin, e.getName(), node.getDir());
                progress++;
                if (progress > 99) {
                    progress = 99;
                }
                pm.setProgress(progress);
            }
            zin.close();
            pm.close();
        }
    } catch (IOException e) {
        JOptionPane.showMessageDialog(this, "Error Reading File" + notesFile.getName());
        Logging.errorPrint("Error Reading File" + notesFile.getName());
        Logging.errorPrint(e.getMessage(), e);
    }
}
Also used : ProgressMonitor(javax.swing.ProgressMonitor) ZipInputStream(java.util.zip.ZipInputStream) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) ZipInputStream(java.util.zip.ZipInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ZipEntry(java.util.zip.ZipEntry) IOException(java.io.IOException) Point(java.awt.Point) FileInputStream(java.io.FileInputStream)

Aggregations

ProgressMonitor (javax.swing.ProgressMonitor)5 File (java.io.File)3 IOException (java.io.IOException)3 Point (java.awt.Point)2 FileInputStream (java.io.FileInputStream)2 CFLint (com.cflint.CFLint)1 HTMLOutput (com.cflint.HTMLOutput)1 TextOutput (com.cflint.TextOutput)1 XMLOutput (com.cflint.XMLOutput)1 CFLintConfig (com.cflint.config.CFLintConfig)1 CFLintConfiguration (com.cflint.config.CFLintConfiguration)1 PluginMessage (com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage)1 CFLintFilter (com.cflint.tools.CFLintFilter)1 DefaultCFlintResultMarshaller (com.cflint.xml.stax.DefaultCFlintResultMarshaller)1 ResourceFile (jadx.api.ResourceFile)1 BufferedInputStream (java.io.BufferedInputStream)1 FileOutputStream (java.io.FileOutputStream)1 FileWriter (java.io.FileWriter)1 InputStream (java.io.InputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1