|
|
@ -1,13 +1,9 @@ |
|
|
|
package com.insigma.ui; |
|
|
|
|
|
|
|
import com.insigma.service.impl.WindowsTomcatMysql; |
|
|
|
import lombok.SneakyThrows; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.border.EmptyBorder; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.io.File; |
|
|
@ -17,43 +13,36 @@ import java.net.URISyntaxException; |
|
|
|
|
|
|
|
|
|
|
|
import java.awt.EventQueue; |
|
|
|
import javax.swing.JFrame; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.border.EmptyBorder; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
import javax.swing.JButton; |
|
|
|
import java.awt.Panel; |
|
|
|
import java.awt.Toolkit; |
|
|
|
|
|
|
|
import javax.swing.JTabbedPane; |
|
|
|
import java.awt.Font; |
|
|
|
import javax.swing.JTextField; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Desktop; |
|
|
|
import javax.swing.JLabel; |
|
|
|
import javax.swing.JScrollPane; |
|
|
|
import javax.swing.JSeparator; |
|
|
|
import javax.swing.UIManager; |
|
|
|
import javax.swing.ImageIcon; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.io.IOException; |
|
|
|
import java.net.URI; |
|
|
|
import java.net.URISyntaxException; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import javax.swing.JCheckBox; |
|
|
|
import javax.swing.JFileChooser; |
|
|
|
import javax.swing.JProgressBar; |
|
|
|
import javax.swing.Timer; |
|
|
|
import javax.swing.JTextPane; |
|
|
|
import javax.swing.JFrame; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JButton; |
|
|
|
import java.awt.Panel; |
|
|
|
import java.awt.Toolkit; |
|
|
|
|
|
|
|
import javax.swing.JTabbedPane; |
|
|
|
import java.awt.Font; |
|
|
|
import javax.swing.JTextField; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Desktop; |
|
|
|
import javax.swing.JLabel; |
|
|
|
import javax.swing.JScrollPane; |
|
|
|
import javax.swing.JSeparator; |
|
|
|
import javax.swing.UIManager; |
|
|
|
import javax.swing.ImageIcon; |
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.net.URI; |
|
|
|
import javax.swing.JCheckBox; |
|
|
|
import javax.swing.JFileChooser; |
|
|
|
import javax.swing.JProgressBar; |
|
|
|
import javax.swing.JTextPane; |
|
|
|
import javax.swing.filechooser.FileFilter; |
|
|
|
import java.awt.Component; |
|
|
|
/** |
|
|
|
* @author BeiJing-GWY |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
|
|
|
|
/** |
|
|
|
* @author BeiJing-GWY |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
private static final long serialVersionUID = 1L; |
|
|
|
private JPanel contentPane; |
|
|
@ -69,10 +58,10 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
private JPanel startBackupPanel; |
|
|
|
private JPanel startRestorePanel; |
|
|
|
private JTabbedPane tabbedPane; |
|
|
|
private JTextField textField_1; |
|
|
|
private JTextField textField_2; |
|
|
|
private JTextField textField_3; |
|
|
|
private JTextField textField_4; |
|
|
|
private JTextField textField_1; |
|
|
|
private JTextField textField_2; |
|
|
|
private JTextField textField_3; |
|
|
|
private JTextField textField_4; |
|
|
|
/** |
|
|
|
* Launch the application. |
|
|
|
*/ |
|
|
@ -92,29 +81,26 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
EventQueue.invokeLater(new Runnable() { |
|
|
|
public void run() { |
|
|
|
try { |
|
|
|
SwingFrame frame = new SwingFrame(); |
|
|
|
frame.setTitle("系统工具"); //设置显示窗口标题
|
|
|
|
EventQueue.invokeLater(() -> { |
|
|
|
try { |
|
|
|
SwingFrame frame = new SwingFrame(); |
|
|
|
frame.setTitle("系统工具"); //设置显示窗口标题
|
|
|
|
// frame.setSize(1600,400);//设置显示窗口大小
|
|
|
|
// frame.getContentPane().setBackground(Color.blue);//设置显示窗体颜色
|
|
|
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置窗口是否可以关闭
|
|
|
|
frame.setBounds(100, 100, 910, 580); |
|
|
|
frame.setVisible(true); |
|
|
|
frame.setIconImage(Toolkit.getDefaultToolkit().getImage("D:\\JavaSwing\\src\\main\\java\\com\\insigma\\ui\\favicon.jpg")); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置窗口是否可以关闭
|
|
|
|
frame.setBounds(100, 100, 910, 580); |
|
|
|
frame.setVisible(true); |
|
|
|
frame.setIconImage(Toolkit.getDefaultToolkit().getImage("D:\\JavaSwing\\src\\main\\java\\com\\insigma\\ui\\favicon.jpg")); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Create the frame. |
|
|
|
* @throws IOException |
|
|
|
*/ |
|
|
|
public SwingFrame() throws IOException { |
|
|
|
public SwingFrame() { |
|
|
|
|
|
|
|
contentPane = new JPanel(); |
|
|
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); |
|
|
@ -218,11 +204,16 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
JButton btnNewButton_7 = new JButton(msgBtn); |
|
|
|
btnNewButton_7.setBounds(72, 138, 329, 59); |
|
|
|
btnNewButton_7.setFont(new Font("微软雅黑", Font.PLAIN, 15)); |
|
|
|
btnNewButton_7.addActionListener(new ActionListener() { |
|
|
|
@SneakyThrows |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
btnNewButton_7.addActionListener(e -> { |
|
|
|
try { |
|
|
|
new WindowsTomcatMysql().setDbSize(200000); |
|
|
|
} catch (Exception exception) { |
|
|
|
exception.printStackTrace(); |
|
|
|
} |
|
|
|
try { |
|
|
|
new WindowsTomcatMysql().setMwSize(200000); |
|
|
|
} catch (Exception exception) { |
|
|
|
exception.printStackTrace(); |
|
|
|
} |
|
|
|
}); |
|
|
|
memoryPanel.add(btnNewButton_7); |
|
|
@ -233,11 +224,16 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
JButton button_1 = new JButton(msgBtn16G); |
|
|
|
button_1.setBounds(72, 227, 329, 59); |
|
|
|
button_1.setFont(new Font("微软雅黑", Font.PLAIN, 15)); |
|
|
|
button_1.addActionListener(new ActionListener() { |
|
|
|
@SneakyThrows |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
button_1.addActionListener(e -> { |
|
|
|
try { |
|
|
|
new WindowsTomcatMysql().setDbSize(160000); |
|
|
|
} catch (Exception exception) { |
|
|
|
exception.printStackTrace(); |
|
|
|
} |
|
|
|
try { |
|
|
|
new WindowsTomcatMysql().setMwSize(160000); |
|
|
|
} catch (Exception exception) { |
|
|
|
exception.printStackTrace(); |
|
|
|
} |
|
|
|
}); |
|
|
|
memoryPanel.add(button_1); |
|
|
@ -248,11 +244,16 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
JButton button_2 = new JButton(msgBtn8G); |
|
|
|
button_2.setBounds(72, 314, 329, 59); |
|
|
|
button_2.setFont(new Font("微软雅黑", Font.PLAIN, 15)); |
|
|
|
button_2.addActionListener(new ActionListener() { |
|
|
|
@SneakyThrows |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
button_2.addActionListener(e -> { |
|
|
|
try { |
|
|
|
new WindowsTomcatMysql().setDbSize(80000); |
|
|
|
} catch (Exception exception) { |
|
|
|
exception.printStackTrace(); |
|
|
|
} |
|
|
|
try { |
|
|
|
new WindowsTomcatMysql().setMwSize(80000); |
|
|
|
} catch (Exception exception) { |
|
|
|
exception.printStackTrace(); |
|
|
|
} |
|
|
|
}); |
|
|
|
memoryPanel.add(button_2); |
|
|
@ -263,20 +264,23 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
JButton button_3 = new JButton(msgBtn4G); |
|
|
|
button_3.setBounds(72, 399, 329, 59); |
|
|
|
button_3.setFont(new Font("微软雅黑", Font.PLAIN, 15)); |
|
|
|
button_3.addActionListener(new ActionListener() { |
|
|
|
@SneakyThrows |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
button_3.addActionListener(e -> { |
|
|
|
try { |
|
|
|
new WindowsTomcatMysql().setDbSize(40000); |
|
|
|
} catch (Exception exception) { |
|
|
|
exception.printStackTrace(); |
|
|
|
} |
|
|
|
try { |
|
|
|
new WindowsTomcatMysql().setMwSize(40000); |
|
|
|
} catch (Exception exception) { |
|
|
|
exception.printStackTrace(); |
|
|
|
} |
|
|
|
}); |
|
|
|
memoryPanel.add(button_3); |
|
|
|
JButton btnNewButton_1 = new JButton("保存"); |
|
|
|
btnNewButton_1.setBounds(566, 472, 113, 40); |
|
|
|
btnNewButton_1.addActionListener(new ActionListener() { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
//暂定保存内容
|
|
|
|
} |
|
|
|
btnNewButton_1.addActionListener(e -> { |
|
|
|
//暂定保存内容
|
|
|
|
}); |
|
|
|
// btnNewButton_1.setContentAreaFilled(false);//按钮设置为透明
|
|
|
|
// btnNewButton_1.setBorder(BorderFactory.createRaisedBevelBorder());//设置凸起来的按钮
|
|
|
@ -366,6 +370,7 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
lblNewLabel_9.setBounds(57, 88, 420, 18); |
|
|
|
|
|
|
|
upgradePanel.addMouseListener(new MouseAdapter() { |
|
|
|
@Override |
|
|
|
public void mouseClicked(MouseEvent e){ //鼠标点击事件
|
|
|
|
@SuppressWarnings("unused") |
|
|
|
URI uri = null; |
|
|
@ -388,9 +393,11 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
@Override |
|
|
|
public void mouseEntered(MouseEvent e) { //鼠标移入事件
|
|
|
|
lblNewLabel_9.setForeground(Color.red); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public void mouseExited(MouseEvent e) { //鼠标移出事件
|
|
|
|
lblNewLabel_9.setForeground(Color.blue); |
|
|
|
} |
|
|
@ -432,12 +439,9 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
// 绘制百分比文本(进度条中间显示的百分数)
|
|
|
|
progressBar.setStringPainted(true); |
|
|
|
// 添加进度改变通知
|
|
|
|
progressBar.addChangeListener(new ChangeListener() { |
|
|
|
@Override |
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
// System.out.println("当前进度值: " + progressBar.getValue() + "; " +
|
|
|
|
// "进度百分比: " + progressBar.getPercentComplete());
|
|
|
|
} |
|
|
|
progressBar.addChangeListener(e -> { |
|
|
|
// System.out.println("当前进度值: " + progressBar.getValue() + "; " +
|
|
|
|
// "进度百分比: " + progressBar.getPercentComplete());
|
|
|
|
}); |
|
|
|
// 添加到内容面板
|
|
|
|
startRepairPanel.add(progressBar); |
|
|
@ -482,18 +486,15 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
JButton btnNewButton_5 = new JButton("更改"); |
|
|
|
btnNewButton_5.setFont(new Font("微软雅黑", Font.PLAIN, 15)); |
|
|
|
btnNewButton_5.setBounds(486, 91, 100, 24); |
|
|
|
btnNewButton_5.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
JFileChooser jfC = new JFileChooser(); |
|
|
|
// jfC.setMultiSelectionEnabled(true);//文件是否多选!参数为true或false
|
|
|
|
jfC.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);//设置文件的打开模式(只能选文件夹)
|
|
|
|
jfC.setDialogTitle("请选择要上传的文件夹"); |
|
|
|
int value = jfC.showOpenDialog(SwingFrame.this); |
|
|
|
if(value == JFileChooser.APPROVE_OPTION) { |
|
|
|
File dirFile = jfC.getSelectedFile();//返回选中的文件
|
|
|
|
textField_5.setText(dirFile.getAbsolutePath()); |
|
|
|
} |
|
|
|
btnNewButton_5.addActionListener(e -> { |
|
|
|
JFileChooser jfC = new JFileChooser(); |
|
|
|
// jfC.setMultiSelectionEnabled(true);//文件是否多选!参数为true或false
|
|
|
|
jfC.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);//设置文件的打开模式(只能选文件夹)
|
|
|
|
jfC.setDialogTitle("请选择要上传的文件夹"); |
|
|
|
int value = jfC.showOpenDialog(SwingFrame.this); |
|
|
|
if(value == JFileChooser.APPROVE_OPTION) { |
|
|
|
File dirFile = jfC.getSelectedFile();//返回选中的文件
|
|
|
|
textField_5.setText(dirFile.getAbsolutePath()); |
|
|
|
} |
|
|
|
}); |
|
|
|
startBackupPanel.add(btnNewButton_5); |
|
|
@ -506,11 +507,8 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
JButton btnNewButton_6 = new JButton("开始备份"); |
|
|
|
btnNewButton_6.setFont(new Font("微软雅黑", Font.PLAIN, 15)); |
|
|
|
btnNewButton_6.setBounds(206, 186, 113, 35); |
|
|
|
btnNewButton_6.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
btnNewButton_6.addActionListener(e -> { |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
startBackupPanel.add(btnNewButton_6); |
|
|
|
|
|
|
@ -538,31 +536,25 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
JButton button_5 = new JButton("上传文件:"); |
|
|
|
button_5.setFont(new Font("微软雅黑", Font.PLAIN, 15)); |
|
|
|
button_5.setBounds(94, 91, 116, 24); |
|
|
|
button_5.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
JFileChooser jfC = new JFileChooser(); |
|
|
|
jfC.setFileFilter(new FileFilter() { |
|
|
|
@Override |
|
|
|
public String getDescription() { |
|
|
|
return "ZIP压缩文件(*.zip)"; |
|
|
|
} |
|
|
|
@Override |
|
|
|
public boolean accept(File f) { |
|
|
|
if(f.getName().toLowerCase().endsWith(".zip")) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
}); |
|
|
|
// jfC.setMultiSelectionEnabled(true);//文件是否多选!参数为true或false
|
|
|
|
jfC.setFileSelectionMode(JFileChooser.FILES_ONLY);//设置文件的打开模式(只能选文件夹)
|
|
|
|
jfC.setDialogTitle("请选择要上传的文件夹"); |
|
|
|
int value = jfC.showOpenDialog(SwingFrame.this); |
|
|
|
if(value == JFileChooser.APPROVE_OPTION) { |
|
|
|
File dirFile = jfC.getSelectedFile();//返回选中的文件
|
|
|
|
textField.setText(dirFile.getAbsolutePath()); |
|
|
|
button_5.addActionListener(e -> { |
|
|
|
JFileChooser jfC = new JFileChooser(); |
|
|
|
jfC.setFileFilter(new FileFilter() { |
|
|
|
@Override |
|
|
|
public String getDescription() { |
|
|
|
return "ZIP压缩文件(*.zip)"; |
|
|
|
} |
|
|
|
@Override |
|
|
|
public boolean accept(File f) { |
|
|
|
return f.getName().toLowerCase().endsWith(".zip"); |
|
|
|
} |
|
|
|
}); |
|
|
|
// jfC.setMultiSelectionEnabled(true);//文件是否多选!参数为true或false
|
|
|
|
jfC.setFileSelectionMode(JFileChooser.FILES_ONLY);//设置文件的打开模式(只能选文件夹)
|
|
|
|
jfC.setDialogTitle("请选择要上传的文件夹"); |
|
|
|
int value = jfC.showOpenDialog(SwingFrame.this); |
|
|
|
if(value == JFileChooser.APPROVE_OPTION) { |
|
|
|
File dirFile = jfC.getSelectedFile();//返回选中的文件
|
|
|
|
textField.setText(dirFile.getAbsolutePath()); |
|
|
|
} |
|
|
|
}); |
|
|
|
startRestorePanel.add(button_5); |
|
|
@ -596,9 +588,11 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
JButton button_8 = new JButton("停止数据库服务"); |
|
|
|
button_8.setFont(new Font("微软雅黑", Font.PLAIN, 15)); |
|
|
|
button_8.setBounds(14, 61, 170, 24); |
|
|
|
button_8.addActionListener(new ActionListener() { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
button_8.addActionListener(e -> { |
|
|
|
try { |
|
|
|
new WindowsTomcatMysql().stopDbService(); |
|
|
|
} catch (Exception exception) { |
|
|
|
exception.printStackTrace(); |
|
|
|
} |
|
|
|
}); |
|
|
|
textPanel.add(button_8); |
|
|
@ -606,9 +600,11 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
JButton button_9 = new JButton("开始中间件"); |
|
|
|
button_9.setFont(new Font("微软雅黑", Font.PLAIN, 15)); |
|
|
|
button_9.setBounds(14, 98, 170, 35); |
|
|
|
button_9.addActionListener(new ActionListener() { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
button_9.addActionListener(e -> { |
|
|
|
try { |
|
|
|
new WindowsTomcatMysql().startMwService(); |
|
|
|
} catch (Exception exception) { |
|
|
|
exception.printStackTrace(); |
|
|
|
} |
|
|
|
}); |
|
|
|
textPanel.add(button_9); |
|
|
@ -616,9 +612,11 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
JButton button_10 = new JButton("停止中间件"); |
|
|
|
button_10.setFont(new Font("微软雅黑", Font.PLAIN, 15)); |
|
|
|
button_10.setBounds(14, 153, 170, 35); |
|
|
|
button_10.addActionListener(new ActionListener() { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
button_10.addActionListener(e -> { |
|
|
|
try { |
|
|
|
new WindowsTomcatMysql().stopMwService(); |
|
|
|
} catch (Exception exception) { |
|
|
|
exception.printStackTrace(); |
|
|
|
} |
|
|
|
}); |
|
|
|
textPanel.add(button_10); |
|
|
@ -663,7 +661,7 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
String buttonCommand = e.getActionCommand(); |
|
|
|
if(buttonCommand.equals("打开服务管理器")) { |
|
|
|
if("打开服务管理器".equals(buttonCommand)) { |
|
|
|
try{ |
|
|
|
// Runtime rt = Runtime.getRuntime();runBak
|
|
|
|
// Process p = rt.exec("cmd.exe /c compmgmt.msc");
|
|
|
@ -671,7 +669,7 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
}catch (Exception ex){ |
|
|
|
ex.printStackTrace(); |
|
|
|
} |
|
|
|
}else if(buttonCommand.equals("开始优化")) { |
|
|
|
}else if("开始优化".equals(buttonCommand)) { |
|
|
|
try{ |
|
|
|
tabbedPane.addTab("开始优化界面", null, startRepairPanel, null); |
|
|
|
tabbedPane.setSelectedComponent(startRepairPanel); |
|
|
@ -680,13 +678,13 @@ public class SwingFrame extends JFrame implements ActionListener { |
|
|
|
}catch (Exception ex){ |
|
|
|
ex.printStackTrace(); |
|
|
|
} |
|
|
|
}else if(buttonCommand.equals("数据库备份")) { |
|
|
|
}else if("数据库备份".equals(buttonCommand)) { |
|
|
|
tabbedPane.addTab("数据库备份", null, startBackupPanel, null); |
|
|
|
tabbedPane.setSelectedComponent(startBackupPanel); |
|
|
|
}else if(buttonCommand.equals("数据库还原")) { |
|
|
|
}else if("数据库还原".equals(buttonCommand)) { |
|
|
|
tabbedPane.addTab("数据库还原", null, startRestorePanel, null); |
|
|
|
tabbedPane.setSelectedComponent(startRestorePanel); |
|
|
|
}else if(buttonCommand.equals("返回")) { |
|
|
|
}else if("返回".equals(buttonCommand)) { |
|
|
|
tabbedPane.setSelectedComponent(backupsPanel); |
|
|
|
} |
|
|
|
} |
|
|
|