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);
}
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 "";
}
}
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);
}
}
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();
}
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);
}
Aggregations