Author: solomax
Date: Thu Dec 20 11:51:13 2012
New Revision: 1424421

URL: http://svn.apache.org/viewvc?rev=1424421&view=rev
Log:
Wicket: chat, initial implementation

Modified:
    
incubator/openmeetings/trunk/singlewebapp/WebContent/openmeetings/css/theme.css
    
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/PagedEntityListPanel.html
    
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/PagedEntityListPanel.java
    
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.html
    
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.java

Modified: 
incubator/openmeetings/trunk/singlewebapp/WebContent/openmeetings/css/theme.css
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/WebContent/openmeetings/css/theme.css?rev=1424421&r1=1424420&r2=1424421&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/WebContent/openmeetings/css/theme.css 
(original)
+++ 
incubator/openmeetings/trunk/singlewebapp/WebContent/openmeetings/css/theme.css 
Thu Dec 20 11:51:13 2012
@@ -66,6 +66,7 @@
        z-index: 2000;
        bottom: 0px;
        right: 10px;
+       width: 300px;
 }
 
 #chatPanel #chat {
@@ -372,7 +373,7 @@ div.tableWrapper {
        display: inline-block;
 }
 
-.pagedEntityListPanel .searchForm {
+.searchForm {
        display: inline-block;
 }
 

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/PagedEntityListPanel.html
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/PagedEntityListPanel.html?rev=1424421&r1=1424420&r2=1424421&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/PagedEntityListPanel.html
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/PagedEntityListPanel.html
 Thu Dec 20 11:51:13 2012
@@ -24,10 +24,10 @@
                <form wicket:id="pagingForm" class="pagedEntityListPanel">
                        <select wicket:id="entitiesPerPage"></select>
                        <span wicket:id="navigator">[dataview navigator]</span>
-                       <form wicket:id="searchForm" class="searchForm">
-                               <input type="text" wicket:id="searchText" 
wicket:ommessage="title:714"/>
-                               <input type="submit" wicket:id="search" 
wicket:ommessage="value:715"/>
-                       </form>
+               </form>
+               <form wicket:id="searchForm" class="searchForm">
+                       <input type="text" wicket:id="searchText" 
wicket:ommessage="title:714"/>
+                       <input type="submit" wicket:id="search" 
wicket:ommessage="value:715"/>
                </form>
        </wicket:panel>
 </html>
\ No newline at end of file

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/PagedEntityListPanel.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/PagedEntityListPanel.java?rev=1424421&r1=1424420&r2=1424421&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/PagedEntityListPanel.java
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/PagedEntityListPanel.java
 Thu Dec 20 11:51:13 2012
@@ -41,7 +41,6 @@ public abstract class PagedEntityListPan
                
                dataView.setItemsPerPage(entitiesPerPage);
                final Form<Void> f = new Form<Void>("pagingForm");
-               f.setOutputMarkupId(true);
 
                f.add(new AdminPagingNavigator("navigator", 
dataView).setOutputMarkupId(true))
                        .add(new DropDownChoice<Integer>("entitiesPerPage", new 
PropertyModel<Integer>(this, "entitiesPerPage"), numbers)
@@ -60,7 +59,7 @@ public abstract class PagedEntityListPan
                
                final SearchableDataProvider<? extends IDataProviderEntity> dp 
= dataView.getDataProvider();
                Form<Void> searchForm = new Form<Void>("searchForm");
-               f.add(searchForm);
+               add(searchForm.setOutputMarkupId(true));
                searchForm.add(new TextField<String>("searchText", new 
PropertyModel<String>(dp, "search")).setOutputMarkupId(true));
                searchForm.add(new AjaxButton("search", searchForm) {
                        private static final long serialVersionUID = 
-1659023337945692814L;
@@ -71,7 +70,7 @@ public abstract class PagedEntityListPan
                                PagedEntityListPanel.this.onEvent(target);
                        }
                });
-               add(f);
+               add(f.setOutputMarkupId(true));
        }
 
        protected abstract void onEvent(AjaxRequestTarget target);

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.html
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.html?rev=1424421&r1=1424420&r2=1424421&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.html
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.html
 Thu Dec 20 11:51:13 2012
