18048805296
2023-02-17 c03a1f6a18af7cf8cd5283c8edef5541da1666e3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package com.lx.product.seal.frame;
 
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
 
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
 
 
public class PathPanel extends JPanel {
    public String name="path_panel";
    Font ft =new Font("微软雅黑", Font.BOLD, 14);
    public JTextField  product_version_root = new JTextField ();
    public JTextField  install_project_root = new JTextField ();
    public JTextField  product_web_root = new JTextField ();
    public JTextField  product_java_root = new JTextField ();
    public JTextField  product_version = new JTextField ();
    private JFileChooser  path_select = new JFileChooser ();
    
    private JButton  product_version_button = new JButton ();
    private JButton  install_project_button = new JButton ();
    private JButton  product_web_button = new JButton ();
    private JButton  product_java_button = new JButton ();
    
 
    public PathPanel(MasterPanel f) {
        product_version_root.setFont(ft);
        install_project_root.setFont(ft);
        product_web_root.setFont(ft);
        product_java_root.setFont(ft);
        product_version.setFont(ft);
        path_select.setFont(ft);
        
        product_version_button.setFont(ft);
        install_project_button.setFont(ft);
        product_web_button.setFont(ft);
        product_java_button.setFont(ft);
        
        product_version_root.setPreferredSize(new Dimension(500, 30));
        install_project_root.setPreferredSize(new Dimension(500, 30));
        product_web_root.setPreferredSize(new Dimension(500, 30));
        product_java_root.setPreferredSize(new Dimension(500, 30));
        product_version.setPreferredSize(new Dimension(500, 30));
        path_select.setPreferredSize(new Dimension(500, 30));
        path_select.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY );
        product_version_button.setText("选择目录");
        product_version_button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(product_version_root.getText()!="")
                    path_select.setCurrentDirectory(new File(product_version_root.getText()));
                int result=path_select.showOpenDialog(product_version_button);
                if (result == JFileChooser.APPROVE_OPTION) {
                    // 如果点击了"保存", 则获取选择的保存路径
                    File file = path_select.getSelectedFile();
                    product_version_root.setText( file.getAbsolutePath());
                }
            }
        });
        install_project_button.setText("选择目录");
        install_project_button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(install_project_root.getText()!="")
                    path_select.setCurrentDirectory(new File(install_project_root.getText()));
                int result=path_select.showOpenDialog(install_project_button);
                if (result == JFileChooser.APPROVE_OPTION) {
                    // 如果点击了"保存", 则获取选择的保存路径
                    File file = path_select.getSelectedFile();
                    install_project_root.setText( file.getAbsolutePath());
                }
            }
        });
        product_web_button.setText("选择目录");
        product_web_button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(product_web_root.getText()!="")
                    path_select.setCurrentDirectory(new File(product_web_root.getText()));
                int result=path_select.showOpenDialog(product_web_button);
                if (result == JFileChooser.APPROVE_OPTION) {
                    // 如果点击了"保存", 则获取选择的保存路径
                    File file = path_select.getSelectedFile();
                    product_web_root.setText( file.getAbsolutePath());
                }
            }
        });
        product_java_button.setText("选择目录");
        product_java_button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(product_java_root.getText()!="")
                    path_select.setCurrentDirectory(new File(product_java_root.getText()));
                int result=path_select.showOpenDialog(product_java_button);
                if (result == JFileChooser.APPROVE_OPTION) {
                    // 如果点击了"保存", 则获取选择的保存路径
                    File file = path_select.getSelectedFile();
                    product_java_root.setText( file.getAbsolutePath());
                }
            }
        });
        GridBagLayout bg = new GridBagLayout();
        this.setLayout(bg);
        GridBagConstraints c = new GridBagConstraints();
        c.anchor = GridBagConstraints.WEST;
        c.insets = new Insets(2, 5, 2, 5);
        c.gridx = 0;
        c.gridy = 0;
        c.gridwidth = 2;
        c.gridheight = 1;
        c.weightx = 0;
        c.weighty = 0;
        JLabel sl = new JLabel();
        sl.setText("产品版本管理目录:");
        sl.setFont(ft);
        sl.setHorizontalAlignment(JLabel.LEFT);
        this.add(sl, c);
        
        c.gridy = 1;
        c.gridwidth = 1;
        product_version_root.setText(f.config.getProduct_version_root());
        this.add(product_version_root, c);
        c.gridx = 1;
        this.add(product_version_button, c);
        c.gridx = 0;
        
        c.gridwidth = 2;
        c.gridy = 2;
        this.add(new JLabel(" "), c);
        
        c.gridy = 3;
        JLabel l3= new JLabel("产品安装工程目录(product-server-install):");
        l3.setFont(ft);
        this.add(l3, c);
        c.gridwidth = 1;
        c.gridy = 4;
        install_project_root.setText(f.config.getInstall_project_root());
        this.add(install_project_root, c);
        c.gridx = 1;
        this.add(install_project_button, c);
        c.gridx = 0;
        c.gridwidth = 2;
        c.gridy = 5;
        this.add(new JLabel(" "), c);
        
        c.gridy = 6;
        JLabel l4=new JLabel("前端代码目录(product-web):");
        l4.setFont(ft);
        this.add(l4, c);
        c.gridwidth = 1;
        c.gridy = 7;
        product_web_root.setText(f.config.getProduct_web_root());
        this.add(product_web_root, c);
        c.gridx = 1;
        this.add(product_web_button, c);
        c.gridx = 0;
        c.gridwidth = 2;
        c.gridy = 8;
        this.add(new JLabel(" "), c);
        
        c.gridy = 9;
        JLabel pl = new JLabel();
        pl.setText("后端代码目录(product-server-web):");
        pl.setFont(ft);
        this.add(pl, c);
        c.gridwidth = 1;
        c.gridy = 10;
        product_java_root.setText(f.config.getProduct_java_root());
        this.add(product_java_root, c);
        c.gridx = 1;
        this.add(product_java_button, c);
 
 
        c.gridx = 0;
        c.gridwidth = 2;
        c.gridy = 11;
        this.add(new JLabel(" "), c);
        c.gridy = 12;
        JLabel vl = new JLabel();
        vl.setText("产品版本号,以V开头,如:V1.0.2:");
        vl.setFont(ft);
        this.add(vl, c);
        c.gridy = 13;
        product_version.setText(f.config.getProduct_version());
        this.add(product_version, c);
        
    }
}