1 56 package org.objectstyle.cayenne.modeler.dialog.db; 57 58 import java.awt.BorderLayout ; 59 import java.awt.Component ; 60 import java.awt.Container ; 61 import java.awt.Dimension ; 62 import java.awt.FlowLayout ; 63 import java.awt.GridLayout ; 64 65 import javax.swing.Box ; 66 import javax.swing.JButton ; 67 import javax.swing.JCheckBox ; 68 import javax.swing.JDialog ; 69 import javax.swing.JLabel ; 70 import javax.swing.JPanel ; 71 import javax.swing.JScrollPane ; 72 import javax.swing.JTabbedPane ; 73 import javax.swing.JTextArea ; 74 75 import com.jgoodies.forms.builder.PanelBuilder; 76 import com.jgoodies.forms.layout.CellConstraints; 77 import com.jgoodies.forms.layout.FormLayout; 78 79 82 public class DBGeneratorOptionsView extends JDialog { 83 84 protected JTextArea sql; 85 protected JButton generateButton; 86 protected JButton cancelButton; 87 protected JButton saveSqlButton; 88 protected JCheckBox dropTables; 89 protected JCheckBox createTables; 90 protected JCheckBox createFK; 91 protected JCheckBox createPK; 92 protected JCheckBox dropPK; 93 protected Component tables; 94 protected JTabbedPane tabs; 95 96 public DBGeneratorOptionsView(Component tables) { 97 this.generateButton = new JButton ("Generate"); 99 this.cancelButton = new JButton ("Close"); 100 this.saveSqlButton = new JButton ("Save SQL"); 101 this.dropTables = new JCheckBox ("Drop Tables"); 102 this.createTables = new JCheckBox ("Create Tables"); 103 this.createFK = new JCheckBox ("Create FK Support"); 104 this.createPK = new JCheckBox ("Create Primary Key Support"); 105 this.dropPK = new JCheckBox ("Drop Primary Key Support"); 106 this.tables = tables; 107 this.tabs = new JTabbedPane (JTabbedPane.TOP); 108 this.sql = new JTextArea (); 109 sql.setEditable(false); 110 sql.setLineWrap(true); 111 sql.setWrapStyleWord(true); 112 113 JPanel optionsPane = new JPanel (new GridLayout (3, 2)); 115 optionsPane.add(dropTables); 116 optionsPane.add(createTables); 117 optionsPane.add(new JLabel ()); 118 optionsPane.add(createFK); 119 optionsPane.add(dropPK); 120 optionsPane.add(createPK); 121 122 JPanel sqlTextPanel = new JPanel (new BorderLayout ()); 123 sqlTextPanel.add(new JScrollPane ( 124 sql, 125 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, 126 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER); 127 128 CellConstraints cc = new CellConstraints(); 129 PanelBuilder builder = new PanelBuilder(new FormLayout( 130 "fill:min(50dlu;pref):grow", 131 "p, 3dlu, p, 9dlu, p, 3dlu, fill:40dlu:grow")); 132 builder.setDefaultDialogBorder(); 133 builder.addSeparator("Options", cc.xywh(1, 1, 1, 1)); 134 builder.add(optionsPane, cc.xy(1, 3, "left,fill")); 135 builder.addSeparator("Generated SQL", cc.xywh(1, 5, 1, 1)); 136 builder.add(sqlTextPanel, cc.xy(1, 7)); 137 138 tabs.addTab("SQL Options", builder.getPanel()); 139 tabs.addTab("Tables", new JScrollPane ( 140 tables, 141 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, 142 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); 143 144 tabs.setPreferredSize(new Dimension (450, 350)); 147 148 JPanel buttons = new JPanel (new FlowLayout (FlowLayout.RIGHT)); 149 buttons.add(saveSqlButton); 150 buttons.add(Box.createHorizontalStrut(20)); 151 buttons.add(cancelButton); 152 buttons.add(generateButton); 153 154 Container contentPane = this.getContentPane(); 155 contentPane.setLayout(new BorderLayout ()); 156 contentPane.add(tabs, BorderLayout.CENTER); 157 contentPane.add(buttons, BorderLayout.SOUTH); 158 } 159 160 public JButton getCancelButton() { 161 return cancelButton; 162 } 163 164 public JTabbedPane getTabs() { 165 return tabs; 166 } 167 168 public JCheckBox getCreateFK() { 169 return createFK; 170 } 171 172 public JCheckBox getCreatePK() { 173 return createPK; 174 } 175 176 public JCheckBox getCreateTables() { 177 return createTables; 178 } 179 180 public JCheckBox getDropPK() { 181 return dropPK; 182 } 183 184 public JCheckBox getDropTables() { 185 return dropTables; 186 } 187 188 public JButton getGenerateButton() { 189 return generateButton; 190 } 191 192 public JButton getSaveSqlButton() { 193 return saveSqlButton; 194 } 195 196 public JTextArea getSql() { 197 return sql; 198 } 199 } | Popular Tags |