]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/widgets/StyledControl.java
Merge security.ui bundle in the cms.ui.workbench bundle
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / widgets / StyledControl.java
index a2c6935d279000ce433813552b420b8e499dc87c..ec1dbe77e3f2af14849090ee7ff1ff4355f326d0 100644 (file)
@@ -7,6 +7,7 @@ import org.argeo.cms.CmsConstants;
 import org.argeo.cms.CmsNames;
 import org.argeo.cms.util.CmsUtils;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusListener;
 import org.eclipse.swt.events.MouseListener;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
@@ -21,6 +22,7 @@ public abstract class StyledControl extends JcrComposite implements
        private Composite box;
 
        protected MouseListener mouseListener;
+       protected FocusListener focusListener;
 
        private Boolean editing = Boolean.FALSE;
 
@@ -65,6 +67,10 @@ public abstract class StyledControl extends JcrComposite implements
                clear(false);
                control = createControl(box, style);
                setControlLayoutData(control);
+
+               // add the focus listener to the newly created edition control
+               if (focusListener != null)
+                       control.addFocusListener(focusListener);
        }
 
        public synchronized void stopEditing() {
@@ -121,4 +127,12 @@ public abstract class StyledControl extends JcrComposite implements
                if (control != null && this.mouseListener != null)
                        control.addMouseListener(mouseListener);
        }
+
+       public void setFocusListener(FocusListener focusListener) {
+               if (this.focusListener != null && control != null)
+                       control.removeFocusListener(this.focusListener);
+               this.focusListener = focusListener;
+               if (control != null && this.focusListener != null)
+                       control.addFocusListener(focusListener);
+       }
 }