You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by cb...@apache.org on 2010/09/24 21:37:30 UTC
svn commit: r1001045 -
/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java
Author: cbartlett
Date: Fri Sep 24 19:37:30 2010
New Revision: 1001045
URL: http://svn.apache.org/viewvc?rev=1001045&view=rev
Log:
PIVOT-607 - Refactored as discussed on dev mailing list
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java?rev=1001045&r1=1001044&r2=1001045&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java Fri Sep 24 19:37:30 2010
@@ -300,20 +300,24 @@ public abstract class ApplicationContext
}
try {
- String property = System.getProperty("org.apache.pivot.wtk.debugfocuscolor");
- if (property != null) {
- property = property.trim().toLowerCase();
- Color focusColor = null;
- if ("red".equals(property)) {
- focusColor = Color.RED;
- } else if ("green".equals(property)) {
- focusColor = Color.GREEN;
- } else if ("blue".equals(property)) {
- focusColor = Color.BLUE;
- }
- if (focusColor != null) {
- Component.setFocusDecorator(new ShadeDecorator(0.2f, focusColor));
- }
+ boolean debugFocus = Boolean.parseBoolean(System.getProperty("org.apache.pivot.wtk.debugfocus"));
+ if (debugFocus) {
+ final Decorator focusDecorator = new ShadeDecorator(0.2f, Color.RED);
+ ComponentClassListener focusChangeListener = new ComponentClassListener() {
+ @Override
+ public void focusedComponentChanged(Component previousFocusedComponent) {
+ if (previousFocusedComponent != null
+ && previousFocusedComponent.getDecorators().indexOf(focusDecorator) > -1) {
+ previousFocusedComponent.getDecorators().remove(focusDecorator);
+ }
+ Component focusedComponent = Component.getFocusedComponent();
+ if (focusedComponent != null
+ && focusedComponent.getDecorators().indexOf(focusDecorator) == -1) {
+ focusedComponent.getDecorators().add(focusDecorator);
+ }
+ }
+ };
+ Component.getComponentClassListeners().add(focusChangeListener);
}
} catch (SecurityException ex) {
// No-op