]> source.dussan.org Git - vaadin-framework.git/commitdiff
System errors, UIDL.XML fix, made console static, allow html in debug windows message...
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 11 Sep 2007 11:49:24 +0000 (11:49 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 11 Sep 2007 11:49:24 +0000 (11:49 +0000)
svn changeset:2276/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
src/com/itmill/toolkit/terminal/gwt/client/Caption.java
src/com/itmill/toolkit/terminal/gwt/client/DebugConsole.java
src/com/itmill/toolkit/terminal/gwt/client/ErrorMessage.java
src/com/itmill/toolkit/terminal/gwt/client/UIDL.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java

index 4c1b7d4e8799cc65768eb7d3be8069d83d2408eb..68d0c7faa8a0fc19cb010869d1033c5aea0d1b00 100755 (executable)
@@ -38,7 +38,7 @@ public class ApplicationConnection implements EntryPoint, FocusListener {
        private RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, appUri
                        + "/UIDL/?repaintAll=1&");
 
-       public Console console;
+       private static Console console;
 
        private Vector pendingVariables = new Vector();
 
@@ -71,8 +71,12 @@ public class ApplicationConnection implements EntryPoint, FocusListener {
                RootPanel.get("itmtk-ajax-window").add(view);
                
        }
+       
+       public static Console getConsole() {
+               return console;
+       }
 
-       private native boolean isDebugMode() /*-{
+       private native static boolean isDebugMode() /*-{
                var uri = $wnd.location;
                var re = /debug[^\/]*$/;
                return re.test(uri);
index d6268e445e64881d45f06df1b27e46fc04fd1c9a..2a036ce9a51232fac0429380b3b5764f054b2381 100644 (file)
@@ -5,7 +5,6 @@ import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.PopupPanel;
-import com.google.gwt.user.client.ui.SimplePanel;
 
 public class Caption extends HTML {
        
@@ -36,7 +35,7 @@ public class Caption extends HTML {
                        
                        if(errorIndicatorElement == null) {
                                errorIndicatorElement = DOM.createDiv();
-                               DOM.setAttribute(errorIndicatorElement, "className", "i-errorindicator");
+                               DOM.setElementProperty(errorIndicatorElement, "className", "i-errorindicator");
                                DOM.insertChild(getElement(), errorIndicatorElement, 0);
                        }
                        
@@ -58,7 +57,7 @@ public class Caption extends HTML {
                
                if(uidl.hasAttribute("description")) {
                        if(captionText != null) {
-                               DOM.setAttribute(captionText, "title", uidl.getStringAttribute("description"));
+                               DOM.setElementProperty(captionText, "title", uidl.getStringAttribute("description"));
                        } else {
                                setTitle(uidl.getStringAttribute("description"));
                        }
@@ -76,6 +75,9 @@ public class Caption extends HTML {
                        case Event.ONMOUSEOUT:
                                hideErrorMessage();
                                break;
+                       case Event.ONCLICK:
+                               ApplicationConnection.getConsole().
+                                       log(DOM.getInnerHTML(errorMessage.getElement()));
                        default:
                                break;
                        }
@@ -96,9 +98,9 @@ public class Caption extends HTML {
                        }
                        errorContainer.setPopupPosition(
                                        DOM.getAbsoluteLeft(errorIndicatorElement) +
-                                               2*DOM.getIntAttribute(errorIndicatorElement, "offsetHeight"),
+                                               2*DOM.getElementPropertyInt(errorIndicatorElement, "offsetHeight"),
                                        DOM.getAbsoluteTop(errorIndicatorElement) + 
-                                               2*DOM.getIntAttribute(errorIndicatorElement, "offsetHeight"));
+                                               2*DOM.getElementPropertyInt(errorIndicatorElement, "offsetHeight"));
                        errorContainer.show();
                }
        }
index 2652456f62619376770f8e2fd6af446387f928f8..1908610cb24890aed2edccb97e505217c54646c9 100755 (executable)
@@ -2,6 +2,7 @@ package com.itmill.toolkit.terminal.gwt.client;
 
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.Label;
 import com.itmill.toolkit.terminal.gwt.client.ui.IWindow;
 
@@ -21,14 +22,14 @@ public final class DebugConsole extends IWindow implements Console {
        private void minimize() {
                // TODO stack to bottom (create window manager of some sort) 
                setPixelSize(60, 60);
-               setPopupPosition(Window.getClientWidth() - 66, Window.getClientHeight() - 66);
+               setPopupPosition(Window.getClientWidth() - 80, Window.getClientHeight() - 80);
        }
 
        /* (non-Javadoc)
         * @see com.itmill.toolkit.terminal.gwt.client.Console#log(java.lang.String)
         */
        public void log(String msg) {
-               panel.add(new Label(msg));
+               panel.add(new HTML(msg));
                System.out.println(msg);
        }
 
@@ -36,7 +37,7 @@ public final class DebugConsole extends IWindow implements Console {
         * @see com.itmill.toolkit.terminal.gwt.client.Console#error(java.lang.String)
         */
        public void error(String msg) {
-               panel.add((new Label(msg)));
+               panel.add((new HTML(msg)));
                System.out.println(msg);
        }
 
index 697968217a325500291beec93752a32e3c4a22ee..2426fe858b067614da6257bfc81fd45ae5663bd9 100644 (file)
@@ -19,6 +19,9 @@ public class ErrorMessage extends FlowPanel {
                        if (child instanceof String) {
                                String errorMessage = (String) child;
                                add(new HTML(errorMessage));
+                       } else if (child instanceof UIDL.XML) {
+                               UIDL.XML xml = (UIDL.XML) child;
+                               add(new HTML(xml.getXMLAsString()));
                        } else {
                                ErrorMessage childError = new ErrorMessage();
                                add(childError);
index 18ef9306a9c8f0653302a6d23ff8a63124693911..d57c6048ac2aec39f6e4ee021c635f0725013499 100644 (file)
@@ -398,7 +398,18 @@ public class UIDL {
                }
 
                public String getXMLAsString() {
-                       return x.get("x").toString();
+                       StringBuffer sb = new StringBuffer();
+                       for(Iterator it = x.keySet().iterator(); it.hasNext();) {
+                               String tag = (String) it.next();
+                               sb.append("<");
+                               sb.append(tag);
+                               sb.append(">");
+                               sb.append(x.get(tag).isString().stringValue());
+                               sb.append("</");
+                               sb.append(tag);
+                               sb.append(">");
+                       }
+                       return sb.toString();
                }
        }
 
index beb882f4862eb56c4be38bcefba8f2b390493a3f..33c15f5f8ec345eb279913c36b934fef7f3f36d8 100644 (file)
@@ -566,7 +566,8 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
                tHead.setHorizontalScrollPosition(scrollLeft);
        
                firstRowInViewPort = (int) Math.ceil( scrollTop / (double) tBody.getRowHeight() );
-               client.console.log("At scrolltop: " + scrollTop + " At row " + firstRowInViewPort);
+               ApplicationConnection.getConsole()
+                       .log("At scrolltop: " + scrollTop + " At row " + firstRowInViewPort);
                
                int postLimit = (int) (firstRowInViewPort + pageLength + pageLength*CACHE_REACT_RATE);
                if(postLimit > totalRows -1 )
@@ -585,7 +586,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
                if(firstRowInViewPort - pageLength*CACHE_RATE > lastRendered ||
                                firstRowInViewPort + pageLength + pageLength*CACHE_RATE < firstRendered ) {
                        // need a totally new set
-                       client.console.log("Table: need a totally new set");
+                       ApplicationConnection.getConsole().log("Table: need a totally new set");
                        rowRequestHandler.setReqFirstRow((int) (firstRowInViewPort - pageLength*CACHE_RATE));
                        rowRequestHandler.setReqRows((int) (2*CACHE_RATE*pageLength + pageLength));
                        rowRequestHandler.deferRowFetch();
@@ -593,7 +594,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
                }
                if(preLimit < firstRendered ) {
                        // need some rows to the beginning of the rendered area
-                       client.console.log("Table: need some rows to the beginning of the rendered area");
+                       ApplicationConnection.getConsole().log("Table: need some rows to the beginning of the rendered area");
                        rowRequestHandler.setReqFirstRow((int) (firstRowInViewPort - pageLength*CACHE_RATE));
                        rowRequestHandler.setReqRows(firstRendered - rowRequestHandler.getReqFirstRow());
                        rowRequestHandler.deferRowFetch();
@@ -602,7 +603,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
                }
                if(postLimit > lastRendered) {
                        // need some rows to the end of the rendered area
-                       client.console.log("need some rows to the end of the rendered area");
+                       ApplicationConnection.getConsole().log("need some rows to the end of the rendered area");
                        rowRequestHandler.setReqFirstRow(lastRendered + 1);
                        rowRequestHandler.setReqRows((int) ((firstRowInViewPort + pageLength + pageLength*CACHE_RATE) - lastRendered));
                        rowRequestHandler.deferRowFetch();
@@ -611,7 +612,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
        }
 
        private void announceScrollPosition() {
-               client.console.log(""+firstRowInViewPort);
+               ApplicationConnection.getConsole().log(""+firstRowInViewPort);
                if(scrollPositionElement == null) {
                        scrollPositionElement = DOM.createDiv();
                        DOM.setElementProperty(scrollPositionElement, "className", "i-table-scrollposition");
@@ -675,7 +676,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
                }
 
                public void run() {
-                       client.console.log("Getting " + reqRows + " rows from " + reqFirstRow);
+                       ApplicationConnection.getConsole().log("Getting " + reqRows + " rows from " + reqFirstRow);
                        client.updateVariable(paintableId, "firstvisible", firstRowInViewPort, false);
                        client.updateVariable(paintableId, "reqfirstrow", reqFirstRow, false);
                        client.updateVariable(paintableId, "reqrows", reqRows, true);
@@ -833,23 +834,23 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
                protected void handleCaptionEvent(Event event) {
                        switch (DOM.eventGetType(event)) {
                        case Event.ONMOUSEDOWN:
-                               client.console.log("HeaderCaption: mouse down");
+                               ApplicationConnection.getConsole().log("HeaderCaption: mouse down");
                                if(columnReordering) {
                                        dragging = true;
                                        moved = false;
                                colIndex = getColIndexByKey(cid);
                                        DOM.setCapture(getElement());
                                        this.headerX = tHead.getAbsoluteLeft();
-                                       client.console.log("HeaderCaption: Caption set to capture mouse events");
+                                       ApplicationConnection.getConsole().log("HeaderCaption: Caption set to capture mouse events");
                                        DOM.eventPreventDefault(event); // prevent selecting text
                                }
                                break;
                        case Event.ONMOUSEUP:
-                               client.console.log("HeaderCaption: mouseUP");
+                               ApplicationConnection.getConsole().log("HeaderCaption: mouseUP");
                                if(columnReordering) {
                                        dragging = false;
                                        DOM.releaseCapture(getElement());
-                                       client.console.log("HeaderCaption: Stopped column reordering");
+                                       ApplicationConnection.getConsole().log("HeaderCaption: Stopped column reordering");
                                        if(moved) {
                                                hideFloatingCopy();
                                                tHead.removeSlotFocus();
@@ -884,7 +885,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
                                break;
                        case Event.ONMOUSEMOVE:
                                if (dragging) {
-                                       client.console.log("HeaderCaption: Dragging column, optimal index...");
+                                       ApplicationConnection.getConsole().log("HeaderCaption: Dragging column, optimal index...");
                                        if(!moved) {
                                                createFloatingCopy();
                                                moved = true;
@@ -912,7 +913,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
                                        tHead.focusSlot(closestSlot);
                                        
                                        updateFloatingCopysPosition(x, -1);
-                                       client.console.log(""+closestSlot);
+                                       ApplicationConnection.getConsole().log(""+closestSlot);
                                }
                                break;
                        default:
@@ -1447,7 +1448,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
                                fixSpacers();
                        } else {
                                // sorted or column reordering changed
-                               client.console.log("Bad update" + firstIndex + "/"+ rows);
+                               ApplicationConnection.getConsole().log("Bad update" + firstIndex + "/"+ rows);
                        }
                }
                
@@ -1700,7 +1701,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
                                switch (DOM.eventGetType(event)) {
                                case Event.ONCLICK:
                                        if((CLASSNAME+"-cell-content").equals(s)) {
-                                               client.console.log("Row click");
+                                               ApplicationConnection.getConsole().log("Row click");
                                                if(selectMode > ITable.SELECT_MODE_NONE) {
                                                        toggleSelection();
                                                        client.updateVariable(paintableId, "selected", selectedRowKeys.toArray(), immediate);
@@ -1715,7 +1716,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
                        }
                        
                        public void showContextMenu(Event event) {
-                               client.console.log("Context menu");
+                               ApplicationConnection.getConsole().log("Context menu");
                                if(actionKeys != null) {
                                        int left = DOM.eventGetClientX(event);
                                        int top = DOM.eventGetClientY(event);
index 09b6dd5351a27fc56930822b60a2a929a06bcfda..bd6c60560350aa6ed82fca33808d49a2428860b5 100644 (file)
@@ -111,7 +111,7 @@ public class ITextualDate extends IDateField implements Paintable, ChangeListene
                                try {\r
                                        date = format.parse(text.getText());\r
                                } catch (Exception e) {\r
-                                       client.console.log(e.getMessage());\r
+                                       ApplicationConnection.getConsole().log(e.getMessage());\r
                                        text.addStyleName(ITextField.CLASSNAME+"-error");\r
                                        Timer t = new Timer() {\r
                                                public void run() {\r
index aca8345453639decc938b3653be35d18cebacf20..2e682b05cf48a3947f96159af9b9ac0ca7da9e0e 100644 (file)
@@ -245,7 +245,6 @@ public class ITree extends Tree implements Paintable {
                }
                
                public void showContextMenu(Event event) {
-                       client.console.log("Context menu");
                        if(actionKeys != null) {
                                int left = DOM.eventGetClientX(event);
                                int top = DOM.eventGetClientY(event);