?? auto.java
字號:
package org.eclipse.ve.model;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.awt.event.*;
import javax.swing.border.*;
/**
* <p>
* Title: Model設置
* </p>
* <p>
* Description: 設置表名及其屬性
* </p>
* <p>
* Copyright: Copyright (c) 2006
* </p>
* <p>
* Company: www.use.com
* </p>
*
* @author jiangyujie
* @version 1.0
*/
public class Auto extends JFrame implements ActionListener, ItemListener {
/**
*
*/
private static final long serialVersionUID = -4487298726165465177L;
static Color DarkColor = new Color(55, 77, 118); // 暗色
static Color LightColor = new Color(111, 146, 212); // 亮色
static Border unSelected = BorderFactory.createLineBorder(DarkColor, 1); // 未選中時的邊框
static Border emptyBorder = BorderFactory.createEmptyBorder();// 選中之后的按鈕邊框
static Dimension faceSize = new Dimension(780, 500);
static Image icon, contentPanelBack, setupDialogBack, warningDialogBack;// 主程序圖標,主界面背景,設置對話框和警告對話框背景
static ImageIcon imgSetup, imgRefresh, imgAbout, imgTomcat, imgPath, sure,
del, logo, exit, run, add, edit, addBack, delBack, exitBack,
runBack, sureBack, editBack;// 主界面按鈕的圖標
static JFileChooser jfchooser = new JFileChooser(); // 目錄選擇器
static JPanel toolBar; // 工具欄
static JPanel contentPanel; // 容器
static JPanel statusPanel; // 狀態欄
static JTextPane actionPanel = new JTextPane(); // 代碼顯示欄
static JLabel jlName = new JLabel();// 對象名
static JLabel jlSeted = new JLabel();// 已選擇的屬性
static JLabel jlParent = new JLabel();// parent
static JLabel jlRun = new JLabel();// run
static Checkbox checkParent = new Checkbox();// parent選擇框
static Checkbox checkInstall = new Checkbox();// run選擇框
static List listParent = new List();// parent外鍵設置列表
static List listProperty = new List();// 已設置的參數
static TextField jtCode = new TextField();// code輸入框
static JTextField companyField = new JTextField();// 狀態欄文字
static JTextField timeField= new JTextField(9);// 時間信息
static SetupDialog setupDialog;// 設置對話框
static AboutDialog aboutDialog; // 關于對話框
static WarnDialog warnDialog;// 警告對話框
static JButton jbSure;// 確定
static JButton jbDel;// 刪除
static JButton jbAdd;// 添加
static JButton jbEdit;// 添加
static JButton jbExit;// 退出
static JButton jbRun;// 運行
static JButton setupButton = new JButton(); // 設置
static JButton aboutButton = new JButton(); // 關于
static JButton pathButton = new JButton(); // 目錄設置
static JButton tomcatButton = new JButton();// tomcat
static String parentModel = null;// parent選擇的Model
static String fileName = null;// 生成文件名
static String path = new String(Constants.modelDir);// Model輸出目錄,默認為C:\\Model
static String pathProject = new String(Constants.modelDir);// 選定的工程目錄,其下必須有build.xml文件才能運行ant
static int flagForeignKey = 0;// flagForeignKey為設置parent與否的標志
static int modelFlag = 0;// 在文件夾中查找model的標志鍵,用于測試是否有文件夾名為model
static ArrayList proList = new ArrayList();// 傳遞的參數列表
static ArrayList modelDireList = new ArrayList();// 傳遞可用的model文件夾列表
static ArrayList modelList = new ArrayList();// 設置了的model列表
final char ch = '\"';// 引號
final char nl = '\n';// 換行
// 構造函數
public Auto() {
initResource();
initUI();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.pack();
this.setSize(faceSize);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((int) (screenSize.width - faceSize.getWidth()) / 2,
(int) (screenSize.height - faceSize.getHeight()) / 2);
this.setResizable(false);
this.setTitle("appfrm自動設置"); // 設置標題
this.setIconImage(icon); // 設置程序圖標
setMouse(this);
}
/**
* 初始化系統所需要的資源
*/
public void initResource() {
// 程序圖標
icon = getImage("images/about.gif");
contentPanelBack = getImage("images/back1.gif");
setupDialogBack = getImage("images/back3.gif");
warningDialogBack = getImage("images/back4.gif");
imgSetup = new ImageIcon(getImage("images/setup.jpg"));
imgAbout = new ImageIcon(getImage("images/about.jpg"));
imgTomcat = new ImageIcon(getImage("images/tomcat.jpg"));
imgPath = new ImageIcon(getImage("images/path.jpg"));
sure = new ImageIcon(getImage("images/sure.jpg"));
del = new ImageIcon(getImage("images/del.jpg"));
logo = new ImageIcon(getImage("images/logo.gif"));
exit = new ImageIcon(getImage("images/exit.jpg"));
run = new ImageIcon(getImage("images/run.jpg"));
add = new ImageIcon(getImage("images/add.jpg"));
edit = new ImageIcon(getImage("images/edit.jpg"));
addBack = new ImageIcon(getImage("images/addback.jpg"));
delBack = new ImageIcon(getImage("images/delback.jpg"));
runBack = new ImageIcon(getImage("images/runback.jpg"));
exitBack = new ImageIcon(getImage("images/exitback.jpg"));
sureBack = new ImageIcon(getImage("images/sureback.jpg"));
editBack = new ImageIcon(getImage("images/editback.jpg"));
// 初始化對話框
setupDialog = new SetupDialog(this);
aboutDialog = new AboutDialog(this);
warnDialog = new WarnDialog(this);
}
/**
* 初始化用戶界面
*/
public void initUI() {
// 界面整體布局
Border border = BorderFactory.createBevelBorder(BevelBorder.LOWERED,
new Color(45, 92, 162), new Color(43, 66, 97), new Color(45,
92, 162), new Color(84, 123, 200));
BorderLayout borderLayout = new BorderLayout();
toolBar = new JPanel();
toolBar.setBackground(new Color(228, 226, 204));
toolBar.setBorder(border);
toolBar.setPreferredSize(new Dimension(780, 40));
toolBar.setMinimumSize(new Dimension(780, 40));
toolBar.setLayout(null);
actionPanel.setBackground(new Color(228, 226, 204));
actionPanel.setBorder(border);
actionPanel.setForeground(Color.red);
actionPanel.setFont(new java.awt.Font("宋體", java.awt.Font.PLAIN, 14));
actionPanel.setPreferredSize(new Dimension(260, 380));
actionPanel.setText("歡迎使用POJO自動設置程序");
actionPanel.setMinimumSize(new Dimension(160, 380));
contentPanel = new Content(contentPanelBack);
contentPanel.setBorder(border);
contentPanel.setPreferredSize(new Dimension(520, 380));
contentPanel.setMinimumSize(new Dimension(620, 380));
contentPanel.setLayout(null);
statusPanel = new JPanel();
statusPanel.setBackground(DarkColor);
statusPanel.setBorder(border);
statusPanel.setPreferredSize(new Dimension(620, 24));
statusPanel.setMinimumSize(new Dimension(620, 24));
statusPanel.setLayout(new BorderLayout());
this.getContentPane().setLayout(borderLayout);
this.getContentPane().add(toolBar, BorderLayout.NORTH);
this.getContentPane().add(actionPanel, BorderLayout.EAST);
this.getContentPane().add(contentPanel, BorderLayout.CENTER);
this.getContentPane().add(statusPanel, BorderLayout.SOUTH);
// 加入設置
toolBar.add(setupButton);
setupButton.setBounds(20, 5, 40, 30);
setupButton.setText("屬性");
setupButton.setIcon(imgSetup);
setupButton.addActionListener(this);
setupButton.setRolloverIcon(imgSetup);
// 加入路徑
toolBar.add(pathButton);
pathButton.setBounds(100, 5, 40, 30);
pathButton.setText("路徑");
pathButton.setIcon(imgPath);
pathButton.addActionListener(this);
// 加入關于
toolBar.add(aboutButton);
aboutButton.setBounds(260, 5, 40, 30);
aboutButton.setText("關于");
aboutButton.setIcon(imgAbout);
aboutButton.addActionListener(this);
// 加入tomcat
toolBar.add(tomcatButton);
tomcatButton.setBounds(180, 5, 40, 30);
tomcatButton.setText("tomcat");
tomcatButton.setIcon(imgTomcat);
tomcatButton.addActionListener(this);
// 加入狀態欄
statusPanel.add(companyField, BorderLayout.CENTER);
companyField.setText("西安用友軟件工程公司");
companyField.setBorder(unSelected);
companyField.setEditable(false);
companyField.setForeground(Color.white);
companyField.setBackground(DarkColor);
statusPanel.add(timeField, BorderLayout.EAST);
timeField.setText(getNowDate().toString());
timeField.setBorder(unSelected);
timeField.setEditable(false);
timeField.setForeground(Color.white);
timeField.setBackground(DarkColor);
jlName.setBounds(100, 50, 80, 30);
jlName.setText("對象名");
jlName.setFont(new java.awt.Font("宋體", java.awt.Font.BOLD, 18));
jlName.setForeground(java.awt.Color.white);
jlSeted.setBounds(40, 150, 120, 20);
jlSeted.setText("已設置的屬性");
jlSeted.setFont(new java.awt.Font("宋體", java.awt.Font.BOLD, 18));
jlSeted.setForeground(java.awt.Color.white);
jlParent.setBounds(320, 150, 120, 20);
jlParent.setText("Parent");
jlParent.setFont(new java.awt.Font("宋體", java.awt.Font.BOLD, 18));
jlParent.setForeground(java.awt.Color.white);
jlRun.setBounds(380, 345, 120, 20);
jlRun.setText("通用");
jlRun.setFont(new java.awt.Font("宋體", java.awt.Font.BOLD, 18));
jlRun.setForeground(java.awt.Color.white);
checkParent.setBounds(340, 180, 20, 15);
checkParent.setBackground(new java.awt.Color(76, 146, 196));
checkParent.addItemListener(this);
checkInstall.setBounds(420, 347, 20, 15);
checkInstall.setBackground(new java.awt.Color(76, 146, 196));
checkInstall.addItemListener(this);
listParent.setBounds(390, 150, 100, 60);
listParent.setVisible(false);
listProperty.setBounds(200, 150, 100, 80);
jtCode.setBounds(200, 50, 100, 30);
jtCode.setFont(new Font("Dialog",Font.PLAIN,18));
jbSure = new JButton("確定", sure);
jbSure.setBounds(new java.awt.Rectangle(140, 340, 60, 30));
jbSure.addActionListener(this);
jbSure.setBorder(unSelected);
jbSure.setRolloverIcon(sureBack);
jbExit = new JButton("退出", exit);
jbExit.setBounds(new java.awt.Rectangle(220, 340, 60, 30));
jbExit.addActionListener(this);
jbExit.setBorder(unSelected);
jbExit.setRolloverIcon(exitBack);
jbRun = new JButton("運行ant", run);
jbRun.setBounds(new java.awt.Rectangle(300, 340, 60, 30));
jbRun.addActionListener(this);
jbRun.setBorder(unSelected);
jbRun.setRolloverIcon(runBack);
jbAdd = new JButton("設置", add);
jbAdd.setBounds(new java.awt.Rectangle(140, 250, 60, 25));
jbAdd.addActionListener(this);
jbAdd.setBorder(unSelected);
jbAdd.setRolloverIcon(addBack);
jbEdit = new JButton("編輯", edit);
jbEdit.setBounds(new java.awt.Rectangle(220, 250, 60, 25));
jbEdit.addActionListener(this);
jbEdit.setBorder(unSelected);
jbEdit.setRolloverIcon(editBack);
jbDel = new JButton("刪除", del);
jbDel.setBounds(new java.awt.Rectangle(300, 250, 60, 25));
jbDel.addActionListener(this);
jbDel.setBorder(unSelected);
jbDel.setRolloverIcon(delBack);
contentPanel.add(jlName);
contentPanel.add(jlSeted);
contentPanel.add(jlParent);
contentPanel.add(jlRun);
contentPanel.add(jtCode);
contentPanel.add(listProperty);
contentPanel.add(checkParent);
contentPanel.add(listParent);
contentPanel.add(checkInstall);
contentPanel.add(jbSure);
contentPanel.add(jbExit);
contentPanel.add(jbEdit);
contentPanel.add(jbRun);
contentPanel.add(jbAdd);
contentPanel.add(jbDel);
jfchooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
jfchooser.setDialogTitle("選擇model所在文件夾");
}
/**
*/
void setButton(JButton jb) {
jbSure.setBorder(unSelected);
jbDel.setBorder(unSelected);
jbAdd.setBorder(unSelected);
jbExit.setBorder(unSelected);
jbRun.setBorder(unSelected);
jbEdit.setBorder(unSelected);
jb.setBorder(emptyBorder);
}
/**
* 設定按鈕的圖案
*/
void setButton() {
jbSure.setBorder(unSelected);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -