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


001:        /*
002:         * The contents of this file are subject to the terms of the Common
003:         * Development
004:        The contents of this file are subject to the terms of either the GNU
005:        General Public License Version 2 only ("GPL") or the Common
006:        Development and Distribution License("CDDL") (collectively, the
007:        "License"). You may not use this file except in compliance with the
008:        License. You can obtain a copy of the License at
009:        http://www.netbeans.org/cddl-gplv2.html
010:        or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
011:        specific language governing permissions and limitations under the
012:        License.  When distributing the software, include this License Header
013:        Notice in each file and include the License file at
014:        nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
015:        particular file as subject to the "Classpath" exception as provided
016:        by Sun in the GPL Version 2 section of the License file that
017:        accompanied this code. If applicable, add the following below the
018:        License Header, with the fields enclosed by brackets [] replaced by
019:        your own identifying information:
020:        "Portions Copyrighted [year] [name of copyright owner]"
021:        Contributor(s):
022:         *
023:         * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
024:        If you wish your version of this file to be governed by only the CDDL
025:        or only the GPL Version 2, indicate your decision by adding
026:        "[Contributor] elects to include this software in this distribution
027:        under the [CDDL or GPL Version 2] license." If you do not indicate a
028:        single choice of license, a recipient has the option to distribute
029:        your version of this file under either the CDDL, the GPL Version 2 or
030:        to extend the choice of license to its licensees as provided above.
031:        However, if you add GPL Version 2 code and therefore, elected the GPL
032:        Version 2 license, then the option applies only if the new code is
033:        made subject to such option by the copyright holder.
034:         *
035:         */
036:        package org.netbeans.modules.etl.ui.palette;
037:
038:        import java.awt.Point;
039:        import java.awt.datatransfer.DataFlavor;
040:        import java.awt.datatransfer.UnsupportedFlavorException;
041:        import java.awt.event.ActionEvent;
042:        import java.beans.PropertyChangeEvent;
043:        import java.beans.PropertyChangeListener;
044:        import java.io.IOException;
045:        import javax.swing.Action;
046:        import org.netbeans.modules.etl.ui.view.ETLCollaborationTopPanel;
047:        import org.netbeans.modules.sql.framework.ui.graph.IGraphView;
048:        import org.netbeans.modules.sql.framework.ui.graph.IOperatorXmlInfo;
049:        import org.netbeans.modules.sql.framework.ui.graph.impl.OperatorXmlInfoModel;
050:        import org.netbeans.spi.palette.DragAndDropHandler;
051:        import org.netbeans.spi.palette.PaletteActions;
052:        import org.netbeans.spi.palette.PaletteController;
053:        import org.netbeans.spi.palette.PaletteFactory;
054:        import org.openide.nodes.Node;
055:        import org.openide.util.Lookup;
056:        import org.openide.util.datatransfer.ExTransferable;
057:
058:        /**
059:         *
060:         * @author nithya
061:         */
062:        public class PaletteSupport {
063:
064:            public static final String MASHUP_DATA_FLAVOR = DataFlavor.javaJVMLocalObjectMimeType;
065:            private static PaletteController controller;
066:            private static IGraphView graphView;
067:
068:            public PaletteSupport() {
069:            }
070:
071:            /**
072:             *
073:             * @return
074:             */
075:            public static PaletteController createPalette(
076:                    final ETLCollaborationTopPanel etlPanel) throws IOException {
077:                controller = PaletteFactory.createPalette("ETLOperators",
078:                        new ETLAction(), null, new ETLDnDHandler());
079:                controller
080:                        .addPropertyChangeListener(new PropertyChangeListener() {
081:
082:                            // FIXME: There should be a better way to do this.
083:                            ETLCollaborationTopPanel topPanel = etlPanel;
084:
085:                            public void propertyChange(PropertyChangeEvent evt) {
086:                                if (PaletteController.PROP_SELECTED_ITEM
087:                                        .equals(evt.getPropertyName())) {
088:                                    Lookup selItem = controller
089:                                            .getSelectedItem();
090:
091:                                    graphView = topPanel.getGraphView();
092:                                    if (null != selItem) {
093:                                        Node selNode = selItem
094:                                                .lookup(Node.class);
095:                                        if (null != selNode) {
096:                                            IOperatorXmlInfo opXmlInfo = OperatorXmlInfoModel
097:                                                    .getInstance("ETLOperators")
098:                                                    .findOperatorXmlInfo(
099:                                                            selNode.getName());
100:                                            graphView.setXMLInfo(opXmlInfo);
101:                                        }
102:                                    }
103:                                }
104:                            }
105:                        });
106:                return controller;
107:            }
108:
109:            public static class ETLAction extends PaletteActions {
110:
111:                /**
112:                 *
113:                 * @return
114:                 */
115:                public Action[] getImportActions() {
116:                    return new Action[0];
117:                }
118:
119:                /**
120:                 *
121:                 * @return
122:                 */
123:                public Action[] getCustomPaletteActions() {
124:                    return new Action[0];
125:                }
126:
127:                /**
128:                 *
129:                 * @param lookup
130:                 * @return
131:                 */
132:                public Action[] getCustomCategoryActions(Lookup lookup) {
133:                    return new Action[0];
134:                }
135:
136:                /**
137:                 *
138:                 * @param lookup
139:                 * @return
140:                 */
141:                public Action[] getCustomItemActions(Lookup lookup) {
142:                    return new Action[0];
143:                }
144:
145:                /**
146:                 *
147:                 * @param lookup
148:                 * @return
149:                 */
150:                public Action getPreferredAction(Lookup lookup) {
151:                    return new PreferredAction(lookup);
152:                }
153:            }
154:
155:            public static class PreferredAction implements  Action {
156:
157:                private IOperatorXmlInfo opXmlInfo = null;
158:
159:                // FIXME: There should be a better way to do this.
160:                public PreferredAction(Lookup lookup) {
161:                    Node node = lookup.lookup(Node.class);
162:                    if (null != node) {
163:                        opXmlInfo = OperatorXmlInfoModel.getInstance(
164:                                "ETLOperators").findOperatorXmlInfo(
165:                                node.getName());
166:                        graphView.setXMLInfo(opXmlInfo);
167:                    }
168:                }
169:
170:                public static String getSHORT_DESCRIPTION() {
171:                    return SHORT_DESCRIPTION;
172:                }
173:
174:                public Object getValue(String key) {
175:                    throw new UnsupportedOperationException(
176:                            "Not supported yet.");
177:                }
178:
179:                public void putValue(String key, Object value) {
180:                    throw new UnsupportedOperationException(
181:                            "Not supported yet.");
182:                }
183:
184:                public void setEnabled(boolean b) {
185:                    throw new UnsupportedOperationException(
186:                            "Not supported yet.");
187:                }
188:
189:                public boolean isEnabled() {
190:                    return true;
191:                }
192:
193:                public void addPropertyChangeListener(
194:                        PropertyChangeListener listener) {
195:                    throw new UnsupportedOperationException(
196:                            "Not supported yet.");
197:                }
198:
199:                public void removePropertyChangeListener(
200:                        PropertyChangeListener listener) {
201:                    throw new UnsupportedOperationException(
202:                            "Not supported yet.");
203:                }
204:
205:                public void actionPerformed(ActionEvent e) {
206:                    Point viewCoord = new Point();
207:                    if (graphView.getGraphController() != null) {
208:                        graphView.getGraphController().handleNodeAdded(
209:                                opXmlInfo, viewCoord);
210:                    }
211:                }
212:            }
213:
214:            private static class ETLDnDHandler extends DragAndDropHandler {
215:
216:                public void customize(ExTransferable exTransferable,
217:                        Lookup lookupobj) {
218:                    final Node node = lookupobj.lookup(Node.class);
219:                    DataFlavor flv = null;
220:                    try {
221:                        flv = new DataFlavor(
222:                                DataFlavor.javaJVMLocalObjectMimeType);
223:                    } catch (ClassNotFoundException ex) {
224:                        ex.printStackTrace();
225:                    }
226:                    exTransferable.put(new ExTransferable.Single(flv) {
227:
228:                        protected Object getData() throws IOException,
229:                                UnsupportedFlavorException {
230:                            return node;
231:                        }
232:                    });
233:                }
234:            }
235:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.