view and download counter added

This commit is contained in:
bancika
2016-10-27 10:51:18 +02:00
parent 377d8c4ed5
commit 3e695a37f0
6 changed files with 49 additions and 77 deletions
@@ -14,13 +14,15 @@ public class ProjectEntity implements Serializable {
private String updated; private String updated;
private String thumbnailUrl; private String thumbnailUrl;
private String downloadUrl; private String downloadUrl;
private int viewCount;
private int downloadCount;
public ProjectEntity() { public ProjectEntity() {
super(); super();
} }
public ProjectEntity(int id, String name, String description, String owner, String category, String updated, public ProjectEntity(int id, String name, String description, String owner, String category, String updated,
String thumbnailUrl, String downloadUrl) { String thumbnailUrl, String downloadUrl, int viewCount, int downloadCount) {
super(); super();
this.id = id; this.id = id;
this.name = name; this.name = name;
@@ -30,6 +32,8 @@ public class ProjectEntity implements Serializable {
this.updated = updated; this.updated = updated;
this.thumbnailUrl = thumbnailUrl; this.thumbnailUrl = thumbnailUrl;
this.downloadUrl = downloadUrl; this.downloadUrl = downloadUrl;
this.viewCount = viewCount;
this.downloadCount = downloadCount;
} }
public int getId() { public int getId() {
@@ -96,31 +100,36 @@ public class ProjectEntity implements Serializable {
this.downloadUrl = downloadUrl; this.downloadUrl = downloadUrl;
} }
// public Action getDownload() { public int getViewCount() {
// return viewCount;
// Action a = new AbstractAction() { }
//
// @Override public void setViewCount(int viewCount) {
// public void actionPerformed(ActionEvent e) { this.viewCount = viewCount;
// JOptionPane.showMessageDialog(null, name); }
// }
// }; public int getDownloadCount() {
// a.putValue(AbstractAction.NAME, "Download"); return downloadCount;
// return a; }
// }
// public void setDownloadCount(int downloadCount) {
this.downloadCount = downloadCount;
}
@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 + ((description == null) ? 0 : description.hashCode()); result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + downloadCount;
result = prime * result + ((downloadUrl == null) ? 0 : downloadUrl.hashCode()); result = prime * result + ((downloadUrl == null) ? 0 : downloadUrl.hashCode());
result = prime * result + id; result = prime * result + id;
result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((owner == null) ? 0 : owner.hashCode()); result = prime * result + ((owner == null) ? 0 : owner.hashCode());
result = prime * result + ((thumbnailUrl == null) ? 0 : thumbnailUrl.hashCode()); result = prime * result + ((thumbnailUrl == null) ? 0 : thumbnailUrl.hashCode());
result = prime * result + ((updated == null) ? 0 : updated.hashCode()); result = prime * result + ((updated == null) ? 0 : updated.hashCode());
result = prime * result + viewCount;
return result; return result;
} }
@@ -143,6 +152,8 @@ public class ProjectEntity implements Serializable {
return false; return false;
} else if (!description.equals(other.description)) } else if (!description.equals(other.description))
return false; return false;
if (downloadCount != other.downloadCount)
return false;
if (downloadUrl == null) { if (downloadUrl == null) {
if (other.downloadUrl != null) if (other.downloadUrl != null)
return false; return false;
@@ -170,6 +181,8 @@ public class ProjectEntity implements Serializable {
return false; return false;
} else if (!updated.equals(other.updated)) } else if (!updated.equals(other.updated))
return false; return false;
if (viewCount != other.viewCount)
return false;
return true; return true;
} }
@@ -34,7 +34,7 @@ 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"); "cloud_wait.png"), Spinning("spinning.gif"), Megaphone("megaphone.png"), Download("download.png"), Eye("eye.png");
protected String name; protected String name;
Binary file not shown.

After

Width:  |  Height:  |  Size: 852 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 789 B

