com.vaadin.ui.UI类的使用及代码示例

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

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

UI介绍

[英]The topmost component in any component hierarchy. There is one UI for every Vaadin instance in a browser window. A UI may either represent an entire browser window (or tab) or some part of a html page where a Vaadin application is embedded.

The UI is the server side entry point for various client side features that are not represented as components added to a layout, e.g notifications, sub windows, and executing javascript in the browser.

When a new UI instance is needed, typically because the user opens a URL in a browser window which points to e.g. VaadinServlet, all UIProviders registered to the current VaadinSession are queried for the UI class that should be used. The selection is by default based on the UI init parameter from web.xml.

After a UI has been created by the application, it is initialized using #init(VaadinRequest). This method is intended to be overridden by the developer to add components to the user interface and initialize non-component functionality. The component hierarchy must be initialized by passing a Component with the main layout or other content of the view to #setContent(Component) or to the constructor of the UI.
[中]任何组件层次结构中最顶层的组件。浏览器窗口中的每个Vaadin实例都有一个UI。UI可以代表整个浏览器窗口(或选项卡),也可以代表嵌入Vaadin应用程序的html页面的某个部分。
UI是各种客户端功能的服务器端入口点,这些功能不表示为添加到布局中的组件,例如通知、子窗口和在浏览器中执行javascript。
当需要一个新的UI实例时,通常是因为用户在浏览器窗口中打开一个指向(例如,VaadinServlet)的URL,所有注册到当前VaadinSession的UIProvider都会被查询出应该使用的UI类。默认情况下,选择基于web的UIinit参数。xml。
应用程序创建UI后,将使用#init(VaadinRequest)对其进行初始化。此方法旨在被开发人员覆盖,以便将组件添加到用户界面并初始化非组件功能。组件层次结构必须通过将带有视图主布局或其他内容的组件传递给#setContent(组件)或UI的构造函数来初始化。

代码示例

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

private Locale findLocale() {
  Locale l = null;
  if (component != null) {
    l = component.getLocale();
  }
  if (l == null && UI.getCurrent() != null) {
    l = UI.getCurrent().getLocale();
  }
  if (l == null) {
    l = Locale.getDefault();
  }
  return l;
}

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

+ uiId + "). ";
  if (getSession() != null
      && !getSession().equals(VaadinSession.getCurrent())) {
    message += "Furthermore, it is already attached to another VaadinSession. ";
setTheme(request.getParameter("theme"));
getPage().init(request);
  setUiPathInfo(uiPathInfo);
if (getSession() != null && getSession().getConfiguration() != null
    && getSession().getConfiguration().isSendUrlsAsParameters()
    && getPage().getLocation() != null) {
  String uiRootPath = getPage().getLocation().getPath();
  setUiRootPath(uiRootPath);
init(request);
Navigator navigator = getNavigator();
if (navigator != null) {

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

/**
 * Method that handles window closing (from UI).
 *
 * <p>
 * By default, windows are removed from their respective UIs and thus
 * visually closed on browser-side.
 * </p>
 *
 * <p>
 * To react to a window being closed (after it is closed), register a
 * {@link CloseListener}.
 * </p>
 */
public void close() {
  UI uI = getUI();
  // Don't do anything if not attached to a UI
  if (uI != null) {
    // window is removed from the UI
    uI.removeWindow(this);
  }
}

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

/**
 * Gets the Page to which the current uI belongs. This is automatically
 * defined when processing requests to the server. In other cases, (e.g.
 * from background threads), the current uI is not automatically defined.
 *
 * @see UI#getCurrent()
 *
 * @return the current page instance if available, otherwise
 *         <code>null</code>
 */
public static Page getCurrent() {
  UI currentUI = UI.getCurrent();
  if (currentUI == null) {
    return null;
  }
  return currentUI.getPage();
}

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

/**
 * Called by the framework to remove an UI instance from the session because
 * it has been closed.
 *
 * @param ui
 *            the UI to remove
 */
public void removeUI(UI ui) {
  assert hasLock() : "Session is locked";
  assert UI.getCurrent() != null : "Current UI cannot be null";
  assert ui != null : "Removed UI cannot be null";
  assert UI.getCurrent().getUIId() == ui.getUIId() : "UIs don't match";
  Integer id = Integer.valueOf(ui.getUIId());
  ui.setSession(null);
  uIs.remove(id);
  String embedId = ui.getEmbedId();
  if (embedId != null && id.equals(embedIdMap.get(embedId))) {
    embedIdMap.remove(embedId);
  }
}

代码示例来源:origin: OpenNMS/opennms

public void open() {
    if (UI.getCurrent() != null) {
      UI.getCurrent().addWindow(this);
    }
  }
}

代码示例来源:origin: eclipse/hawkbit

/**
 * Constructor for BaseUIEvent
 */
public BaseUIEvent() {
  this.source = UI.getCurrent().getNavigator().getCurrentView().getClass();
}

代码示例来源:origin: org.ikasan/ikasan-dashboard-jar

public void buttonClick(ClickEvent event) 
  {
    UI.getCurrent().removeWindow(ServerWindow.this);
  }
});

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final CustomFilterUIEvent custFUIEvent) {
  if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW
      || custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
    UI.getCurrent().access(this::populateTableData);
  } else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) {
    UI.getCurrent().access(this::onQuery);
  }
}

