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);
}
}
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();
}
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) {
}
}
}
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");
}
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);
}
}
Aggregations