📄 octopusgeneratorpanel.java
字号:
package org.webdocwf.util.loader.wizard;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.Writer;
import java.util.HashMap;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
public class OctopusGeneratorPanel extends JPanel {
private static final String SOURCE_TYPE = "Source database type",
TARGET_TYPE = "Target database type",
SOURCE_DATABASE = "Source database URL",
TARGET_DATABASE = "Target database URL",
SOURCE_USER = "Source database user",
SOURCE_PASSWORD = "Source database password",
TARGET_USER = "Target database user",
TARGET_PASSWORD = "Target database password",
VALUE_MODE = "Value mode",
GENERATOR_OUTPUT = "Generator output directory",
DOML_PATH = "Doml URL( when use Doml as input )",
PACKAGE_NAME = "Package name",
SOURCE_DRIVER_NAME = "Source database driver name",
TARGET_DRIVER_NAME = "Target database driver name",
ADDITIONAL_PATHS = "Additional classpath",
DROP_TABLE = "Drop Tables",
CREATE_TABLE = "Create Tables",
CREATE_PRIMARY_KEYS = "Create Primary Keys",
DROP_FOREIGN_KEYS = "Drop Foreign Keys",
CREATE_FOREIGN_KEYS = "Create Foreign Keys",
CREATE_INDEXES = "Create Indexes",
CREATE_SQL_FOR_ALL_VENDORS = "Create SQL Statements for All Vendors",
GENERATE_DOML = "Generate Doml file",
GENERATE_XML = "Generate Xml files",
GENERATE_SQL = "Generate Sql files",
OPTIMIZED_MODE = "Optimized mode for all tables",
FULL_MODE = "Full mode for all tables",
INCLUDE_TABLE_LIST = "Include Table List (e.g. table1;table2)",
PATH_TO_CONF_IN_JAR = "Path to conf files in jar",
LOG_MODE = "Log mode",
LOG_FILE_NAME ="Log file name",
LOG_FILE_DIRECTORY = "Log file directory";
//dimensions
public static Dimension bigButton = new Dimension(140, 25);
public static Dimension toolBarButton = new Dimension(30, 30);
public static Dimension smallComponent = new Dimension(150, 20);
public static Dimension bigComponent = new Dimension(400, 20);
public static Dimension bigPlusButton = new Dimension(380, 20);
public static Dimension veryBigComponent = new Dimension(650, 20);
public static Dimension veryBigPlusButton = new Dimension(630, 20);
public static Dimension panelComponenet = new Dimension(720, 40);
JSplitPane main;
Border loweredBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
Border raisedBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
Border bevelBorder = BorderFactory.createLoweredBevelBorder();
private JCheckBox sqlFiles,
xmlFiles,
domlFile,
createTables,
createPK,
createFK,
createIn,
dropTables,
createSQLForAll,
dropFK;
private JRadioButton optimizedMode, fullMode;
private JTextField packageField, generatorOutput, addPaths;
// private OctopusProjectFrame parent;
private OctopusGeneratorData initData;
private HashMap fields;
private JTextArea traceArea;
public OctopusGeneratorPanel() {
// super("Octopus Generator Application", true, true, true, true);
// setFrameIcon( new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/"+
// "wizard/images/Enhydra16.gif")));
// this.parent = parent;
fields = new HashMap();
//generatorOptions
// JPanel generatorOptionsUp = new JPanel();
// JPanel generatorOptionsDown = new JPanel();
//generator input data
JTabbedPane octopusGeneratorData = new JTabbedPane();
JPanel commonPanel = new JPanel();
JPanel advancedPanel = new JPanel();
JPanel outputOptions = new JPanel();
octopusGeneratorData.addTab("JDBC", commonPanel);
octopusGeneratorData.addTab("Output options", outputOptions);
octopusGeneratorData.addTab("Advanced", advancedPanel);
//generatotOptionsUp panel
// generatorOptionsUp.setLayout(new BoxLayout(generatorOptionsUp, BoxLayout.Y_AXIS));
// generatorOptionsUp.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
// JButton help = createOctopusButton("Help", bigButton);
// help.setAction(new OctopusHelpAction());
// generatorOptionsUp.add(help);
//generatotOptionsDown panel
// generatorOptionsDown.setLayout(new BoxLayout(generatorOptionsDown, BoxLayout.Y_AXIS));
// generatorOptionsDown.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
// JButton start = createOctopusButton("Start", bigButton);
// start.setAction(new StartOctopusGenerator());
// JButton stop = createOctopusButton("Stop", bigButton);
// stop.setAction(new StopOctopusGenerator());
// JButton save = createOctopusButton("Save", bigButton);
// save.setAction(new SaveProjectAction());
// generatorOptionsDown.add(Box.createRigidArea(new Dimension(0, 5)));
// generatorOptionsDown.add(start);
// generatorOptionsDown.add(Box.createRigidArea(new Dimension(0, 5)));
// generatorOptionsDown.add(stop);
// generatorOptionsDown.add(Box.createRigidArea(new Dimension(0, 5)));
// generatorOptionsDown.add(save);
// generatorOptionsDown.add(Box.createRigidArea(new Dimension(0, 15)));
// generatorOptionsDown.add(help);
//generatorOptions
// JSplitPane generatorOptions = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true,
// generatorOptionsUp, generatorOptionsDown);
// generatorOptions.setOneTouchExpandable(true);
// generatorOptions.setDividerLocation(560);
// JSplitPane generatorInputData = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
// generatorOptions, octopusGeneratorData);
// JSplitPane generatorInputData =
// new JSplitPane(
// JSplitPane.HORIZONTAL_SPLIT,
// true,
// new JPanel(),
// octopusGeneratorData);
//advanced panel
JPanel pathToConfPanel = new JPanel();
pathToConfPanel.setLayout(new BoxLayout(pathToConfPanel, BoxLayout.X_AXIS));
pathToConfPanel.setBorder(setTitleOfBorder("Advanced Options", loweredBorder));
JLabel strPathToConf = OctopusProjectFrame.createOctopusLabel(PATH_TO_CONF_IN_JAR, smallComponent);
JTextField pathToConf = OctopusProjectFrame.createOctopusTextField(PATH_TO_CONF_IN_JAR, veryBigComponent);
pathToConfPanel.add(strPathToConf);
pathToConfPanel.add(pathToConf);
JPanel mainPathToConfPanel = new JPanel();
mainPathToConfPanel.setLayout(new BoxLayout(mainPathToConfPanel, BoxLayout.X_AXIS));
mainPathToConfPanel.add(pathToConfPanel);
mainPathToConfPanel.add(Box.createHorizontalGlue());
advancedPanel.setLayout(new BoxLayout(advancedPanel, BoxLayout.Y_AXIS));
advancedPanel.add(Box.createRigidArea(new Dimension(0, 15)));
advancedPanel.add(mainPathToConfPanel);
//sourcePanel
JPanel sourcePanel = new JPanel();
sourcePanel.setLayout(new BoxLayout(sourcePanel, BoxLayout.Y_AXIS));
//sourceType
JLabel strSourceType = OctopusProjectFrame.createOctopusLabel(SOURCE_TYPE, bigComponent);
JComboBox sourceType = OctopusProjectFrame.createOctopusCombobox(SOURCE_TYPE, bigComponent);
//sourceUrl
JLabel strSourceUrl = OctopusProjectFrame.createOctopusLabel(SOURCE_DATABASE, bigComponent);
JTextField sourceUrl = OctopusProjectFrame.createOctopusTextField(SOURCE_DATABASE, bigComponent);
//sourceDriverName
JLabel strSourceDriverName = OctopusProjectFrame.createOctopusLabel(SOURCE_DRIVER_NAME, bigComponent);
JComboBox sourceDriverName = OctopusProjectFrame.createOctopusCombobox(SOURCE_DRIVER_NAME, bigComponent);
//sourceUser
JLabel strSourceUser = OctopusProjectFrame.createOctopusLabel(SOURCE_USER, bigComponent);
JTextField sourceUser = OctopusProjectFrame.createOctopusTextField(SOURCE_USER, bigComponent);
//sourcePassword
JLabel strSourcePassword = OctopusProjectFrame.createOctopusLabel(SOURCE_PASSWORD, bigComponent);
JTextField sourcePassword = OctopusProjectFrame.createOctopusTextField(SOURCE_PASSWORD, bigComponent);
//doml
JLabel strDomlUrl = OctopusProjectFrame.createOctopusLabel(DOML_PATH, bigComponent);
JTextField domlUrl = OctopusProjectFrame.createOctopusTextField(DOML_PATH, bigPlusButton);
JButton domlButton = OctopusProjectFrame.createOctopusButton("doml url button", new Dimension(20, 20));
domlButton.setAction(new BrowseAction_DOML());
ImageIcon icon =
new ImageIcon(
getClass().getClassLoader().getResource(
"org/webdocwf/util/loader/" + "wizard/images/database.gif"));
JLabel sourceLabel = new JLabel("JDBC Source Database", icon, SwingConstants.RIGHT);
sourcePanel.add(createJDBCRow(sourceLabel, null));
sourcePanel.add(Box.createRigidArea(new Dimension(0, 10)));
sourcePanel.add(createJDBCRow(strSourceType, null));
sourcePanel.add(createJDBCRow(sourceType, null));
sourcePanel.add(createJDBCRow(strSourceUrl, null));
sourcePanel.add(createJDBCRow(sourceUrl, null));
sourcePanel.add(createJDBCRow(strDomlUrl, null));
sourcePanel.add(createJDBCRow(domlUrl, domlButton));
sourcePanel.add(createJDBCRow(strSourceDriverName, null));
sourcePanel.add(createJDBCRow(sourceDriverName, null));
sourcePanel.add(createJDBCRow(strSourceUser, null));
sourcePanel.add(createJDBCRow(sourceUser, null));
sourcePanel.add(createJDBCRow(strSourcePassword, null));
sourcePanel.add(createJDBCRow(sourcePassword, null));
sourcePanel.setBorder(setTitleOfBorder("", bevelBorder));
//targetPanel
JPanel targetPanel = new JPanel();
targetPanel.setLayout(new BoxLayout(targetPanel, BoxLayout.Y_AXIS));
//targetType
JLabel strTargetType = OctopusProjectFrame.createOctopusLabel(TARGET_TYPE, bigComponent);
JComboBox targetType = OctopusProjectFrame.createOctopusCombobox(TARGET_TYPE, bigComponent);
//targetUrl
JLabel strTargetUrl =OctopusProjectFrame.createOctopusLabel(TARGET_DATABASE, bigComponent);
JTextField targetUrl = OctopusProjectFrame.createOctopusTextField(TARGET_DATABASE, bigComponent);
//targetDriverName
JLabel strTargetDriverName = OctopusProjectFrame.createOctopusLabel(TARGET_DRIVER_NAME, bigComponent);
JComboBox targetDriverName = OctopusProjectFrame.createOctopusCombobox(TARGET_DRIVER_NAME, bigComponent);
//targetUser
JLabel strTargetUser = OctopusProjectFrame.createOctopusLabel(TARGET_USER, bigComponent);
JTextField targetUser = OctopusProjectFrame.createOctopusTextField(TARGET_USER, bigComponent);
//targetPassword
JLabel strTargetPassword = OctopusProjectFrame.createOctopusLabel(TARGET_PASSWORD, bigComponent);
JTextField targetPassword = OctopusProjectFrame.createOctopusTextField(TARGET_PASSWORD, bigComponent);
JLabel strTargetDoml = OctopusProjectFrame.createOctopusLabel("Doml URL", bigComponent);
String msg = "Doml file will be placed in output directory";
JTextField targetDoml = OctopusProjectFrame.createOctopusTextField("Doml URL target", bigComponent);
targetDoml.setText(msg);
targetDoml.setEditable(false);
ImageIcon icon2 =
new ImageIcon(
getClass().getClassLoader().getResource(
"org/webdocwf/util/loader/" + "wizard/images/database2.gif"));
JLabel targetLabel = new JLabel("JDBC Target Database", icon2, SwingConstants.RIGHT);
targetPanel.add(createJDBCRow(targetLabel, null));
targetPanel.add(Box.createRigidArea(new Dimension(0, 10)));
targetPanel.add(createJDBCRow(strTargetType, null));
targetPanel.add(createJDBCRow(targetType, null));
targetPanel.add(createJDBCRow(strTargetUrl, null));
targetPanel.add(createJDBCRow(targetUrl, null));
targetPanel.add(createJDBCRow(strTargetDoml, null));
targetPanel.add(createJDBCRow(targetDoml, null));
targetPanel.add(createJDBCRow(strTargetDriverName, null));
targetPanel.add(createJDBCRow(targetDriverName, null));
targetPanel.add(createJDBCRow(strTargetUser, null));
targetPanel.add(createJDBCRow(targetUser, null));
targetPanel.add(createJDBCRow(strTargetPassword, null));
targetPanel.add(createJDBCRow(targetPassword, null));
targetPanel.setBorder(setTitleOfBorder("", bevelBorder));
JPanel JDBCPanel = new JPanel();
JDBCPanel.setLayout(new BoxLayout(JDBCPanel, BoxLayout.X_AXIS));
JDBCPanel.add(sourcePanel);
JDBCPanel.add(targetPanel);
JPanel JDBCMainPanel = new JPanel();
JDBCMainPanel.setLayout(new BoxLayout(JDBCMainPanel, BoxLayout.X_AXIS));
JDBCMainPanel.add(JDBCPanel);
JDBCMainPanel.add(Box.createHorizontalGlue());
//value mode panel
JPanel valuModePanel = new JPanel();
valuModePanel.setLayout(new BoxLayout(valuModePanel, BoxLayout.X_AXIS));
valuModePanel.setBorder(setTitleOfBorder("Value mode", loweredBorder));
JLabel strValueMode = OctopusProjectFrame.createOctopusLabel(VALUE_MODE, smallComponent);
JComboBox valueMode = OctopusProjectFrame.createOctopusCombobox(VALUE_MODE, veryBigComponent);
valuModePanel.add(strValueMode);
valuModePanel.add(valueMode);
JPanel mainValueModePanel = new JPanel();
mainValueModePanel.setLayout(new BoxLayout(mainValueModePanel, BoxLayout.X_AXIS));
mainValueModePanel.add(valuModePanel);
mainValueModePanel.add(Box.createHorizontalGlue());
//generatorOutput panel
JPanel generatorOutputPanel = new JPanel();
generatorOutputPanel.setLayout(new BoxLayout(generatorOutputPanel, BoxLayout.X_AXIS));
JPanel generatorOutputInnerPanel = new JPanel();
JButton browseGeneratorOutput = OctopusProjectFrame.createOctopusButton("O", new Dimension(20, 20));
browseGeneratorOutput.setAction(new BrowseAction_GO());
generatorOutputInnerPanel.setLayout(
new BoxLayout(generatorOutputInnerPanel, BoxLayout.X_AXIS));
generatorOutputInnerPanel.setBorder(
setTitleOfBorder("Generator Output", loweredBorder));
JLabel strGeneratorOutput = OctopusProjectFrame.createOctopusLabel(GENERATOR_OUTPUT, smallComponent);
generatorOutput = OctopusProjectFrame.createOctopusTextField(GENERATOR_OUTPUT, veryBigPlusButton);
generatorOutputInnerPanel.add(strGeneratorOutput);
generatorOutputInnerPanel.add(generatorOutput);
generatorOutputInnerPanel.add(browseGeneratorOutput);
generatorOutputPanel.add(generatorOutputInnerPanel);
generatorOutputPanel.add(Box.createHorizontalGlue());
//includetablelist panel
JPanel includeTableListPanel = new JPanel();
includeTableListPanel.setLayout(new BoxLayout(includeTableListPanel, BoxLayout.X_AXIS));
JPanel includeTableListInnerPanel = new JPanel();
includeTableListInnerPanel.setLayout(
new BoxLayout(includeTableListInnerPanel, BoxLayout.X_AXIS));
includeTableListInnerPanel.setBorder(setTitleOfBorder("Tables List", loweredBorder));
JLabel strIncludeTableList = OctopusProjectFrame.createOctopusLabel(INCLUDE_TABLE_LIST, smallComponent);
JTextField includeTableList =
OctopusProjectFrame.createOctopusTextField(INCLUDE_TABLE_LIST, veryBigComponent);
includeTableListInnerPanel.add(strIncludeTableList);
includeTableListInnerPanel.add(includeTableList);
includeTableListPanel.add(includeTableListInnerPanel);
includeTableListPanel.add(Box.createHorizontalGlue());
//additinal classpaths panel
JPanel addPathsPanel = new JPanel();
addPathsPanel.setLayout(new BoxLayout(addPathsPanel, BoxLayout.X_AXIS));
JPanel addPathsInnerPanel = new JPanel();
JButton browseAdditionalClass = OctopusProjectFrame.createOctopusButton("O", new Dimension(20, 20));
browseAdditionalClass.setAction(new BrowseAction_AC());
addPathsInnerPanel.setLayout(new BoxLayout(addPathsInnerPanel, BoxLayout.X_AXIS));
addPathsInnerPanel.setBorder(setTitleOfBorder("Add new drivers", loweredBorder));
JLabel strAddPaths = OctopusProjectFrame.createOctopusLabel(ADDITIONAL_PATHS, smallComponent);
addPaths = OctopusProjectFrame.createOctopusTextField(ADDITIONAL_PATHS, veryBigPlusButton);
addPathsInnerPanel.add(strAddPaths);
addPathsInnerPanel.add(addPaths);
addPathsInnerPanel.add(browseAdditionalClass);
addPathsPanel.add(addPathsInnerPanel);
addPathsPanel.add(Box.createHorizontalGlue());
JPanel commonOptionsPanel = new JPanel();
JPanel commonOptionsMainPanel = new JPanel();
commonOptionsPanel.setLayout(new BoxLayout(commonOptionsPanel, BoxLayout.Y_AXIS));
commonOptionsMainPanel.setLayout(
new BoxLayout(commonOptionsMainPanel, BoxLayout.X_AXIS));
commonOptionsPanel.add(mainValueModePanel);
commonOptionsPanel.add(generatorOutputPanel);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -