package org.liufei.gerber;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.InputEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JDesktopPane;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.JSplitPane;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import org.liufei.exception.GerberException;
import org.liufei.gerber.iframe.GerberProjectManager;
import org.liufei.gerber.iframe.GerberProjectPropsManager;
import org.liufei.gerber.iframe.JdbcManager;
import org.liufei.gerber.iframe.LocalGenerateWin;
import org.liufei.gerber.iframe.RemoteGenerateWin;
import org.liufei.gerber.iframe.SvnGerberManager;
import org.liufei.gerber.iframe.SvnManager;
import org.liufei.quota.Install;
import org.liufei.quota.SoftwareInstall;
import org.liufei.util.DesktopUtil;
import org.liufei.util.Source;
import org.pushingpixels.substance.api.SubstanceLookAndFeel;
import org.pushingpixels.substance.api.skin.SkinInfo;
/**
* 生成Gerber文件窗口.
*
* @author 刘飞
*
*/
public class WinMainGenerate extends MyJFrame implements ActionListener,
ItemListener {
private static final long serialVersionUID = 1L;
private static final JDesktopPane DESKTOP_PANE = new JDesktopPane();
private JMenuBar menuBar = new JMenuBar();
private JMenu menuOption = new JMenu("系统");
private JMenu menuHelpe = new JMenu("帮助");
private JMenu menuConfig = new JMenu("配置项");
private JMenu menuGenerate = new JMenu("生成");
private JMenu itemskin = new JMenu("皮肤设置");
private ButtonGroup plafButtonGroup = new ButtonGroup();
private JRadioButton[] plafJRadioButton;
private JMenuItem itemExit = new JMenuItem("退出", new ImageIcon(this
.getClass().getResource("/image/user_delete.gif")));
private JMenuItem itemChangeModes = new JMenuItem("设置系统分辨率", new ImageIcon(this
.getClass().getResource("/image/refresh.gif")));
private JMenuItem gerberProject = new JMenuItem("Gerber工程配置", new ImageIcon(
this.getClass().getResource("/image/books.gif")));
private JMenuItem gerberProjectProps = new JMenuItem("Gerber工程属性配置", new ImageIcon(this
.getClass().getResource("/image/grid.png")));
private JMenuItem jdbc = new JMenuItem("远程jdbc配置", new ImageIcon(this
.getClass().getResource("/image/prev_nav.gif")));
private JMenuItem svn = new JMenuItem("SVN配置", new ImageIcon(this.getClass().getResource("/image/plugin.gif"))) ;
private JMenuItem svnGerberProps = new JMenuItem("Gerber的SVN属性配置", new ImageIcon(this.getClass().getResource("/image/xxsl.gif"))) ;
private JMenuItem generateLocal = new JMenuItem("本地生成", new ImageIcon(this.getClass().getResource("/image/zip.gif"))) ;
private JMenuItem generateRemote = new JMenuItem("远程SVN生成", new ImageIcon(this.getClass().getResource("/image/wtjsl.gif"))) ;
private JMenuItem itemHelpe = new JMenuItem("帮助", new ImageIcon(this
.getClass().getResource("/image/docs.gif")));
private JMenuItem itemAbout = new JMenuItem("关于", new ImageIcon(this
.getClass().getResource("/image/comment.gif")));
private JMenu menuQuota = new JMenu("系统配额");
private JMenuItem qtpInstall = new JMenuItem("安装QTP", new ImageIcon(this
.getClass().getResource("/image/qtp.jpg")));
private JMenuItem cam350Install = new JMenuItem("安装CAM350", new ImageIcon(this
.getClass().getResource("/image/cam350.jpg")));
static {
final JLabel label = new JLabel();
label.setBounds(0, 0, 0, 0);
label.setIcon(null); // 窗体背景
DESKTOP_PANE.addComponentListener(new ComponentAdapter() {
public void componentResized(final ComponentEvent e) {
Dimension size = e.getComponent().getSize();
label.setSize(e.getComponent().getSize());
label.setText("<html><img width=" + size.width + " height="
+ size.height + " src='"
+ this.getClass().getResource("/image/bg33.jpg")
+ "'></html>");
}
});
DESKTOP_PANE.add(label, new Integer(Integer.MIN_VALUE));
DESKTOP_PANE.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
}
public WinMainGenerate(String title) throws HeadlessException {
super(title);
Container container = getContentPane();
container.setLayout(new BorderLayout());
this.setResizable(true);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setCursor(new Cursor(0));
Toolkit tool = getToolkit();
Dimension dim = tool.getScreenSize();
this.setBounds(dim.width / 2 - 550, dim.height / 2 - 350, 1100, 700);
Image image = tool.getImage(this.getClass().getResource(
"/image/LOGO.png"));
this.setIconImage(image);
this.initMenuItem();
this.initCheckBox();
JSplitPane jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
true, LeftTreeMenu.getInstance(), DESKTOP_PANE);
jSplitPane.setDividerSize(7);
jSplitPane.setDividerLocation(0.5);
container.add(MenuBar.getMenuBarHORIZONTAL(), BorderLayout.NORTH);
container.add(jSplitPane, BorderLayout.CENTER);
this.setContentPane(container);
this.validate();
}
private void initCheckBox() {
Map<String, SkinInfo> allSkins = SubstanceLookAndFeel.getAllSkins() ;
plafJRadioButton = new JRadioButton[allSkins.size()];
int i = 0;
for (String skinInfo : allSkins.keySet()) {
plafJRadioButton[i] = new JRadioButton(skinInfo);
plafButtonGroup.add(plafJRadioButton[i]);
plafJRadioButton[i].addItemListener(this);
itemskin.add(plafJRadioButton[i]);
itemskin.addSeparator();
i++;
}
// for(JRadioButton b : plafJRadioButton) {
// if(b.getText().equals("Office Silver 2007")) {
// b.setSelected(true);
// }
// }
}
public static void addAndShowIFrame(JInternalFrame iframe) {
DESKTOP_PANE.add(iframe);
DESKTOP_PANE.setSelectedFrame(iframe) ;
DESKTOP_PANE.getDesktopManager().activateFrame(iframe) ;
}
public static JDesktopPane jDesktopPane() {
return DESKTOP_PANE;
}
private void initMenuItem() {
/**
* 系统操作菜单
*/
menuOption.add(itemskin);
menuOption.setCursor(Cursor.getPredefinedCursor(12));
itemskin.setCursor(Cursor.getPredefinedCursor(12));
menuOption.addSeparator();
menuOption.add(itemChangeModes) ;
itemChangeModes.setCursor(Cursor.getPredefinedCursor(12));
menuOption.addSeparator();
menuOption.add(itemExit);
itemExit.setCursor(Cursor.getPredefinedCursor(12));
itemExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
InputEvent.CTRL_MASK));
/**
* 配置项菜单
*/
menuConfig.setCursor(Cursor.getPredefinedCursor(12));
menuConfig.add(gerberProject);
gerberProject.setCursor(Cursor.getPredefinedCursor(12));
gerberProject.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G,
InputEvent.CTRL_MASK));
menuConfig.addSeparator();
menuConfig.add(gerberProjectProps);
gerberProjectProps.setCursor(Cursor.getPredefinedCursor(12));
gerberProjectProps.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F,
InputEvent.CTRL_MASK));
menuConfig.addSeparator();
menuConfig.add(jdbc);
jdbc.setCursor(Cursor.getPredefinedCursor(12));
jdbc.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J,
InputEvent.CTRL_MASK));
menuConfig.addSeparator();
menuConfig.add(svn);
svn.setCursor(Cursor.getPredefinedCursor(12));
svn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B,
InputEvent.CTRL_MASK));
menuConfig.addSeparator();
menuConfig.add(svnGerberProps);
svnGerberProps.setCursor(Cursor.getPredefinedCursor(12));
svnGerberProps.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H,
InputEvent.CTRL_MASK));
/**
* 生成菜单
*/
menuGenerate.setCursor(Cursor.getPredefinedCursor(12));
menuGenerate.add(generateLocal);
generateLocal.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W,
InputEvent.CTRL_MASK));
generateLocal.setCursor(Cursor.getPredefinedCursor(12));
menuGenerate.addSeparator();
menuGenerate.add(generateRemote);
generateRemote.setCursor(Cursor.getPredefinedCursor(12));
generateRemote.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,
InputEvent.CTRL_MASK));
/**
* 帮助菜单
*/
menuHelpe.add(itemHelpe);
menuHelpe.setCursor(Cursor.getPredefinedCursor(12));
itemHelpe.setCursor(Cursor.getPredefinedCursor(12));
itemHelpe.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1,
InputEvent.CTRL_MASK));
menuHelpe.addSeparator();
menuHelpe.add(itemAbout);
itemAbout.setCursor(Cursor.getPredefinedCursor(12));
itemAbout.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,
InputEvent.CTRL_MASK));
/**
* 系统配额
*/
menuQuota.add(qtpInstall) ;
menuQuota.addSeparator();
menuQuota.setCursor(Cursor.getPredefinedCursor(12));
qtpInstall.setCursor(Cursor.getPredefinedCursor(12));
cam350Install.setCursor(Cursor.getPredefinedCursor(12));
menuQuota.add(cam350Install) ;
menuBar.add(menuOption);
menuBar.add(menuConfig);
menuBar.add(menuGenerate);
menuBar.add(menuQuota);
menuBar.add(menuHelpe);
menuBar.setBorderPainted(true);
gerberProject.addActionListener(this);
gerberProjectProps.addActionListener(this);
itemExit.addActionListener(this);
itemHelpe.addActionListener(this);
itemAbout.addActionListener(this);
jdbc.addActionListener(this);
svn.addActionListener(this);
svnGerberProps.addActionListener(this);
generateLocal.addActionListener(this);
generateRemote.addActionListener(this);
qtpInstall.addActionListener(this);
cam350Install.addActionListener(this);
itemChangeModes.addActionListener(this) ;
menuBar.setCursor(Cursor.getPredefinedCursor(12));
this.setJMenuBar(menuBar);
}
@Override
public void actionPerformed(ActionEvent e) {
Object actionObject = e.getSource();
if (actionObject == itemExit) {
int n = JOptionPane.showConfirmDialog(this, "你确定要退出系统吗?", "系统提示",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE, new ImageIcon(this
.getClass().getResource("/image/help.gif")));
if (n == JOptionPane.YES_OPTION) {
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {// 在退出JVM之前要处理的必要操作代码
// System.gc() ;
}
});
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {// 在退出JVM之前要处理的必要操作代码
// System.gc() ;
}
});
System.exit(0);
} else if (n == JOptionPane.NO_OPTION) {
} else if (n == JOptionPane.CANCEL_OPTION) {
} else if (n == JOptionPane.OK_OPTION) {
} else if (n == JOptionPane.CLOSED_OPTION) {
}
} else if (actionObject == itemskin) {
JOptionPane.showMessageDialog(this, "皮肤设置") ;
} else if (actionObject == itemHelpe) {
DesktopUtil.openAndWarn(new File("help/gerber文件生成系统.pdf"), this) ;
} else if (actionObject == itemAbout) {
// DesktopUtil.openAndWarn(new File("help/gerber文件生成系统.doc"), this) ;
DesktopUtil.browseAndWarn("http://liufei-fir.iteye.com/", this) ;
} else if (actionObject == gerberProject) {
GerberProjectManager gerberProjectManager = new GerberProjectManager("Gerber工程配置管理", false, true, false, true) ;
WinMainGenerate.addAndShowIFrame(gerberProjectManager) ;
} else if (actionObject == gerberProjectProps) {
GerberProjectPropsManager gerberProjectManager = new GerberProjectPropsManager("Gerber工程相应属性配置管理", false, true, false, true) ;
WinMainGenerate.addAndShowIFrame(gerberProjectManager) ;
} else if (actionObject == svn) {
SvnManager svnManager = new SvnManager("SVN配置管理", false, true, false, true) ;
WinMainGenerate.addAndShowIFrame(svnManager) ;
} else if (actionObject == svnGerberProps) {
SvnGerberManager svnGerberManager = new SvnGerberManager("Gerber工程SVN属性配置管理", false, true, false, true) ;
WinMainGenerate.addAndShowIFrame(svnGerberManager) ;
} else if (actionObject == jdbc) {
JdbcManager jdbcManager = new JdbcManager("JDBC配置管理", false, true, false, true) ;
WinMainGenerate.addAndShowIFrame(jdbcManager) ;
} else if (actionObject == generateLocal) {
LocalGenerateWin generateWin = new LocalGenerateWin("本地资源生成Gerber文件", false, true, false, true) ;
WinMainGenerate.addAndShowIFrame(generateWin) ;
} else if (actionObject == generateRemote) {
RemoteGenerateWin generateWin = new RemoteGenerateWin("远程SVN资源Gerber文件生成", false, true, false, true) ;
WinMainGenerate.addAndShowIFrame(generateWin) ;
}
else if (actionObject == qtpInstall) {//安装QTP
String[] paths = new String[]{
Source.getAbsolutePath("Quota/QTP/qtp92"),
Source.getAbsolutePath("Quota/QTP/qtp92/安装重要说明(获取免费).txt")
} ;
SoftwareInstall install = new Install(this, "QTP", paths) ;
try {
install.install(Source.getAbsolutePath("Quota/QTP/qtp92/QTP92/setup.exe")) ;
} catch (GerberException e1) {
JOptionPane.showInternalMessageDialog(
this,
"QTP安装时异常",
"系统提示",
JOptionPane.ERROR_MESSAGE
);
}
}
else if (actionObject == cam350Install) {//安装CAM350
String[] paths = new String[]{
Source.getAbsolutePath("Quota/CAM350/camv8.6/CAM350V8_6新的解密文件"),
Source.getAbsolutePath("Quota/CAM350/camv8.6/CAM350安装说明.txt")
} ;
SoftwareInstall install = new Install(this, "CAM350", paths) ;
try {
install.install(Source.getAbsolutePath("Quota/CAM350/camv8.6/CAM350v86.exe")) ;
} catch (GerberException e1) {
JOptionPane.showInternalMessageDialog(
this,
"CAM350安装时异常",
"系统提示",
JOptionPane.ERROR_MESSAGE
);
}
}
else if(actionObject == itemChangeModes) {
try {
Process process = Runtime.getRuntime().exec(Source.getAbsolutePath(Source.CHANGE_MODES), null);
process.waitFor() ;
if(process.exitValue() == 0) {
JOptionPane.showMessageDialog(this, "系统分辨率设置成功!", "系统提示", JOptionPane.INFORMATION_MESSAGE) ;
}
} catch (IOException e1) {
JOptionPane.showMessageDialog(this, "系统分辨率设置异常!", "系统提示", JOptionPane.ERROR_MESSAGE) ;
} catch (InterruptedException e2) {
JOptionPane.showMessageDialog(this, "系统分辨率设置异常!", "系统提示", JOptionPane.ERROR_MESSAGE) ;
}
}
}
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
for (final JRadioButton radio : plafJRadioButton) {
if (e.getSource() == radio) {
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run() {
SubstanceLookAndFeel.setSkin(SubstanceLookAndFeel.getAllSkins().get(radio.getText()).getClassName());
}}) ;
}
}
}
}
}
package org.liufei;
import java.awt.HeadlessException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import org.liufei.db.SystemInitialize;
import org.liufei.gerber.WinMainGenerate;
import org.liufei.util.LoadingSource;
import org.liufei.util.Source;
import org.pushingpixels.substance.api.SubstanceLookAndFeel;
/**
*
* @author 刘飞
*
*/
public class SystemRunner {
/**
* 系统注册表根
*/
private static final String PREFERENCES_ROOT = "gerber" ;
/**
* 系统注册表键
*/
private static final String[] PREFERENCES_KEYS = {"author", "version", "email"} ;
/**
* 系统注册表值
*/
private static final String[] PREFERENCES_VALUES = {"liufei", "1.0 beta", "liufei_it@126.com"} ;
/**
* @param args
* @throws IOException
* @throws FileNotFoundException
* @throws HeadlessException
*/
public static void main(String[] args){
init() ;
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run() {
// SubstanceLookAndFeel.getAllSkins().get("Mist Silver").getClassName();
SubstanceLookAndFeel.setSkin("org.pushingpixels.substance.api.skin.MistSilverSkin");
WinMainGenerate generate = null ;
try {
generate = new WinMainGenerate(LoadingSource.reader(
new File("config/system_init.properties")).getProperty(
"system.main.title"));
} catch (HeadlessException e) {
JOptionPane.showMessageDialog(generate, "系统初始化失败!", "系统提示", JOptionPane.ERROR_MESSAGE) ;
} catch (FileNotFoundException e) {
JOptionPane.showMessageDialog(generate, "系统启动找不到初始化文件!", "系统提示", JOptionPane.ERROR_MESSAGE) ;
} catch (IOException e) {
JOptionPane.showMessageDialog(generate, "系统启动加载初始化文件异常!", "系统提示", JOptionPane.ERROR_MESSAGE) ;
}
}}) ;
}
public static void init() {
Source.deleteQTPReportFile() ;
new SystemInitialize() ;
Preferences preferences = Preferences.systemRoot().node(PREFERENCES_ROOT);
try {
if( !preferences.nodeExists(PREFERENCES_ROOT) ) {
for (int i = 0 ; i < PREFERENCES_KEYS.length ; i++) {
preferences.put(PREFERENCES_KEYS[i], PREFERENCES_VALUES[i]) ;
}
}
} catch (BackingStoreException e) {}
}
}
分享到:
相关推荐
为了更好地理解并实践观感切换,你可以参考 `Swing观感切换.doc` 文件中的内容。这个文档可能包含更详细的步骤、示例代码以及可能遇到的陷阱和解决策略。通过学习和实践,开发者能够创建出既美观又符合用户操作习惯...
里面有一个swing外观包,找的很辛苦又不会使用的可以学习下,本程序调用的是office2007外观,个人感觉很漂亮,而且我写的很多程序都用这个substance.jar观感包。 也有打包好的.jar文件,直接运行
//改变观感 //org.jvnet.substance.SubstanceLookAndFeel try { UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel"); } catch (Exception e) { e.printStackTrace(); } new Zhuyemian()...
嵌入式八股文面试题库资料知识宝典-华为的面试试题.zip
训练导控系统设计.pdf
嵌入式八股文面试题库资料知识宝典-网络编程.zip
人脸转正GAN模型的高效压缩.pdf
少儿编程scratch项目源代码文件案例素材-几何冲刺 转瞬即逝.zip
少儿编程scratch项目源代码文件案例素材-鸡蛋.zip
嵌入式系统_USB设备枚举与HID通信_CH559单片机USB主机键盘鼠标复合设备控制_基于CH559单片机的USB主机模式设备枚举与键盘鼠标数据收发系统支持复合设备识别与HID
嵌入式八股文面试题库资料知识宝典-linux常见面试题.zip
面向智慧工地的压力机在线数据的预警应用开发.pdf
基于Unity3D的鱼类运动行为可视化研究.pdf
少儿编程scratch项目源代码文件案例素材-霍格沃茨魔法学校.zip
少儿编程scratch项目源代码文件案例素材-金币冲刺.zip
内容概要:本文深入探讨了HarmonyOS编译构建子系统的作用及其技术细节。作为鸿蒙操作系统背后的关键技术之一,编译构建子系统通过GN和Ninja工具实现了高效的源代码到机器代码的转换,确保了系统的稳定性和性能优化。该系统不仅支持多系统版本构建、芯片厂商定制,还具备强大的调试与维护能力。其高效编译速度、灵活性和可扩展性使其在华为设备和其他智能终端中发挥了重要作用。文章还比较了HarmonyOS编译构建子系统与安卓和iOS编译系统的异同,并展望了其未来的发展趋势和技术演进方向。; 适合人群:对操作系统底层技术感兴趣的开发者、工程师和技术爱好者。; 使用场景及目标:①了解HarmonyOS编译构建子系统的基本概念和工作原理;②掌握其在不同设备上的应用和优化策略;③对比HarmonyOS与安卓、iOS编译系统的差异;④探索其未来发展方向和技术演进路径。; 其他说明:本文详细介绍了HarmonyOS编译构建子系统的架构设计、核心功能和实际应用案例,强调了其在万物互联时代的重要性和潜力。阅读时建议重点关注编译构建子系统的独特优势及其对鸿蒙生态系统的深远影响。
嵌入式八股文面试题库资料知识宝典-奇虎360 2015校园招聘C++研发工程师笔试题.zip
嵌入式八股文面试题库资料知识宝典-腾讯2014校园招聘C语言笔试题(附答案).zip
双种群变异策略改进RWCE算法优化换热网络.pdf
内容概要:本文详细介绍了基于瞬时无功功率理论的三电平有源电力滤波器(APF)仿真研究。主要内容涵盖并联型APF的工作原理、三相三电平NPC结构、谐波检测方法(ipiq)、双闭环控制策略(电压外环+电流内环PI控制)以及SVPWM矢量调制技术。仿真结果显示,在APF投入前后,电网电流THD从21.9%降至3.77%,显著提高了电能质量。 适用人群:从事电力系统研究、电力电子技术开发的专业人士,尤其是对有源电力滤波器及其仿真感兴趣的工程师和技术人员。 使用场景及目标:适用于需要解决电力系统中谐波污染和无功补偿问题的研究项目。目标是通过仿真验证APF的有效性和可行性,优化电力系统的电能质量。 其他说明:文中提到的仿真模型涉及多个关键模块,如三相交流电压模块、非线性负载、信号采集模块、LC滤波器模块等,这些模块的设计和协同工作对于实现良好的谐波抑制和无功补偿至关重要。