Source Code Cross Referenced for ETGenericEdgeUI.java in  » IDE-Netbeans » uml » org » netbeans » modules » uml » ui » products » ad » viewfactory » 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.products.ad.viewfactory 
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.products.ad.viewfactory;
043:
044:        import java.util.List;
045:        import java.awt.Graphics;
046:        import java.awt.RenderingHints;
047:
048:        import com.tomsawyer.util.TSProperty;
049:        import com.tomsawyer.editor.TSEEdge;
050:        import com.tomsawyer.editor.TSEGraphWindow;
051:        import com.tomsawyer.editor.TSEObject;
052:        import com.tomsawyer.editor.TSEObjectUI;
053:        import com.tomsawyer.editor.graphics.TSEGraphics;
054:        import com.tomsawyer.editor.ui.TSEDefaultEdgeUI;
055:        import com.tomsawyer.editor.TSEColor;
056:        import org.netbeans.modules.uml.common.ETException;
057:        import org.netbeans.modules.uml.core.metamodel.core.foundation.FactoryRetriever;
058:        import org.netbeans.modules.uml.core.metamodel.core.foundation.ICreationFactory;
059:        import org.netbeans.modules.uml.core.metamodel.core.foundation.IElement;
060:        import org.netbeans.modules.uml.core.metamodel.core.foundation.INamespace;
061:        import org.netbeans.modules.uml.core.metamodel.core.foundation.IPresentationElement;
062:        import org.netbeans.modules.uml.core.support.umlsupport.IETRect;
063:        import org.netbeans.modules.uml.core.support.umlsupport.IStrings;
064:        import org.netbeans.modules.uml.ui.support.applicationmanager.DrawingFactory;
065:        import org.netbeans.modules.uml.ui.support.applicationmanager.IEdgePresentation;
066:        import org.netbeans.modules.uml.ui.support.applicationmanager.IPresentationTypesMgr;
067:        import org.netbeans.modules.uml.ui.support.applicationmanager.PresentationTypesMgrImpl;
068:        import org.netbeans.modules.uml.ui.support.archivesupport.IProductArchive;
069:        import org.netbeans.modules.uml.ui.support.archivesupport.IProductArchiveElement;
070:        import org.netbeans.modules.uml.ui.support.archivesupport.IProductArchiveDefinitions;
071:        import org.netbeans.modules.uml.ui.support.relationshipVerification.IEdgeVerification;
072:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine;
073:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawInfo;
074:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IETEdge;
075:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IETEdgeUI;
076:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IETGraphObject;
077:        import org.netbeans.modules.uml.ui.products.ad.applicationcore.ADPresentationTypesMgrImpl;
078:        import org.netbeans.modules.uml.ui.products.ad.drawengines.ETDrawEngineFactory;
079:        import org.netbeans.modules.uml.ui.products.ad.graphobjects.ETEdge;
080:        import org.netbeans.modules.uml.ui.swing.drawingarea.IDrawingAreaControl;
081:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.ITSGraphObject;
082:
083:        /*
084:         * 
085:         * @author KevinM
086:         *
087:         */
088:        public class ETGenericEdgeUI extends TSEDefaultEdgeUI implements 
089:                IETEdgeUI {
090:
091:            private final String ZERO_VALUE = "";
092:
093:            private IDrawEngine drawEngine = null;
094:            private String drawEngineClass = null;
095:
096:            private String peidValue = this .ZERO_VALUE;
097:            private String meidValue = this .ZERO_VALUE;
098:            private String topLevelMEIDValue = this .ZERO_VALUE;
099:            private String initStringValue = this .ZERO_VALUE;
100:            private String m_ReloadedOwnerPresentationXMIID = this .ZERO_VALUE;
101:            private IStrings m_PresentationReferenceReferredElements = null;
102:            private boolean m_WasModelElementDeleted = false;
103:            private boolean m_FailedToCreateDrawEngine = false;
104:
105:            private IProductArchiveElement archiveElement;
106:            private IElement modelElement = null;
107:            protected RenderingHints qualityHints = new RenderingHints(
108:                    RenderingHints.KEY_ANTIALIASING,
109:                    RenderingHints.VALUE_ANTIALIAS_ON);
110:
111:            /*
112:             * 
113:             */
114:            public ETGenericEdgeUI() {
115:                super ();
116:                // we draw the arrowheads
117:                setArrowType(NO_ARROW);
118:            }
119:
120:            /*
121:             * 
122:             */
123:            private boolean initDrawEngine() throws ETException {
124:                if (this .getDrawEngineClass() != null
125:                        && getDrawEngineClass().length() > 0) {
126:                    this .setDrawEngine(ETDrawEngineFactory
127:                            .createDrawEngine(this ));
128:                    return this .drawEngine != null;
129:                } else
130:                    return false;
131:            }
132:
133:            /**
134:             * This method draws the object represented by this UI.
135:             * @param graphics the <code>TSEGraphics</code> object onto which
136:             * the UI is being drawn.
137:             */
138:            public void draw(TSEGraphics graphics) {
139:                if (getDrawEngine() != null) {
140:                    RenderingHints prevHint = graphics.getRenderingHints();
141:                    qualityHints.put(RenderingHints.KEY_RENDERING,
142:                            RenderingHints.VALUE_RENDER_QUALITY);
143:
144:                    graphics.setRenderingHints(qualityHints);
145:
146:                    IDrawInfo drawInfo = getDrawInfo(graphics);
147:                    if (drawInfo != null)
148:                        getDrawEngine().doDraw(drawInfo);
149:                    else
150:                        super .draw(graphics);
151:
152:                    graphics.setRenderingHints(prevHint);
153:                } else
154:                    super .draw(graphics);
155:            }
156:
157:            /**
158:             * Retrieves the graphics context for the node ui.
159:             * 
160:             * @return The graphics context.
161:             */
162:            public IDrawInfo getDrawInfo() {
163:                TSEGraphWindow window = getGraphWindow();
164:                if (window != null) {
165:                    Graphics g = window.getGraphics();
166:                    return g instanceof  TSEGraphics ? getDrawInfo((TSEGraphics) g)
167:                            : null;
168:                } else
169:                    return null;
170:            }
171:
172:            /*
173:             * Returns the GraphWindow.
174:             */
175:            public TSEGraphWindow getGraphWindow() {
176:                return ETBaseUI.getGraphWindow(this );
177:            }
178:
179:            /*
180:             * Returns World points, (Logical)
181:             */
182:            public IETRect getLogicalBounds() {
183:                return ETBaseUI.getLogicalBounds(this );
184:            }
185:
186:            /*
187:             * Returns the device bounding rect.
188:             */
189:            public IETRect getDeviceBounds() {
190:                return ETBaseUI.getDeviceBounds(this );
191:            }
192:
193:            /**
194:             * Retrieves the graphics context for the node ui.
195:             * 
196:             * @param graphics The TS graphics class.
197:             * @return The graphics context.
198:             */
199:            public IDrawInfo getDrawInfo(TSEGraphics graphics) {
200:                IDrawInfo retVal = ETBaseUI.getDrawInfo(graphics, this );
201:
202:                if (retVal != null) {
203:                    retVal.setIsTransparent(false);
204:                    retVal.setIsBorderDrawn(false);
205:                }
206:                // TODO: Determine what the DrawinToMainDrawingArea and AlwaysSetFont
207:                //       Should be set to.
208:
209:                return retVal;
210:            }
211:
212:            /*
213:             *  (non-Javadoc)
214:             * @see com.tomsawyer.editor.TSEObjectUI#drawOutline(com.tomsawyer.editor.graphics.TSEGraphics)
215:             */
216:            public void drawOutline(TSEGraphics graphics) {
217:                draw(graphics);
218:            }
219:
220:            /*
221:             *  (non-Javadoc)
222:             * @see com.tomsawyer.editor.TSEObjectUI#drawSelected(com.tomsawyer.editor.graphics.TSEGraphics)
223:             */
224:            public void drawSelected(TSEGraphics graphics) {
225:                draw(graphics);
226:            }
227:
228:            /*
229:             *  (non-Javadoc)
230:             * @see com.tomsawyer.editor.TSEObjectUI#drawSelectedOutline(com.tomsawyer.editor.graphics.TSEGraphics)
231:             */
232:            public void drawSelectedOutline(TSEGraphics graphics) {
233:                draw(graphics);
234:            }
235:
236:            /*
237:             *  (non-Javadoc)
238:             * @see com.tomsawyer.editor.TSEObjectUI#reset()
239:             */
240:            public void reset() {
241:                super .reset();
242:                this .setHighlightedColor(TSEColor.paleBlue);
243:
244:                this .peidValue = this .ZERO_VALUE;
245:                this .meidValue = this .ZERO_VALUE;
246:                this .topLevelMEIDValue = this .ZERO_VALUE;
247:                this .initStringValue = this .ZERO_VALUE;
248:            }
249:
250:            /*
251:             *  (non-Javadoc)
252:             * @see com.tomsawyer.editor.TSEObjectUI#copy(com.tomsawyer.editor.TSEObjectUI)
253:             */
254:            public void copy(TSEObjectUI sourceUI) {
255:                super .copy(sourceUI);
256:                ETGenericEdgeUI sourceObjUI = (ETGenericEdgeUI) sourceUI;
257:                this .meidValue = sourceObjUI.meidValue;
258:                this .topLevelMEIDValue = sourceObjUI.topLevelMEIDValue;
259:                this .modelElement = sourceObjUI.modelElement;
260:
261:                this .setInitStringValue(sourceObjUI.getInitStringValue());
262:                this .setDrawEngineClass(sourceObjUI.getDrawEngineClass());
263:            }
264:
265:            /*
266:             *  (non-Javadoc)
267:             * @see com.tomsawyer.editor.TSEObjectUI#getProperties()
268:             */
269:            public List getProperties() {
270:                /* commented by jyothi
271:                List list = super.getProperties();
272:                list.add(new TSProperty(IProductArchiveDefinitions.PRESENTATIONELEMENTID_STRING, this.peidValue));
273:                return list;
274:                 */
275:                List list = super .getProperties();
276:                String value = null;
277:                IPresentationElement pPE = ((IETGraphObject) getTSObject())
278:                        .getPresentationElement();
279:                if (pPE != null) {
280:                    // Get the presentation el  ement id
281:                    String presEleId = pPE.getXMIID();
282:                    if (presEleId != null && presEleId.length() > 0) {
283:                        value = presEleId;
284:                    }
285:                }
286:
287:                list
288:                        .add(new TSProperty(
289:                                IProductArchiveDefinitions.PRESENTATIONELEMENTID_STRING,
290:                                value));
291:                return list;
292:            }
293:
294:            /*
295:             *  (non-Javadoc)
296:             * @see com.tomsawyer.editor.TSEObjectUI#setProperty(com.tomsawyer.util.TSProperty)
297:             */
298:            public void setProperty(TSProperty property) {
299:                //String attrString = (String) property.getValue(); //Jyothi
300:                if (IProductArchiveDefinitions.PRESENTATIONELEMENTID_STRING
301:                        .equals(property.getName())) {
302:                    String attrString = (String) property.getValue();
303:                    this .peidValue = attrString;
304:                } else {
305:                    super .setProperty(property);
306:                }
307:            }
308:
309:            /*
310:             *  (non-Javadoc)
311:             * @see com.tomsawyer.editor.TSEObjectUI#getChangedProperties()
312:             */
313:            public List getChangedProperties() {
314:                List list = super .getChangedProperties();
315:
316:                IPresentationElement pPE = ((IETGraphObject) getTSObject())
317:                        .getPresentationElement();
318:                if (pPE != null) {
319:                    // Get the presentation element id
320:                    String presEleId = pPE.getXMIID();
321:                    if (presEleId != null && presEleId.length() > 0) {
322:                        list
323:                                .add(new TSProperty(
324:                                        IProductArchiveDefinitions.PRESENTATIONELEMENTID_STRING,
325:                                        presEleId));
326:                    }
327:                }
328:                return list;
329:            }
330:
331:            /*
332:             *  (non-Javadoc)
333:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#getDrawEngine()
334:             */
335:            public IDrawEngine getDrawEngine() {
336:                if (drawEngine == null) {
337:                    try {
338:                        this .initDrawEngine();
339:                    } catch (Exception e) {
340:                        return null;
341:                    }
342:                }
343:
344:                return drawEngine;
345:            }
346:
347:            /*
348:             *  (non-Javadoc)
349:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#getDrawEngineClass()
350:             */
351:            public String getDrawEngineClass() {
352:                return drawEngineClass;
353:            }
354:
355:            /*
356:             *  (non-Javadoc)
357:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#setDrawEngineClass(java.lang.String)
358:             */
359:            public void setDrawEngineClass(String string) {
360:                drawEngineClass = string;
361:            }
362:
363:            /*
364:             *  (non-Javadoc)
365:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#setDrawEngine(org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine)
366:             */
367:            public void setDrawEngine(IDrawEngine newDrawEngine) {
368:                try {
369:                    if (newDrawEngine != drawEngine) {
370:                        drawEngine = newDrawEngine;
371:                        //				if (drawEngine != null)
372:                        //					drawEngine.init();
373:
374:                    }
375:                } catch (Exception e) {
376:                    e.printStackTrace();
377:                }
378:            }
379:
380:            /*
381:             * 
382:             */
383:            public String getPeidValue() {
384:                return peidValue;
385:            }
386:
387:            public String getMeidValue() {
388:                return this .meidValue;
389:            }
390:
391:            /*
392:             * 
393:             */
394:            public String getTopLevelMEIDValue() {
395:                return this .topLevelMEIDValue;
396:            }
397:
398:            public IElement getModelElement() {
399:                return this .modelElement;
400:            }
401:
402:            public void setModelElement(IElement element) {
403:                this .modelElement = element;
404:            }
405:
406:            public IProductArchiveElement getArchiveElement() {
407:                return this .archiveElement;
408:            }
409:
410:            /*
411:             * 
412:             */
413:            public void setArchiveElement(IProductArchiveElement element) {
414:                this .archiveElement = element;
415:                this .readFromArchive(element);
416:            }
417:
418:            /*
419:             * 
420:             */
421:            private void readFromArchive(IProductArchiveElement element) {
422:                if (element != null) {
423:                    this .meidValue = element
424:                            .getAttributeString(IProductArchiveDefinitions.MEID_STRING);
425:                    this .topLevelMEIDValue = element
426:                            .getAttributeString(IProductArchiveDefinitions.TOPLEVELID_STRING);
427:                    setInitStringValue(element
428:                            .getAttributeString(IProductArchiveDefinitions.INITIALIZATIONSTRING_STRING));
429:
430:                    IProductArchiveElement engineElement = element
431:                            .getElement(IProductArchiveDefinitions.ENGINENAMEELEMENT_STRING);
432:                    setDrawEngineClass(engineElement
433:                            .getAttributeString(IProductArchiveDefinitions.ENGINENAMEATTRIBUTE_STRING));
434:                }
435:            }
436:
437:            public void readFromArchive(IProductArchive prodArch,
438:                    IProductArchiveElement archEle) {
439:                archiveElement = archEle;
440:                ETBaseUI.readFromArchive(prodArch, archEle, this );
441:            }
442:
443:            public void writeToArchive(IProductArchive prodArch,
444:                    IProductArchiveElement archEle) {
445:                ETBaseUI.writeToArchive(prodArch, archEle, this );
446:            }
447:
448:            /*
449:             *  (non-Javadoc)
450:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#getDrawingArea()
451:             */
452:            public IDrawingAreaControl getDrawingArea() {
453:                return ETBaseUI.getDrawingArea(this );
454:            }
455:
456:            /*
457:             *  (non-Javadoc)
458:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#setDrawingArea(org.netbeans.modules.uml.ui.swing.drawingarea.IDrawingAreaControl)
459:             */
460:            public void setDrawingArea(IDrawingAreaControl control) {
461:                //this.drawingArea = control;
462:            }
463:
464:            /*
465:             *  (non-Javadoc)
466:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#getInitStringValue()
467:             */
468:            public String getInitStringValue() {
469:                String retStr = initStringValue;
470:                String className = this .getClass().getName();
471:                if (!retStr.startsWith(className)) {
472:                    retStr = className + " " + initStringValue;
473:                }
474:                return retStr;
475:            }
476:
477:            /*
478:             *  (non-Javadoc)
479:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#setInitStringValue(java.lang.String)
480:             */
481:            public void setInitStringValue(String string) {
482:                this .initStringValue = string;
483:            }
484:
485:            /*
486:             *  (non-Javadoc)
487:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#getTSObject()
488:             */
489:            public ITSGraphObject getTSObject() {
490:                return getOwner() instanceof  ITSGraphObject ? (ITSGraphObject) getOwner()
491:                        : null;
492:            }
493:
494:            /*
495:             *  (non-Javadoc)
496:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#getReloadedModelElementXMIID()
497:             */
498:            public String getReloadedModelElementXMIID() {
499:                return meidValue;
500:            }
501:
502:            /*
503:             *  (non-Javadoc)
504:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#setReloadedModelElementXMIID(java.lang.String)
505:             */
506:            public void setReloadedModelElementXMIID(String newVal) {
507:                meidValue = newVal;
508:            }
509:
510:            /*
511:             *  (non-Javadoc)
512:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#getReloadedTopLevelXMIID()
513:             */
514:            public String getReloadedTopLevelXMIID() {
515:                return topLevelMEIDValue;
516:            }
517:
518:            /*
519:             *  (non-Javadoc)
520:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#setReloadedTopLevelXMIID(java.lang.String)
521:             */
522:            public void setReloadedTopLevelXMIID(String newVal) {
523:                topLevelMEIDValue = newVal;
524:            }
525:
526:            /*
527:             *  (non-Javadoc)
528:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#getReloadedPresentationXMIID()
529:             */
530:            public String getReloadedPresentationXMIID() {
531:                return peidValue;
532:            }
533:
534:            /*
535:             *  (non-Javadoc)
536:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#setReloadedPresentationXMIID(java.lang.String)
537:             */
538:            public void setReloadedPresentationXMIID(String newVal) {
539:                peidValue = newVal;
540:            }
541:
542:            /*
543:             *  (non-Javadoc)
544:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#getReloadedOwnerPresentationXMIID()
545:             */
546:            public String getReloadedOwnerPresentationXMIID() {
547:                return m_ReloadedOwnerPresentationXMIID;
548:            }
549:
550:            /*
551:             *  (non-Javadoc)
552:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#setReloadedOwnerPresentationXMIID(java.lang.String)
553:             */
554:            public void setReloadedOwnerPresentationXMIID(String newVal) {
555:                m_ReloadedOwnerPresentationXMIID = newVal;
556:            }
557:
558:            /*
559:             *  (non-Javadoc)
560:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#getReferredElements()
561:             */
562:            public IStrings getReferredElements() {
563:                return m_PresentationReferenceReferredElements;
564:            }
565:
566:            /*
567:             *  (non-Javadoc)
568:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#setReferredElements(org.netbeans.modules.uml.core.support.umlsupport.IStrings)
569:             */
570:            public void setReferredElements(IStrings newVal) {
571:                m_PresentationReferenceReferredElements = newVal;
572:            }
573:
574:            /**
575:             * Creates a new IEdgePresentation and returns true and pElem!=0 if successful.
576:             *
577:             * @param pElement [in] The element that this edge view represents
578:             * @param pElem [out,retval] Creates the appropriate IPresentationElement for this node (right now it's
579:             * always an INodePresentation.)
580:             */
581:            public IPresentationElement createPresentationElement(IElement pEle) {
582:                IPresentationElement retObj = null;
583:                IPresentationTypesMgr typesMgr = null;
584:
585:                IDrawingAreaControl control = getDrawingArea();
586:                if (control != null) {
587:                    typesMgr = control.getPresentationTypesMgr();
588:                } else {
589:                    // This is here so we can support copy/paste when the ui is in the
590:                    // clipboard and not on a control.
591:                    typesMgr = new ADPresentationTypesMgrImpl();
592:                }
593:                if (typesMgr != null && pEle != null) {
594:
595:                    // The type to create depends on the metatype of the incoming IElement
596:                    String incomingMetaType = pEle.getElementType();
597:                    String peToCreate = "";
598:                    if (typesMgr != null) {
599:                        peToCreate = typesMgr.getPresentationElementMetaType(
600:                                incomingMetaType, initStringValue);
601:                    }
602:                    if (peToCreate == null || peToCreate.length() == 0) {
603:                        peToCreate = "EdgePresentation";
604:                    }
605:
606:                    IEdgePresentation edgePres = DrawingFactory
607:                            .retrieveEdgePresentationMetaType(peToCreate);
608:                    if (edgePres != null) {
609:                        edgePres.setTSEdge((ETEdge) getTSObject());
610:                        retObj = edgePres;
611:                    }
612:                }
613:                return retObj;
614:            }
615:
616:            public boolean getWasModelElementDeleted() {
617:                return m_WasModelElementDeleted;
618:            }
619:
620:            public void setWasModelElementDeleted(boolean newVal) {
621:                m_WasModelElementDeleted = newVal;
622:            }
623:
624:            public boolean getFailedToCreateDrawEngine() {
625:                return m_FailedToCreateDrawEngine;
626:            }
627:
628:            public void setFailedToCreateDrawEngine(boolean newVal) {
629:                m_FailedToCreateDrawEngine = newVal;
630:            }
631:
632:            /**
633:             * Creates the appropriate EdgeVerification
634:             *
635:             * @param pVerif [out,retval] The returned, created edge verification created through the factory
636:             */
637:            private IEdgeVerification getEdgeVerification() {
638:                IEdgeVerification retObj = null;
639:                ICreationFactory factory = FactoryRetriever.instance()
640:                        .getCreationFactory();
641:                if (factory != null) {
642:                    Object obj = factory.retrieveEmptyMetaType(
643:                            "RelationshipVerification", "EdgeVerification",
644:                            null);
645:                    if (obj != null && obj instanceof  IEdgeVerification) {
646:                        retObj = (IEdgeVerification) obj;
647:                    }
648:                }
649:                return retObj;
650:            }
651:
652:            /**
653:             * This routine is called when an object needs to be created from scratch.  The user has dropped
654:             * a TS node on the tree and we need to create the appropriate model element and presentation elements and
655:             * tie them together.  After all that is done look at the initialization string and create the correct engine.
656:             *
657:             * @param pNamespace [in] The namespace to add the new item to
658:             * @param sInitializationString [in] The init string used to create this node
659:             * @param pCreatedPresentationElement [out] The presentatation element created if all goes well.
660:             * @param pCreatedElement [out] The model element created if all goes well.
661:             */
662:            public IElement createNew(INamespace space, String initStr) {
663:                IElement retEle = null;
664:                IETEdge etObj = (IETEdge) getTSObject();
665:                IEdgeVerification pEdgeVerification = getEdgeVerification();
666:                String metaType = ETBaseUI.getMetaType(this );
667:                if (pEdgeVerification != null) {
668:                    // Verify and create the edge relationship
669:                    retEle = pEdgeVerification.verifyAndCreateEdgeRelation(
670:                            etObj, space, metaType, initStr);
671:                }
672:
673:                // If we have a good model element then create the presentation element and
674:                // hook the two up.
675:                if (retEle != null) {
676:                    IPresentationElement pEle = createPresentationElement(retEle);
677:                    if (pEle != null) {
678:                        pEle.addSubject(retEle);
679:                        etObj.setPresentationElement(pEle);
680:                    }
681:
682:                    // There are times when the verify logic actually changes the metatype of what gets
683:                    // created.  Get the metatype of the modelelement that got created and if it's different
684:                    // then just post a reset on the drawing area for this product element
685:                    IDrawingAreaControl control = getDrawingArea();
686:                    if (control != null) {
687:                        String actualMetaType = retEle.getElementType();
688:                        if (actualMetaType != null
689:                                && !actualMetaType.equals(metaType)) {
690:                            control.resetDrawEngine2(etObj);
691:                        }
692:                    }
693:                }
694:                return retEle;
695:            }
696:
697:            /*
698:             *  (non-Javadoc)
699:             * @see org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI#isOnTheScreen(com.tomsawyer.editor.graphics.TSEGraphics)
700:             */
701:            public boolean isOnTheScreen(TSEGraphics g) {
702:                return ETBaseUI.isOnTheScreen(g, this);
703:            }
704:        }
w__ww_.__j_a__v__a2_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.