選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Util.java 1.6KB

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 IE.
  19. *
  20. * @return true if IE
  21. */
  22. public static native boolean isIE() /*-{
  23. var browser=$wnd.navigator.appName;
  24. if (browser=="Microsoft Internet Explorer") {
  25. return true;
  26. }
  27. return false;
  28. }-*/;
  29. /**
  30. * Nulls oncontextmenu function on given element. We need to manually clear
  31. * context menu events due bad browsers memory leaks, since we GWT don't
  32. * support them.
  33. *
  34. * @param el
  35. */
  36. public native static void removeContextMenuEvent(Element el) /*-{
  37. el.oncontextmenu = null;
  38. }-*/;
  39. /**
  40. * Traverses recursively ancestors until ContainerResizedListener child
  41. * widget is found. They will delegate it futher if needed.
  42. *
  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. }