예제 #1
0
파일: VUI.java 프로젝트: horun/vaadin
  /**
   * Send new dimensions to the server.
   *
   * <p>For internal use only. May be removed or replaced in the future.
   */
  public void sendClientResized() {
    Profiler.enter("VUI.sendClientResized");
    Element parentElement = getElement().getParentElement();
    int viewHeight = parentElement.getClientHeight();
    int viewWidth = parentElement.getClientWidth();

    ResizeEvent.fire(this, viewWidth, viewHeight);
    Profiler.leave("VUI.sendClientResized");
  }
  @Override
  public void onModuleLoad() {
    Profiler.initialize();
    Profiler.enter("ApplicationConfiguration.onModuleLoad");

    BrowserInfo browserInfo = BrowserInfo.get();

    // Enable iOS6 cast fix (see #10460)
    if (browserInfo.isIOS()
        && browserInfo.isWebkit()
        && browserInfo.getBrowserMajorVersion() == 6) {
      enableIOS6castFix();
    }

    // Prepare VConsole for debugging
    if (isDebugMode()) {
      Console console = GWT.create(Console.class);
      console.setQuietMode(isQuietDebugMode());
      console.init();
      VConsole.setImplementation(console);
    } else {
      VConsole.setImplementation((Console) GWT.create(NullConsole.class));
    }
    /*
     * Display some sort of error of exceptions in web mode to debug
     * console. After this, exceptions are reported to VConsole and possible
     * GWT hosted mode.
     */
    GWT.setUncaughtExceptionHandler(
        new UncaughtExceptionHandler() {

          @Override
          public void onUncaughtException(Throwable e) {
            /*
             * Note in case of null console (without ?debug) we eat
             * exceptions. "a1 is not an object" style errors helps nobody,
             * especially end user. It does not work tells just as much.
             */
            VConsole.getImplementation().error(e);
          }
        });
    Profiler.leave("ApplicationConfiguration.onModuleLoad");

    if (SuperDevMode.enableBasedOnParameter()) {
      // Do not start any application as super dev mode will refresh the
      // page once done compiling
      return;
    }
    registerCallback(GWT.getModuleName());
  }
