[Fb-contrib-commit] SF.net SVN: fb-contrib: [502] trunk/fb-contrib/etc
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-04-25 17:35:57
|
Revision: 502 Author: dbrosius Date: 2006-04-25 10:35:42 -0700 (Tue, 25 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=502&view=rev Log Message: ----------- add check for JComponent derived classes that don't implement the Accessible interface Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/samples/S508C_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-04-25 17:19:19 UTC (rev 501) +++ trunk/fb-contrib/etc/findbugs.xml 2006-04-25 17:35:42 UTC (rev 502) @@ -185,7 +185,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.Section508Compliance" speed="fast" - reports="S508C_NULL_LAYOUT,S508C_NO_SETLABELFOR,S508C_NO_SETSIZE" /> + reports="S508C_NULL_LAYOUT,S508C_NO_SETLABELFOR,S508C_NO_SETSIZE,S508C_NON_ACCESSIBLE_JCOMPONENT" /> <!-- BugPattern --> @@ -234,4 +234,5 @@ <BugPattern abbrev="S508C" type="S508C_NULL_LAYOUT" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="S508C" type="S508C_NO_SETLABELFOR" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="S508C" type="S508C_NO_SETSIZE" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="S508C" type="S508C_NON_ACCESSIBLE_JCOMPONENT" category="CORRECTNESS" experimental="true"/> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-04-25 17:19:19 UTC (rev 501) +++ trunk/fb-contrib/etc/messages.xml 2006-04-25 17:35:42 UTC (rev 502) @@ -1129,6 +1129,18 @@ </Details> </BugPattern> + <BugPattern type="S508C_NON_ACCESSIBLE_JCOMPONENT"> + <ShortDescription>Class extends JComponent but does not implement Accessible interface</ShortDescription> + <LongDescription>Class {0} extends JComponent but does not implement Accessible interface</LongDescription> + <Details> + <![CDATA[ + <p>This class extends the JComponent gui control but does not implement the Accessibility interface. + This makes this control unable to be processed by screen readers, etc, for people with reading/vision + difficulties</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> Modified: trunk/fb-contrib/samples/S508C_Sample.java =================================================================== --- trunk/fb-contrib/samples/S508C_Sample.java 2006-04-25 17:19:19 UTC (rev 501) +++ trunk/fb-contrib/samples/S508C_Sample.java 2006-04-25 17:35:42 UTC (rev 502) @@ -1,11 +1,13 @@ import java.awt.Container; +import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; public class S508C_Sample extends JFrame { private JLabel fLabel = new JLabel("Hello"); + private JComponent c = new MyComponent(); public S508C_Sample() { Container cp = getContentPane(); @@ -14,7 +16,13 @@ cp.add(fLabel); JLabel lLabel = new JLabel("there"); cp.add(lLabel); + cp.add(c); setSize(300, 200); } } + +class MyComponent extends JComponent +{ + +} Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-04-25 17:19:19 UTC (rev 501) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-04-25 17:35:42 UTC (rev 502) @@ -28,12 +28,24 @@ public class Section508Compliance extends BytecodeScanningDetector { private static JavaClass windowClass; + private static JavaClass jcomponentClass; + private static JavaClass accessibleClass; static { try { windowClass = Repository.lookupClass("java/awt/Window"); } catch (ClassNotFoundException cnfe) { windowClass = null; } + try { + jcomponentClass = Repository.lookupClass("javax/swing/JComponent"); + } catch (ClassNotFoundException cnfe) { + jcomponentClass = null; + } + try { + accessibleClass = Repository.lookupClass("javax.accessibility.Accessible"); + } catch (ClassNotFoundException cnfe) { + accessibleClass = null; + } } private BugReporter bugReporter; private OpcodeStack stack; @@ -56,6 +68,16 @@ @Override public void visitClassContext(ClassContext classContext) { try { + if ((jcomponentClass != null) && (accessibleClass != null)) { + JavaClass cls = classContext.getJavaClass(); + if (cls.instanceOf(jcomponentClass)) { + if (!cls.implementationOf(accessibleClass)) { + bugReporter.reportBug(new BugInstance(this, "S508C_NON_ACCESSIBLE_JCOMPONENT", NORMAL_PRIORITY) + .addClass(cls)); + } + } + } + stack = new OpcodeStack(); fieldLabels = new HashSet<FieldAnnotation>(); localLabels = new HashMap<Integer, SourceLineAnnotation>(); @@ -65,6 +87,8 @@ .addClass(this) .addField(fa)); } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); } finally { stack = null; fieldLabels = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |