public void buildFinished(IJavaProject project) { try { StringBuilder sb = new StringBuilder(); PreProcessing(project.getElementName()); IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(Constants.BUNDLE_NAME); String fileName = prefs.get("LTiEFileName", "Empty String") + project.getElementName() + ".MTD"; sb.append("<COMPILE_INSTANCE>"); Calendar c = Calendar.getInstance(); SimpleDateFormat format = new SimpleDateFormat("EEE, MMM d, yyyy 'at' HH:mm:ss z"); sb.append( "<TIME UTC=\"" + c.getTimeInMillis() + "\">" + format.format(c.getTime()) + "</TIME>"); IPackageFragment[] packages = project.getPackageFragments(); sb.append("<PACKAGES>"); for (IPackageFragment aPackage : packages) { if (aPackage.getKind() == IPackageFragmentRoot.K_SOURCE) { String packageName = aPackage.getElementName().isEmpty() ? "default" : aPackage.getElementName(); Constants.writer.println("Package Fragment Name: " + packageName); sb.append("<PACKAGE>"); sb.append("<NAME>" + packageName + "</NAME>"); sb.append("<FILES>"); for (ICompilationUnit unit : aPackage.getCompilationUnits()) { sb.append("<FILE>"); sb.append("<NAME>" + unit.getElementName() + "</NAME>"); printFileInternals(unit, sb); printFilesProblems(unit, sb); sb.append("<SOURCE>" + StringEscapeUtils.escapeHtml4(unit.getSource()) + "</SOURCE>"); sb.append("</FILE>"); } ProcessUMLFiles(aPackage.getNonJavaResources(), sb); sb.append("</FILES>"); sb.append("</PACKAGE>"); } } sb.append("</PACKAGES>"); Object[] nonJavaResources = project.getNonJavaResources(); if (nonJavaResources != null && nonJavaResources.length > 0) { sb.append("<FILES>"); ProcessUMLFiles(nonJavaResources, sb); sb.append("</FILES>"); } sb.append("</COMPILE_INSTANCE>"); PrintWriter out = new PrintWriter(new FileWriter(fileName, true)); out.write(XMLFormatter.format(sb.toString())); out.close(); } catch (Exception e) { e.printStackTrace(Constants.writer); } }
@Override public Object execute(Object[] params) throws ParserConfigurationException, IOException, SAXException { Element element = (Element) params[0]; String attributeName = String.valueOf(params[1]); StringBuilder buf = new StringBuilder(); buf.append("<b>Element:</b>") .append(HighlighterUtils.INSTANCE.highlightXML(XMLFormatter.prettyPrint(element))); LOG.pureHtml(buf.toString()); String result = element.getAttribute(attributeName); LOG.createAppender() .appendBold("Get Element Attribute:") .appendProperty("Attribute", attributeName) .appendProperty("Result", result) .log(); return result; }