예제 #3
0
  /**
   * Create an uninitialized connector that best matches given UIDL. The connector must implement
   * {@link ServerConnector}.
   *
   * @param tag connector type tag for the connector to create
   * @param conf the application configuration to use when creating the connector
   * @return New uninitialized and unregistered connector that can paint given UIDL.
   */
  public ServerConnector createConnector(int tag, ApplicationConfiguration conf) {
    /*
     * Yes, this (including the generated code in WidgetMap) may look very
     * odd code, but due the nature of GWT, we cannot do this any cleaner.
     * Luckily this is mostly written by WidgetSetGenerator, here are just
     * some hacks. Extra instantiation code is needed if client side
     * connector has no "native" counterpart on client side.
     */
    Profiler.enter("WidgetSet.createConnector");

    Class<? extends ServerConnector> classType = resolveInheritedConnectorType(conf, tag);

    try {
      if (classType == null
          || classType == UnknownComponentConnector.class
          || classType == UnknownExtensionConnector.class) {
        String serverSideName = conf.getUnknownServerClassNameByTag(tag);
        if (classType == UnknownExtensionConnector.class) {
          // Display message in the console for non-visual connectors
          getLogger().severe(UnknownComponentConnector.createMessage(serverSideName));
          return GWT.create(UnknownExtensionConnector.class);
        } else {
          UnknownComponentConnector c = GWT.create(UnknownComponentConnector.class);
          // Set message to be shown in a widget for visual connectors
          c.setServerSideClassName(serverSideName);
          return c;
        }
      } else {
        /*
         * let the auto generated code instantiate this type
         */
        ServerConnector connector = (ServerConnector) TypeData.getType(classType).createInstance();
        if (connector instanceof HasJavaScriptConnectorHelper) {
          ((HasJavaScriptConnectorHelper) connector).getJavascriptConnectorHelper().setTag(tag);
        }
        return connector;
      }
    } catch (NoDataException e) {
      throw new IllegalStateException(
          "There is no information about "
              + classType
              + ". Did you remember to compile the right widgetset?",
          e);
    } finally {
      Profiler.leave("WidgetSet.createConnector");
    }
  }
  @Override
  public void onModuleLoad() {
    Profiler.initialize();
    Profiler.enter("ApplicationConfiguration.onModuleLoad");

    BrowserInfo browserInfo = BrowserInfo.get();

    // Enable iOS6 cast fix (see #10460)
    if (browserInfo.isIOS6() && browserInfo.isWebkit()) {
      enableIOS6castFix();
    }

    // Prepare the debugging window
    if (isDebugMode()) {
      /*
       * XXX Lots of implementation details here right now. This should be
       * cleared up when an API for extending the debug window is
       * implemented.
       */
      VDebugWindow window = GWT.create(VDebugWindow.class);

      if (LogConfiguration.loggingIsEnabled()) {
        window.addSection((Section) GWT.create(LogSection.class));
      }
      window.addSection((Section) GWT.create(InfoSection.class));
      window.addSection((Section) GWT.create(HierarchySection.class));
      window.addSection((Section) GWT.create(NetworkSection.class));
      if (Profiler.isEnabled()) {
        window.addSection((Section) GWT.create(ProfilerSection.class));
      }

      if (isQuietDebugMode()) {
        window.close();
      } else {
        window.init();
      }

      // Connect to the legacy API
      VConsole.setImplementation(window);

      Handler errorNotificationHandler = GWT.create(ErrorNotificationHandler.class);
      Logger.getLogger("").addHandler(errorNotificationHandler);
    }

    if (LogConfiguration.loggingIsEnabled()) {
      GWT.setUncaughtExceptionHandler(
          new UncaughtExceptionHandler() {

            @Override
            public void onUncaughtException(Throwable e) {
              /*
               * If the debug window is not enabled (?debug), this will
               * not show anything to normal users. "a1 is not an object"
               * style errors helps nobody, especially end user. It does
               * not work tells just as much.
               */
              getLogger().log(Level.SEVERE, e.getMessage(), e);
            }
          });

      if (isProductionMode()) {
        // Disable all logging if in production mode
        Logger.getLogger("").setLevel(Level.OFF);
      }
    }
    Profiler.leave("ApplicationConfiguration.onModuleLoad");

    if (SuperDevMode.enableBasedOnParameter()) {
      // Do not start any application as super dev mode will refresh the
      // page once done compiling
      return;
    }
    registerCallback(GWT.getModuleName());
  }
  @Override
  public void onModuleLoad() {

    // Don't run twice if the module has been inherited several times.
    if (moduleLoaded) {
      return;
    }
    moduleLoaded = true;

    Profiler.initialize();
    Profiler.enter("ApplicationConfiguration.onModuleLoad");

    BrowserInfo browserInfo = BrowserInfo.get();

    // Enable iOS6 cast fix (see #10460)
    if (browserInfo.isIOS6() && browserInfo.isWebkit()) {
      enableIOS6castFix();
    }

    // Enable IE prompt fix (#13367)
    if (browserInfo.isIE() && browserInfo.getBrowserMajorVersion() >= 10) {
      enableIEPromptFix();
    }

    // Register pointer events (must be done before any events are used)
    PointerEventSupport.init();

    // Prepare the debugging window
    if (isDebugMode()) {
      /*
       * XXX Lots of implementation details here right now. This should be
       * cleared up when an API for extending the debug window is
       * implemented.
       */
      VDebugWindow window = GWT.create(VDebugWindow.class);

      if (LogConfiguration.loggingIsEnabled()) {
        window.addSection((Section) GWT.create(LogSection.class));
      }
      window.addSection((Section) GWT.create(InfoSection.class));
      window.addSection((Section) GWT.create(HierarchySection.class));
      window.addSection((Section) GWT.create(NetworkSection.class));
      window.addSection((Section) GWT.create(TestBenchSection.class));
      if (Profiler.isEnabled()) {
        window.addSection((Section) GWT.create(ProfilerSection.class));
      }

      if (isQuietDebugMode()) {
        window.close();
      } else {
        // Load debug window styles asynchronously
        GWT.runAsync(
            new RunAsyncCallback() {
              @Override
              public void onSuccess() {
                DebugWindowStyles dws = GWT.create(DebugWindowStyles.class);
                dws.css().ensureInjected();
              }

              @Override
              public void onFailure(Throwable reason) {
                Window.alert("Failed to load Vaadin debug window styles");
              }
            });

        window.init();
      }

      // Connect to the legacy API
      VConsole.setImplementation(window);

      Handler errorNotificationHandler = GWT.create(ErrorNotificationHandler.class);
      Logger.getLogger("").addHandler(errorNotificationHandler);
    }

    if (LogConfiguration.loggingIsEnabled()) {
      GWT.setUncaughtExceptionHandler(
          new UncaughtExceptionHandler() {

            @Override
            public void onUncaughtException(Throwable e) {
              /*
               * If the debug window is not enabled (?debug), this will
               * not show anything to normal users. "a1 is not an object"
               * style errors helps nobody, especially end user. It does
               * not work tells just as much.
               */
              getLogger().log(Level.SEVERE, e.getMessage(), e);
            }
          });

      if (isProductionMode()) {
        // Disable all logging if in production mode
        Logger.getLogger("").setLevel(Level.OFF);
      }
    }
    Profiler.leave("ApplicationConfiguration.onModuleLoad");

    if (SuperDevMode.enableBasedOnParameter()) {
      // Do not start any application as super dev mode will refresh the
      // page once done compiling
      return;
    }
    registerCallback(GWT.getModuleName());
  }