代码示例来源:origin: org.ikasan/ikasan-dashboard-jar

@Override
  public void onClick(PointClickEvent event) 
  {
    Module module = moduleMap.get(event.getCategory());
    VaadinSession.getCurrent().setAttribute("module", module);
    VaadinSession.getCurrent().setAttribute("tab", TopologyViewPanel.CATEGORISED_ERROR_TAB);
    UI.getCurrent().getNavigator().navigateTo("topologyView");
  }
});

代码示例来源:origin: eclipse/hawkbit

private static void addTypeStyle(final Long tagId, final String color) {
  final JavaScript javaScript = UI.getCurrent().getPage().getJavaScript();
  UI.getCurrent()
      .access(() -> javaScript.execute(
          HawkbitCommonUtil.getScriptSMHighlightWithColor(".v-table-row-distribution-upload-type-" + tagId
              + "{background-color:" + color + " !important;background-image:none !important }")));
}

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

protected Class<?> getAssociatedClass() {
  if (associatedClass == null) {
    UI current = UI.getCurrent();
    if (current instanceof LegacyWindow) {
      LegacyWindow legacyWindow = (LegacyWindow) current;
      return legacyWindow.getApplication().getClass();
    } else {
      return current.getClass();
    }
  }
  return associatedClass;
}

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

Page page = getPage();
URI oldLocation = page.getLocation();
int oldWidth = page.getBrowserWindowWidth();
int oldHeight = page.getBrowserWindowHeight();
page.init(request);
setLastHeartbeatTimestamp(System.currentTimeMillis());
refresh(request);
URI newLocation = page.getLocation();
Navigator navigator = getNavigator();
if (navigator != null) {
  navigator.navigateTo(navigator.getState());

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

try {
  session = service.findVaadinSession(vaadinRequest);
  assert VaadinSession.getCurrent() == session;
session.lock();
try {
  ui = service.findUI(vaadinRequest);
  assert UI.getCurrent() == ui;
  if (ui != null && ui.getPushConnection() != null) {
        .getPushConnection()).getResource();
} finally {
  try {
    session.unlock();
  } catch (Exception e) {
    getLogger().log(Level.WARNING,

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

VaadinRequest request) {
if (component == null) {
  component = UI.getCurrent();
  session = VaadinSession.getCurrent();
  Locale locale = session.getLocale();
  if (locale != null) {
    return locale;

代码示例来源:origin: viritin/viritin

private void updateVaadinLocale() {
  Locale locale = getLocale();
  UI.getCurrent().setLocale(locale);
  VaadinSession.getCurrent().setLocale(locale);
  recursiveSetLocale();
}

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

/**
 * Load and initialize the mobile drag-drop-polyfill if needed and not yet
 * done so.
 */
private void loadMobileHtml5DndPolyfill() {
  if (mobileHtml5DndPolyfillLoaded) {
    return;
  }
  if (!getPage().getWebBrowser().isTouchDevice()) {
    return;
  }
  mobileHtml5DndPolyfillLoaded = true;
  String vaadinLocation = getSession().getService().getStaticFileLocation(
      VaadinService.getCurrentRequest()) + "/VAADIN/";
  getPage().addDependency(new Dependency(Type.JAVASCRIPT,
      vaadinLocation + ApplicationConstants.MOBILE_DND_POLYFILL_JS));
  getRpcProxy(PageClientRpc.class).initializeMobileHtml5DndPolyfill();
}

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

/**
 * Shows a notification message.
 *
 * @see Notification
 * @see #showNotification(String)
 * @see #showNotification(String, int)
 * @see #showNotification(String, String)
 * @see #showNotification(String, String, int)
 *
 * @param notification
 *            The notification message to show
 *
 * @deprecated As of 7.0, use Notification.show instead
 */
@Deprecated
public void showNotification(Notification notification) {
  getPage().showNotification(notification);
}

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

VaadinSession session = ui.getSession();
VaadinService service = session.getService();
LegacyCommunicationManager manager = session.getCommunicationManager();
ClientCache clientCache = manager.getClientCache(ui);
boolean repaintAll = clientCache.isEmpty();
ConnectorTracker uiConnectorTracker = ui.getConnectorTracker();
getLogger().log(Level.FINE, "* Creating response to client");
      .getLastProcessedClientToServerId() + 1;
  writer.write("\"" + ApplicationConstants.CLIENT_TO_SERVER_ID
      + "\": " + nextClientToServerMessageId + ", ");
  SystemMessages messages = ui.getSession().getService()
      .getSystemMessages(ui.getLocale(), null);
  dependencies.addAll(ui.getPage().getPendingDependencies());
  dependencies.addAll(Dependency.findDependencies(newConnectorTypes,
      manager, new FilterContext(session)));

代码示例来源:origin: OpenNMS/opennms

@Override
  public void buttonClick(Button.ClickEvent clickEvent) {
    GraphSelectionWindow graphSelectionWindow = new GraphSelectionWindow(nodeDao, rrdGraphHelper, RrdGraphEntry.this);
    getUI().addWindow(graphSelectionWindow);
  }
});

相关文章