com.vaadin.ui.UI.getConnectorTracker()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(156)

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

UI.getConnectorTracker介绍

暂无

代码示例

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

/**
 * @deprecated As of 7.1. In 7.2 and later, use
 *             {@link ConnectorTracker#getConnector(String)
 *             uI.getConnectorTracker().getConnector(connectorId)} instead.
 *             See ticket #11411.
 */
@Deprecated
public ClientConnector getConnector(UI uI, String connectorId) {
  return uI.getConnectorTracker().getConnector(connectorId);
}

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

/**
 * Removes StreamVariables that belong to connectors that are no longer
 * attached to the session.
 */
private void cleanStreamVariables() {
  if (pidToNameToStreamVariable != null) {
    ConnectorTracker connectorTracker = uI.getConnectorTracker();
    Iterator<String> iterator = pidToNameToStreamVariable.keySet()
        .iterator();
    while (iterator.hasNext()) {
      String connectorId = iterator.next();
      if (connectorTracker.getConnector(connectorId) == null) {
        // Owner is no longer attached to the session
        Map<String, StreamVariable> removed = pidToNameToStreamVariable
            .get(connectorId);
        for (String key : removed.keySet()) {
          streamVariableToSeckey.remove(removed.get(key));
        }
        iterator.remove();
      }
    }
  }
}

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

/**
 * Requests that the given UI should be fully re-rendered on the client
 * side.
 *
 * @since 7.1 @deprecated. As of 7.1. Should be refactored once locales are
 *        fixed (#11378)
 */
@Deprecated
public void repaintAll(UI ui) {
  getClientCache(ui).clear();
  ui.getConnectorTracker().markAllConnectorsDirty();
  ui.getConnectorTracker().markAllClientSidesUninitialized();
}

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

private void cleanStreamVariable(VaadinSession session, final UI ui,
      final ClientConnector owner, final String variableName) {
    session.accessSynchronously(() -> ui.getConnectorTracker()
        .cleanStreamVariable(owner.getConnectorId(), variableName));
  }
}

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

.getConnectorTracker().getDirtyVisibleConnectors();

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

/**
 * Encodes the given value to JSON.
 * <p>
 * This is a helper method that can be invoked by an {@link #encode(Object)
 * encode(T)} override if serializing a value of type other than
 * {@link #getPresentationType() the presentation type} is desired. For
 * instance, a {@code Renderer<Date>} could first turn a date value into a
 * formatted string and return {@code encode(dateString, String.class)}.
 *
 * @param value
 *            the value to be encoded
 * @param type
 *            the type of the value
 * @return a JSON representation of the given value
 */
protected <U> JsonValue encode(U value, Class<U> type) {
  return JsonCodec
      .encode(value, null, type, getUI().getConnectorTracker())
      .getEncodedValue();
}

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

/**
 * @deprecated As of 7.1. See #11411.
 */
@Deprecated
public static JsonObject encodeState(ClientConnector connector,
    SharedState state) {
  UI uI = connector.getUI();
  ConnectorTracker connectorTracker = uI.getConnectorTracker();
  Class<? extends SharedState> stateType = connector.getStateType();
  JsonValue diffState = connectorTracker.getDiffState(connector);
  if (diffState == null) {
    // Use an empty state object as reference for full
    // repaints
    diffState = REFERENCE_DIFF_STATES.get(stateType);
    if (diffState == null) {
      diffState = createReferenceDiffStateState(stateType);
      REFERENCE_DIFF_STATES.put(stateType, diffState);
    }
  }
  EncodeResult encodeResult = JsonCodec.encode(state, diffState,
      stateType, uI.getConnectorTracker());
  connectorTracker.setDiffState(connector,
      (JsonObject) encodeResult.getEncodedValue());
  return (JsonObject) encodeResult.getDiff();
}

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

/**
   * Sets the expected value of a state property so that changes can be
   * properly sent to the client. This needs to be done in cases where a state
   * change originates from the client, since otherwise the server-side would
   * fail to recognize if the value is changed back to its previous value.
   *
   * @param propertyName
   *            the name of the shared state property to update
   * @param newValue
   *            the new diffstate reference value
   */
  protected void updateDiffstate(String propertyName, JsonValue newValue) {
    if (!isAttached()) {
      return;
    }

    JsonObject diffState = getUI().getConnectorTracker().getDiffState(this);
    if (diffState == null) {
      return;
    }

    assert diffState.hasKey(propertyName) : "Diffstate for "
        + getClass().getName() + " has no property named "
        + propertyName;

    diffState.put(propertyName, newValue);
  }
}

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

/**
 * Returns the shared state for this connector.
 *
 * @param markAsDirty
 *            true if the connector should automatically be marked dirty,
 *            false otherwise
 *
 * @return The shared state for this connector. Never null.
 * @see #getState()
 */
