@@ -323,7 +323,9 @@ public void setValueAt(Object value, int row, int col) {
323323 String valueStr = ((String ) value ).trim ();
324324 entry .setComments (new HashSet <>(Arrays .asList (valueStr .split ("," ))));
325325 titleDao .addOrUpdateTitle (entry );//写入数据库
326- fireTableCellUpdated (row , col );
326+ SwingUtilities .invokeLater (() -> {
327+ fireTableRowsUpdated (row , col );
328+ });
327329 }
328330 }
329331 //////////////////////^^^extend AbstractTableModel^^^////////////////////////////////
@@ -660,7 +662,10 @@ public void updateIconHashes(int[] rows) {
660662 for (int i =rows .length -1 ;i >=0 ;i -- ) {//降序删除才能正确删除每个元素
661663 LineEntry entry = lineEntries .get (rows [i ]);
662664 entry .DoGetIconHash ();
663- this .fireTableRowsUpdated (rows [i ], rows [i ]);
665+ int index = rows [i ];
666+ SwingUtilities .invokeLater (() -> {
667+ fireTableRowsUpdated (index , index );
668+ });
664669 titleDao .addOrUpdateTitle (entry );//写入数据库
665670 }
666671 }
@@ -693,7 +698,9 @@ public void removeRows(int[] rows) {
693698 lineEntries .remove (index );
694699 titleDao .deleteTitleByUrl (url );//写入数据库
695700 stdout .println ("!!! " +url +" deleted" );
696- this .fireTableRowsDeleted (index ,index );
701+ SwingUtilities .invokeLater (() -> {
702+ fireTableRowsDeleted (index , index );
703+ });
697704 } catch (Exception e ) {
698705 e .printStackTrace (stderr );
699706 }
@@ -710,7 +717,10 @@ public void removeRow(int row) {
710717 lineEntries .remove (row );
711718 titleDao .deleteTitleByUrl (url );//写入数据库
712719 stdout .println ("!!! " +url +" deleted" );
713- this .fireTableRowsDeleted (row ,row );
720+
721+ SwingUtilities .invokeLater (() -> {
722+ fireTableRowsDeleted (row , row );
723+ });
714724 } catch (Exception e ) {
715725 e .printStackTrace (stderr );
716726 }
@@ -755,7 +765,10 @@ public void MarkNotTargetRows() {
755765
756766 entry .addComment ("Non-Target[host is not target]" );
757767 titleDao .addOrUpdateTitle (entry );//写入数据库
758- this .fireTableRowsUpdated (i , i );
768+ int index = i ;
769+ SwingUtilities .invokeLater (() -> {
770+ fireTableRowsUpdated (index , index );
771+ });
759772
760773 continue ;
761774 }
@@ -781,7 +794,10 @@ public void MarkNotTargetRows() {
781794
782795 entry .addComment ("Non-Target[cert domain is not target]" );
783796 titleDao .addOrUpdateTitle (entry );//写入数据库
784- this .fireTableRowsUpdated (i , i );
797+ int index = i ;
798+ SwingUtilities .invokeLater (() -> {
799+ fireTableRowsUpdated (index , index );
800+ });
785801
786802 continue ;
787803 }
@@ -793,7 +809,11 @@ public void MarkNotTargetRows() {
793809
794810 entry .addComment ("Non-Target[host IP not in custom assets]" );
795811 titleDao .addOrUpdateTitle (entry );//写入数据库
796- this .fireTableRowsUpdated (i , i );
812+
813+ int index = i ;
814+ SwingUtilities .invokeLater (() -> {
815+ fireTableRowsUpdated (index , index );
816+ });
797817
798818 continue ;
799819 }
@@ -822,7 +842,10 @@ public void removeRowsNotInTargets() {
822842 lineEntries .remove (i );
823843 titleDao .deleteTitleByUrl (url );//写入数据库
824844 stdout .println ("!!! " +url +" deleted, due to : " +entry .getComments ().toString ());
825- this .fireTableRowsDeleted (i ,i );
845+ int index = i ;
846+ SwingUtilities .invokeLater (() -> {
847+ fireTableRowsDeleted (index , index );
848+ });
826849 }
827850
828851 } catch (Exception e ) {
@@ -863,7 +886,9 @@ public void updateRowsStatus(int[] rows,String status) {
863886 }
864887 titleDao .addOrUpdateTitle (entry );//写入数据库
865888 stdout .println ("$$$ " +entry .getUrl ()+" updated" );
866- this .fireTableRowsUpdated (index , index );
889+ SwingUtilities .invokeLater (() -> {
890+ fireTableRowsUpdated (index , index );
891+ });
867892 } catch (Exception e ) {
868893 e .printStackTrace (stderr );
869894 }
@@ -884,7 +909,9 @@ public void updateAssetTypeOfRows(int[] rows,String assetType) {
884909 entry .setAssetType (assetType );
885910 titleDao .addOrUpdateTitle (entry );//写入数据库
886911 stdout .println (String .format ("$$$ %s updated [AssetType-->%s]" ,entry .getUrl (),assetType ));
887- this .fireTableRowsUpdated (index , index );
912+ SwingUtilities .invokeLater (() -> {
913+ fireTableRowsUpdated (index , index );
914+ });
888915 } catch (Exception e ) {
889916 e .printStackTrace (stderr );
890917 }
@@ -906,7 +933,9 @@ public void updateComments(int[] rows, String commentAdd) {
906933 entry .addComment (commentAdd );
907934 titleDao .addOrUpdateTitle (entry );//写入数据库
908935 stdout .println ("$$$ " +entry .getUrl ()+" updated" );
909- this .fireTableRowsUpdated (index , index );
936+ SwingUtilities .invokeLater (() -> {
937+ fireTableRowsUpdated (index , index );
938+ });
910939 } catch (Exception e ) {
911940 e .printStackTrace (stderr );
912941 }
@@ -928,7 +957,9 @@ public void clearComments(int[] rows) {
928957 entry .getComments ().clear ();
929958 titleDao .addOrUpdateTitle (entry );//写入数据库
930959 stdout .println ("$$$ " +entry .getUrl ()+" updated" );
931- this .fireTableRowsUpdated (index , index );
960+ SwingUtilities .invokeLater (() -> {
961+ fireTableRowsUpdated (index , index );
962+ });
932963 } catch (Exception e ) {
933964 e .printStackTrace (stderr );
934965 }
@@ -949,7 +980,9 @@ public void freshASNInfo(int[] rows) {
949980 entry .freshASNInfo ();
950981 titleDao .addOrUpdateTitle (entry );//写入数据库
951982 stdout .println ("$$$ " +entry .getUrl ()+"ASN Info updated" );
952- this .fireTableRowsUpdated (index , index );
983+ SwingUtilities .invokeLater (() -> {
984+ fireTableRowsUpdated (index , index );
985+ });
953986 } catch (Exception e ) {
954987 e .printStackTrace (stderr );
955988 }
@@ -1017,27 +1050,6 @@ public HashSet<String> getDomainsForBypassCheck(){
10171050 return tmp ;
10181051 }
10191052
1020- //为了同时fire多个不连续的行,自行实现这个方法。
1021- @ Deprecated
1022- private void fireDeleted (int [] rows ) {
1023- List <int []> slice = IntArraySlice .slice (rows );
1024- //必须逆序,从高位index开始删除,否则删除的对象和预期不一致!!!
1025- //上面得到的顺序就是从高位开始的
1026- for (int [] sli :slice ) {
1027- System .out .println (Arrays .toString (sli ));
1028- this .fireTableRowsDeleted (sli [sli .length -1 ],sli [0 ]);//这里传入的值必须是低位数在前面,高位数在后面
1029- }
1030- }
1031-
1032- @ Deprecated
1033- private void fireUpdated (int [] rows ) {
1034- List <int []> slice = IntArraySlice .slice (rows );
1035- for (int [] sli :slice ) {
1036- System .out .println (Arrays .toString (sli ));
1037- this .fireTableRowsUpdated (sli [sli .length -1 ],sli [0 ]);//同上,修复更新多个记录时的错误
1038- }
1039- }
1040-
10411053
10421054 ///////////////////^^^多个行内容的增删查改^^^/////////////////////////////////
10431055
@@ -1177,7 +1189,9 @@ public void freshAllASNInfo(){
11771189 for (LineEntry entry : lineEntries .values ()) {
11781190 entry .freshASNInfo ();
11791191 }
1180- fireTableRowsUpdated (0 ,lineEntries .size ()-1 );
1192+ SwingUtilities .invokeLater (() -> {
1193+ fireTableRowsUpdated (0 ,lineEntries .size ()-1 );//有毫秒级时间戳,只会是新增
1194+ });
11811195 }
11821196
11831197
@@ -1226,7 +1240,11 @@ public void markFullSameEntries(LineEntry entry) {//
12261240
12271241 value .addComment ("duplicateItem" );
12281242 value .setCheckStatus (LineEntry .CheckStatus_Checked );
1229- fireTableRowsUpdated (i ,i );//主动通知更新,否则不会写入数据库!!!
1243+
1244+ int index = i ;
1245+ SwingUtilities .invokeLater (() -> {
1246+ fireTableRowsUpdated (index ,index );//主动通知更新,否则不会写入数据库!!!
1247+ });
12301248 }
12311249 }
12321250}
0 commit comments