KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectstyle > cayenne > modeler > dialog > db > DBGeneratorOptionsView


1 /* ====================================================================
2  *
3  * The ObjectStyle Group Software License, version 1.1
4  * ObjectStyle Group - http://objectstyle.org/
5  *
6  * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
7  * of the software. All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution, if any,
22  * must include the following acknowlegement:
23  * "This product includes software developed by independent contributors
24  * and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
25  * Alternately, this acknowlegement may appear in the software itself,
26  * if and wherever such third-party acknowlegements normally appear.
27  *
28  * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
29  * or promote products derived from this software without prior written
30  * permission. For written permission, email
31  * "andrus at objectstyle dot org".
32  *
33  * 5. Products derived from this software may not be called "ObjectStyle"
34  * or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
35  * names without prior written permission.
36  *
37  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40  * DISCLAIMED. IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
41  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48  * SUCH DAMAGE.
49  * ====================================================================
50  *
51  * This software consists of voluntary contributions made by many
52  * individuals and hosted on ObjectStyle Group web site. For more
53  * information on the ObjectStyle Group, please see
54  * <http://objectstyle.org/>.
55  */

56 package org.objectstyle.cayenne.modeler.dialog.db;
57
58 import java.awt.BorderLayout JavaDoc;
59 import java.awt.Component JavaDoc;
60 import java.awt.Container JavaDoc;
61 import java.awt.Dimension JavaDoc;
62 import java.awt.FlowLayout JavaDoc;
63 import java.awt.GridLayout JavaDoc;
64
65 import javax.swing.Box JavaDoc;
66 import javax.swing.JButton JavaDoc;
67 import javax.swing.JCheckBox JavaDoc;
68 import javax.swing.JDialog JavaDoc;
69 import javax.swing.JLabel JavaDoc;
70 import javax.swing.JPanel JavaDoc;
71 import javax.swing.JScrollPane JavaDoc;
72 import javax.swing.JTabbedPane JavaDoc;
73 import javax.swing.JTextArea JavaDoc;
74
75 import com.jgoodies.forms.builder.PanelBuilder;
76 import com.jgoodies.forms.layout.CellConstraints;
77 import com.jgoodies.forms.layout.FormLayout;
78
79 /**
80  * Wizard for generating the database from the data map.
81  */

82 public class DBGeneratorOptionsView extends JDialog JavaDoc {
83
84     protected JTextArea JavaDoc sql;
85     protected JButton JavaDoc generateButton;
86     protected JButton JavaDoc cancelButton;
87     protected JButton JavaDoc saveSqlButton;
88     protected JCheckBox JavaDoc dropTables;
89     protected JCheckBox JavaDoc createTables;
90     protected JCheckBox JavaDoc createFK;
91     protected JCheckBox JavaDoc createPK;
92     protected JCheckBox JavaDoc dropPK;
93     protected Component JavaDoc tables;
94     protected JTabbedPane JavaDoc tabs;
95
96     public DBGeneratorOptionsView(Component JavaDoc tables) {
97         // create widgets
98
this.generateButton = new JButton JavaDoc("Generate");
99         this.cancelButton = new JButton JavaDoc("Close");
100         this.saveSqlButton = new JButton JavaDoc("Save SQL");
101         this.dropTables = new JCheckBox JavaDoc("Drop Tables");
102         this.createTables = new JCheckBox JavaDoc("Create Tables");
103         this.createFK = new JCheckBox JavaDoc("Create FK Support");
104         this.createPK = new JCheckBox JavaDoc("Create Primary Key Support");
105         this.dropPK = new JCheckBox JavaDoc("Drop Primary Key Support");
106         this.tables = tables;
107         this.tabs = new JTabbedPane JavaDoc(JTabbedPane.TOP);
108         this.sql = new JTextArea JavaDoc();
109         sql.setEditable(false);
110         sql.setLineWrap(true);
111         sql.setWrapStyleWord(true);
112
113         // assemble...
114
JPanel JavaDoc optionsPane = new JPanel JavaDoc(new GridLayout JavaDoc(3, 2));
115         optionsPane.add(dropTables);
116         optionsPane.add(createTables);
117         optionsPane.add(new JLabel JavaDoc());
118         optionsPane.add(createFK);
119         optionsPane.add(dropPK);
120         optionsPane.add(createPK);
121
122         JPanel JavaDoc sqlTextPanel = new JPanel JavaDoc(new BorderLayout JavaDoc());
123         sqlTextPanel.add(new JScrollPane JavaDoc(
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 JavaDoc(
140                 tables,
141                 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
142                 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
143
144         // we need the right preferred size so that dialog "pack()" produces decent
145
// default size...
146
tabs.setPreferredSize(new Dimension JavaDoc(450, 350));
147
148         JPanel JavaDoc buttons = new JPanel JavaDoc(new FlowLayout JavaDoc(FlowLayout.RIGHT));
149         buttons.add(saveSqlButton);
150         buttons.add(Box.createHorizontalStrut(20));
151         buttons.add(cancelButton);
152         buttons.add(generateButton);
153
154         Container JavaDoc contentPane = this.getContentPane();
155         contentPane.setLayout(new BorderLayout JavaDoc());
156         contentPane.add(tabs, BorderLayout.CENTER);
157         contentPane.add(buttons, BorderLayout.SOUTH);
158     }
159
160     public JButton JavaDoc getCancelButton() {
161         return cancelButton;
162     }
163
164     public JTabbedPane JavaDoc getTabs() {
165         return tabs;
166     }
167
168     public JCheckBox JavaDoc getCreateFK() {
169         return createFK;
170     }
171
172     public JCheckBox JavaDoc getCreatePK() {
173         return createPK;
174     }
175
176     public JCheckBox JavaDoc getCreateTables() {
177         return createTables;
178     }
179
180     public JCheckBox JavaDoc getDropPK() {
181         return dropPK;
182     }
183
184     public JCheckBox JavaDoc getDropTables() {
185         return dropTables;
186     }
187
188     public JButton JavaDoc getGenerateButton() {
189         return generateButton;
190     }
191
192     public JButton JavaDoc getSaveSqlButton() {
193         return saveSqlButton;
194     }
195
196     public JTextArea JavaDoc getSql() {
197         return sql;
198     }
199 }
Popular Tags