81
81
82
82
public class SettingsFrame {
83
83
private Set <String > cacheSet ;
84
- private boolean isFramePrepared = false ;
84
+ private volatile boolean isFramePrepared = false ;
85
85
private boolean isSuffixChanged = false ;
86
86
private static volatile int tmp_copyPathKeyCode ;
87
87
private static volatile int tmp_runAsAdminKeyCode ;
@@ -91,7 +91,7 @@ public class SettingsFrame {
91
91
private static final TranslateService translateService = TranslateService .getInstance ();
92
92
private static final EventManagement eventManagement = EventManagement .getInstance ();
93
93
private static final AllConfigs allConfigs = AllConfigs .getInstance ();
94
- private static final ThreadPoolUtil THREAD_POOL_UTIL = ThreadPoolUtil .getInstance ();
94
+ private static final ThreadPoolUtil threadPoolUtil = ThreadPoolUtil .getInstance ();
95
95
private final HashMap <TabNameAndTitle , Component > tabComponentNameMap = new HashMap <>();
96
96
private Map <String , String > cudaDeviceMap = new HashMap <>();
97
97
private HashMap <String , Integer > suffixMap ;
@@ -382,7 +382,7 @@ private void addButtonRemoveDesktopListener() {
382
382
}
383
383
int isConfirmed = JOptionPane .showConfirmDialog (frame , translateService .getTranslation ("Whether to remove and backup all files on the desktop," + "they will be in the program's Files folder, which may take a few minutes" ));
384
384
if (isConfirmed == JOptionPane .YES_OPTION ) {
385
- Future <Boolean > future = THREAD_POOL_UTIL .executeTask (MoveDesktopFilesUtil ::start , true );
385
+ Future <Boolean > future = threadPoolUtil .executeTask (MoveDesktopFilesUtil ::start , true );
386
386
try {
387
387
if (future == null ) {
388
388
return ;
@@ -641,7 +641,7 @@ private void addCheckForUpdateButtonListener() {
641
641
downloadManager .newJar = new DownloadManager ((String ) updateInfo .get ("url64" ), Constants .FILE_NAME , new File ("tmp" ).getAbsolutePath ());
642
642
downloadManager .newLauncher = new DownloadManager ((String ) updateInfo .get ("urlLauncher" ), Constants .LAUNCH_WRAPPER_NAME , new File ("tmp" ).getAbsolutePath ());
643
643
eventManagement .putEvent (new StartDownloadEvent (downloadManager .newLauncher ));
644
- THREAD_POOL_UTIL .executeTask (() -> {
644
+ threadPoolUtil .executeTask (() -> {
645
645
try {
646
646
if (!downloadManager .newLauncher .waitFor (10 * 60 * 1000 )) {
647
647
return ;
@@ -654,7 +654,7 @@ private void addCheckForUpdateButtonListener() {
654
654
}
655
655
});
656
656
eventManagement .putEvent (new StartDownloadEvent (downloadManager .newJar ));
657
- THREAD_POOL_UTIL .executeTask (() -> {
657
+ threadPoolUtil .executeTask (() -> {
658
658
boolean isDownloadSuccess = SetDownloadProgress .setProgress (labelDownloadProgress ,
659
659
buttonCheckUpdate ,
660
660
downloadManager .newLauncher ,
@@ -745,6 +745,7 @@ private void addResetColorButtonListener() {
745
745
* @param max 最大值
746
746
* @return boolean
747
747
*/
748
+ @ SuppressWarnings ("BooleanMethodIsAlwaysInverted" )
748
749
private boolean canParseInteger (String str , int min , int max ) {
749
750
try {
750
751
int ret = Integer .parseInt (str );
@@ -812,7 +813,7 @@ private void setColorChooserLabel(Color color, JLabel label) {
812
813
* 实时监测textField中保存的颜色信息,并尝试更新label
813
814
*/
814
815
private void addColorChooserLabelListener () {
815
- THREAD_POOL_UTIL .executeTask (() -> {
816
+ threadPoolUtil .executeTask (() -> {
816
817
try {
817
818
Color labelColor ;
818
819
Color fontColorWithCoverage ;
@@ -1074,7 +1075,7 @@ private void addButtonVacuumListener() {
1074
1075
System .out .println ("开始优化" );
1075
1076
}
1076
1077
eventManagement .putEvent (new OptimiseDatabaseEvent ());
1077
- THREAD_POOL_UTIL .executeTask (() -> {
1078
+ threadPoolUtil .executeTask (() -> {
1078
1079
//实时显示VACUUM状态
1079
1080
try {
1080
1081
DatabaseService instance = DatabaseService .getInstance ();
@@ -1995,7 +1996,7 @@ private void addButtonPreviewListener() {
1995
1996
buttonPreviewColor .addActionListener (e -> {
1996
1997
PreviewStatus .isPreview = true ;
1997
1998
eventManagement .putEvent (new StartPreviewEvent ());
1998
- THREAD_POOL_UTIL .executeTask (() -> {
1999
+ threadPoolUtil .executeTask (() -> {
1999
2000
try {
2000
2001
String borderColor ;
2001
2002
String searchBarColor ;
@@ -2016,7 +2017,16 @@ private void addButtonPreviewListener() {
2016
2017
defaultBackgroundColor = textFieldBackgroundDefault .getText ();
2017
2018
borderThickness = textFieldBorderThickness .getText ();
2018
2019
borderType = (Constants .Enums .BorderType ) comboBoxBorderType .getSelectedItem ();
2019
- if (canParseToRGB (borderColor ) && canParseToRGB (searchBarColor ) && canParseToRGB (searchBarFontColor ) && canParseToRGB (labelColor ) && canParseToRGB (fontColorCoverage ) && canParseToRGB (fontColor ) && canParseToRGB (defaultBackgroundColor ) && canParseInteger (borderThickness , 1 , 5 )) {
2020
+ if (
2021
+ canParseToRGB (borderColor ) &&
2022
+ canParseToRGB (searchBarColor ) &&
2023
+ canParseToRGB (searchBarFontColor ) &&
2024
+ canParseToRGB (labelColor ) &&
2025
+ canParseToRGB (fontColorCoverage ) &&
2026
+ canParseToRGB (fontColor ) &&
2027
+ canParseToRGB (defaultBackgroundColor ) &&
2028
+ canParseFloat (borderThickness , 0 , 4 )
2029
+ ) {
2020
2030
eventManagement .putEvent (new PreviewSearchBarEvent (borderColor , searchBarColor , searchBarFontColor , labelColor , fontColorCoverage , fontColor , defaultBackgroundColor , borderType , borderThickness ));
2021
2031
}
2022
2032
TimeUnit .SECONDS .sleep (1 );
@@ -2502,7 +2512,7 @@ private void addButtonPluginUpdateCheckListener() {
2502
2512
eventManagement .putEvent (new StartDownloadEvent (downloadManagerContainer .downloadManager ));
2503
2513
pluginInfoMap .put (pluginName , downloadManagerContainer .downloadManager );
2504
2514
DownloadManager finalDownloadManager = downloadManagerContainer .downloadManager ;
2505
- THREAD_POOL_UTIL .executeTask (() ->
2515
+ threadPoolUtil .executeTask (() ->
2506
2516
SetDownloadProgress .setProgress (labelProgress ,
2507
2517
buttonUpdatePlugin ,
2508
2518
finalDownloadManager ,
@@ -3149,7 +3159,7 @@ private static void showSettingsFrameEvent(Event event) {
3149
3159
} else {
3150
3160
settingsFrame .showWindow (showSettingsFrameEvent .showTabName );
3151
3161
}
3152
- THREAD_POOL_UTIL .executeTask (() -> {
3162
+ threadPoolUtil .executeTask (() -> {
3153
3163
try {
3154
3164
final long startVisible = System .currentTimeMillis ();
3155
3165
while (SettingsFrame .frame .isVisible () || System .currentTimeMillis () - startVisible < 3000 ) {
0 commit comments