Java 类com.google.gwt.core.client.js.JsExport 实例源码

项目:dom-distiller    文件:JsTestEntry.java   
@JsExport
public static TestSuiteResults runWithFilter(String filter) {
    int debugLevel = JavaScript.parseInt(Window.Location.getParameter("debug_level"));
    LogUtil.setDebugLevel(debugLevel);
    boolean consoleLog = !"0".equals(Window.Location.getParameter("console_log"));
    LogUtil.setSuppressConsoleOutput(!consoleLog);
    JsTestSuiteBuilder builder = GWT.<JsTestSuiteBuilder>create(JsTestSuiteBuilder.class);
    TestLogger logger = new TestLogger();
    boolean shuffle = "1".equals(Window.Location.getParameter("shuffle"));
    Map<String, JsTestSuiteBase.TestCaseResults> results =
        builder.build().run(logger, filter, shuffle);
    return createTestSuiteResults(results, logger);
}
项目:dom-distiller    文件:JsTestEntry.java   
@JsExport
public static void printTestNames() {
    JsTestSuiteBuilder builder = GWT.<JsTestSuiteBuilder>create(JsTestSuiteBuilder.class);
    Map<String, JsTestSuiteBase.TestCaseResults> results = builder.build().run(
            new TestLogger.NullLogger(), "$^");
    for (Map.Entry<String, JsTestSuiteBase.TestCaseResults> testCaseEntry :
            results.entrySet()) {
        for (Map.Entry<String, JsTestSuiteBase.TestResult> testEntry :
                testCaseEntry.getValue().getResults().entrySet()) {
            LogUtil.logToConsole(testCaseEntry.getKey() + "." + testEntry.getKey());
        }
    }
}
项目:RedQueryBuilder    文件:RedQueryBuilder.java   
@JsExport("$wnd.redQueryBuilder")
static CommandBuilder configure(JsConfiguration config, String sql,
        JsArrayMixed args) throws Exception {
    if (config == null) {
        throw new IllegalArgumentException("Config is null.");
    }

    RedQueryBuilder rqb = new RedQueryBuilder();

    return rqb.install(config, sql, JsList.get().toList(args));
}
项目:dom-distiller    文件:DomDistiller.java   
@JsExport
public static DomDistillerProtos.DomDistillerResult apply() {
    return applyWithOptions(DomDistillerProtos.DomDistillerOptions.create());
}
项目:dom-distiller    文件:DomDistiller.java   
@JsExport
public static DomDistillerProtos.DomDistillerResult applyWithOptions(
        DomDistillerProtos.DomDistillerOptions options) {
    double startTime = DomUtil.getTime();
    StringUtil.setWordCounter(
            DomUtil.javascriptTextContent(Document.get().getDocumentElement()));
    DomDistillerProtos.DomDistillerResult result =
            DomDistillerProtos.DomDistillerResult.create();
    ContentExtractor contentExtractor =
            new ContentExtractor(Document.get().getDocumentElement());
    result.setTitle(contentExtractor.extractTitle());

    LogUtil.setDebugLevel(
            options.hasDebugLevel() ? options.getDebugLevel() : LogUtil.DEBUG_LEVEL_NONE);
    LogUtil.logToConsole("DomDistiller debug level: " + LogUtil.getDebugLevel());

    DomDistillerProtos.DistilledContent content = DomDistillerProtos.DistilledContent.create();
    boolean textOnly = options.hasExtractTextOnly() && options.getExtractTextOnly();
    content.setHtml(contentExtractor.extractContent(textOnly));
    result.setDistilledContent(content);
    result.setTextDirection(contentExtractor.getTextDirection());

    for (String url : contentExtractor.getImageUrls()) {
        result.addContentImages().setUrl(url);
    }

    // iOS doesn't support reading window.location.href, so we use document.URL instead.
    String originalUrl =
            options.hasOriginalUrl() ? options.getOriginalUrl() : Document.get().getURL();
    TimingInfo timingInfo = contentExtractor.getTimingInfo();
    double stPaging = DomUtil.getTime();
    String paginationAlgo = options.hasPaginationAlgo() ? options.getPaginationAlgo() : "next";
    if (paginationAlgo.equals("pagenum")) {
        PageParamInfo paramInfo = PageParameterParser.parse(originalUrl, timingInfo);
        DomDistillerProtos.PaginationInfo info = DomDistillerProtos.PaginationInfo.create();
        String next = paramInfo.mNextPagingUrl;
        if (!next.isEmpty()) {
            info.setNextPage(next);
        }
        result.setPaginationInfo(info);
        if (LogUtil.isLoggable(LogUtil.DEBUG_LEVEL_PAGING_INFO)) {
            LogUtil.logToConsole("paging by pagenum: " + paramInfo.toString());
        }
    } else {
        if (LogUtil.isLoggable(LogUtil.DEBUG_LEVEL_PAGING_INFO)) {
            LogUtil.logToConsole("paging by next");
        }
        result.setPaginationInfo(PagingLinksFinder.getPaginationInfo(originalUrl));
    }
    LogUtil.addTimingInfo(stPaging, timingInfo, "Pagination");

    result.setMarkupInfo(contentExtractor.getMarkupParser().getMarkupInfo());
    timingInfo.setTotalTime(DomUtil.getTime() - startTime);
    result.setTimingInfo(timingInfo);
    result.setStatisticsInfo(contentExtractor.getStatisticsInfo());
    DebugInfo debugInfo = DebugInfo.create();
    debugInfo.setLog(LogUtil.getAndClearLog());
    result.setDebugInfo(debugInfo);
    return result;
}
项目:dom-distiller    文件:JsTestEntry.java   
@JsExport
public static TestSuiteResults run() {
    String filter = Window.Location.getParameter("filter");
    return runWithFilter(filter);
}
项目:RedQueryBuilder    文件:JsMessage.java   
@JsExport("$wnd.rqb.Message")
public JsMessage(String text) {
    this.text = text;
}
项目:realtime-channel    文件:ReconnectBus.java   
@JsExport
public ReconnectBus(String serverUri, JsonObject options) {
  super(serverUri, options);
  this.options = options;
  reconnect =
      options == null || !options.has(AUTO_RECONNECT) ? true : options.getBoolean(AUTO_RECONNECT);
  backOffGenerator = new FuzzingBackOffGenerator(1 * 1000, 30 * 60 * 1000, 0.5);

  super.setHook(new BusHookProxy() {
    @Override
    public void handleOpened() {
      backOffGenerator.reset();

      handlerCount.keys().forEach(new JsonArray.ListIterator<String>() {
        @Override
        public void call(int index, String topic) {
          assert handlerCount.getNumber(topic) > 0 : "Handlers registried on " + topic
              + " shouldn't be empty";
          sendUnsubscribe(topic);
          sendSubscribe(topic);
        }
      });

      if (queuedMessages.length() > 0) {
        JsonArray copy = queuedMessages.copy();
        queuedMessages.clear();
        // Drain any messages that came in while the channel was not open.
        copy.forEach(new JsonArray.ListIterator<JsonObject>() {
          @Override
          public void call(int index, JsonObject msg) {
            send(msg);
          }
        });
      }
      super.handleOpened();
    }

    @Override
    public void handlePostClose() {
      if (reconnect) {
        Platform.scheduler().scheduleDelay(backOffGenerator.next().targetDelay,
            new Handler<Void>() {
              @Override
              public void handle(Void event) {
                if (reconnect) {
                  reconnect();
                }
              }
            });
      }
      super.handlePostClose();
    }

    @Override
    protected BusHook delegate() {
      return hook;
    }
  });
}
项目:RedQueryBuilder    文件:JsVisitor.java   
@JsExport("$wnd.rqb.Visitor")
public JsVisitor() {

}