Search in sources :

Example 1 with IBrowserFrame

use of org.loboevolution.component.IBrowserFrame in project LoboEvolution by LoboEvolution.

the class HtmlRendererContext method back.

/**
 * It should navigate back one page. This implementation does nothing and should
 * be overridden.
 */
public void back() {
    final IBrowserPanel bpanel = htmlPanel.getBrowserPanel();
    final ITabbedPane tabbedPane = bpanel.getTabbedPane();
    final IBrowserFrame browserFrame = bpanel.getBrowserFrame();
    final IToolBar toolbar = browserFrame.getToolbar();
    final JTextField addressBar = toolbar.getAddressBar();
    String url = addressBar.getText();
    tabbedPane.setComponentPopupMenu(bpanel);
    NavigationStore nh = new NavigationStore();
    final int indexPanel = tabbedPane.getSelectedIndex();
    List<BookmarkInfo> tabsById = nh.getRecentHost(indexPanel, true);
    for (int i = 0; i < tabsById.size(); i++) {
        BookmarkInfo info = tabsById.get(i);
        String tab = info.getUrl();
        if (tab.equals(url) && i > 0) {
            url = tabsById.get(i - 1).getUrl();
        }
    }
    final HtmlPanel hpanel = HtmlPanel.createHtmlPanel(bpanel, url);
    final HTMLDocumentImpl nodeImpl = (HTMLDocumentImpl) hpanel.getRootNode();
    final String title = Strings.isNotBlank(nodeImpl.getTitle()) ? nodeImpl.getTitle() : "New Tab";
    tabbedPane.remove(indexPanel);
    tabbedPane.insertTab(title, null, htmlPanel, title, indexPanel);
    browserFrame.getToolbar().getAddressBar().setText(url);
    bpanel.getScroll().getViewport().add((Component) tabbedPane);
    TabStore.deleteTab(indexPanel);
    TabStore.insertTab(indexPanel, url, title);
}
Also used : BookmarkInfo(org.loboevolution.info.BookmarkInfo) HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl) IBrowserFrame(org.loboevolution.component.IBrowserFrame) NavigationStore(org.loboevolution.store.NavigationStore) HtmlPanel(org.loboevolution.html.gui.HtmlPanel) IBrowserPanel(org.loboevolution.component.IBrowserPanel) ITabbedPane(org.loboevolution.component.ITabbedPane) IToolBar(org.loboevolution.component.IToolBar)

Example 2 with IBrowserFrame

use of org.loboevolution.component.IBrowserFrame in project LoboEvolution by LoboEvolution.

the class HtmlRendererContext method getCurrentURL.

/**
 * <p>getCurrentURL.</p>
 *
 * @return a {@link java.lang.String} object.
 */
public String getCurrentURL() {
    HtmlPanel html = htmlPanel;
    IBrowserPanel panel = html.getBrowserPanel();
    if (panel != null) {
        IBrowserFrame frame = panel.getBrowserFrame();
        IToolBar toolbar = frame.getToolbar();
        JTextField jtf = toolbar.getAddressBar();
        return jtf.getText();
    } else {
        return "";
    }
}
Also used : IBrowserFrame(org.loboevolution.component.IBrowserFrame) HtmlPanel(org.loboevolution.html.gui.HtmlPanel) IBrowserPanel(org.loboevolution.component.IBrowserPanel) IToolBar(org.loboevolution.component.IToolBar)

Example 3 with IBrowserFrame

use of org.loboevolution.component.IBrowserFrame in project LoboEvolution by LoboEvolution.

the class HtmlRendererContext method openImageViewer.

/**
 * <p>openImageViewer.</p>
 *
 * @param fullURL a {@link java.lang.String} object.
 * @param stream a {@link java.io.InputStream} object.
 */
public void openImageViewer(String fullURL, InputStream stream) {
    try {
        final IBrowserPanel bpanel = htmlPanel.getBrowserPanel();
        final ITabbedPane tabbedPane = bpanel.getTabbedPane();
        final IBrowserFrame browserFrame = bpanel.getBrowserFrame();
        final BufferedImage img = ImageIO.read(stream);
        final ImageViewer viewer = new ImageViewer(img);
        final String title = "Image Viewer";
        int index = TabStore.getTabs().size();
        JPanel jPanel = new JPanel();
        jPanel.add(viewer.getComponent());
        browserFrame.getToolbar().getAddressBar().setText(fullURL);
        tabbedPane.insertTab(title, null, viewer.getComponent(), title, index);
        bpanel.getScroll().getViewport().add((Component) tabbedPane);
    } catch (IOException e) {
        logger.log(Level.SEVERE, e.getMessage(), e);
    }
}
Also used : IBrowserFrame(org.loboevolution.component.IBrowserFrame) IBrowserPanel(org.loboevolution.component.IBrowserPanel) ITabbedPane(org.loboevolution.component.ITabbedPane) ImageViewer(org.loboevolution.img.ImageViewer) BufferedImage(java.awt.image.BufferedImage)

Example 4 with IBrowserFrame

use of org.loboevolution.component.IBrowserFrame in project LoboEvolution by LoboEvolution.

the class HtmlRendererContext method open.

/**
 * It should open a new browser window. This implementation does nothing and
 * should be overridden.
 *
 * @param url            The requested URL.
 * @param windowName     A window identifier.
 * @param windowFeatures WindowImpl features specified in a format equivalent to
 *                       that of window.open() in Javascript.
 * @param replace        Whether an existing window with the same name should be
 *                       replaced.
 * @return a {@link org.loboevolution.http.HtmlRendererContext} object.
 */
