Search in sources :

Example 1 with BookmarkInfo

use of org.loboevolution.info.BookmarkInfo in project LoboEvolution by LoboEvolution.

the class BookmarksStore method getBookmarks.

/**
 * Gets the bookmarks
 *
 * @return bookmarks
 * @param num a {@link java.lang.Integer} object.
 */
public List<BookmarkInfo> getBookmarks(Integer num) {
    synchronized (this) {
        final List<BookmarkInfo> values = new ArrayList<>();
        if (DatabseSQLite.storeExist()) {
            String query = "SELECT name, description, baseUrl, tags FROM BOOKMARKS";
            if (num != null) {
                query = query + " LIMIT " + num;
            }
            try (Connection conn = DriverManager.getConnection(DB_PATH);
                Statement stmt = conn.createStatement();
                ResultSet rs = stmt.executeQuery(query)) {
                while (rs != null && rs.next()) {
                    final BookmarkInfo info = new BookmarkInfo();
                    info.setTitle(rs.getString(1));
                    info.setDescription(rs.getString(2));
                    info.setUrl(rs.getString(3));
                    info.setTags(Strings.splitUsingTokenizer(rs.getString(4), " "));
                    values.add(info);
                }
            } catch (final Exception e) {
                logger.log(Level.SEVERE, e.getMessage(), e);
            }
        }
        return values;
    }
}
Also used : BookmarkInfo(org.loboevolution.info.BookmarkInfo) ArrayList(java.util.ArrayList)

Example 2 with BookmarkInfo

use of org.loboevolution.info.BookmarkInfo in project LoboEvolution by LoboEvolution.

the class InputStore method getPassword.

/**
 * <p>getPassword.</p>
 *
 * @param maxNumItems a int.
 * @return a {@link java.util.List} object.
 */
public List<BookmarkInfo> getPassword(int maxNumItems) {
    List<BookmarkInfo> autoList = new ArrayList<>();
    try (Connection conn = DriverManager.getConnection(DB_PATH);
        PreparedStatement pstmt = conn.prepareStatement(SQLiteCommon.INPUT_LIMIT)) {
        pstmt.setInt(1, maxNumItems);
        try (ResultSet rs = pstmt.executeQuery()) {
            while (rs != null && rs.next()) {
                BookmarkInfo info = new BookmarkInfo();
                info.setDescription(rs.getString(1));
                info.setTitle(rs.getString(2));
                info.setUrl(rs.getString(3));
                autoList.add(info);
            }
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE, e.getMessage(), e);
    }
    return autoList;
}
Also used : BookmarkInfo(org.loboevolution.info.BookmarkInfo) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 3 with BookmarkInfo

use of org.loboevolution.info.BookmarkInfo in project LoboEvolution by LoboEvolution.

the class NavigationStore method getRecentHost.

/**
 * <p>getRecentHost.</p>
 *
 * @param index a int.
 * @param isTab a boolean.
 * @return a {@link java.util.List} object.
 */
public List<BookmarkInfo> getRecentHost(int index, boolean isTab) {
    final List<BookmarkInfo> recentHostEntries = new ArrayList<>();
    try (Connection conn = DriverManager.getConnection(DB_PATH);
        PreparedStatement pstmt = conn.prepareStatement(isTab ? HOST_TAB : HOST)) {
        pstmt.setInt(1, index);
        try (ResultSet rs = pstmt.executeQuery()) {
            while (rs != null && rs.next()) {
                BookmarkInfo info = new BookmarkInfo();
                info.setUrl(rs.getString(1));
                info.setTitle(rs.getString(2));
                recentHostEntries.add(info);
            }
        }
    } catch (final Exception e) {
        logger.log(Level.SEVERE, e.getMessage(), e);
    }
    return recentHostEntries;
}
Also used : BookmarkInfo(org.loboevolution.info.BookmarkInfo) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 4 with BookmarkInfo

use of org.loboevolution.info.BookmarkInfo in project LoboEvolution by LoboEvolution.

the class ToolBar method init.

