Source Code Cross Referenced for CustomSQLOperatorGraphNode.java in  » IDE-Netbeans » etl.project » org » netbeans » modules » sql » framework » ui » view » graph » 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.graph 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* *************************************************************************
002:         *
003:         *          Copyright (c) 2005, Sun Microsystems,
004:         *          All Rights Reserved.
005:
006:        If you wish your version of this file to be governed by only the CDDL
007:        or only the GPL Version 2, indicate your decision by adding
008:        "[Contributor] elects to include this software in this distribution
009:        under the [CDDL or GPL Version 2] license." If you do not indicate a
010:        single choice of license, a recipient has the option to distribute
011:        your version of this file under either the CDDL, the GPL Version 2 or
012:        to extend the choice of license to its licensees as provided above.
013:        However, if you add GPL Version 2 code and therefore, elected the GPL
014:        Version 2 license, then the option applies only if the new code is
015:        made subject to such option by the copyright holder.
016:
017:        If you wish your version of this file to be governed by only the CDDL
018:        or only the GPL Version 2, indicate your decision by adding
019:        "[Contributor] elects to include this software in this distribution
020:        under the [CDDL or GPL Version 2] license." If you do not indicate a
021:        single choice of license, a recipient has the option to distribute
022:        your version of this file under either the CDDL, the GPL Version 2 or
023:        to extend the choice of license to its licensees as provided above.
024:        However, if you add GPL Version 2 code and therefore, elected the GPL
025:        Version 2 license, then the option applies only if the new code is
026:        made subject to such option by the copyright holder.
027:         *
028:         *          This program, and all the routines referenced herein,
029:         *          are the proprietary properties and trade secrets of
030:         *          Sun Microsystems.
031:         *
032:         *          Except as provided for by license agreement, this
033:         *          program shall not be duplicated, used, or disclosed
034:         *          without  written consent signed by an officer of
035:         *          Sun Microsystems.
036:         *
037:         ***************************************************************************/
038:        package org.netbeans.modules.sql.framework.ui.view.graph;
039:
040:        import java.awt.Dialog;
041:        import java.awt.event.ActionEvent;
042:        import java.util.Iterator;
043:        import java.util.List;
044:
045:        import javax.swing.ImageIcon;
046:        import javax.swing.JMenuItem;
047:        import javax.swing.JPopupMenu;
048:        import net.java.hulp.i18n.Logger;
049:        import com.sun.sql.framework.jdbc.SQLUtils;
050:        import org.netbeans.modules.etl.logger.Localizer;
051:        import org.netbeans.modules.etl.logger.LogUtil;
052:        import org.netbeans.modules.sql.framework.model.GUIInfo;
053:        import org.netbeans.modules.sql.framework.model.SQLCanvasObject;
054:        import org.netbeans.modules.sql.framework.model.SQLOperatorArg;
055:        import org.netbeans.modules.sql.framework.model.impl.SQLCustomOperatorImpl;
056:        import org.netbeans.modules.sql.framework.ui.graph.IOperatorField;
057:        import org.netbeans.modules.sql.framework.ui.graph.IOperatorXmlInfo;
058:        import org.netbeans.modules.sql.framework.ui.graph.impl.CustomOperatorNode;
059:        import org.netbeans.modules.sql.framework.ui.graph.impl.OperatorGraphFieldNode;
060:        import org.netbeans.modules.sql.framework.ui.model.CollabSQLUIModel;
061:        import org.netbeans.modules.sql.framework.ui.model.impl.ConditionBuilderSQLUIModelImpl;
062:        import org.netbeans.modules.sql.framework.ui.view.graph.SQLOperatorGraphNode.OperatorActionListener;
063:        import org.openide.DialogDescriptor;
064:        import org.openide.DialogDisplayer;
065:        import org.openide.NotifyDescriptor;
066:
067:        /**
068:         * Graphical representation of a custom operator
069:         *
070:         * @author Srinivasan Rengarajan
071:         */
072:        public class CustomSQLOperatorGraphNode extends SQLOperatorGraphNode {
073:
074:            private static transient final Logger mLogger = LogUtil
075:                    .getLogger(CustomSQLOperatorGraphNode.class.getName());
076:            private static transient final Localizer mLoc = Localizer.get();
077:            private JMenuItem editItem;
078:            private IOperatorXmlInfo info;
079:            private static final String LOG_CATEGORY = CustomSQLOperatorGraphNode.class
080:                    .getName();
081:
082:            /** Creates a new instance of OperatorGraphNode */
083:            public CustomSQLOperatorGraphNode(IOperatorXmlInfo info) {
084:
085:                super (info, false);
086:                this .info = info;
087:            }
088:
089:            public CustomSQLOperatorGraphNode(IOperatorXmlInfo info,
090:                    boolean show) {
091:
092:                super (info, show);
093:                this .info = info;
094:            }
095:
096:            public CustomSQLOperatorGraphNode(IOperatorXmlInfo info,
097:                    boolean show, String nameOverride) {
098:
099:                super (info, show, nameOverride);
100:                this .info = info;
101:            }
102:
103:            /**
104:             * populates the menu and adds the edit option
105:             */
106:            protected void initializePopUpMenu() {
107:
108:                CustomOperatorActionListener aListener = new CustomOperatorActionListener();
109:                // remove menu
110:                if (popUpMenu == null) {
111:                    popUpMenu = new JPopupMenu();
112:                }
113:
114:                editItem = new JMenuItem("Edit", new ImageIcon(editUrl));
115:                editItem.addActionListener(aListener);
116:                popUpMenu.add(editItem);
117:                popUpMenu.addSeparator();
118:                super .initializePopUpMenu();
119:
120:            }
121:
122:            private class CustomOperatorActionListener extends
123:                    OperatorActionListener {
124:
125:                public void actionPerformed(ActionEvent e) {
126:                    super .actionPerformed(e);
127:                    Object source = e.getSource();
128:                    if (source == editItem) {
129:                        editItem_actionPerformed(e);
130:                    }
131:                }
132:            }
133:
134:            /**
135:             * method invoked to edit a custom operator definition
136:             *
137:             */
138:            private void editCustomOperator() {
139:                // step1 : get the original Data object
140:                SQLCanvasObject sqlObj = (SQLCanvasObject) this .getDataObject();
141:                Object graphModel = getGraphView().getGraphModel();
142:                // step2 : clone it
143:                SQLCanvasObject copyObj = null;
144:                try {
145:                    // step3 : build the gui
146:                    SQLCustomOperatorImpl custOp = (SQLCustomOperatorImpl) sqlObj;
147:                    SQLOperatorArg retType = null;
148:
149:                    Iterator iter = custOp.getOperatorXmlInfo()
150:                            .getOutputFields().iterator();
151:                    if (iter.hasNext()) {
152:                        IOperatorField operField = (IOperatorField) iter.next();
153:                        String jdbcType = (String) operField
154:                                .getAttributeValue("retTypeStr");
155:                        retType = new SQLOperatorArg(operField.getName(),
156:                                SQLUtils.getStdJdbcType(jdbcType));
157:                    }
158:                    List inputArgs = custOp.getOperatorDefinition()
159:                            .getArgList();
160:
161:                    CustomOperatorPane customOptPane = new CustomOperatorPane(
162:                            inputArgs, retType);
163:
164:                    customOptPane.setFunctionName(custOp
165:                            .getCustomOperatorName());
166:                    // String title = NbBundle.getMessage(BasicSQLGraphController.class,
167:                    // "TITLE_user_function");
168:                    DialogDescriptor dlgDesc = new DialogDescriptor(
169:                            customOptPane, "title", true,
170:                            NotifyDescriptor.OK_CANCEL_OPTION,
171:                            NotifyDescriptor.OK_OPTION,
172:                            DialogDescriptor.DEFAULT_ALIGN, null, null);
173:                    Dialog customOptDialog = DialogDisplayer.getDefault()
174:                            .createDialog(dlgDesc);
175:                    customOptDialog
176:                            .getAccessibleContext()
177:                            .setAccessibleDescription(
178:                                    "This dialog provides information about Custom Operators");
179:                    customOptDialog.setVisible(true);
180:                    if (NotifyDescriptor.CANCEL_OPTION == dlgDesc.getValue()) {
181:                        return;
182:                    }
183:
184:                    // step 4: apply changes to the custOp which is a clone of the data
185:                    // object
186:                    inputArgs = customOptPane.getArgList();
187:                    retType = customOptPane.getReturnType();
188:                    custOp.setCustomOperatorName(customOptPane
189:                            .getFunctionName());
190:                    custOp.getOperatorDefinition().setArgList(inputArgs);
191:                    CustomOperatorNode customOptNode = new CustomOperatorNode(
192:                            info, inputArgs, retType);
193:                    custOp.setOperatorXmlInfo(customOptNode);
194:                    Iterator fieldIter = fieldList.iterator();
195:                    while (fieldIter.hasNext()) {
196:                        OperatorGraphFieldNode fieldNode = (OperatorGraphFieldNode) fieldIter
197:                                .next();
198:                        this .removeObject(fieldNode);
199:
200:                    }
201:                    this .fieldList.clear();
202:                    super .initialize(customOptNode);
203:                    GUIInfo guiInfo = custOp.getGUIInfo();
204:                    int x = guiInfo.getX();
205:                    int y = guiInfo.getY();
206:                    int width = guiInfo.getWidth();
207:                    int height = guiInfo.getHeight();
208:                    this .getBoundingRect().setLocation(x, y);
209:                    this .getBoundingRect().setSize(width, height);
210:                    this .titleArea.setTitle(customOptPane.getFunctionName());
211:                    this .titleArea.setTopLeft(x, y);
212:                    this .layoutChildren();
213:                    if (graphModel instanceof  CollabSQLUIModel) {
214:                        ((CollabSQLUIModel) graphModel).restoreUIState();
215:                    } else if (graphModel instanceof  ConditionBuilderSQLUIModelImpl) {
216:                        ((ConditionBuilderSQLUIModelImpl) graphModel)
217:                                .restoreUIState();
218:                    }
219:                } catch (Exception e) {
220:                    mLogger.errorNoloc(mLoc.t("PRSR167: editCustomOperator{0}",
221:                            e.getMessage()), e);
222:                }
223:            }
224:
225:            /**
226:             * Invoked when an action occurs.
227:             */
228:            private void editItem_actionPerformed(ActionEvent e) {
229:                this.editCustomOperator();
230:            }
231:        }
ww_w.j_a_v___a_2_s___.c__om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.