# HG changeset patch # User Tom Rodriguez # Date 1450198962 28800 # Node ID 4c89b26b4b2852b85ba9c22d5b3f0f664b1c9214 # Parent cc7291261d3493982f3824c52c3d6d6e1c0d7e51 Allow importing multiple files at once in IGV diff -r cc7291261d34 -r 4c89b26b4b28 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java Mon Dec 14 12:38:57 2015 -0800 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java Tue Dec 15 09:02:42 2015 -0800 @@ -94,72 +94,73 @@ JFileChooser fc = new JFileChooser(); fc.setFileFilter(ImportAction.getFileFilter()); fc.setCurrentDirectory(new File(Settings.get().get(Settings.DIRECTORY, Settings.DIRECTORY_DEFAULT))); + fc.setMultiSelectionEnabled(true); if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { - final File file = fc.getSelectedFile(); - - File dir = file; - if (!dir.isDirectory()) { - dir = dir.getParentFile(); - } + for (final File file : fc.getSelectedFiles()) { + File dir = file; + if (!dir.isDirectory()) { + dir = dir.getParentFile(); + } - Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath()); - try { - final FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ); - final ProgressHandle handle = ProgressHandleFactory.createHandle("Opening file " + file.getName()); - handle.start(WORKUNITS); - final long startTime = System.currentTimeMillis(); - final long start = channel.size(); - ParseMonitor monitor = new ParseMonitor() { - @Override - public void updateProgress() { - try { - int prog = (int) (WORKUNITS * (double) channel.position() / (double) start); - handle.progress(prog); - } catch (IOException ex) { - } - } - @Override - public void setState(String state) { - updateProgress(); - handle.progress(state); + Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath()); + try { + final FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ); + final ProgressHandle handle = ProgressHandleFactory.createHandle("Opening file " + file.getName()); + handle.start(WORKUNITS); + final long startTime = System.currentTimeMillis(); + final long start = channel.size(); + ParseMonitor monitor = new ParseMonitor() { + @Override + public void updateProgress() { + try { + int prog = (int) (WORKUNITS * (double) channel.position() / (double) start); + handle.progress(prog); + } catch (IOException ex) { + } + } + @Override + public void setState(String state) { + updateProgress(); + handle.progress(state); + } + }; + final GraphParser parser; + final OutlineTopComponent component = OutlineTopComponent.findInstance(); + if (file.getName().endsWith(".xml")) { + parser = new Parser(channel, monitor, null); + } else if (file.getName().endsWith(".bgv")) { + parser = new BinaryParser(channel, monitor, component.getDocument(), null); + } else { + parser = null; } - }; - final GraphParser parser; - final OutlineTopComponent component = OutlineTopComponent.findInstance(); - if (file.getName().endsWith(".xml")) { - parser = new Parser(channel, monitor, null); - } else if (file.getName().endsWith(".bgv")) { - parser = new BinaryParser(channel, monitor, component.getDocument(), null); - } else { - parser = null; + RequestProcessor.getDefault().post(new Runnable() { + @Override + public void run() { + try { + final GraphDocument document = parser.parse(); + if (document != null) { + SwingUtilities.invokeLater(new Runnable(){ + @Override + public void run() { + component.requestActive(); + component.getDocument().addGraphDocument(document); + } + }); + } + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + handle.finish(); + long stop = System.currentTimeMillis(); + Logger.getLogger(getClass().getName()).log(Level.INFO, "Loaded in " + file + " in " + ((stop - startTime) / 1000.0) + " seconds"); + } + }); + } catch (FileNotFoundException ex) { + Exceptions.printStackTrace(ex); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); } - RequestProcessor.getDefault().post(new Runnable() { - @Override - public void run() { - try { - final GraphDocument document = parser.parse(); - if (document != null) { - SwingUtilities.invokeLater(new Runnable(){ - @Override - public void run() { - component.requestActive(); - component.getDocument().addGraphDocument(document); - } - }); - } - } catch (IOException ex) { - Exceptions.printStackTrace(ex); - } - handle.finish(); - long stop = System.currentTimeMillis(); - Logger.getLogger(getClass().getName()).log(Level.INFO, "Loaded in " + file + " in " + ((stop - startTime) / 1000.0) + " seconds"); - } - }); - } catch (FileNotFoundException ex) { - Exceptions.printStackTrace(ex); - } catch (IOException ex) { - Exceptions.printStackTrace(ex); } } }