com.vaadin.flow.component.UI.getInternals()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(196)

本文整理了Java中com.vaadin.flow.component.UI.getInternals()方法的一些代码示例,展示了UI.getInternals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UI.getInternals()方法的具体详情如下:
包路径:com.vaadin.flow.component.UI
类名称:UI
方法名:getInternals

UI.getInternals介绍

[英]Gets the framework data object for this UI.
[中]获取此UI的框架数据对象。

代码示例

代码示例来源:origin: com.vaadin/flow-server

private static AtmospherePushConnection getConnectionForUI(UI ui) {
  PushConnection pushConnection = ui.getInternals().getPushConnection();
  if (pushConnection instanceof AtmospherePushConnection) {
    return (AtmospherePushConnection) pushConnection;
  } else {
    return null;
  }
}

代码示例来源:origin: com.vaadin/flow-server

/**
 * Sets the page title. The title is displayed by the browser e.g. as the
 * title of the browser window or tab.
 * <p>
 * To clear the page title, use an empty string.
 *
 * @param title
 *            the page title to set, not <code>null</code>
 */
public void setTitle(String title) {
  if (title == null) {
    throw new IllegalArgumentException("Cannot set a null page title.");
  }
  ui.getInternals().setTitle(title);
}

代码示例来源:origin: com.vaadin/flow-server

private void storeContinueNavigationAction(UI ui,
    ContinueNavigationAction currentAction) {
  ContinueNavigationAction previousAction = ui.getInternals()
      .getContinueNavigationAction();
  if (previousAction != null && previousAction != currentAction) {
    // Any earlier action is now obsolete, so it must be defused
    // to prevent it from wreaking havoc if it's ever called
    previousAction.setReferences(null, null);
  }
  ui.getInternals().setContinueNavigationAction(currentAction);
}

代码示例来源:origin: com.vaadin/flow-server

private boolean handleNavigationForLocation(UI ui, Location location) {
  if (ui.getInternals().hasLastHandledLocation()) {
    return !location.getPathWithQueryParameters()
        .equals(ui.getInternals().getLastHandledLocation()
            .getPathWithQueryParameters());
  }
  return true;
}

代码示例来源:origin: com.vaadin/flow-server

/**
 * Gets the state node for this UI.
 *
 * @return the state node for the UI, in practice the state tree root node
 */
private StateNode getNode() {
  return getInternals().getStateTree().getRootNode();
}

代码示例来源:origin: com.vaadin/flow-server

private void addDependency(Dependency dependency) {
  assert dependency != null;
  ui.getInternals().getDependencyList().add(dependency);
}

代码示例来源:origin: com.vaadin/flow-server

private static UI findUiUsingResource(AtmosphereResource resource,
    Collection<UI> uIs) {
  for (UI ui : uIs) {
    PushConnection pushConnection = ui.getInternals()
        .getPushConnection();
    if (pushConnection instanceof AtmospherePushConnection) {
      if (((AtmospherePushConnection) pushConnection)
          .getResource() == resource) {
        return ui;
      }
    }
  }
  return null;
}

代码示例来源:origin: com.vaadin/vaadin-notification-flow

@Override
  public void accept(UI ui) {
    if (this == deferredJob) {
      String appId = ui.getInternals().getAppId();
      int nodeId = container.getNode().getId();
      String template = String.format(
          "<flow-component-renderer appid=\"%s\" nodeid=\"%s\"></flow-component-renderer>",
          appId, nodeId);
      templateElement.setProperty("innerHTML", template);
    }
  }
}

代码示例来源:origin: com.vaadin/flow-server

private PushConfigurationMap getPushConfigurationMap() {
  return ui.getInternals().getStateTree().getRootNode()
      .getFeature(PushConfigurationMap.class);
}

代码示例来源:origin: com.vaadin/flow-data

private void requestFlush(HierarchicalCommunicationController<T> update) {
  SerializableConsumer<ExecutionContext> flushRequest = context -> update
      .flush();
  stateNode.runWhenAttached(ui -> ui.getInternals().getStateTree()
      .beforeClientResponse(stateNode, flushRequest));
}

代码示例来源:origin: com.vaadin/flow-data

