Skip to content

Commit cb42a4b

Browse files
committed
添加下载按钮
1 parent c403aa3 commit cb42a4b

File tree

6 files changed

+95
-4
lines changed

6 files changed

+95
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ ipfs pubsub peers bmJzaW8ubmV0
1313
- 聊天功能
1414
- 联系人名片
1515
- 增加节点信息显示
16-
## skjd
16+
## Version 2.0.2
17+
- 增加文件下载功能

conf/nbs.db

0 Bytes
Binary file not shown.

nbssvr/ipfs.exe

-28.7 MB
Binary file not shown.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.nbs.entity;
2+
3+
/**
4+
* @Package : com.nbs.entity
5+
* @Description : <p></p>
6+
* @Author : lambor.c
7+
* @Date : 2018/8/2-13:46
8+
* Copyright (c) 2018, NBS , lambor.c<[email protected]>.
9+
* All rights reserved.
10+
*/
11+
public class IPFSFileEntity {
12+
String hash;
13+
String wrapHash;
14+
String saveName;
15+
String fullName;
16+
String suffix;
17+
18+
Long size;
19+
20+
public String getHash() {
21+
return hash;
22+
}
23+
24+
public void setHash(String hash) {
25+
this.hash = hash;
26+
}
27+
28+
public String getWrapHash() {
29+
return wrapHash;
30+
}
31+
32+
public void setWrapHash(String wrapHash) {
33+
this.wrapHash = wrapHash;
34+
}
35+
36+
public String getSaveName() {
37+
return saveName;
38+
}
39+
40+
public void setSaveName(String saveName) {
41+
this.saveName = saveName;
42+
}
43+
44+
public String getFullName() {
45+
return fullName;
46+
}
47+
48+
public void setFullName(String fullName) {
49+
this.fullName = fullName;
50+
}
51+
52+
public String getSuffix() {
53+
return suffix;
54+
}
55+
56+
public void setSuffix(String suffix) {
57+
this.suffix = suffix;
58+
}
59+
60+
public Long getSize() {
61+
return size;
62+
}
63+
64+
public void setSize(Long size) {
65+
this.size = size;
66+
}
67+
}

src/main/java/io/nbs/client/ui/panels/manage/MMSearcherPanel.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.nbs.ui.panels.ListPanel;
77
import io.ipfs.api.IPFS;
88
import io.ipfs.api.JSONParser;
9+
import io.ipfs.api.MerkleNode;
910
import io.ipfs.api.beans.blk.BlockStat;
1011
import io.ipfs.multihash.Multihash;
1112
import io.nbs.client.Launcher;
@@ -190,7 +191,17 @@ private void searchHash(final String text){
190191
try {
191192
tipResultHashPanel.searchingFromIntelnet();
192193
Object o =ipfs.object.stat(multihash1);
194+
MerkleNode merkleNode = ipfs.object.get(multihash1);
193195
String json = JSONParser.toString(o);
196+
if(merkleNode!=null){
197+
String fileName = "";
198+
try{
199+
logger.info( merkleNode.toJSONString());
200+
fileName = merkleNode.name.get();
201+
}catch (RuntimeException e){
202+
203+
}
204+
}
194205
BlockStat stat = JSON.parseObject(json,BlockStat.class);
195206
long usedsecd = System.currentTimeMillis()-start;
196207
logger.info("客户端IP{}用时{}ms",MainFrame.getContext().getCurrentPeer().getIp(),usedsecd);

src/main/java/io/nbs/client/ui/panels/manage/body/TipResultHashPanel.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.awt.*;
2323
import java.awt.event.ActionEvent;
2424
import java.awt.event.ActionListener;
25+
import java.io.File;
2526
import java.io.IOException;
2627
import java.util.ArrayList;
2728

@@ -70,11 +71,13 @@ public class TipResultHashPanel extends ParentAvailablePanel {
7071
private NBSButton openBtn;
7172
private NBSButton addBtn;
7273

73-
private BlockStat stat;
74+
private BlockStat stat =null;
7475
private String preousHash;
7576

7677
private MMMonitPanel monitPanel;
7778

79+
private JFileChooser fileChooser;
80+
7881

7982

8083

@@ -135,7 +138,7 @@ private void initComponents() {
135138
openBtn = new NBSButton("浏览器打开",ColorCnst.CONTACTS_ITEM_GRAY,ColorCnst.WINDOW_BACKGROUND_LIGHT);
136139
openBtn.setForeground(ColorCnst.FONT_ABOUT_TITLE_BLUE);
137140
addBtn = new NBSButton("下载到本地",ColorCnst.CONTACTS_ITEM_GRAY,ColorCnst.WINDOW_BACKGROUND_LIGHT);
138-
addBtn.setVisible(false);//暂未开发完成
141+
addBtn.setVisible(true);//暂未开发完成
139142
addBtn.setForeground(ColorCnst.FONT_ABOUT_TITLE_BLUE);
140143

141144
operPanel.add(openBtn);
@@ -161,6 +164,13 @@ public void searchingFromIntelnet(){
161164
operPanel.setVisible(false);
162165
}
163166

167+
168+
private void openSaveOption(BlockStat stat ){
169+
if(stat!=null&&stat.getHash()!=null){
170+
//add Queue
171+
}
172+
}
173+
164174
/**
165175
* [initView description]
166176
*
@@ -195,7 +205,7 @@ public void actionPerformed(ActionEvent e) {
195205
addBtn.addActionListener(new ActionListener() {
196206
@Override
197207
public void actionPerformed(ActionEvent e) {
198-
208+
logger.info("download lanbery");
199209
}
200210
});
201211
}
@@ -215,6 +225,7 @@ public void setBlkStat(BlockStat stat,String errorMSG,long usedSecd){
215225
if(errorMSG==null&&stat!=null){
216226
this.stat = stat;
217227
errorLabel.setVisible(false);
228+
//showDownload(true);
218229
operPanel.setVisible(true);
219230
Long totalSize = stat.getCumulativeSize()==null?0:stat.getCumulativeSize();
220231
Long blkSize = stat.getBlockSize();
@@ -240,6 +251,7 @@ public void setBlkStat(BlockStat stat,String errorMSG,long usedSecd){
240251
*
241252
*/
242253
public void clearVol(){
254+
this.stat = null;
243255
cumulativeSizeVol.setText("");
244256
blockSizeVol.setText("");
245257
linksSizeVol.setText("");

0 commit comments

Comments
 (0)