Search in sources :

Example 1 with HtmlPanel

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());
}
Also used : HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl) HtmlPanel(org.loboevolution.html.gui.HtmlPanel)

Example 2 with HtmlPanel

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);
}
Also used : HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl) HtmlPanel(org.loboevolution.html.gui.HtmlPanel)

Example 3 with HtmlPanel

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;
}
Also used : HtmlRendererContext(org.loboevolution.http.HtmlRendererContext) HtmlPanel(org.loboevolution.html.gui.HtmlPanel) AbstractCSSProperties(org.loboevolution.html.style.AbstractCSSProperties)

Example 4 with HtmlPanel

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);
}
Also used : HtmlPanel(org.loboevolution.html.gui.HtmlPanel) Dimension(java.awt.Dimension) URL(java.net.URL)

Example 5 with HtmlPanel

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;
}
Also used : HtmlPanel(org.loboevolution.html.gui.HtmlPanel) LoboCheckBox(com.jtattoo.plaf.lobo.LoboCheckBox) StyleStore(org.loboevolution.store.StyleStore) LoboPanel(com.jtattoo.plaf.lobo.LoboPanel) ArrayList(java.util.ArrayList) NavigationManager(org.loboevolution.http.NavigationManager) java.awt(java.awt) ITabbedPane(org.loboevolution.component.ITabbedPane) List(java.util.List) Strings(org.loboevolution.common.Strings) HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl) BrowserFrame(org.loboevolution.component.BrowserFrame) IBrowserPanel(org.loboevolution.component.IBrowserPanel) ChangeListener(javax.swing.event.ChangeListener) javax.swing(javax.swing) HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl) StyleStore(org.loboevolution.store.StyleStore) LoboCheckBox(com.jtattoo.plaf.lobo.LoboCheckBox) HtmlPanel(org.loboevolution.html.gui.HtmlPanel) IBrowserPanel(org.loboevolution.component.IBrowserPanel) ITabbedPane(org.loboevolution.component.ITabbedPane) ChangeListener(javax.swing.event.ChangeListener)

Aggregations

HtmlPanel (org.loboevolution.html.gui.HtmlPanel)32 HTMLDocumentImpl (org.loboevolution.html.dom.domimpl.HTMLDocumentImpl)20 HtmlRendererContext (org.loboevolution.http.HtmlRendererContext)12 ITabbedPane (org.loboevolution.component.ITabbedPane)11 IBrowserFrame (org.loboevolution.component.IBrowserFrame)7 URL (java.net.URL)6 IBrowserPanel (org.loboevolution.component.IBrowserPanel)6 BookmarkInfo (org.loboevolution.info.BookmarkInfo)6 TimingInfo (org.loboevolution.info.TimingInfo)6 NavigationStore (org.loboevolution.store.NavigationStore)5 BrowserPanel (org.loboevolution.component.BrowserPanel)4 UserAgentContext (org.loboevolution.http.UserAgentContext)4 LoboPanel (com.jtattoo.plaf.lobo.LoboPanel)3 Dimension (java.awt.Dimension)3 InputStreamReader (java.io.InputStreamReader)3 IToolBar (org.loboevolution.component.IToolBar)3 LoboButton (com.jtattoo.plaf.lobo.LoboButton)2 LoboTextField (com.jtattoo.plaf.lobo.LoboTextField)2 Font (java.awt.Font)2 Image (java.awt.Image)2