@@ -95,7 +95,43 @@ private void initEvent() {
9595 contextMenu .getItems ().add (menu_tab );
9696 contextMenu .show (hostTextField , null , 0 , hostTextField .getHeight ());
9797 });
98- // configurationTreeView.setEditable(true);
98+
99+ selectTextField .textProperty ().addListener ((observable , oldValue , newValue ) -> {
100+ if (contextMenu .isShowing ()) {
101+ contextMenu .hide ();
102+ }
103+ contextMenu .getItems ().clear ();
104+ for (Map .Entry <String , String > stringStringEntry : transferToolService .getTaskConfigFileStringMap ().entrySet ()) {
105+ if (stringStringEntry .getValue ().contains (newValue )) {
106+ Map <String , TaskConfig > taskConfigMap = transferToolService .getTaskConfigFileMap ().get (stringStringEntry .getKey ());
107+ if (taskConfigMap != null && !taskConfigMap .isEmpty ()) {
108+ for (Map .Entry <String , TaskConfig > stringTaskConfigEntry : taskConfigMap .entrySet ()) {
109+ if (stringTaskConfigEntry .getValue ().toString ().contains (newValue )) {
110+ MenuItem menu_tab = new MenuItem (stringTaskConfigEntry .getKey ());
111+ menu_tab .setOnAction (event1 -> {
112+ transferToolService .addTaskConfigTabPane (stringStringEntry .getKey (), stringTaskConfigEntry .getKey ());
113+ });
114+ contextMenu .getItems ().add (menu_tab );
115+ }
116+ }
117+ }
118+ Map <String , DataSourceConfigDruid > dataSourceConfigDruidMap = transferToolService .getDataSourceConfigFileMap ().get (stringStringEntry .getKey ());
119+ if (dataSourceConfigDruidMap != null && !dataSourceConfigDruidMap .isEmpty ()) {
120+ for (Map .Entry <String , DataSourceConfigDruid > stringDataSourceConfigDruidEntry : dataSourceConfigDruidMap .entrySet ()) {
121+ if (stringDataSourceConfigDruidEntry .getValue ().toString ().contains (newValue )) {
122+ MenuItem menu_tab = new MenuItem (stringDataSourceConfigDruidEntry .getKey ());
123+ menu_tab .setOnAction (event1 -> {
124+ transferToolService .addTaskConfigTabPane (stringStringEntry .getKey (), stringDataSourceConfigDruidEntry .getKey ());
125+ });
126+ contextMenu .getItems ().add (menu_tab );
127+ }
128+ }
129+ }
130+ }
131+ }
132+ contextMenu .show (selectTextField , null , 0 , selectTextField .getHeight ());
133+ });
134+
99135 configurationTreeView .setCellFactory (TextFieldTreeCell .forTreeView ());
100136 configurationTreeView .setOnMouseClicked (event -> {
101137 TreeItem <String > selectedItem = configurationTreeView .getSelectionModel ().getSelectedItem ();
@@ -122,7 +158,6 @@ private void initEvent() {
122158 });
123159 MenuItem menu_FoldAll = new MenuItem ("折叠所有" );
124160 menu_FoldAll .setOnAction (event1 -> {
125- // configurationTreeView.getRoot().setExpanded(false);
126161 configurationTreeView .getRoot ().getChildren ().forEach (stringTreeItem -> {
127162 stringTreeItem .setExpanded (false );
128163 });
@@ -262,7 +297,6 @@ private void initEvent() {
262297 String taskConfigString = ClipboardUtil .getStr ();
263298 try {
264299 TaskConfig taskConfig = new Yaml ().load (taskConfigString );
265- // String taskConfigName = taskConfig.getName() + "_copy";
266300 String taskConfigName = StringUtils .appendIfMissing (taskConfig .getName (), "_copy" , "_copy" );
267301 while (transferToolService .getTaskConfigFileMap ().get (selectedItem .getValue ()).containsKey (taskConfigName )) {
268302 String [] copyName = taskConfigName .split ("_copy" );
0 commit comments