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.

NetworkSection.java 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.client.debug.internal;
  17. import com.google.gwt.user.client.ui.FlowPanel;
  18. import com.google.gwt.user.client.ui.HTML;
  19. import com.google.gwt.user.client.ui.Widget;
  20. import com.vaadin.client.ApplicationConnection;
  21. import com.vaadin.client.VUIDLBrowser;
  22. import com.vaadin.client.ValueMap;
  23. /**
  24. * Displays network activity; requests and responses.
  25. *
  26. * Currently only displays responses in a simple manner.
  27. *
  28. * @since 7.1
  29. * @author Vaadin Ltd
  30. */
  31. public class NetworkSection implements Section {
  32. private final int maxSize = 10;
  33. private final DebugButton tabButton = new DebugButton(Icon.NETWORK,
  34. "Communication");
  35. private final HTML controls = new HTML(tabButton.getTitle());
  36. private final FlowPanel content = new FlowPanel();
  37. public NetworkSection() {
  38. content.setStyleName(VDebugWindow.STYLENAME + "-network");
  39. }
  40. @Override
  41. public DebugButton getTabButton() {
  42. return tabButton;
  43. }
  44. @Override
  45. public Widget getControls() {
  46. return controls;
  47. }
  48. @Override
  49. public Widget getContent() {
  50. return content;
  51. }
  52. @Override
  53. public void show() {
  54. // TODO Auto-generated method stub
  55. }
  56. @Override
  57. public void hide() {
  58. // TODO Auto-generated method stub
  59. }
  60. @Override
  61. public void meta(ApplicationConnection ac, ValueMap meta) {
  62. // NOP
  63. }
  64. @Override
  65. public void uidl(ApplicationConnection ac, ValueMap uidl) {
  66. int sinceStart = VDebugWindow.getMillisSinceStart();
  67. int sinceReset = VDebugWindow.getMillisSinceReset();
  68. VUIDLBrowser vuidlBrowser = new VUIDLBrowser(uidl, ac);
  69. vuidlBrowser.addStyleName(VDebugWindow.STYLENAME + "-row");
  70. vuidlBrowser.setText("Response @ " + sinceReset + "ms");
  71. vuidlBrowser.setTitle(VDebugWindow.getTimingTooltip(sinceStart,
  72. sinceReset));
  73. vuidlBrowser.close();
  74. content.add(vuidlBrowser);
  75. while (content.getWidgetCount() > maxSize) {
  76. content.remove(0);
  77. }
  78. }
  79. }