From 58f2b4b37cd525bd4793f8704122259623d0b836 Mon Sep 17 00:00:00 2001 From: Manlio Bacco <manlio.bacco@isti.cnr.it> Date: Tue, 4 Dec 2012 16:14:31 +0000 Subject: [PATCH] --- .../META-INF/MANIFEST.MF | 2 +- .../icons/icon_question_sml.gif | Bin 0 -> 619 bytes .../icons/icon_success_sml.gif | Bin 0 -> 990 bytes .../tools/conformanceTools/Activator.java | 3 +- .../conformanceTools/checks/api/Check.java | 6 +- .../checks/api/CheckImpl.java | 11 + .../checks/{impl => api}/SubInterfaces.java | 2 +- .../{Activator.java => ActivatorCheck.java} | 11 +- .../checks/impl/Maven_nature.java | 12 +- .../checks/impl/NameGroupID.java | 20 +- .../checks/impl/OSGI_bundle.java | 11 +- .../checks/impl/POM_file.java | 12 +- .../markers/BugResolution.java | 7 +- .../tools/conformanceTools/run/ToolsRun.java | 263 ++++++++++++------ .../conformanceTools/utils/RunPlugin.java | 8 +- .../conformanceTools/windows/MainFrame.java | 15 +- 16 files changed, 229 insertions(+), 154 deletions(-) create mode 100644 conformance/org.universaal.tools.conformanceTools/icons/icon_question_sml.gif create mode 100644 conformance/org.universaal.tools.conformanceTools/icons/icon_success_sml.gif create mode 100644 conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/api/CheckImpl.java rename conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/{impl => api}/SubInterfaces.java (88%) rename conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/{Activator.java => ActivatorCheck.java} (83%) diff --git a/conformance/org.universaal.tools.conformanceTools/META-INF/MANIFEST.MF b/conformance/org.universaal.tools.conformanceTools/META-INF/MANIFEST.MF index f38c64bd2..6d4bdf26a 100644 --- a/conformance/org.universaal.tools.conformanceTools/META-INF/MANIFEST.MF +++ b/conformance/org.universaal.tools.conformanceTools/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: ConformanceTools Bundle-SymbolicName: org.universaal.tools.conformanceTools;singleton:=true -Bundle-Version: 0.4.5 +Bundle-Version: 0.4 Bundle-Activator: org.universaal.tools.conformanceTools.Activator Bundle-Vendor: universAAL Require-Bundle: org.eclipse.ui, diff --git a/conformance/org.universaal.tools.conformanceTools/icons/icon_question_sml.gif b/conformance/org.universaal.tools.conformanceTools/icons/icon_question_sml.gif new file mode 100644 index 0000000000000000000000000000000000000000..34f04f6ed6d446d6549d74953ce7411aebea386d GIT binary patch literal 619 zcmZ?wbhEHb6k-r!I3~;>;IU!(z8mF}*EpB1{P5v}K){8v*|!dycwkWQ-y)`O!iooH z@4lb3Xmdcr1%-qUX*2(CIPf8$1IRe@|NsB`#a9&~HpI6ro3P@;feRlJCVY7C;eTM( zyafmTH>~(?oc3QK;=zOs{|jdy7YI1;;luwan{PN&e2DD3l-_%I^7@M#PCPhp;eSBI zfd?->luX_l(C~l3jt31Z9`tW{w(tDYh6NWCGX8tDT~Y`*u=dnbhl2kbPW%t3Tv{;W zf5D6o3wC@6Xn0URe^1$*OFNF;JaFSf`-&R^0UN5PE>Xz%klnUn!H)k49T$#Ye;Lwy z^}~<<hpxU^viqSz#DSom{|*)Z9{_zCaiM(4!wn}s1ogb%eDZ$VnoB?*(H|)OWMLFx zsAte&00K~)FtDF!sBda+X>DuoXyx`Z6cKV})af)2aq<xs_Hj}SZ#Vbz(UJ`akd=^% zVC)L<kqPveE@f>iCFIrO=cE;AEo{ke>7yE|snNpbBWn?$z~N>iEa<5$)}kh?$8pO< za+aCDFlURYaG;zUpP;aSzl-R@7H=OLK6!a@VOAv<Z5HVkjh2v~21^_GC6pK#Dhd~H zEL3wa(GXB{I>^#$yhMgGsDp)vS6|Ae^3ns=ZZRIdg%%T=7}S{91JovcOm=AEwPGpo MIkH*(yaR(Z0C;I#{r~^~ literal 0 HcmV?d00001 diff --git a/conformance/org.universaal.tools.conformanceTools/icons/icon_success_sml.gif b/conformance/org.universaal.tools.conformanceTools/icons/icon_success_sml.gif new file mode 100644 index 0000000000000000000000000000000000000000..52e85a430af9da4dfb217d71b4d6f3a1d4a4b571 GIT binary patch literal 990 zcmZ?wbhEHb<Y(Y#_|5<V|NsAQnYnA(wsXt3pWAcd*71uE_Mf<#T(@Z9#^d*&zAc}y zrhev@Wjjt!U$=km=EE!Zo(?W-lGW00TDVq9RYTdrR$5(4(b!y8M_<F)L*3C$&CW?q z-$+(VN7KzyTuCvYD0|MHEsGB9$eP;LvSv=nobE+OH@PMIH?QqCceg%z?Zn&@i`QIR zx&8K*9rrgGIq7YBxODTQW!oRG-tlD3jwfq(Jzc-&>Bjy;4ci{C-1K14rU#4Xoa<O~ zZ^r67Ggsc6zWVm`*r`r)&$TYP(!KKb#JOi%)?S?+JH>9{m6qopA9n0cn|!>ecYkij zwyX=!4*mH3EoqLqSGiVbyFqxD(bS8XSDu{6U1jZ<u2QtwK7WmE>O70Ic@{~t&7=B^ zBD)NOoAkU&Gy^LQJ5PtV?u{&65}4ZUmfYbweP{LTy^YnAGv=<HaPIo?cb{LioN_PQ z?ohhbK6|NE#ys<cNyc798uf==<0cvh*60M+>AGa7*6wj}%~b0?7r5!@qH7P%p1*$L z@#{ODxoUwG+WsY)zWExj-aqxpQS(e!bx&6L`u)?tfB$~}{{8*?cVO&*V`-G2NeC$Z zWMO1r=w{FXnGVVm3>>=|#5rX=HY{-DP?VF<iCEyuE5;(mCz9yw#wR2sZd%~Te5_xV zTTIKqP`Qm?$uC64-~~fFpPb_imIXo!7c`36w#h_pQfrV@;N<WV2wLJf$&iul=s~8W z2My9*6IebRRzDzTmEXf5V3E`{!?>NPL-%m%>B+*~5-k^-+4*MLF<z<ZJhYTsf<@!T znZm_KyQi9DJh`%wS>r;tQ0}^rlS-^!^Q`Mx1hrB$jw<m>n&hk~Xk=#Nl+_9Nu|Y$D G!5RQ;-6)O# literal 0 HcmV?d00001 diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/Activator.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/Activator.java index e1db426ac..9a363c1f2 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/Activator.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/Activator.java @@ -14,7 +14,6 @@ public class Activator extends AbstractUIPlugin { // The shared instance private static Activator plugin; - public static String absolutePath; /** @@ -30,7 +29,7 @@ public class Activator extends AbstractUIPlugin { public void start(BundleContext context) throws Exception { super.start(context); plugin = this; - absolutePath=context.getBundle().getLocation().substring(15);//Remove "reference:file:" + absolutePath = context.getBundle().getLocation().replace("initial@reference:file:", ""); } /* diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/api/Check.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/api/Check.java index caca43c4c..e6dfa72eb 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/api/Check.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/api/Check.java @@ -4,9 +4,9 @@ import org.eclipse.core.resources.IResource; public interface Check { - public final String ok = ""; //image path - public final String ko = ""; //image path - public final String maybe = ""; //image path + public final String ok = "icon_success_sml.gif"; + public final String ko = "icon_error_sml.gif"; + public final String unknown = "icon_question_sml.gif"; public String getCheckName(); diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/api/CheckImpl.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/api/CheckImpl.java new file mode 100644 index 000000000..c661b5611 --- /dev/null +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/api/CheckImpl.java @@ -0,0 +1,11 @@ +package org.universaal.tools.conformanceTools.checks.api; + +public abstract class CheckImpl implements Check { + + protected String result = "Test not yet performed."; + + @Override + public String getCheckResultDescription() { + return result; + } +} \ No newline at end of file diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/SubInterfaces.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/api/SubInterfaces.java similarity index 88% rename from conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/SubInterfaces.java rename to conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/api/SubInterfaces.java index c9dcbaf0d..3d8731c07 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/SubInterfaces.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/api/SubInterfaces.java @@ -1,4 +1,4 @@ -package org.universaal.tools.conformanceTools.checks.impl; +package org.universaal.tools.conformanceTools.checks.api; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/Activator.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/ActivatorCheck.java similarity index 83% rename from conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/Activator.java rename to conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/ActivatorCheck.java index 33be920ea..d516629b4 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/Activator.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/ActivatorCheck.java @@ -6,15 +6,13 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.eclipse.core.resources.IResource; -import org.universaal.tools.conformanceTools.checks.api.Check; +import org.universaal.tools.conformanceTools.checks.api.CheckImpl; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -public class Activator implements Check { - - private String result = "Test not yet performed."; +public class ActivatorCheck extends CheckImpl { @Override public String getCheckName() { @@ -53,9 +51,4 @@ public class Activator implements Check { result = "This project has not a proper Activator class."; return ko; } - - @Override - public String getCheckResultDescription() { - return result; - } } diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/Maven_nature.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/Maven_nature.java index 1b27b6d24..e8edc9c9e 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/Maven_nature.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/Maven_nature.java @@ -3,11 +3,10 @@ package org.universaal.tools.conformanceTools.checks.impl; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.m2e.core.internal.IMavenConstants; -import org.universaal.tools.conformanceTools.checks.api.Check; +import org.universaal.tools.conformanceTools.checks.api.CheckImpl; +import org.universaal.tools.conformanceTools.checks.api.SubInterfaces; -public class Maven_nature implements Check { - - private String result = "Test not yet performed."; +public class Maven_nature extends CheckImpl { @Override public String getCheckName() { @@ -34,9 +33,4 @@ public class Maven_nature implements Check { result = "Selected project has not Maven nature."; return ko; } - - @Override - public String getCheckResultDescription() { - return result; - } } \ No newline at end of file diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/NameGroupID.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/NameGroupID.java index deadc518d..fb882ea56 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/NameGroupID.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/NameGroupID.java @@ -8,15 +8,14 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.m2e.core.internal.IMavenConstants; -import org.universaal.tools.conformanceTools.checks.api.Check; +import org.universaal.tools.conformanceTools.checks.api.CheckImpl; +import org.universaal.tools.conformanceTools.checks.api.SubInterfaces; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -public class NameGroupID implements Check { - - private String result = "Test not yet performed."; +public class NameGroupID extends CheckImpl { private final String AALapp = "org.universAAL.AALaaplication"; private final String AAL = "org.universAAL"; @@ -65,14 +64,14 @@ public class NameGroupID implements Check { } if(groupID != null && artifactID != null){ - if(groupID.equals(AALapp) && artifactId.equals(AALapp)) + if(groupID.equals(AALapp) && artifactID.equals(AALapp)) result = "Selected project is a uAAL application from WP4?"; - if(groupID.equals(AAL) && artifactId.equals(AAL)) + if(groupID.equals(AAL) && artifactID.equals(AAL)) result = "Selected project is a uAAL code package?"; - if(groupID.equals(noAAL) && artifactId.equals(noAAL)) + if(groupID.equals(noAAL) && artifactID.equals(noAAL)) result = "Are you a developer outside uAAL?"; - return maybe; + return unknown; } else{ result = "Selected project has not valid descriptors."; @@ -85,11 +84,6 @@ public class NameGroupID implements Check { return ko; } - @Override - public String getCheckResultDescription() { - return result; - } - private String checkNamingConvention(String tag){ if(tag != null && !tag.isEmpty()){ if(tag.startsWith("org.universAAL.AALaaplication")) diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/OSGI_bundle.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/OSGI_bundle.java index 6af69111f..94be64ee2 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/OSGI_bundle.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/OSGI_bundle.java @@ -9,15 +9,13 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.universaal.tools.conformanceTools.checks.api.Check; +import org.universaal.tools.conformanceTools.checks.api.CheckImpl; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -public class OSGI_bundle implements Check{ - - private String result = "Test not yet performed."; +public class OSGI_bundle extends CheckImpl { @Override public String getCheckName() { @@ -57,11 +55,6 @@ public class OSGI_bundle implements Check{ return ko; } - @Override - public String getCheckResultDescription() { - return result; - } - private String getProjectPath(IResource resource) throws CoreException{ return ResourcesPlugin.getWorkspace().getRoot().getLocation().makeAbsolute()+"/"+((IProject)resource).getDescription().getName(); diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/POM_file.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/POM_file.java index 855810cc5..d0cd205ee 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/POM_file.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/impl/POM_file.java @@ -5,11 +5,10 @@ import java.io.File; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.m2e.core.internal.IMavenConstants; -import org.universaal.tools.conformanceTools.checks.api.Check; +import org.universaal.tools.conformanceTools.checks.api.CheckImpl; +import org.universaal.tools.conformanceTools.checks.api.SubInterfaces; -public class POM_file implements Check { - - private String result = "Test not yet performed."; +public class POM_file extends CheckImpl { @Override public String getCheckName() { @@ -37,11 +36,6 @@ public class POM_file implements Check { return ko; } - @Override - public String getCheckResultDescription() { - return result; - } - public File getPOMfile(IResource resource) throws Exception{ if(check(resource).equals(ok)){ diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/markers/BugResolution.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/markers/BugResolution.java index 07691fc30..b19667465 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/markers/BugResolution.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/markers/BugResolution.java @@ -4,7 +4,6 @@ import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; import org.eclipse.ui.IMarkerResolution; import org.eclipse.ui.IMarkerResolutionGenerator2; -import org.universaal.tools.conformanceTools.utils.RunPlugin; public class BugResolution implements IMarkerResolutionGenerator2 { @@ -46,12 +45,12 @@ public class BugResolution implements IMarkerResolutionGenerator2 { public void run(IMarker marker) { try { String plugin = (String) marker.getAttribute(IMarker.SOURCE_ID); - if(plugin.equals(RunPlugin.FindBugs)){ + /*if(plugin.equals(RunPlugin.FindBugs)){ //@edu.umd.cs.findbugs.annotations.SuppressWarnings("URF_UNREAD_FIELD") String error = (String) marker.getAttribute(IMarker.TEXT); } - else - markers.deleteMarker(marker); + else*/ + markers.deleteMarker(marker); } catch (CoreException e) { e.printStackTrace(); } diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/run/ToolsRun.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/run/ToolsRun.java index 913ed19a2..13ddfd048 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/run/ToolsRun.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/run/ToolsRun.java @@ -44,13 +44,17 @@ import org.eclipse.m2e.core.embedder.IMaven; import org.eclipse.m2e.core.internal.IMavenConstants; import org.eclipse.m2e.core.project.IMavenProjectFacade; import org.eclipse.m2e.core.project.IMavenProjectRegistry; -import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; import org.eclipse.ui.ide.IDE; import org.osgi.framework.Bundle; import org.universaal.tools.conformanceTools.Activator; +import org.universaal.tools.conformanceTools.checks.api.CheckImpl; +import org.universaal.tools.conformanceTools.checks.impl.ActivatorCheck; +import org.universaal.tools.conformanceTools.checks.impl.Maven_nature; import org.universaal.tools.conformanceTools.checks.impl.NameGroupID; +import org.universaal.tools.conformanceTools.checks.impl.OSGI_bundle; +import org.universaal.tools.conformanceTools.checks.impl.POM_file; import org.universaal.tools.conformanceTools.markers.CTMarker; import org.universaal.tools.conformanceTools.markers.Markers; import org.universaal.tools.conformanceTools.utils.HtmlPage; @@ -65,7 +69,6 @@ public class ToolsRun { private static ToolsRun instance; - private RunPlugin plugin; private IProject projectToAnalyze; private IWorkbenchWindow window; private ISelection selection; @@ -86,7 +89,7 @@ public class ToolsRun { private ToolsRun(){ orderderbugsMap = new ArrayList<BugDescriptor>(); - markers = Markers.getInstance(); + markers = Markers.getInstance(); } public static synchronized ToolsRun getInstance(){ @@ -98,7 +101,6 @@ public class ToolsRun { public void run(IWorkbenchWindow window, RunPlugin plugin) { - this.plugin = plugin; this.window = window; this.selection = window.getSelectionService().getSelection("org.eclipse.jdt.ui.PackageExplorer"); @@ -124,11 +126,25 @@ public class ToolsRun { return; } try{ - //removeOldBugs(); - //testConformance(); + verifyImages(); - NameGroupID t = new NameGroupID(); - t.check(this.projectToAnalyze); + if(plugin == RunPlugin.CodeStyle){ + removeOldBugs(); + testConformance(); + } + + if(plugin == RunPlugin.CustomChecks){ + + List<String> checks = new ArrayList<String>(); + checks.add(ActivatorCheck.class.getName()); + checks.add(Maven_nature.class.getName()); + checks.add(NameGroupID.class.getName()); + checks.add(OSGI_bundle.class.getName()); + checks.add(POM_file.class.getName()); + + List<Result> results = test(checks); + visualizeNewResults(results); + } } catch(Exception ex){ ex.printStackTrace(); } } @@ -136,6 +152,80 @@ public class ToolsRun { System.out.println("uAAL CT - no valid selection."); } + private void visualizeNewResults(List<Result> results){ + + try{ + HtmlPage page = new HtmlPage("uAAL CONFORMANCE TOOLS - ANALYSIS RESULTS"); + String path_ = ResourcesPlugin.getWorkspace().getRoot().getLocation().makeAbsolute()+"/"+projectToAnalyze.getDescription().getName()+"/target/site/images/logos/"; + + Table t = page.new Table(results.size()+2, 4); + + // table header + t.addContentCentered("<font size='5'><b>TEST RESULT</b></font>", 0, 0); + t.addContentCentered("<font size='5'><b>TEST NAME</b></font>", 0, 1); + t.addContentCentered("<font size='5'><b>TEST DESCRIPTION</b></font>", 0, 2); + t.addContentCentered("<font size='5'><b>RESULT DESCRIPTION</b></font>", 0, 3); + + for(int i = 0; i < results.size(); i++){ + Result check = results.get(i); + t.addContentCentered("<img src='"+path_+check.resultImg+"' />", i+1, 0); + t.addContentCentered(check.checkName, i+1, 1); + t.addContentCentered(check.checkDescription, i+1, 2); + t.addContentCentered(check.resultDscr, i+1, 3); + } + + page.getBody().addElement(t.getTable()); + page.getBody().addElement("<br/><br/><p>Total: "+results.size()+" performed test(s).</p>"); + String filePath = ResourcesPlugin.getWorkspace().getRoot().getLocation().makeAbsolute()+"/"+projectToAnalyze.getDescription().getName()+"/target/site/"+fileNameResults; + File file = new File(filePath); + page.write(file); + + IDE.openEditorOnFileStore( window.getActivePage(), EFS.getLocalFileSystem().getStore(file.toURI()) ); + } + catch(Exception ex){ + ex.printStackTrace(); + } + } + + private List<Result> test(List<String> checks){ + + List<Result> results = new ArrayList<Result>(); + try{ + for(String c: checks){ + Object ck = Class.forName(c).newInstance(); + CheckImpl check = (CheckImpl) ck; + + String name = check.getCheckName(); + String description = check.getCheckDescription(); + + String resultImg = check.check(this.projectToAnalyze); + String resultDscr = check.getCheckResultDescription(); + + results.add(new Result(name, description, resultImg, resultDscr)); + } + + if(results != null) + return results; + } + catch(Exception ex){ + ex.printStackTrace(); + } + + return null; + } + + private class Result{ + + private String checkName, checkDescription, resultImg, resultDscr; + + public Result(String checkName, String checkDescription, String resultImg, String resultDscr){ + this.checkName = checkName; + this.checkDescription = checkDescription; + this.resultImg = resultImg; + this.resultDscr = resultDscr; + } + } + private void testConformance() throws CoreException { final String path_ = ResourcesPlugin.getWorkspace().getRoot().getLocation().makeAbsolute()+"/"+projectToAnalyze.getDescription().getName(); @@ -172,11 +262,11 @@ public class ToolsRun { if (!description.isAutoBuilding()) goals.add("compiler:compile"); // compile it if autobuilding is off - if(plugin == RunPlugin.FindBugs) - goals.add("findbugs:findbugs"); + //if(plugin == RunPlugin.FindBugs) + goals.add("findbugs:findbugs"); - else if(plugin == RunPlugin.CheckStyle) - goals.add("checkstyle:checkstyle"); + //else if(plugin == RunPlugin.CheckStyle) + goals.add("checkstyle:checkstyle"); request.setGoals(goals); MavenExecutionResult result = maven.execute(request, monitor); @@ -207,17 +297,17 @@ public class ToolsRun { projectFacade.getResolverConfiguration(), monitor); Properties props = new Properties(); - if(plugin == RunPlugin.FindBugs){ + //if(plugin == RunPlugin.FindBugs){ - goals.add("findbugs:check"); - props.setProperty("findbugs.failOnError", "false"); - } - else if(plugin == RunPlugin.CheckStyle){ + goals.add("findbugs:check"); + props.setProperty("findbugs.failOnError", "false"); + //} + //else if(plugin == RunPlugin.CheckStyle){ - goals.add("checkstyle:check"); - props.setProperty("checkstyle.failOnViolation", "false"); - props.setProperty("checkstyle.failsOnError", "false"); - } + goals.add("checkstyle:check"); + props.setProperty("checkstyle.failOnViolation", "false"); + props.setProperty("checkstyle.failsOnError", "false"); + //} request2.setUserProperties(props); request2.setGoals(goals); @@ -242,43 +332,46 @@ public class ToolsRun { public void run() { try{ - File f = null; + //if(plugin == RunPlugin.CheckStyle) + //f = new File(path_+"/target/checkstyle-result.xml"); + int[] maxMinCK = parseCheckstyleResult(new File(path_+"/target/checkstyle-result.xml")); - if(plugin == RunPlugin.CheckStyle){ - f = new File(path_+"/target/checkstyle-result.xml"); - } + //if(plugin == RunPlugin.FindBugs) + //f = new File(path_+"/target/findbugsXml.xml"); + int[] maxMinFB = parseFindBugsResults(new File(path_+"/target/findbugsXml.xml")); - if(plugin == RunPlugin.FindBugs) - f = new File(path_+"/target/findbugsXml.xml"); - - if (f != null && f.exists() ){ + int max = 0, min = 0; + if(maxMinCK[0] >= maxMinFB[0]) + max = maxMinCK[0]; + else + max = maxMinFB[0]; + if(maxMinCK[1] < maxMinFB[1]) + min = maxMinCK[1]; + else + min = maxMinFB[1]; - if(plugin == RunPlugin.FindBugs) - parseFindBugsResults(f); - else if(plugin == RunPlugin.CheckStyle) - parseCheckstyleResult(f); + orderBySeverity(max, min); - visualizeResults(); - f = new File(path_+"/target/site/"+fileNameResults); + //if(plugin == RunPlugin.FindBugs) + //parseFindBugsResults(f); + //else if(plugin == RunPlugin.CheckStyle) + //parseCheckstyleResult(f); - org.eclipse.core.filesystem.IFileStore fileStore = EFS.getLocalFileSystem().getStore(f.toURI()); - IWorkbenchPage page = window.getActivePage(); + visualizeResults(); + //f = new File(path_+"/target/site/"+fileNameResults); - try { - verifyImages(); - if(page != null && fileStore != null) - IDE.openEditorOnFileStore( page, fileStore ); - else - System.out.println("uAAL CT - can't open report file - "+plugin); - } - catch ( PartInitException e ) { - e.printStackTrace(); - } + org.eclipse.core.filesystem.IFileStore fileStore = EFS.getLocalFileSystem().getStore( + new File(path_+"/target/site/"+fileNameResults).toURI()); + try { + if(fileStore != null) + IDE.openEditorOnFileStore( window.getActivePage(), fileStore ); + else + System.out.println("uAAL CT - can't open report file."); } - else - System.out.println("uAAL CT - does file "+path_+"/target/site/"+"fileNameResults"+" exist?"); - + catch ( PartInitException e ) { + e.printStackTrace(); + } } catch(Exception ex){ ex.printStackTrace(); @@ -305,7 +398,7 @@ public class ToolsRun { job.schedule(); } - private void parseFindBugsResults(File xml){ + private int[] parseFindBugsResults(File xml){ int maxSeverity = -1; int minSeverity = 1000; @@ -321,7 +414,7 @@ public class ToolsRun { BugDescriptor bd = new BugDescriptor(); - bd.setPlugin(RunPlugin.FindBugs); + //bd.setPlugin(RunPlugin.FindBugs); if(bug.getNodeType() == Node.ELEMENT_NODE){ Element bug_ = (Element) bug; @@ -353,15 +446,18 @@ public class ToolsRun { } } - orderBySeverity(maxSeverity, minSeverity); + //orderBySeverity(maxSeverity, minSeverity); markClasses(); + return new int[]{maxSeverity, minSeverity}; } catch(Exception ex){ ex.printStackTrace(); } + + return new int[]{0, 0}; } - private void parseCheckstyleResult(File xml){ + private int[] parseCheckstyleResult(File xml){ int min = 0, max = 0; try{ @@ -383,7 +479,7 @@ public class ToolsRun { Element error_ = (Element) error; BugDescriptor bd = new BugDescriptor(); - bd.setPlugin(RunPlugin.CheckStyle); + //bd.setPlugin(RunPlugin.CheckStyle); String separator = "\\\\"; String[] path = fileName.trim().split(separator); @@ -419,12 +515,15 @@ public class ToolsRun { } } - orderBySeverity(max, min); + //orderBySeverity(max, min); markClasses(); + return new int[]{max, min}; } catch(Exception ex){ ex.printStackTrace(); } + + return new int[]{0, 0}; } private void removeOldBugs(){ @@ -435,14 +534,14 @@ public class ToolsRun { int k = 0; for(int i = 0; i < orderderbugsMap.size(); i++){ if(orderderbugsMap.get(i) != null) - if(orderderbugsMap.get(i).getPlugin() == this.plugin){ - orderderbugsMap.set(i, null); - k++; - } + //if(orderderbugsMap.get(i).getPlugin() == this.plugin){ + orderderbugsMap.set(i, null); + k++; + //} } System.out.println("uAAL CT - deleted "+k+" bug instances."); - markers.deleteAll(this.plugin); + markers.deleteAll(/*this.plugin*/); } catch(Exception ex){ ex.printStackTrace(); @@ -492,7 +591,7 @@ public class ToolsRun { if(!orderderbugsMap.get(j).getSeverityDescription().equals(no_severity)){ - attributes.put(IMarker.SOURCE_ID, orderderbugsMap.get(j).getPlugin()); + //attributes.put(IMarker.SOURCE_ID, orderderbugsMap.get(j).getPlugin()); if(orderderbugsMap.get(j).getSeverityDescription().equals(low_severity)){ attributes.put(IMarker.SEVERITY, IMarker.SEVERITY_INFO); @@ -542,7 +641,7 @@ public class ToolsRun { try{ HtmlPage page = new HtmlPage("uAAL CONFORMANCE TOOLS - ANALYSIS RESULTS"); String path_ = ResourcesPlugin.getWorkspace().getRoot().getLocation().makeAbsolute()+"/"+projectToAnalyze.getDescription().getName()+"/target/site/images/logos/maven-feather.png"; - page.getBody().addElement("<img src='"+path_+"' alt='Maven Logo'><br/><br/>"); + page.getBody().addElement("<img src='"+path_+"' alt='Maven Logo' /><br/><br/>"); Table t = page.new Table(getBugsNumber()+2, 6); @@ -592,16 +691,16 @@ public class ToolsRun { private void verifyImages(){ - try{ - String errFN = "icon_error_sml.gif"; - String infFN = "icon_info_sml.gif"; - String warnFN = "icon_warning_sml.gif"; - String mavFN = "maven-feather.png"; - + try{ String destPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().makeAbsolute()+"/"+this.projectToAnalyze.getDescription().getName(); String destInternalProjectPath = "/target/site/images/"; - File target, site, images, logos; + Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID); + + File dir = new File(Activator.absolutePath+"/icons/"); + File[] icons = dir.listFiles(); + + File target, site, images, logos; // subdirectories structure target = new File(destPath+"/target"); if(!target.exists()) target.mkdir(); @@ -613,27 +712,25 @@ public class ToolsRun { images.mkdir(); logos = new File(destPath+"/target/site/images/logos/"); if(!logos.exists()) - logos.mkdir(); + logos.mkdir(); - Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID); - - copyFile(bundle, destPath, destInternalProjectPath, errFN, "/icons/"); - copyFile(bundle, destPath, destInternalProjectPath, infFN, "/icons/"); - copyFile(bundle, destPath, destInternalProjectPath, warnFN, "/icons/"); - copyFile(bundle, destPath, destInternalProjectPath+"logos/", mavFN, "/icons/"); + for(File icon: icons){ + copyFile(bundle, destPath+destInternalProjectPath, icon.getName(), "/icons/"); + copyFile(bundle, destPath+destInternalProjectPath+"logos/", icon.getName(), "/icons/"); + } } catch(Exception ex){ ex.printStackTrace(); } } - private void copyFile(Bundle bundle, String destPath, String destInternalProjectPath, String fileName, String sourceInternalProjectPath){ + private void copyFile(Bundle bundle, String destPath, String fileName, String sourcePath){ try{ - Path path = new Path(sourceInternalProjectPath+fileName); + Path path = new Path(sourcePath+fileName); URL fileURL = Platform.find(bundle, path); InputStream is = fileURL.openStream(); - OutputStream os = new FileOutputStream(destPath+destInternalProjectPath+fileName); + OutputStream os = new FileOutputStream(destPath+fileName); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { @@ -689,14 +786,14 @@ public class ToolsRun { private String clazz; private String errorType; private ICompilationUnit cu; - private RunPlugin plugin; + //private RunPlugin plugin; - public RunPlugin getPlugin() { + /*public RunPlugin getPlugin() { return plugin; } public void setPlugin(RunPlugin plugin) { this.plugin = plugin; - } + }*/ public ICompilationUnit getCu() { return cu; } diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/utils/RunPlugin.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/utils/RunPlugin.java index 42e4917cc..715718b30 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/utils/RunPlugin.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/utils/RunPlugin.java @@ -1,9 +1,11 @@ package org.universaal.tools.conformanceTools.utils; public enum RunPlugin { - - CheckStyle, + + /*CheckStyle, FindBugs, - Maven_Verifier; + Maven_Verifier;*/ + CodeStyle, + CustomChecks; } \ No newline at end of file diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/windows/MainFrame.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/windows/MainFrame.java index 40628083b..19558ae6d 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/windows/MainFrame.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/windows/MainFrame.java @@ -9,7 +9,6 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchWindow; -import org.universaal.tools.conformance.verify.plugin.handlers.VerifierHandler; import org.universaal.tools.conformanceTools.run.ToolsRun; import org.universaal.tools.conformanceTools.utils.RunPlugin; @@ -21,14 +20,14 @@ public class MainFrame { final Shell shell = new Shell(window.getShell()); GridLayout layout = new GridLayout(); - layout.numColumns = 3; + layout.numColumns = 2; // buttons number layout.makeColumnsEqualWidth = true; shell.setLayout(layout); GridData data = new GridData(GridData.FILL_BOTH); Button two = new Button(shell, SWT.PUSH); - two.setText("Check against code style rules"); + two.setText("Code style rules"); two.setEnabled(true); two.addMouseListener(new MouseListener() { @@ -36,7 +35,7 @@ public class MainFrame { shell.close(); shell.dispose(); - instance.run(window, RunPlugin.CheckStyle); + instance.run(window, RunPlugin.CodeStyle); } public void mouseDown(MouseEvent e) { @@ -48,7 +47,7 @@ public class MainFrame { two.setLayoutData(data); Button four = new Button(shell, SWT.PUSH); - four.setText("Identify the most common bugs"); + four.setText("uAAL checks"); four.setEnabled(true); four.addMouseListener(new MouseListener() { @@ -56,7 +55,7 @@ public class MainFrame { shell.close(); shell.dispose(); - instance.run(window, RunPlugin.FindBugs); + instance.run(window, RunPlugin.CustomChecks); } public void mouseDown(MouseEvent e) { @@ -67,7 +66,7 @@ public class MainFrame { }); four.setLayoutData(data); - Button five = new Button(shell, SWT.PUSH); + /*Button five = new Button(shell, SWT.PUSH); five.setText("Verify files in project"); five.setEnabled(false); five.addMouseListener(new MouseListener() { @@ -91,7 +90,7 @@ public class MainFrame { public void mouseDoubleClick(MouseEvent e) { } }); - five.setLayoutData(data); + five.setLayoutData(data);*/ shell.pack(); shell.open(); -- GitLab