Source Code Cross Referenced for BasicCanvasArea.java in  » IDE-Netbeans » etl.project » org » netbeans » modules » sql » framework » ui » graph » impl » 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.graph.impl 
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:
042:        package org.netbeans.modules.sql.framework.ui.graph.impl;
043:
044:        import java.awt.Dimension;
045:        import java.awt.Point;
046:        import java.awt.Rectangle;
047:        import java.util.Iterator;
048:        import java.util.List;
049:
050:        import javax.swing.Action;
051:        import javax.swing.JMenuItem;
052:        import javax.swing.JPopupMenu;
053:
054:        import org.netbeans.modules.sql.framework.model.GUIInfo;
055:        import org.netbeans.modules.sql.framework.model.SQLCanvasObject;
056:        import org.netbeans.modules.sql.framework.ui.graph.IGraphNode;
057:        import org.netbeans.modules.sql.framework.ui.graph.IGraphPort;
058:        import org.netbeans.modules.sql.framework.ui.graph.IGraphView;
059:
060:        import com.nwoods.jgo.JGoView;
061:
062:        /**
063:         * @author Ritesh Adval
064:         * @version $Revision$
065:         */
066:        public class BasicCanvasArea extends CanvasArea implements  IGraphNode {
067:
068:            protected TitleArea titleArea;
069:            protected Dimension expandedSize;
070:            protected Object dataObject = null;
071:            protected IGraphView view;
072:            protected JPopupMenu popUpMenu;
073:
074:            private boolean updateGuiInfo = true;
075:
076:            /** Creates a new instance of BasicCanvasArea */
077:            public BasicCanvasArea() {
078:                super ();
079:                expandedSize = new Dimension(-1, -1);
080:                titleArea = new TitleArea("dummy");
081:            }
082:
083:            /**
084:             * Expand this graph node
085:             * 
086:             * @param expand whether to expand or collapse this node
087:             */
088:            public void expand(boolean expand) {
089:                this .setExpandedState(expand);
090:            }
091:
092:            /**
093:             * set the expansion state of the graph node
094:             * 
095:             * @param expand expansion state
096:             */
097:            public void setExpandedState(boolean expand) {
098:                if (expand) {
099:                    titleArea.setState(TitleArea.EXPANDED);
100:                } else {
101:                    titleArea.setState(TitleArea.COLLAPSED);
102:                }
103:            }
104:
105:            /**
106:             * get the expanded state
107:             * 
108:             * @return expanded state
109:             */
110:            public boolean isExpandedState() {
111:                if (titleArea.getState() == TitleArea.EXPANDED) {
112:                    return true;
113:                }
114:
115:                return false;
116:            }
117:
118:            /**
119:             * get a list of all input and output links
120:             * 
121:             * @return list of input links
122:             */
123:            public List getAllLinks() {
124:                return null;
125:            }
126:
127:            /**
128:             * get the child graphNode
129:             * 
130:             * @param obj child data object
131:             * @return graph node
132:             */
133:            public IGraphNode getChildNode(Object obj) {
134:                return null;
135:            }
136:
137:            /**
138:             * get the data object associated with graph node
139:             * 
140:             * @return data object
141:             */
142:            public Object getDataObject() {
143:                return dataObject;
144:            }
145:
146:            /**
147:             * get field name given a port
148:             * 
149:             * @param graphPort graph port
150:             * @return field name
151:             */
152:            public String getFieldName(IGraphPort graphPort) {
153:                return null;
154:            }
155:
156:            /**
157:             * get input graph port , given a field name
158:             * 
159:             * @param fieldName field name
160:             * @return graph port
161:             */
162:            public IGraphPort getInputGraphPort(String fieldName) {
163:                return null;
164:            }
165:
166:            /**
167:             * get output graph port , given a field name
168:             * 
169:             * @param fieldName field name
170:             * @return graph port
171:             */
172:            public IGraphPort getOutputGraphPort(String fieldName) {
173:                return null;
174:            }
175:
176:            /**
177:             * Get the parent node
178:             * 
179:             * @return parent
180:             */
181:            public IGraphNode getParentGraphNode() {
182:                return null;
183:            }
184:
185:            /**
186:             * Remove a child object
187:             * 
188:             * @param child child object
189:             */
190:            public void removeChildNode(IGraphNode childNode) throws Exception {
191:            }
192:
193:            /**
194:             * set data object in this graph node
195:             * 
196:             * @param obj data object
197:             */
198:            public void setDataObject(Object obj) {
199:                this .dataObject = obj;
200:            }
201:
202:            /**
203:             * Sets whether this area is expanded. called by update method may be overriden by
204:             * subclass
205:             * 
206:             * @param isExpanded whether area is expanded
207:             */
208:            protected void setExpanded(boolean isExpanded) {
209:                this .setResizable(isExpanded);
210:
211:                if (isExpanded) {
212:                    this .setSize(expandedSize);
213:                } else {
214:                    expandedSize = this .getSize();
215:                    this .setSize(getMinimumWidth(), getMinimumHeight());
216:                }
217:
218:                SQLCanvasObject canvasObject = (SQLCanvasObject) this 
219:                        .getDataObject();
220:                if (canvasObject != null && updateGuiInfo) {
221:                    GUIInfo guiInfo = canvasObject.getGUIInfo();
222:                    if (guiInfo != null) {
223:                        guiInfo.setExpanded(this .isExpandedState());
224:                    }
225:                }
226:            }
227:
228:            /**
229:             * handle geometry change
230:             * 
231:             * @param prevRect previous bounds rectangle
232:             */
233:            protected void geometryChange(Rectangle prevRect) {
234:                super .geometryChange(prevRect);
235:                Rectangle rect = this .getBoundingRect();
236:                SQLCanvasObject canvasObject = (SQLCanvasObject) this 
237:                        .getDataObject();
238:                if (canvasObject != null && updateGuiInfo) {
239:                    GUIInfo guiInfo = canvasObject.getGUIInfo();
240:                    if (guiInfo != null && guiInfo.isVisible()) {
241:                        guiInfo.setX(rect.x);
242:                        guiInfo.setY(rect.y);
243:                        if (this .isExpandedState()) {
244:                            guiInfo.setWidth(rect.width);
245:                            guiInfo.setHeight(rect.height);
246:                        }
247:                    }
248:                }
249:            }
250:
251:            /**
252:             * Updates contents based on notification from the TableTitleArea when its
253:             * expand/collapse control is clicked.
254:             * 
255:             * @param hint event hint
256:             * @param prevInt previous integer value
257:             * @param prevVal previous object val
258:             */
259:            public void update(int hint, int prevInt, Object prevVal) {
260:                if (hint == TitleArea.EXPANSION_STATE_CHANGED) {
261:                    // optimization: assume area doesn't change when scrolling items
262:                    if (titleArea.getState() == TitleArea.EXPANDED) {
263:                        setExpanded(true);
264:                    } else {
265:                        setExpanded(false);
266:                    }
267:                } else {
268:                    super .update(hint, prevInt, prevVal);
269:                }
270:            }
271:
272:            /**
273:             * set the graph view whixh hold this node
274:             * 
275:             * @param view graph view
276:             */
277:            public void setGraphView(IGraphView view) {
278:                this .view = view;
279:            }
280:
281:            /**
282:             * get the graphview which holds this view
283:             * 
284:             * @return graph view
285:             */
286:            public IGraphView getGraphView() {
287:                return view;
288:            }
289:
290:            /**
291:             * update this node with changes in data object
292:             */
293:            public void updateUI() {
294:            }
295:
296:            /**
297:             * remove the child data object
298:             * 
299:             * @param obj child data object
300:             */
301:            public void removeChildObject(Object obj) {
302:            }
303:
304:            /**
305:             * add child data object
306:             * 
307:             * @param obj child data object
308:             */
309:            public void addChildObject(Object obj) {
310:            }
311:
312:            public boolean doMouseClick(int modifiers, Point dc, Point vc,
313:                    JGoView view1) {
314:
315:                int onmask = java.awt.event.InputEvent.BUTTON3_MASK;
316:
317:                if ((modifiers & onmask) != 0 && popUpMenu != null) {
318:                    popUpMenu.show(view1, vc.x, vc.y);
319:                    return true;
320:                }
321:
322:                return false;
323:            }
324:
325:            /**
326:             * set the actions on a node
327:             * 
328:             * @param actions
329:             */
330:            public void initializeActions(List actions) {
331:                popUpMenu = new JPopupMenu();
332:                Iterator it = actions.iterator();
333:
334:                while (it.hasNext()) {
335:                    Action action = (Action) it.next();
336:                    JMenuItem item = new JMenuItem(action);
337:                    popUpMenu.addSeparator();
338:                    popUpMenu.add(item);
339:                }
340:            }
341:
342:            public void setUpdateGuiInfo(boolean update) {
343:                this .updateGuiInfo = update;
344:            }
345:
346:            /**
347:             * is this node can be deleted
348:             * 
349:             * @return true if node can be deleted
350:             */
351:            public boolean isDeleteAllowed() {
352:                return true;
353:            }
354:        }
ww___w__._j_a_v___a2s__.___c_o__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.