mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
improve search results
This commit is contained in:
+2
-1
@@ -199,7 +199,8 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
getResultsScrollPane().showNoMatches();
|
getResultsScrollPane().showNoMatches();
|
||||||
count++;
|
count++;
|
||||||
}
|
} else
|
||||||
|
getResultsScrollPane().finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-9
@@ -2,6 +2,7 @@ package org.diylc.swing.plugins.cloud.view.browser;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
|
import java.awt.Dimension;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
@@ -23,6 +24,7 @@ import javax.swing.JLabel;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JSeparator;
|
import javax.swing.JSeparator;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
@@ -76,19 +78,25 @@ public class ResultsScrollPanel extends JScrollPane {
|
|||||||
getResultsPanel().add(label, gbc);
|
getResultsPanel().add(label, gbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addProjectToDisplay(final ProjectEntity project, int location) {
|
public void addProjectToDisplay(final ProjectEntity project, int location) {
|
||||||
JLabel thumbnailLabel = new JLabel(loadImage(project.getThumbnailUrl()));
|
JLabel thumbnailLabel = new JLabel(loadImage(project.getThumbnailUrl()));
|
||||||
JLabel nameLabel = new JLabel("<html><b>" + project.getName() + "</b></html>");
|
JLabel nameLabel = new JLabel("<html><b>" + project.getName() + "</b></html>");
|
||||||
nameLabel.setFont(nameLabel.getFont().deriveFont(12f));
|
nameLabel.setFont(nameLabel.getFont().deriveFont(12f));
|
||||||
JLabel descriptionLabel = new JLabel("<html>" + project.getDescription() + "</html>");
|
JTextArea descriptionArea = new JTextArea(project.getDescription().replace("<br>", "\n"));
|
||||||
|
descriptionArea.setEditable(false);
|
||||||
|
descriptionArea.setFont(thumbnailLabel.getFont());
|
||||||
|
descriptionArea.setLineWrap(true);
|
||||||
|
descriptionArea.setWrapStyleWord(true);
|
||||||
|
// JLabel descriptionLabel = new JLabel("<html>" + project.getDescription() + "</html>");
|
||||||
|
// JScrollPane descriptionScroll = new JScrollPane(descriptionArea);
|
||||||
|
// descriptionScroll.setBorder(null);
|
||||||
|
// descriptionLabel.setMaximumSize(new Dimension(200, 100));
|
||||||
JLabel categoryLabel = new JLabel("<html>Category: <b>" + project.getCategory() + "</b></html>");
|
JLabel categoryLabel = new JLabel("<html>Category: <b>" + project.getCategory() + "</b></html>");
|
||||||
JLabel authorLabel = new JLabel("<html>Author: <b>" + project.getOwner() + "</b></html>");
|
JLabel authorLabel = new JLabel("<html>Author: <b>" + project.getOwner() + "</b></html>");
|
||||||
JLabel updatedLabel = new JLabel("<html>Last updated: <b>" + project.getUpdated() + "</b></html>");
|
JLabel updatedLabel = new JLabel("<html>Last updated: <b>" + project.getUpdated() + "</b></html>");
|
||||||
JButton downloadButton = new JButton(IconLoader.CloudDownload.getIcon());
|
JButton downloadButton = new JButton(IconLoader.CloudDownload.getIcon());
|
||||||
|
|
||||||
downloadButton.setBorderPainted(false);
|
downloadButton.setBorderPainted(false);
|
||||||
// downloadButton.setFocusPainted(false);
|
|
||||||
downloadButton.setContentAreaFilled(false);
|
downloadButton.setContentAreaFilled(false);
|
||||||
downloadButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
downloadButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
downloadButton.addActionListener(new ActionListener() {
|
downloadButton.addActionListener(new ActionListener() {
|
||||||
@@ -168,21 +176,21 @@ public class ResultsScrollPanel extends JScrollPane {
|
|||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
gbc.insets = new Insets(2, 6, 2, 2);
|
gbc.insets = new Insets(2, 6, 2, 2);
|
||||||
getResultsPanel().add(nameLabel, gbc);
|
getResultsPanel().add(nameLabel, gbc);
|
||||||
//
|
|
||||||
// gbc.gridx = 2;
|
|
||||||
// gbc.anchor = GridBagConstraints.NORTHEAST;
|
|
||||||
// gbc.insets = new Insets(2, 2, 2, 8);
|
|
||||||
// getResultsPanel().add(authorLabel, gbc);
|
|
||||||
|
|
||||||
gbc.gridy++;
|
gbc.gridy++;
|
||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
gbc.weighty = 1;
|
gbc.weighty = 1;
|
||||||
|
gbc.weightx = 1;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
gbc.anchor = GridBagConstraints.NORTHWEST;
|
gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||||
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
gbc.insets = new Insets(2, 6, 2, 2);
|
gbc.insets = new Insets(2, 6, 2, 2);
|
||||||
getResultsPanel().add(descriptionLabel, gbc);
|
getResultsPanel().add(descriptionArea, gbc);
|
||||||
|
|
||||||
gbc.gridy++;
|
gbc.gridy++;
|
||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
gbc.fill = GridBagConstraints.NONE;
|
||||||
gbc.weighty = 0;
|
gbc.weighty = 0;
|
||||||
getResultsPanel().add(categoryLabel, gbc);
|
getResultsPanel().add(categoryLabel, gbc);
|
||||||
|
|
||||||
@@ -209,6 +217,21 @@ public class ResultsScrollPanel extends JScrollPane {
|
|||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
gbc.insets = new Insets(2, 2, 2, 2);
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
getResultsPanel().add(new JSeparator(), gbc);
|
getResultsPanel().add(new JSeparator(), gbc);
|
||||||
|
|
||||||
|
this.lastGridY = gbc.gridy;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int lastGridY;
|
||||||
|
|
||||||
|
public void finish() {
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = lastGridY;
|
||||||
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc.weightx = 0;
|
||||||
|
gbc.weighty = 100;
|
||||||
|
getResultsPanel().add(new JLabel(), gbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private JPanel getResultsPanel() {
|
private JPanel getResultsPanel() {
|
||||||
|
|||||||
Reference in New Issue
Block a user