public static ExternalResource testRule = new ExternalResource(){ @Override protected void before() throws Throwable{
@Override public String format(Resource value) { // default behavior for HTTP, HTTPS, FTP and FTPS return ((ExternalResource) value).getURL(); }
@Override protected void createResource() { resource = new ExternalResource(url); ((ExternalResource) resource).setMIMEType(mimeType); }
@Override public void setMimeType(String mimeType) { this.mimeType = mimeType; if (resource != null) { ((ExternalResource) resource).setMIMEType(mimeType); } }
@Override public void setMimeType(String mimeType) { this.mimeType = mimeType; if (resource != null) { ((ExternalResource) resource).setMIMEType(mimeType); } }
public static class UsesExternalResource { Server myServer = new Server(); @Rule public ExternalResource resource = new ExternalResource() { @Override protected void before() throws Throwable { myServer.connect(); }; @Override protected void after() { myServer.disconnect(); }; }; @Test public void testFoo() { new Client().run(myServer); } }
/** * Gets the MIME type of the resource. * * @see com.vaadin.server.Resource#getMIMEType() */ @Override public String getMIMEType() { if (mimeType == null) { mimeType = FileTypeResolver.getMIMEType(getURL()); } return mimeType; }
/** * Creates a window opener that will open windows to the provided URL. * * @param url * the URL to open in the window */ public BrowserWindowOpener(String url) { this(new ExternalResource(url)); }
/** * Returns the URL for this BrowserWindowOpener instance. Returns * {@code null} if this instance is not URL resource based (a non URL based * resource has been set for it). * * @since 7.4 * * @return URL to open in the new browser window/tab when the extended * component is clicked */ public String getUrl() { Resource resource = getResource(); if (resource instanceof ExternalResource) { return ((ExternalResource) resource).getURL(); } return null; }
@Override public Resource parse(String value) { // default behavior for HTTP, HTTPS, FTP and FTPS return new ExternalResource(value); }
@Override public String getURL() { if (resource instanceof ExternalResource) { return ((ExternalResource) resource).getURL(); } else if (resource instanceof ConnectorResource) { ConnectorResource connectorResource = (ConnectorResource) resource;
/** * Creates a new open resource. * * @param url * The URL to open * @param name * The name of the target window * @param width * The width of the target window * @param height * The height of the target window * @param border * The border style of the target window * @param tryToOpenAsPopup * Should try to open as a pop-up */ private OpenResource(String url, String name, int width, int height, BorderStyle border, boolean tryToOpenAsPopup) { this(new ExternalResource(url), name, width, height, border, tryToOpenAsPopup); }
/** * Creates the button HTML for the given icon resource.<p> * * @param icon the icon * * @return the HTML */ static String getDropDownButtonHtml(ExternalResource icon) { return "<div tabindex=\"0\" role=\"button\" class=\"v-button v-widget borderless v-button-borderless " + OpenCmsTheme.TOOLBAR_BUTTON + " v-button-" + OpenCmsTheme.TOOLBAR_BUTTON + "\"><span class=\"v-button-wrap\"><img class=\"v-icon\" src=\"" + icon.getURL() + "\" /></span></div>"; }
/** * Sets the provided URL {@code url} for this instance. The {@code url} will * be opened in a new browser window/tab when the extended component is * clicked. * * @since 7.4 * * @param url * URL to open */ public void setUrl(String url) { setResource(new ExternalResource(url)); }
@Override public String getUrl() { Resource resource = component.getResource(); if (resource instanceof ExternalResource) return ((ExternalResource) resource).getURL(); return null; }
/** * Creates a window opener that will open windows containing the provided UI * using the provided path. * * @param uiClass * the UI class that should be opened when the extended component * is clicked * @param path * the path that the UI should be bound to */ public BrowserWindowOpener(Class<? extends UI> uiClass, String path) { // Create a Resource with a translated URL going to the VaadinService this(new ExternalResource( ApplicationConstants.APP_PROTOCOL_PREFIX + path), new BrowserWindowOpenerUIProvider(uiClass, path)); }
@Test public void getThumbnailResourceByPath() throws Exception { // GIVEN final Node contactNode = createMainImageNode("myNode", IMAGE_NODE_NAME, MediaType.GIF); final String imageNodeUuid = contactNode.getNode(IMAGE_NODE_NAME).getIdentifier(); final JcrNodeAdapter nodeAdapter = new JcrNodeAdapter(contactNode); Object itemId = JcrItemUtil.getItemId(contactNode); doReturn(nodeAdapter).when(contentConnector).getItem(itemId); // WHEN Object resource = imageProvider.getThumbnailResource(itemId, ImageProvider.THUMBNAIL_GENERATOR); // THEN assertNotNull(resource); assertTrue(resource instanceof ExternalResource); assertEquals("/foo/.imaging/thumbnail/test/" + imageNodeUuid + "/MaxMustermann.jpg", ((ExternalResource) resource).getURL()); }
@ClassRule public static ExternalResource resource = new ExternalResource() { @Override protected void before() throws Throwable { myServer.connect(); } @Override protected void after() { myServer.disconnect(); } };
String imageLink = ""; if (icon instanceof ExternalResource) { imageLink = ((ExternalResource)icon).getURL();
@Rule ExternalResource myRule = new ExternalResource() { public void after() { test.postExecution(); } }