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.drawengines;
0043:
0044: import java.awt.Color;
0045: import java.awt.Dimension;
0046: import java.awt.Font;
0047: import java.awt.Rectangle;
0048: import java.awt.event.ActionEvent;
0049: import java.awt.event.KeyEvent;
0050: import java.awt.event.MouseEvent;
0051: import java.util.ArrayList;
0052: import java.util.Iterator;
0053: import java.util.List;
0054: import java.util.Locale;
0055: import java.util.MissingResourceException;
0056: import java.util.ResourceBundle;
0057: import javax.swing.SwingUtilities;
0058: import javax.accessibility.Accessible;
0059: import javax.accessibility.AccessibleContext;
0060: import javax.accessibility.AccessibleComponent;
0061: import javax.accessibility.AccessibleRelation;
0062: import javax.accessibility.AccessibleRelationSet;
0063: import javax.accessibility.AccessibleRole;
0064: import javax.accessibility.AccessibleSelection;
0065: import javax.accessibility.AccessibleState;
0066: import javax.accessibility.AccessibleStateSet;
0067: import org.netbeans.modules.uml.common.ETException;
0068: import org.netbeans.modules.uml.common.generics.IteratorT;
0069: import org.netbeans.modules.uml.core.metamodel.core.foundation.IElement;
0070: import org.netbeans.modules.uml.core.metamodel.core.foundation.INamedElement;
0071: import org.netbeans.modules.uml.core.metamodel.core.foundation.IPresentationElement;
0072: import org.netbeans.modules.uml.core.metamodel.core.foundation.ITaggedValue;
0073: import org.netbeans.modules.uml.core.metamodel.diagrams.IDiagram;
0074: import org.netbeans.modules.uml.core.metamodel.diagrams.IGraphEventKind;
0075: import org.netbeans.modules.uml.core.metamodel.infrastructure.coreinfrastructure.IClassifier;
0076: import org.netbeans.modules.uml.core.support.umlsupport.ETPoint;
0077: import org.netbeans.modules.uml.core.support.umlsupport.ETRect;
0078: import org.netbeans.modules.uml.core.support.umlsupport.ETSize;
0079: import org.netbeans.modules.uml.core.support.umlsupport.IETPoint;
0080: import org.netbeans.modules.uml.core.support.umlsupport.IETRect;
0081: import org.netbeans.modules.uml.core.support.umlsupport.IETSize;
0082: import org.netbeans.modules.uml.core.support.umlutils.ETArrayList;
0083: import org.netbeans.modules.uml.core.support.umlutils.ETList;
0084: import org.netbeans.modules.uml.ui.products.ad.application.IMenuManager;
0085: import org.netbeans.modules.uml.ui.products.ad.application.action.ContextMenuActionClass;
0086: import org.netbeans.modules.uml.ui.products.ad.application.action.IETContextMenuHandler;
0087: import org.netbeans.modules.uml.ui.products.ad.compartments.ETListCompartment;
0088: import org.netbeans.modules.uml.ui.products.ad.compartments.IADCommentBodyCompartment;
0089: import org.netbeans.modules.uml.ui.products.ad.compartments.IADExpressionCompartment;
0090: import org.netbeans.modules.uml.ui.products.ad.compartments.ITemplateParametersCompartment;
0091: import org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI;
0092: import org.netbeans.modules.uml.ui.support.CreationFactoryHelper;
0093: import org.netbeans.modules.uml.ui.support.DiagramAndPresentationNavigator;
0094: import org.netbeans.modules.uml.ui.support.IDiagramAndPresentationNavigator;
0095: import org.netbeans.modules.uml.ui.support.accessibility.AccessibleSelectionParent;
0096: import org.netbeans.modules.uml.ui.support.applicationmanager.DrawingFactory;
0097: import org.netbeans.modules.uml.ui.support.applicationmanager.IGraphPresentation;
0098: import org.netbeans.modules.uml.ui.support.archivesupport.IProductArchive;
0099: import org.netbeans.modules.uml.ui.support.archivesupport.IProductArchiveDefinitions;
0100: import org.netbeans.modules.uml.ui.support.archivesupport.IProductArchiveElement;
0101: import org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenu;
0102: import org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenuItem;
0103: import org.netbeans.modules.uml.ui.support.drawingproperties.IColorProperty;
0104: import org.netbeans.modules.uml.ui.support.drawingproperties.IDrawingPropertyProvider;
0105: import org.netbeans.modules.uml.ui.support.drawingproperties.IFontProperty;
0106: import org.netbeans.modules.uml.ui.support.umltsconversions.RectConversions;
0107: import org.netbeans.modules.uml.ui.support.viewfactorysupport.ETRectEx;
0108: import org.netbeans.modules.uml.ui.support.viewfactorysupport.ETTransformOwner;
0109: import org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment;
0110: import org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine;
0111: import org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawInfo;
0112: import org.netbeans.modules.uml.ui.support.viewfactorysupport.IETGraphObject;
0113: import org.netbeans.modules.uml.ui.support.viewfactorysupport.IETLabel;
0114: import org.netbeans.modules.uml.ui.support.viewfactorysupport.IEventManager;
0115: import org.netbeans.modules.uml.ui.support.viewfactorysupport.IGraphObjectManager;
0116: import org.netbeans.modules.uml.ui.support.viewfactorysupport.ILabelManager;
0117: import org.netbeans.modules.uml.ui.support.viewfactorysupport.IListCompartment;
0118: import org.netbeans.modules.uml.ui.support.viewfactorysupport.INotificationTargets;
0119: import org.netbeans.modules.uml.ui.support.viewfactorysupport.IResourceUserHelper;
0120: import org.netbeans.modules.uml.ui.support.viewfactorysupport.ISetCursorEvent;
0121: import org.netbeans.modules.uml.ui.support.viewfactorysupport.ISimpleListCompartment;
0122: import org.netbeans.modules.uml.ui.support.viewfactorysupport.ITSGraphObject;
0123: import org.netbeans.modules.uml.ui.support.viewfactorysupport.IToolTipData;
0124: import org.netbeans.modules.uml.ui.support.viewfactorysupport.DrawEngineResourceUser;
0125: import org.netbeans.modules.uml.ui.support.viewfactorysupport.TSLabelKind;
0126: import org.netbeans.modules.uml.ui.support.viewfactorysupport.TypeConversions;
0127: import org.netbeans.modules.uml.ui.swing.drawingarea.ADGraphWindow;
0128: import org.netbeans.modules.uml.ui.swing.drawingarea.IDrawingAreaControl;
0129: import org.netbeans.modules.uml.ui.swing.drawingarea.diagramtools.SmartDragTool;
0130: import org.netbeans.modules.uml.ui.support.viewfactorysupport.UIResources;
0131: import org.netbeans.modules.uml.ui.support.drawingproperties.IDrawingProperty;
0132: import org.netbeans.modules.uml.ui.support.helpers.ETSmartWaitCursor;
0133: import com.tomsawyer.editor.TSEGraph;
0134: import com.tomsawyer.editor.TSEObject;
0135: import com.tomsawyer.graph.TSGraphObject;
0136: import com.tomsawyer.drawing.geometry.TSConstPoint;
0137: import com.tomsawyer.editor.TSTransform;
0138: import java.util.StringTokenizer;
0139: import org.openide.explorer.ExplorerManager;
0140: import org.openide.windows.TopComponent;
0141: import org.openide.windows.WindowManager;
0142: import org.netbeans.modules.uml.ui.swing.testbed.addin.menu.Separator;
0143:
0144: /*
0145: * Common base class for all drawEngines.
0146: */
0147: public abstract class ETDrawEngine extends ETTransformOwner implements
0148: IDrawEngine, IETContextMenuHandler, IDrawingPropertyProvider,
0149: IResourceUserHelper, Accessible {
0150: protected DrawEngineResourceUser m_ResourceUser = new DrawEngineResourceUser(
0151: (IResourceUserHelper) this );
0152:
0153: public static int TSE_NODE_RESIZE_ORIGINAL = 0;
0154: public static int TSE_NODE_RESIZE_ORIG_INTERACTIVE = 1;
0155:
0156: public static final int MK_LABELMANAGER = 0;
0157: public static final int MK_BRIDGEMANAGER = 1;
0158: public static final int MK_EVENTMANAGER = 2;
0159:
0160: /// Container variables
0161: boolean m_bFindNewContainer = true; /// set to true to get the container to be recalculated
0162: boolean m_bActiveLayout = false; /// true during layout operations: move, resize, layout
0163: IDrawEngine m_containerDE = null;
0164:
0165: private static final String BUNDLE_NAME = "org.netbeans.modules.uml.ui.products.ad.diagramengines.Bundle"; //$NON-NLS-1$
0166: private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
0167: .getBundle(BUNDLE_NAME);
0168: private IETGraphObjectUI m_parentUI;
0169: private boolean m_bInitResources = false;
0170: protected ICompartment m_anchoredCompartment;
0171: protected ICompartment m_defaultCompartment;
0172: protected int m_LastResizeOriginator = TSE_NODE_RESIZE_ORIGINAL;
0173:
0174: /// mouse anchor position
0175:
0176: /// All the compartments this draw engine owns
0177: private ETList<ICompartment> m_compartments = new ETArrayList<ICompartment>();
0178:
0179: // /// This is the root of the typeproxy hierarchy. This allows us to get back to the COM interface
0180: // ImpHolder* m_COMInterface;
0181:
0182: protected boolean m_readOnly;
0183:
0184: // TSENodeResizeOriginator m_LastResizeOriginator;
0185:
0186: /// This is the guy that managers the labels for this node or edge
0187: protected ILabelManager m_LabelManager;
0188:
0189: /// This is the guy that managers the edges for this node
0190: protected IEventManager m_EventManager;
0191:
0192: /// Should we check sync state when drawing. This is set to true after create or attach.
0193: protected boolean m_checkSyncStateDuringDraw;
0194:
0195: private UIResources m_resources = null;
0196: private int compIndex = -1;
0197:
0198: /*
0199: * Derived classes must implement this if no element is present.
0200: */
0201: public String getElementType() {
0202: IETGraphObjectUI ui = getUI();
0203: return ui != null && ui.getModelElement() != null ? ui
0204: .getModelElement().getElementType() : null;
0205: }
0206:
0207: // **************************************************
0208: // Compartment Management
0209: //**************************************************
0210:
0211: public ETList<ICompartment> getCompartments() {
0212: return m_compartments;
0213: }
0214:
0215: /*
0216: * Adds a compartment to the end of the compartments list.
0217: */
0218: public void addCompartment(ICompartment pCompartment) {
0219: getCompartments().add(pCompartment);
0220: }
0221:
0222: /*
0223: * (non-Javadoc)
0224: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#addCompartment(org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment, int)
0225: */
0226: public void addCompartment(ICompartment pCompartment, int nPos) {
0227: if (pCompartment != null) {
0228: pCompartment.setVisible(true);
0229: pCompartment.setEngine(this );
0230: //pCompartment.addModelElement(m_parentUI.getModelElement(), -1);
0231:
0232: if (nPos >= 0) {
0233: this .m_compartments.add(nPos, pCompartment);
0234: } else {
0235: m_compartments.add(pCompartment);
0236: }
0237: }
0238: }
0239:
0240: /**
0241: * Creates and adds the compartment to our drawengine. The new compartment
0242: * is appended to the end of the compartment list.
0243: *
0244: * @param sCompartmentID The compartment class name. A new compartment of
0245: * this type will be created. ie ArrowheadCompartment
0246: * @return The newly created ICompartment.
0247: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#createAndAddCompartment(java.lang.String, org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment, int)
0248: */
0249: public ICompartment createAndAddCompartment(String sCompartmentID) {
0250: return createAndAddCompartment(sCompartmentID, -1);
0251: }
0252:
0253: /**
0254: * Creates and adds the compartment to our drawengine.
0255: *
0256: * @param sCompartmentID The compartment class name. A new compartment of
0257: * this type will be created. ie ArrowheadCompartment
0258: * @param nPosThe Zero-based position within the list to insert the new
0259: * compartment. If -1 the compartment is inserted at the end
0260: * of the list, the list is scrolled if necessary.
0261: * @return The newly created ICompartment.
0262: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#createAndAddCompartment(java.lang.String, org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment, int)
0263: */
0264: public ICompartment createAndAddCompartment(String sCompartmentID,
0265: int nPos) {
0266: if (sCompartmentID != null && sCompartmentID.length() > 0) {
0267: ICompartment compartment = CreationFactoryHelper
0268: .createCompartment(sCompartmentID);
0269:
0270: if (compartment != null) {
0271: compartment.setEngine(this );
0272: addCompartment(compartment, nPos);
0273: compartment.initResources();
0274: }
0275: return compartment;
0276: }
0277:
0278: return null;
0279: }
0280:
0281: /**
0282: * Create and initalizes all compartments. This is an empty method. It
0283: * must be implemented by derivied classes to do anything useful.
0284: *
0285: * @throws ETException
0286: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#createCompartments()
0287: */
0288: public void createCompartments() throws ETException {
0289: }
0290:
0291: public void clearCompartments() {
0292: if (m_compartments != null)
0293: this .m_compartments.clear();
0294: }
0295:
0296: /**
0297: * Remove this compartment to this list, optionally deletes its model element.
0298: * The compartments model element will not be removed from the active model.
0299: * @param pCompartment The compartment to remove
0300: * @see #removeCompartment(ICompartment, boolean)
0301: */
0302: public void removeCompartment(ICompartment compartment) {
0303: removeCompartment(compartment, false);
0304: }
0305:
0306: /**
0307: * Remove this compartment to this list, optionally deletes its model element.
0308: *
0309: * @param pCompartment The compartment to remove
0310: * @param bDeleteElement Indicates whether the compartment's model element
0311: * should be removed from the active model. By default
0312: * this flag is FALSE. If the model is unable to
0313: * delete the element the compartment is removed
0314: * anyway. Not used in DrawEngineImpl - used in list
0315: * compartments.
0316: */
0317: public void removeCompartment(ICompartment compartment,
0318: boolean deleteElement) {
0319: if (compartment != null) {
0320: List compartments = getCompartments();
0321:
0322: int index = compartments != null ? compartments
0323: .indexOf(compartment) : -1;
0324: if (index >= 0) {
0325: compartment.setCollapsed(true);
0326: compartments.remove(index);
0327: }
0328: }
0329: }
0330:
0331: /**
0332: * Clears our list of visible compartments.
0333: */
0334: public void clearVisibleCompartments() {
0335: ETList<ICompartment> compartments = getCompartments();
0336: if (compartments != null) {
0337: for (Iterator<ICompartment> iter = compartments.iterator(); iter
0338: .hasNext();) {
0339: ICompartment curCompartment = iter.next();
0340: if (curCompartment != null) {
0341: curCompartment.setVisible(false);
0342: }
0343: }
0344: }
0345: }
0346:
0347: /**
0348: * Adds a compartment to the end of our list of visible compartments.
0349: *
0350: * @param compartment The compartment to be made visible
0351: */
0352: public void addVisibleCompartment(ICompartment compartment) {
0353: if (compartment != null) {
0354: compartment.setVisible(true);
0355: }
0356: }
0357:
0358: /**
0359: * Returns the number of compartments.
0360: *
0361: * @return The number of compartments
0362: */
0363: public int getNumCompartments() {
0364: return m_compartments.size();
0365: }
0366:
0367: public int getNumVisibleCompartments() {
0368:
0369: int visComps = 0;
0370: Iterator<ICompartment> iterator = this .getCompartments()
0371: .iterator();
0372: while (iterator.hasNext()) {
0373: if (iterator.next().getVisible()) {
0374: visComps++;
0375: }
0376: }
0377: return visComps;
0378: }
0379:
0380: /**
0381: * There are two categories of compartments. The first category
0382: * is the visible components, which are the top level compartments
0383: * that are owned by the draw engine. The visible compartments does
0384: * not include children of the top level compartments. This is usally
0385: * what we want getNumSelectableCompartments to return. For example
0386: * the class node uses Shift-Arrow keys to navigate through the
0387: * name list compartment, attribute , and operation compartments. The
0388: * user can then use Up/Down keys to cycle through elements in these compartment lists.
0389: */
0390: protected int getNumSelectableCompartments() {
0391: return getNumVisibleCompartments();
0392: }
0393:
0394: protected ICompartment getSelectableCompartment(int index) {
0395: return getVisibleCompartment(index);
0396: }
0397:
0398: /**
0399: * Returns the compartment at the argument index.
0400: *
0401: * @param index The index into the list of the draw engines compartments
0402: * @return The compartment at this index, otherwise null
0403: */
0404: public ICompartment getCompartment(int index) {
0405: return m_compartments.size() > index ? (ICompartment) m_compartments
0406: .get(index)
0407: : null;
0408: }
0409:
0410: /**
0411: * Does this draw engine have selected compartments.
0412: *
0413: * @return <code>true</code> if this draw engine has selected compartments
0414: */
0415: public boolean hasSelectedCompartments() {
0416: if (this .getNumCompartments() == 0)
0417: return false;
0418:
0419: Iterator<ICompartment> iterator = this .getCompartments()
0420: .iterator();
0421: while (iterator.hasNext()) {
0422: ICompartment currObject = iterator.next();
0423: if (currObject instanceof ISimpleListCompartment) {
0424: ISimpleListCompartment listCompartment = (ISimpleListCompartment) currObject;
0425:
0426: Iterator<ICompartment> compartmentIterator = listCompartment
0427: .getCompartments().iterator();
0428: while (compartmentIterator.hasNext()) {
0429: ICompartment foundCompartment = compartmentIterator
0430: .next();
0431: if (foundCompartment.isSelected()) {
0432: return true;
0433: }
0434: }
0435: }
0436: }
0437:
0438: return false;
0439: }
0440:
0441: public void selectAllCompartments(boolean bSelected) {
0442: if (this .getNumCompartments() == 0)
0443: return;
0444:
0445: Iterator iterator = this .getCompartments().iterator();
0446: while (iterator.hasNext()) {
0447: Object curObject = iterator.next();
0448: // set selection state for self first
0449: if (curObject instanceof ICompartment) {
0450: ((ICompartment) curObject).setSelected(bSelected);
0451: }
0452: //set selection state for sub compartments if any
0453: if (curObject instanceof ISimpleListCompartment) {
0454: ISimpleListCompartment compartment = (ISimpleListCompartment) curObject;
0455: Iterator<ICompartment> compartmentIterator = compartment
0456: .getCompartments().iterator();
0457: while (compartmentIterator.hasNext()) {
0458: ICompartment foundCompartment = compartmentIterator
0459: .next();
0460: //for zonecompartments you have to go two levels deep...
0461: if (foundCompartment instanceof ISimpleListCompartment) {
0462: ISimpleListCompartment foundListComp = (ISimpleListCompartment) foundCompartment;
0463: Iterator<ICompartment> foundCompIter = foundListComp
0464: .getCompartments().iterator();
0465: while (foundCompIter.hasNext()) {
0466: ICompartment newFoundComp = foundCompIter
0467: .next();
0468: if (newFoundComp != null) {
0469: newFoundComp.setSelected(bSelected);
0470: }
0471: }
0472: } else {
0473: foundCompartment.setSelected(bSelected);
0474: }
0475: }
0476: } else if (curObject instanceof IADExpressionCompartment) {
0477: ((IADExpressionCompartment) curObject)
0478: .setSelected(bSelected);
0479: }
0480: }
0481: }
0482:
0483: /*
0484: * (non-Javadoc)
0485: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getSelectedCompartments()
0486: */
0487: public ETList<ICompartment> getSelectedCompartments() {
0488: if (this .getNumCompartments() == 0)
0489: return null;
0490:
0491: ETList<ICompartment> selectedCompartments = new ETArrayList<ICompartment>();
0492: Iterator iterator = this .getCompartments().iterator();
0493: while (iterator.hasNext()) {
0494: Object currObject = iterator.next();
0495: if (currObject instanceof ISimpleListCompartment) {
0496: ISimpleListCompartment listCompartment = (ISimpleListCompartment) currObject;
0497:
0498: Iterator<ICompartment> compartmentIterator = listCompartment
0499: .getCompartments().iterator();
0500: while (compartmentIterator.hasNext()) {
0501: ICompartment foundCompartment = compartmentIterator
0502: .next();
0503: //for zonecompartments you have to go two levels deep...
0504: if (foundCompartment instanceof ISimpleListCompartment) {
0505: ISimpleListCompartment foundListComp = (ISimpleListCompartment) foundCompartment;
0506: Iterator<ICompartment> foundCompIter = foundListComp
0507: .getCompartments().iterator();
0508: while (foundCompIter.hasNext()) {
0509: ICompartment newFoundComp = foundCompIter
0510: .next();
0511: if (newFoundComp.isSelected()) {
0512: selectedCompartments.add(newFoundComp);
0513: }
0514: }
0515: } else if (foundCompartment.isSelected()) {
0516: selectedCompartments.add(foundCompartment);
0517: }
0518: }
0519: } else if (currObject instanceof IADCommentBodyCompartment) {
0520: selectedCompartments
0521: .add((IADCommentBodyCompartment) currObject);
0522: } else if (currObject instanceof IADExpressionCompartment) {
0523: if (((IADExpressionCompartment) currObject)
0524: .isSelected())
0525: selectedCompartments
0526: .add((IADExpressionCompartment) currObject);
0527: }
0528: }
0529: return selectedCompartments;
0530: }
0531:
0532: /*
0533: * (non-Javadoc)
0534: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getCompartmentAtPoint(org.netbeans.modules.uml.core.support.umlsupport.IETPoint)
0535: */
0536: public ICompartment getCompartmentAtPoint(IETPoint pCurrentPos) {
0537: Iterator iterator = this .getCompartments().iterator();
0538: while (iterator.hasNext()) {
0539: Object curObject = iterator.next();
0540: if (curObject instanceof IListCompartment) {
0541: IListCompartment listCompartment = (IListCompartment) curObject;
0542:
0543: Iterator<ICompartment> compartmentIterator = listCompartment
0544: .getCompartments().iterator();
0545: while (compartmentIterator.hasNext()) {
0546: ICompartment foundCompartment = compartmentIterator
0547: .next();
0548: if (foundCompartment
0549: .isPointInCompartment(pCurrentPos)) {
0550: return foundCompartment;
0551: }
0552: }
0553: }
0554: }
0555:
0556: return null;
0557: }
0558:
0559: /*
0560: * Returns the Init string.
0561: */
0562: protected String getInitializationString() {
0563: IETGraphObjectUI parentUI = (IETGraphObjectUI) this .getParent();
0564: return parentUI != null ? parentUI.getInitStringValue() : null;
0565: }
0566:
0567: /* (non-Javadoc)
0568: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#affectModelElementDeletion()
0569: */
0570: //Jyothi: modified this method to fix java.lang.IllegalStateException: Assertion failed. WindowsAPI is required to be called from AWT thread only
0571: // There a few NetBeans methods that require you to be in the AWT thread before you can execute the method.
0572: //WindowManager.getDefault().findTopComponent("projectTabLogical_tc") must be one of them.. so putting it in an awt thread.
0573: public void affectModelElementDeletion() {
0574: final IElement element1 = getFirstModelElement();
0575: if (element1 != null) {
0576:
0577: // workaround for #6286600
0578: if (element1 instanceof IClassifier) {
0579:
0580: SwingUtilities.invokeLater(new Runnable() {
0581: public void run() {
0582: checkSelectedNodes((IClassifier) element1);
0583: }
0584: });
0585: }
0586: element1.delete();
0587: }
0588: }
0589:
0590: private void checkSelectedNodes(IClassifier element) {
0591: TopComponent tc = WindowManager.getDefault().findTopComponent(
0592: "projectTabLogical_tc");
0593: if (tc != null && (tc instanceof ExplorerManager.Provider)) {
0594: ExplorerManager em = ((ExplorerManager.Provider) tc)
0595: .getExplorerManager();
0596: org.openide.nodes.Node[] nodes = em.getSelectedNodes();
0597: ArrayList list = new ArrayList(nodes.length);
0598:
0599: String qName = element.getQualifiedName();
0600: StringBuffer sf = new StringBuffer();
0601: StringTokenizer st = new StringTokenizer(qName, "::"); // NOI18N
0602: while (st.hasMoreTokens()) {
0603: String str = st.nextToken();
0604: if (st.hasMoreTokens()) {
0605: sf.append(str);
0606: sf.append('.');
0607: }
0608: }
0609: String pkgName = sf.toString();
0610: if (pkgName.length() > 0) {
0611: pkgName = pkgName.substring(0, pkgName.length() - 1);
0612: }
0613:
0614: String clsName = element.getName();
0615: /* NB60TBD
0616: org.openide.src.Identifier clsIdent = org.openide.src.Identifier.create(clsName, clsName);
0617: for (int x = 0; x < nodes.length; x++) {
0618: if (!isUnderClass(pkgName, clsIdent, nodes[x])) {
0619: list.add(nodes[x]);
0620: }
0621: }
0622: */
0623: try {
0624: em
0625: .setSelectedNodes((org.openide.nodes.Node[]) list
0626: .toArray(new org.openide.nodes.Node[list
0627: .size()]));
0628: } catch (java.beans.PropertyVetoException e) {
0629: }
0630: }
0631: }
0632:
0633: /* NB60TBD
0634: private boolean isUnderClass(String pkgName, org.openide.src.Identifier clsName, org.openide.nodes.Node node) {
0635: SourceCookie cookie = null;
0636: while (node != null && cookie == null) {
0637: cookie = (SourceCookie)node.getCookie(SourceCookie.class);
0638: if (cookie == null) {
0639: node = node.getParentNode();
0640: }
0641: }
0642: if (cookie != null) {
0643: SourceElement src = cookie.getSource();
0644: if (src != null) {
0645: org.openide.src.Identifier pkgId = src.getPackage();
0646: String elPkgName = pkgId != null ? pkgId.getFullName() : ""; // NOI18N
0647: return pkgName.equals(elPkgName) && (src.getClass(clsName) != null);
0648: }
0649: }
0650: return false;
0651: }
0652: */
0653:
0654: /* (non-Javadoc)
0655: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#anchorMouseEvent(org.netbeans.modules.uml.ui.support.viewfactorysupport.IMouseEvent, org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment)
0656: */
0657: public long anchorMouseEvent(MouseEvent pMouseEvent,
0658: ICompartment pCompartment) {
0659: // TODO Auto-generated method stub
0660: return 0;
0661: }
0662:
0663: /* (non-Javadoc)
0664: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#calculateOptimumSize(int, int, int, boolean)
0665: */
0666: public IETSize calculateOptimumSize(IDrawInfo pDrawInfo,
0667: boolean bAt100Pct) {
0668: IETSize returnSize = new ETSize(0, 0);
0669:
0670: ETList<ICompartment> compartments = getCompartments();
0671:
0672: if (compartments != null && compartments.size() > 0) {
0673:
0674: ICompartment prevCompartment = null;
0675: IETSize prevSize = null;
0676:
0677: for (Iterator iter = compartments.iterator(); iter
0678: .hasNext();) {
0679:
0680: ICompartment curCompartment = (ICompartment) iter
0681: .next();
0682:
0683: if (curCompartment != null) {
0684: // Since the default assumption is that
0685: // all the compartments are stacked top to bottom,
0686: // set the logical offset with the left side being zero.
0687: IETPoint pointLogicalOffset = new ETPoint(0,
0688: returnSize.getHeight());
0689: curCompartment
0690: .setLogicalOffsetInDrawEngineRect(pointLogicalOffset);
0691:
0692: // Make sure all the but last compartment have a fixed height.
0693: if ((prevCompartment != null) && (prevSize != null)) {
0694: prevCompartment.setTransformSize(
0695: ICompartment.EXPAND_TO_NODE, prevSize
0696: .getHeight());
0697: }
0698:
0699: prevSize = curCompartment.calculateOptimumSize(
0700: pDrawInfo, true);
0701: if (prevSize != null) {
0702: final int maxWidth = returnSize.getWidth();
0703:
0704: returnSize.setSize(Math.max(maxWidth, prevSize
0705: .getWidth()), returnSize.getHeight()
0706: + prevSize.getHeight());
0707: }
0708: }
0709:
0710: prevCompartment = curCompartment;
0711: }
0712: }
0713:
0714: return bAt100Pct || returnSize == null ? returnSize
0715: : scaleSize(returnSize, pDrawInfo != null ? pDrawInfo
0716: .getTSTransform() : getTransform());
0717: }
0718:
0719: /* (non-Javadoc)
0720: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#clone(org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine)
0721: */
0722: public Object clone() {
0723: try {
0724: IDrawEngine de = ETDrawEngineFactory.createDrawEngine(this
0725: .getClass().getName());
0726: if (de != null)
0727: de.copy(this );
0728:
0729: return de;
0730: } catch (Exception e) {
0731: e.printStackTrace();
0732: return null;
0733: }
0734: }
0735:
0736: public boolean copy(IDrawEngine pConstDrawEngine) {
0737: if (pConstDrawEngine == null)
0738: return false;
0739:
0740: m_parentUI = (IETGraphObjectUI) pConstDrawEngine.getParent()
0741: .clone();
0742: m_LastResizeOriginator = ((ETDrawEngine) pConstDrawEngine).m_LastResizeOriginator;
0743:
0744: // if (pConstDrawEngine instanceof ETDrawEngine) {
0745: // ETDrawEngine pETConstDrawEngine = (ETDrawEngine) pConstDrawEngine;
0746: // // m_defaultCompartment = pETConstDrawEngine.m_defaultCompartment.clone();
0747: // // m_defaultCompartment = pETConstDrawEngine.m_anchoredCompartment.clone();
0748: // }
0749:
0750: return true;
0751: }
0752:
0753: /**
0754: * The rectangle used for last drawing operation, in logical coordinates.
0755: *
0756: * @param bIncludeLabels When true, include the bounding rectangles for all
0757: * the labels as well
0758: * @return The rectangle used for last drawing operation, in logical
0759: * coordinates
0760: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getLogicalBoundingRect(org.netbeans.modules.uml.core.support.umlsupport.IETRect, boolean)
0761: */
0762: public IETRect getLogicalBoundingRect(boolean bIncludeLabels) {
0763: IETRect rectLogicialBounding = getLogicalBoundingRect();
0764: IETRect retVal = rectLogicialBounding;
0765: if (rectLogicialBounding != null && bIncludeLabels) {
0766: ILabelManager labelManager = getLabelManager();
0767: if (labelManager != null) {
0768: IETRect labelRect = labelManager
0769: .getLogicalBoundingRectForAllLabels();
0770: if (labelRect != null && !labelRect.isZero()) {
0771: retVal = RectConversions.unionTSCoordinates(
0772: rectLogicialBounding, labelRect);
0773: }
0774: }
0775: }
0776:
0777: return retVal;
0778: }
0779:
0780: /* (non-Javadoc)
0781: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#delayedDeleteAndReinitializeAllLabels()
0782: */
0783: public void delayedDeleteAndReinitializeAllLabels() {
0784:
0785: }
0786:
0787: /* (non-Javadoc)
0788: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#delayedSizeToContents()
0789: */
0790: public void delayedSizeToContents() {
0791: sizeToContents();
0792: }
0793:
0794: /* (non-Javadoc)
0795: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#displayColorDialog(int, int)
0796: */
0797: public boolean displayColorDialog(int nKind, int pCOLORREF) {
0798: // TODO Auto-generated method stub
0799: return false;
0800: }
0801:
0802: /* (non-Javadoc)
0803: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#displayFontDialog(int, java.lang.Object, boolean)
0804: */
0805: public void displayFontDialog(int pCOLORREF,
0806: Object pUserSelectedFont, boolean bUserSelectedFontOrColor) {
0807: // TODO Auto-generated method stub
0808: }
0809:
0810: /* (non-Javadoc)
0811: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#doDraw(org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawInfo)
0812: */
0813: public abstract void doDraw(IDrawInfo pDrawInfo);
0814:
0815: /* (non-Javadoc)
0816: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#findCompartment(org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment)
0817: */
0818: public boolean findCompartment(ICompartment pCompartment) {
0819: return getCompartments().contains(pCompartment);
0820: }
0821:
0822: /* (non-Javadoc)
0823: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#findCompartmentByCompartmentID(java.lang.String)
0824: */
0825: public ICompartment findCompartmentByCompartmentID(
0826: String sCompartmentID) {
0827: ICompartment retVal = null;
0828:
0829: for (ICompartment compartment : getCompartments()) {
0830: if (sCompartmentID.equals(compartment.getCompartmentID()) == true) {
0831: retVal = compartment;
0832: break;
0833: }
0834: }
0835:
0836: return retVal;
0837: }
0838:
0839: /* (non-Javadoc)
0840: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#findCompartmentByTitle(java.lang.String)
0841: */
0842: public ICompartment findCompartmentByTitle(String sName) {
0843:
0844: ICompartment retValue = null;
0845:
0846: Iterator<ICompartment> iterator = getCompartments().iterator();
0847:
0848: while (iterator.hasNext()) {
0849:
0850: ICompartment curObject = iterator.next();
0851: ICompartment compartment = curObject;
0852:
0853: if (compartment != null
0854: && compartment.getName().equals(sName)) {
0855: retValue = curObject;
0856: break;
0857: }
0858: }
0859:
0860: return retValue;
0861: }
0862:
0863: /* (non-Javadoc)
0864: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#findCompartmentContainingElement(org.netbeans.modules.uml.core.metamodel.core.foundation.IElement)
0865: */
0866: public ICompartment findCompartmentContainingElement(
0867: IElement pElement) {
0868:
0869: ICompartment retValue = null;
0870:
0871: Iterator<ICompartment> iterator = getCompartments().iterator();
0872: while (iterator.hasNext()) {
0873: ICompartment curObject = iterator.next();
0874:
0875: if (curObject instanceof ISimpleListCompartment) {
0876: ISimpleListCompartment listCompartment = (ISimpleListCompartment) curObject;
0877: ICompartment found = listCompartment
0878: .findCompartmentContainingElement(pElement);
0879: if (found != null) {
0880: retValue = found;
0881: break;
0882: }
0883: } else {
0884: IElement compartmentElement = curObject
0885: .getModelElement();
0886: if (compartmentElement != null
0887: && compartmentElement.isSame(pElement)) {
0888: retValue = curObject;
0889: break;
0890: }
0891: }
0892: }
0893: return retValue;
0894: }
0895:
0896: /* (non-Javadoc)
0897: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#findListCompartmentContainingCompartment(org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment)
0898: */
0899: public IListCompartment findListCompartmentContainingCompartment(
0900: ICompartment pCompartment) {
0901:
0902: IListCompartment pListCompartment = null;
0903:
0904: ICompartment pCompartmentToFind = pCompartment;
0905:
0906: IElement pElement = null;
0907:
0908: pElement = pCompartmentToFind.getModelElement();
0909:
0910: if (pElement != null) {
0911: return findListCompartmentContainingElement(pElement);
0912: }
0913:
0914: Iterator<ICompartment> iterator = getCompartments().iterator();
0915:
0916: while (iterator.hasNext()) {
0917:
0918: ICompartment compartment = iterator.next();
0919:
0920: if (compartment != null
0921: && compartment instanceof IListCompartment) {
0922:
0923: if (compartment == pCompartmentToFind) {
0924: pListCompartment = (IListCompartment) compartment;
0925: break;
0926: }
0927:
0928: boolean bFound = ((ETListCompartment) compartment)
0929: .findCompartment(pCompartmentToFind);
0930:
0931: if (bFound) {
0932: pListCompartment = (IListCompartment) compartment;
0933: break;
0934: }
0935: }
0936:
0937: }
0938: return pListCompartment;
0939: }
0940:
0941: public IListCompartment findListCompartmentContainingElement(
0942: IElement pElement) {
0943:
0944: IListCompartment pListCompartment = null;
0945:
0946: String sElementID = pElement.getXMIID();
0947:
0948: // check if this compartment already exists
0949:
0950: Iterator<ICompartment> iterator = getCompartments().iterator();
0951:
0952: while (iterator.hasNext()) {
0953:
0954: ICompartment pTestCompartment = iterator.next();
0955:
0956: if (pTestCompartment instanceof ETListCompartment) {
0957: ICompartment pFound = ((ETListCompartment) pTestCompartment)
0958: .findCompartmentContainingElement(pElement);
0959: if (pFound != null) {
0960: pListCompartment = (IListCompartment) pTestCompartment;
0961: break;
0962: }
0963: }
0964: }
0965:
0966: return pListCompartment;
0967: }
0968:
0969: /* (non-Javadoc)
0970: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getAnchoredCompartment()
0971: */
0972: public ICompartment getAnchoredCompartment() {
0973: return this .m_anchoredCompartment;
0974: }
0975:
0976: /* (non-Javadoc)
0977: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getBoundingRect()
0978: */
0979: public IETRect getBoundingRect() {
0980: IETRect retVal = super .getBoundingRect();
0981: if (retVal != null) {
0982: retVal.normalizeRect();
0983: }
0984:
0985: return retVal;
0986: }
0987:
0988: /* (non-Javadoc)
0989: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getCheckSyncStateDuringDraw()
0990: */
0991: public boolean getCheckSyncStateDuringDraw() {
0992: // TODO Auto-generated method stub
0993: return false;
0994: }
0995:
0996: /* (non-Javadoc)
0997: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getDefaultCompartment()
0998: */
0999: public ICompartment getDefaultCompartment() {
1000: return this .m_defaultCompartment;
1001: }
1002:
1003: /* (non-Javadoc)
1004: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getDiagram()
1005: */
1006: public IDiagram getDiagram() {
1007: return TypeConversions.getDiagram(this );
1008: }
1009:
1010: /*
1011: * should be overwritten in derived classes
1012: */
1013: abstract public String getDrawEngineID();
1014:
1015: /**
1016: * This is the string to be used when looking for other similar drawengines.
1017: *
1018: * @param sID [out,retval] The unique engine identifier
1019: */
1020: public String getDrawEngineMatchID() {
1021: // The match is based on draw engine and element types
1022: String engineType = getDrawEngineID();
1023: IElement modEle = getFirstModelElement();
1024: String elemType = modEle != null ? modEle.getElementType() : "";
1025:
1026: return engineType + "," + elemType;
1027: }
1028:
1029: /**
1030: * Retrieves the event manager that the draw engine uses. The event manager
1031: * that is used is determined by the return value of getManagerType().
1032: *
1033: * @see #getManagerType(int)
1034: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getEventManager()
1035: */
1036: public IEventManager getEventManager() {
1037: if (m_EventManager == null) {
1038: String eventManagerType = getManagerMetaType(MK_EVENTMANAGER);
1039: if ((eventManagerType != null)
1040: && (eventManagerType.length() > 0)) {
1041: m_EventManager = DrawingFactory
1042: .retrieveEventManager(eventManagerType);
1043: setManagerBackpointer(m_EventManager);
1044: }
1045: }
1046:
1047: return m_EventManager;
1048: }
1049:
1050: /**
1051: * Returns the metatype of the manager we should use. This implementation
1052: * always returns an empty string.
1053: *
1054: * @return The metatype in essentialconfig.etc that defines the label manager
1055: * @param managerType The type of manager.
1056: */
1057: public String getManagerMetaType(int nManagerKind) {
1058: return "";
1059: }
1060:
1061: /* (non-Javadoc)
1062: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getIsGraphicalContainer()
1063: */
1064: public boolean getIsGraphicalContainer() {
1065: return false;
1066: }
1067:
1068: /**
1069: Retrieves the smallest node draw engine that graphically contains this draw engine
1070: */
1071: public IDrawEngine getGraphicalContainer() {
1072: if (m_bActiveLayout || m_bFindNewContainer) {
1073: // Assume this draw engine is not contained
1074: m_containerDE = null;
1075:
1076: // Retrieve all the node presentation elements (PEs) on this PE's diagram
1077: ETList<IPresentationElement> allNodePEs = null;
1078: {
1079: IDrawingAreaControl control = getDrawingArea();
1080: if (control != null) {
1081: allNodePEs = control.getAllNodeItems(null);
1082: }
1083: }
1084:
1085: if (allNodePEs != null) {
1086: // Remove this node from the list of all nodes
1087: {
1088: IPresentationElement this PE = getPresentationElement();
1089: // When the node is 1st created it is possible for this PE to be null
1090: if (this PE != null) {
1091: allNodePEs.removeItem(this PE);
1092: }
1093: }
1094:
1095: final IETRect rectThisBounding = getLogicalBoundingRect();
1096:
1097: float fMinContainerArea = Float.MAX_VALUE;
1098:
1099: for (Iterator iter = allNodePEs.iterator(); iter
1100: .hasNext();) {
1101: IPresentationElement pe = (IPresentationElement) iter
1102: .next();
1103:
1104: IDrawEngine engine = TypeConversions
1105: .getDrawEngine(pe);
1106: if (engine != null) {
1107: if (engine.getIsGraphicalContainer()) {
1108: final IETRect rectEngine = TypeConversions
1109: .getLogicalBoundingRect(engine);
1110: if (rectEngine.contains(rectThisBounding)) {
1111: // The true container is the container with the smallest area
1112: float fEngineArea = (float) rectEngine
1113: .getWidth()
1114: * (float) rectEngine
1115: .getHeight();
1116: assert (fEngineArea > 0);
1117:
1118: if (fEngineArea < fMinContainerArea) {
1119: fMinContainerArea = fEngineArea;
1120:
1121: m_containerDE = engine;
1122: }
1123: }
1124: }
1125: }
1126: }
1127: }
1128: }
1129:
1130: m_bFindNewContainer = false;
1131:
1132: return m_containerDE;
1133: }
1134:
1135: /**
1136: * Clears the member variable that retains the graphical container
1137: */
1138: public void resetGraphicalContainer() {
1139: m_bFindNewContainer = true;
1140: }
1141:
1142: protected ILabelManager createLabelManager() {
1143: String sLabelManagerType = getManagerMetaType(MK_LABELMANAGER);
1144: ILabelManager labelManager = null;
1145:
1146: // If we have a label manager type now go ahead and create it
1147: if (sLabelManagerType != null && sLabelManagerType.length() > 0) {
1148:
1149: String sForcedStereotypeText = getForcedStereotypeText();
1150: labelManager = DrawingFactory
1151: .retrieveLabelManager(sLabelManagerType);
1152:
1153: if (labelManager != null && sForcedStereotypeText != null
1154: && sForcedStereotypeText.length() > 0) {
1155:
1156: // If we're forcing the stereotype text then do that here.
1157: labelManager
1158: .setForcedStereotypeString(sForcedStereotypeText);
1159: }
1160:
1161: if (labelManager != null) {
1162: setManagerBackpointer(labelManager);
1163: }
1164: }
1165:
1166: return labelManager;
1167: }
1168:
1169: /* (non-Javadoc)
1170: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getLabelManager()
1171: */
1172: public ILabelManager getLabelManager() {
1173:
1174: if (m_LabelManager == null) {
1175: m_LabelManager = createLabelManager();
1176:
1177: } else {
1178: // Refresh the forced stereotype
1179: m_LabelManager
1180: .setForcedStereotypeString(getForcedStereotypeText());
1181: }
1182:
1183: return m_LabelManager;
1184:
1185: }
1186:
1187: protected String getForcedStereotypeText() {
1188: return "";
1189: }
1190:
1191: /* (non-Javadoc)
1192: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getLastDrawPointY()
1193: */
1194: public int getLastDrawPointY() {
1195: // TODO Auto-generated method stub
1196: return 0;
1197: }
1198:
1199: /* (non-Javadoc)
1200: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getOLEDragElements()
1201: */
1202: public IElement[] getOLEDragElements() {
1203: // TODO Auto-generated method stub
1204: return null;
1205: }
1206:
1207: /* (non-Javadoc)
1208: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getParent()
1209: */
1210: public IETGraphObjectUI getParent() {
1211: return m_parentUI;
1212: }
1213:
1214: /* (non-Javadoc)
1215: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getParentETElement()
1216: */
1217: public ITSGraphObject getParentETElement() {
1218: IETGraphObjectUI ui = getParent();
1219: return ui != null && ui.getOwner() instanceof ITSGraphObject ? (ITSGraphObject) ui
1220: .getOwner()
1221: : null;
1222: }
1223:
1224: /* (non-Javadoc)
1225: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getWindow()
1226: */
1227: public int getWindow() {
1228: // TODO Auto-generated method stub
1229: return 0;
1230: }
1231:
1232: /* (non-Javadoc)
1233: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#handleAccelerator(int)
1234: */
1235: public boolean handleAccelerator(String accelerator) {
1236: // TODO Auto-generated method stub
1237: return false;
1238: }
1239:
1240: /* (non-Javadoc)
1241: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#handleSetCursor(org.netbeans.modules.uml.ui.support.viewfactorysupport.ISetCursorEvent)
1242: */
1243: public boolean handleSetCursor(ISetCursorEvent event) {
1244: boolean bHandled = false;
1245:
1246: // this is the relative position within the node (topleft = 0,0)
1247: IETPoint point = getWinScaledOwnerCursorPosition(event);
1248:
1249: final int numCompartments = getNumVisibleCompartments();
1250: for (int i = 0; (bHandled == false) && (i < numCompartments); i++) {
1251: ICompartment compartment = getVisibleCompartment(i);
1252: if (compartment != null) {
1253: bHandled = compartment.handleSetCursor(point, event);
1254: }
1255: }
1256:
1257: return bHandled;
1258: }
1259:
1260: /* (non-Javadoc)
1261: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#init()
1262: */
1263: public void init() throws ETException {
1264: if (TypeConversions.getElement(this ) != null) {
1265: IPresentationElement pPE = getPresentationElement();
1266: if (pPE != null) {
1267: this .clearCompartments();
1268: this .createCompartments();
1269: this .initCompartments(pPE);
1270: }
1271:
1272: if (this .m_bInitResources == false) {
1273: this .initResources();
1274: }
1275: this .sizeToContents();
1276: }
1277: }
1278:
1279: public void initCompartments(IPresentationElement pElement) {
1280: // TODO Auto-generated method stub
1281: }
1282:
1283: /* (non-Javadoc)
1284: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#initResources()
1285: */
1286: public void initResources() {
1287: if (m_bInitResources == false) {
1288: m_bInitResources = true;
1289: }
1290: }
1291:
1292: /*
1293: * (non-Javadoc)
1294: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#invalidate()
1295: */
1296: public long invalidate() {
1297: return invalidateRect(getLogicalBoundingRect(true));
1298: }
1299:
1300: /*
1301: * (non-Javadoc)
1302: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#invalidateRect(org.netbeans.modules.uml.core.support.umlsupport.IETRect)
1303: */
1304: public long invalidateRect(IETRect rect) {
1305: if (rect != null) {
1306: IDrawingAreaControl control = getDrawingArea();
1307: if (control != null && control.getGraphWindow() != null) {
1308: control.refreshRect(rect);
1309: }
1310: }
1311: return 0;
1312: }
1313:
1314: /* (non-Javadoc)
1315: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#layout()
1316: */
1317: public void layout() {
1318: // create a draw info
1319: // One reason for not getting a draw info here it is because the window has closed.
1320: IDrawInfo drawInfo = getParent().getDrawInfo();
1321: if (drawInfo != null) {
1322: IETSize size = calculateOptimumSize(drawInfo, true);
1323:
1324: // Make sure the compartment, and its pieces are laid out properly
1325: IETRect rectEngineBounding = getLogicalBoundingRect();
1326:
1327: IETRect rectCompartmentInDE = new ETRect(0, 0,
1328: rectEngineBounding.getWidth(), rectEngineBounding
1329: .getHeight());
1330:
1331: ETList<ICompartment> compartments = getCompartments();
1332: for (Iterator<ICompartment> iter = compartments.iterator(); iter
1333: .hasNext();) {
1334: ICompartment compartment = iter.next();
1335:
1336: IETPoint ptOffset = compartment
1337: .getLogicalOffsetInDrawEngineRect();
1338:
1339: rectCompartmentInDE.setLeft(ptOffset.getX());
1340: rectCompartmentInDE.setTop(ptOffset.getY());
1341:
1342: compartment.layout(rectCompartmentInDE);
1343: }
1344: }
1345: }
1346:
1347: /* (non-Javadoc)
1348: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#modelElementDeleted(org.netbeans.modules.uml.ui.support.viewfactorysupport.INotificationTargets)
1349: */
1350: public long modelElementDeleted(INotificationTargets pTargets) {
1351: int count = getNumCompartments();
1352: for (int i = 0; i < count; i++) {
1353: ICompartment pComp = getCompartment(i);
1354: if (pComp != null) {
1355: pComp.modelElementDeleted(pTargets);
1356: }
1357: }
1358: return 0;
1359: }
1360:
1361: /**
1362: * Notifier that the model element has changed, if available the changed IFeature is passed along.
1363: *
1364: * @param pTargets[in] Information about what has changed
1365: */
1366: public long modelElementHasChanged(INotificationTargets pTargets) {
1367: //dispatch model element has changed to compartments
1368: Iterator<ICompartment> iterator = this .getCompartments()
1369: .iterator();
1370: while (iterator.hasNext()) {
1371: iterator.next().modelElementHasChanged(pTargets);
1372: }
1373: return 0;
1374: }
1375:
1376: /* (non-Javadoc)
1377: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#nodeResized(int)
1378: */
1379: public void onResized() {
1380:
1381: m_LastResizeOriginator = TSE_NODE_RESIZE_ORIGINAL;
1382: }
1383:
1384: /* (non-Javadoc)
1385: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#onCompartmentCollapsed(org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment, boolean)
1386: */
1387: public long onCompartmentCollapsed(ICompartment pCompartment,
1388: boolean bCollapsed) {
1389: // TODO Auto-generated method stub
1390: return 0;
1391: }
1392:
1393: /* (non-Javadoc)
1394: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#onContextMenu(org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenu, int, int)
1395: */
1396: public long onContextMenu(IProductContextMenu pContextMenu,
1397: int logicalX, int logicalY) {
1398: // TODO Auto-generated method stub
1399: return 0;
1400: }
1401:
1402: /* (non-Javadoc)
1403: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#onContextMenuHandleSelection(org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenu, org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenuItem)
1404: */
1405: public long onContextMenuHandleSelection(
1406: IProductContextMenu pContextMenu,
1407: IProductContextMenuItem pMenuItem) {
1408: // TODO Auto-generated method stub
1409: return 0;
1410: }
1411:
1412: /* (non-Javadoc)
1413: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#onGraphEvent(int)
1414: */
1415: public void onGraphEvent(int nKind) {
1416: Iterator<ICompartment> iterator = this .getCompartments()
1417: .iterator();
1418: while (iterator.hasNext()) {
1419: iterator.next().onGraphEvent(nKind);
1420: }
1421:
1422: switch (nKind) {
1423: case IGraphEventKind.GEK_PRE_MOVE:
1424: case IGraphEventKind.GEK_PRE_RESIZE:
1425: case IGraphEventKind.GEK_PRE_LAYOUT:
1426: m_bActiveLayout = true;
1427: break;
1428:
1429: case IGraphEventKind.GEK_POST_MOVE:
1430: case IGraphEventKind.GEK_POST_RESIZE:
1431: case IGraphEventKind.GEK_POST_LAYOUT:
1432: m_bActiveLayout = false;
1433: resetGraphicalContainer();
1434: break;
1435: }
1436: }
1437:
1438: /* (non-Javadoc)
1439: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#onKeydown(int, int)
1440: */
1441: public boolean onKeydown(int nKeyCode, int nShift) {
1442: //dispatch the key down event to all compartments
1443: return dispatchKeyDownToCompartments(nKeyCode, nShift);
1444: }
1445:
1446: private boolean dispatchKeyDownToCompartments(int nKeyCode,
1447: int nShift) {
1448: boolean handled = false;
1449: int count = getNumVisibleCompartments();
1450: for (int i = count - 1; i >= 0; i--) {
1451: ICompartment pComp = getVisibleCompartment(i);
1452: if (pComp != null) {
1453: handled = pComp.handleKeyDown(nKeyCode, nShift);
1454: if (handled) {
1455: break;
1456: }
1457: }
1458: }
1459: // Fixed IZ 99020 - IndexOutOfBoundsException when using keyboard to traverse
1460: // Composite State compartment after deleting a Region Row
1461: // Correct the logic to calculate the index of the compartment to be selected.
1462: if (!handled
1463: && nShift == 0
1464: && (nKeyCode == KeyEvent.VK_RIGHT || nKeyCode == KeyEvent.VK_LEFT)) {
1465: ICompartment pComp = null;
1466: int selectableCompCount = getNumSelectableCompartments();
1467: if (nKeyCode == KeyEvent.VK_RIGHT) {
1468: // calcualte the current compartment index
1469: compIndex = compIndex + 1;
1470: if (compIndex >= selectableCompCount)
1471: compIndex = 0;
1472: } else if (nKeyCode == KeyEvent.VK_LEFT) {
1473: compIndex = compIndex - 1;
1474: if (compIndex < 0)
1475: compIndex = selectableCompCount - 1;
1476: }
1477: pComp = getSelectableCompartment(compIndex);
1478:
1479: if (pComp != null) {
1480: //Fixed issue 83794. Disabled the ability to select a
1481: // TemplateParametersCompartment for editing.
1482: if (pComp instanceof ITemplateParametersCompartment) {
1483: // skip ITemplateParametersCompartment compartment and
1484: // process the next compartment instead.
1485: if (nKeyCode == KeyEvent.VK_RIGHT) {
1486: // Advance the compartment index to the next compartment
1487: compIndex = compIndex + 1;
1488: if (compIndex >= selectableCompCount)
1489: compIndex = 0;
1490: } else if (nKeyCode == KeyEvent.VK_LEFT) {
1491: compIndex = compIndex - 1;
1492: if (compIndex < 0)
1493: compIndex = selectableCompCount - 1;
1494: }
1495: pComp = getSelectableCompartment(compIndex);
1496: }
1497: //1. deselect all selected compartment
1498: selectAllCompartments(false);
1499: //2. select this compartment
1500: pComp.setSelected(true);
1501: invalidate();
1502: getDrawingArea().refresh(true);
1503: handled = true;
1504:
1505: } else {
1506: // System.err.println(" pComp is null! ");
1507: }
1508:
1509: } //end of if(nshift==0)
1510:
1511: ICompartment oldDefault = null;
1512: //if nobody handled, pass on to the default compartment
1513: if (!handled && m_defaultCompartment == null) {
1514: for (int i = 0; i < count; i++) {
1515: ICompartment pComp = getVisibleCompartment(i);
1516: if (pComp != null) {
1517: oldDefault = getDefaultCompartment();
1518: setDefaultCompartment(pComp.getDefaultCompartment());
1519: break;
1520: }
1521: }
1522: }
1523:
1524: // leave it for ADDrawingAreaControl to handle
1525: if (!handled && nKeyCode == KeyEvent.VK_DELETE)
1526: return false;
1527: if (!handled && m_defaultCompartment != null) {
1528: // save selection state
1529: boolean selected = m_defaultCompartment.isSelected();
1530: // save anchored ref
1531: ICompartment oldAnchored = getAnchoredCompartment();
1532:
1533: // select compartment so the HandleKeyDown logic fires
1534: m_defaultCompartment.setSelected(true);
1535: handled = m_defaultCompartment.handleKeyDown(nKeyCode,
1536: nShift);
1537:
1538: // if not handled and the default wasn't selected, leave it unselected
1539: // KSL - we were seeing a situation where dropping a new class, then using auto-type to edit
1540: // the class name would leave the class name selected. This was b/c the call to HandleKeyDown()
1541: // was returning *bHandled = true. so we now just test if the default compartment was initially
1542: // unselected, to leave it unselected. I'm leaving the commented out code in until we verify
1543: // no other types depend on this behaviour.
1544: if (!selected) {
1545: m_defaultCompartment.setSelected(false);
1546: }
1547: setAnchoredCompartment(oldAnchored);
1548: if (!handled && oldDefault != null) {
1549: setDefaultCompartment(oldDefault);
1550: }
1551: }
1552: return handled;
1553: }
1554:
1555: /* (non-Javadoc)
1556: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#onCharTyped(char)
1557: */
1558: public boolean onCharTyped(char ch) {
1559: boolean handled = false;
1560: int count = getNumVisibleCompartments();
1561: for (int i = count - 1; i >= 0; i--) {
1562: ICompartment pComp = getVisibleCompartment(i);
1563: if (pComp != null) {
1564: handled = pComp.handleCharTyped(ch);
1565: if (handled) {
1566: break;
1567: }
1568: }
1569: }
1570:
1571: //if nobody handled, pass on to the default compartment
1572: if (!handled && m_defaultCompartment == null) {
1573: for (int i = 0; i < count; i++) {
1574: ICompartment pComp = getVisibleCompartment(i);
1575: if (pComp != null) {
1576: setDefaultCompartment(pComp.getDefaultCompartment());
1577: break;
1578: }
1579: }
1580: }
1581:
1582: if (!handled && m_defaultCompartment != null) {
1583: // save selection state
1584: boolean selected = m_defaultCompartment.isSelected();
1585:
1586: // select compartment so the HandleKeyDown logic fires
1587: m_defaultCompartment.setSelected(true);
1588: handled = m_defaultCompartment.handleCharTyped(ch);
1589:
1590: if (!selected) {
1591: m_defaultCompartment.setSelected(false);
1592: }
1593: }
1594: return handled;
1595: }
1596:
1597: /**
1598: * Returns the visible compartment at the argument index.
1599: *
1600: * @param index [in] The index into the list of the draw engines visible compartments
1601: * @param pCompartment [out,retval] The compartment at this index, otherwise NULL
1602: */
1603: protected ICompartment getVisibleCompartment(int index) {
1604: ICompartment retObj = null;
1605: int count = getNumCompartments();
1606: int visiIndex = 0;
1607: for (int i = 0; i < count; i++) {
1608: ICompartment pComp = (ICompartment) m_compartments.get(i);
1609: if (pComp != null && pComp.getVisible()) {
1610: if (index == visiIndex) {
1611: retObj = pComp;
1612: break;
1613: }
1614: visiIndex++;
1615: }
1616: }
1617: return retObj;
1618: }
1619:
1620: /* (non-Javadoc)
1621: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#onKeyup(int, int)
1622: */
1623: public boolean onKeyup(int KeyCode, int Shift) {
1624: // TODO Auto-generated method stub
1625: return false;
1626: }
1627:
1628: /* (non-Javadoc)
1629: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#performDeepSynch()
1630: */
1631: public long performDeepSynch() {
1632: try {
1633: IPresentationElement pPE = getPresentationElement();
1634: if (pPE != null) {
1635: // Fix J1255: Clearing and initializing the compartments resets the
1636: // divider data for the zones compartment.
1637: // So, we don't want that to happen.
1638: // this.clearCompartments();
1639: // this.createCompartments();
1640: this .initCompartments(pPE);
1641: }
1642: } catch (Exception e) {
1643: }
1644: return 0;
1645: }
1646:
1647: /* (non-Javadoc)
1648: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#postLoad()
1649: */
1650: public long postLoad() {
1651: ETList<ICompartment> compartments = getCompartments();
1652: for (Iterator iter = compartments.iterator(); iter.hasNext();) {
1653: ICompartment compartment = (ICompartment) iter.next();
1654:
1655: compartment.postLoad();
1656: }
1657:
1658: return 0;
1659: }
1660:
1661: /* (non-Javadoc)
1662: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#preHandleNameCollision(org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment, org.netbeans.modules.uml.core.metamodel.core.foundation.INamedElement, org.netbeans.modules.uml.core.metamodel.core.foundation.INamedElement)
1663: */
1664: public boolean preHandleNameCollision(
1665: ICompartment pCompartmentBeingEdited,
1666: INamedElement pElement, INamedElement pFirstCollidingElement) {
1667: return true;
1668: }
1669:
1670: /* (non-Javadoc)
1671: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#queryToolTipData(org.netbeans.modules.uml.ui.support.viewfactorysupport.IToolTipData)
1672: */
1673: public long queryToolTipData(IToolTipData pToolTipData) {
1674: // TODO Auto-generated method stub
1675: return 0;
1676: }
1677:
1678: /**
1679: * Restore draw engine presentation attributes from the product archive.
1680: *
1681: * @param pProductArchive [in] The archive we're reading from
1682: * @param pEngineElement [in] The element where this draw engine's information should exist
1683: */
1684: public long readFromArchive(IProductArchive pProductArchive,
1685: IProductArchiveElement pParentElement) {
1686: // perform any special read here for the engine. Derived draw engines should perform their
1687: // read before calling this base class.
1688: clearCompartments();
1689:
1690: // If hr is 0x80040111 then that means that the essential config does not contain
1691: // a compartment that is in the diagram file. The drawengine should fix when
1692: // the draw happens because it's there we check to make sure the drawengine has at least
1693: // one compartment.
1694: DrawingFactory.createCompartments(this , pProductArchive,
1695: pParentElement);
1696:
1697: // after compartments are created we init resources
1698: initResources();
1699:
1700: // read any custom overrides now, after all default initialization
1701: m_ResourceUser.readResourcesFromArchive(pProductArchive,
1702: pParentElement);
1703:
1704: // Put the compartment reloading of resources in another try block so incase we throw
1705: // we don't leave static compartments in memory
1706: try {
1707: // Tell the compartments to read their resources from archive
1708: DrawingFactory
1709: .readCompartmentResourcesFromArchive(pProductArchive);
1710:
1711: // We should be fully loaded by now so draw a red border if we still can't get our
1712: // model element.
1713: setCheckSyncStateDuringDraw(true);
1714: } catch (Exception e) {
1715: }
1716: return 0;
1717: }
1718:
1719: /*
1720: * (non-Javadoc)
1721: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#reinitCompartments(org.netbeans.modules.uml.core.metamodel.core.foundation.IPresentationElement)
1722: */
1723: public long reinitCompartments(IPresentationElement pElement) {
1724: // TODO Auto-generated method stub
1725: return 0;
1726: }
1727:
1728: /* (non-Javadoc)
1729: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#selectExtendCompartments(org.netbeans.modules.uml.ui.support.viewfactorysupport.IMouseEvent)
1730: */
1731: public void selectExtendCompartments(MouseEvent pEvent) {
1732: // TODO Auto-generated method stub
1733: }
1734:
1735: /* (non-Javadoc)
1736: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#setAnchoredCompartment(org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment)
1737: */
1738: public long setAnchoredCompartment(ICompartment pCompartment) {
1739: this .m_anchoredCompartment = pCompartment;
1740: return 0;
1741: }
1742:
1743: /* (non-Javadoc)
1744: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#setCheckSyncStateDuringDraw(boolean)
1745: */
1746: public void setCheckSyncStateDuringDraw(boolean value) {
1747: // TODO Auto-generated method stub
1748:
1749: }
1750:
1751: /* (non-Javadoc)
1752: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#setDefaultCompartment(org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment)
1753: */
1754: public void setDefaultCompartment(ICompartment pCompartment) {
1755: this .m_defaultCompartment = pCompartment;
1756: }
1757:
1758: /*
1759: * (non-Javadoc)
1760: * set isDirty to true when there is data that needs to be saved
1761: */
1762: public long setIsDirty() {
1763: IDrawingAreaControl control = getDrawingArea();
1764: if (control != null) {
1765: control.setIsDirty(true);
1766: }
1767: return 0;
1768: }
1769:
1770: /* (non-Javadoc)
1771: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#setLastDrawPointY(int)
1772: */
1773: public void setLastDrawPointY(int i) {
1774: // TODO Auto-generated method stub
1775:
1776: }
1777:
1778: /* (non-Javadoc)
1779: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#setParent(com.tomsawyer.editor.TSEObjectUI)
1780: */
1781: public void setParent(IETGraphObjectUI pParent) {
1782: this .m_parentUI = pParent;
1783:
1784: // Release the transform 'cause it's now pointing at a different object
1785: this .clearTransformOwner();
1786:
1787: // Clear the resource manager, which is indexed by our diagram
1788: //ClearResourceManager();
1789: }
1790:
1791: /* (non-Javadoc)
1792: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getReadOnly()
1793: */
1794: public boolean getReadOnly() {
1795: return m_readOnly;
1796: }
1797:
1798: /* (non-Javadoc)
1799: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#setReadOnly(boolean)
1800: */
1801: public void setReadOnly(boolean value) {
1802: m_readOnly = value;
1803: }
1804:
1805: /* (non-Javadoc)
1806: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#setSensitivityAndCheck(org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenu, org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenuItem, int)
1807: */
1808: public boolean setSensitivityAndCheck(
1809: IProductContextMenu pContextMenu,
1810: IProductContextMenuItem pMenuItem, int buttonKind) {
1811: // TODO Auto-generated method stub
1812: return false;
1813: }
1814:
1815: /* (non-Javadoc)
1816: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#setupOwner()
1817: */
1818: public void setupOwner() {
1819: // TODO Auto-generated method stub
1820: }
1821:
1822: /* (non-Javadoc)
1823: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#sizeToContents()
1824: */
1825: public void sizeToContents() {
1826: }
1827:
1828: /* (non-Javadoc)
1829: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#updateColorPreferenceToCurrent(int)
1830: */
1831: public void updateColorPreferenceToCurrent(int nKind) {
1832: // TODO Auto-generated method stub
1833: }
1834:
1835: /* (non-Javadoc)
1836: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#updateLastDrawPointY(double)
1837: */
1838: public void updateLastDrawPointY(double d) {
1839: // TODO Auto-generated method stub
1840:
1841: }
1842:
1843: /* (non-Javadoc)
1844: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#validateNode()
1845: */
1846: public boolean validateNode() {
1847: // TODO Auto-generated method stub
1848: return false;
1849: }
1850:
1851: /* (non-Javadoc)
1852: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#validateResize(int, int)
1853: */
1854: public Dimension validateResize(int x, int y) {
1855: return new Dimension(x, y);
1856: }
1857:
1858: /**
1859: * Saves the draw engine and compartment stuff to the product archive.
1860: *
1861: * @param pProductArchive [in] The archive we're saving to
1862: * @param pElement [in] The current element, or parent for any new attributes or elements
1863: */
1864: public long writeToArchive(IProductArchive pProductArchive,
1865: IProductArchiveElement pElement) {
1866: if (pProductArchive != null && pElement != null) {
1867: // if none of the compartments have anything to save then no reason to save this engine
1868: String engName = getDrawEngineID();
1869: if (engName != null && engName.length() > 0) {
1870: IProductArchiveElement engEle = pElement
1871: .createElement(IProductArchiveDefinitions.ENGINENAMEELEMENT_STRING);
1872: if (engEle != null) {
1873: engEle
1874: .addAttribute(
1875: IProductArchiveDefinitions.ENGINENAMEATTRIBUTE_STRING,
1876: engName);
1877: writeResourcesToArchive(pProductArchive, engEle);
1878:
1879: m_ResourceUser.writeResourcesToArchive(
1880: pProductArchive, engEle);
1881:
1882: // Now create a element based on each compartment and write out each compartment
1883: int count = getNumCompartments();
1884: for (int i = 0; i < count; i++) {
1885: // Tell each compartment to write to the archive
1886: ICompartment pCompartment = getCompartment(i);
1887: if (pCompartment != null) {
1888: pCompartment.writeToArchive(
1889: pProductArchive, engEle);
1890: }
1891: }
1892: }
1893: }
1894: }
1895: return 0;
1896: }
1897:
1898: /**
1899: * @param pProductArchive
1900: * @param engEle
1901: */
1902: private void writeResourcesToArchive(
1903: IProductArchive pProductArchive,
1904: IProductArchiveElement engEle) {
1905: // TODO Auto-generated method stub
1906:
1907: }
1908:
1909: // Abstract mouse event handlers.
1910: public abstract boolean handleLeftMouseButton(MouseEvent pEvent);
1911:
1912: public abstract boolean handleLeftMouseButtonDoubleClick(
1913: MouseEvent pEvent);
1914:
1915: public abstract boolean handleRightMouseButton(MouseEvent pEvent);
1916:
1917: public abstract boolean handleLeftMouseBeginDrag(
1918: IETPoint pStartPos, IETPoint pCurrentPos);
1919:
1920: public abstract boolean handleLeftMouseDrag(IETPoint pStartPos,
1921: IETPoint pCurrentPos);
1922:
1923: public abstract boolean handleLeftMouseDrop(IETPoint pCurrentPos,
1924: List pElements, boolean bMoving);
1925:
1926: public boolean handleLeftMouseButtonPressed(MouseEvent pEvent) {
1927: return false;
1928: }
1929:
1930: public abstract String getPresentationType();
1931:
1932: /* (non-Javadoc)
1933: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getUI()
1934: */
1935: public IETGraphObjectUI getUI() {
1936: return getParent();
1937: }
1938:
1939: /*
1940: * (non-Javadoc)
1941: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getPresentation()
1942: */
1943: public IGraphPresentation getPresentation() {
1944: IETGraphObjectUI ui = getUI();
1945: if (ui != null && ui.getTSObject() instanceof IETGraphObject) {
1946: return (IGraphPresentation) ((IETGraphObject) ui
1947: .getTSObject()).getPresentationElement();
1948: }
1949: return null;
1950: }
1951:
1952: /**
1953: * Returns the node's Presentation Element.
1954: *
1955: * @param pElement [out,retval] The presentation element that represents this edge draw engine
1956: */
1957: protected IPresentationElement getPresentationElement() {
1958: IETGraphObject pETElement = (IETGraphObject) getParentETElement();
1959: return pETElement != null ? pETElement.getPresentationElement()
1960: : null;
1961: }
1962:
1963: /*
1964: protected IDrawingFactory getPresentationFactory()
1965: {
1966: if (m_presentationFactory == null){
1967: m_presentationFactory = new DrawingFactory();
1968: }
1969: return m_presentationFactory;
1970: }
1971: */
1972:
1973: /* (non-Javadoc)
1974: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getDrawingArea()
1975: */
1976: public IDrawingAreaControl getDrawingArea() {
1977: return getParent() != null ? getParent().getDrawingArea()
1978: : null;
1979: }
1980:
1981: /*
1982: *
1983: */
1984: public String getTaggedValuesText(IElement pElement) {
1985: String retValue = null;
1986: if (pElement != null) {
1987: ETList<ITaggedValue> taggedValues = pElement
1988: .getAllTaggedValues();
1989: if (taggedValues != null && taggedValues.size() > 0) {
1990: String finalName = "{";
1991: int count = taggedValues.size();
1992: for (int i = 0; i < count; i++) {
1993: ITaggedValue taggedValue = taggedValues.get(i);
1994: if (taggedValue != null) {
1995: String name = taggedValue.getName();
1996: String value = taggedValue.getDataValue();
1997:
1998: //throw out the documentation property
1999: if (name.toLowerCase().equals("documentation"))
2000: continue;
2001:
2002: if (i > 0) {
2003: finalName += ",";
2004: }
2005: finalName += name;
2006: finalName += "=";
2007: finalName += value;
2008: }
2009: }
2010: finalName += "}";
2011: retValue = finalName;
2012: }
2013: }
2014: return retValue;
2015: }
2016:
2017: public void onContextMenu(IMenuManager manager) {
2018: }
2019:
2020: /**
2021: * Adds the menu items that are unique for packages.
2022: *
2023: * @param pContextMenu[in] The context menu about to be displayed
2024: */
2025: public void addCustomizeMenuItems(IMenuManager manager) {
2026: IMenuManager subMenu = manager
2027: .createOrGetSubMenu(
2028: loadString("IDS_COMPARTMENT_TITLE"),
2029: "org.netbeans.modules.uml.view.drawingarea.layout.popup");
2030: if (subMenu != null) {
2031: addSeparatorMenuItem(subMenu);
2032: subMenu.add(createMenuAction(
2033: loadString("IDS_POPUPMENU_CUSTOMIZE"),
2034: "MBK_CUSTOMIZE"));
2035: //manager.add(subMenu);
2036: }
2037: }
2038:
2039: /**
2040: * Adds Interface Edge specific stuff.
2041: *
2042: * Link Type ->Aggregation
2043: * Association
2044: * Link End ->Navigable
2045: *
2046: * @param pContextMenu
2047: */
2048: public void addInterfaceEdgeMenuItems(IMenuManager manager) {
2049: IMenuManager subMenu = manager
2050: .createOrGetSubMenu(loadString("IDS_LABELS_TITLE"),
2051: "org.netbeans.modules.uml.view.drawingarea.layout.popup");
2052: if (subMenu != null) {
2053: addSeparatorMenuItem(subMenu);
2054: subMenu.add(createMenuAction(
2055: loadString("IDS_SHOW_INTERFACENAME"),
2056: "MBK_SHOW_INTERFACENAME"));
2057: //manager.add(subMenu);
2058: }
2059: }
2060:
2061: /**
2062: * Adds the name label if the edge has a name.
2063: *
2064: * @param pEngine[in] The controlling draw engine
2065: * @param pContextMenu[in] The context menu about to be displayed
2066: */
2067: public void addNameLabelPullright(IDrawEngine pEngine,
2068: IMenuManager manager) {
2069: ILabelManager labelMgr = pEngine.getLabelManager();
2070: // See if the name is a valid label kind
2071: boolean isValid = labelMgr != null ? labelMgr
2072: .isValidLabelKind(TSLabelKind.TSLK_NAME) : false;
2073:
2074: if (isValid) {
2075: IMenuManager subMenu = manager
2076: .createOrGetSubMenu(loadString("IDS_LABELS_TITLE"),
2077: "org.netbeans.modules.uml.view.drawingarea.layout.popup");
2078: if (subMenu != null) {
2079: subMenu.add(createMenuAction(
2080: loadString("IDS_NAME_LABEL"),
2081: "MBK_SHOW_NAME_LABEL"));
2082: //manager.add(subMenu);
2083: }
2084: }
2085: }
2086:
2087: /**
2088: * Adds the stereotype label if the edge has a stereotype.
2089: *
2090: * @param pEngine[in] The controlling draw engine
2091: * @param pContextMenu[in] The context menu about to be displayed
2092: */
2093: public void addStereotypeLabelPullright(IDrawEngine pEngine,
2094: IMenuManager manager) {
2095: ILabelManager labelMgr = pEngine.getLabelManager();
2096: String finalName;
2097: if (labelMgr != null) {
2098: // Use the label manager to get the stereotype text. We do this because there are some
2099: // label managers that force a stereotype text even though the model element doesn't
2100: // have actual stereotypes.
2101: finalName = labelMgr.getStereotypeText();
2102: } else
2103: finalName = "";
2104:
2105: if (finalName != null && finalName.length() > 0) {
2106: IMenuManager subMenu = manager
2107: .createOrGetSubMenu(loadString("IDS_LABELS_TITLE"),
2108: "org.netbeans.modules.uml.view.drawingarea.layout.popup");
2109: if (subMenu != null) {
2110: subMenu.add(createMenuAction(
2111: loadString("IDS_SHOW_STEREOTYPE"),
2112: "MBK_SHOW_STEREOTYPE"));
2113: //manager.add(subMenu);
2114: }
2115: }
2116: }
2117:
2118: /**
2119: * Adds the bind label if the edge is a derivation.
2120: *
2121: * @param pContextMenu[in] The context menu about to be displayed
2122: */
2123: public void addBindLabelPullright(IMenuManager manager) {
2124: IMenuManager subMenu = manager
2125: .createOrGetSubMenu(loadString("IDS_LABELS_TITLE"),
2126: "org.netbeans.modules.uml.view.drawingarea.layout.popup");
2127: if (subMenu != null) {
2128: subMenu
2129: .add(createMenuAction(
2130: loadString("IDS_SHOW_BINDING"),
2131: "MBK_SHOW_BINDING"));
2132: //manager.add(subMenu);
2133: }
2134: }
2135:
2136: /**
2137: * Adds the Association set multiplicity items.
2138: *
2139: * Set Multiplicity ->Association Name
2140: * Both Role Names
2141: * Both Multiplicities
2142: *
2143: * @param pContextMenu[in] The context menu about to be displayed
2144: */
2145: public void addAssociationEndSetMultiplicityMenuItems(
2146: IMenuManager manager) {
2147: IMenuManager subMenu = manager
2148: .createOrGetSubMenu(loadString("IDS_SET_MULTIPLICITY"),
2149: "org.netbeans.modules.uml.view.drawingarea.layout.popup");
2150: if (subMenu != null) {
2151: subMenu.add(createMenuAction(
2152: loadString("IDS_SET_MULTIPLICITY_0_1"),
2153: "MBK_SET_MULTIPLICITY_0_1"));
2154: subMenu.add(createMenuAction(
2155: loadString("IDS_SET_MULTIPLICITY_0_STAR"),
2156: "MBK_SET_MULTIPLICITY_0_STAR"));
2157: subMenu.add(createMenuAction(
2158: loadString("IDS_SET_MULTIPLICITY_STAR"),
2159: "MBK_SET_MULTIPLICITY_STAR"));
2160: subMenu.add(createMenuAction(
2161: loadString("IDS_SET_MULTIPLICITY_1"),
2162: "MBK_SET_MULTIPLICITY_1"));
2163: subMenu.add(createMenuAction(
2164: loadString("IDS_SET_MULTIPLICITY_1_STAR"),
2165: "MBK_SET_MULTIPLICITY_1_STAR"));
2166: //manager.add(subMenu);
2167: }
2168: }
2169:
2170: /**
2171: * Adds the Association menu items for controlling name, both ends and both multiplicities.
2172: *
2173: * Show ->Association Name
2174: * Both Role Names
2175: * Both Multiplicities
2176: *
2177: * @param pContextMenu[in] The context menu about to be displayed
2178: * @param bInMiddle[in] Is the context menu in the middle of the association (true), or on an end (false)
2179: */
2180: public void addAssociationMultiLabelSelectionsPullright(
2181: IMenuManager manager, boolean bInMiddle) {
2182: IMenuManager subMenu = manager
2183: .createOrGetSubMenu(loadString("IDS_LABELS_TITLE"),
2184: "org.netbeans.modules.uml.view.drawingarea.layout.popup");
2185: if (subMenu != null) {
2186: subMenu.add(createMenuAction(
2187: loadString("IDS_SHOW_ASSOCIATION_NAME"),
2188: "MBK_SHOW_ASSOCIATION_NAME"));
2189: subMenu.add(createMenuAction(
2190: loadString("IDS_SHOW_BOTH_ROLENAMES"),
2191: "MBK_SHOW_BOTH_ROLENAMES"));
2192: subMenu.add(createMenuAction(
2193: loadString("IDS_SHOW_BOTH_MULTIPLICITIES"),
2194: "MBK_SHOW_BOTH_MULTIPLICITIES"));
2195: //manager.add(subMenu);
2196: }
2197: }
2198:
2199: /**
2200: * Adds the Association menu items when the location is CMPK_END or CMPK_START.
2201: *
2202: * Show Association Name
2203: * Show Role Name
2204: * Show Multiplicity
2205: *
2206: * @param pContextMenu[in] The context menu about to be displayed
2207: */
2208: public void addAssociationEndLabelsPullright(IMenuManager manager) {
2209: IMenuManager subMenu = manager
2210: .createOrGetSubMenu(loadString("IDS_LABELS_TITLE"),
2211: "org.netbeans.modules.uml.view.drawingarea.layout.popup");
2212: if (subMenu != null) {
2213: // J1923
2214: //subMenu.add(createMenuAction(loadString("IDS_SHOW_ASSOCIATION_NAME2"), "MBK_SHOW_ASSOCIATION_NAME"));
2215: subMenu.add(createMenuAction(
2216: loadString("IDS_SHOW_ROLENAME"),
2217: "MBK_SHOW_ROLENAME"));
2218: subMenu.add(createMenuAction(
2219: loadString("IDS_SHOW_MULTIPLICITY"),
2220: "MBK_SHOW_MULTIPLICITY"));
2221: //manager.add(subMenu);
2222: }
2223: }
2224:
2225: public void addActivityEdgeMenuItems(IMenuManager manager) {
2226: IMenuManager subMenu = manager
2227: .createOrGetSubMenu(loadString("IDS_LABELS_TITLE"),
2228: "org.netbeans.modules.uml.view.drawingarea.layout.popup");
2229: if (subMenu != null) {
2230: subMenu.add(createMenuAction(
2231: loadString("IDS_SHOW_GUARD_CONDITION"),
2232: "MBK_SHOW_GUARD_CONDITION"));
2233: subMenu.add(createMenuAction(
2234: loadString("IDS_SHOW_ACTIVITYEDGE_NAME"),
2235: "MBK_SHOW_ACTIVITYEDGE_NAME"));
2236: //manager.add(subMenu);
2237: }
2238: }
2239:
2240: /**
2241: * Adds the qualifiers buttons
2242: *
2243: * @param pContextMenu[in] The context menu about to be displayed
2244: */
2245: public void addQualifiersButton(IMenuManager manager) {
2246: manager.add(createMenuAction(loadString("IDS_QUALIFIERS"),
2247: "MBK_QUALIFIERS"));
2248: }
2249:
2250: /**
2251: * Adds Association and Aggregation Edge specific items.
2252: *
2253: * Transform -> To Ordinary Aggregate - accelerator (O)
2254: * To Composite Aggregate - accelerator (C)
2255: * Remove Aggregate - accelerator (e)
2256: * --------------------------------------------
2257: * Navigable - accelerator (N)
2258: * Reverse Ends - acclerator (R)
2259: *
2260: * @param pContextMenu[in] The context menu we're adding to
2261: * @param pLinkElement[in] The link element that this context menu applies to
2262: */
2263: public void addAssociationAndAggregationEdgeMenuItems(
2264: IMenuManager manager, IElement pLinkElement) {
2265: IMenuManager subMenu = manager
2266: .createOrGetSubMenu(
2267: loadString("IDS_EDGETRANSFORM_POPUP_TITLE"),
2268: "org.netbeans.modules.uml.view.drawingarea.layout.popup");
2269: if (subMenu != null) {
2270: subMenu
2271: .add(createMenuAction(
2272: loadString("IDS_POPUP_LINK_END_ORDINARY_AGGREGATE"),
2273: "MBK_LINK_END_ORDINARY_AGGREGATE"));
2274: subMenu
2275: .add(createMenuAction(
2276: loadString("IDS_POPUP_LINK_END_COMPOSITE_AGGREGATE"),
2277: "MBK_LINK_END_COMPOSITE_AGGREGATE"));
2278: subMenu.add(createMenuAction(
2279: loadString("IDS_POPUP_LINK_END_REMOVE_AGGREGATE"),
2280: "MBK_LINK_END_REMOVE_AGGREGATE"));
2281: subMenu.add(createMenuAction(
2282: loadString("IDS_POPUP_LINK_END_NAVIGABLE"),
2283: "MBK_LINK_END_NAVIGABLE"));
2284: subMenu.add(createMenuAction(
2285: loadString("IDS_POPUP_LINK_END_REVERSE_ENDS"),
2286: "MBK_LINK_END_REVERSE_ENDS"));
2287: //manager.add(subMenu);
2288: }
2289: }
2290:
2291: /*
2292: * Loads a string from default resource bundle.
2293: */
2294: public String loadString(String key) {
2295: try {
2296: return RESOURCE_BUNDLE.getString(key);
2297: } catch (MissingResourceException e) {
2298: return '!' + key + '!';
2299: }
2300: }
2301:
2302: public void addSeparatorMenuItem(IMenuManager manager) {
2303: manager.add(new Separator());
2304: }
2305:
2306: /**
2307: * Is this draw engine valid for this model element?
2308: *
2309: * @return true if this draw engine can correctly represent the attached model element.
2310: */
2311: public boolean isDrawEngineValidForModelElement() {
2312: // Base draw engine always returns true
2313: return true;
2314: }
2315:
2316: /**
2317: * Returns the first IElement off the presentation element
2318: */
2319: public IElement getFirstModelElement() {
2320: return TypeConversions.getElement(this );
2321: }
2322:
2323: public UIResources getResources() {
2324: if (m_resources == null)
2325: m_resources = new UIResources();
2326: return m_resources;
2327: }
2328:
2329: /* (non-Javadoc)
2330: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#getResourceName(int)
2331: */
2332: public String getResourceName(int nKind) {
2333:
2334: String retValue = "";
2335:
2336: switch (nKind) {
2337: case UIResources.CK_FONT:
2338: retValue = "name";
2339: break;
2340: case UIResources.CK_TEXTCOLOR:
2341: retValue = "name";
2342: break;
2343: case UIResources.CK_FILLCOLOR:
2344: ETList<IDrawingProperty> pDrawingProperties = getDrawingProperties();
2345: for (int i = 0; i < pDrawingProperties.size(); i++) {
2346: IDrawingProperty pDrawingProperty = pDrawingProperties
2347: .get(i);
2348: if (pDrawingProperty.getResourceType().equals("color")
2349: && pDrawingProperty.getResourceName().indexOf(
2350: "fill") > 0) {
2351: retValue = pDrawingProperty.getResourceName();
2352: break;
2353: }
2354: }
2355: break;
2356: case UIResources.CK_BORDERCOLOR:
2357: pDrawingProperties = getDrawingProperties();
2358: for (int i = 0; i < pDrawingProperties.size(); i++) {
2359: IDrawingProperty pDrawingProperty = pDrawingProperties
2360: .get(i);
2361: if (pDrawingProperty.getResourceType().equals("color")
2362: && pDrawingProperty.getResourceName().indexOf(
2363: "border") > 0) {
2364: retValue = pDrawingProperty.getResourceName();
2365: break;
2366: }
2367: }
2368: break;
2369: }
2370: return retValue;
2371: }
2372:
2373: /* (non-Javadoc)
2374: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#setFontResource()
2375: */
2376: public void setFontResource(int resourceKind, Font font) {
2377: // code refactored from font menu handling in ADCoreEngine
2378: if (font != null) {
2379: int weight = 400;
2380: if (font.isBold()) {
2381: weight = 700;
2382: }
2383: String resourceName = getResourceName(resourceKind);
2384: resetToDefaultResource(getDrawEngineID(), resourceName,
2385: "font");
2386: saveFont(getDrawEngineID(), resourceName, font.getName(),
2387: font.getSize(), weight, font.isItalic(),
2388: Color.BLACK.getRGB());
2389: invalidateProvider();
2390: }
2391: }
2392:
2393: /* (non-Javadoc)
2394: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#setColorResource()
2395: */
2396: public void setColorResource(int resourceKind, Color color) {
2397: // code refactored from color menu handling in ADCoreEngine
2398: if (color != null) {
2399: String resourceName = getResourceName(resourceKind);
2400: if (resourceKind == UIResources.CK_TEXTCOLOR) {
2401: resetToDefaultResource(getDrawEngineID(), resourceName,
2402: "color");
2403: }
2404: saveColor(getDrawEngineID(), resourceName, color.getRGB());
2405: invalidateProvider();
2406: }
2407: }
2408:
2409: public boolean setSensitivityAndCheck(String id,
2410: ContextMenuActionClass pClass) {
2411: return false;
2412: }
2413:
2414: public boolean onHandleButton(ActionEvent e, String id) {
2415: return false;
2416: }
2417:
2418: /**
2419: * Tests to determine if the associated parent diagram is readonly.
2420: *
2421: * @return true if the parent diagram is readonly
2422: */
2423: protected boolean isParentDiagramReadOnly() {
2424: IDiagram dia = getDiagram();
2425: return dia != null ? dia.getReadOnly() : true;
2426: }
2427:
2428: /*
2429: * Searches through all the compartments looking for the specified compartment
2430: */
2431: public <Type> Type getCompartmentByKind(Class interfacetype) {
2432: try {
2433: IteratorT<ICompartment> iter = new IteratorT<ICompartment>(
2434: this .getCompartments());
2435: while (iter.hasNext()) {
2436: ICompartment comp = iter.next();
2437: if (interfacetype.isAssignableFrom(comp.getClass()))
2438: return (Type) comp;
2439: }
2440: } catch (Exception e) {
2441: e.printStackTrace();
2442: }
2443: return null;
2444: }
2445:
2446: /**
2447: * Returns the meta type of the IElement this draw engine represents.
2448: *
2449: * @return The metatype of the element this draw engine represents.
2450: */
2451: protected String getMetaTypeOfElement() {
2452: IElement pEle = TypeConversions.getElement(this );
2453: return pEle != null ? pEle.getElementType() : null;
2454: }
2455:
2456: public double getLastDrawPointWorldY() {
2457: return 0;
2458: }
2459:
2460: public void setLastDrawPointWorldY(double i) {
2461: }
2462:
2463: public void updateLastDrawPointWorldY(double d) {
2464: }
2465:
2466: /*
2467: *
2468: */
2469: public void setManagerBackpointer(IGraphObjectManager pManager) {
2470: // this is gross, but we aren't getting the same types as the cleaner C++ version,
2471: // for whatever reason, so the conversion has to happen here
2472: if (pManager != null
2473: && getParentETElement() instanceof IETGraphObject) {
2474: IETGraphObject object = (IETGraphObject) getParentETElement();
2475: pManager.setParentETGraphObject(object);
2476: }
2477: }
2478:
2479: /**
2480: * Posts and invalidate to the drawing area.
2481: */
2482: protected void postInvalidate() {
2483: try {
2484: IDrawingAreaControl pDA = this .getDrawingArea();
2485:
2486: if (pDA != null) {
2487: // Find the presentation element associated with this draw engine
2488: IPresentationElement pPresentationElement = getPresentationElement();
2489: if (pPresentationElement != null) {
2490: pDA.postInvalidate(pPresentationElement);
2491: }
2492: }
2493: } catch (Exception e) {
2494: e.printStackTrace();
2495: }
2496: }
2497:
2498: /*
2499: * Dispatches draw to all the compartments
2500: */
2501: public void dispatchDrawToCompartments(IDrawInfo pInfo,
2502: IETRect pDeviceBounds) {
2503: try {
2504: IteratorT<ICompartment> iter = new IteratorT<ICompartment>(
2505: this .getCompartments());
2506: while (iter.hasNext()) {
2507: iter.next().draw(pInfo, pDeviceBounds);
2508: }
2509: } catch (Exception e) {
2510: e.printStackTrace();
2511: }
2512: }
2513:
2514: public ContextMenuActionClass createMenuAction(String text,
2515: String menuID) {
2516: return new ContextMenuActionClass(this , text, menuID);
2517: }
2518:
2519: public boolean parentDiagramIsReadOnly() {
2520: IDiagram pDiagram = getDiagram();
2521: return pDiagram != null ? pDiagram.getReadOnly() : true;
2522: }
2523:
2524: // Resource user
2525: public ETList<IDrawingProperty> getDrawingProperties() {
2526: String sDrawEngineID = getDrawEngineID();
2527: if (sDrawEngineID != null && sDrawEngineID.length() > 0) {
2528: return m_ResourceUser.getDrawingProperties(this ,
2529: sDrawEngineID);
2530: }
2531:
2532: return null;
2533: }
2534:
2535: public void saveColor(String sDrawEngineType, String sResourceName,
2536: int nColor) {
2537: setIsDirty();
2538: m_ResourceUser
2539: .saveColor(sDrawEngineType, sResourceName, nColor);
2540: }
2541:
2542: public void saveColor2(IColorProperty pProperty) {
2543: setIsDirty();
2544: m_ResourceUser.saveColor2(pProperty);
2545: }
2546:
2547: public void saveFont(String sDrawEngineName, String sResourceName,
2548: String sFaceName, int nHeight, int nWeight,
2549: boolean bItalic, int nColor) {
2550: setIsDirty();
2551: m_ResourceUser.saveFont(sDrawEngineName, sResourceName,
2552: sFaceName, nHeight, nWeight, bItalic, nColor);
2553: }
2554:
2555: public void saveFont2(IFontProperty pProperty) {
2556: setIsDirty();
2557: m_ResourceUser.saveFont2(pProperty);
2558: }
2559:
2560: public void resetToDefaultResource(String sDrawEngineName,
2561: String sResourceName, String sResourceType) {
2562: setIsDirty();
2563: m_ResourceUser.resetToDefaultResource(sDrawEngineName,
2564: sResourceName, sResourceType);
2565:
2566: // Reset our child compartments
2567: int numCompartments = getNumCompartments();
2568: for (int i = 0; i < numCompartments; i++) {
2569: ICompartment cpCompartment = getCompartment(i);
2570: IDrawingPropertyProvider pCompProvider = (IDrawingPropertyProvider) cpCompartment;
2571: if (pCompProvider != null) {
2572: pCompProvider.resetToDefaultResource(sDrawEngineName,
2573: sResourceName, sResourceType);
2574: }
2575: }
2576:
2577: initResources();
2578: //invalidateProvider();
2579: }
2580:
2581: public void resetToDefaultResources() {
2582: setIsDirty();
2583: m_ResourceUser.resetToDefaultResources();
2584:
2585: // Reset our child compartments
2586: int numCompartments = getNumCompartments();
2587: for (int i = 0; i < numCompartments; i++) {
2588: ICompartment cpCompartment = getCompartment(i);
2589: IDrawingPropertyProvider pCompProvider = (IDrawingPropertyProvider) cpCompartment;
2590: if (pCompProvider != null) {
2591: pCompProvider.resetToDefaultResources();
2592: }
2593: }
2594:
2595: initResources();
2596: invalidateProvider();
2597: }
2598:
2599: public void resetToDefaultResources2(String sDrawEngineName) {
2600: if (sDrawEngineName != null && sDrawEngineName.length() > 0) {
2601: String sDrawEngineID = getDrawEngineID();
2602: if (sDrawEngineID != null
2603: && sDrawEngineID.equals(sDrawEngineName)) {
2604: resetToDefaultResources();
2605: }
2606: }
2607: }
2608:
2609: public void dumpToFile(String sFile, boolean bDumpChildren,
2610: boolean bAppendToExistingFile) {
2611: m_ResourceUser.dumpToFile(sFile, bAppendToExistingFile);
2612:
2613: if (bDumpChildren) {
2614: // Reset our child compartments
2615: int numCompartments = getNumCompartments();
2616: for (int i = 0; i < numCompartments; i++) {
2617: ICompartment cpCompartment = getCompartment(i);
2618: IDrawingPropertyProvider pCompProvider = (IDrawingPropertyProvider) cpCompartment;
2619: if (pCompProvider != null) {
2620: pCompProvider.dumpToFile(sFile, true, true);
2621: }
2622: }
2623: }
2624: }
2625:
2626: public boolean displayFontDialog(IFontProperty pProperty) {
2627: return m_ResourceUser.displayFontDialog(pProperty);
2628: }
2629:
2630: public boolean displayColorDialog(IColorProperty pProperty) {
2631: return m_ResourceUser.displayColorDialog(pProperty);
2632: }
2633:
2634: public void invalidateProvider() {
2635: invalidate();
2636: // This will enbale engine redraw immediatly, but with problems for some case. See J909
2637: // IDrawingAreaControl drawingArea = getDrawingArea();
2638: //
2639: // if (drawingArea != null)
2640: // drawingArea.refresh(false);
2641: }
2642:
2643: // IResourceUserHelper
2644: public int getColorID(int nColorStringID) {
2645: int nID = -1;
2646:
2647: if (nColorStringID != -1) {
2648: Integer iterator = m_ResourceUser.m_Colors.get(new Integer(
2649: nColorStringID));
2650: if (iterator != null) {
2651: // Our color has been cached from the last time
2652: int nTempID = iterator.intValue();
2653:
2654: // Make sure the id is valid, if not then re-get a good
2655: // id from our draw engine.
2656: if (nTempID == -1
2657: || m_ResourceUser.getResourceMgr()
2658: .isValidColorID(nTempID) == false) {
2659: m_ResourceUser.m_Colors.remove(new Integer(
2660: nColorStringID));
2661: } else {
2662: nID = nTempID;
2663: }
2664: }
2665: }
2666:
2667: // Get it from the resource manager
2668: if (nID == -1 && m_ResourceUser.verifyDrawEngineStringID()) {
2669: // Get the id from the diagram
2670: nID = m_ResourceUser.getResourceMgr().getColorID(
2671: m_ResourceUser.m_nDrawEngineStringID,
2672: nColorStringID);
2673: if (nID != -1) {
2674: m_ResourceUser.m_Colors.put(
2675: new Integer(nColorStringID), new Integer(nID));
2676:
2677: // Reset the draw time so we re-get our draw information
2678: //setLastDrawTime(true);
2679: }
2680: }
2681:
2682: return nID;
2683: }
2684:
2685: public int getFontID(int nFontStringID) {
2686: int nID = -1;
2687:
2688: if (nFontStringID != -1) {
2689: Integer iterator = m_ResourceUser.m_Fonts.get(new Integer(
2690: nFontStringID));
2691: if (iterator != null) {
2692: // Our font has been cached from the last time
2693: int nTempID = iterator.intValue();
2694:
2695: // Make sure the id is valid, if not then re-get a good
2696: // id from our draw engine.
2697: if (nTempID == -1
2698: || m_ResourceUser.getResourceMgr()
2699: .isValidFontID(nTempID) == false) {
2700: m_ResourceUser.m_Fonts.remove(new Integer(
2701: nFontStringID));
2702: } else {
2703: nID = nTempID;
2704: }
2705: }
2706:
2707: // Get it from the resource manager
2708: if (nID == -1 && m_ResourceUser.verifyDrawEngineStringID()) {
2709: // Get the id from the diagram
2710: nID = m_ResourceUser.getResourceMgr().getFontID(
2711: m_ResourceUser.m_nDrawEngineStringID,
2712: nFontStringID);
2713:
2714: if (nID != -1) {
2715: m_ResourceUser.m_Fonts.put(new Integer(
2716: nFontStringID), new Integer(nID));
2717: }
2718: }
2719: }
2720: return nID;
2721: }
2722:
2723: public boolean verifyDrawEngineStringID() {
2724: boolean bIDOK = true;
2725:
2726: if (m_ResourceUser.m_nDrawEngineStringID == -1) {
2727: String sDrawEngineID = getDrawEngineID();
2728: if (sDrawEngineID.length() > 0) {
2729: // Set the draw engine string id on the resource user
2730: m_ResourceUser.setDrawEngineStringID(sDrawEngineID);
2731: if (m_ResourceUser.m_nDrawEngineStringID == -1) {
2732: bIDOK = false;
2733: }
2734: }
2735: }
2736:
2737: return bIDOK;
2738: }
2739:
2740: /*
2741: * Returns true if this Engine has been Initialized
2742: */
2743: public boolean isInitialized() {
2744: return m_bInitResources;
2745: }
2746:
2747: // public int convertCPPColor( int cppColor)
2748: // {
2749: // int b = cppColor >> 16;
2750: // int g = (cppColor >> 8) - (b << 8);
2751: // int r = cppColor - (b << 16) - (g << 8);
2752: // Color pColor = new Color(r, g, b);
2753: // return pColor.getRGB();
2754: // }
2755:
2756: protected SmartDragTool createSmartDragTool(MouseEvent pEvent) {
2757: SmartDragTool dragTool = null;
2758: IDrawingAreaControl daCtrl = getDrawingArea();
2759: ADGraphWindow graphWindow = daCtrl != null ? daCtrl
2760: .getGraphWindow() : null;
2761:
2762: if (daCtrl != null && graphWindow != null) {
2763: TSGraphObject graphObject = getOwnerGraphObject();
2764: TSEObject tseObject = graphObject instanceof TSEObject ? (TSEObject) graphObject
2765: : null;
2766:
2767: if (tseObject != null) {
2768: if (!pEvent.isControlDown()) {
2769: graphWindow.deselectAll(true);
2770: }
2771:
2772: graphWindow.selectObject(tseObject, true);
2773: }
2774:
2775: IETPoint startPoint = daCtrl.deviceToLogicalPoint(pEvent
2776: .getX(), pEvent.getY());
2777: // Don't create the drag tool and then change the selection.
2778: dragTool = new SmartDragTool(new TSConstPoint(startPoint
2779: .getX(), startPoint.getY()), daCtrl, false);
2780:
2781: if (dragTool != null) {
2782: TSEGraph graph = graphWindow.getGraph();
2783: dragTool.setGraph(graph);
2784: dragTool.setDrawingAreaControl(daCtrl);
2785: }
2786: }
2787: return dragTool;
2788: }
2789:
2790: /*
2791: * Returns the Scaled size in device units, you must pass a size calculated at zoom level 1.0
2792: */
2793: public IETSize scaleSize(final IETSize sizeAtOneHundred,
2794: TSTransform windowTransform) {
2795: if (windowTransform != null && sizeAtOneHundred != null) {
2796: TSTransform transform = (TSTransform) windowTransform
2797: .clone();
2798: transform.setScale(1.0);
2799: double worldSizeX = transform.widthToWorld(sizeAtOneHundred
2800: .getWidth());
2801: double worldSizeY = transform
2802: .heightToWorld(sizeAtOneHundred.getHeight());
2803: Dimension d = windowTransform.sizeToDevice(worldSizeX,
2804: worldSizeY);
2805:
2806: return d != null ? new ETSize(d.width, d.height) : null;
2807: }
2808: return null;
2809: }
2810:
2811: /**
2812: * Calculates the node's device coordinates given a Tom Sawyer mouse event.
2813: */
2814: public IETRect getLogicalBoundingRect() {
2815: IETGraphObjectUI ui = this .getParent();
2816: return ui != null && ui.getOwner() != null ? new ETRectEx(ui
2817: .getBounds()) : null;
2818: }
2819:
2820: public int getLastResizeOriginator() {
2821: return m_LastResizeOriginator;
2822: }
2823:
2824: public void setLastResizeOriginator(int i) {
2825: m_LastResizeOriginator = i;
2826: }
2827:
2828: /**
2829: * Displays the navigation dialog - used during doubleclicks
2830: */
2831: public void displayNavigationDialog() {
2832: // Bring up a dialog allowing user to go to either diagrams or PE's
2833: IDiagramAndPresentationNavigator pNavigator = new DiagramAndPresentationNavigator();
2834: if (pNavigator != null) {
2835: boolean bMeHandled = false;
2836: ETSmartWaitCursor waitCursor = new ETSmartWaitCursor();
2837: IElement pFirstME = getFirstModelElement();
2838: if (pFirstME != null) {
2839: bMeHandled = pNavigator.handleNavigation(0, pFirstME,
2840: true);
2841: }
2842: waitCursor.stop();
2843: }
2844: }
2845:
2846: /*
2847: * (non-Javadoc)
2848: * @see org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine#onDiscardParentETElement()
2849: */
2850: public void onDiscardParentETElement() {
2851: clearCompartments();
2852: m_parentUI = null;
2853: }
2854:
2855: /////////////
2856: // Accessible
2857: /////////////
2858:
2859: AccessibleContext accessibleContext;
2860:
2861: public AccessibleContext getAccessibleContext() {
2862: if (accessibleContext == null) {
2863: accessibleContext = new AccessibleETDrawEngine();
2864: }
2865: return accessibleContext;
2866: }
2867:
2868: public class AccessibleETDrawEngine extends AccessibleContext
2869: implements AccessibleComponent, AccessibleSelection {
2870:
2871: public Locale getLocale() {
2872: return getGraphWindow().getLocale();
2873: }
2874:
2875: public int getAccessibleIndexInParent() {
2876: return 0;
2877: }
2878:
2879: public AccessibleStateSet getAccessibleStateSet() {
2880: return new AccessibleStateSet(new AccessibleState[] {
2881: AccessibleState.SHOWING, AccessibleState.VISIBLE,
2882: AccessibleState.ENABLED, AccessibleState.FOCUSABLE,
2883: AccessibleState.RESIZABLE,
2884: AccessibleState.SELECTABLE });
2885: }
2886:
2887: public String getAccessibleName() {
2888: String acName = "";
2889: IElement pEle = TypeConversions
2890: .getElement(ETDrawEngine.this );
2891: if (pEle != null) {
2892: String eleType = pEle.getElementType();
2893: if (eleType != null && eleType.length() > 0) {
2894: String expandedType = pEle.getExpandedElementType();
2895: if (expandedType != null) {
2896: String captionKey = "IDS_"
2897: + expandedType.toUpperCase();
2898: String caption = loadString(captionKey);
2899: if (!caption.equals("!" + captionKey + "!")) {
2900: eleType = caption;
2901: }
2902: }
2903: acName = eleType;
2904:
2905: String name = "";
2906: if (pEle instanceof INamedElement) {
2907: name = ((INamedElement) pEle).getName();
2908: }
2909: acName += " " + name;
2910: }
2911: }
2912: return acName;
2913: }
2914:
2915: public String getAccessibleDescription() {
2916: return getAccessibleName();
2917: }
2918:
2919: public AccessibleRole getAccessibleRole() {
2920: return AccessibleRole.PANEL;
2921: }
2922:
2923: public int getAccessibleChildrenCount() {
2924: return getAccessibleChildren().size();
2925: }
2926:
2927: public Accessible getAccessibleChild(int i) {
2928: if (i < getAccessibleChildrenCount()) {
2929: return getAccessibleChildren().get(i);
2930: }
2931: return null;
2932: }
2933:
2934: public AccessibleRelationSet getAccessibleRelationSet() {
2935: AccessibleRelationSet relSet = new AccessibleRelationSet();
2936: ILabelManager labelMgr = getLabelManager();
2937: if (labelMgr != null) {
2938: ArrayList<IDrawEngine> engines = new ArrayList<IDrawEngine>();
2939: for (int lIndx = 0; /* break below */; lIndx++) {
2940: IETLabel label = null;
2941: label = labelMgr.getLabelByIndex(lIndx);
2942: if (label != null) {
2943: IDrawEngine eng = label.getEngine();
2944: if (eng != null) {
2945: engines.add(eng);
2946: }
2947: } else {
2948: break;
2949: }
2950: }
2951: if (engines.size() > 0) {
2952: AccessibleRelation labeledBy = new AccessibleRelation(
2953: AccessibleRelation.LABELED_BY, engines
2954: .toArray());
2955: relSet.add(labeledBy);
2956: }
2957: }
2958: return relSet;
2959: }
2960:
2961: public AccessibleComponent getAccessibleComponent() {
2962: return this ;
2963: }
2964:
2965: public AccessibleSelection getAccessibleSelection() {
2966: int childnum = getAccessibleChildrenCount();
2967: for (int i = 0; i < getAccessibleChildrenCount(); i++) {
2968: if (isSelectable(getAccessibleChild(i))) {
2969: return this ;
2970: }
2971: }
2972: return null;
2973: }
2974:
2975: ////////////////////////////////
2976: // interface AccessibleComponent
2977: ////////////////////////////////
2978:
2979: public java.awt.Color getBackground() {
2980: return null;
2981: }
2982:
2983: public void setBackground(java.awt.Color color) {
2984: ;
2985: }
2986:
2987: public java.awt.Color getForeground() {
2988: return null;
2989: }
2990:
2991: public void setForeground(java.awt.Color color) {
2992: ;
2993: }
2994:
2995: public java.awt.Cursor getCursor() {
2996: return getGraphWindow().getCursor();
2997: }
2998:
2999: public void setCursor(java.awt.Cursor cursor) {
3000: ;
3001: }
3002:
3003: public java.awt.Font getFont() {
3004: return null;
3005: }
3006:
3007: public void setFont(java.awt.Font font) {
3008: ;
3009: }
3010:
3011: public java.awt.FontMetrics getFontMetrics(java.awt.Font font) {
3012: return getGraphWindow().getFontMetrics(font);
3013: }
3014:
3015: public boolean isEnabled() {
3016: return true;
3017: }
3018:
3019: public void setEnabled(boolean enabled) {
3020:
3021: }
3022:
3023: public boolean isVisible() {
3024: return true;
3025: }
3026:
3027: public void setVisible(boolean visible) {
3028: ;
3029: }
3030:
3031: public boolean isShowing() {
3032: return true;
3033: }
3034:
3035: public boolean contains(java.awt.Point point) {
3036: Rectangle r = getBounds();
3037: return r.contains(point);
3038: }
3039:
3040: public java.awt.Point getLocationOnScreen() {
3041: IETRect scRect = getWinScreenRect();
3042: if (scRect != null) {
3043: return new java.awt.Point(scRect.getIntX(), scRect
3044: .getIntY());
3045: }
3046: return null;
3047: }
3048:
3049: public java.awt.Point getLocation() {
3050: AccessibleComponent parentComponent = accessibleParent
3051: .getAccessibleContext().getAccessibleParent()
3052: .getAccessibleContext().getAccessibleComponent();
3053: if (parentComponent != null) {
3054: java.awt.Point parentLocation = parentComponent
3055: .getLocationOnScreen();
3056: java.awt.Point componentLocation = getLocationOnScreen();
3057: if (parentLocation != null && componentLocation != null) {
3058: return new java.awt.Point(parentLocation.x
3059: - componentLocation.x, parentLocation.y
3060: - componentLocation.y);
3061: }
3062: }
3063: return null;
3064: }
3065:
3066: public void setLocation(java.awt.Point point) {
3067: ;
3068: }
3069:
3070: public java.awt.Rectangle getBounds() {
3071: IETRect clientRect = getWinClientRect();
3072: java.awt.Point loc = getLocation();
3073: if (clientRect != null && loc != null) {
3074: return new Rectangle(loc.x, loc.y, clientRect
3075: .getIntWidth(), clientRect.getIntHeight());
3076: }
3077: return null;
3078: }
3079:
3080: public void setBounds(java.awt.Rectangle bounds) {
3081: setWinClientRectangle(new ETRect(bounds.x, bounds.y,
3082: bounds.width, bounds.height));
3083: }
3084:
3085: public java.awt.Dimension getSize() {
3086: Rectangle r = getBounds();
3087: return new Dimension(r.width, r.height);
3088: }
3089:
3090: public void setSize(java.awt.Dimension dim) {
3091: setScaledSize(new ETSize(dim.width, dim.height));
3092: }
3093:
3094: public javax.accessibility.Accessible getAccessibleAt(
3095: java.awt.Point point) {
3096: //getCompartmentAtPoint(IETPoint pCurrentPos)
3097: return null;
3098: }
3099:
3100: public boolean isFocusTraversable() {
3101: return true;
3102: }
3103:
3104: public void requestFocus() {
3105: ;
3106: }
3107:
3108: public void addFocusListener(
3109: java.awt.event.FocusListener listener) {
3110: ;
3111: }
3112:
3113: public void removeFocusListener(
3114: java.awt.event.FocusListener listener) {
3115: ;
3116: }
3117:
3118: ////////////////////////////////
3119: // interface AccessibleSelection
3120: ////////////////////////////////
3121:
3122: public int getAccessibleSelectionCount() {
3123: List<Accessible> selected = getSelectedAccessibleChildren();
3124: if (selected != null) {
3125: return selected.size();
3126: }
3127: return 0;
3128: }
3129:
3130: public Accessible getAccessibleSelection(int i) {
3131: List<Accessible> selected = getSelectedAccessibleChildren();
3132: if (selected != null && i < selected.size()) {
3133: return selected.get(i);
3134: }
3135: return null;
3136: }
3137:
3138: public boolean isAccessibleChildSelected(int i) {
3139: Accessible child = getAccessibleChild(i);
3140: if (child != null) {
3141: return isSelected(child);
3142: }
3143: return false;
3144: }
3145:
3146: public void addAccessibleSelection(int i) {
3147: Accessible child = getAccessibleChild(i);
3148: if (child != null) {
3149: selectChild(child, true, false);
3150: }
3151: }
3152:
3153: public void removeAccessibleSelection(int i) {
3154: List<Accessible> children = getAccessibleChildren();
3155: if (children != null && i < children.size()) {
3156: selectChild(children.get(i), false, false);
3157: }
3158: }
3159:
3160: public void selectAllAccessibleSelection() {
3161: List<Accessible> children = getAccessibleChildren();
3162: if (children != null) {
3163: for (int i = 0; i < children.size(); i++) {
3164: selectChild(children.get(i), true, false);
3165: }
3166: }
3167: }
3168:
3169: public void clearAccessibleSelection() {
3170: List<Accessible> selected = getSelectedAccessibleChildren();
3171: if (selected != null) {
3172: for (int i = 0; i < selected.size(); i++) {
3173: selectChild(selected.get(i), false, true);
3174: }
3175: }
3176: }
3177:
3178: /////////////////
3179: // Helper methods
3180: /////////////////
3181:
3182: public void selectChild(Accessible child, boolean select,
3183: boolean replaceSelection) {
3184:
3185: if (child instanceof ICompartment) {
3186: if (replaceSelection) {
3187: selectAllCompartments(false);
3188: }
3189: ((ICompartment) child).setSelected(select);
3190: }
3191:
3192: if (accessibleParent != null
3193: && accessibleParent.getAccessibleContext() instanceof AccessibleSelectionParent) {
3194: ((AccessibleSelectionParent) accessibleParent
3195: .getAccessibleContext()).selectChild(
3196: ETDrawEngine.this , select, replaceSelection);
3197: }
3198:
3199: }
3200:
3201: public boolean isSelectable(Accessible child) {
3202: AccessibleStateSet stateSet = child.getAccessibleContext()
3203: .getAccessibleStateSet();
3204: if (stateSet != null
3205: && stateSet.contains(AccessibleState.SELECTABLE)) {
3206: return true;
3207: }
3208: return false;
3209: }
3210:
3211: public boolean isSelected(Accessible child) {
3212: if (child instanceof ICompartment) {
3213: return ((ICompartment) child).isSelected();
3214: }
3215: return false;
3216: }
3217:
3218: public List<Accessible> getAccessibleChildren() {
3219: ArrayList<Accessible> children = new ArrayList<Accessible>();
3220: for (int i = 0; i < m_compartments.size(); i++) {
3221: ICompartment comp = m_compartments.get(i);
3222: if (comp instanceof Accessible) {
3223: ((Accessible) comp).getAccessibleContext()
3224: .setAccessibleParent(ETDrawEngine.this );
3225: children.add((Accessible) comp);
3226: }
3227:
3228: }
3229: return children;
3230: }
3231:
3232: public List<Accessible> getSelectedAccessibleChildren() {
3233: ArrayList<Accessible> selected = new ArrayList<Accessible>();
3234: List<Accessible> children = getAccessibleChildren();
3235: for (int i = 0; i < children.size(); i++) {
3236: Accessible child = children.get(i);
3237: if (isSelected(child)) {
3238: selected.add(child);
3239: }
3240: }
3241: return selected;
3242: }
3243:
3244: }
3245:
3246: }
|