@@ -101,7 +101,7 @@ 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 = 2; gbc.gridwidth = 4;
resultsPanel.add(getLoadMoreLabel(), gbc); resultsPanel.add(getLoadMoreLabel(), gbc);
gbc.gridx = 2; gbc.gridx = 2;
@@ -179,6 +179,13 @@ public class ResultsScrollPanel extends JScrollPane {
descriptionArea.setEnabled(false); descriptionArea.setEnabled(false);
// descriptionArea.setDisabledTextColor(descriptionArea.getSelectionColor()); // descriptionArea.setDisabledTextColor(descriptionArea.getSelectionColor());
JLabel viewLabel =
new JLabel(Integer.toString(project.getViewCount()), IconLoader.Eye.getIcon(), SwingConstants.LEFT);
viewLabel.setToolTipText("View count");
JLabel downloadLabel =
new JLabel(Integer.toString(project.getDownloadCount()), IconLoader.Download.getIcon(), SwingConstants.LEFT);
downloadLabel.setToolTipText("Download count");
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>");
@@ -260,30 +267,37 @@ public class ResultsScrollPanel extends JScrollPane {
getResultsPanel().add(thumbnailLabel, gbc); getResultsPanel().add(thumbnailLabel, gbc);
gbc.gridheight = 1; gbc.gridheight = 1;
gbc.gridx = 1; gbc.gridx++;
gbc.weightx = 1; gbc.weightx = 1000;
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++;
gbc.weightx = 0;
getResultsPanel().add(viewLabel, gbc);
gbc.gridx++;
getResultsPanel().add(downloadLabel, gbc);
gbc.gridy++; gbc.gridy++;
gbc.gridx = 1; gbc.gridx = 1;
gbc.weighty = 1; gbc.weighty = 1;
gbc.weightx = 1; gbc.weightx = 1;
gbc.gridwidth = 2; gbc.gridwidth = 4;
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);
getResultsPanel().add(descriptionArea, gbc); getResultsPanel().add(descriptionArea, gbc);
gbc.gridy++; gbc.gridy++;
gbc.gridx = 1;
gbc.gridwidth = 1; gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.NONE; gbc.fill = GridBagConstraints.NONE;
gbc.weighty = 0; gbc.weighty = 0;
getResultsPanel().add(categoryLabel, gbc); getResultsPanel().add(categoryLabel, gbc);
gbc.gridx = 2; gbc.gridx++;
gbc.gridheight = 3; gbc.gridheight = 3;
gbc.gridwidth = 2;
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);
@@ -300,7 +314,7 @@ public class ResultsScrollPanel extends JScrollPane {
gbc.gridx = 0; gbc.gridx = 0;
gbc.gridy++; gbc.gridy++;
gbc.gridwidth = 3; gbc.gridwidth = 5;
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);
@@ -1,55 +0,0 @@
package org.diylc;
import java.util.ArrayList;
import java.util.List;
import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import org.apache.log4j.BasicConfigurator;
import org.diylc.plugins.cloud.model.ProjectEntity;
import org.diylc.swingframework.objecttable.IActionProcessor;
import org.diylc.swingframework.objecttable.ObjectListTable;
public class TableTest {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
BasicConfigurator.configure();
List<ProjectEntity> projects = new ArrayList<ProjectEntity>();
projects.add(new ProjectEntity(1, "first", "some text", "bane", "none", "", "", ""));
projects.add(new ProjectEntity(2, "second", "anoter text", "bisera", "none", "", "", ""));
ObjectListTable<ProjectEntity> t =
new ObjectListTable<ProjectEntity>(ProjectEntity.class, new String[] {"getName", "getDescription",
"getCategory", "getOwner", "action:Download"}, new IActionProcessor<ProjectEntity>() {
@Override
public void actionExecuted(ProjectEntity value, String actionColumnName) {
System.out.println("row clicked: " + actionColumnName + " - " + value);
}
@Override
public Icon getActionIcon(String actionColumnName) {
return null;
}
@Override
public String getActionLabel(String actionColumnName) {
return "get me";
}
});
t.setData(projects);
JFrame f = new JFrame();
f.add(new JScrollPane(t));
f.pack();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}