@@ -26,6 +26,11 @@
                                var chat = $('#chat');
                                chat.animate({ height: chat.height() < 20 ? 
"300px" : "16px" }, 1000);
                        }
+                       Wicket.Event.subscribe("/websocket/message", 
function(jqEvent, message) {
+                               $('#messageArea').append('<div>' + message + 
'</div>'); 
+                               // do something with the message.
+                               // it may be a text or a binary message 
depending on what you pushed from the server side
+                       });
                </script>
        </wicket:head>
        <wicket:panel>

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.java?rev=1424421&r1=1424420&r2=1424421&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.java
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/ChatPanel.java
 Thu Dec 20 11:51:13 2012
@@ -18,33 +18,64 @@
  */
 package org.apache.openmeetings.web.components.user;
 
+import java.io.Serializable;
+
+import org.apache.openmeetings.OpenmeetingsVariables;
 import org.apache.openmeetings.web.components.UserPanel;
+import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.form.Button;
 import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.form.TextArea;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.protocol.ws.IWebSocketSettings;
+import org.apache.wicket.protocol.ws.api.WebSocketPushBroadcaster;
+import org.apache.wicket.protocol.ws.api.message.IWebSocketPushMessage;
+import org.apache.wicket.protocol.ws.api.message.TextMessage;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
 
 public class ChatPanel extends UserPanel {
+       private static final Logger log = 
Red5LoggerFactory.getLogger(ChatPanel.class, 
OpenmeetingsVariables.webAppRootKey);
        private static final long serialVersionUID = -9144707674886211557L;
+       private String message;
+       
+       private class ChatMessage extends TextMessage implements 
IWebSocketPushMessage, Serializable {
+               private static final long serialVersionUID = 
-3802182673895471248L;
 
+               public ChatMessage(String msg) {
+                       super(msg);
+               }
+       }
+       
        public ChatPanel(String id) {
                super(id);
                setOutputMarkupId(true);
                setMarkupId(id);
                
-               add(new WebMarkupContainer("messages"));
-               add(new Form<Void>("sendForm") {
-                       private static final long serialVersionUID = 
-6367566664201921428L;
-
-                       {
-                               add(new 
TextArea<String>("message").setOutputMarkupId(true));
-                               add(new Button("send").add(new 
AjaxFormSubmitBehavior("onclick"){
-                                       private static final long 
serialVersionUID = -3746739738826501331L;
-                                       
-                               }));
-                       }
-               });
+               add(new 
WebMarkupContainer("messages").setMarkupId("messageArea"));
+               final Form<Void> f = new Form<Void>("sendForm");
+               f.add(new TextArea<String>("message", new 
PropertyModel<String>(ChatPanel.this, "message")).setOutputMarkupId(true));
+               f.add(new Button("send").add(new 
AjaxFormSubmitBehavior("onclick"){
+                       private static final long serialVersionUID = 
-3746739738826501331L;
+                       
+                       protected void onSubmit(AjaxRequestTarget target) {
+                               //Application.getBean(ChatService) 
sendMessageToOverallChat
+                               new 
WebSocketPushBroadcaster(IWebSocketSettings.Holder.get(getApplication()).getConnectionRegistry())
+                                       .broadcastAll(getApplication(), new 
ChatMessage(message));
+                               /*for (IWebSocketConnection c : 
IWebSocketSettings.Holder.get(getApplication()).getConnectionRegistry().getConnections(getApplication()))
 {
+                                       try {
+                                               c.sendMessage(message);
+                                       } catch(Exception e) {
+                                               log.error("Error while sending 
message", e);
+                                       }
+                               }*/
+                               ChatPanel.this.message = "";
+                               target.add(f);
+                       };
+               }));
+               add(f.setOutputMarkupId(true));
        }
 
 }


Reply via email to