private void init(BrowserPanel panel) {
    setLayout(new BorderLayout());
    setBorderPainted(true);
    setOpaque(true);
    setEnabled(false);
    setFloatable(false);
    this.addressBar = new JTextField() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void paintComponent(Graphics g) {
            if (!isOpaque() && getBorder() instanceof RoundedCornerBorder) {
                final Graphics2D g2 = (Graphics2D) g.create();
                g2.setColor(Color.LIGHT_GRAY);
                g2.fill(((RoundedCornerBorder) getBorder()).getBorderShape(0, 0, getWidth() - 1, getHeight() - 1));
                g2.dispose();
            }
            super.paintComponent(g);
        }

        @Override
        public void updateUI() {
            super.updateUI();
            setOpaque(false);
            setBorder(new RoundedCornerBorder());
        }
    };
    BookmarksStore book = new BookmarksStore();
    List<BookmarkInfo> bookmarks = book.getBookmarks(100);
    List<String> hosts = new ArrayList<>();
    bookmarks.forEach(bookmark -> hosts.add(bookmark.getUrl()));
    Autocomplete.setupAutoComplete(addressBar, hosts);
    addressBar.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                GoAction go = new GoAction(panel, addressBar);
                go.actionPerformed(null);
            }
        }
    });
    final ClassLoader classLoader = getClass().getClassLoader();
    ImageIcon icon = new ImageIcon(classLoader.getResource("org/lobo/image/back.png"));
    final JButton back = new JButton();
    back.setIcon(new ImageIcon(icon.getImage().getScaledInstance(30, 30, Image.SCALE_SMOOTH)));
    back.setToolTipText("Back");
    back.setBorder(BorderFactory.createEmptyBorder());
    back.addActionListener(new BackAction(panel, this.addressBar));
    icon = new ImageIcon(classLoader.getResource("org/lobo/image/forward.png"));
    final JButton forward = new JButton();
    forward.setIcon(new ImageIcon(icon.getImage().getScaledInstance(30, 30, Image.SCALE_SMOOTH)));
    forward.setToolTipText("Forward");
    forward.setBorder(BorderFactory.createEmptyBorder());
    forward.addActionListener(new ForwardAction(panel, this.addressBar));
    icon = new ImageIcon(classLoader.getResource("org/lobo/image/reload.png"));
    final JButton refresh = new JButton();
    refresh.setIcon(new ImageIcon(icon.getImage().getScaledInstance(30, 30, Image.SCALE_SMOOTH)));
    refresh.setToolTipText("Refresh");
    refresh.setBorder(BorderFactory.createEmptyBorder());
    refresh.addActionListener(new GoAction(panel, this.addressBar));
    this.addressBar.setEditable(true);
    this.addressBar.setBackground(Color.LIGHT_GRAY);
    icon = new ImageIcon(classLoader.getResource("org/lobo/image/go.png"));
    final JButton go = new JButton();
    go.setIcon(new ImageIcon(icon.getImage().getScaledInstance(30, 30, Image.SCALE_SMOOTH)));
    go.setToolTipText("Go");
    go.setBorder(BorderFactory.createEmptyBorder());
    go.addActionListener(new GoAction(panel, this.addressBar));
    icon = new ImageIcon(classLoader.getResource("org/lobo/image/home.png"));
    final JButton home = new JButton();
    home.setIcon(new ImageIcon(icon.getImage().getScaledInstance(30, 30, Image.SCALE_SMOOTH)));
    home.setToolTipText("Home");
    home.setBorder(BorderFactory.createEmptyBorder());
    home.addActionListener(new HomeAction(panel));
    final JPanel panel1 = new JPanel();
    panel1.setLayout(new BorderLayout());
    panel1.add(back, BorderLayout.WEST);
    panel1.add(forward, BorderLayout.CENTER);
    panel1.add(refresh, BorderLayout.EAST);
    final JPanel panel2 = new JPanel();
    panel2.setLayout(new BorderLayout());
    panel2.add(go, BorderLayout.WEST);
    panel2.add(home, BorderLayout.EAST);
    add(panel1, BorderLayout.WEST);
    add(this.addressBar, BorderLayout.CENTER);
    add(panel2, BorderLayout.EAST);
}
Also used : ImageIcon(javax.swing.ImageIcon) JPanel(javax.swing.JPanel) KeyAdapter(java.awt.event.KeyAdapter) ArrayList(java.util.ArrayList) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) Graphics2D(java.awt.Graphics2D) Graphics(java.awt.Graphics) BookmarksStore(org.loboevolution.store.BookmarksStore) BookmarkInfo(org.loboevolution.info.BookmarkInfo) KeyEvent(java.awt.event.KeyEvent) BorderLayout(java.awt.BorderLayout)

Example 5 with BookmarkInfo

use of org.loboevolution.info.BookmarkInfo in project LoboEvolution by LoboEvolution.

the class AddBookmarkWindow method getinfo.

private BookmarkInfo getinfo() {
    final BookmarkInfo binfo = new BookmarkInfo();
    binfo.setUrl(getUrlField().getText());
    binfo.setTitle(getTitleField().getText());
    binfo.setDescription(getDescriptionField().getText());
    binfo.setTags(Strings.split(getTagsField().getText()));
    return binfo;
}
Also used : BookmarkInfo(org.loboevolution.info.BookmarkInfo)

Aggregations

BookmarkInfo (org.loboevolution.info.BookmarkInfo)21 ArrayList (java.util.ArrayList)8 NavigationStore (org.loboevolution.store.NavigationStore)7 HTMLDocumentImpl (org.loboevolution.html.dom.domimpl.HTMLDocumentImpl)6 HtmlPanel (org.loboevolution.html.gui.HtmlPanel)6 Connection (java.sql.Connection)5 PreparedStatement (java.sql.PreparedStatement)5 ResultSet (java.sql.ResultSet)5 ITabbedPane (org.loboevolution.component.ITabbedPane)4 BookmarksStore (org.loboevolution.store.BookmarksStore)4 LoboButton (com.jtattoo.plaf.lobo.LoboButton)3 LoboPanel (com.jtattoo.plaf.lobo.LoboPanel)3 LoboTextField (com.jtattoo.plaf.lobo.LoboTextField)3 Dimension (java.awt.Dimension)3 Font (java.awt.Font)3 BrowserPanel (org.loboevolution.component.BrowserPanel)2 IBrowserFrame (org.loboevolution.component.IBrowserFrame)2 IBrowserPanel (org.loboevolution.component.IBrowserPanel)2 IToolBar (org.loboevolution.component.IToolBar)2 LoboSeparator (com.jtattoo.plaf.lobo.LoboSeparator)1