001    // This file is part of AceWiki.
002    // Copyright 2008-2012, AceWiki developers.
003    // 
004    // AceWiki is free software: you can redistribute it and/or modify it under the terms of the GNU
005    // Lesser General Public License as published by the Free Software Foundation, either version 3 of
006    // the License, or (at your option) any later version.
007    // 
008    // AceWiki is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
009    // even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
010    // Lesser General Public License for more details.
011    // 
012    // You should have received a copy of the GNU Lesser General Public License along with AceWiki. If
013    // not, see http://www.gnu.org/licenses/.
014    
015    package ch.uzh.ifi.attempto.echocomp;
016    
017    import nextapp.echo.app.Component;
018    import nextapp.echo.app.util.Context;
019    
020    import nextapp.echo.webcontainer.ServerMessage;
021    import nextapp.echo.webcontainer.WebContainerServlet;
022    import nextapp.echo.webcontainer.service.JavaScriptService;
023    
024    import nextapp.echo.webcontainer.sync.component.TextFieldPeer;
025    
026    /**
027     * This is the peer component for the class {@link TabSensitiveTextField}.
028     * 
029     * @author Tobias Kuhn
030     */
031    public class TabSensitiveTextFieldPeer extends TextFieldPeer {
032    
033            private static final String REGISTRY_KEY = "Attempto.TabSensitiveTextField";
034            private static final String JAVASCRIPT_PATH = "ch/uzh/ifi/attempto/echocomp/TabSensitiveTextField.js";
035            
036            static {
037                    WebContainerServlet.getServiceRegistry().add(
038                                    JavaScriptService.forResource(REGISTRY_KEY, JAVASCRIPT_PATH)
039                            );
040            }
041            
042            public void init(Context context, Component component) {
043                    super.init(context, component);
044                    
045                    ServerMessage serverMessage = (ServerMessage) context.get(ServerMessage.class);
046                    serverMessage.addLibrary(REGISTRY_KEY);
047            }
048            
049            @SuppressWarnings("rawtypes")
050            public Class getComponentClass() {
051                    return TabSensitiveTextField.class;
052            }
053            
054            public String getClientComponentType(boolean shortType) {
055                    return REGISTRY_KEY;
056            }
057    
058    }