1 32 33 package com.jeantessier.dependencyfinder.gui; 34 35 import java.awt.event.*; 36 import java.io.*; 37 import java.util.*; 38 39 import javax.swing.*; 40 41 import com.jeantessier.classreader.*; 42 import com.jeantessier.dependency.*; 43 44 public class RefreshDependencyGraphAction extends AbstractAction implements Runnable { 45 private DependencyFinder model = null; 46 47 public RefreshDependencyGraphAction(DependencyFinder model) { 48 this.model = model; 49 50 putValue(Action.LONG_DESCRIPTION, "Re-extract the current dependency graph"); 51 putValue(Action.NAME, "Refresh"); 52 putValue(Action.SMALL_ICON, new ImageIcon(getClass().getResource("icons/refresh.gif"))); 53 } 54 55 public void actionPerformed(ActionEvent e) { 56 new Thread (this).start(); 57 } 58 59 public void run() { 60 Date start = new Date(); 61 62 model.clearDependencyResult(); 63 model.clearClosureResult(); 64 model.clearMetricsResult(); 65 66 model.getStatusLine().showInfo("Scanning ..."); 67 ClassfileScanner scanner = new ClassfileScanner(); 68 scanner.load(model.getInputFiles()); 69 70 model.getProgressBar().setMaximum(scanner.getNbFiles()); 71 72 model.getMonitor().setClosedSession(true); 73 74 ClassfileLoader loader = new TransientClassfileLoader(model.getClassfileLoaderDispatcher()); 75 loader.addLoadListener(new VerboseListener(model.getStatusLine(), model.getProgressBar())); 76 loader.addLoadListener(model.getMonitor()); 77 loader.load(model.getInputFiles()); 78 79 if (model.getMaximize()) { 80 model.getStatusLine().showInfo("Maximizing ..."); 81 new LinkMaximizer().traverseNodes(model.getPackages()); 82 } else if (model.getMinimize()) { 83 model.getStatusLine().showInfo("Minimizing ..."); 84 new LinkMinimizer().traverseNodes(model.getPackages()); 85 } 86 87 Date stop = new Date(); 88 89 model.getStatusLine().showInfo("Done (" + ((stop.getTime() - start.getTime()) / (double) 1000) + " secs)."); 90 } 91 } 92 | Popular Tags |