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` 文件中的内容。这个文档可能包含更详细的步骤、示例代码以及可能遇到的陷阱和解决策略。通过学习和实践,开发者能够创建出既美观又符合用户操作习惯...
Substance 是一个流行的 Java Swing 库,它为 Swing 组件提供了丰富的皮肤和主题,使得 Java 图形用户界面(GUI)可以拥有更加美观和现代的外观。Swing 是 Java 平台上的标准 GUI 工具包,它允许开发者创建桌面应用...
"Substance 6.1 Swing 皮肤包"是一款专为Java Swing应用设计的视觉样式库,它为Swing组件提供了丰富的、高度可定制的外观和感觉。Substance库以其独特的设计和灵活性,允许开发者轻松地改变应用程序的界面风格,从而...
为了提升用户界面的视觉吸引力,开发者可以使用第三方库,如Substance库,来改变Swing组件的皮肤和主题。Substance.jar是一个流行的Java库,专门用于为Swing应用添加各种美观的主题和皮肤。 在Java中使用Substance...
Swing开源皮肤Substance6.1是一款为Java Swing应用程序提供美观界面的库,它极大地提升了Swing组件的视觉效果,让应用看起来更加现代和专业。Substance库是完全开源的,允许开发者根据需要自定义和扩展皮肤,为用户...
Swing Substance 是一个Java Swing 的UI主题库,它极大地扩展了Swing的视觉表现力,提供了丰富的皮肤和组件样式,让Java桌面应用看起来更加现代化和专业。最新发布的Swing Substance 包含了一系列更新和改进,旨在...
为了提升用户体验和视觉吸引力,开发人员可以使用第三方库来改变Swing应用程序的皮肤,其中"Substance"就是一种广受欢迎的皮肤库。 Substance库为Swing应用提供了多种独特的视觉主题,这些主题不仅改变了控件的外观...
Swing软件Substance库是一个非常独特且功能丰富的Java GUI(图形用户界面)工具包,它扩展了Java Swing组件,提供了大量的视觉主题和自定义样式,让开发者能够为应用程序创建出极具吸引力的用户界面。这个“神奇”的...
一直以来都认为用Swing做出来的程序太难看了,但是又无可奈何,但现在好了,有了substance.jar,只需要在你的程序中添加几行简单的代码,就可以做出非常漂亮的界面来,如果不是亲眼看到,你也许不敢相信这是真的;...
swing substance 实例集合,打开之后,会去网上自动下载的,该实例包含了所有的substance的效果,Java的CS不再丑陋啦!!
Substance 是一个开源项目,专为 Java Swing 应用程序提供多种主题和皮肤,可以显著提升应用的外观和感觉。它提供了丰富的自定义选项,使得开发者能够轻松改变控件的样式,使应用程序看起来更加现代化、专业。...
为了提升用户界面的视觉吸引力,开发者可以使用第三方库来改变Swing组件的外观,例如Substance库。Substance是一款开源的外观皮肤框架,它为Swing应用提供了多种独特的主题,使应用看起来更现代、更吸引人。 ...
Swing Substance是一款为Java Swing界面库提供丰富主题和皮肤的框架,主要用于提升Java应用程序的用户界面美观度和用户体验。Substance-6.0是该框架的一个版本,它包含了一系列精心设计的UI主题,使得开发者可以轻松...
"substance-swingx.jar" 是一个专门为Java Swing应用程序提供美观皮肤和增强功能的库。SwingX是Swing的扩展库,而Substance则是Swing的一个主题引擎,它允许开发者为他们的应用添加丰富的视觉样式,使用户界面更加...
Swing开源皮肤Substance6.0是一款为Java Swing应用程序提供美观、可定制界面的库。它为开发者提供了丰富的皮肤选择,让应用的外观更加现代化,同时也增强了用户体验。Substance库不仅包含了多种预设的皮肤风格,还...
"Substance7.1(全) Swing LAF"是一个针对Java Swing用户界面库的皮肤包,专注于提升应用程序的视觉外观和用户体验。Swing Look and Feel(LAF)是Java Swing框架的一部分,允许开发者改变应用程序的界面风格以适应...
substance风格需要的jar包,这里有着多种lookandfeel,喜欢用swing的可以看看
substance5.2.jar substance swing 皮肤
swing的皮肤包 substance.jar 可以设置swing组件的外观