use of org.loboevolution.html.gui.HtmlPanel in project LoboEvolution by LoboEvolution.
the class GoAction method goURL.
private void goURL(String text, HttpURLConnection httpcon) {
final ITabbedPane tabbedPane = panel.getTabbedPane();
tabbedPane.setComponentPopupMenu(this.panel);
final int indexPanel = tabbedPane.getSelectedIndex();
HtmlPanel htmlPanel;
if (httpcon == null) {
htmlPanel = HtmlPanel.createHtmlPanel(panel, text);
} else {
htmlPanel = HtmlPanel.createHtmlPanel(panel, text, httpcon);
}
final HTMLDocumentImpl nodeImpl = (HTMLDocumentImpl) htmlPanel.getRootNode();
final String title = Strings.isNotBlank(nodeImpl.getTitle()) ? nodeImpl.getTitle() : "New Tab";
tabbedPane.remove(indexPanel);
tabbedPane.insertTab(title, null, htmlPanel, title, indexPanel);
this.addressBar.setText(text);
panel.getScroll().getViewport().add((Component) tabbedPane);
TabStore.deleteTab(indexPanel);
TabStore.insertTab(indexPanel, text, title);
NavigationManager.insertHistory(text, title, indexPanel);
addressBar.removeAll();
Autocomplete.setupAutoComplete(addressBar, TabStore.getUrls());
}
use of org.loboevolution.html.gui.HtmlPanel in project LoboEvolution by LoboEvolution.
the class DragDropListener method openFileDrop.
private void openFileDrop(String fullURL) {
fullURL = fullURL.replace("\\", "/");
final ITabbedPane tabbedPane = bpanel.getTabbedPane();
tabbedPane.setComponentPopupMenu(bpanel);
int index = TabStore.getTabs().size();
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 + 1);
tabbedPane.setSelectedIndex(index + 1);
final IBrowserFrame browserFrame = bpanel.getBrowserFrame();
IBrowserPanel panel = browserFrame.getPanel();
IWelcomePanel welcome = panel.getWelcome();
browserFrame.getToolbar().getAddressBar().setText(fullURL);
TabStore.insertTab(index + 1, fullURL, title);
welcome.setBackground(new Color(37, 51, 61));
bpanel.getScroll().getViewport().add((Component) tabbedPane);
}
use of org.loboevolution.html.gui.HtmlPanel in project LoboEvolution by LoboEvolution.
the class ElementImpl method calculateWidth.
protected int calculateWidth(boolean border, boolean padding) {
final HTMLDocumentImpl doc = (HTMLDocumentImpl) this.document;
final HtmlRendererContext htmlRendererContext = doc.getHtmlRendererContext();
final HtmlPanel htmlPanel = htmlRendererContext.getHtmlPanel();
final Dimension preferredSize = htmlPanel.getPreferredSize();
final AbstractCSSProperties currentStyle = ((HTMLElementImpl) this).getCurrentStyle();
String width = currentStyle.getWidth();
String paddingRight = currentStyle.getPaddingRight();
String paddingLeft = currentStyle.getPaddingLeft();
String borderLeftWidth = currentStyle.getBorderLeftWidth();
String borderRightWidth = currentStyle.getBorderRightWidth();
String boxSizing = currentStyle.getBoxSizing();
int sizeWidth = preferredSize.width;
if (this instanceof HTMLBodyElementImpl) {
width = String.valueOf(doc.getDefaultView().getInnerWidth());
}
final Node nodeObj = getParentNode();
if (nodeObj instanceof HTMLElementImpl) {
HTMLElementImpl elem = (HTMLElementImpl) nodeObj;
if (elem.getClientHeight() != -1) {
sizeWidth = elem.getClientWidth();
}
}
if (Strings.isBlank(width) || "auto".equalsIgnoreCase(width)) {
width = "100%";
}
int widthSize = HtmlValues.getPixelSize(width, null, doc.getDefaultView(), -1, sizeWidth);
if ("border-box".equals(boxSizing)) {
padding = false;
border = false;
}
if (padding) {
widthSize += HtmlValues.getPixelSize(paddingRight, null, doc.getDefaultView(), 0);
widthSize += HtmlValues.getPixelSize(paddingLeft, null, doc.getDefaultView(), 0);
}
if (border) {
widthSize += HtmlValues.getPixelSize(borderRightWidth, null, doc.getDefaultView(), 0);
widthSize += HtmlValues.getPixelSize(borderLeftWidth, null, doc.getDefaultView(), 0);
}
return widthSize;
}
use of org.loboevolution.html.gui.HtmlPanel in project LoboEvolution by LoboEvolution.
the class HTMLImageElementImpl method draw.
/**
* <p>draw.</p>
*
* @param imgSvgControl a {@link org.loboevolution.html.control.ImgSvgControl} object.
*/
public void draw(ImgSvgControl imgSvgControl) {
final Object document = this.document;
String uri = null;
if (document instanceof HTMLDocumentImpl) {
try {
HTMLDocumentImpl doc = (HTMLDocumentImpl) document;
URL baseURL = new URL(doc.getBaseURI());
String src = getSrc();
URL scriptURL = Urls.createURL(baseURL, src);
uri = scriptURL == null ? src : scriptURL.toExternalForm();
} catch (Exception e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
} else {
uri = getSrc();
}
final HtmlPanel hpanel = HtmlPanel.createHtmlPanel(null, uri);
final Dimension dim = hpanel.getPreferredSize();
final double height = getHeight() == -1 ? dim.getHeight() : getHeight();
final double width = getWidth() == -1 ? dim.getWidth() : getWidth();
hpanel.setPreferredSize(new Dimension((int) width, (int) height));
imgSvgControl.add(hpanel);
}
use of org.loboevolution.html.gui.HtmlPanel in project LoboEvolution by LoboEvolution.
the class StyleWindow method getCheckBox.
private Component getCheckBox(BrowserFrame frame, String name) {
LoboCheckBox checkbox = new LoboCheckBox(name);
checkbox.setActionCommand(name);
checkbox.setToolTipText("Open current site with style " + name);
ChangeListener changeListener = changeEvent -> {
AbstractButton abstractButton = (AbstractButton) changeEvent.getSource();
ButtonModel buttonModel = abstractButton.getModel();
if (buttonModel.isPressed() && buttonModel.isSelected()) {
String fullURL = frame.getToolbar().getAddressBar().getText();
StyleStore style = new StyleStore();
style.selectStyle(buttonModel.getActionCommand());
final IBrowserPanel panel = frame.getPanel();
final ITabbedPane tabbedPane = panel.getTabbedPane();
tabbedPane.setComponentPopupMenu(panel);
final int indexPanel = tabbedPane.getSelectedIndex();
HtmlPanel htmlPanel = HtmlPanel.createHtmlPanel(panel, fullURL);
final HTMLDocumentImpl nodeImpl = (HTMLDocumentImpl) htmlPanel.getRootNode();
final String title = Strings.isNotBlank(nodeImpl.getTitle()) ? nodeImpl.getTitle() : "New Tab";
tabbedPane.remove(indexPanel);
tabbedPane.insertTab(title, null, htmlPanel, title, indexPanel);
NavigationManager.insertHistory(fullURL, title, indexPanel);
panel.getScroll().getViewport().add((Component) tabbedPane);
dispose();
setVisible(false);
}
};
checkbox.addChangeListener(changeListener);
return checkbox;
}
Aggregations