1+ package com .xwintop .xJavaFxTool .controller .epmsTools .gatewayConfTool ;
2+
3+ import com .easipass .gateway .filter .bean .FilterConfig ;
4+ import com .easipass .gateway .receiver .entity .ReceiverConfig ;
5+ import com .easipass .gateway .route .entity .SenderConfig ;
6+ import com .jfoenix .controls .JFXCheckBox ;
7+ import com .xwintop .xJavaFxTool .controller .IndexController ;
8+ import com .xwintop .xJavaFxTool .services .epmsTools .gatewayConfTool .GatewayConfToolServiceViewService ;
9+ import com .xwintop .xJavaFxTool .utils .JavaFxViewUtil ;
10+ import com .xwintop .xJavaFxTool .view .epmsTools .gatewayConfTool .GatewayConfToolServiceViewView ;
11+ import javafx .collections .FXCollections ;
12+ import javafx .collections .ObservableList ;
13+ import javafx .event .ActionEvent ;
14+ import javafx .fxml .FXML ;
15+ import javafx .fxml .FXMLLoader ;
16+ import javafx .scene .control .*;
17+ import javafx .scene .paint .Color ;
18+ import lombok .Getter ;
19+ import lombok .Setter ;
20+ import lombok .extern .slf4j .Slf4j ;
21+
22+ import java .lang .reflect .Field ;
23+ import java .net .URL ;
24+ import java .util .HashMap ;
25+ import java .util .List ;
26+ import java .util .Map ;
27+ import java .util .ResourceBundle ;
28+
29+ @ Getter
30+ @ Setter
31+ @ Slf4j
32+ public class GatewayConfToolServiceViewController extends GatewayConfToolServiceViewView {
33+ private GatewayConfToolServiceViewService gatewayConfToolServiceViewService = new GatewayConfToolServiceViewService (this );
34+
35+ private GatewayConfToolTaskViewController gatewayConfToolTaskViewController ;
36+ private String tabName ;
37+
38+ public static FXMLLoader getFXMLLoader () {
39+ FXMLLoader fXMLLoader = new FXMLLoader (IndexController .class .getResource ("/com/xwintop/xJavaFxTool/fxmlView/epmsTools/gatewayConfTool/GatewayConfToolServiceView.fxml" ));
40+ return fXMLLoader ;
41+ }
42+
43+ @ Override
44+ public void initialize (URL location , ResourceBundle resources ) {
45+ initView ();
46+ initEvent ();
47+ initService ();
48+ }
49+
50+ private void initView () {
51+ }
52+
53+ private void initEvent () {
54+ }
55+
56+ private void initService () {
57+ }
58+
59+ @ FXML
60+ private void saveAction (ActionEvent event ) {
61+ }
62+
63+ public void setData (GatewayConfToolTaskViewController gatewayConfToolTaskViewController , Object configObject ) {
64+ this .gatewayConfToolTaskViewController = gatewayConfToolTaskViewController ;
65+ for (Field field : configObject .getClass ().getDeclaredFields ()) {
66+ field .setAccessible (true );
67+ try {
68+ if (field .getType () == String .class ) {
69+ Label label = new Label (field .getName () + ":" );
70+ label .setTextFill (Color .RED );
71+ serviceViewFlowPane .getChildren ().add (label );
72+ TextField textField = new TextField (field .get (configObject ) == null ? "" : field .get (configObject ).toString ());
73+ if ("serviceName" .equals (field .getName ())){
74+ textField .setEditable (false );
75+ }
76+ serviceViewFlowPane .getChildren ().add (textField );
77+ } else if (field .getType () == Boolean .class || field .getType () == boolean .class ) {
78+ JFXCheckBox checkBox = new JFXCheckBox (field .getName ());
79+ checkBox .setSelected (field .getBoolean (configObject ));
80+ serviceViewFlowPane .getChildren ().add (checkBox );
81+ } else if (field .getType () == int .class || field .getType () == long .class ) {
82+ Label label = new Label (field .getName () + ":" );
83+ label .setTextFill (Color .RED );
84+ serviceViewFlowPane .getChildren ().add (label );
85+ Spinner <Integer > spinner = new Spinner <>();
86+ JavaFxViewUtil .setSpinnerValueFactory (spinner , Integer .MIN_VALUE , Integer .MAX_VALUE , Integer .valueOf (field .get (configObject ).toString ()));
87+ spinner .setEditable (true );
88+ serviceViewFlowPane .getChildren ().add (spinner );
89+ } else if (field .getType () == Map .class ) {
90+ Label label = new Label (field .getName () + ":" );
91+ label .setTextFill (Color .RED );
92+ serviceViewFlowPane .getChildren ().add (label );
93+ TableView <Map <String , String >> propertiesTableView = new TableView <>();
94+ propertiesTableView .setColumnResizePolicy (TableView .CONSTRAINED_RESIZE_POLICY );
95+ propertiesTableView .setPrefHeight (160 );
96+ TableColumn <Map <String , String >, String > propertiesKeyTableColumn = new TableColumn <>("key" );
97+ TableColumn <Map <String , String >, String > propertiesValueTableColumn = new TableColumn <>("value" );
98+ propertiesTableView .getColumns ().add (propertiesKeyTableColumn );
99+ propertiesTableView .getColumns ().add (propertiesValueTableColumn );
100+ JavaFxViewUtil .setTableColumnMapValueFactory (propertiesKeyTableColumn , "key" );
101+ JavaFxViewUtil .setTableColumnMapValueFactory (propertiesValueTableColumn , "value" );
102+ ObservableList <Map <String , String >> propertiesTableData = FXCollections .observableArrayList ();
103+ propertiesTableView .setItems (propertiesTableData );
104+ ((Map ) field .get (configObject )).forEach ((key , value ) -> {
105+ Map <String , String > map = new HashMap <>();
106+ map .put ("key" , key .toString ());
107+ map .put ("value" , value .toString ());
108+ propertiesTableData .add (map );
109+ });
110+ JavaFxViewUtil .addTableViewOnMouseRightClickMenu (propertiesTableView );
111+ serviceViewFlowPane .getChildren ().add (propertiesTableView );
112+ } else if (field .getType () == List .class ) {
113+ Label label = new Label (field .getName () + ":" );
114+ label .setTextFill (Color .RED );
115+ serviceViewFlowPane .getChildren ().add (label );
116+ ListView <String > listView = new ListView <>();
117+ listView .setPrefHeight (160 );
118+ ObservableList <String > listData = FXCollections .observableArrayList ();
119+ listView .setItems (listData );
120+ listData .addAll ((List ) field .get (configObject ));
121+ JavaFxViewUtil .addListViewOnMouseRightClickMenu (listView );
122+ serviceViewFlowPane .getChildren ().add (listView );
123+ } else {
124+ Label label = new Label (field .getName () + ":" );
125+ label .setTextFill (Color .RED );
126+ serviceViewFlowPane .getChildren ().add (label );
127+ TextField textField = new TextField (field .get (configObject ) == null ? "" : field .get (configObject ).toString ());
128+ serviceViewFlowPane .getChildren ().add (textField );
129+ }
130+ // FieldUtils.readField(field, configObject, true);
131+ } catch (IllegalAccessException e ) {
132+ e .printStackTrace ();
133+ }
134+ }
135+ if (configObject instanceof ReceiverConfig ) {
136+ } else if (configObject instanceof FilterConfig ) {
137+ } else if (configObject instanceof SenderConfig ) {
138+ }
139+ }
140+ }
0 commit comments