james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From man...@apache.org
Subject svn commit: r898990 - in /james/hupa/trunk: client/src/main/java/org/apache/hupa/client/ client/src/main/java/org/apache/hupa/client/mvp/ client/war/ widgets/src/main/java/org/apache/hupa/widgets/editor/
Date Wed, 13 Jan 2010 22:57:32 GMT
Author: manolo
Date: Wed Jan 13 22:57:32 2010
New Revision: 898990

URL: http://svn.apache.org/viewvc?rev=898990&view=rev
Log:
Fixed some issues in rich text editor. 
Now everything works as expected in FF, but IE and safari need some research.

Modified:
    james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HupaCSS.java
    james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MainView.java
    james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MessageSendPresenter.java
    james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MessageSendView.java
    james/hupa/trunk/client/war/Hupa.css
    james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/Editor.java
    james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/Toolbar.java

Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HupaCSS.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HupaCSS.java?rev=898990&r1=898989&r2=898990&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HupaCSS.java (original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HupaCSS.java Wed Jan 13 22:57:32
2010
@@ -51,6 +51,8 @@
     
     public static final String C_contacts_container = "hupa-contacts";
 
+    public static final String C_tree_container = "hupa-tree";
+
     public static final String C_msg_list_container = "hupa-msglist";
     public static final String C_msg_table = "hupa-msgtable";
     public static final String C_msg_table_empty = "hupa-msgtable-empty";

Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MainView.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MainView.java?rev=898990&r1=898989&r2=898990&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MainView.java (original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MainView.java Wed Jan
13 22:57:32 2010
@@ -24,6 +24,7 @@
 
 import net.customware.gwt.presenter.client.EventBus;
 
+import org.apache.hupa.client.HupaCSS;
 import org.apache.hupa.client.HupaConstants;
 import org.apache.hupa.client.HupaMessages;
 import org.apache.hupa.client.bundles.IMAPTreeImages;
@@ -130,7 +131,7 @@
     private void createWest() {
         west = new RndPanel();
         west.add(folderTree);
-        west.setWidth("158px");
+        west.addStyleName(HupaCSS.C_tree_container);
 
         folderTree.setAnimationEnabled(true);
         folderPanel.setSpacing(5);
@@ -163,9 +164,6 @@
     private void createNorth() {
         north = new VerticalPanel();
         north.setWidth("100%");
-
-
-
     }
 
     private void createCenter() {

Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MessageSendPresenter.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MessageSendPresenter.java?rev=898990&r1=898989&r2=898990&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MessageSendPresenter.java
(original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MessageSendPresenter.java
Wed Jan 13 22:57:32 2010
@@ -19,7 +19,25 @@
 
 package org.apache.hupa.client.mvp;
 
-import java.util.ArrayList;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.HasClickHandlers;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.Focusable;
+import com.google.gwt.user.client.ui.HasHTML;
+import com.google.gwt.user.client.ui.HasText;
+import com.google.inject.Inject;
+
+import eu.maydu.gwt.validation.client.DefaultValidationProcessor;
+import eu.maydu.gwt.validation.client.ValidationProcessor;
+import eu.maydu.gwt.validation.client.actions.FocusAction;
+import eu.maydu.gwt.validation.client.actions.StyleAction;
+import eu.maydu.gwt.validation.client.i18n.ValidationMessages;
+import gwtupload.client.IUploader;
+import gwtupload.client.IUploadStatus.Status;
+import gwtupload.client.IUploader.OnCancelUploaderHandler;
+import gwtupload.client.IUploader.OnFinishUploaderHandler;
+import gwtupload.client.IUploader.OnStatusChangedHandler;
 
 import net.customware.gwt.dispatch.client.DispatchAsync;
 import net.customware.gwt.presenter.client.EventBus;
@@ -48,24 +66,7 @@
 import org.apache.hupa.shared.rpc.SendMessage;
 import org.apache.hupa.widgets.ui.HasEnable;
 
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.HasClickHandlers;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.HasHTML;
-import com.google.gwt.user.client.ui.HasText;
-import com.google.inject.Inject;
-
-import eu.maydu.gwt.validation.client.DefaultValidationProcessor;
-import eu.maydu.gwt.validation.client.ValidationProcessor;
-import eu.maydu.gwt.validation.client.actions.FocusAction;
-import eu.maydu.gwt.validation.client.actions.StyleAction;
-import eu.maydu.gwt.validation.client.i18n.ValidationMessages;
-import gwtupload.client.IUploader;
-import gwtupload.client.IUploadStatus.Status;
-import gwtupload.client.IUploader.OnCancelUploaderHandler;
-import gwtupload.client.IUploader.OnFinishUploaderHandler;
-import gwtupload.client.IUploader.OnStatusChangedHandler;
+import java.util.ArrayList;
 
 /**
  * Presenter which handles the sending, reply, replay-all, forward of mails
@@ -161,6 +162,8 @@
         public HasText getSubjectText();
 
         public HasHTML getMessageHTML();
+        
+        public Focusable getEditorFocus();
 
         public HasClickHandlers getSendClick();
 
@@ -372,6 +375,8 @@
         firePresenterChangedEvent();
         
         revealDisplay();
+        
+        display.getEditorFocus().setFocus(true);
     }
 
     public void revealDisplay(User user, IMAPFolder folder, Message oldmessage, MessageDetails
oldDetails, Type type) {
@@ -393,11 +398,12 @@
 
     @Override
     protected void onRevealDisplay() {
-        // DO Nothing
     }
-
-    private String generateHeader(Message message, Type type) {
-        String ret = "<br><br>";
+    
+    private static String generateHeader(Message message, Type type) {
+        String ret = "<br>";
+        if (message == null)
+            return ret;
         if (type.equals(Type.FORWARD)) {
             ret += "--------- Forwarded message --------- <br>";
             ret += "From: " + message.getFrom().replaceAll("<", "&lt;").replaceAll(">",
"&gt;") + "<br>";
@@ -415,14 +421,16 @@
         return ret + "<br>";
     }
 
-    private String wrapMessage(Message message, MessageDetails details, Type type) {
-        String ret;
-        ret = "<font size=2 style='font-family: arial'>";
-        ret += generateHeader(message, type);
-        ret += "<blockquote style='border-left: 1px solid rgb(204, 204, 204); margin:
0pt 0pt 0pt 0.8ex; padding-left: 1ex;'>";
-        if (details != null)
+    public static String wrapMessage(Message message, MessageDetails details, Type type)
{
+        String ret = "";
+        if (message != null) {
+            ret += generateHeader(message, type);
+        }
+        if (details != null && details.getText() != null && !details.getText().isEmpty())
{
+            ret += "<blockquote style='border-left: 1px solid rgb(204, 204, 204); margin:
0pt 0pt 0pt 0.8ex; padding-left: 1ex;'>";
             ret += details.getText();
-        ret += "</blockquote></font>";
+            ret += "</blockquote>";
+        }
         return ret;
     }
 

Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MessageSendView.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MessageSendView.java?rev=898990&r1=898989&r2=898990&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MessageSendView.java
(original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/MessageSendView.java
Wed Jan 13 22:57:32 2010
@@ -38,6 +38,7 @@
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.event.dom.client.HasClickHandlers;
 import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Focusable;
 import com.google.gwt.user.client.ui.HasHTML;
 import com.google.gwt.user.client.ui.HasText;
 import com.google.gwt.user.client.ui.Label;
@@ -218,6 +219,13 @@
     }
     
     /* (non-Javadoc)
+     * @see org.apache.hupa.client.mvp.MessageSendPresenter.Display#getEditorFocus()
+     */
+    public Focusable getEditorFocus() {
+        return to;
+    }
+
+    /* (non-Javadoc)
      * @see org.apache.hupa.client.mvp.MessageSendPresenter.Display#refresh()
      */
     public void refresh() {

Modified: james/hupa/trunk/client/war/Hupa.css
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/war/Hupa.css?rev=898990&r1=898989&r2=898990&view=diff
==============================================================================
--- james/hupa/trunk/client/war/Hupa.css (original)
+++ james/hupa/trunk/client/war/Hupa.css Wed Jan 13 22:57:32 2010
@@ -167,6 +167,12 @@
 	margin-left: 5px;
 }
 
+/*************[ view: MainView ]*********************/
+.hupa-tree {
+	width: 158px;
+	overflow: hidden;
+}
+
 /************[ widget: CommandsBar ]*********/
 .hupa-commands-bar {
 	width: 100%;
@@ -202,6 +208,31 @@
 	width: 150px;
 }
 
+.gwt-ListBox, .gwt-SuggestBox {
+    background-color:  #d8ecfd;
+    border: 1px solid #7FAAFF;
+}
+.dragdrop-dragable{
+	background: red;
+	}
+
+.gwt-SuggestBoxPopup {
+    font-size: 10px;
+}
+
+.hupa-buttons .gwt-ListBox {
+	margin-left: 5px;
+}
+
+/*************[ buttonbars ]*********************/
+.hupa-buttons {
+    white-space: nowrap;
+}
+
+.hupa-buttons td {
+  padding-left: 3px;
+}
+
 .hupa-buttons div {
 	white-space: nowrap;
 	vertical-align: middle;
@@ -210,14 +241,6 @@
 	padding-left: 6px;
 }
 
-.gwt-ListBox, .gwt-SuggestBox {
-    background-color:  #d8ecfd;
-    border: 1px solid #7FAAFF;
-    font-size: 10px;
-}
-.gwt-SuggestBoxPopup {
-    font-size: 10px;
-}
 
 /************[ widget: MessageHeaders ]*******************/
 table.hupa-msg-headers {

Modified: james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/Editor.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/Editor.java?rev=898990&r1=898989&r2=898990&view=diff
==============================================================================
--- james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/Editor.java (original)
+++ james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/Editor.java Wed
Jan 13 22:57:32 2010
@@ -18,8 +18,20 @@
  ****************************************************************/
 package org.apache.hupa.widgets.editor;
 
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.FocusEvent;
+import com.google.gwt.event.dom.client.FocusHandler;
+import com.google.gwt.event.dom.client.KeyCodes;
+import com.google.gwt.event.dom.client.KeyPressEvent;
+import com.google.gwt.event.dom.client.KeyPressHandler;
+import com.google.gwt.event.logical.shared.InitializeEvent;
+import com.google.gwt.event.logical.shared.InitializeHandler;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.ui.Focusable;
 import com.google.gwt.user.client.ui.HasHTML;
-
 import com.google.gwt.user.client.ui.RichTextArea;
 import com.google.gwt.user.client.ui.VerticalPanel;
 
@@ -27,15 +39,14 @@
 /**
  * Wysiwyg editor for composing and editing emails in Hupa
  */
-public class Editor extends VerticalPanel implements HasHTML {
-
+public class Editor extends VerticalPanel implements HasHTML, Focusable {
+    
     RichTextArea area = new RichTextArea();
+    boolean isNewMessage = true;
     
     public Editor() {
         area.ensureDebugId("hupa-editor-area");
-        // Note: rich-area is created in an iframe, so Hupa's style sheets 
-        // are not available, unless we inject them to the generated iframe
-        area.setSize("100%", "200em");
+        area.setSize("100%", "234px");
         
         Toolbar toolbar = new Toolbar(area);
         toolbar.ensureDebugId("hupa-editor-toolbar");
@@ -44,7 +55,24 @@
         super.add(toolbar);
         super.add(area);
         super.setWidth("100%");
-
+        
+        // Note: rich-area is created in an iframe, so Hupa's style sheets 
+        // are not available, unless we inject them to the generated iframe
+        //
+        // When body is available, we put the default style for messages:
+        area.addInitializeHandler(new InitializeHandler() {
+            public void onInitialize(InitializeEvent event) {
+                setBodyStyleAttribute("fontFamily", "arial");
+                setBodyStyleAttribute("fontSize", "80%");
+            }
+        });
+        
+        // When the users writes in-line comments in replies, the text has to be leftIdented.
+        // Right now, I've implemented this feature only in gecko browsers, for other browsers
+        // the user has to push the leftIdent button.
+        if (getUA().equals("ff"))
+            addNewlineHandlersForFireFox();
+        
     }
     
     @Override
@@ -67,7 +95,8 @@
     }
 
     public void setHTML(String html) {
-        area.setHTML("<font style='font-family: arial' size=2>" + html + "</font>");
+        isNewMessage = html.isEmpty(); 
+        area.setHTML("<font size=2 style='font-family: arial'><br/>" + html +
"</font>");
     }
 
     public String getText() {
@@ -77,5 +106,105 @@
     public void setText(String text) {
         area.setText(text);
     }
+
+    public void setBodyStyleAttribute(final String key, final String value) {
+        DOM.setStyleAttribute(getBody(area.getElement()), key, value);
+    }
+    
+    public int getTabIndex() {
+        return area.getTabIndex();
+    }
+
+    public void setAccessKey(char key) {
+        area.setAccessKey(key);
+    }
+
+    public void setFocus(boolean focused) {
+        area.setFocus(focused);
+    }
+
+    public void setTabIndex(int index) {
+        area.setTabIndex(index);
+    }
+    
+    // isEnabled and setEnabled dont work in richtextarea due to a bug,
+    // I've sent a patch to gwt, when it is accepted this native methods can be
+    // removed
+    public void setEnabled(boolean b) {
+        setEnabled(area.getElement(), b);
+    }
+    
+    public boolean isEnabled() {
+        return isEnabled(area.getElement());
+    }
+    
+    private native void setEnabled(Element iframe, boolean b) /*-{
+       var doc = iframe.contentWindow.document;
+       if (doc.body.contentEditable) 
+          doc.body.contentEditable = b;
+       else 
+          doc.designMode = b ? 'On' : 'Off';
+    }-*/;
+
+    private native boolean isEnabled(Element iframe) /*-{
+       var doc = iframe.contentWindow.document;
+       alert((doc.designMode.toUpperCase()) == 'ON');
+       if (doc.body.contentEditable) {
+           alert("editable ???");
+          return doc.body.contentEditable;
+       } else {
+           var ret = (((doc.designMode).toUpperCase()) == 'ON') ? true : false;
+           alert(ret);
+           return ret;
+       }
+    }-*/;
+    
+    private native Element getBody(Element frame) /*-{
+        return frame.contentWindow.document.body;
+    }-*/;
+    
+    private void addNewlineHandlersForFireFox() {
+        area.addClickHandler(new ClickHandler() {
+            public void onClick(ClickEvent event) {
+                doNline = true;
+            }
+        });
+        area.addFocusHandler(new FocusHandler() {
+            public void onFocus(FocusEvent event) {
+                doNline = true;
+            }
+        });
+        area.addKeyPressHandler(new KeyPressHandler() {
+            public void onKeyPress(KeyPressEvent event) {
+                if (!isNewMessage) {
+                    if (doNline && event.getCharCode() == KeyCodes.KEY_ENTER) {
+                        doNline = false;
+                        leftIdentTimer.schedule(10);
+                        event.preventDefault();
+                    }
+                    if (!doNline && (event.getCharCode() == KeyCodes.KEY_DOWN ||
event.getCharCode() == KeyCodes.KEY_UP)) {
+                        doNline = true;
+                    }
+                }
+            }
+        });
+
+    }
+    
+    boolean doNline = true;
+    private Timer leftIdentTimer = new Timer(){
+        public void run() {
+            area.getFormatter().insertHTML("<br/>\n");
+            area.getFormatter().leftIndent();
+        }
+    };
+    
+    private native String getUA() /*-{
+      var ua = navigator.userAgent.toLowerCase();
+      if (ua.indexOf("gecko") != -1) 
+         return "ff";
+      return "other";
+    }-*/;
+
     
 }
\ No newline at end of file

Modified: james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/Toolbar.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/Toolbar.java?rev=898990&r1=898989&r2=898990&view=diff
==============================================================================
--- james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/Toolbar.java (original)
+++ james/hupa/trunk/widgets/src/main/java/org/apache/hupa/widgets/editor/Toolbar.java Wed
Jan 13 22:57:32 2010
@@ -125,17 +125,7 @@
             }
         }
 
-        boolean first = true;
-
         public void onKeyDown(KeyDownEvent event) {
-            if (first) {
-                Widget sender = (Widget) event.getSource();
-                RichTextArea area = (RichTextArea) sender;
-                area.getExtendedFormatter().selectAll();
-                area.getExtendedFormatter().setFontName("Arial");
-                area.getExtendedFormatter().setFontSize(FontSize.X_SMALL);
-                first = false;
-            }
         }
 
         public void onKeyUp(KeyUpEvent event) {



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message