/* * (non-Javadoc) * * @see org.lobobrowser.ua.NavigatorWindowListener#documentAccessed(org. * lobobrowser .ua.NavigatorWindowEvent) */ @Override public void documentAccessed(NavigatorWindowEvent event) { URL url = event.getUrl(); if ("GET".equals(event.getMethod()) && isHistoryRequest(event.getRequestType())) { NavigationHistory.getInstance().addAsRecent(url, null); } }
/** * Gets the chronology menu. * * @return the chronology menu */ public JMenu getChronologyMenu() { JMenu menu = new JMenu("Recent Hosts"); menu.removeAll(); Collection<HostEntry> hostEntries = NavigationHistory.getInstance().getRecentHostEntries(PREFERRED_MAX_MENU_SIZE); for (HostEntry entry : hostEntries) { String urlText = "http://" + entry.getHost(); try { URL url = new URL(urlText); long elapsed = System.currentTimeMillis() - entry.getTimestamp(); String menuText = entry.getHost() + " (" + Timing.getElapsedText(elapsed) + " ago)"; Action action = this.actionPool.createNavigateAction(url); JMenuItem menuItem = menuItem(menuText, action); menuItem.setToolTipText(url.toExternalForm()); menu.add(menuItem); } catch (MalformedURLException mfu) { logger.log(Level.WARNING, "populateRecentHosts(): Bad URL=" + urlText, mfu); } } menu.addSeparator(); menu.add(menuItem("Show All Recent Hosts", new ShowRecentHostsAction(this, window))); return menu; }
/** * Checks for recent entries. * * @return true, if successful */ public boolean hasRecentEntries() { return NavigationHistory.getInstance().hasRecentEntries(); }
/** * Gets the recent locations. * * @param max the max * @return the recent locations */ public Collection<String> getRecentLocations(int max) { return NavigationHistory.getInstance().getRecentItems(max); }
/** * Gets the potential matches. * * @param urlPrefix the url prefix * @param max the max * @return the potential matches */ public Collection<String> getPotentialMatches(String urlPrefix) { return NavigationHistory.getInstance().getHeadMatchItems(urlPrefix); }