Source Code Cross Referenced for ETCompartment.java in  » IDE-Netbeans » uml » org » netbeans » modules » uml » ui » products » ad » compartments » 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.compartments 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003:         *
0004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005:         *
0006:         * The contents of this file are subject to the terms of either the GNU
0007:         * General Public License Version 2 only ("GPL") or the Common
0008:         * Development and Distribution License("CDDL") (collectively, the
0009:         * "License"). You may not use this file except in compliance with the
0010:         * License. You can obtain a copy of the License at
0011:         * http://www.netbeans.org/cddl-gplv2.html
0012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0013:         * specific language governing permissions and limitations under the
0014:         * License.  When distributing the software, include this License Header
0015:         * Notice in each file and include the License file at
0016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
0017:         * particular file as subject to the "Classpath" exception as provided
0018:         * by Sun in the GPL Version 2 section of the License file that
0019:         * accompanied this code. If applicable, add the following below the
0020:         * License Header, with the fields enclosed by brackets [] replaced by
0021:         * your own identifying information:
0022:         * "Portions Copyrighted [year] [name of copyright owner]"
0023:         *
0024:         * Contributor(s):
0025:         *
0026:         * The Original Software is NetBeans. The Initial Developer of the Original
0027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
0028:         * Microsystems, Inc. All Rights Reserved.
0029:         *
0030:         * If you wish your version of this file to be governed by only the CDDL
0031:         * or only the GPL Version 2, indicate your decision by adding
0032:         * "[Contributor] elects to include this software in this distribution
0033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
0034:         * single choice of license, a recipient has the option to distribute
0035:         * your version of this file under either the CDDL, the GPL Version 2 or
0036:         * to extend the choice of license to its licensees as provided above.
0037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
0038:         * Version 2 license, then the option applies only if the new code is
0039:         * made subject to such option by the copyright holder.
0040:         */
0041:
0042:        package org.netbeans.modules.uml.ui.products.ad.compartments;
0043:
0044:        import java.awt.Color;
0045:        import java.awt.Dimension;
0046:        import java.awt.Font;
0047:        import java.awt.Graphics;
0048:        import java.awt.Point;
0049:        import java.awt.Rectangle;
0050:        import java.awt.event.ActionEvent;
0051:        import java.awt.event.MouseEvent;
0052:        import java.util.List;
0053:        import java.util.Locale;
0054:        import java.util.MissingResourceException;
0055:        import java.util.ResourceBundle;
0056:        import javax.accessibility.Accessible;
0057:        import javax.accessibility.AccessibleContext;
0058:        import javax.accessibility.AccessibleComponent;
0059:        import javax.accessibility.AccessibleRole;
0060:        import javax.accessibility.AccessibleState;
0061:        import javax.accessibility.AccessibleStateSet;
0062:        import org.netbeans.modules.uml.common.generics.ETPairT;
0063:        import org.netbeans.modules.uml.core.metamodel.basic.basicactions.IProcedure;
0064:        import org.netbeans.modules.uml.core.metamodel.common.commonstatemachines.IState;
0065:        import org.netbeans.modules.uml.core.metamodel.core.foundation.IElement;
0066:        import org.netbeans.modules.uml.core.metamodel.core.foundation.IPresentationElement;
0067:        import org.netbeans.modules.uml.core.metamodel.diagrams.IDiagram;
0068:        import org.netbeans.modules.uml.core.support.umlsupport.ETDeviceRect;
0069:        import org.netbeans.modules.uml.core.support.umlsupport.ETPoint;
0070:        import org.netbeans.modules.uml.core.support.umlsupport.ETRect;
0071:        import org.netbeans.modules.uml.core.support.umlsupport.ETSize;
0072:        import org.netbeans.modules.uml.core.support.umlsupport.IETPoint;
0073:        import org.netbeans.modules.uml.core.support.umlsupport.IETRect;
0074:        import org.netbeans.modules.uml.core.support.umlsupport.IETSize;
0075:        import org.netbeans.modules.uml.core.support.umlutils.ETList;
0076:        import org.netbeans.modules.uml.core.support.umlutils.ElementLocator;
0077:        import org.netbeans.modules.uml.core.support.umlutils.IDataFormatter;
0078:        import org.netbeans.modules.uml.ui.products.ad.application.IMenuManager;
0079:        import org.netbeans.modules.uml.ui.products.ad.application.action.BaseAction;
0080:        import org.netbeans.modules.uml.ui.products.ad.application.action.ContextMenuActionClass;
0081:        import org.netbeans.modules.uml.ui.products.ad.application.action.IETContextMenuHandler;
0082:        import org.netbeans.modules.uml.ui.products.ad.diagramengines.diagramActivityEngine.ETInvocationNodeDrawEngine;
0083:        import org.netbeans.modules.uml.ui.products.ad.diagramengines.diagramActivityEngine.ObjectNodeDrawEngine;
0084:        import org.netbeans.modules.uml.ui.products.ad.diagramengines.sequencediagram.LifelineDrawEngine;
0085:        import org.netbeans.modules.uml.ui.products.ad.drawengines.ETClassDrawEngine;
0086:        import org.netbeans.modules.uml.ui.products.ad.drawengines.ETCommentDrawEngine;
0087:        import org.netbeans.modules.uml.ui.products.ad.drawengines.ETLabelDrawEngine;
0088:        import org.netbeans.modules.uml.ui.products.ad.drawengines.ETStateDrawEngine;
0089:        import org.netbeans.modules.uml.ui.products.ad.drawengines.ETUseCaseDrawEngine;
0090:        import org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI;
0091:        import org.netbeans.modules.uml.ui.support.ProductHelper;
0092:        import org.netbeans.modules.uml.ui.support.applicationmanager.DrawingFactory;
0093:        import org.netbeans.modules.uml.ui.support.applicationmanager.INodePresentation;
0094:        import org.netbeans.modules.uml.ui.support.archivesupport.IProductArchive;
0095:        import org.netbeans.modules.uml.ui.support.archivesupport.IProductArchiveAttribute;
0096:        import org.netbeans.modules.uml.ui.support.archivesupport.IProductArchiveDefinitions;
0097:        import org.netbeans.modules.uml.ui.support.archivesupport.IProductArchiveElement;
0098:        import org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenu;
0099:        import org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenuItem;
0100:        import org.netbeans.modules.uml.ui.support.drawingproperties.IColorProperty;
0101:        import org.netbeans.modules.uml.ui.support.drawingproperties.IDrawingProperty;
0102:        import org.netbeans.modules.uml.ui.support.drawingproperties.IDrawingPropertyProvider;
0103:        import org.netbeans.modules.uml.ui.support.drawingproperties.IFontProperty;
0104:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.ETTransformOwner;
0105:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.GDISupport;
0106:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment;
0107:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine;
0108:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawInfo;
0109:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IETLabel;
0110:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.ILabelDrawEngine;
0111:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.INotificationTargets;
0112:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IResourceUserHelper;
0113:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.ISetCursorEvent;
0114:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IStretchContext;
0115:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.ITSGraphObject;
0116:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IToolTipData;
0117:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.CompartmentResourceUser;
0118:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.TypeConversions;
0119:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.UIResources;
0120:        import org.netbeans.modules.uml.ui.swing.drawingarea.ADGraphWindow;
0121:        import org.netbeans.modules.uml.ui.swing.drawingarea.IDrawingAreaControl;
0122:        import com.tomsawyer.editor.TSEGraphWindow;
0123:        import com.tomsawyer.editor.graphics.TSEGraphics;
0124:        import com.tomsawyer.graph.TSGraphObject;
0125:        import com.tomsawyer.drawing.geometry.TSConstPoint;
0126:        import com.tomsawyer.editor.TSTransform;
0127:        import java.util.StringTokenizer;
0128:        import javax.swing.Action;
0129:        import javax.swing.KeyStroke;
0130:        import org.netbeans.modules.uml.ui.products.ad.drawengines.ETNodeDrawEngine;
0131:        import org.netbeans.modules.uml.ui.swing.testbed.addin.menu.Separator;
0132:
0133:        /**
0134:         * @author Embarcadero Technologies Inc
0135:         *
0136:         *
0137:         */
0138:        public abstract class ETCompartment extends ETTransformOwner implements 
0139:                IADCompartment, IETContextMenuHandler,
0140:                IDrawingPropertyProvider, IResourceUserHelper, Accessible {
0141:            protected CompartmentResourceUser m_ResourceUser = new CompartmentResourceUser(
0142:                    (IResourceUserHelper) this );
0143:            protected int m_nNameFontStringID = -1;
0144:            protected static final int HOLLOW_EDGE_WIDTH = 15;
0145:
0146:            private static final String BUNDLE_NAME = "org.netbeans.modules.uml.ui.products.ad.diagramengines.Bundle"; //$NON-NLS-1$
0147:            private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
0148:                    .getBundle(BUNDLE_NAME);
0149:            // The parent draw engine.
0150:            protected IDrawEngine m_engine = null;
0151:
0152:            // Should the compartment display its name?
0153:            boolean m_showName = true;
0154:
0155:            // true if compartment cannot be edited
0156:            boolean m_readOnly = false;
0157:
0158:            protected IDrawInfo m_drawInfo = null;
0159:
0160:            // Is this compartment selected?
0161:            boolean m_selected = false;
0162:
0163:            // indicates whether this compartment has any presentation data to save
0164:            boolean m_hasOverride = false;
0165:
0166:            // The name of this compartment
0167:            protected String m_name = null;
0168:            protected String m_aliasName = null;
0169:
0170:            // The model element this compartment represents
0171:            protected IElement m_modelElement = null;
0172:
0173:            // The model element id.  When loading from archive this is used to cache up the model element that should be attached to
0174:            protected String m_XMIID = "";
0175:
0176:            // Is this compartment Visible
0177:            boolean m_visible = true;
0178:
0179:            // Can this compartment add context menus?
0180:            boolean m_contextMenuEnabled = true;
0181:
0182:            boolean m_resizeable = false;
0183:            boolean m_collapsible = false;
0184:            boolean m_collapsed = false;
0185:            boolean m_textWrapping = false;
0186:
0187:            // the compartment static text
0188:            //   String m_staticText = null;
0189:
0190:            // defines the area actually occupied by the compartment
0191:            protected IETRect m_boundingRect = new ETDeviceRect();
0192:
0193:            // defines the area actually occupied by text
0194:            protected IETRect m_textRect = null;
0195:
0196:            //protected long m_style = SINGLELINE | VCENTER | HCENTER | END_ELLIPSIS;
0197:
0198:            protected String m_fontString = "";
0199:
0200:            // The cashed optimum size must be calculated at least once
0201:            // Indicates that the optimum size has been determined
0202:            boolean m_hasOptimumSizeBeenSet = false;
0203:
0204:            // The last minimum size calculated, this is the size at 100%
0205:            protected IETSize m_cachedOptimumSize = new ETSize(0, 0);
0206:
0207:            /// The current bounding rect in 100% coordinates
0208:            protected IETSize m_cachedVisibleSize = new ETSize(0, 0);
0209:
0210:            /// The user defined size, -1,-1 if not to be used.  This is the size at 100%.  You must zoom it at other levels.
0211:            protected IETSize m_cachedUserSize = new ETSize(0, 0);
0212:
0213:            IETPoint m_ptLogicalOffsetInDrawEngineRect = new ETPoint();
0214:
0215:            // flag indicating that a mouse click over our text should select us
0216:            boolean m_singleClickSelect = true;
0217:
0218:            /**
0219:             * The vertical alignment value. Defaults to IADEditableCompartment.CENTER
0220:             *
0221:             * @see  IADEditableCompartment
0222:             */
0223:            private int m_VerticalAlignment = CENTER;
0224:
0225:            /**
0226:             * The horizontal alignment value. Defaults to IADEditableCompartment.CENTER
0227:             *
0228:             * @see  IADEditableCompartment
0229:             */
0230:            private int m_HorizontalAlignment = CENTER;
0231:
0232:            /**
0233:             * The border style to use when rendering the compartment.  Defaults to
0234:             * IADNameCompartment.NCBK_DRAW_JUST_NAME.
0235:             *
0236:             * @see IADNameCompartment
0237:             */
0238:            private int m_BorderKind = IADNameCompartment.NCBK_DRAW_JUST_NAME;
0239:
0240:            //   private IETSize m_CachedOptimumSize = null;
0241:
0242:            private UIResources m_resources = new UIResources();
0243:
0244:            public ETCompartment() {
0245:                this .init();
0246:            }
0247:
0248:            public ETCompartment(IDrawEngine pDrawEngine) {
0249:                this .setEngine(pDrawEngine);
0250:                this .init();
0251:            }
0252:
0253:            private void init() {
0254:                this .m_readOnly = false;
0255:                this .m_singleClickSelect = true;
0256:                this .setSelected(false);
0257:                this .setCollapsed(false);
0258:            }
0259:
0260:            public TSGraphObject getOwnerGraphObject() {
0261:                IDrawEngine engine = getEngine();
0262:                if (engine != null) {
0263:                    ITSGraphObject object = engine.getParentETElement();
0264:                    return object instanceof  TSGraphObject ? (TSGraphObject) object
0265:                            : null;
0266:                }
0267:
0268:                return null;
0269:            }
0270:
0271:            public void addDecoration(String sDecorationType, IETPoint pLocation) {
0272:                // TODO Auto-generated method stub
0273:            }
0274:
0275:            public TSEGraphics getGraphics(IDrawInfo pDrawInfo) {
0276:                if (pDrawInfo != null) {
0277:                    return pDrawInfo.getTSEGraphics();
0278:                } else if (m_drawInfo != null) {
0279:                    return m_drawInfo.getTSEGraphics();
0280:                } else if (getDrawingArea() != null) {
0281:                    TSEGraphWindow wnd = getDrawingArea().getGraphWindow();
0282:                    if (wnd != null) {
0283:                        Graphics g = wnd.getGraphics();
0284:                        if (g != null) {
0285:                            return wnd.newGraphics(g);
0286:                        }
0287:                    }
0288:                }
0289:
0290:                return null;
0291:            }
0292:
0293:            /**
0294:             * Set the compartment's model element.
0295:             */
0296:            public void addModelElement(IElement pElement, int nIndex) {
0297:                this .m_name = "";
0298:                this .m_modelElement = pElement;
0299:
0300:                this .m_XMIID = "";
0301:                this .getModelElementXMIID();
0302:                this .initResources();
0303:
0304:                // read the formatted name
0305:                if (m_modelElement != null) {
0306:                    IDataFormatter dataFormatter = ProductHelper
0307:                            .getDataFormatter();
0308:                    if (dataFormatter != null) {
0309:                        this .setName(dataFormatter
0310:                                .formatElement(m_modelElement));
0311:                    }
0312:                }
0313:            }
0314:
0315:            /**
0316:             * Calculates the "best" size for this compartment.  The calculation sets
0317:             * the member variable m_szCachedOptimumSize, which represents the "best"
0318:             * size of the compartment at 100%.
0319:             *
0320:             * @param pDrawInfo The draw info used to perform the calculation.
0321:             * @param bAt100Pct pMinSize is either in current zoom or 100% based on this
0322:             *                  flag.  If bAt100Pct then it's at 100%
0323:             * @return The optimum size of the compartment.
0324:             */
0325:            public IETSize calculateOptimumSize(IDrawInfo pDrawInfo,
0326:                    boolean bAt100Pct) {
0327:
0328:                int height = 0;
0329:                int width = 0;
0330:
0331:                String sCompartmentName = getName();
0332:                boolean bShowName = getShowName();
0333:                TSEGraphics graphics = getGraphics(pDrawInfo);
0334:
0335:                if (bShowName && (sCompartmentName != null)
0336:                        && (sCompartmentName.length() > 0)) {
0337:
0338:                    if (graphics != null) {
0339:
0340:                        Font originalFont = graphics.getFont();
0341:
0342:                        Font compartmentFont = getCompartmentFont(1.0);
0343:                        graphics.setFont(compartmentFont);
0344:
0345:                        height = graphics.getFontMetrics().getHeight() + 2;
0346:
0347:                        if (this .getName() != null) {
0348:                            width = graphics.getFontMetrics().stringWidth(
0349:                                    sCompartmentName) + 2;
0350:                        }
0351:
0352:                        graphics.setFont(originalFont);
0353:                    }
0354:                }
0355:
0356:                // Make sure only 1 to 1 ratio is the set in the internal size,
0357:                internalSetOptimumSize(width, height);
0358:
0359:                // Now Scale the device units
0360:                return bAt100Pct ? getOptimumSize(bAt100Pct) : this .scaleSize(
0361:                        this .m_cachedOptimumSize, graphics != null ? graphics
0362:                                .getTSTransform() : this .getTransform());
0363:            }
0364:
0365:            /**
0366:             * Retrieves the cached optimum size.
0367:             *
0368:             * @return The optimum size.
0369:             */
0370:            protected IETSize getCachedOptimumSize() {
0371:                return m_cachedOptimumSize;
0372:            }
0373:
0374:            /**
0375:             * Sets the internally cached optimum size member. {PROTECTED]
0376:             *
0377:             * @param size The size passed in is the actual zoomed
0378:             *              size at the current zoom level.
0379:             */
0380:            protected void internalSetOptimumSize(IETSize size) {
0381:                m_cachedOptimumSize = size;
0382:                m_hasOptimumSizeBeenSet = true;
0383:            }
0384:
0385:            /**
0386:             * Sets the internally cached optimum size member. {PROTECTED]
0387:             *
0388:             * @param size The size passed in is the actual zoomed
0389:             *              size at the current zoom level.
0390:             */
0391:            protected void internalSetOptimumSize(int width, int height) {
0392:                internalSetOptimumSize(new ETSize(width, height));
0393:            }
0394:
0395:            /*
0396:             * Returns a scaled size in Device untils using the input transform you must pass a size calculated at zoom level at Factor it was calculated at.
0397:             */
0398:            protected IETSize scaleSize(final IETSize atOneHundred,
0399:                    final TSTransform windowTransform, double fromFactor) {
0400:                if (atOneHundred != null && windowTransform != null) {
0401:                    TSTransform transform = (TSTransform) windowTransform
0402:                            .clone();
0403:                    transform.setScale(fromFactor);
0404:                    double worldSizeX = transform.widthToWorld(atOneHundred
0405:                            .getWidth());
0406:                    double worldSizeY = transform.heightToWorld(atOneHundred
0407:                            .getHeight());
0408:                    Dimension d = windowTransform.sizeToDevice(worldSizeX,
0409:                            worldSizeY);
0410:
0411:                    return new ETSize(d.width, d.height);
0412:                }
0413:                return null;
0414:            }
0415:
0416:            /*
0417:             * Returns a scaled size in Device untils using the input transform, you must pass a size calculated at zoom level 1.0
0418:             */
0419:            protected IETSize scaleSize(final IETSize atOneHundred,
0420:                    final TSTransform windowTransform) {
0421:                return scaleSize(atOneHundred, windowTransform, 1.0);
0422:            }
0423:
0424:            /*
0425:             * Returns a scaled size in Device untils, you must pass a size calculated at zoom level 1.0
0426:             */
0427:            protected IETSize scaleSize(final IETSize atOneHundred) {
0428:                return scaleSize(atOneHundred, this .getTransform());
0429:            }
0430:
0431:            /**
0432:             * Returns the size of the compartment if it could draw itself with no
0433:             * restrictions (does not recalculate, should not be called between zoom
0434:             * operations).  If the optimum size has not been set, CalculateOptimumSize()
0435:             * is called
0436:             *
0437:             * @param bAt100Pct
0438:             * @return The optimum size.
0439:             */
0440:            public IETSize getOptimumSize(boolean bAt100Pct) {
0441:                if (this .m_collapsed) {
0442:                    return new ETSize(0, 0);
0443:                } else if (!m_hasOptimumSizeBeenSet) {
0444:                    return calculateOptimumSize(null, bAt100Pct);
0445:                } else if (bAt100Pct) {
0446:                    return new ETSize(m_cachedOptimumSize.getWidth(),
0447:                            m_cachedOptimumSize.getHeight());
0448:
0449:                } else {
0450:                    return scaleSize(m_cachedOptimumSize);
0451:                }
0452:            }
0453:
0454:            /* (non-Javadoc)
0455:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#clearStretch()
0456:             */
0457:            public long clearStretch(IDrawInfo drawInfo) {
0458:                m_cachedUserSize.setSize(-1, -1);
0459:                return 0;
0460:            }
0461:
0462:            /* (non-Javadoc)
0463:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#clone(org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine, org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment)
0464:             */
0465:            public ICompartment clone(IDrawEngine pParentDrawEngine) {
0466:                // TODO Auto-generated method stub
0467:                return null;
0468:            }
0469:
0470:            public void draw(IDrawInfo pDrawInfo, IETRect pBoundingRect) {
0471:                m_drawInfo = pDrawInfo;
0472:
0473:                IETRect rectBounding = (IETRect) pBoundingRect.clone();
0474:
0475:                // if user has resized the compartment apply those now
0476:                if (m_collapsed) {
0477:                    rectBounding.setBottom(rectBounding.getTop());
0478:                } else {
0479:                    final double dZoomLevel = this .getZoomLevel(pDrawInfo);
0480:
0481:                    if (m_cachedUserSize.getHeight() > 0) {
0482:                        final int userSizeAtThisZoomLevel = (int) Math
0483:                                .round(m_cachedUserSize.getHeight()
0484:                                        * dZoomLevel);
0485:                        rectBounding.setBottom(Math.min(rectBounding
0486:                                .getBottom(), rectBounding.getTop()
0487:                                + userSizeAtThisZoomLevel));
0488:                    }
0489:                }
0490:
0491:                m_cachedVisibleSize.setWidth(rectBounding.getIntWidth());
0492:                m_cachedVisibleSize.setHeight(rectBounding.getIntHeight());
0493:
0494:                setBoundingRect(pDrawInfo, (IETRect) rectBounding.clone());
0495:
0496:                IETRect originRect = (IETRect) rectBounding.clone();
0497:
0498:                if (isCollapsible()) {
0499:                    originRect.setBottom(originRect.getTop());
0500:                }
0501:                setWinClientRectangle(originRect);
0502:            }
0503:
0504:            private void setBoundingRect(IDrawInfo pDrawInfo,
0505:                    IETRect pBoundingRect) {
0506:
0507:                TSEGraphics graphics = getGraphics(pDrawInfo);
0508:
0509:                if (graphics != null && pBoundingRect != null) {
0510:
0511:                    Font originalFont = graphics.getFont();
0512:
0513:                    Font compartmentFont = getCompartmentFont(pDrawInfo != null ? pDrawInfo
0514:                            .getFontScaleFactor()
0515:                            : graphics.getTSTransform().getScaleX());
0516:                    graphics.setFont(compartmentFont);
0517:
0518:                    //         int textWidth = 0;
0519:                    //
0520:                    //         if (getName() != null)
0521:                    //         {
0522:                    //            textWidth = graphics.getFontMetrics().stringWidth(getName());
0523:                    //         } else
0524:                    //         {
0525:                    //            textWidth = pBoundingRect.getIntWidth();
0526:                    //         }
0527:
0528:                    m_boundingRect = (IETRect) pBoundingRect.clone();
0529:
0530:                    //         m_textRect = new ETDeviceRect(pBoundingRect.getIntX(), pBoundingRect.getIntY(), textWidth, pBoundingRect.getIntHeight());
0531:                    m_textRect = new ETDeviceRect(pBoundingRect.getIntX(),
0532:                            pBoundingRect.getIntY(), pBoundingRect
0533:                                    .getIntWidth(), pBoundingRect
0534:                                    .getIntHeight());
0535:                    graphics.setFont(originalFont);
0536:                }
0537:            }
0538:
0539:            /**
0540:             * Invokes the in=place editor for this compartment.
0541:             *
0542:             * @param bNew[in] - Flag indicating that this is a new compartment and should be destroyed if the edit is cancelled.
0543:             * Default is FALSE.
0544:             * @param KeyCode[in] - The key pressed that invoked editing, NULL if none.  Default is NULL.
0545:             * @param nPos[in] - The horizontal position for the cursor, used if editing was activated via the mouse. The position value
0546:             * is in pixels in client coordinates, e.g. the left edge of the control is position 0.  Default is -1 which does not position
0547:             * the cursor (some translators may select a field by default).
0548:             */
0549:            public long editCompartment(boolean bNew, int nKeyCode, int nShift,
0550:                    int nPos) {
0551:                //nothing to do - editable compartment will handle it, a compartment by default is non-editable.
0552:                return 0;
0553:            }
0554:
0555:            /* (non-Javadoc)
0556:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#get_DefaultCompartment()
0557:             */
0558:            public ICompartment getDefaultCompartment() {
0559:                // TODO Auto-generated method stub
0560:                return null;
0561:            }
0562:
0563:            /**
0564:             * Returns the bounding rect for this compartment
0565:             */
0566:            public IETRect getBoundingRect() {
0567:                return this .m_boundingRect;
0568:            }
0569:
0570:            /**
0571:             * Returns the bounding rect for this compartment as a device rect
0572:             */
0573:            protected ETDeviceRect getBoundingAsDeviceRect() {
0574:                if (m_boundingRect instanceof  ETRect) {
0575:                    // This special case is for all the code that depends
0576:                    // on the bounding rectangle in device coordinates.
0577:                    return ((ETRect) m_boundingRect).getAsDeviceRect();
0578:                } else if (m_boundingRect instanceof  ETDeviceRect) {
0579:                    return (ETDeviceRect) m_boundingRect;
0580:                }
0581:
0582:                return null;
0583:            }
0584:
0585:            /* (non-Javadoc)
0586:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#getCenterText()
0587:             */
0588:            public boolean getCenterText() {
0589:                // Please note that is overidden,.
0590:                return false;
0591:            }
0592:
0593:            public boolean getCollapsed() {
0594:                return this .m_collapsed;
0595:            }
0596:
0597:            /* (non-Javadoc)
0598:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#getCompartmentHasNonRectangularShape()
0599:             */
0600:            public boolean getCompartmentHasNonRectangularShape() {
0601:                // TODO Auto-generated method stub
0602:                return false;
0603:            }
0604:
0605:            /**
0606:             * This is the name of the drawengine used when storing and reading from the product archive.
0607:             *
0608:             * @param sID[out,retval] The unique name for this compartment.  Used when reading and writing the
0609:             * product archive (etlp file).
0610:             */
0611:            public String getCompartmentID() {
0612:                return "Compartment";
0613:            }
0614:
0615:            /* (non-Javadoc)
0616:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#getCompartmentShape()
0617:             */
0618:            public ETList<IETPoint> getCompartmentShape() {
0619:                // TODO Auto-generated method stub
0620:                return null;
0621:            }
0622:
0623:            public IETSize getTextExtent(IDrawInfo drawInfo, String sText) {
0624:                return drawInfo != null ? GDISupport.getTextExtent(drawInfo
0625:                        .getTSEGraphics(), sText) : null;
0626:            }
0627:
0628:            public IETSize getCurrentSize(TSTransform transform,
0629:                    boolean bAt100Pct) {
0630:                IETSize retValue = null;
0631:                IETSize returnSize = null;
0632:                long nX = 0;
0633:                long nY = 0;
0634:
0635:                // fetch the last calculated size
0636:                returnSize = this .m_cachedOptimumSize;
0637:                if (returnSize == null) {
0638:                    return new ETSize((int) nX, (int) nY);
0639:                }
0640:
0641:                // if any sizes have been changed by the user report those instead
0642:                if (m_cachedUserSize != null && m_cachedUserSize.getWidth() > 0) {
0643:                    returnSize.setWidth(m_cachedUserSize.getWidth());
0644:                }
0645:                if (m_cachedUserSize != null
0646:                        && m_cachedUserSize.getHeight() > 0) {
0647:                    returnSize.setHeight(m_cachedUserSize.getHeight());
0648:                }
0649:
0650:                // apply zooming if requested
0651:                if (bAt100Pct == false) {
0652:                    // scale the size
0653:                    return scaleSize(returnSize, transform);
0654:                } else {
0655:                    nX = returnSize.getWidth();
0656:                    nY = returnSize.getHeight();
0657:                }
0658:
0659:                retValue = new ETSize((int) nX, (int) nY);
0660:                return retValue;
0661:            }
0662:
0663:            public IETSize getCurrentSize(boolean bAt100Pct) {
0664:                return this .getCurrentSize(this .getTransform(), bAt100Pct);
0665:            }
0666:
0667:            /**
0668:             * Returns the best fit size for this compartment.  Single compartments
0669:             * return the optimum size.
0670:             *
0671:             * @return The desired size.  The desired size will be equal to the optimum
0672:             *         size if scrolling is not in effect, otherwise it will be equal to
0673:             *         the optimum width and the current height.
0674:             */
0675:            public IETSize getDesiredSizeToFit() {
0676:                return calculateOptimumSize(null, true);
0677:            }
0678:
0679:            /**
0680:             * Enables or disables the compartments context menu
0681:             *
0682:             * @param pVal [out,retval] true if this compartment can add context menu items
0683:             */
0684:            public boolean getEnableContextMenu() {
0685:                return m_contextMenuEnabled;
0686:            }
0687:
0688:            public IDrawEngine getEngine() {
0689:                return this .m_engine;
0690:            }
0691:
0692:            /**
0693:             * Converts a diagram logical point to a logical location within the compartment.
0694:             *
0695:             * @param pPosition Logical location within the diagram
0696:             *
0697:             * @return A non-zoomed location within the compartment (0,0) is the upper left
0698:             */
0699:            public IETPoint logicalToCompartmentLogical(IETPoint position) {
0700:                return logicalToCompartmentLogical(position.getX(), position
0701:                        .getY());
0702:            }
0703:
0704:            /**
0705:             * Converts a diagram logical point to a logical location within the compartment.
0706:             *
0707:             * @param pPosition Logical location within the diagram
0708:             *
0709:             * @return A non-zoomed location within the compartment (0,0) is the upper left
0710:             */
0711:            public IETPoint logicalToCompartmentLogical(int x, int y) {
0712:                IETPoint retVal = null;
0713:
0714:                IETRect logicalBounding = getLogicalBoundingRect();
0715:                if (logicalBounding != null) {
0716:                    retVal = new ETPoint();
0717:                    retVal.setX(x - logicalBounding.getLeft());
0718:                    retVal.setY(logicalBounding.getTop() - y);
0719:                } else {
0720:                    retVal = new ETPoint(x, y);
0721:                }
0722:
0723:                return retVal;
0724:            }
0725:
0726:            /* (non-Javadoc)
0727:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#getLogicalOffsetInDrawEngineRect()
0728:             */
0729:            public IETPoint getLogicalOffsetInDrawEngineRect() {
0730:                return m_ptLogicalOffsetInDrawEngineRect;
0731:            }
0732:
0733:            public IElement getModelElement() {
0734:
0735:                if (this .m_modelElement == null) {
0736:                    if (this .m_XMIID.length() > 0) {
0737:                        this .reattach(this .m_XMIID);
0738:                        return this .m_modelElement;
0739:                    } else {
0740:                        return null;
0741:                    }
0742:                } else {
0743:                    return this .m_modelElement;
0744:                }
0745:            }
0746:
0747:            public String getModelElementXMIID() {
0748:                if (m_XMIID == null || m_XMIID.length() == 0
0749:                        && m_modelElement != null) {
0750:                    setModelElementXMIID(m_modelElement.getXMIID());
0751:                }
0752:
0753:                return m_XMIID != null ? m_XMIID : "";
0754:            }
0755:
0756:            public void setModelElementXMIID(String newVal) {
0757:                this .m_XMIID = newVal;
0758:            }
0759:
0760:            /* (non-Javadoc)
0761:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#getParentResource()
0762:             */
0763:            public int getParentResource() {
0764:                // TODO Auto-generated method stub
0765:                return 0;
0766:            }
0767:
0768:            /**
0769:             * Get the parent product element, if there is one.
0770:             */
0771:            public IETLabel getParentETLabel() {
0772:                IETLabel retVal = null;
0773:                IDrawEngine pEngine = getEngine();
0774:                if (pEngine != null && pEngine instanceof  ILabelDrawEngine) {
0775:                    retVal = ((ILabelDrawEngine) pEngine).getParentETLabel();
0776:                }
0777:                return retVal;
0778:            }
0779:
0780:            public boolean getReadOnly() {
0781:                boolean isReadOnly = m_readOnly;
0782:
0783:                //  readonly drawengine implies readonly compartment
0784:                if ((m_engine != null) && !isReadOnly) {
0785:                    isReadOnly = m_engine.getReadOnly();
0786:                }
0787:
0788:                return isReadOnly;
0789:            }
0790:
0791:            public boolean isSelected() {
0792:                return this .m_selected;
0793:            }
0794:
0795:            public boolean getShowName() {
0796:                return this .m_showName;
0797:            }
0798:
0799:            /* (non-Javadoc)
0800:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#getTextWrapping()
0801:             */
0802:            public boolean getTextWrapping() {
0803:                return m_textWrapping;
0804:            }
0805:
0806:            /* (non-Javadoc)
0807:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#getVerticallyCenterText()
0808:             */
0809:            public boolean getVerticallyCenterText() {
0810:                // TODO Auto-generated method stub
0811:                return false;
0812:            }
0813:
0814:            public boolean getVisible() {
0815:                return this .m_visible;
0816:            }
0817:
0818:            /* (non-Javadoc)
0819:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#getVisibleSize(int, int, boolean)
0820:             */
0821:            public IETSize getVisibleSize(boolean bAt100Pct) {
0822:
0823:                int nX = m_cachedVisibleSize.getWidth();
0824:                int nY = m_cachedVisibleSize.getHeight();
0825:
0826:                // Remove zooming if requested
0827:                if (bAt100Pct == true) {
0828:                    // scale the size
0829:                    final double dZoomLevel = getZoomLevel();
0830:                    nX = (int) Math.round(m_cachedVisibleSize.getWidth()
0831:                            / dZoomLevel);
0832:                    nY = (int) Math.round(m_cachedVisibleSize.getHeight()
0833:                            / dZoomLevel);
0834:                }
0835:
0836:                return new ETSize(nX, nY);
0837:            }
0838:
0839:            /* (non-Javadoc)
0840:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#handleKeyDown(int, int)
0841:             */
0842:            public boolean handleKeyDown(int keyCode, int Shift) {
0843:                return false;
0844:            }
0845:
0846:            /* (non-Javadoc)
0847:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#handleCharTyped(char)
0848:             */
0849:            public boolean handleCharTyped(char ch) {
0850:                return false;
0851:            }
0852:
0853:            /* (non-Javadoc)
0854:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#handleKeyUp(int, int)
0855:             */
0856:            public boolean handleKeyUp(int KeyCode, int Shift) {
0857:                // TODO Auto-generated method stub
0858:                return false;
0859:            }
0860:
0861:            /* (non-Javadoc)
0862:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#handleRightMouseButton(org.netbeans.modules.uml.ui.support.viewfactorysupport.IMouseEvent)
0863:             */
0864:            public boolean handleRightMouseButton(MouseEvent pEvent) {
0865:                // TODO Auto-generated method stub
0866:                return false;
0867:            }
0868:
0869:            /* (non-Javadoc)
0870:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#handleSetCursor(org.netbeans.modules.uml.core.support.umlsupport.IETPoint)
0871:             */
0872:            public boolean handleSetCursor(IETPoint point, ISetCursorEvent event) {
0873:                boolean bHandled = false;
0874:
0875:                /* TODO get the m_textRect working properly. It is not working in C++ at this point
0876:                      final IETRect rect = getWinScaledOwnerRect();
0877:                 
0878:                      if( getWinScaledOwnerRect().contains( point ) )
0879:                      {
0880:                         bHandled = true;
0881:                 
0882:                         // set cursor to an arrow only when over text
0883:                         if( (m_textRect.getHeight() >= 8) && m_textRect.contains( point ) )
0884:                         {
0885:                            event.setCursor( Cursor.getPredefinedCursor( Cursor.TEXT_CURSOR ) );
0886:                         }
0887:                      }
0888:                 */
0889:
0890:                return bHandled;
0891:            }
0892:
0893:            /* (non-Javadoc)
0894:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#hasOverride()
0895:             */
0896:            public boolean hasOverride() {
0897:                // TODO Auto-generated method stub
0898:                return false;
0899:            }
0900:
0901:            /* (non-Javadoc)
0902:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#initResources()
0903:             */
0904:            private boolean m_bInitResources = false;
0905:
0906:            public void initResources() {
0907:                if (m_bInitResources == false) {
0908:                    m_resources.setResourceID(UIResources.CK_FONT);
0909:                    m_resources.setResourceID(UIResources.CK_TEXTCOLOR);
0910:                    m_resources.setResourceID(UIResources.CK_FILLCOLOR);
0911:                    m_bInitResources = true;
0912:                }
0913:            }
0914:
0915:            /**
0916:             * Toggle selection status.
0917:             */
0918:            public void invertSelected() {
0919:                this .m_selected = !this .m_selected;
0920:                if ((m_selected) && (m_engine != null)) {
0921:                    m_engine.setAnchoredCompartment(this );
0922:                }
0923:            }
0924:
0925:            public boolean isCollapsible() {
0926:                return this .m_collapsible;
0927:            }
0928:
0929:            public boolean isPointInCompartment(IETPoint pPoint) {
0930:                IETRect deviceRect = getBoundingAsDeviceRect();
0931:                return deviceRect != null ? deviceRect.contains(pPoint) : false;
0932:            }
0933:
0934:            /* (non-Javadoc)
0935:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#isPointInCompartmentYAxis(org.netbeans.modules.uml.core.support.umlsupport.IETPoint)
0936:             */
0937:            public boolean isPointInCompartmentYAxis(IETPoint pLogical) {
0938:                // TODO Auto-generated method stub
0939:                return false;
0940:            }
0941:
0942:            /* (non-Javadoc)
0943:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#isPointInOptimum(org.netbeans.modules.uml.core.support.umlsupport.IETPoint)
0944:             */
0945:            public boolean isPointInOptimum(IETPoint pLogical) {
0946:                // TODO Auto-generated method stub
0947:                return false;
0948:            }
0949:
0950:            public void setResizeToFitCompartments(boolean resize) {
0951:                m_resizeable = resize;
0952:            }
0953:
0954:            public boolean isResizeable() {
0955:                return this .m_resizeable;
0956:            }
0957:
0958:            /* (non-Javadoc)
0959:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#isResizing()
0960:             */
0961:            public boolean isResizing() {
0962:                // TODO Auto-generated method stub
0963:                return false;
0964:            }
0965:
0966:            /* (non-Javadoc)
0967:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#layout(org.netbeans.modules.uml.core.support.umlsupport.IETRect)
0968:             */
0969:            public long layout(IETRect pCompartmentInDE) {
0970:                // TODO Auto-generated method stub
0971:                return 0;
0972:            }
0973:
0974:            /* (non-Javadoc)
0975:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#modelElementDeleted(org.netbeans.modules.uml.ui.support.viewfactorysupport.INotificationTargets)
0976:             */
0977:            public long modelElementDeleted(INotificationTargets pTargets) {
0978:                // TODO Auto-generated method stub
0979:                return 0;
0980:            }
0981:
0982:            /* (non-Javadoc)
0983:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#modelElementHasChanged(org.netbeans.modules.uml.ui.support.viewfactorysupport.INotificationTargets)
0984:             */
0985:            public long modelElementHasChanged(INotificationTargets pTargets) {
0986:                // TODO Auto-generated method stub
0987:                return 0;
0988:            }
0989:
0990:            /* (non-Javadoc)
0991:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#nodeResized(int)
0992:             */
0993:            public long nodeResized(int nodeResizeOriginator) {
0994:                // TODO Auto-generated method stub
0995:                return 0;
0996:            }
0997:
0998:            /* (non-Javadoc)
0999:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#onContextMenu(org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenu, int, int)
1000:             */
1001:            public long onContextMenu(IProductContextMenu pContextMenu,
1002:                    int logicalX, int logicalY) {
1003:                // TODO Auto-generated method stub
1004:                return 0;
1005:            }
1006:
1007:            public void onContextMenu(IMenuManager manager) {
1008:
1009:            }
1010:
1011:            /* (non-Javadoc)
1012:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#onContextMenuHandleSelection(org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenu, org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenuItem)
1013:             */
1014:            public long onContextMenuHandleSelection(
1015:                    IProductContextMenu pContextMenu,
1016:                    IProductContextMenuItem pMenuItem) {
1017:                // TODO Auto-generated method stub
1018:                return 0;
1019:            }
1020:
1021:            /* (non-Javadoc)
1022:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#onGraphEvent(int)
1023:             */
1024:            public long onGraphEvent(int nKind) {
1025:                // TODO Auto-generated method stub
1026:                return 0;
1027:            }
1028:
1029:            /* (non-Javadoc)
1030:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#postLoad()
1031:             */
1032:            public long postLoad() {
1033:                // TODO Auto-generated method stub
1034:                return 0;
1035:            }
1036:
1037:            /* (non-Javadoc)
1038:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#queryToolTipData(org.netbeans.modules.uml.ui.support.viewfactorysupport.IToolTipData)
1039:             */
1040:            public long queryToolTipData(IToolTipData pToolTipData) {
1041:                // TODO Auto-generated method stub
1042:                return 0;
1043:            }
1044:
1045:            /**
1046:             * Update from archive.
1047:             *
1048:             * @param pProductArchive [in] The archive we're reading from
1049:             * @param pCompartmentElement [in] The element where this compartment's information should exist
1050:             */
1051:            public void readFromArchive(IProductArchive pProductArchive,
1052:                    IProductArchiveElement pCompartmentElement) {
1053:                if (pProductArchive != null && pCompartmentElement != null) {
1054:                    // set the default resources for this compartment
1055:                    initResources();
1056:
1057:                    // get compartment's XMI ID
1058:                    //this.m_XMIID = pCompartmentElement.getAttributeString(IProductArchiveDefinitions.COMPARTMENTXMIIDATTRIBUTE_STRING);
1059:                    IProductArchiveAttribute idAttr = pCompartmentElement
1060:                            .getAttribute(IProductArchiveDefinitions.COMPARTMENTXMIIDATTRIBUTE_STRING);
1061:                    if (idAttr != null) {
1062:                        String str = idAttr.getStringValue();
1063:                        if (str != null && str.length() > 0) {
1064:                            m_XMIID = str;
1065:                        } else {
1066:                            m_XMIID = "";
1067:                        }
1068:                    }
1069:
1070:                    // get our text
1071:                    String text = pCompartmentElement
1072:                            .getAttributeString(IProductArchiveDefinitions.COMPARTMENTTEXTATTRIBUTE_STRING);
1073:                    if (text != null && text.length() > 0) {
1074:                        setName(text);
1075:                    }
1076:                    //this.m_staticText = pCompartmentElement.getAttributeString(IProductArchiveDefinitions.COMPARTMENTTEXTATTRIBUTE_STRING);
1077:                    this 
1078:                            .setName(pCompartmentElement
1079:                                    .getAttributeString(IProductArchiveDefinitions.COMPARTMENTTEXTATTRIBUTE_STRING));
1080:
1081:                    //this.m_aliasName = pCompartmentElement.getAttributeString(IProductArchiveDefinitions.COMPARTMENTALIASATTRIBUTE_STRING);
1082:                    //this.m_style = pCompartmentElement.getAttributeString(IProductArchiveDefinitions.COMPARTMENTTEXTSTYLE_STRING);
1083:
1084:                    // Get our font
1085:                    ETPairT<IProductArchiveElement, String> result = pProductArchive
1086:                            .getTableEntry(
1087:                                    pCompartmentElement,
1088:                                    IProductArchiveDefinitions.COMPARTMENTFONTATTRIBUTE_STRING,
1089:                                    IProductArchiveDefinitions.COMPARTMENTFONTTABLE_STRING);
1090:                    if (result != null) {
1091:                        String foundId = result.getParamTwo();
1092:                        if (foundId != null && foundId.length() > 0) {
1093:                            //setResourceID(CK_FONT, foundId);
1094:                        }
1095:                    }
1096:
1097:                    // Get our forground color
1098:                    result = null;
1099:                    result = pProductArchive
1100:                            .getTableEntry(
1101:                                    pCompartmentElement,
1102:                                    IProductArchiveDefinitions.COMPARTMENTFOREATTRIBUTE_STRING,
1103:                                    IProductArchiveDefinitions.COMPARTMENTFONTCOLORTABLE_STRING);
1104:                    if (result != null) {
1105:                        String foundId = result.getParamTwo();
1106:                        if (foundId != null && foundId.length() > 0) {
1107:                            //setResourceID(CK_TEXTCOLOR, foundId);
1108:                        }
1109:                    }
1110:
1111:                    // Get our text style
1112:                    //m_style = pCompartmentElement.getAttributeLong(IProductArchiveDefinitions.COMPARTMENTTEXTSTYLE_STRING);
1113:                    String styles = pCompartmentElement
1114:                            .getAttributeString(IProductArchiveDefinitions.COMPARTMENTTEXTSTYLE_STRING);
1115:                    setTextStyles(styles);
1116:
1117:                    // Get our collapsed state
1118:                    m_collapsed = pCompartmentElement
1119:                            .getAttributeBool(IProductArchiveDefinitions.COMPARTMENTCOLLAPSED_STRING);
1120:
1121:                    // Tell the drawing factory that we need to load our resources.  This has to happen
1122:                    // though after all the compartments and the drawengine is created.  The drawengine
1123:                    // needs to call InitResources first to setup the basic resources - then we overlay
1124:                    // and overwrite those basic resources with the ones in the file.  So we need to
1125:                    // delay the loading of resources until after the draw engine is done.  See
1126:                    // DrawEngineImpl::ReadFromArchive for where we complete the loading of the compartment.
1127:                    DrawingFactory.addCompartmentResourcePair(this ,
1128:                            pCompartmentElement);
1129:                }
1130:            }
1131:
1132:            protected String getTextStylesAsString() {
1133:                StringBuffer retVal = new StringBuffer();
1134:
1135:                int vAlignment = getVerticalAlignment();
1136:                if ((vAlignment & CENTER) == CENTER) {
1137:                    addPipedDelementedString(retVal, "VCENTER");
1138:                }
1139:
1140:                if ((vAlignment & LEFT) == LEFT) {
1141:                    addPipedDelementedString(retVal, "LEFT");
1142:                }
1143:
1144:                if ((vAlignment & RIGHT) == RIGHT) {
1145:                    addPipedDelementedString(retVal, "RIGHT");
1146:                }
1147:
1148:                int hAlignment = getHorizontalAlignment();
1149:                if ((hAlignment & CENTER) == CENTER) {
1150:                    addPipedDelementedString(retVal, "HCENTER");
1151:                }
1152:
1153:                if ((hAlignment & TOP) == TOP) {
1154:                    addPipedDelementedString(retVal, "TOP");
1155:                }
1156:
1157:                if ((hAlignment & BOTTOM) == BOTTOM) {
1158:                    addPipedDelementedString(retVal, "BOTTOM");
1159:                }
1160:
1161:                if (getTextWrapping() == true) {
1162:                    addPipedDelementedString(retVal, "MULTILINE");
1163:                } else {
1164:                    addPipedDelementedString(retVal, "SINGLELINE");
1165:                }
1166:
1167:                return retVal.toString();
1168:            }
1169:
1170:            protected void addPipedDelementedString(StringBuffer buffer,
1171:                    String value) {
1172:                if (buffer.length() > 0) {
1173:                    buffer.append("|");
1174:                }
1175:                buffer.append(value);
1176:            }
1177:
1178:            protected void setTextStyles(String styles) {
1179:                StringTokenizer tokenizer = new StringTokenizer(styles, "|");
1180:
1181:                m_VerticalAlignment = 0;
1182:                m_HorizontalAlignment = 0;
1183:                while (tokenizer.hasMoreTokens() == true) {
1184:                    String curToken = tokenizer.nextToken();
1185:                    if (curToken.equals("VCENTER") == true) {
1186:                        m_VerticalAlignment |= CENTER;
1187:                    } else if (curToken.equals("HCENTER") == true) {
1188:                        m_HorizontalAlignment |= CENTER;
1189:                    } else if (curToken.equals("LEFT") == true) {
1190:                        m_VerticalAlignment |= LEFT;
1191:                    } else if (curToken.equals("RIGHT") == true) {
1192:                        m_VerticalAlignment |= RIGHT;
1193:                    } else if (curToken.equals("TOP") == true) {
1194:                        m_HorizontalAlignment |= TOP;
1195:                    } else if (curToken.equals("BOTTOM") == true) {
1196:                        m_HorizontalAlignment |= BOTTOM;
1197:                    } else if (curToken.equals("SINGLELINE") == true) {
1198:                        setTextWrapping(false);
1199:                    } else if (curToken.equals("MULTILINE") == true) {
1200:                        setTextWrapping(true);
1201:                    } else if (curToken.equals("END_ELLIPSIS") == true) {
1202:
1203:                    }
1204:                }
1205:            }
1206:
1207:            /**
1208:             * Reattachs to the model element whose XMIID matches that specified.
1209:             */
1210:            public void reattach() {
1211:                reattach(null);
1212:            }
1213:
1214:            /**
1215:             * Reattachs to the model element whose XMIID matches that specified.
1216:             */
1217:            public void reattach(String pCompartmentID) {
1218:                String compartmentId = pCompartmentID;
1219:                if (compartmentId == null || compartmentId.length() == 0) {
1220:                    compartmentId = getXMIID();
1221:                }
1222:
1223:                ElementLocator elementLocator = new ElementLocator();
1224:                IETGraphObjectUI ui = this .getEngine().getParent();
1225:
1226:                IElement element = elementLocator.findElementByID(ui
1227:                        .getTopLevelMEIDValue(), compartmentId);
1228:                if (element != null) {
1229:                    this .addModelElement(element, -1);
1230:                    this .getEngine().invalidate();
1231:                }
1232:            }
1233:
1234:            /* (non-Javadoc)
1235:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#saveModelElement()
1236:             */
1237:            public long saveModelElement() {
1238:                // TODO Auto-generated method stub
1239:                return 0;
1240:            }
1241:
1242:            /* (non-Javadoc)
1243:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#selectExtended(org.netbeans.modules.uml.core.support.umlsupport.IETRect)
1244:             */
1245:            public boolean selectExtended(IETRect rect) {
1246:                // TODO Auto-generated method stub
1247:                return false;
1248:            }
1249:
1250:            /* (non-Javadoc)
1251:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#setCenterText(boolean)
1252:             */
1253:            public void setCenterText(boolean value) {
1254:                // TODO Auto-generated method stub
1255:
1256:            }
1257:
1258:            public void setCollapsed(boolean value) {
1259:                this .m_collapsed = value;
1260:            }
1261:
1262:            public void setCurrentSize(IETSize pNewSize) {
1263:
1264:                /*
1265:                 if (m_cachedOptimumSize != null && m_cachedOptimumSize == pNewSize)
1266:                 {
1267:                 clearStretch(drawInfo);
1268:                 }
1269:                 else
1270:                 {
1271:                 m_cachedUserSize = new ETSize(pNewSize.getWidth(), pNewSize.getHeight());
1272:                 m_cachedVisibleSize = new ETSize(pNewSize.getWidth(), pNewSize.getHeight());
1273:                 }
1274:                 */
1275:                //
1276:                m_cachedUserSize = new ETSize(pNewSize);
1277:                m_cachedVisibleSize = new ETSize(pNewSize);
1278:            }
1279:
1280:            /**
1281:             * Enables or disables the compartments context menu
1282:             *
1283:             * @param bVisible [in] true if this compartment can add context menu items
1284:             */
1285:            public void setEnableContextMenu(boolean value) {
1286:                m_contextMenuEnabled = value;
1287:            }
1288:
1289:            public void setEngine(IDrawEngine pEngine) {
1290:                this .m_engine = pEngine;
1291:
1292:                // m_Resources.ClearResourceManager();
1293:
1294:                if (m_engine != null) {
1295:                    m_resources.setParentResources(m_engine.getResources());
1296:                }
1297:            }
1298:
1299:            /* (non-Javadoc)
1300:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#setLogicalOffsetInDrawEngineRect(org.netbeans.modules.uml.core.support.umlsupport.IETPoint)
1301:             */
1302:            public void setLogicalOffsetInDrawEngineRect(IETPoint value) {
1303:                m_ptLogicalOffsetInDrawEngineRect = value;
1304:            }
1305:
1306:            /* (non-Javadoc)
1307:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#setParentResource(int)
1308:             */
1309:            public long setParentResource(int pParentResource) {
1310:                // TODO Auto-generated method stub
1311:                return 0;
1312:            }
1313:
1314:            public void setReadOnly(boolean pValue) {
1315:                this .m_readOnly = pValue;
1316:            }
1317:
1318:            public void setSelected(boolean pValue) {
1319:                this .m_selected = pValue;
1320:                if ((m_selected == true) && (m_engine != null)) {
1321:                    m_engine.setAnchoredCompartment(this );
1322:                }
1323:            }
1324:
1325:            public boolean setSensitivityAndCheck(
1326:                    IProductContextMenu pContextMenu,
1327:                    IProductContextMenuItem pMenuItem, int buttonKind) {
1328:                // TODO Auto-generated method stub
1329:                return false;
1330:            }
1331:
1332:            public void setShowName(boolean pValue) {
1333:                this .m_showName = pValue;
1334:            }
1335:
1336:            //   public void setStyle(int value)
1337:            //   {
1338:            //      m_style = value;
1339:            //   }
1340:
1341:            /* (non-Javadoc)
1342:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#setTextWrapping(boolean)
1343:             */
1344:            public void setTextWrapping(boolean value) {
1345:                m_textWrapping = value;
1346:            }
1347:
1348:            public void setTransformSize(IETSize pNewSize) {
1349:                if (pNewSize != null) {
1350:                    setTransformSize(pNewSize.getWidth(), pNewSize.getHeight());
1351:                }
1352:            }
1353:
1354:            public void setTransformSize(int width, int height) {
1355:                setAbsoluteSize(width, height);
1356:            }
1357:
1358:            /* (non-Javadoc)
1359:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#setVerticallyCenterText(boolean)
1360:             */
1361:            public void setVerticallyCenterText(boolean value) {
1362:                // TODO Auto-generated method stub
1363:
1364:            }
1365:
1366:            /* (non-Javadoc)
1367:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#getContained()
1368:             */
1369:            public ETList<IPresentationElement> getContained() {
1370:                return getContained(this );
1371:            }
1372:
1373:            /**
1374:             * Retrieves the presentation elements graphically contained by this compartment.
1375:             */
1376:            public static ETList<IPresentationElement> getContained(
1377:                    ICompartment compartment) {
1378:                ETList<IPresentationElement> pes = null;
1379:
1380:                INodePresentation this NodePE = TypeConversions
1381:                        .getNodePresentation(compartment);
1382:                if (this NodePE != null) {
1383:                    // Find all the presentation elements inside this compartment's bounding rectangle
1384:
1385:                    IETRect rect = compartment.getLogicalBoundingRect();
1386:                    pes = this NodePE.getPEsViaRect(false, rect);
1387:                }
1388:
1389:                return pes;
1390:            }
1391:
1392:            public void setVisible(boolean pValue) {
1393:                this .m_visible = pValue;
1394:            }
1395:
1396:            /* (non-Javadoc)
1397:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#stretch(org.netbeans.modules.uml.ui.support.viewfactorysupport.IStretchContext)
1398:             */
1399:            public long stretch(IStretchContext pStretchContext) {
1400:                // TODO Auto-generated method stub
1401:                return 0;
1402:            }
1403:
1404:            /* (non-Javadoc)
1405:             * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment#validate(org.netbeans.modules.uml.core.metamodel.core.foundation.IElement)
1406:             */
1407:            public boolean validate(IElement pElement) {
1408:                String sID = pElement != null ? pElement.getXMIID() : null;
1409:
1410:                if (sID != null && sID.length() > 0) {
1411:                    String sOurID = getXMIID();
1412:                    return sOurID != null && sOurID.length() > 0
1413:                            && sOurID.equals(sID);
1414:                }
1415:                return false;
1416:            }
1417:
1418:            /**
1419:             * Write ourselves to archive, returns the compartment element.
1420:             *
1421:             * @param pProductArchive [in] The archive we're saving to
1422:             * @param pElement [in] The current element, or parent for any new attributes or elements
1423:             * @param pCompartmentElement [out] The created element for this compartment's information
1424:             */
1425:            public IProductArchiveElement writeToArchive(
1426:                    IProductArchive pProductArchive,
1427:                    IProductArchiveElement pEngineElement) {
1428:                IProductArchiveElement retObj = null;
1429:                if (pEngineElement != null) {
1430:                    // create an element for this compartment
1431:                    String compEleId = getXMIID();
1432:                    String compName = getCompartmentID();
1433:                    IProductArchiveElement pElement = pEngineElement
1434:                            .createElement(IProductArchiveDefinitions.COMPARTMENTNAMEELEMENT_STRING);
1435:                    if (pElement != null) {
1436:                        // Add the compartment name to the table of compartment names, store just the id so we
1437:                        // can store more compactly.
1438:                        IProductArchiveAttribute createdAttr = pProductArchive
1439:                                .insertIntoTable(
1440:                                        IProductArchiveDefinitions.COMPARTMENTNAMETABLE_STRING,
1441:                                        compName,
1442:                                        IProductArchiveDefinitions.COMPARTMENTNAMETABLEINDEXATTRIBUTE_STRING,
1443:                                        pElement);
1444:                        createdAttr = null;
1445:                        if (compEleId != null && compEleId.length() > 0) {
1446:                            // write xml id
1447:                            pElement
1448:                                    .addAttributeString(
1449:                                            IProductArchiveDefinitions.COMPARTMENTXMIIDATTRIBUTE_STRING,
1450:                                            compEleId);
1451:                        }
1452:
1453:                        // return element if requested
1454:                        retObj = pElement;
1455:
1456:                        // write out changes to text fields
1457:                        // write out our text
1458:                        String str = getName();
1459:                        pElement
1460:                                .addAttributeString(
1461:                                        IProductArchiveDefinitions.COMPARTMENTTEXTATTRIBUTE_STRING,
1462:                                        str);
1463:
1464:                        // Write our text style
1465:                        pElement
1466:                                .addAttributeString(
1467:                                        IProductArchiveDefinitions.COMPARTMENTTEXTSTYLE_STRING,
1468:                                        getTextStylesAsString());
1469:
1470:                        // Set our collapsed state
1471:                        if (m_collapsed) {
1472:                            pElement
1473:                                    .addAttributeBool(
1474:                                            IProductArchiveDefinitions.COMPARTMENTCOLLAPSED_STRING,
1475:                                            m_collapsed);
1476:                        }
1477:
1478:                        // now write out our resourceid's
1479:                        m_ResourceUser.writeResourcesToArchive(pProductArchive,
1480:                                pElement);
1481:                    }
1482:                }
1483:                return retObj;
1484:            }
1485:
1486:            /**
1487:             * @param pProductArchive
1488:             * @param pElement
1489:             */
1490:            private void writeResourcesToArchive(
1491:                    IProductArchive pProductArchive,
1492:                    IProductArchiveElement pElement) {
1493:                // TODO Auto-generated method stub
1494:
1495:            }
1496:
1497:            /**
1498:             * Get the compartment's XMI ID.
1499:             */
1500:            public String getXMIID() {
1501:                if (m_XMIID == null || m_XMIID.length() == 0) {
1502:                    if (m_modelElement != null) {
1503:                        m_XMIID = m_modelElement.getXMIID();
1504:                    }
1505:                }
1506:                return m_XMIID;
1507:            }
1508:
1509:            // Is the mouse unhandled and within the bounding rect of an editable compartment?
1510:            public boolean isMouseInBoundingRect(MouseEvent pEvent,
1511:                    boolean pHandled) {
1512:                ETDeviceRect rect = getBoundingAsDeviceRect();
1513:                Point point = pEvent.getPoint();
1514:                return !pHandled && !this .m_readOnly && rect != null
1515:                        && rect.contains(point.x, point.y);
1516:            }
1517:
1518:            // Is the mouse unhandled and within the text area of an editable compartment?
1519:            public boolean isMouseInTextRect(MouseEvent pEvent, boolean pHandled) {
1520:                return false;
1521:            }
1522:
1523:            public boolean handleLeftMouseButton(MouseEvent pEvent) {
1524:                boolean retVal = false;
1525:                if (this .m_singleClickSelect
1526:                        && this .isMouseInTextRect(pEvent, false)) {
1527:                    if (pEvent.isControlDown()) {
1528:                        this .invertSelected();
1529:                    } else if (pEvent.isShiftDown()) {
1530:                        this .m_engine.selectExtendCompartments(pEvent);
1531:                    } else {
1532:                        this .m_engine.selectAllCompartments(false);
1533:                        this .m_engine.anchorMouseEvent(pEvent, this );
1534:                        this .invertSelected();
1535:                    }
1536:                    retVal = true;
1537:                }
1538:                return retVal;
1539:            }
1540:
1541:            public boolean handleLeftMouseBeginDrag(IETPoint pStartPos,
1542:                    IETPoint pCurrentPos, boolean bCancel) {
1543:                return this .m_selected && this .isPointInCompartment(pStartPos);
1544:            }
1545:
1546:            public boolean handleLeftMouseButtonDoubleClick(MouseEvent pEvent) {
1547:                boolean isHandled = false;
1548:                boolean bBeginEdit = false;
1549:                if (isMouseInBoundingRect(pEvent, isHandled)) {
1550:                    bBeginEdit = true;
1551:                } else if (isMouseInTextRect(pEvent, isHandled)) {
1552:                    bBeginEdit = true;
1553:                }
1554:
1555:                if (bBeginEdit) {
1556:                    //int x = pEvent.getX() - getWinScaledOwnerRect().left;
1557:                    editCompartment(false, 0, 0, pEvent.getX());
1558:                    isHandled = true;
1559:                    // this logic is not clear, commented out for 114303
1560:                    //            if (!(this.m_engine instanceof ETCommentDrawEngine) &&
1561:                    //                !(this.m_engine instanceof ETUseCaseDrawEngine) &&
1562:                    //                !(this.m_engine instanceof ETInvocationNodeDrawEngine) &&
1563:                    //                !(this.m_engine instanceof ObjectNodeDrawEngine) &&
1564:                    //                !(this.m_engine instanceof LifelineDrawEngine) &&
1565:                    //                !(this.m_engine instanceof ETStateDrawEngine)&&
1566:                    //                !(this.m_engine instanceof ETClassDrawEngine)&&
1567:                    //                !(this.m_engine instanceof ETLabelDrawEngine))
1568:                    //            {
1569:                    //                this.m_engine.selectAllCompartments(false);
1570:                    //                this.m_engine.anchorMouseEvent(pEvent, this);
1571:                    //                this.invertSelected();
1572:                    //            }
1573:                }
1574:                return isHandled;
1575:            }
1576:
1577:            public boolean handleLeftMouseDrag(IETPoint pStartPos,
1578:                    IETPoint pCurrentPos) {
1579:                return false;
1580:            }
1581:
1582:            public boolean handleLeftMouseDrop(IETPoint pCurrentPos,
1583:                    List pElements, boolean bMoving) {
1584:                return false;
1585:            }
1586:
1587:            public boolean handleLeftMouseButtonPressed(MouseEvent pEvent) {
1588:                return isMouseInTextRect(pEvent, false);
1589:            }
1590:
1591:            public String getName() {
1592:                return this .m_name;
1593:            }
1594:
1595:            public void setName(String pNewName) {
1596:                this .m_name = pNewName;
1597:            }
1598:
1599:            public String getFontString() {
1600:                return m_fontString;
1601:            }
1602:
1603:            public void setFontString(String string) {
1604:                m_fontString = string;
1605:            }
1606:
1607:            // Returns the text for the stereotype compartment
1608:            public String getStereotypeText(IElement pElement) {
1609:                return pElement != null ? pElement
1610:                        .getAppliedStereotypesAsString(false) : null;
1611:            }
1612:
1613:            public void save() {
1614:                //editable compartment will handle it.
1615:            }
1616:
1617:            public void cancelEditing() {
1618:                //editable compartment will handle it.
1619:            }
1620:
1621:            /* (non-Javadoc)
1622:             * @see org.netbeans.modules.uml.ui.products.ad.compartments.IADEditableCompartment#setHorizontalAlignment(int)
1623:             */
1624:            public void setHorizontalAlignment(int alignment) {
1625:                m_HorizontalAlignment = alignment;
1626:            }
1627:
1628:            /* (non-Javadoc)
1629:             * @see org.netbeans.modules.uml.ui.products.ad.compartments.IADEditableCompartment#getHorizontalAlignment()
1630:             */
1631:            public int getHorizontalAlignment() {
1632:                return m_HorizontalAlignment;
1633:            }
1634:
1635:            /* (non-Javadoc)
1636:             * @see org.netbeans.modules.uml.ui.products.ad.compartments.IADEditableCompartment#setVerticalAlignment(int)
1637:             */
1638:            public void setVerticalAlignment(int alignment) {
1639:                m_VerticalAlignment = alignment;
1640:            }
1641:
1642:            /* (non-Javadoc)
1643:             * @see org.netbeans.modules.uml.ui.products.ad.compartments.IADEditableCompartment#getVerticalAlignment()
1644:             */
1645:            public int getVerticalAlignment() {
1646:                return m_VerticalAlignment;
1647:            }
1648:
1649:            /* (non-Javadoc)
1650:             * @see org.netbeans.modules.uml.ui.products.ad.compartments.IADNameCompartment#setNameCompartmentBorderKind(int)
1651:             */
1652:            public void setNameCompartmentBorderKind(int value) {
1653:                if (value >= 0
1654:                        && value <= IADNameCompartment.NCBK_DRAW_BORDER_TOTAL) {
1655:                    m_BorderKind = value;
1656:                }
1657:            }
1658:
1659:            /* (non-Javadoc)
1660:             * @see org.netbeans.modules.uml.ui.products.ad.compartments.IADNameCompartment#getNameCompartmentBorderKind()
1661:             */
1662:            public int getNameCompartmentBorderKind() {
1663:                return m_BorderKind;
1664:            }
1665:
1666:            /**
1667:             * Adds the interaction operand choices for the combined fragment.
1668:             *
1669:             * @param pContextMenu[in] The menu about to be displayed
1670:             */
1671:            public void addInteractionOperandButtons(IMenuManager manager) {
1672:                IMenuManager subMenu = manager.createOrGetSubMenu(
1673:                        loadString("IDS_POPUP_INTERACTION_OPERAND"), "");
1674:                if (subMenu != null) {
1675:                    subMenu.add(createMenuAction(
1676:                            loadString("IDS_CF_EDIT_INTERACTION_CONSTRAINT"),
1677:                            "MBK_CF_EDIT_INTERACTION_CONSTRAINT"));
1678:                }
1679:            }
1680:
1681:            /**
1682:             * Adds the interaction operands choices for the IADZonesCompartment.
1683:             *
1684:             * @param pContextMenu[in] The menu about to be displayed
1685:             */
1686:            protected void addInteractionOperandsButtons(IMenuManager manager) {
1687:                IMenuManager subMenu = manager.createOrGetSubMenu(
1688:                        loadString("IDS_POPUP_INTERACTION_OPERAND"), "");
1689:                if (subMenu != null) {
1690:                    subMenu.add(createMenuAction(
1691:                            loadString("IDS_CF_ADD_INTERACTION_OPERAND"),
1692:                            "MBK_Z_ADD_ROW"));
1693:                    subMenu.add(createMenuAction(
1694:                            loadString("IDS_CF_DELETE_INTERACTION_OPERAND"),
1695:                            "MBK_Z_DELETE_ROW"));
1696:                }
1697:            }
1698:
1699:            /**
1700:             * Adds the lifeline remove destroy element button.
1701:             *
1702:             * @param pContextMenu[in] The menu about to be displayed
1703:             */
1704:            public void addLifelineRemoveDestroyButton(IMenuManager manager) {
1705:                manager.add(createMenuAction(
1706:                        loadString("IDS_LL_REMOVE_DESTROY"),
1707:                        "MBK_LL_REMOVE_DESTROY"));
1708:            }
1709:
1710:            /**
1711:             * Adds the partions choices for the IADZonesCompartment.
1712:             *
1713:             * @param pContextMenu[in] The menu about to be displayed
1714:             */
1715:            void addActivityPartionsButtons(IMenuManager manager, int /*ORIENTATION*/
1716:            orientation) {
1717:                IMenuManager subMenu = manager.createOrGetSubMenu(
1718:                        loadString("IDS_POPUP_PARTITIONS"), "");
1719:                if (subMenu != null) {
1720:                    if (orientation != IETZoneDividers.DMO_HORIZONTAL) {
1721:                        subMenu.add(createMenuAction(
1722:                                loadString("IDS_PARTITION_ADD_COLUMN"),
1723:                                "MBK_Z_ADD_COLUMN"));
1724:                        if (orientation != IETZoneDividers.DMO_UNKNOWN) {
1725:                            subMenu.add(createMenuAction(
1726:                                    loadString("IDS_PARTITION_DELETE_COLUMN"),
1727:                                    "MBK_Z_DELETE_COLUMN"));
1728:                        }
1729:                    }
1730:
1731:                    addSeparatorMenuItem(subMenu);
1732:
1733:                    if (orientation != IETZoneDividers.DMO_VERTICAL) {
1734:                        subMenu.add(createMenuAction(
1735:                                loadString("IDS_PARTITION_ADD_ROW"),
1736:                                "MBK_Z_ADD_ROW"));
1737:                        if (orientation != IETZoneDividers.DMO_UNKNOWN) {
1738:                            subMenu.add(createMenuAction(
1739:                                    loadString("IDS_PARTITION_DELETE_ROW"),
1740:                                    "MBK_Z_DELETE_ROW"));
1741:                        }
1742:                    }
1743:
1744:                    // Add the ability to populate the partitions
1745:                    /* TODO
1746:                               // Add the ability to populate the partitions
1747:                               addSeparatorMenuItem( subMenu );
1748:                     
1749:                               subMenu.add(createMenuAction(loadString("IDS_POPULATE_THIS_PARTITION"), "MBK_POPULATE_THIS_Z"));
1750:                               subMenu.add(createMenuAction(loadString("IDS_POPULATE_ALL_PARTITIONS"), "MBK_POPULATE_ALL_ZS"));
1751:                     */
1752:                }
1753:            }
1754:
1755:            /**
1756:             * Adds the DELETE/delete buttons for state events and internal transitions
1757:             *
1758:             * @param pContextMenu[in] The menu about to be displayed
1759:             */
1760:            public void addStateEventsAndTransitionsButton(IMenuManager manager) {
1761:                IElement pElem = getDrawEngineModelElement();
1762:                if (pElem != null && pElem instanceof  IState) {
1763:                    IState pState = (IState) pElem;
1764:                    IProcedure pEntry = pState.getEntry();
1765:                    IProcedure pExit = pState.getExit();
1766:                    IProcedure pDoActivity = pState.getDoActivity();
1767:
1768:                    IMenuManager subMenu = manager.createOrGetSubMenu(
1769:                            loadString("IDS_POPUP_STATE_EVENTS"), "");
1770:                    if (subMenu != null) {
1771:                        if (pEntry == null) {
1772:                            subMenu.add(createMenuAction(
1773:                                    loadString("IDS_INSERT_ENTRY"),
1774:                                    "MBK_INSERT_ENTRY"));
1775:                        } else {
1776:                            subMenu.add(createMenuAction(
1777:                                    loadString("IDS_DELETE_ENTRY"),
1778:                                    "MBK_DELETE_ENTRY"));
1779:                        }
1780:
1781:                        if (pExit == null) {
1782:                            subMenu.add(createMenuAction(
1783:                                    loadString("IDS_INSERT_EXIT"),
1784:                                    "MBK_INSERT_EXIT"));
1785:                        } else {
1786:                            subMenu.add(createMenuAction(
1787:                                    loadString("IDS_DELETE_EXIT"),
1788:                                    "MBK_DELETE_EXIT"));
1789:                        }
1790:
1791:                        if (pDoActivity == null) {
1792:                            subMenu.add(createMenuAction(
1793:                                    loadString("IDS_INSERT_DOACTIVITY"),
1794:                                    "MBK_INSERT_DOACTIVITY"));
1795:                        } else {
1796:                            subMenu.add(createMenuAction(
1797:                                    loadString("IDS_DELETE_DOACTIVITY"),
1798:                                    "MBK_DELETE_DOACTIVITY"));
1799:                        }
1800:
1801:                        subMenu
1802:                                .add(createMenuAction(
1803:                                        loadString("IDS_INSERT_INCOMING_INTERNALTRANSITION"),
1804:                                        "MBK_INSERT_INCOMING_INTERNALTRANSITION"));
1805:                        subMenu
1806:                                .add(createMenuAction(
1807:                                        loadString("IDS_INSERT_OUTGOING_INTERNALTRANSITION"),
1808:                                        "MBK_INSERT_OUTGOING_INTERNALTRANSITION"));
1809:                        subMenu.add(createMenuAction(
1810:                                loadString("IDS_DELETE_INTERNALTRANSITION"),
1811:                                "MBK_DELETE_INTERNALTRANSITION"));
1812:                    }
1813:                }
1814:            }
1815:
1816:            /**
1817:             * Returns the model element attached to the draw engine this compartment is associated with
1818:             *
1819:             * @param pElement [out,retval] The IElement the draw engine is attached to.
1820:             */
1821:            public IElement getDrawEngineModelElement() {
1822:                return TypeConversions.getElement(m_engine);
1823:            }
1824:
1825:            /**
1826:             * Adds the interaction operator choices for the combined fragment.
1827:             *
1828:             * @param pContextMenu[in] The menu about to be displayed
1829:             */
1830:            public void addInteractionOperatorButtons(IMenuManager manager) {
1831:                IMenuManager subMenu = manager.createOrGetSubMenu(
1832:                        loadString("IDS_POPUP_INTERACTION_OPERATOR"), "");
1833:                if (subMenu != null) {
1834:                    subMenu.add(createMenuAction(loadString("IDS_CF_IO_ALT"),
1835:                            "MBK_CF_IO_ALT", BaseAction.AS_CHECK_BOX));
1836:                    subMenu.add(createMenuAction(
1837:                            loadString("IDS_CF_IO_ASSERT"), "MBK_CF_IO_ASSERT",
1838:                            BaseAction.AS_CHECK_BOX));
1839:                    subMenu.add(createMenuAction(loadString("IDS_CF_IO_ELSE"),
1840:                            "MBK_CF_IO_ELSE", BaseAction.AS_CHECK_BOX));
1841:                    subMenu.add(createMenuAction(loadString("IDS_CF_IO_LOOP"),
1842:                            "MBK_CF_IO_LOOP", BaseAction.AS_CHECK_BOX));
1843:                    subMenu.add(createMenuAction(loadString("IDS_CF_IO_NEG"),
1844:                            "MBK_CF_IO_NEG", BaseAction.AS_CHECK_BOX));
1845:                    subMenu.add(createMenuAction(loadString("IDS_CF_IO_OPT"),
1846:                            "MBK_CF_IO_OPT", BaseAction.AS_CHECK_BOX));
1847:                    subMenu.add(createMenuAction(loadString("IDS_CF_IO_PAR"),
1848:                            "MBK_CF_IO_PAR", BaseAction.AS_CHECK_BOX));
1849:                    subMenu.add(createMenuAction(
1850:                            loadString("IDS_CF_IO_REGION"), "MBK_CF_IO_REGION",
1851:                            BaseAction.AS_CHECK_BOX));
1852:                    subMenu.add(createMenuAction(loadString("IDS_CF_IO_SEQ"),
1853:                            "MBK_CF_IO_SEQ", BaseAction.AS_CHECK_BOX));
1854:                    subMenu.add(createMenuAction(
1855:                            loadString("IDS_CF_IO_STRICT"), "MBK_CF_IO_STRICT",
1856:                            BaseAction.AS_CHECK_BOX));
1857:                }
1858:            }
1859:
1860:            public String loadString(String key) {
1861:                try {
1862:                    return RESOURCE_BUNDLE.getString(key);
1863:                } catch (MissingResourceException e) {
1864:                    return '!' + key + '!';
1865:                }
1866:            }
1867:
1868:            public boolean containsPoint(Point p) {
1869:                ETDeviceRect rect = getBoundingAsDeviceRect();
1870:                return rect != null ? rect.contains(p) : false;
1871:            }
1872:
1873:            /**
1874:             * Force Tom Sawyer to redraw the entire draw engine's node
1875:             */
1876:            public void refresh() {
1877:                try {
1878:                    if (m_engine != null) {
1879:                        m_engine.invalidate();
1880:
1881:                        // Fix J1558:  The above invalidate() is not repainting the window when the user
1882:                        //             removes a destroy element from a lifeline.
1883:                        //             This fixes that problem, but was not needed in the C++ code.
1884:                        IDrawingAreaControl control = m_engine.getDrawingArea();
1885:                        if (control != null) {
1886:                            control.refresh(true);
1887:                        }
1888:                    }
1889:                } catch (Exception e) {
1890:                    e.printStackTrace();
1891:                }
1892:            }
1893:
1894:            /**
1895:             * Forces the GUI to repaint by invalidating the node and pumping messages.
1896:             */
1897:            public void redrawNow() {
1898:                if (m_engine != null) {
1899:                    m_engine.invalidate();
1900:                    IDrawingAreaControl drawingArea = m_engine.getDrawingArea();
1901:                    if (drawingArea != null) {
1902:                        // The C++ code calls refresh (which refreshs the entire diagram)
1903:                        // then pumps the messages to cause the events to occur.  I have
1904:                        // not been able to find out how to pump the messages in Java
1905:                        // Therefore, I am going to refresh the draw engine now.
1906:                        ADGraphWindow window = drawingArea.getGraphWindow();
1907:                        if (window != null) {
1908:                            window.updateInvalidRegions(true);
1909:                        }
1910:                    }
1911:                    pumpMessages();
1912:                }
1913:            }
1914:
1915:            /**
1916:             * Message pump.
1917:             */
1918:            public void pumpMessages() {
1919:                //to do implement
1920:            }
1921:
1922:            /**
1923:             * Make the drawing dirty
1924:             */
1925:            public void setIsDirty() {
1926:                if (m_engine != null) {
1927:                    m_engine.setIsDirty();
1928:                }
1929:            }
1930:
1931:            public boolean setSensitivityAndCheck(String id,
1932:                    ContextMenuActionClass pMenuAction) {
1933:                return false;
1934:            }
1935:
1936:            public boolean onHandleButton(ActionEvent e, String id) {
1937:                return false;
1938:            }
1939:
1940:            protected boolean isParentDiagramReadOnly() {
1941:                if (m_engine != null) {
1942:                    IDiagram pDiagram = m_engine.getDiagram();
1943:                    return pDiagram != null ? pDiagram.getReadOnly() : true;
1944:                }
1945:                return true;
1946:            }
1947:
1948:            public ContextMenuActionClass createMenuAction(String text,
1949:                    String menuID, int style) {
1950:                ContextMenuActionClass menu = new ContextMenuActionClass(this ,
1951:                        text, menuID);
1952:                if (menu != null) {
1953:                    menu.setStyle(style);
1954:                }
1955:
1956:                return menu;
1957:            }
1958:
1959:            public ContextMenuActionClass createMenuAction(String text,
1960:                    String menuID, String shortcut) {
1961:                ContextMenuActionClass menu = new ContextMenuActionClass(this ,
1962:                        text, menuID);
1963:                if (menu != null) {
1964:                    menu.putValue(Action.ACCELERATOR_KEY, KeyStroke
1965:                            .getKeyStroke(shortcut));
1966:                }
1967:
1968:                return menu;
1969:            }
1970:
1971:            public ContextMenuActionClass createMenuAction(String text,
1972:                    String menuID) {
1973:                return new ContextMenuActionClass(this , text, menuID);
1974:            }
1975:
1976:            // Resource user
1977:            public ETList<IDrawingProperty> getDrawingProperties() {
1978:                ETList<IDrawingProperty> pProperties = null;
1979:
1980:                IDrawEngine pDrawEngine = getEngine();
1981:                if (pDrawEngine != null) {
1982:                    String sDrawEngineID = pDrawEngine.getDrawEngineID();
1983:                    if (sDrawEngineID != null && sDrawEngineID.length() > 0) {
1984:                        pProperties = m_ResourceUser.getDrawingProperties(this ,
1985:                                sDrawEngineID);
1986:                    }
1987:                }
1988:
1989:                return pProperties;
1990:            }
1991:
1992:            public void saveColor(String sDrawEngineType, String sResourceName,
1993:                    int nColor) {
1994:                setIsDirty();
1995:                m_ResourceUser
1996:                        .saveColor(sDrawEngineType, sResourceName, nColor);
1997:            }
1998:
1999:            public void saveColor2(IColorProperty pProperty) {
2000:                setIsDirty();
2001:                m_ResourceUser.saveColor2(pProperty);
2002:            }
2003:
2004:            public void saveFont(String sDrawEngineName, String sResourceName,
2005:                    String sFaceName, int nHeight, int nWeight,
2006:                    boolean bItalic, int nColor) {
2007:                setIsDirty();
2008:                m_ResourceUser.saveFont(sDrawEngineName, sResourceName,
2009:                        sFaceName, nHeight, nWeight, bItalic, nColor);
2010:            }
2011:
2012:            public void saveFont2(IFontProperty pProperty) {
2013:                setIsDirty();
2014:                m_ResourceUser.saveFont2(pProperty);
2015:            }
2016:
2017:            public void resetToDefaultResource(String sDrawEngineName,
2018:                    String sResourceName, String sResourceType) {
2019:                setIsDirty();
2020:                m_ResourceUser.resetToDefaultResource(sDrawEngineName,
2021:                        sResourceName, sResourceType);
2022:                initResources();
2023:                invalidateProvider();
2024:            }
2025:
2026:            public void resetToDefaultResources() {
2027:                setIsDirty();
2028:                m_ResourceUser.resetToDefaultResources();
2029:            }
2030:
2031:            public void resetToDefaultResources2(String sDrawEngineName) {
2032:                // The draw engine should have handled this message and if we're inside of this
2033:                // kind of draw engine then it calls ResetToDefaultResources.
2034:            }
2035:
2036:            public void dumpToFile(String sFile, boolean bDumpChildren,
2037:                    boolean bAppendToExistingFile) {
2038:                m_ResourceUser.dumpToFile(sFile, bAppendToExistingFile);
2039:            }
2040:
2041:            public boolean displayFontDialog(IFontProperty pProperty) {
2042:                return m_ResourceUser.displayFontDialog(pProperty);
2043:            }
2044:
2045:            public boolean displayColorDialog(IColorProperty pProperty) {
2046:                return m_ResourceUser.displayColorDialog(pProperty);
2047:            }
2048:
2049:            public void invalidateProvider() {
2050:                getEngine().invalidate();
2051:            }
2052:
2053:            // IResourceUserHelper
2054:            public IDrawingAreaControl getDrawingArea() {
2055:                IDrawEngine pDrawEngine = getEngine();
2056:                return pDrawEngine != null ? pDrawEngine.getDrawingArea()
2057:                        : null;
2058:            }
2059:
2060:            public int getColorID(int nColorStringID) {
2061:                int nID = -1;
2062:
2063:                Integer iterator = m_ResourceUser.m_Colors.get(new Integer(
2064:                        nColorStringID));
2065:                if (iterator != null) {
2066:                    // Our color has been cached from the last time
2067:                    int nTempID = iterator.intValue();
2068:
2069:                    // Make sure the id is valid, if not then re-get a good
2070:                    // id from our draw engine.
2071:                    if (nTempID == -1
2072:                            || m_ResourceUser.getResourceMgr().isValidColorID(
2073:                                    nTempID) == false) {
2074:                        m_ResourceUser.m_Colors.remove(new Integer(
2075:                                nColorStringID));
2076:                    } else {
2077:                        nID = nTempID;
2078:                    }
2079:                }
2080:
2081:                // Get the color from the draw engine if necessary
2082:                if (nID == -1) {
2083:                    IDrawEngine pDrawEngine = getEngine();
2084:                    if (pDrawEngine != null) {
2085:                        // See if the draw engine has an override, go to the
2086:                        // diagram if necessary
2087:                        nID = ((IResourceUserHelper) pDrawEngine)
2088:                                .getColorID(nColorStringID);
2089:
2090:                        if (nID != -1) {
2091:                            m_ResourceUser.m_Colors.put(new Integer(
2092:                                    nColorStringID), new Integer(nID));
2093:                        }
2094:                    }
2095:                }
2096:                return nID;
2097:            }
2098:
2099:            public int getFontID(int nFontStringID) {
2100:                int nID = -1;
2101:
2102:                Integer iterator = m_ResourceUser.m_Fonts.get(new Integer(
2103:                        nFontStringID));
2104:                if (iterator != null) {
2105:                    // Our font has been cached from the last time
2106:                    int nTempID = iterator.intValue();
2107:
2108:                    // Make sure the id is valid, if not then re-get a good
2109:                    // id from our draw engine.
2110:                    if (nTempID == -1
2111:                            || m_ResourceUser.getResourceMgr().isValidFontID(
2112:                                    nTempID) == false) {
2113:                        m_ResourceUser.m_Fonts
2114:                                .remove(new Integer(nFontStringID));
2115:                    } else {
2116:                        nID = nTempID;
2117:                    }
2118:                }
2119:
2120:                // Get the font from the draw engine if necessary
2121:                if (nID == -1) {
2122:                    IDrawEngine pDrawEngine = getEngine();
2123:                    if (pDrawEngine != null) {
2124:                        // Else see if the draw engine has an override
2125:                        nID = ((IResourceUserHelper) pDrawEngine)
2126:                                .getFontID(nFontStringID);
2127:
2128:                        if (nID != -1) {
2129:                            m_ResourceUser.m_Fonts.put(new Integer(
2130:                                    nFontStringID), new Integer(nID));
2131:                        }
2132:                    }
2133:                }
2134:                return nID;
2135:            }
2136:
2137:            public boolean verifyDrawEngineStringID() {
2138:                boolean bIDOK = true;
2139:                if (m_ResourceUser.m_nDrawEngineStringID == -1) {
2140:                    IDrawEngine pEngine = getEngine();
2141:
2142:                    if (pEngine != null) {
2143:                        String sDrawEngineID = pEngine.getDrawEngineID();
2144:                        if (sDrawEngineID.length() > 0) {
2145:                            // Set the draw engine string id on the resource user
2146:                            m_ResourceUser.setDrawEngineStringID(sDrawEngineID);
2147:                            if (m_ResourceUser.m_nDrawEngineStringID == -1) {
2148:                                bIDOK = false;
2149:                            }
2150:                        }
2151:                    }
2152:                }
2153:
2154:                return bIDOK;
2155:            }
2156:
2157:            public int setResourceID(String resourceName, Color color) {
2158:                m_nNameFontStringID = m_ResourceUser.setResourceStringID(
2159:                        m_nNameFontStringID, resourceName, color.getRGB());
2160:                return m_nNameFontStringID;
2161:            }
2162:
2163:            public Font getCompartmentFont(double zoomLevel) {
2164:                return m_ResourceUser.getZoomedFontForStringID(
2165:                        m_nNameFontStringID, zoomLevel);
2166:            }
2167:
2168:            public Color getCompartmentFontColor() {
2169:                return new Color(m_ResourceUser
2170:                        .getCOLORREFForStringID(m_nNameFontStringID));
2171:            }
2172:
2173:            public void setDefaultColor(String resourceName, int colorRef) {
2174:                m_ResourceUser.setDefaultColor(resourceName, colorRef);
2175:            }
2176:
2177:            public void setDefaultColor(String resourceName, Color color) {
2178:                m_ResourceUser.setDefaultColor(resourceName, color.getRGB());
2179:            }
2180:
2181:            public CompartmentResourceUser getCompartmentResourceUser() {
2182:                return m_ResourceUser;
2183:            }
2184:
2185:            /**
2186:             * Helper function to determine the mouse location
2187:             * during the processing of a context menu.
2188:             */
2189:            protected TSConstPoint getLogicalMouseLocation(ActionEvent event) {
2190:                try {
2191:                    Point pointDevice = ((ContextMenuActionClass) ((javax.swing.JMenuItem) event
2192:                            .getSource()).getAction()).getMenuManager()
2193:                            .getLocation();
2194:                    return getTransform().pointToWorld(pointDevice);
2195:                } catch (Exception ex) {
2196:                }
2197:
2198:                return null;
2199:            }
2200:
2201:            protected void addSeparatorMenuItem(IMenuManager manager) {
2202:                manager.add(new Separator());
2203:            }
2204:
2205:            //   /**
2206:            //    * Sets the horizontal alignment property of the compartment.  Valid
2207:            //    * values are:
2208:            //    * <ul>
2209:            //    *    <li>IADEditableCompartment.LEFT</li>
2210:            //    *    <li>IADEditableCompartment.CENTER</li>
2211:            //    *    <li>IADEditableCompartment.RIGHT</li>
2212:            //    * </ul>
2213:            //    * @param alignment The horizonal alignment.
2214:            //    */
2215:            //   public void setHorizontalAlignment(int alignment)
2216:            //   {
2217:            //      long newStyle = m_style | ;
2218:            //   }
2219:            //
2220:            //   /**
2221:            //    * Retrieves the horizontal alignment property of the compartment.  Valid
2222:            //    * values are:
2223:            //    * <ul>
2224:            //    *    <li>IADEditableCompartment.LEFT</li>
2225:            //    *    <li>IADEditableCompartment.CENTER</li>
2226:            //    *    <li>IADEditableCompartment.RIGHT</li>
2227:            //    * </ul>
2228:            //    * @return The horizonal alignment.
2229:            //    */
2230:            //   public int getHorizontalAlignment()
2231:            //   {
2232:            //
2233:            //   }
2234:            //
2235:            //   /**
2236:            //    * Sets the vertical alignment property of the compartment.  Valid
2237:            //    * values are:
2238:            //    * <ul>
2239:            //    *    <li>IADEditableCompartment.TOP</li>
2240:            //    *    <li>IADEditableCompartment.CENTER</li>
2241:            //    *    <li>IADEditableCompartment.BOTTOM</li>
2242:            //    * </ul>
2243:            //    * @param alignment The vertical alignment.
2244:            //    */
2245:            //   public void setVerticalAlignment(int alignment)
2246:            //   {
2247:            //
2248:            //   }
2249:            //
2250:            //   /**
2251:            //    * Retrieves the vertical alignment property of the compartment.  Valid
2252:            //    * values are:
2253:            //    * <ul>
2254:            //    *    <li>IADEditableCompartment.TOP</li>
2255:            //    *    <li>IADEditableCompartment.CENTER</li>
2256:            //    *    <li>IADEditableCompartment.BOTTOM</li>
2257:            //    * </ul>
2258:            //    * @return The vertical alignment.
2259:            //    */
2260:            //   public int getVerticalAlignment()
2261:            //   {
2262:            //
2263:            //   }
2264:
2265:            /////////////
2266:            // Accessible
2267:            /////////////
2268:
2269:            AccessibleContext accessibleContext;
2270:
2271:            public AccessibleContext getAccessibleContext() {
2272:                if (accessibleContext == null) {
2273:                    accessibleContext = new AccessibleETCompartment();
2274:                }
2275:                return accessibleContext;
2276:            }
2277:
2278:            public class AccessibleETCompartment extends AccessibleContext
2279:                    implements  AccessibleComponent {
2280:
2281:                ////////////////////
2282:                // AccessibleContext
2283:                ////////////////////
2284:
2285:                public AccessibleStateSet getAccessibleStateSet() {
2286:                    return new AccessibleStateSet(
2287:                            new AccessibleState[] { AccessibleState.SHOWING,
2288:                                    AccessibleState.VISIBLE,
2289:                                    AccessibleState.ENABLED,
2290:                                    AccessibleState.FOCUSABLE });
2291:                }
2292:
2293:                public String getAccessibleName() {
2294:                    return getName();
2295:                }
2296:
2297:                public String getAccessibleDescription() {
2298:                    return getAccessibleName();
2299:                }
2300:
2301:                public AccessibleRole getAccessibleRole() {
2302:                    return AccessibleRole.UNKNOWN;
2303:                }
2304:
2305:                public int getAccessibleChildrenCount() {
2306:                    return 0;
2307:                }
2308:
2309:                public Accessible getAccessibleChild(int i) {
2310:                    return null;
2311:                }
2312:
2313:                public int getAccessibleIndexInParent() {
2314:                    return 0;
2315:                }
2316:
2317:                public Locale getLocale() {
2318:                    return getGraphWindow().getLocale();
2319:                }
2320:
2321:                public AccessibleComponent getAccessibleComponent() {
2322:                    return this ;
2323:                }
2324:
2325:                ////////////////////////////////
2326:                // interface AccessibleComponent
2327:                ////////////////////////////////
2328:
2329:                public java.awt.Color getBackground() {
2330:                    return null;
2331:                }
2332:
2333:                public void setBackground(java.awt.Color color) {
2334:                    ;
2335:                }
2336:
2337:                public java.awt.Color getForeground() {
2338:                    return null;
2339:                }
2340:
2341:                public void setForeground(java.awt.Color color) {
2342:                    ;
2343:                }
2344:
2345:                public java.awt.Cursor getCursor() {
2346:                    return null;
2347:                }
2348:
2349:                public void setCursor(java.awt.Cursor cursor) {
2350:                    ;
2351:                }
2352:
2353:                public java.awt.Font getFont() {
2354:                    return null;
2355:                }
2356:
2357:                public void setFont(java.awt.Font font) {
2358:                    ;
2359:                }
2360:
2361:                public java.awt.FontMetrics getFontMetrics(java.awt.Font font) {
2362:                    return null;
2363:                }
2364:
2365:                public boolean isEnabled() {
2366:                    return true;
2367:                }
2368:
2369:                public void setEnabled(boolean enabled) {
2370:
2371:                }
2372:
2373:                public boolean isVisible() {
2374:                    return true;
2375:                }
2376:
2377:                public void setVisible(boolean visible) {
2378:                    ;
2379:                }
2380:
2381:                public boolean isShowing() {
2382:                    return true;
2383:                }
2384:
2385:                public boolean contains(java.awt.Point point) {
2386:                    Rectangle r = getBounds();
2387:                    return r.contains(point);
2388:                }
2389:
2390:                public java.awt.Point getLocationOnScreen() {
2391:                    IETRect scRect = getWinScreenRect();
2392:                    if (scRect != null) {
2393:                        return new java.awt.Point(scRect.getIntX(), scRect
2394:                                .getIntY());
2395:                    }
2396:                    return null;
2397:                }
2398:
2399:                // wrt parent
2400:                public java.awt.Point getLocation() {
2401:                    AccessibleComponent parentComponent = accessibleParent
2402:                            .getAccessibleContext().getAccessibleComponent();
2403:                    if (parentComponent != null) {
2404:                        java.awt.Point parentLocation = parentComponent
2405:                                .getLocationOnScreen();
2406:                        java.awt.Point componentLocation = getLocationOnScreen();
2407:                        if (parentLocation != null && componentLocation != null) {
2408:                            return new java.awt.Point(parentLocation.x
2409:                                    - componentLocation.x, parentLocation.y
2410:                                    - componentLocation.y);
2411:                        }
2412:                    }
2413:                    return null;
2414:                }
2415:
2416:                // wrt parent
2417:                public void setLocation(java.awt.Point point) {
2418:                    ;
2419:                }
2420:
2421:                // wrt parent
2422:                public java.awt.Rectangle getBounds() {
2423:                    IETRect clientRect = getWinClientRect();
2424:                    java.awt.Point loc = getLocation();
2425:                    if (clientRect != null && loc != null) {
2426:                        return new Rectangle(loc.x, loc.y, clientRect
2427:                                .getIntWidth(), clientRect.getIntHeight());
2428:                    }
2429:                    return null;
2430:                }
2431:
2432:                public void setBounds(java.awt.Rectangle bounds) {
2433:                    //setWinClientRectangle(new ETRect());
2434:                }
2435:
2436:                public java.awt.Dimension getSize() {
2437:                    Rectangle r = getBounds();
2438:                    return new Dimension(r.width, r.height);
2439:                }
2440:
2441:                public void setSize(java.awt.Dimension dim) {
2442:                    setScaledSize(new ETSize(dim.width, dim.height));
2443:                }
2444:
2445:                public javax.accessibility.Accessible getAccessibleAt(
2446:                        java.awt.Point point) {
2447:                    return null;
2448:                }
2449:
2450:                public boolean isFocusTraversable() {
2451:                    return true;
2452:                }
2453:
2454:                public void requestFocus() {
2455:                    ;
2456:                }
2457:
2458:                public void addFocusListener(
2459:                        java.awt.event.FocusListener listener) {
2460:                    ;
2461:                }
2462:
2463:                public void removeFocusListener(
2464:                        java.awt.event.FocusListener listener) {
2465:                    ;
2466:                }
2467:
2468:            }
2469:
2470:        }
ww___w_.__ja_v_a_2s___.c___o___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.