/** * Get given <code>view</code> content: if View is a {@link ViewContentProvider}, than * {@link ViewContentProvider#getViewContent()} is returned, else if view is a {@link Component}, view instance * itself is returned. Otherwise, a {@link IllegalArgumentException} is thrown. * @param view View for which retrieve the content * @return View content as {@link Component} * @throws IllegalArgumentException if view instance is not a {@link ViewContentProvider} nor a {@link Component} */ public static Component getViewContent(View view) throws IllegalArgumentException { if (view != null) { if (view instanceof ViewContentProvider) { try { // view delegates content providing to ViewContentProvider return ((ViewContentProvider) view).getViewContent(); } catch (Exception e) { throw new ViewConfigurationException( "Failed to obtain View content of View [" + view.getClass().getName() + "]", e); } } else if (view instanceof Component) { // view is a Component itself return (Component) view; } else { throw new IllegalArgumentException( "Invalid View " + view.getClass().getName() + ": View instance must be a " + Component.class.getName() + " or a " + ViewContentProvider.class.getName()); } } return null; }