Skip to content

Commit 384b1bb

Browse files
committed
增加加速器
1 parent 1fdb04a commit 384b1bb

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

conf/nbs.db

0 Bytes
Binary file not shown.

src/main/java/io/nbs/client/ui/components/forms/LCFormLabel.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,12 @@ public void setVolumeText(String text){
4949
public void setHorizontalAlignment(int horizontalAlignment){
5050
this.label.setHorizontalAlignment(horizontalAlignment);
5151
}
52+
53+
public JLabel getLabel() {
54+
return label;
55+
}
56+
57+
public LCJTextArea getTextArea() {
58+
return textArea;
59+
}
5260
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ private void setListeners() {
106106
* @param who
107107
*/
108108
public void showPanel(MMNames who){
109+
if(who==MMNames.TIP){
110+
MMMonitPanel.CtrlSign = false;
111+
}else {
112+
MMMonitPanel.CtrlSign = true;
113+
}
109114
cardLayout.show(cardPanel,who.name());
110115
}
111116

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class MMMonitPanel extends JPanel {
5353
//private SizeAutoAdjustTextArea textArea;
5454
private JPanel wantListPanel;
5555

56-
private static boolean CtrlSign = false;
56+
public static boolean CtrlSign = false;
5757
private long fsize = 0l;
5858
private String rhash;
5959
private IPFS ipfs;
@@ -154,7 +154,7 @@ public void startMonitor(String rhash,BlockStat stat){
154154
this.rhash = rhash;
155155
this.fsize = stat.getCumulativeSize();
156156
Multihash multihash = Multihash.fromBase58(stat.getHash());
157-
statusLabel.setText("浏览器打开,正在加载数据...");
157+
158158

159159
new Thread(()->{
160160
int sec = 0;
@@ -177,7 +177,7 @@ public void startMonitor(String rhash,BlockStat stat){
177177
generateHash(multihash);
178178
}).start();
179179

180-
monitorList();
180+
//monitorList();
181181
boosterPined();
182182
this.setVisible(true);
183183
}
@@ -205,9 +205,11 @@ private void generateHash(Multihash multihash){
205205
/**
206206
*
207207
*/
208-
private void boosterPined(){
208+
public void boosterPined(){
209+
if(CtrlSign)return;
209210
new Thread(()->{
210211
while (completeSize.get()<fsize){
212+
CtrlSign = true;
211213
try {
212214
Multihash multihash = pinedBooster.take();
213215

@@ -229,14 +231,20 @@ private void boosterPined(){
229231
e.printStackTrace();
230232
}
231233
}
234+
CtrlSign = false;
232235
}).start();
233236
}
234237

235-
private void monitorList(){
238+
/**
239+
*
240+
*/
241+
public void monitorList(){
242+
236243
new Thread(()->{
237-
while (completeSize.get()<fsize){
244+
while (!CtrlSign){
238245
ResData<BitSwap> resData = bitSwapService.getBitSwapStat();
239246
if(resData.getCode()==0){
247+
statusLabel.setText("浏览器打开,正在加载数据...");
240248
BitSwap bitSwap = resData.getData();
241249
if(bitSwap!=null&&bitSwap.getWantlist().size()>0){
242250
wantListPanel.removeAll();
@@ -261,7 +269,7 @@ public void mouseEntered(MouseEvent e) {
261269
}
262270

263271
try {
264-
TimeUnit.SECONDS.sleep(2);
272+
TimeUnit.SECONDS.sleep(5);
265273
} catch (InterruptedException e) {
266274
e.printStackTrace();
267275
}
@@ -271,4 +279,6 @@ public void mouseEntered(MouseEvent e) {
271279
}).start();
272280

273281
}
282+
283+
274284
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,15 @@ private void initView() {
174174
contentPanel.add(dataSize,"split,span ,growx ,gaptop 5");
175175
contentPanel.add(dataSizeVol,"span ,growx ,gaptop 5");
176176
contentPanel.add(numLinks,"span ,growx ,gaptop 5");
177-
contentPanel.add(numLinksVol,"span ,growx ,gaptop 5");
177+
contentPanel.add(numLinksVol,"span ,growx ,gaptop 5,wrap");
178+
contentPanel.add(errorLabel,"split ,span 1 ,wrap,grow");
178179
}
179180

180181
private void setListeners() {
181182
openBtn.addActionListener(new ActionListener() {
182183
@Override
183184
public void actionPerformed(ActionEvent e) {
184-
185-
186-
185+
monitPanel.monitorList();
187186
BrowserOperationHelper.getInstance().openURL(hash58);
188187
}
189188
});
@@ -207,6 +206,7 @@ public void setHash(String hash){
207206
public void setBlkStat(BlockStat stat,String errorMSG,long usedSecd){
208207
String timeUsed = DateHelper.calcUsedTime(usedSecd);
209208
searchUsed.setVolumeText(timeUsed);
209+
searchUsed.getTextArea().setBackground(ColorCnst.WINDOW_BACKGROUND);
210210
if(errorMSG==null&&stat!=null){
211211
this.stat = stat;
212212
errorLabel.setVisible(false);

0 commit comments

Comments
 (0)