Source Code Cross Referenced for JoinMainDialog.java in  » IDE-Netbeans » etl.project » org » netbeans » modules » sql » framework » ui » view » join » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » etl.project » org.netbeans.modules.sql.framework.ui.view.join 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.modules.sql.framework.ui.view.join;
042:
043:        import java.awt.BorderLayout;
044:        import java.awt.Container;
045:        import java.awt.Dimension;
046:        import java.awt.FlowLayout;
047:        import java.awt.Frame;
048:        import java.awt.event.ActionEvent;
049:        import java.awt.event.ActionListener;
050:        import java.awt.event.WindowAdapter;
051:        import java.awt.event.WindowEvent;
052:        import java.util.Collection;
053:        import java.util.List;
054:
055:        import javax.swing.BorderFactory;
056:        import javax.swing.JButton;
057:        import javax.swing.JDialog;
058:        import javax.swing.JPanel;
059:        import javax.swing.JRootPane;
060:        import javax.swing.JSeparator;
061:        import javax.swing.ListModel;
062:        import javax.swing.event.ListDataEvent;
063:        import javax.swing.event.ListDataListener;
064:        import net.java.hulp.i18n.Logger;
065:        import org.netbeans.modules.etl.logger.Localizer;
066:        import org.netbeans.modules.etl.logger.LogUtil;
067:        import org.netbeans.modules.sql.framework.model.DBTable;
068:        import org.netbeans.modules.sql.framework.model.SQLDBTable;
069:
070:        import org.netbeans.modules.sql.framework.model.SQLJoinView;
071:        import org.netbeans.modules.sql.framework.model.SourceTable;
072:        import org.netbeans.modules.sql.framework.ui.graph.IGraphView;
073:        import org.netbeans.modules.sql.framework.ui.utils.UIUtil;
074:        import org.openide.windows.WindowManager;
075:
076:        /**
077:         * This is the main join dialog which provides a view to define join between various
078:         * tables.
079:         * 
080:         * @author Ritesh Adval
081:         */
082:        public class JoinMainDialog extends JDialog {
083:
084:            public static final int OK_BUTTON = 0;
085:            public static final int CANCEL_BUTTON = 1;
086:            private static JoinMainPanel joinMainPanel;
087:            private JButton okButton;
088:            private JButton cancelButton;
089:            private static JoinMainDialog dlg;
090:            private static int buttonState = OK_BUTTON;
091:            private static IGraphView graphView;
092:            private static transient final Logger mLogger = LogUtil
093:                    .getLogger(JoinMainDialog.class.getName());
094:            private static transient final Localizer mLoc = Localizer.get();
095:
096:            /** Creates a new instance of JoinMainDialog */
097:            public JoinMainDialog() {
098:                this (WindowManager.getDefault().getMainWindow());
099:                this .setPreferredSize(new Dimension(780, 580));
100:            }
101:
102:            public JoinMainDialog(Frame parent) {
103:                super (parent);
104:                this .setPreferredSize(new Dimension(780, 580));
105:                initGUI();
106:            }
107:
108:            private void initGUI() {
109:                // initialize layout for dialog content panel
110:                Container contentPane = this .getContentPane();
111:                contentPane.setLayout(new BorderLayout());
112:
113:                // initialize join main panel
114:                joinMainPanel = new JoinMainPanel(graphView);
115:                joinMainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10,
116:                        10, 10));
117:                contentPane.add(joinMainPanel, BorderLayout.CENTER);
118:
119:                ListTransferPanel listPanel = joinMainPanel
120:                        .getListTransferPanel();
121:                // add a listener to listen for updates in list model so that
122:                // preview panel can be refreshed.
123:                listPanel.getDestinationJList().getModel().addListDataListener(
124:                        new TargetListDataListener());
125:
126:                // initialize the bottom button panel
127:                JPanel buttonPanel = new JPanel();
128:                buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
129:                buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5,
130:                        5));
131:
132:                JPanel bottomPanel = new JPanel(new BorderLayout());
133:                bottomPanel.add(new JSeparator(), BorderLayout.NORTH);
134:                bottomPanel.add(buttonPanel, BorderLayout.SOUTH);
135:
136:                contentPane.add(bottomPanel, BorderLayout.SOUTH);
137:                String nbBundle1 = mLoc.t("PRSR001: Ok");
138:                okButton = new JButton(Localizer.parse(nbBundle1));
139:                okButton.getAccessibleContext().setAccessibleName(
140:                        Localizer.parse(nbBundle1));
141:                okButton.setMnemonic(Localizer.parse(nbBundle1).charAt(0));
142:                String nbBundle2 = mLoc.t("PRSR001: Cancel");
143:                cancelButton = new JButton(Localizer.parse(nbBundle2));
144:                cancelButton.setMnemonic(Localizer.parse(nbBundle2).charAt(0));
145:                cancelButton.getAccessibleContext().setAccessibleName(
146:                        Localizer.parse(nbBundle2));
147:                int maxBWidth = okButton.getPreferredSize().width;
148:                if (cancelButton.getPreferredSize().width > maxBWidth) {
149:                    maxBWidth = cancelButton.getPreferredSize().width;
150:                }
151:
152:                okButton.setPreferredSize(new Dimension(maxBWidth, okButton
153:                        .getPreferredSize().height));
154:                cancelButton.setPreferredSize(new Dimension(maxBWidth,
155:                        cancelButton.getPreferredSize().height));
156:
157:                okButton.setEnabled(false);
158:
159:                // add action listener to button
160:                ButtonActionListener listener = new ButtonActionListener();
161:                okButton.addActionListener(listener);
162:                cancelButton.addActionListener(listener);
163:                // add all buttons to button panel
164:                buttonPanel.add(okButton);
165:                buttonPanel.add(cancelButton);
166:
167:                JRootPane rp = this .getRootPane();
168:                UIUtil.addEscapeListener(rp, listener);
169:
170:                this .addWindowListener(new JoinWindowAdapter());
171:            }
172:
173:            public void reset() {
174:            }
175:
176:            public static void showJoinDialog(Collection<DBTable> sList,
177:                    Collection<DBTable> tList, IGraphView view,
178:                    boolean enableButton) {
179:                graphView = view;
180:                if (dlg == null) {
181:                    dlg = new JoinMainDialog();
182:                }
183:                String nbBundle3 = mLoc.t("PRSR001: Create New Join View");
184:                dlg.setTitle(Localizer.parse(nbBundle3));
185:
186:                joinMainPanel.reset(view);
187:
188:                joinMainPanel.setSourceList(sList);
189:                joinMainPanel.setTargetList(tList);
190:                joinMainPanel.getListTransferPanel().enableButton(enableButton);
191:                makeDialogVisible();
192:            }
193:
194:            public static void showJoinDialog(Collection sList,
195:                    SQLJoinView jView, IGraphView view) {
196:                graphView = view;
197:                if (dlg == null) {
198:                    dlg = new JoinMainDialog();
199:                }
200:                String nbBundle4 = mLoc.t("PRSR001: Edit Join View");
201:                dlg.setTitle(Localizer.parse(nbBundle4) + " ("
202:                        + jView.getAliasName() + ")");
203:
204:                joinMainPanel.reset(view);
205:                joinMainPanel.setSourceList(sList);
206:                joinMainPanel.setSQLJoinView(jView);
207:
208:                makeDialogVisible();
209:            }
210:
211:            public static void showJoinDialog(Collection sList,
212:                    SourceTable sTable, SQLJoinView jView, IGraphView view) {
213:                graphView = view;
214:                if (dlg == null) {
215:                    dlg = new JoinMainDialog();
216:                }
217:                String nbBundle5 = mLoc.t("PRSR001: Edit Join View");
218:                dlg.setTitle(Localizer.parse(nbBundle5) + " ("
219:                        + jView.getAliasName() + ")");
220:
221:                joinMainPanel.reset(view);
222:                joinMainPanel.setSourceList(sList);
223:                joinMainPanel.setEditSQLJoinView(sTable, jView);
224:
225:                makeDialogVisible();
226:            }
227:
228:            private static void makeDialogVisible() {
229:                Frame f = WindowManager.getDefault().getMainWindow();
230:
231:                dlg.setModal(true);
232:                int width = (f.getWidth() * 4) / 5;
233:                int height = (f.getHeight() * 4) / 5;
234:                dlg.setSize(width, height);
235:                // call to pack resize dialog to preffered size
236:                joinMainPanel.setPreferredSize(new Dimension(width, height));
237:
238:                int x = (f.getWidth() - dlg.getWidth()) / 2;
239:                int y = (f.getHeight() - dlg.getHeight()) / 2;
240:
241:                dlg.setLocation(x, y);
242:                dlg.pack();
243:                joinMainPanel.setDividerLocation();
244:                dlg.setVisible(true);
245:                dlg.setSize(400, 400);
246:                dlg.setPreferredSize(new Dimension(400, 400));
247:            }
248:
249:            public static void showJoinDialog() {
250:                if (dlg == null) {
251:                    dlg = new JoinMainDialog();
252:                }
253:
254:                dlg.setModal(true);
255:                dlg.setPreferredSize(new Dimension(400, 400));
256:                dlg.pack();
257:                dlg.setVisible(true);
258:            }
259:
260:            public static void main(String[] args) {
261:                showJoinDialog();
262:            }
263:
264:            class ButtonActionListener implements  ActionListener {
265:
266:                /**
267:                 * Invoked when an action occurs.
268:                 */
269:                public void actionPerformed(ActionEvent e) {
270:                    Object source = e.getSource();
271:
272:                    if (source.equals(okButton)) {
273:                        buttonState = OK_BUTTON;
274:                        JoinMainDialog.this .setVisible(false);
275:                    } else {
276:                        // Treat Escape button also as Cancel button
277:                        buttonState = CANCEL_BUTTON;
278:                        handleCancel();
279:                        JoinMainDialog.this .setVisible(false);
280:                    }
281:                }
282:            }
283:
284:            private void handleCancel() {
285:                joinMainPanel.handleCancel();
286:            }
287:
288:            class JoinWindowAdapter extends WindowAdapter {
289:
290:                /**
291:                 * Invoked when a window has been closed.
292:                 */
293:                @Override
294:                public void windowClosing(WindowEvent e) {
295:                    buttonState = CANCEL_BUTTON;
296:                    handleCancel();
297:                    JoinMainDialog.this .setVisible(false);
298:                }
299:            }
300:
301:            public static SQLJoinView getSQLJoinView() {
302:                return joinMainPanel.getSQLJoinView();
303:            }
304:
305:            public static List getTableColumnNodes() {
306:                return joinMainPanel.getTableColumnNodes();
307:            }
308:
309:            public static int getClosingButtonState() {
310:                return buttonState;
311:            }
312:
313:            private void changeButtonState(ListDataEvent e) {
314:                ListModel model = (ListModel) e.getSource();
315:                if (model.getSize() > 1) {
316:                    this .okButton.setEnabled(true);
317:                } else {
318:                    this .okButton.setEnabled(false);
319:                }
320:            }
321:
322:            class TargetListDataListener implements  ListDataListener {
323:
324:                /**
325:                 * Sent when the contents of the list has changed in a way that's too complex to
326:                 * characterize with the previous methods. For example, this is sent when an item
327:                 * has been replaced. Index0 and index1 bracket the change.
328:                 * 
329:                 * @param e a <code>ListDataEvent</code> encapsulating the event information
330:                 */
331:                public void contentsChanged(ListDataEvent e) {
332:                    changeButtonState(e);
333:                }
334:
335:                /**
336:                 * Sent after the indices in the index0,index1 interval have been inserted in the
337:                 * data model. The new interval includes both index0 and index1.
338:                 * 
339:                 * @param e a <code>ListDataEvent</code> encapsulating the event information
340:                 */
341:                public void intervalAdded(ListDataEvent e) {
342:                    changeButtonState(e);
343:                }
344:
345:                /**
346:                 * Sent after the indices in the index0,index1 interval have been removed from the
347:                 * data model. The interval includes both index0 and index1.
348:                 * 
349:                 * @param e a <code>ListDataEvent</code> encapsulating the event information
350:                 */
351:                public void intervalRemoved(ListDataEvent e) {
352:                    changeButtonState(e);
353:                }
354:            }
355:        }
www___.__ja___va___2__s___.__com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.