protected SharedState getState(boolean markAsDirty) {
  assert getSession() == null
      || getSession().hasLock() : buildLockAssertMessage(
          "getState()");
  if (null == sharedState) {
    sharedState = createState();
  }
  if (markAsDirty) {
    UI ui = getUI();
    if (ui != null && !ui.getConnectorTracker().isDirty(this)
        && !ui.getConnectorTracker().isWritingResponse()) {
      ui.getConnectorTracker().markDirty(this);
    }
  }
  return sharedState;
}

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

UI ui = getUI();
if (ui != null) {
  ui.getConnectorTracker().getDiffState(Grid.this)
      .remove(diffStateKey);

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

private String getStreamVariableTargetUrl(String name,
    StreamVariable value) {
  String connectorId = getConnectorId();
  UI ui = getUI();
  int uiId = ui.getUIId();
  String key = uiId + "/" + connectorId + "/" + name;
  ConnectorTracker connectorTracker = ui.getConnectorTracker();
  connectorTracker.addStreamVariable(connectorId, name, value);
  String secKey = connectorTracker.getSeckey(value);
  return ApplicationConstants.APP_PROTOCOL_PREFIX
      + ServletPortletHelper.UPLOAD_URL_PREFIX + key + "/" + secKey;
}

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

/**
 * Triggered when the user unchecks the select all checkbox.
 *
 * @param userOriginated
 *            {@code true} if originated from client side by user
 */
protected void onDeselectAll(boolean userOriginated) {
  if (userOriginated) {
    verifyUserCanSelectAll();
    // all selected state has been update in client side already
    getState(false).allSelected = false;
    getUI().getConnectorTracker().getDiffState(this).put("allSelected",
        false);
  } else {
    getState().allSelected = false;
  }
  updateSelection(Collections.emptySet(), new LinkedHashSet<>(selection),
      userOriginated);
}

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

/**
 * @deprecated As of 7.1. See #11411.
 */
@Deprecated
public String getStreamVariableTargetUrl(ClientConnector owner, String name,
    StreamVariable value) {
  /*
   * We will use the same APP/* URI space as ApplicationResources but
   * prefix url with UPLOAD
   *
   * e.g. APP/UPLOAD/[UIID]/[PID]/[NAME]/[SECKEY]
   *
   * SECKEY is created on each paint to make URL's unpredictable (to
   * prevent CSRF attacks).
   *
   * NAME and PID from URI forms a key to fetch StreamVariable when
   * handling post
   */
  String paintableId = owner.getConnectorId();
  UI ui = owner.getUI();
  int uiId = ui.getUIId();
  String key = uiId + "/" + paintableId + "/" + name;
  ConnectorTracker connectorTracker = ui.getConnectorTracker();
  connectorTracker.addStreamVariable(paintableId, name, value);
  String seckey = connectorTracker.getSeckey(value);
  return ApplicationConstants.APP_PROTOCOL_PREFIX
      + ServletPortletHelper.UPLOAD_URL_PREFIX + key + "/" + seckey;
}

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

.getConnectorTracker().getDirtyVisibleConnectors();

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

@Override
public void markAsDirty() {
  assert getSession() == null
      || getSession().hasLock() : buildLockAssertMessage(
          "markAsDirty()");
  UI uI = getUI();
  if (uI != null) {
    uI.getConnectorTracker().markDirty(this);
  }
}

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

@Override
public void attach() {
  markAsDirty();
  getUI().getConnectorTracker().registerConnector(this);
  for (ClientConnector connector : getAllChildrenIterable(this)) {
    connector.attach();
  }
  fireEvent(new AttachEvent(this));
}

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

/**
 * {@inheritDoc}
 *
 * <p>
 * The {@link #getSession()} and {@link #getUI()} methods might return
 * <code>null</code> after this method is called.
 * </p>
 */
@Override
public void detach() {
  for (ClientConnector connector : getAllChildrenIterable(this)) {
    connector.detach();
  }
  fireEvent(new DetachEvent(this));
  getUI().getConnectorTracker().unregisterConnector(this);
}

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

/**
 * Triggered when the user checks the select all checkbox.
 *
 * @param userOriginated
 *            {@code true} if originated from client side by user
 */
protected void onSelectAll(boolean userOriginated) {
  if (userOriginated) {
    verifyUserCanSelectAll();
    // all selected state has been updated in client side already
    getState(false).allSelected = true;
    getUI().getConnectorTracker().getDiffState(this).put("allSelected",
        true);
  } else {
    getState().allSelected = true;
  }
  Stream<T> allItemsStream;
  DataProvider<T, ?> dataProvider = getGrid().getDataProvider();
  // this will fetch everything from backend
  if (dataProvider instanceof HierarchicalDataProvider) {
    allItemsStream = fetchAllHierarchical(
        (HierarchicalDataProvider<T, ?>) dataProvider);
  } else {
    allItemsStream = fetchAll(dataProvider);
  }
  LinkedHashSet<T> allItems = new LinkedHashSet<>();
  allItemsStream.forEach(allItems::add);
  updateSelection(allItems, Collections.emptySet(), userOriginated);
}

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

.getConnectorTracker().getDirtyVisibleConnectors();

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

if (!getConnectorTracker().hasDirtyConnectors()) {

相关文章