Browse Source

System errors, UIDL.XML fix, made console static, allow html in debug windows messages, clickin error icon prints error to console

svn changeset:2276/svn branch:trunk
tags/6.7.0.beta1
Matti Tahvonen 16 years ago
parent
commit
ac1118a249

+ 6
- 2
src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java View File

@@ -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);

+ 7
- 5
src/com/itmill/toolkit/terminal/gwt/client/Caption.java View 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();
}
}

+ 4
- 3
src/com/itmill/toolkit/terminal/gwt/client/DebugConsole.java View File

@@ -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);
}


+ 3
- 0
src/com/itmill/toolkit/terminal/gwt/client/ErrorMessage.java View 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);

+ 12
- 1
src/com/itmill/toolkit/terminal/gwt/client/UIDL.java View 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();
}
}


+ 16
- 15
src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java View 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);

+ 1
- 1
src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java View File

@@ -111,7 +111,7 @@ public class ITextualDate extends IDateField implements Paintable, ChangeListene
try {
date = format.parse(text.getText());
} catch (Exception e) {
client.console.log(e.getMessage());
ApplicationConnection.getConsole().log(e.getMessage());
text.addStyleName(ITextField.CLASSNAME+"-error");
Timer t = new Timer() {
public void run() {

+ 0
- 1
src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java View 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);

Loading…
Cancel
Save