private void requestFlushUpdatedData() {
  if (flushUpdatedDataRequest == null) {
    flushUpdatedDataRequest = context -> {
      flushUpdatedData();
      flushUpdatedDataRequest = null;
    };
    stateNode.runWhenAttached(ui -> ui.getInternals().getStateTree()
        .beforeClientResponse(stateNode, flushUpdatedDataRequest));
  }
}

代码示例来源:origin: com.vaadin/flow-data

private void requestFlush(HierarchicalUpdate update) {
  SerializableConsumer<ExecutionContext> flushRequest = context -> update
      .commit();
  stateNode.runWhenAttached(ui -> ui.getInternals().getStateTree()
      .beforeClientResponse(stateNode, flushRequest));
}

代码示例来源:origin: com.vaadin/flow-server

private static Object getTemplateItem(PolymerTemplate<?> template,
    JsonObject argValue, Type convertedType) {
  StateNode node = template.getUI().get().getInternals().getStateTree()
      .getNodeById((int) argValue.getNumber("nodeId"));
  ModelType propertyType = template.getModelType(convertedType);
  return propertyType.modelToApplication(node);
}

代码示例来源:origin: com.vaadin/flow-data

private void setupTemplate(Element owner, SimpleValueRendering rendering,
    DataKeyMapper<SOURCE> keyMapper) {
  owner.getNode()
      .runWhenAttached(ui -> ui.getInternals().getStateTree()
          .beforeClientResponse(owner.getNode(),
              context -> setupTemplateWhenAttached(owner,
                  rendering, keyMapper)));
}

代码示例来源:origin: com.vaadin/flow-server

/**
 * Runs the given action right before the next response during which this
 * element is attached.
 *
 * @param action
 *            the action to run
 */
private void runBeforeAttachedResponse(SerializableConsumer<UI> action) {
  getNode().runWhenAttached(
      ui -> ui.getInternals().getStateTree().beforeClientResponse(
          getNode(), context -> action.accept(context.getUI())));
}

代码示例来源:origin: com.vaadin/vaadin-context-menu-flow

private void resetContent() {
  if (updateScheduled) {
    return;
  }
  updateScheduled = true;
  runBeforeClientResponse(ui -> {
    container.removeAllChildren();
    getItems().forEach(this::resetContainers);
    int containerNodeId = createNewContainer(getChildren());
    String appId = ui.getInternals().getAppId();
    ui.getPage().executeJavaScript(
        "window.Vaadin.Flow.contextMenuConnector.generateItems($0, $1, $2)",
        getElement(), appId, containerNodeId);
    updateScheduled = false;
  });
}

代码示例来源:origin: com.vaadin/vaadin-text-field-flow

private static void execJS(Component component, String js) {
  StateNode node = component.getElement().getNode();
  node.runWhenAttached(ui -> ui.getInternals().getStateTree()
      .beforeClientResponse(node, context -> ui.getPage()
          .executeJavaScript(js, component.getElement())));
}

代码示例来源:origin: com.vaadin/flow-data

private void requestFlush() {
  if (flushRequest == null) {
    flushRequest = context -> {
      if (!context.isClientSideInitialized()) {
        reset();
        arrayUpdater.initialize();
      }
      flush();
      flushRequest = null;
    };
    stateNode.runWhenAttached(ui -> ui.getInternals().getStateTree()
        .beforeClientResponse(stateNode, flushRequest));
  }
}

代码示例来源:origin: com.vaadin/vaadin-iron-list-flow

private void runBeforeClientResponse(Command command) {
  getElement().getNode()
      .runWhenAttached(ui -> ui.getInternals().getStateTree()
          .beforeClientResponse(getElement().getNode(),
              context -> command.execute()));
}

代码示例来源:origin: com.vaadin/flow-data

@Override
public Rendering<SOURCE> render(Element container,
    DataKeyMapper<SOURCE> keyMapper, Element contentTemplate) {
  ComponentRendering rendering = new ComponentRendering(
      keyMapper == null ? null : keyMapper::key);
  rendering.setTemplateElement(contentTemplate);
  container.getNode()
      .runWhenAttached(ui -> ui.getInternals().getStateTree()
          .beforeClientResponse(container.getNode(),
              context -> setupTemplateWhenAttached(
                  context.getUI(), container, rendering,
                  keyMapper)));
  return rendering;
}

相关文章