Changeset 5558

Show
Ignore:
Timestamp:
09/30/08 11:13:49 (3 months ago)
Author:
matti.tahvonen@…
Message:
 
Location:
trunk/src/com/itmill/toolkit
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java

    r5528 r5558  
    480480            } 
    481481 
    482             // add meta instruction for client to set focus if it is set 
    483             final Paintable f = (Paintable) application.consumeFocus(); 
    484             if (f != null) { 
    485                 if (metaOpen) { 
    486                     outWriter.write(","); 
    487                 } 
    488                 outWriter.write("\"focus\":\"" + getPaintableId(f) + "\""); 
    489             } 
    490  
    491482            outWriter.print("}, \"resources\" : {"); 
    492483 
  • trunk/src/com/itmill/toolkit/ui/AbstractField.java

    r5490 r5558  
    926926    } 
    927927 
    928     /** 
    929      * Asks the terminal to place the cursor to this field. 
     928    /* 
     929     * (non-Javadoc) 
     930     *  
     931     * @see com.itmill.toolkit.ui.Component.Focusable#focus() 
    930932     */ 
    931933    public void focus() { 
    932934        final Application app = getApplication(); 
    933935        if (app != null) { 
    934             app.setFocusedComponent(this); 
     936            getWindow().setFocusedComponent(this); 
     937            delayedFocus = false; 
    935938        } else { 
    936939            delayedFocus = true; 
     
    10141017        super.attach(); 
    10151018        if (delayedFocus) { 
    1016  
    1017             delayedFocus = false; 
    10181019            focus(); 
    10191020        } 
  • trunk/src/com/itmill/toolkit/ui/Component.java

    r5513 r5558  
    402402     * Interface implemented by components which can obtain input focus. 
    403403     */ 
    404     public interface Focusable { 
     404    public interface Focusable extends Component { 
    405405 
    406406        /** 
  • trunk/src/com/itmill/toolkit/ui/Upload.java

    r5281 r5558  
    846846    } 
    847847 
    848     /** 
    849      * Sets the focus to this component. 
     848    /* 
     849     * (non-Javadoc) 
    850850     *  
    851851     * @see com.itmill.toolkit.ui.Component.Focusable#focus() 
     
    854854        final Application app = getApplication(); 
    855855        if (app != null) { 
    856             app.setFocusedComponent(this); 
     856            getWindow().setFocusedComponent(this); 
     857            delayedFocus = false; 
    857858        } else { 
    858859            delayedFocus = true; 
     
    9991000        super.attach(); 
    10001001        if (delayedFocus) { 
    1001             delayedFocus = false; 
    10021002            focus(); 
    10031003        } 
  • trunk/src/com/itmill/toolkit/ui/Window.java

    r5552 r5558  
    112112 
    113113    private boolean centerRequested = false; 
     114 
     115    private Focusable pendingFocus; 
    114116 
    115117    /* ********************************************************************* */ 
     
    541543        } 
    542544 
     545        if (pendingFocus != null) { 
     546            // ensure focused component is still attached to this main window 
     547            if (pendingFocus.getWindow() == this 
     548                    || (pendingFocus.getWindow() != null && pendingFocus 
     549                            .getWindow().getParent() == this)) { 
     550                target.paintReference(pendingFocus, "focused"); 
     551            } 
     552            pendingFocus = null; 
     553        } 
     554 
    543555    } 
    544556 
     
    11921204        notifications.add(notification); 
    11931205        requestRepaint(); 
     1206    } 
     1207 
     1208    /** 
     1209     * This method is used by Component.Focusable objects to request focus to 
     1210     * themselves. Focus renders must be handled at window level (instead of 
     1211     * Component.Focusable) due we want the last focused component to be focused 
     1212     * in client too. Not the one that is rendered last (the case we'd get if 
     1213     * implemented in Focusable only). 
     1214     *  
     1215     * To focus component from Toolkit application, use Focusable.focus(). See 
     1216     * {@link Focusable}. 
     1217     *  
     1218     * @param focusable 
     1219     *            to be focused on next paint 
     1220     */ 
     1221    void setFocusedComponent(Focusable focusable) { 
     1222        if (getParent() != null) { 
     1223            // focus is handled by main windows 
     1224            ((Window) getParent()).setFocusedComponent(focusable); 
     1225        } else { 
     1226            pendingFocus = focusable; 
     1227            requestRepaint(); 
     1228        } 
    11941229    } 
    11951230