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