@ -21,6 +21,7 @@ import com.fr.env.detect.base.EnvDetectorConfig;
import com.fr.env.detect.bean.DetectorResult ;
import com.fr.env.detect.bean.DetectorResult ;
import com.fr.env.detect.bean.DetectorStatus ;
import com.fr.env.detect.bean.DetectorStatus ;
import com.fr.env.detect.bean.DetectorType ;
import com.fr.env.detect.bean.DetectorType ;
import com.fr.log.FineLoggerFactory ;
import org.jetbrains.annotations.NotNull ;
import org.jetbrains.annotations.NotNull ;
import javax.swing.BorderFactory ;
import javax.swing.BorderFactory ;
@ -55,6 +56,7 @@ public class EnvDetectorDialog extends JDialog {
private static final int TIMEOUT = 1000 ;
private static final int TIMEOUT = 1000 ;
private static final Color SUCCESS_COLOR = new Color ( 22 , 193 , 83 ) ;
private static final Color SUCCESS_COLOR = new Color ( 22 , 193 , 83 ) ;
private static final Color DETAIL_FONT_COLOR = new Color ( 65 , 155 , 249 ) ;
private final JPanel body ;
private final JPanel body ;
@ -177,7 +179,7 @@ public class EnvDetectorDialog extends JDialog {
}
}
// 执行前
// 执行前
buttonStatus = buttonStatus . next ( ) ;
buttonStatus = buttonStatus . next ( ) ;
UIUtil . invokeLaterIfNeeded ( EnvDetectorDialog . this : : refreshHeaderPanel ) ;
UIUtil . invokeLaterIfNeeded ( EnvDetectorDialog . this : : refreshHeader ) ;
detectWorker = new SwingWorker < Void , Void > ( ) {
detectWorker = new SwingWorker < Void , Void > ( ) {
@Override
@Override
@ -192,7 +194,7 @@ public class EnvDetectorDialog extends JDialog {
}
}
// 刷新一下面板-开始执行啦
// 刷新一下面板-开始执行啦
UIUtil . invokeLaterIfNeeded ( EnvDetectorDialog . this : : refresh ) ;
UIUtil . invokeLaterIfNeeded ( EnvDetectorDialog . this : : refreshBody ) ;
EnvDetectorItem item = items . get ( i ) ;
EnvDetectorItem item = items . get ( i ) ;
DetectorType type = item . getType ( ) ;
DetectorType type = item . getType ( ) ;
@ -208,7 +210,7 @@ public class EnvDetectorDialog extends JDialog {
// 只有还在运行中,才会真正的刷新面板
// 只有还在运行中,才会真正的刷新面板
if ( buttonStatus . isExecuting ( ) ) {
if ( buttonStatus . isExecuting ( ) ) {
// 在刷新一下面板
// 在刷新一下面板
UIUtil . invokeLaterIfNeeded ( EnvDetectorDialog . this : : refresh ) ;
UIUtil . invokeLaterIfNeeded ( EnvDetectorDialog . this : : refreshBody ) ;
currentDetectIndex + + ;
currentDetectIndex + + ;
}
}
@ -219,10 +221,15 @@ public class EnvDetectorDialog extends JDialog {
@Override
@Override
protected void done ( ) {
protected void done ( ) {
try {
this . get ( ) ;
if ( buttonStatus . isExecuting ( ) ) {
if ( buttonStatus . isExecuting ( ) ) {
// 执行结束
// 执行结束
buttonStatus = EnvDetectorButtonStatus . A_NEW ;
buttonStatus = EnvDetectorButtonStatus . A_NEW ;
UIUtil . invokeLaterIfNeeded ( EnvDetectorDialog . this : : refreshHeaderPanel ) ;
UIUtil . invokeLaterIfNeeded ( EnvDetectorDialog . this : : refreshHeader ) ;
}
} catch ( Exception e ) {
FineLoggerFactory . getLogger ( ) . error ( "detect failed" , e ) ;
}
}
}
}
} ;
} ;
@ -236,7 +243,7 @@ public class EnvDetectorDialog extends JDialog {
e . setResult ( null ) ;
e . setResult ( null ) ;
}
}
// 刷新一下面板-开始执行啦
// 刷新一下面板-开始执行啦
UIUtil . invokeLaterIfNeeded ( EnvDetectorDialog . this : : refresh ) ;
UIUtil . invokeLaterIfNeeded ( EnvDetectorDialog . this : : refreshBody ) ;
}
}
private void stopDetecting ( UIButton detectButton ) {
private void stopDetecting ( UIButton detectButton ) {
@ -251,7 +258,7 @@ public class EnvDetectorDialog extends JDialog {
// 刷新按钮
// 刷新按钮
detectButton . setText ( buttonStatus . getDesc ( ) ) ;
detectButton . setText ( buttonStatus . getDesc ( ) ) ;
// 刷新面板
// 刷新面板
refresh ( ) ;
refreshBody ( ) ;
} ) ;
} ) ;
}
}
@ -265,7 +272,7 @@ public class EnvDetectorDialog extends JDialog {
this . resultSummaryPane . setLayout ( new BorderLayout ( 5 , 0 ) ) ;
this . resultSummaryPane . setLayout ( new BorderLayout ( 5 , 0 ) ) ;
Boolean success = model . getResults ( )
Boolean success = model . getResults ( )
. map ( ( e ) - > {
. map ( ( e ) - > {
if ( e . getStatus ( ) = = DetectorStatus . NORMAL ) {
if ( e ! = null & & e . getStatus ( ) = = DetectorStatus . NORMAL ) {
return Boolean . TRUE ;
return Boolean . TRUE ;
}
}
return Boolean . FALSE ;
return Boolean . FALSE ;
@ -361,11 +368,13 @@ public class EnvDetectorDialog extends JDialog {
}
}
statusPanel . add ( infoPanel , BorderLayout . WEST ) ;
statusPanel . add ( infoPanel , BorderLayout . WEST ) ;
// 如果结果是检测出的异常,则出现详细信息。
if ( result . getStatus ( ) = = DetectorStatus . EXCEPTION ) {
JPanel detailPanel = FRGUIPaneFactory . createBorderLayout_S_Pane ( ) ;
JPanel detailPanel = FRGUIPaneFactory . createBorderLayout_S_Pane ( ) ;
{
{
detailPanel . setBorder ( BorderFactory . createEmptyBorder ( 0 , 10 , 0 , 0 ) ) ;
detailPanel . setBorder ( BorderFactory . createEmptyBorder ( 0 , 10 , 0 , 0 ) ) ;
UILabel detailLabel = new UILabel ( Toolkit . i18nText ( "Fine_Designer_Look_Detail" ) ) ;
UILabel detailLabel = new UILabel ( Toolkit . i18nText ( "Fine_Designer_Look_Detail" ) ) ;
detailLabel . setForeground ( new Color ( 65 , 155 , 249 ) ) ;
detailLabel . setForeground ( DETAIL_FONT_COLOR ) ;
detailLabel . addMouseListener ( new MouseAdapter ( ) {
detailLabel . addMouseListener ( new MouseAdapter ( ) {
@Override
@Override
public void mouseClicked ( MouseEvent mouseEvent ) {
public void mouseClicked ( MouseEvent mouseEvent ) {
@ -383,9 +392,10 @@ public class EnvDetectorDialog extends JDialog {
} ) ;
} ) ;
detailPanel . add ( detailLabel , BorderLayout . CENTER ) ;
detailPanel . add ( detailLabel , BorderLayout . CENTER ) ;
}
}
statusPanel . add ( detailPanel , BorderLayout . CENTER ) ;
statusPanel . add ( detailPanel , BorderLayout . CENTER ) ;
}
}
}
return statusPanel ;
return statusPanel ;
}
}
@ -434,14 +444,14 @@ public class EnvDetectorDialog extends JDialog {
return tailPanel ;
return tailPanel ;
}
}
private void refreshHeaderPanel ( ) {
private void refreshHeader ( ) {
updateHeaderPanel ( ) ;
updateHeaderPanel ( ) ;
pack ( ) ;
pack ( ) ;
repaint ( ) ;
repaint ( ) ;
}
}
private void refresh ( ) {
private void refreshBody ( ) {
updateTable ( this . tablePanel ) ;
updateTable ( this . tablePanel ) ;
pack ( ) ;
pack ( ) ;