void longUri(String uri) { String relonged = CompressedURIHandler.longURI(CompressedURIHandler.shortURI(URIs.of(uri))).toString(); equals(uri, relonged); System.out.println( uri.length() + "v." + CompressedURIHandler.shortURI(URIs.of(uri)).toString().length()); }
public String shutdown() { String tip = "Shutdown DBBrowser"; Label text = Label.of("X"); URIObject target = URIs.of("exit"); URIObject image = Icons.OFF; return Link.textTargetImageAlt(text, target, image, tip).toString(); }
public String removeServer() { String tip = "Remove a database server"; Label text = Label.of("-"); URIObject target = URIs.of("remove"); URIObject image = Icons.MINUS; return Link.textTargetImageAlt(text, target, image, tip).toString(); }
public String addServer() { String tip = "Add a database server"; Label text = Label.of("+"); URIObject target = URIs.of("add"); URIObject image = Icons.PLUS; return Link.textTargetImageAlt(text, target, image, tip).toString(); }
/** Renders a DatabasePage to a HTML string. */ final class DatabasesPageRenderer implements ModelHtmlRenderer { final Log log = Logs.of(); private final NavigationButtons buttons; private static URIObject HELP = URIs.of("/resource/help/Databases.html"); private DatabasesPageRenderer() { buttons = NavigationButtons.of(); } public static DatabasesPageRenderer of() { return new DatabasesPageRenderer(); } @Override public UIElement render(Model model, ClientInfo client) { DatabasesPage page = (DatabasesPage) model; DBServer server = page.server; String title = "Available Databases on " + server.toString(); String guts = tableOfDatabases(page); String nav[] = new String[] { Replace.bracketQuote("Available Databases on <a href=[/]>server</a> ") + server, buttons.SEARCH }; return HtmlPage.gutsTitleNavHelp(guts, title, nav, HELP); } String tableOfDatabases(DatabasesPage page) { UITableBuilder out = UITableBuilder.of(); out.add(row(header("Database"), header("Tables"))); for (Database database : page.databases) { out.add( row( detail(database.linkTo().toString(), CSS.DATABASE), detail(tablesOn(page, database), CSS.TABLE))); } return out.build().toString(); } String tablesOn(DatabasesPage page, Database database) { StringBuilder out = new StringBuilder(); int i = 0; for (DBTable table : page.tables.get(database)) { out.append(table.linkTo() + " "); i++; if (i > 20) { out.append("..."); return out.toString(); } } return out.toString(); } }
public String logout() { return Link.textTarget(Label.of("logout"), URIs.of("logout")).toString(); }
@Test public void shortUriNotEndingWithSlash() { String uri = CompressedURIHandler.shortURI(URIs.of("/foo/bar")).toString(); assertFalse(uri.endsWith("/")); assertTrue(uri.startsWith("/z/")); }