8181
8282public class SettingsFrame {
8383 private Set <String > cacheSet ;
84- private boolean isFramePrepared = false ;
84+ private volatile boolean isFramePrepared = false ;
8585 private boolean isSuffixChanged = false ;
8686 private static volatile int tmp_copyPathKeyCode ;
8787 private static volatile int tmp_runAsAdminKeyCode ;
@@ -91,7 +91,7 @@ public class SettingsFrame {
9191 private static final TranslateService translateService = TranslateService .getInstance ();
9292 private static final EventManagement eventManagement = EventManagement .getInstance ();
9393 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 ();
9595 private final HashMap <TabNameAndTitle , Component > tabComponentNameMap = new HashMap <>();
9696 private Map <String , String > cudaDeviceMap = new HashMap <>();
9797 private HashMap <String , Integer > suffixMap ;
@@ -382,7 +382,7 @@ private void addButtonRemoveDesktopListener() {
382382 }
383383 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" ));
384384 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 );
386386 try {
387387 if (future == null ) {
388388 return ;
@@ -641,7 +641,7 @@ private void addCheckForUpdateButtonListener() {
641641 downloadManager .newJar = new DownloadManager ((String ) updateInfo .get ("url64" ), Constants .FILE_NAME , new File ("tmp" ).getAbsolutePath ());
642642 downloadManager .newLauncher = new DownloadManager ((String ) updateInfo .get ("urlLauncher" ), Constants .LAUNCH_WRAPPER_NAME , new File ("tmp" ).getAbsolutePath ());
643643 eventManagement .putEvent (new StartDownloadEvent (downloadManager .newLauncher ));
644- THREAD_POOL_UTIL .executeTask (() -> {
644+ threadPoolUtil .executeTask (() -> {
645645 try {
646646 if (!downloadManager .newLauncher .waitFor (10 * 60 * 1000 )) {
647647 return ;
@@ -654,7 +654,7 @@ private void addCheckForUpdateButtonListener() {
654654 }
655655 });
656656 eventManagement .putEvent (new StartDownloadEvent (downloadManager .newJar ));
657- THREAD_POOL_UTIL .executeTask (() -> {
657+ threadPoolUtil .executeTask (() -> {
658658 boolean isDownloadSuccess = SetDownloadProgress .setProgress (labelDownloadProgress ,
659659 buttonCheckUpdate ,
660660 downloadManager .newLauncher ,
@@ -745,6 +745,7 @@ private void addResetColorButtonListener() {
745745 * @param max 最大值
746746 * @return boolean
747747 */
748+ @ SuppressWarnings ("BooleanMethodIsAlwaysInverted" )
748749 private boolean canParseInteger (String str , int min , int max ) {
749750 try {
750751 int ret = Integer .parseInt (str );
@@ -812,7 +813,7 @@ private void setColorChooserLabel(Color color, JLabel label) {
812813 * 实时监测textField中保存的颜色信息,并尝试更新label
813814 */
814815 private void addColorChooserLabelListener () {
815- THREAD_POOL_UTIL .executeTask (() -> {
816+ threadPoolUtil .executeTask (() -> {
816817 try {
817818 Color labelColor ;
818819 Color fontColorWithCoverage ;
@@ -1074,7 +1075,7 @@ private void addButtonVacuumListener() {
10741075 System .out .println ("开始优化" );
10751076 }
10761077 eventManagement .putEvent (new OptimiseDatabaseEvent ());
1077- THREAD_POOL_UTIL .executeTask (() -> {
1078+ threadPoolUtil .executeTask (() -> {
10781079 //实时显示VACUUM状态
10791080 try {
10801081 DatabaseService instance = DatabaseService .getInstance ();
@@ -1995,7 +1996,7 @@ private void addButtonPreviewListener() {
19951996 buttonPreviewColor .addActionListener (e -> {
19961997 PreviewStatus .isPreview = true ;
19971998 eventManagement .putEvent (new StartPreviewEvent ());
1998- THREAD_POOL_UTIL .executeTask (() -> {
1999+ threadPoolUtil .executeTask (() -> {
19992000 try {
20002001 String borderColor ;
20012002 String searchBarColor ;
@@ -2016,7 +2017,16 @@ private void addButtonPreviewListener() {
20162017 defaultBackgroundColor = textFieldBackgroundDefault .getText ();
20172018 borderThickness = textFieldBorderThickness .getText ();
20182019 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+ ) {
20202030 eventManagement .putEvent (new PreviewSearchBarEvent (borderColor , searchBarColor , searchBarFontColor , labelColor , fontColorCoverage , fontColor , defaultBackgroundColor , borderType , borderThickness ));
20212031 }
20222032 TimeUnit .SECONDS .sleep (1 );
@@ -2502,7 +2512,7 @@ private void addButtonPluginUpdateCheckListener() {
25022512 eventManagement .putEvent (new StartDownloadEvent (downloadManagerContainer .downloadManager ));
25032513 pluginInfoMap .put (pluginName , downloadManagerContainer .downloadManager );
25042514 DownloadManager finalDownloadManager = downloadManagerContainer .downloadManager ;
2505- THREAD_POOL_UTIL .executeTask (() ->
2515+ threadPoolUtil .executeTask (() ->
25062516 SetDownloadProgress .setProgress (labelProgress ,
25072517 buttonUpdatePlugin ,
25082518 finalDownloadManager ,
@@ -3149,7 +3159,7 @@ private static void showSettingsFrameEvent(Event event) {
31493159 } else {
31503160 settingsFrame .showWindow (showSettingsFrameEvent .showTabName );
31513161 }
3152- THREAD_POOL_UTIL .executeTask (() -> {
3162+ threadPoolUtil .executeTask (() -> {
31533163 try {
31543164 final long startVisible = System .currentTimeMillis ();
31553165 while (SettingsFrame .frame .isVisible () || System .currentTimeMillis () - startVisible < 3000 ) {
0 commit comments