Source Code Cross Referenced for LabelPresentation.java in  » IDE-Netbeans » uml » org » netbeans » modules » uml » ui » support » applicationmanager » 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 » uml » org.netbeans.modules.uml.ui.support.applicationmanager 
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.uml.ui.support.applicationmanager;
043:
044:        import org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI;
045:        import java.util.List;
046:
047:        import org.dom4j.Document;
048:        import org.dom4j.Node;
049:
050:        import org.netbeans.modules.uml.core.metamodel.core.foundation.IElement;
051:        import org.netbeans.modules.uml.core.metamodel.core.foundation.IPresentationElement;
052:        import org.netbeans.modules.uml.core.support.umlsupport.IETPoint;
053:        import org.netbeans.modules.uml.core.support.umlsupport.ETPoint;
054:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment;
055:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine;
056:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IETGraphObject;
057:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IETLabel;
058:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.TypeConversions;
059:        import org.netbeans.modules.uml.ui.swing.drawingarea.IDrawingAreaControl;
060:        import com.tomsawyer.drawing.TSLabel;
061:        import com.tomsawyer.editor.TSENodeLabel;
062:        import com.tomsawyer.editor.TSEConnectorLabel;
063:        import com.tomsawyer.editor.TSEEdgeLabel;
064:        import com.tomsawyer.editor.TSEObjectUI;
065:        import com.tomsawyer.editor.TSEGraphWindow;
066:        import com.tomsawyer.editor.TSEObject;
067:        import com.tomsawyer.editor.ui.TSELabelUI;
068:        import com.tomsawyer.graph.TSGraphObject;
069:
070:        public class LabelPresentation extends GraphPresentation implements 
071:                ILabelPresentation {
072:
073:            /// flag indicated if the element should be deleted if not edited
074:            boolean m_bDeleteIfNotEdited = false;
075:
076:            /**
077:             *
078:             */
079:            public LabelPresentation() {
080:                super ();
081:            }
082:
083:            /* (non-Javadoc)
084:             * @see org.netbeans.modules.uml.ui.support.applicationmanager.ILabelPresentation#getETLabel()
085:             */
086:            public IETLabel getETLabel() {
087:                return getETGraphObject() instanceof  IETLabel ? (IETLabel) getETGraphObject()
088:                        : null;
089:            }
090:
091:            /* (non-Javadoc)
092:             * @see org.netbeans.modules.uml.ui.support.applicationmanager.ILabelPresentation#getLabelView()
093:             */
094:            public TSELabelUI getLabelView() {
095:                return this .getUI() instanceof  TSELabelUI ? (TSELabelUI) this 
096:                        .getUI() : null;
097:            }
098:
099:            private TSLabel mLabel = null;
100:
101:            /* (non-Javadoc)
102:             * @see org.netbeans.modules.uml.ui.support.applicationmanager.ILabelPresentation#getTSLabel()
103:             */
104:            public TSLabel getTSLabel() {
105:                return mLabel;
106:            }
107:
108:            /* (non-Javadoc)
109:             * @see org.netbeans.modules.uml.ui.support.applicationmanager.ILabelPresentation#setTSLabel(com.tomsawyer.drawing.TSLabel)
110:             */
111:            public void setTSLabel(TSLabel value) {
112:                mLabel = value;
113:            }
114:
115:            public IETGraphObjectUI getUI() {
116:                TSLabel label = getTSLabel();
117:                IETGraphObjectUI retVal = null;
118:
119:                TSEObjectUI ui = null;
120:                if (label instanceof  TSEEdgeLabel) {
121:                    TSEEdgeLabel edgeLabel = (TSEEdgeLabel) label;
122:                    ui = edgeLabel.getUI();
123:                } else if (label instanceof  TSENodeLabel) {
124:                    TSENodeLabel edgeLabel = (TSENodeLabel) label;
125:                    ui = edgeLabel.getUI();
126:                } else if (label instanceof  TSEConnectorLabel) {
127:                    TSEConnectorLabel edgeLabel = (TSEConnectorLabel) label;
128:                    ui = edgeLabel.getUI();
129:                }
130:
131:                if (ui instanceof  IETGraphObjectUI) {
132:                    retVal = (IETGraphObjectUI) ui;
133:                }
134:
135:                return retVal;
136:            }
137:
138:            /* (non-Javadoc)
139:             * @see org.netbeans.modules.uml.ui.support.applicationmanager.ILabelPresentation#invalidate()
140:             */
141:            public void invalidate() {
142:                TSLabel label = getTSLabel();
143:                IDrawEngine engine = getDrawEngine();
144:                if (label != null && engine != null) {
145:
146:                    IDrawingAreaControl ctrl = engine.getDrawingArea();
147:
148:                    TSEGraphWindow window = ctrl.getGraphWindow();
149:                    if (window != null) {
150:                        window.addInvalidRegion((TSEObject) label);
151:                    }
152:                }
153:
154:            }
155:
156:            /* (non-Javadoc)
157:             * @see org.netbeans.modules.uml.ui.support.applicationmanager.ILabelPresentation#beginEdit()
158:             */
159:            public long beginEdit() {
160:
161:                IDrawEngine pDE = this .getDrawEngine();
162:
163:                if (pDE != null) {
164:
165:                    int count = 0;
166:
167:                    List pCompartments = pDE.getCompartments();
168:
169:                    if (pCompartments != null) {
170:                        count = pCompartments.size();
171:                    }
172:                    if (count > 0) {
173:                        ICompartment pFirstCompartment = (ICompartment) pCompartments
174:                                .get(0);
175:
176:                        if (pFirstCompartment != null) {
177:                            int tempShort = 0;
178:                            setSelected(true);
179:                            pFirstCompartment.editCompartment(
180:                                    m_bDeleteIfNotEdited, tempShort, 0, -1);
181:
182:                            // always set deleteIfNotEdited back to false so subsequent edits don't accidently delete
183:                            m_bDeleteIfNotEdited = false;
184:                        }
185:                    }
186:                }
187:                return 0;
188:            }
189:
190:            /* (non-Javadoc)
191:             * @see org.netbeans.modules.uml.ui.support.applicationmanager.ILabelPresentation#get_DeleteIfNotEdited()
192:             */
193:            public boolean getDeleteIfNotEdited() {
194:                // TODO Auto-generated method stub
195:                return false;
196:            }
197:
198:            /* (non-Javadoc)
199:             * @see org.netbeans.modules.uml.ui.support.applicationmanager.ILabelPresentation#put_DeleteIfNotEdited(boolean)
200:             */
201:            public long setDeleteIfNotEdited(boolean bDelete) {
202:                // TODO Auto-generated method stub
203:                return 0;
204:            }
205:
206:            /* (non-Javadoc)
207:             * @see org.netbeans.modules.uml.ui.support.applicationmanager.ILabelPresentation#getPresentationOwner()
208:             */
209:            public IPresentationElement getPresentationOwner() {
210:                IPresentationElement retVal = null;
211:
212:                IETLabel etlabel = getETLabel();
213:                if (etlabel != null) {
214:                    retVal = etlabel.getParentPresentationElement();
215:                }
216:
217:                return retVal;
218:            }
219:
220:            /* (non-Javadoc)
221:             * @see org.netbeans.modules.uml.ui.support.applicationmanager.ILabelPresentation#getLocation(int, int, int, int)
222:             */
223:            public long getLocation(int pWidth, int pHeight, int pXCenter,
224:                    int pYCenter) {
225:                // TODO Auto-generated method stub
226:                return 0;
227:            }
228:
229:            /* (non-Javadoc)
230:             * @see org.netbeans.modules.uml.ui.support.applicationmanager.ILabelPresentation#moveTo(int, int, int)
231:             */
232:            public long moveTo(int x, int y, int flags) {
233:                // TODO Auto-generated method stub
234:                return 0;
235:            }
236:
237:            /**
238:             *
239:             * Creates the label presentation element node.
240:             *
241:             * @param doc[in] the document owner of the new node
242:             * @param parent[in] the parent of the new node
243:             * @return HRESULTs
244:             *
245:             */
246:            public void establishNodePresence(Document doc, Node parent) {
247:                buildNodePresence("UML:LabelPresentation", doc, parent);
248:            }
249:
250:            /**
251:             * Gets the FIRST model element associated with this presentation element.  More generically
252:             * there is a many to one relationship...but in most cases a many to one relationship
253:             * between an IPresentationElement and IElement exists.
254:             *
255:             * @param pVal[out, retval] The first model element associated with this presentation element
256:             *
257:             * @return HRESULT
258:             */
259:            public IElement getModelElement() {
260:                return super .getModelElement();
261:                //		return getFirstSubject();
262:            }
263:
264:            /**
265:             * Sets the model element associated with this presentation element.
266:             *
267:             * @param newVal[in] The model element associated with this presentation element
268:             *
269:             * @return HRESULT
270:             */
271:            public void setModelElement(IElement newVal) {
272:
273:                super .setModelElement(newVal);
274:                //		if (newVal != null) {
275:                //			// Remove all the subjects
276:                //			ETList < IElement > pModelElements = getSubjects();
277:                //			long count = getSubjectCount();
278:                //			for (long i = 0; i < count; i++) {
279:                //				IElement pEle = pModelElements.get((int) i);
280:                //				pEle.removePresentationElement(this);
281:                //				removeSubject(pEle);
282:                //			}
283:                //
284:                //			// Add the subject
285:                //			addSubject(newVal);
286:                //
287:                //			// Now update the draw engine/compartment so that it's pointing to the same model element
288:                //			IETGraphObject graphObj = getETGraphObject();
289:                //			if (graphObj != null) {
290:                //				IDrawEngine drawEng = graphObj.getEngine();
291:                //				if (drawEng != null) {
292:                //					drawEng.initCompartments(this);
293:                //				}
294:                //			}
295:                //		}
296:            }
297:
298:            public IETPoint getCenter() {
299:                TSLabel label = getTSLabel();
300:                return label != null ? new ETPoint((int) label.getCenter()
301:                        .getX(), (int) label.getCenter().getY()) : null;
302:            }
303:
304:            public long getWidth() {
305:                TSLabel label = getTSLabel();
306:                return label != null ? (long) label.getWidth() : 0;
307:            }
308:
309:            public long getHeight() {
310:                TSLabel label = getTSLabel();
311:                return label != null ? (long) label.getHeight() : 0;
312:            }
313:
314:        }
ww__w_._j___a__v___a_2___s.___c_o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.