Skip to content

Commit cbc43a2

Browse files
committed
修正日志中文乱码
1 parent aa123a9 commit cbc43a2

File tree

5 files changed

+88
-73
lines changed

5 files changed

+88
-73
lines changed

conf/nbs.db

0 Bytes
Binary file not shown.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ private void searchHash(final String text){
178178
bodyPanel.showPanel(MMBodyPanel.MMNames.TIP);
179179
IPFS ipfs = Launcher.getContext().getIpfs();
180180
TipResultHashPanel tipResultHashPanel= MMBodyPanel.getContext().getTipResultHashPanel();
181-
tipResultHashPanel.clearVol();
182181
if(tipResultHashPanel.prevousHash().equals(text))return;
182+
tipResultHashPanel.clearVol();
183183
tipResultHashPanel.setHash(multihash.toBase58());
184184
new Thread(()->{
185185
if( tipResultHashPanel.getMonitPanel()!=null){
@@ -204,6 +204,7 @@ private void searchHash(final String text){
204204
logger.info("TESTLOG:{}>>>查找文件:{}没有查到,用时{}",Launcher.getSysUser(),text,DateHelper.calcUsedTime(usedsecd));
205205
tipResultHashPanel.setBlkStat(null,error,usedsecd);
206206
}
207+
tipResultHashPanel.setPreousHash(text);
207208
}).start();
208209
}else {
209210
bodyPanel.showPanel(MMBodyPanel.MMNames.LISTF);

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

Lines changed: 77 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -237,86 +237,93 @@ public void monitorList()
237237
CtrlSign.set(0);
238238
this.setVisible(true);
239239
sec = 0;
240-
if(timeThread == null){
241-
timeThread = new Thread(){
242-
@Override
243-
public void run() {
244-
statusLabel.setText("浏览器打开,正在加载数据...");
245-
while (CtrlSign.intValue()==0&& sec<=timeout){
246-
sec++;
247-
timelabel.setText(sec+"s");
248-
timelabel.updateUI();
249-
try {
250-
TimeUnit.SECONDS.sleep(1);
251-
} catch (InterruptedException e) {
252-
e.printStackTrace();
253-
}
254-
}
240+
resetTimes();
241+
newWantlistThread();
255242

243+
}
244+
245+
private void resetTimes(){
246+
if(timeThread!=null){
247+
try{
248+
timeThread.interrupt();
249+
}catch (RuntimeException re){
250+
re.printStackTrace();
251+
logger.warn(re.getMessage());
252+
}
253+
timeThread=null;
254+
}
255+
timeThread = new Thread(){
256+
@Override
257+
public void run() {
258+
statusLabel.setText("浏览器打开,正在加载数据...");
259+
while (CtrlSign.intValue()==0&& sec<=timeout){
260+
sec++;
261+
timelabel.setText(sec+"s");
262+
timelabel.updateUI();
263+
try {
264+
TimeUnit.SECONDS.sleep(1);
265+
} catch (InterruptedException e) {
266+
e.printStackTrace();
267+
}
256268
}
257-
};
258-
timeThread.start();
269+
270+
}
271+
};
272+
timeThread.start();
273+
}
274+
275+
private void newWantlistThread(){
276+
if(wantThread!=null){
277+
try{
278+
wantThread.interrupt();
279+
}catch (RuntimeException re){
280+
logger.warn(re.getMessage());
281+
}
282+
wantThread=null;
259283
}
260-
else
284+
wantThread = new Thread()
261285
{
262-
Thread.State state =timeThread.getState();
263-
if(state==Thread.State.TERMINATED)timeThread.start();
264-
}
286+
@Override
287+
public void run() {
288+
while (CtrlSign.intValue()==0&& sec<=timeout) {
289+
ResData<BitSwap> resData = bitSwapService.getBitSwapStat();
290+
if (resData.getCode() == 0) {
291+
BitSwap bitSwap = resData.getData();
292+
if (bitSwap != null && bitSwap.getWantlist().size() > 0) {
293+
wantListPanel.removeAll();
294+
for (String hash58 : bitSwap.getWantlist()) {
295+
wantListPanel.add(new LCJlabel(hash58, wantHashColor) {
296+
@Override
297+
public void setToolTipText(String text) {
298+
super.setToolTipText(hash58);
299+
}
300+
301+
@Override
302+
public synchronized void addMouseListener(MouseListener l) {
303+
MouseAdapter adapter = new MouseAdapter() {
304+
@Override
305+
public void mouseEntered(MouseEvent e) {
306+
e.getComponent().setCursor(MainFrame.handCursor);
307+
}
308+
};
309+
super.addMouseListener(adapter);
310+
}
311+
});
312+
313+
wantListPanel.updateUI();
314+
}
265315

266-
if(wantThread == null){
267-
wantThread = new Thread()
268-
{
269-
@Override
270-
public void run() {
271-
while (CtrlSign.intValue()==0&& sec<=timeout) {
272-
ResData<BitSwap> resData = bitSwapService.getBitSwapStat();
273-
if (resData.getCode() == 0) {
274-
BitSwap bitSwap = resData.getData();
275-
if (bitSwap != null && bitSwap.getWantlist().size() > 0) {
276-
wantListPanel.removeAll();
277-
for (String hash58 : bitSwap.getWantlist()) {
278-
wantListPanel.add(new LCJlabel(hash58, wantHashColor) {
279-
@Override
280-
public void setToolTipText(String text) {
281-
super.setToolTipText(hash58);
282-
}
283-
284-
@Override
285-
public synchronized void addMouseListener(MouseListener l) {
286-
MouseAdapter adapter = new MouseAdapter() {
287-
@Override
288-
public void mouseEntered(MouseEvent e) {
289-
e.getComponent().setCursor(MainFrame.handCursor);
290-
}
291-
};
292-
super.addMouseListener(adapter);
293-
}
294-
});
295-
296-
wantListPanel.updateUI();
297-
}
298-
299-
try {
300-
TimeUnit.SECONDS.sleep(3);
301-
} catch (InterruptedException e) {
302-
e.printStackTrace();
303-
}
316+
try {
317+
TimeUnit.SECONDS.sleep(3);
318+
} catch (InterruptedException e) {
319+
e.printStackTrace();
304320
}
305321
}
306322
}
307-
308323
}
309-
};
310-
wantThread.start();
311-
//wantThread = null;
312-
}
313-
else
314-
{
315-
if(wantThread.getState()==Thread.State.TERMINATED){
316-
wantThread.start();
317-
}
318-
}
319324

325+
}
326+
};
320327
}
321328

322329
/**

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public class TipResultHashPanel extends ParentAvailablePanel {
7171
private NBSButton addBtn;
7272

7373
private BlockStat stat;
74+
private String preousHash;
7475

7576
private MMMonitPanel monitPanel;
7677

@@ -143,7 +144,7 @@ private void initComponents() {
143144

144145
this.add(errorLabel);
145146

146-
errorLabel.setText("lanbery");
147+
errorLabel.setText("");
147148

148149
monitPanel = new MMMonitPanel();
149150

@@ -260,7 +261,7 @@ public static TipResultHashPanel getContext() {
260261
* @return
261262
*/
262263
public String prevousHash(){
263-
return this.hash58==null?"":this.hash58;
264+
return this.preousHash == null ? "":this.hash58;
264265
}
265266

266267
private void pinedHash(){
@@ -291,4 +292,8 @@ public MMMonitPanel getMonitPanel() {
291292
public void hideMMMonitor(){
292293
monitPanel.setVisible(false);
293294
}
295+
296+
public void setPreousHash(String preousHash) {
297+
this.preousHash = preousHash;
298+
}
294299
}

src/main/resources/logback.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
44
<encoder>
55
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
6+
<charset>UTF-8</charset>
67
</encoder>
78
</appender>
89

@@ -12,6 +13,7 @@
1213
</rollingPolicy>
1314
<encoder>
1415
<pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
16+
<charset>UTF-8</charset>
1517
</encoder>
1618
</appender>
1719

0 commit comments

Comments
 (0)