123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- /*
- @ITMillApache2LicenseForJavaFiles@
- */
-
- package com.itmill.toolkit.terminal.gwt.client;
-
- import com.google.gwt.user.client.DOM;
- import com.google.gwt.user.client.Element;
- import com.google.gwt.user.client.Event;
- 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.google.gwt.user.client.ui.Panel;
- import com.google.gwt.user.client.ui.ScrollPanel;
- import com.google.gwt.user.client.ui.Widget;
- import com.itmill.toolkit.terminal.gwt.client.ui.IWindow;
-
- public final class IDebugConsole extends IWindow implements Console {
-
- /**
- * Builds number. For example 0-custom_tag in 5.0.0-custom_tag.
- */
- public static final String VERSION;
-
- /* Initialize version numbers from string replaced by build-script. */
- static {
- if ("@VERSION@".equals("@" + "VERSION" + "@")) {
- VERSION = "5.9.9-INTERNAL-NONVERSIONED-DEBUG-BUILD";
- } else {
- VERSION = "@VERSION@";
- }
- }
-
- private final Panel panel;
-
- public IDebugConsole(ApplicationConnection client,
- ApplicationConfiguration cnf) {
- super();
- this.client = client;
- panel = new FlowPanel();
- final ScrollPanel p = new ScrollPanel();
- p.add(panel);
- setWidget(p);
- setCaption("Debug window");
- minimize();
- show();
-
- ;
-
- log("Toolkit application servlet version: " + cnf.getSerletVersion());
- log("Widget set is built on version: " + VERSION);
- log("Application version: " + cnf.getApplicationVersion());
-
- if (!cnf.getSerletVersion().equals(VERSION)) {
- error("Warning: your widget set seems to be built with different "
- + "version than the one used on server. Unexpected "
- + "behavior may occur.");
- }
- }
-
- private void minimize() {
- // TODO stack to bottom (create window manager of some sort)
- setPixelSize(60, 60);
- setPopupPosition(Window.getClientWidth() - 142, 0);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.itmill.toolkit.terminal.gwt.client.Console#log(java.lang.String)
- */
- public void log(String msg) {
- panel.add(new HTML(msg));
- System.out.println(msg);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.itmill.toolkit.terminal.gwt.client.Console#error(java.lang.String)
- */
- public void error(String msg) {
- panel.add((new HTML(msg)));
- System.out.println(msg);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.itmill.toolkit.terminal.gwt.client.Console#printObject(java.lang.
- * Object)
- */
- public void printObject(Object msg) {
- panel.add((new Label(msg.toString())));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.itmill.toolkit.terminal.gwt.client.Console#dirUIDL(com.itmill.toolkit
- * .terminal.gwt.client.UIDL)
- */
- public void dirUIDL(UIDL u) {
- panel.add(u.print_r());
- }
-
- public void setSize(Event event, boolean updateVariables) {
- super.setSize(event, false);
- }
-
- public void onScroll(Widget widget, int scrollLeft, int scrollTop) {
-
- }
-
- public void setPopupPosition(int left, int top) {
- // Keep the popup within the browser's client area, so that they can't
- // get
- // 'lost' and become impossible to interact with. Note that we don't
- // attempt
- // to keep popups pegged to the bottom and right edges, as they will
- // then
- // cause scrollbars to appear, so the user can't lose them.
- if (left < 0) {
- left = 0;
- }
- if (top < 0) {
- top = 0;
- }
-
- // Set the popup's position manually, allowing setPopupPosition() to be
- // called before show() is called (so a popup can be positioned without
- // it
- // 'jumping' on the screen).
- Element elem = getElement();
- DOM.setStyleAttribute(elem, "left", left + "px");
- DOM.setStyleAttribute(elem, "top", top + "px");
- }
-
- }
|