mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
view/download/comment count
This commit is contained in:
@@ -94,7 +94,6 @@ public interface IServiceAPI {
|
|||||||
*
|
*
|
||||||
* @param criteria
|
* @param criteria
|
||||||
* @param category
|
* @param category
|
||||||
* @param format
|
|
||||||
* @param page
|
* @param page
|
||||||
* @param itemsPerPage
|
* @param itemsPerPage
|
||||||
* @param sort
|
* @param sort
|
||||||
@@ -102,8 +101,7 @@ public interface IServiceAPI {
|
|||||||
* objects.
|
* objects.
|
||||||
*/
|
*/
|
||||||
Object search(@ParamName("criteria") String criteria, @ParamName("category") String category,
|
Object search(@ParamName("criteria") String criteria, @ParamName("category") String category,
|
||||||
@ParamName("format") String format, @ParamName("page") Integer page,
|
@ParamName("page") Integer page, @ParamName("itemsPerPage") Integer itemsPerPage, @ParamName("sort") String sort);
|
||||||
@ParamName("itemsPerPage") Integer itemsPerPage, @ParamName("sort") String sort);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uploads a project using token to authenticate.
|
* Uploads a project using token to authenticate.
|
||||||
|
|||||||
@@ -16,26 +16,12 @@ public class ProjectEntity implements Serializable {
|
|||||||
private String downloadUrl;
|
private String downloadUrl;
|
||||||
private int viewCount;
|
private int viewCount;
|
||||||
private int downloadCount;
|
private int downloadCount;
|
||||||
|
private int commentCount;
|
||||||
|
|
||||||
public ProjectEntity() {
|
public ProjectEntity() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProjectEntity(int id, String name, String description, String owner, String category, String updated,
|
|
||||||
String thumbnailUrl, String downloadUrl, int viewCount, int downloadCount) {
|
|
||||||
super();
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
this.description = description;
|
|
||||||
this.owner = owner;
|
|
||||||
this.category = category;
|
|
||||||
this.updated = updated;
|
|
||||||
this.thumbnailUrl = thumbnailUrl;
|
|
||||||
this.downloadUrl = downloadUrl;
|
|
||||||
this.viewCount = viewCount;
|
|
||||||
this.downloadCount = downloadCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -116,11 +102,20 @@ public class ProjectEntity implements Serializable {
|
|||||||
this.downloadCount = downloadCount;
|
this.downloadCount = downloadCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCommentCount() {
|
||||||
|
return commentCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommentCount(int commentCount) {
|
||||||
|
this.commentCount = commentCount;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((category == null) ? 0 : category.hashCode());
|
result = prime * result + ((category == null) ? 0 : category.hashCode());
|
||||||
|
result = prime * result + commentCount;
|
||||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||||
result = prime * result + downloadCount;
|
result = prime * result + downloadCount;
|
||||||
result = prime * result + ((downloadUrl == null) ? 0 : downloadUrl.hashCode());
|
result = prime * result + ((downloadUrl == null) ? 0 : downloadUrl.hashCode());
|
||||||
@@ -147,6 +142,8 @@ public class ProjectEntity implements Serializable {
|
|||||||
return false;
|
return false;
|
||||||
} else if (!category.equals(other.category))
|
} else if (!category.equals(other.category))
|
||||||
return false;
|
return false;
|
||||||
|
if (commentCount != other.commentCount)
|
||||||
|
return false;
|
||||||
if (description == null) {
|
if (description == null) {
|
||||||
if (other.description != null)
|
if (other.description != null)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ public class CloudPresenter {
|
|||||||
throws CloudException {
|
throws CloudException {
|
||||||
LOG.info(String.format("search(%1$s,%2$s,%3$s,%4$d,%5$d)", criteria, category, sortOrder, pageNumber, itemsPerPage));
|
LOG.info(String.format("search(%1$s,%2$s,%3$s,%4$d,%5$d)", criteria, category, sortOrder, pageNumber, itemsPerPage));
|
||||||
try {
|
try {
|
||||||
Object res = service.search(criteria, category, "json", pageNumber, itemsPerPage, sortOrder);
|
Object res = service.search(criteria, category, pageNumber, itemsPerPage, sortOrder);
|
||||||
// Thread.sleep(2000);
|
// Thread.sleep(2000);
|
||||||
if (res == null)
|
if (res == null)
|
||||||
throw new CloudException("Failed to retreive search results.");
|
throw new CloudException("Failed to retreive search results.");
|
||||||
@@ -225,7 +225,8 @@ public class CloudPresenter {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<ProjectEntity> projects = (List<ProjectEntity>) res;
|
List<ProjectEntity> projects = (List<ProjectEntity>) res;
|
||||||
LOG.info("Received " + projects.size() + " results. Downloading thumbnails...");
|
LOG.info("Received " + projects.size() + " results. Downloading thumbnails...");
|
||||||
// Download thumbnails and replace urls with local paths to speed up loading in the main thread
|
// Download thumbnails and replace urls with local paths to speed up loading in the main
|
||||||
|
// thread
|
||||||
for (int i = 0; i < projects.size(); i++) {
|
for (int i = 0; i < projects.size(); i++) {
|
||||||
String url = projects.get(i).getThumbnailUrl();
|
String url = projects.get(i).getThumbnailUrl();
|
||||||
URL website = new URL(url);
|
URL website = new URL(url);
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import javax.imageio.ImageIO;
|
|||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
|
import com.sun.org.apache.xml.internal.serializer.utils.Messages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads image resources as Icons.
|
* Loads image resources as Icons.
|
||||||
*
|
*
|
||||||
@@ -34,7 +36,8 @@ public enum IconLoader {
|
|||||||
"id_card_edit.png"), KeyEdit("key_edit.png"), Find("find.png"), Dashboard("dashboard.png"), DataFind(
|
"id_card_edit.png"), KeyEdit("key_edit.png"), Find("find.png"), Dashboard("dashboard.png"), DataFind(
|
||||||
"data_find.png"), CloudDownload("cloud-download.png"), NavLeftBlue("nav_left_blue.png"), NavRightBlue(
|
"data_find.png"), CloudDownload("cloud-download.png"), NavLeftBlue("nav_left_blue.png"), NavRightBlue(
|
||||||
"nav_right_blue.png"), MissingImage("missing_image.png"), CloudBg("cloud_bg.png"), CloudBig("cloud_big.png"), CloudWait(
|
"nav_right_blue.png"), MissingImage("missing_image.png"), CloudBg("cloud_bg.png"), CloudBig("cloud_big.png"), CloudWait(
|
||||||
"cloud_wait.png"), Spinning("spinning.gif"), Megaphone("megaphone.png"), Download("download.png"), Eye("eye.png");
|
"cloud_wait.png"), Spinning("spinning.gif"), Megaphone("megaphone.png"), Download("download.png"), Eye("eye.png"), Messages(
|
||||||
|
"messages.png");
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 883 B |
Binary file not shown.
|
After Width: | Height: | Size: 877 B |
Binary file not shown.
|
After Width: | Height: | Size: 877 B |
+15
-6
@@ -101,11 +101,11 @@ public class ResultsScrollPanel extends JScrollPane {
|
|||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
gbc.weightx = 100;
|
gbc.weightx = 100;
|
||||||
gbc.weighty = 100;
|
gbc.weighty = 100;
|
||||||
gbc.gridwidth = 4;
|
gbc.gridwidth = 3;
|
||||||
resultsPanel.add(getLoadMoreLabel(), gbc);
|
resultsPanel.add(getLoadMoreLabel(), gbc);
|
||||||
|
|
||||||
gbc.gridx = 2;
|
gbc.gridx = 3;
|
||||||
gbc.gridwidth = 1;
|
gbc.gridwidth = 2;
|
||||||
gbc.weightx = 0;
|
gbc.weightx = 0;
|
||||||
gbc.insets = new Insets(0, 0, 0, 2);
|
gbc.insets = new Insets(0, 0, 0, 2);
|
||||||
gbc.fill = GridBagConstraints.NONE;
|
gbc.fill = GridBagConstraints.NONE;
|
||||||
@@ -179,9 +179,15 @@ public class ResultsScrollPanel extends JScrollPane {
|
|||||||
descriptionArea.setEnabled(false);
|
descriptionArea.setEnabled(false);
|
||||||
// descriptionArea.setDisabledTextColor(descriptionArea.getSelectionColor());
|
// descriptionArea.setDisabledTextColor(descriptionArea.getSelectionColor());
|
||||||
|
|
||||||
|
JLabel commentLabel =
|
||||||
|
new JLabel(Integer.toString(project.getCommentCount()), IconLoader.Messages.getIcon(), SwingConstants.LEFT);
|
||||||
|
commentLabel.setToolTipText("Click to see and add public comments");
|
||||||
|
commentLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
|
|
||||||
JLabel viewLabel =
|
JLabel viewLabel =
|
||||||
new JLabel(Integer.toString(project.getViewCount()), IconLoader.Eye.getIcon(), SwingConstants.LEFT);
|
new JLabel(Integer.toString(project.getViewCount()), IconLoader.Eye.getIcon(), SwingConstants.LEFT);
|
||||||
viewLabel.setToolTipText("View count");
|
viewLabel.setToolTipText("View count");
|
||||||
|
|
||||||
JLabel downloadLabel =
|
JLabel downloadLabel =
|
||||||
new JLabel(Integer.toString(project.getDownloadCount()), IconLoader.Download.getIcon(), SwingConstants.LEFT);
|
new JLabel(Integer.toString(project.getDownloadCount()), IconLoader.Download.getIcon(), SwingConstants.LEFT);
|
||||||
downloadLabel.setToolTipText("Download count");
|
downloadLabel.setToolTipText("Download count");
|
||||||
@@ -274,6 +280,9 @@ public class ResultsScrollPanel extends JScrollPane {
|
|||||||
|
|
||||||
gbc.gridx++;
|
gbc.gridx++;
|
||||||
gbc.weightx = 0;
|
gbc.weightx = 0;
|
||||||
|
getResultsPanel().add(commentLabel, gbc);
|
||||||
|
|
||||||
|
gbc.gridx++;
|
||||||
getResultsPanel().add(viewLabel, gbc);
|
getResultsPanel().add(viewLabel, gbc);
|
||||||
|
|
||||||
gbc.gridx++;
|
gbc.gridx++;
|
||||||
@@ -283,7 +292,7 @@ public class ResultsScrollPanel extends JScrollPane {
|
|||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
gbc.weighty = 1;
|
gbc.weighty = 1;
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
gbc.gridwidth = 4;
|
gbc.gridwidth = 5;
|
||||||
gbc.anchor = GridBagConstraints.NORTHWEST;
|
gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
gbc.insets = new Insets(2, 6, 2, 2);
|
gbc.insets = new Insets(2, 6, 2, 2);
|
||||||
@@ -297,7 +306,7 @@ public class ResultsScrollPanel extends JScrollPane {
|
|||||||
|
|
||||||
gbc.gridx++;
|
gbc.gridx++;
|
||||||
gbc.gridheight = 3;
|
gbc.gridheight = 3;
|
||||||
gbc.gridwidth = 2;
|
gbc.gridwidth = 3;
|
||||||
gbc.insets = new Insets(2, 2, 2, 2);
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
gbc.anchor = GridBagConstraints.SOUTHEAST;
|
gbc.anchor = GridBagConstraints.SOUTHEAST;
|
||||||
getResultsPanel().add(downloadButton, gbc);
|
getResultsPanel().add(downloadButton, gbc);
|
||||||
@@ -314,7 +323,7 @@ public class ResultsScrollPanel extends JScrollPane {
|
|||||||
|
|
||||||
gbc.gridx = 0;
|
gbc.gridx = 0;
|
||||||
gbc.gridy++;
|
gbc.gridy++;
|
||||||
gbc.gridwidth = 5;
|
gbc.gridwidth = 6;
|
||||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
gbc.insets = new Insets(2, 2, 2, 2);
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user