You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Util.java 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package com.itmill.toolkit.terminal.gwt.client;
  2. import java.util.Iterator;
  3. import com.google.gwt.user.client.Element;
  4. import com.google.gwt.user.client.ui.HasWidgets;
  5. import com.google.gwt.user.client.ui.Widget;
  6. public class Util {
  7. /**
  8. * Helper method for debugging purposes.
  9. *
  10. * Stops execution on firefox browsers on a breakpoint.
  11. *
  12. */
  13. public static native void browserDebugger() /*-{
  14. if(window.console)
  15. debugger;
  16. }-*/;
  17. /**
  18. * Detects if current browser is IE6. Use to isola
  19. *
  20. * @return true if IE6
  21. */
  22. public static native boolean isIE6() /*-{
  23. var browser=$wnd.navigator.appName;
  24. var version=parseFloat($wnd.navigator.appVersion);
  25. if (browser=="Microsoft Internet Explorer" && (version < 7) ) {
  26. return true;
  27. }
  28. return false;
  29. }-*/;
  30. /**
  31. * Nulls oncontextmenu function on given element. We need to manually clear
  32. * context menu events due bad browsers memory leaks, since we GWT don't
  33. * support them.
  34. *
  35. * @param el
  36. */
  37. public native static void removeContextMenuEvent(Element el) /*-{
  38. el.oncontextmenu = null;
  39. }-*/;
  40. /**
  41. * Traverses recursively ancestors until ContainerResizedListener child widget is found.
  42. * They will delegate it futher if needed.
  43. * @param container
  44. */
  45. public static void runAnchestorsLayout(HasWidgets container) {
  46. Iterator childWidgets = container.iterator();
  47. while (childWidgets.hasNext()) {
  48. Widget child = (Widget) childWidgets.next();
  49. if (child instanceof ContainerResizedListener) {
  50. ((ContainerResizedListener) child).iLayout();
  51. } else if (child instanceof HasWidgets) {
  52. HasWidgets childContainer = (HasWidgets) child;
  53. runAnchestorsLayout(childContainer);
  54. }
  55. }
  56. }
  57. }