25
25
import javafx .scene .layout .VBox ;
26
26
import lombok .extern .slf4j .Slf4j ;
27
27
import org .code4everything .boot .base .FileUtils ;
28
+ import org .code4everything .boot .base .constant .StringConsts ;
28
29
import org .code4everything .wetool .WeApplication ;
29
30
import org .code4everything .wetool .constant .FileConsts ;
30
31
import org .code4everything .wetool .constant .TipConsts ;
@@ -119,7 +120,7 @@ public static void registerAction(String name, EventHandler<ActionEvent> eventHa
119
120
name = StrUtil .trim (name );
120
121
Preconditions .checkArgument (StrUtil .isNotBlank (name ), "action name must not be blank" );
121
122
ACTION_MAP .put (name , eventHandler );
122
- if (name .endsWith ("*" )) {
123
+ if (name .endsWith (StringConsts . Sign . STAR )) {
123
124
return ;
124
125
}
125
126
String pinyin = PinyinUtil .getPinyin (name );
@@ -185,7 +186,9 @@ public void handleEvent0(String s, Date date) {
185
186
registerAction ("插件仓库-pluginrepository" , actionEvent -> FxUtils .openLink (TipConsts .REPO_LINK ));
186
187
187
188
// 注册模式匹配动作
188
- registerAction ("hutool*" , this ::runHutoolCmd );
189
+ EventHandler <ActionEvent > runHutoolCmd = this ::runHutoolCmd ;
190
+ registerAction ("hutool*" , runHutoolCmd );
191
+ registerAction ("*" , runHutoolCmd );
189
192
registerAction ("file-browser*" , HttpFileBrowserService .getInstance ());
190
193
registerAction ("env*" , a -> {
191
194
String name = StrUtil .removePrefix (a .getSource ().toString (), "env" ).trim ();
@@ -579,7 +582,7 @@ public void toolBoxKeyReleased(KeyEvent keyEvent) {
579
582
toolSearchBox .getItems ().clear ();
580
583
String [] tokenizer = StrUtil .splitTrim (keyword , " " ).toArray (new String [0 ]);
581
584
ACTION_MAP .forEach ((k , v ) -> {
582
- if (k .endsWith ("*" )) {
585
+ if (k .endsWith (StringConsts . Sign . STAR )) {
583
586
// 模式匹配,不适用下拉框提示
584
587
return ;
585
588
}
@@ -605,21 +608,24 @@ private EventHandler<ActionEvent> getActionEventEventHandler(String keyword, Str
605
608
606
609
// 模式匹配
607
610
return actionCache .get (keyword , () -> {
611
+ EventHandler <ActionEvent > handler = null ;
608
612
for (Map .Entry <String , EventHandler <ActionEvent >> entry : ACTION_MAP .entrySet ()) {
609
613
String key = entry .getKey ();
610
- if (!key .endsWith ("*" )) {
614
+ if (!key .endsWith (StringConsts .Sign .STAR )) {
615
+ continue ;
616
+ }
617
+
618
+ if (key .equals (StringConsts .Sign .STAR )) {
619
+ handler = entry .getValue ();
611
620
continue ;
612
621
}
613
622
614
623
key = key .substring (0 , key .length () - 1 );
615
- if (keyword .startsWith (key )) {
616
- EventHandler <ActionEvent > handler = entry .getValue ();
617
- if (Objects .nonNull (handler )) {
618
- return handler ;
619
- }
624
+ if (keyword .startsWith (key ) && Objects .nonNull (entry .getValue ())) {
625
+ return entry .getValue ();
620
626
}
621
627
}
622
- return null ;
628
+ return handler ;
623
629
});
624
630
}
625
631
0 commit comments