final List<String> packagesList = getPackageListInteractively();
if (packagesList == null || packagesList.isEmpty()) {
return;
}
final SequenceDiagramContext ctx = new SequenceDiagramContext();
final SequenceDiagramGenerator gen = new SequenceDiagramGenerator(
classLoader);
ctx.setClassInfo(new ClassInfo(className, gen.getClassLoader()));
ctx.setFilters(packagesList
.toArray(IConstants.ZERO_LENGTH_STRING_ARRAY));
ctx.setFollowInvokedMethods(false);
// Show source code lines.
ctx.setShowSourceLines(true);
// Find all relevant source code locations.
// Actually, ask the user to provide these (if any).
// ctx.setSourceCodeManager(sourceCodeManager)
ctx.setShowInstructions(false);
ClassInfo classInfo = new ClassInfo(className, gen.getClassLoader());
final List<MethodInfo> methods = classInfo.getMethods();
final Map<MethodInfo, byte[]> diagrams = new HashMap<MethodInfo, byte[]>();
// Create the sequence diagram.
new TaskRunner(new ISwingRunnableWithProgress() {
public void run(IProgress progress) throws Throwable {
progress.setRange(0, methods.size() + 1);
for (MethodInfo method : methods) {
progress.increment(1, "Processing "
+ method.getMethodName());
ctx.setMethodInfo(method);
diagrams.put(method, DrawImage
.drawImage(gen.generateSequenceDiagramSpec(ctx),
OutputFormat.JPG));
}
}