public HtmlRendererContext open(URL url, String windowName, String windowFeatures, boolean replace) {
    final IBrowserPanel bpanel = htmlPanel.getBrowserPanel();
    final ITabbedPane tabbedPane = bpanel.getTabbedPane();
    tabbedPane.setComponentPopupMenu(bpanel);
    int index = TabStore.getTabs().size();
    String fullURL = url.toString();
    final HtmlPanel hpanel = HtmlPanel.createHtmlPanel(bpanel, fullURL);
    final HTMLDocumentImpl nodeImpl = (HTMLDocumentImpl) hpanel.getRootNode();
    final String title = Strings.isNotBlank(nodeImpl.getTitle()) ? nodeImpl.getTitle() : "New Tab";
    tabbedPane.insertTab(title, null, hpanel, title, index);
    tabbedPane.setSelectedIndex(index);
    final IBrowserFrame browserFrame = bpanel.getBrowserFrame();
    browserFrame.getToolbar().getAddressBar().setText(fullURL);
    TabStore.insertTab(index, fullURL, title);
    LinkStore.insertLinkVisited(fullURL);
    bpanel.getScroll().getViewport().add((Component) tabbedPane);
    return nodeImpl.getHtmlRendererContext();
}
Also used : HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl) IBrowserFrame(org.loboevolution.component.IBrowserFrame) HtmlPanel(org.loboevolution.html.gui.HtmlPanel) IBrowserPanel(org.loboevolution.component.IBrowserPanel) ITabbedPane(org.loboevolution.component.ITabbedPane)

Example 5 with IBrowserFrame

use of org.loboevolution.component.IBrowserFrame in project LoboEvolution by LoboEvolution.

the class HtmlRendererContext method forward.

/**
 * <p>forward.</p>
 */
public void forward() {
    final IBrowserPanel bpanel = htmlPanel.getBrowserPanel();
    final ITabbedPane tabbedPane = bpanel.getTabbedPane();
    final IBrowserFrame browserFrame = bpanel.getBrowserFrame();
    final IToolBar toolbar = browserFrame.getToolbar();
    final JTextField addressBar = toolbar.getAddressBar();
    String url = addressBar.getText();
    tabbedPane.setComponentPopupMenu(bpanel);
    NavigationStore nh = new NavigationStore();
    final int indexPanel = tabbedPane.getSelectedIndex();
    List<BookmarkInfo> tabsById = nh.getRecentHost(indexPanel, true);
    for (int i = 0; i < tabsById.size(); i++) {
        BookmarkInfo info = tabsById.get(i);
        String tab = info.getUrl();
        if (tab.equals(url) && i < tabsById.size() - 1) {
            url = tabsById.get(i + 1).getUrl();
        }
    }
    final HtmlPanel hpanel = HtmlPanel.createHtmlPanel(bpanel, url);
    final HTMLDocumentImpl nodeImpl = (HTMLDocumentImpl) hpanel.getRootNode();
    final String title = Strings.isNotBlank(nodeImpl.getTitle()) ? nodeImpl.getTitle() : "New Tab";
    tabbedPane.remove(indexPanel);
    tabbedPane.insertTab(title, null, htmlPanel, title, indexPanel);
    browserFrame.getToolbar().getAddressBar().setText(url);
    bpanel.getScroll().getViewport().add((Component) tabbedPane);
    TabStore.deleteTab(indexPanel);
    TabStore.insertTab(indexPanel, url, title);
}
Also used : BookmarkInfo(org.loboevolution.info.BookmarkInfo) HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl) IBrowserFrame(org.loboevolution.component.IBrowserFrame) NavigationStore(org.loboevolution.store.NavigationStore) HtmlPanel(org.loboevolution.html.gui.HtmlPanel) IBrowserPanel(org.loboevolution.component.IBrowserPanel) ITabbedPane(org.loboevolution.component.ITabbedPane) IToolBar(org.loboevolution.component.IToolBar)

Aggregations

IBrowserFrame (org.loboevolution.component.IBrowserFrame)13 IBrowserPanel (org.loboevolution.component.IBrowserPanel)9 ITabbedPane (org.loboevolution.component.ITabbedPane)9 HtmlPanel (org.loboevolution.html.gui.HtmlPanel)7 HTMLDocumentImpl (org.loboevolution.html.dom.domimpl.HTMLDocumentImpl)6 IToolBar (org.loboevolution.component.IToolBar)3 BufferedImage (java.awt.image.BufferedImage)2 ImageViewer (org.loboevolution.img.ImageViewer)2 BookmarkInfo (org.loboevolution.info.BookmarkInfo)2 TabInfo (org.loboevolution.info.TabInfo)2 NavigationStore (org.loboevolution.store.NavigationStore)2 java.awt (java.awt)1 javax.swing (javax.swing)1 ChangeListener (javax.swing.event.ChangeListener)1 BufferExceededException (org.loboevolution.common.BufferExceededException)1 Strings (org.loboevolution.common.Strings)1 PDFViewer (org.loboevolution.pdf.PDFViewer)1 TabStore (org.loboevolution.store.TabStore)1 WelcomePanel (org.loboevolution.welcome.WelcomePanel)1 JhromeTabbedPaneUI (org.sexydock.tabs.jhrome.JhromeTabbedPaneUI)1