#236763 proposed patch default
authorSergey B. Petrov <sj-nb@netbeans.org>
Sat, 05 Oct 2013 10:58:10 +0400
changeset 4455780b8b65f1
parent 43 a5dd444daeaf
child 45 06a2bfb5d607
#236763 proposed patch
uml.project/src/org/netbeans/modules/uml/project/ui/nodes/UMLElementNode.java
     1.1 --- a/uml.project/src/org/netbeans/modules/uml/project/ui/nodes/UMLElementNode.java	Sat Oct 05 10:56:08 2013 +0400
     1.2 +++ b/uml.project/src/org/netbeans/modules/uml/project/ui/nodes/UMLElementNode.java	Sat Oct 05 10:58:10 2013 +0400
     1.3 @@ -41,8 +41,6 @@
     1.4   * Version 2 license, then the option applies only if the new code is
     1.5   * made subject to such option by the copyright holder.
     1.6   */
     1.7 -
     1.8 -
     1.9  package org.netbeans.modules.uml.project.ui.nodes;
    1.10  
    1.11  import org.netbeans.modules.uml.core.metamodel.structure.IProject;
    1.12 @@ -59,6 +57,7 @@
    1.13  import javax.swing.Action;
    1.14  import javax.swing.Icon;
    1.15  import javax.swing.ImageIcon;
    1.16 +import java.util.List;
    1.17  
    1.18  import org.openide.actions.OpenAction;
    1.19  import org.openide.cookies.OpenCookie;
    1.20 @@ -79,6 +78,7 @@
    1.21  import org.netbeans.modules.uml.resources.images.ImageUtil;
    1.22  import org.netbeans.modules.uml.ui.controls.projecttree.IProjectTreeEventDispatcher;
    1.23  import org.netbeans.modules.uml.ui.controls.projecttree.IProjectTreeItem;
    1.24 +import org.netbeans.modules.uml.project.ui.NetBeansUMLProjectTreeModel;
    1.25  import org.netbeans.modules.uml.ui.controls.projecttree.ProjectTreeItemImpl;
    1.26  import org.netbeans.modules.uml.ui.support.DispatchHelper;
    1.27  import org.netbeans.modules.uml.ui.support.ProductHelper;
    1.28 @@ -89,138 +89,118 @@
    1.29  import org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem;
    1.30  import org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeRelElement;
    1.31  import org.netbeans.modules.uml.ui.support.projecttreesupport.ProjectTreeComparable;
    1.32 -
    1.33 +import org.openide.nodes.ChildFactory;
    1.34  
    1.35  /**
    1.36   *
    1.37   * @author Trey Spiva
    1.38   */
    1.39  public class UMLElementNode extends AbstractModelElementNode
    1.40 -	implements ITreeItem, CookieSet.Factory, Comparable
    1.41 -{
    1.42 -	private IProjectTreeItem m_Data = null;
    1.43 -	private String mPathAsString = ""; // NOI18N
    1.44 -	private Node.Cookie mOpenCookie = null;
    1.45 -	private Node.Cookie mModelElementCookie = null;
    1.46 -	
    1.47 -	/** Determines if the node has been initialized with children yet. */
    1.48 -	private boolean mIsInitialized = false;
    1.49 -	
    1.50 -	//Cache to speed up performance
    1.51 -	private Image icon=null;
    1.52 +        implements ITreeItem, CookieSet.Factory, Comparable {
    1.53 +
    1.54 +    private IProjectTreeItem m_Data = null;
    1.55 +    private String mPathAsString = ""; // NOI18N
    1.56 +    private Node.Cookie mOpenCookie = null;
    1.57 +    private Node.Cookie mModelElementCookie = null;
    1.58 +    /**
    1.59 +     * Determines if the node has been initialized with children yet.
    1.60 +     */
    1.61 +    private boolean mIsInitialized = false;
    1.62 +    //Cache to speed up performance
    1.63 +    private Image icon = null;
    1.64  //	private Action[] actions=null;
    1.65 -	
    1.66 -	/**
    1.67 -	 * Create a new UMLElementNode
    1.68 -	 */
    1.69 -	public UMLElementNode()
    1.70 -	{
    1.71 -		this(new ProjectTreeItemImpl());
    1.72 -		initCookies();
    1.73 -	}
    1.74 -	
    1.75 -	/**
    1.76 -	 *
    1.77 -	 */
    1.78 -	public UMLElementNode(Lookup lookup)
    1.79 -	{
    1.80 -		this(lookup, new ProjectTreeItemImpl());
    1.81 -	}
    1.82 -	
    1.83 -	/**
    1.84 -	 * Create a new UMLElementNode
    1.85 -	 */
    1.86 -	public UMLElementNode(Children ch, Lookup lookup)
    1.87 -	{
    1.88 -		this(ch, lookup, new ProjectTreeItemImpl());
    1.89 -	}
    1.90 -	
    1.91 -	/**
    1.92 -	 * Create a new UMLElementNode and initialize its data with the information
    1.93 -	 * from an IProjectTreeItem.
    1.94 -	 *
    1.95 -	 * @param item The ITreeItem used to initialize the new node.
    1.96 -	 * @see IProjectTreeItem
    1.97 -	 */
    1.98 -	public UMLElementNode(IProjectTreeItem data)
    1.99 -	{
   1.100 -		super(new UMLChildren());
   1.101 -		setData(data);
   1.102 -		setUpChildren();
   1.103 -		addProjectTreeItemCookie(data);
   1.104 -	}
   1.105 -	
   1.106 -	/**
   1.107 -	 * Create a new UMLElementNode and initialize its data with the information
   1.108 -	 * from an ITreeItem.
   1.109 -	 *
   1.110 -	 * @param item The ITreeItem used to initialize the new node.
   1.111 -	 * @see ITreeItem
   1.112 -	 */
   1.113 -	public UMLElementNode(ITreeItem item)
   1.114 -	{
   1.115 -		this(item.getData());
   1.116 -	}
   1.117 -	
   1.118 -	/**
   1.119 -	 * Create a new UMLElementNode and initialize its data with the information
   1.120 -	 * from an IProjectTreeItem.
   1.121 -	 */
   1.122 -	public UMLElementNode(Lookup lookup, IProjectTreeItem data)
   1.123 -	{
   1.124 -		super(new UMLChildren(), lookup);
   1.125 -		setData(data);
   1.126 -		//addChild(this);
   1.127 -		setUpChildren();
   1.128 -	}
   1.129 -	
   1.130 -	public UMLElementNode(Children ch, Lookup lookup, IProjectTreeItem data)
   1.131 -	{
   1.132 -		super(ch, lookup);
   1.133 -		setData(data);
   1.134 -		setUpChildren();
   1.135 -		//addChild(this);
   1.136 -		//setChildren(new UMLChildren(this));
   1.137 -	}
   1.138 -	
   1.139 -	
   1.140 -	
   1.141 -	protected void addProjectTreeItemCookie(IProjectTreeItem projectTreeItem)
   1.142 -	{
   1.143 -		getCookieSet().add(projectTreeItem);
   1.144 -	}
   1.145 -	
   1.146 -	/**
   1.147 -	 * Gathers the nodes children.
   1.148 -	 */
   1.149 -	public void setUpChildren()
   1.150 -	{
   1.151 -		Children ch = getChildren();
   1.152 -		if (ch != null && ch instanceof UMLChildren)
   1.153 -		{
   1.154 -			final UMLChildren children = (UMLChildren)ch;
   1.155 -			children.setItem(this);
   1.156 -		}
   1.157 -	}
   1.158 -	
   1.159 +
   1.160 +    /**
   1.161 +     * Create a new UMLElementNode
   1.162 +     */
   1.163 +    public UMLElementNode() {
   1.164 +        this(new ProjectTreeItemImpl());
   1.165 +        initCookies();
   1.166 +    }
   1.167 +
   1.168 +    /**
   1.169 +     *
   1.170 +     */
   1.171 +    public UMLElementNode(Lookup lookup) {
   1.172 +        this(lookup, new ProjectTreeItemImpl());
   1.173 +    }
   1.174 +
   1.175 +    /**
   1.176 +     * Create a new UMLElementNode
   1.177 +     */
   1.178 +    public UMLElementNode(Children ch, Lookup lookup) {
   1.179 +        this(ch, lookup, new ProjectTreeItemImpl());
   1.180 +    }
   1.181 +
   1.182 +    /**
   1.183 +     * Create a new UMLElementNode and initialize its data with the information
   1.184 +     * from an IProjectTreeItem.
   1.185 +     *
   1.186 +     * @param item The ITreeItem used to initialize the new node.
   1.187 +     * @see IProjectTreeItem
   1.188 +     */
   1.189 +    public UMLElementNode(IProjectTreeItem data) {
   1.190 +        super();
   1.191 +        setData(data);
   1.192 +        setUpChildren();
   1.193 +        addProjectTreeItemCookie(data);
   1.194 +    }
   1.195 +
   1.196 +    /**
   1.197 +     * Create a new UMLElementNode and initialize its data with the information
   1.198 +     * from an ITreeItem.
   1.199 +     *
   1.200 +     * @param item The ITreeItem used to initialize the new node.
   1.201 +     * @see ITreeItem
   1.202 +     */
   1.203 +    public UMLElementNode(ITreeItem item) {
   1.204 +        this(item.getData());
   1.205 +    }
   1.206 +
   1.207 +    /**
   1.208 +     * Create a new UMLElementNode and initialize its data with the information
   1.209 +     * from an IProjectTreeItem.
   1.210 +     */
   1.211 +    public UMLElementNode(Lookup lookup, IProjectTreeItem data) {
   1.212 +        super(lookup);
   1.213 +        setData(data);
   1.214 +        //addChild(this);
   1.215 +        //setUpChildren();
   1.216 +    }
   1.217 +
   1.218 +    public UMLElementNode(Children ch, Lookup lookup, IProjectTreeItem data) {
   1.219 +        super(ch, lookup);
   1.220 +        setData(data);
   1.221 +        setUpChildren();
   1.222 +        //addChild(this);
   1.223 +        //setChildren(new UMLChildren(this));
   1.224 +    }
   1.225 +
   1.226 +    protected void addProjectTreeItemCookie(IProjectTreeItem projectTreeItem) {
   1.227 +        getCookieSet().add(projectTreeItem);
   1.228 +    }
   1.229 +
   1.230 +    /**
   1.231 +     * Gathers the nodes children.
   1.232 +     */
   1.233 +    public void setUpChildren() {
   1.234 +        setChildren(Children.create(new UMLChildFactory(this), true));
   1.235 +    }
   1.236 +
   1.237      //**************************************************
   1.238      // ITreeItem Implementation
   1.239      //**************************************************
   1.240 +    public String getName() {
   1.241 +        IElement element = getModelElement();
   1.242  
   1.243 -   public String getName()
   1.244 -    {
   1.245 -        IElement element = getModelElement(); 
   1.246 -
   1.247 -        if (element instanceof INamedElement)
   1.248 -        {
   1.249 +        if (element instanceof INamedElement) {
   1.250              // return unformatted name for attributes and operations, so that
   1.251              // rename action on those nodes will display the bare name without
   1.252              // visibility modifier and type information, since we only support 
   1.253              // rename the name part of these two types of elements from project
   1.254              // tree
   1.255 -            if (element.getElementType().equals(ELEMENT_TYPE_ATTRIBUTE) ||
   1.256 -                    element.getElementType().equals(ELEMENT_TYPE_OPERATION))
   1.257 -            {
   1.258 +            if (element.getElementType().equals(ELEMENT_TYPE_ATTRIBUTE)
   1.259 +                    || element.getElementType().equals(ELEMENT_TYPE_OPERATION)) {
   1.260                  return (((INamedElement) element).getName());
   1.261              }
   1.262          }
   1.263 @@ -228,783 +208,732 @@
   1.264          return super.getName();
   1.265      }
   1.266  
   1.267 -    
   1.268 -   /* (non-Javadoc)
   1.269 -    * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setDisplayedName(java.lang.String)
   1.270 -    */
   1.271 -        public void setDisplayedName(String name)
   1.272 -        {
   1.273 -            setDisplayedName(name, true);
   1.274 +    /* (non-Javadoc)
   1.275 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setDisplayedName(java.lang.String)
   1.276 +     */
   1.277 +    public void setDisplayedName(String name) {
   1.278 +        setDisplayedName(name, true);
   1.279 +    }
   1.280 +
   1.281 +    /* (non-Javadoc)
   1.282 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setDisplayedName(java.lang.String,V)
   1.283 +     */
   1.284 +    public void setDisplayedName(String name, boolean buildProperties) {
   1.285 +        setDisplayName(name, buildProperties);
   1.286 +        if (getData() != null) {
   1.287 +            getData().setItemText(name);
   1.288          }
   1.289 -        
   1.290 -   /* (non-Javadoc)
   1.291 -    * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setDisplayedName(java.lang.String,V)
   1.292 -    */
   1.293 -        public void setDisplayedName(String name, boolean buildProperties)
   1.294 -        {
   1.295 -            setDisplayName(name, buildProperties);
   1.296 -            if (getData() != null)
   1.297 -                getData().setItemText(name);
   1.298 -            
   1.299 -            IElement element = getModelElement();
   1.300 -            
   1.301 -            if (element instanceof INamedElement)
   1.302 -            {
   1.303 -                // set the name of the node as well, so in edit mode, the new name
   1.304 -                // of the element will be displayed
   1.305 -                super.setName(((INamedElement)element).getName());
   1.306 -            }
   1.307 -            
   1.308 +
   1.309 +        IElement element = getModelElement();
   1.310 +
   1.311 +        if (element instanceof INamedElement) {
   1.312 +            // set the name of the node as well, so in edit mode, the new name
   1.313 +            // of the element will be displayed
   1.314 +            super.setName(((INamedElement) element).getName());
   1.315 +        }
   1.316 +
   1.317  //        else
   1.318  //            setName(name);
   1.319 +    }
   1.320 +
   1.321 +    public String getDisplayName() {
   1.322 +        String retVal = super.getDisplayName();
   1.323 +
   1.324 +        if (retVal == null || retVal.length() <= 0) {
   1.325 +            if (getData() != null) {
   1.326 +                retVal = getData().getItemText();
   1.327 +            }
   1.328          }
   1.329 -    
   1.330 -    
   1.331 -    public String getDisplayName()
   1.332 -    {
   1.333 -        String retVal = super.getDisplayName();
   1.334 -        
   1.335 -        if (retVal == null || retVal.length() <= 0)
   1.336 -        {
   1.337 -            if (getData() != null)
   1.338 -                retVal = getData().getItemText();
   1.339 +
   1.340 +        if (retVal == null || retVal.length() <= 0) {
   1.341 +            retVal = getName();
   1.342          }
   1.343 -        
   1.344 -        if (retVal == null || retVal.length() <= 0)
   1.345 -            retVal = getName();
   1.346 -        
   1.347 +
   1.348          return retVal;
   1.349      }
   1.350 -    
   1.351 -    
   1.352 -   /* (non-Javadoc)
   1.353 -    * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getDisplayedName()
   1.354 -    */
   1.355 -    public String getDisplayedName()
   1.356 -    {
   1.357 +
   1.358 +    /* (non-Javadoc)
   1.359 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getDisplayedName()
   1.360 +     */
   1.361 +    public String getDisplayedName() {
   1.362          return getDisplayName();
   1.363 -	}
   1.364 -	
   1.365 -	
   1.366 -	
   1.367 -   /* (non-Javadoc)
   1.368 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getPath()
   1.369 -	*/
   1.370 -	public Object[] getPath()
   1.371 -	{
   1.372 -		ArrayList parents = new ArrayList();
   1.373 -		
   1.374 -		while (getParentNode() != null)
   1.375 -		{
   1.376 -			parents.add(0, getParentNode());
   1.377 -		}
   1.378 -		
   1.379 -		Object[] retVal = new Object[parents.size()];
   1.380 -		parents.toArray(retVal);
   1.381 -		return retVal;
   1.382 -	}
   1.383 -	
   1.384 -   /* (non-Javadoc)
   1.385 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getPathAsString()
   1.386 -	*/
   1.387 -	public String getPathAsString()
   1.388 -	{
   1.389 -		//      StringBuffer retVal = new StringBuffer(getDisplayName());
   1.390 -		//
   1.391 -		////      ArrayList parents = new ArrayList();
   1.392 -		////
   1.393 -		////      while (getParentNode() != null)
   1.394 -		////      {
   1.395 -		////         retVal.insert(0, "|");
   1.396 -		////         retVal.insert(0, getParentNode().getDisplayName());
   1.397 -		////      }
   1.398 -		//
   1.399 -		//      Node parent = getParentNode();
   1.400 -		//      if(parent != null)
   1.401 -		//      {
   1.402 -		//
   1.403 -		//      }
   1.404 -		//
   1.405 -		//      return retVal.toString();
   1.406 -		
   1.407 -		return mPathAsString;
   1.408 -	}
   1.409 -	
   1.410 -   /* (non-Javadoc)
   1.411 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setPathAsString(java.lang.String)
   1.412 -	*/
   1.413 -	public void setPathAsString(String str)
   1.414 -	{
   1.415 -		mPathAsString = str;
   1.416 -	}
   1.417 -	
   1.418 -   /* (non-Javadoc)
   1.419 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#isSame(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem)
   1.420 -	*/
   1.421 -	public boolean isSame(ITreeItem queryItem)
   1.422 -	{
   1.423 -		return equals(queryItem);
   1.424 -	}
   1.425 -	
   1.426 -   /* (non-Javadoc)
   1.427 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getParentItem()
   1.428 -	*/
   1.429 -	public ITreeItem getParentItem()
   1.430 -	{
   1.431 -		ITreeItem retVal = null;
   1.432 -		Node parentNode = getParentNode();
   1.433 -		
   1.434 -		if (parentNode instanceof ITreeItem)
   1.435 -			retVal = (ITreeItem)parentNode;
   1.436 -		
   1.437 -		return retVal;
   1.438 -	}
   1.439 -	
   1.440 -   /* (non-Javadoc)
   1.441 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setParentItem(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem)
   1.442 -	*/
   1.443 -	public void setParentItem(ITreeItem parent)
   1.444 -	{
   1.445 -	}
   1.446 -	
   1.447 -   /* (non-Javadoc)
   1.448 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getTopParentItem()
   1.449 -	*/
   1.450 -	public ITreeItem getTopParentItem()
   1.451 -	{
   1.452 -		ITreeItem pTop = null;
   1.453 -		ITreeItem pItem = getParentItem();
   1.454 -		
   1.455 -		while (pItem != null)
   1.456 -		{
   1.457 -			pTop = pItem;
   1.458 -			ITreeItem pTemp = pTop.getParentItem();
   1.459 -			pItem = pTemp;
   1.460 -		}
   1.461 -		
   1.462 -		return pTop;
   1.463 -	}
   1.464 -	
   1.465 -   /* (non-Javadoc)
   1.466 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getOwningTreeElement()
   1.467 -	*/
   1.468 -	public ITreeElement getOwningTreeElement()
   1.469 -	{
   1.470 -		ITreeElement pOutEle = null;
   1.471 -		ITreeItem pLast = null;
   1.472 -		ITreeItem pItem = getParentItem();
   1.473 -		
   1.474 -		while (pItem != null)
   1.475 -		{
   1.476 -			pLast = pItem;
   1.477 -			
   1.478 -			if (pItem instanceof ITreeRelElement)
   1.479 -			{
   1.480 -				ITreeItem pTemp = pLast.getParentItem();
   1.481 -				pItem = pTemp;
   1.482 -			}
   1.483 -			
   1.484 -			else if (pItem instanceof ITreeElement)
   1.485 -				pItem = null;
   1.486 -			
   1.487 -			else
   1.488 -			{
   1.489 -				ITreeItem pTemp = pLast.getParentItem();
   1.490 -				pItem = pTemp;
   1.491 -			}
   1.492 -		}
   1.493 +    }
   1.494  
   1.495 -		if (pLast != null)
   1.496 -		{
   1.497 -			if (pLast instanceof ITreeElement)
   1.498 -				pOutEle = (ITreeElement)pLast;
   1.499 -		}
   1.500 -		
   1.501 -		return pOutEle;
   1.502 -	}
   1.503 -	
   1.504 -   /* (non-Javadoc)
   1.505 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getType()
   1.506 -	*/
   1.507 -	public String getType()
   1.508 -	{
   1.509 -		return null;
   1.510 -	}
   1.511 -	
   1.512 -   /* (non-Javadoc)
   1.513 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#addChild(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem)
   1.514 -	*/
   1.515 -	public void addChild(ITreeItem item)
   1.516 -	{
   1.517 +    /* (non-Javadoc)
   1.518 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getPath()
   1.519 +     */
   1.520 +    public Object[] getPath() {
   1.521 +        ArrayList parents = new ArrayList();
   1.522 +
   1.523 +        while (getParentNode() != null) {
   1.524 +            parents.add(0, getParentNode());
   1.525 +        }
   1.526 +
   1.527 +        Object[] retVal = new Object[parents.size()];
   1.528 +        parents.toArray(retVal);
   1.529 +        return retVal;
   1.530 +    }
   1.531 +
   1.532 +    /* (non-Javadoc)
   1.533 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getPathAsString()
   1.534 +     */
   1.535 +    public String getPathAsString() {
   1.536 +        //      StringBuffer retVal = new StringBuffer(getDisplayName());
   1.537 +        //
   1.538 +        ////      ArrayList parents = new ArrayList();
   1.539 +        ////
   1.540 +        ////      while (getParentNode() != null)
   1.541 +        ////      {
   1.542 +        ////         retVal.insert(0, "|");
   1.543 +        ////         retVal.insert(0, getParentNode().getDisplayName());
   1.544 +        ////      }
   1.545 +        //
   1.546 +        //      Node parent = getParentNode();
   1.547 +        //      if(parent != null)
   1.548 +        //      {
   1.549 +        //
   1.550 +        //      }
   1.551 +        //
   1.552 +        //      return retVal.toString();
   1.553 +
   1.554 +        return mPathAsString;
   1.555 +    }
   1.556 +
   1.557 +    /* (non-Javadoc)
   1.558 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setPathAsString(java.lang.String)
   1.559 +     */
   1.560 +    public void setPathAsString(String str) {
   1.561 +        mPathAsString = str;
   1.562 +    }
   1.563 +
   1.564 +    /* (non-Javadoc)
   1.565 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#isSame(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem)
   1.566 +     */
   1.567 +    public boolean isSame(ITreeItem queryItem) {
   1.568 +        return equals(queryItem);
   1.569 +    }
   1.570 +
   1.571 +    /* (non-Javadoc)
   1.572 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getParentItem()
   1.573 +     */
   1.574 +    public ITreeItem getParentItem() {
   1.575 +        ITreeItem retVal = null;
   1.576 +        Node parentNode = getParentNode();
   1.577 +
   1.578 +        if (parentNode instanceof ITreeItem) {
   1.579 +            retVal = (ITreeItem) parentNode;
   1.580 +        }
   1.581 +
   1.582 +        return retVal;
   1.583 +    }
   1.584 +
   1.585 +    /* (non-Javadoc)
   1.586 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setParentItem(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem)
   1.587 +     */
   1.588 +    public void setParentItem(ITreeItem parent) {
   1.589 +    }
   1.590 +
   1.591 +    /* (non-Javadoc)
   1.592 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getTopParentItem()
   1.593 +     */
   1.594 +    public ITreeItem getTopParentItem() {
   1.595 +        ITreeItem pTop = null;
   1.596 +        ITreeItem pItem = getParentItem();
   1.597 +
   1.598 +        while (pItem != null) {
   1.599 +            pTop = pItem;
   1.600 +            ITreeItem pTemp = pTop.getParentItem();
   1.601 +            pItem = pTemp;
   1.602 +        }
   1.603 +
   1.604 +        return pTop;
   1.605 +    }
   1.606 +
   1.607 +    /* (non-Javadoc)
   1.608 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getOwningTreeElement()
   1.609 +     */
   1.610 +    public ITreeElement getOwningTreeElement() {
   1.611 +        ITreeElement pOutEle = null;
   1.612 +        ITreeItem pLast = null;
   1.613 +        ITreeItem pItem = getParentItem();
   1.614 +
   1.615 +        while (pItem != null) {
   1.616 +            pLast = pItem;
   1.617 +
   1.618 +            if (pItem instanceof ITreeRelElement) {
   1.619 +                ITreeItem pTemp = pLast.getParentItem();
   1.620 +                pItem = pTemp;
   1.621 +            } else if (pItem instanceof ITreeElement) {
   1.622 +                pItem = null;
   1.623 +            } else {
   1.624 +                ITreeItem pTemp = pLast.getParentItem();
   1.625 +                pItem = pTemp;
   1.626 +            }
   1.627 +        }
   1.628 +
   1.629 +        if (pLast != null) {
   1.630 +            if (pLast instanceof ITreeElement) {
   1.631 +                pOutEle = (ITreeElement) pLast;
   1.632 +            }
   1.633 +        }
   1.634 +
   1.635 +        return pOutEle;
   1.636 +    }
   1.637 +
   1.638 +    /* (non-Javadoc)
   1.639 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getType()
   1.640 +     */
   1.641 +    public String getType() {
   1.642 +        return null;
   1.643 +    }
   1.644 +
   1.645 +    /* (non-Javadoc)
   1.646 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#addChild(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem)
   1.647 +     */
   1.648 +    public void addChild(ITreeItem item) {
   1.649          boolean canAdd = true;
   1.650 -		// <Sheryl> Do we really need this condition check? In case like 'Relationships' 
   1.651 -		// -> 'Specializations', these two folders both refer to the same 
   1.652 -		// model element, the sub-folder will not be added as a result, #6320478
   1.653 -		// to filter out the relationship end which refers to itself, it's temporary
   1.654 -		// we need to go back to visit the root cause in project tree impl
   1.655 +        // <Sheryl> Do we really need this condition check? In case like 'Relationships' 
   1.656 +        // -> 'Specializations', these two folders both refer to the same 
   1.657 +        // model element, the sub-folder will not be added as a result, #6320478
   1.658 +        // to filter out the relationship end which refers to itself, it's temporary
   1.659 +        // we need to go back to visit the root cause in project tree impl
   1.660          ITreeItem parent = getParentItem();
   1.661 -        if(parent != null)
   1.662 -        {
   1.663 +        if (parent != null) {
   1.664              String yourID = item.getData().getModelElementXMIID();
   1.665              String parentID = parent.getData().getModelElementXMIID();
   1.666 -			if (item instanceof ITreeFolder == false)
   1.667 -				canAdd = !yourID.equals(parentID);
   1.668 +            if (item instanceof ITreeFolder == false) {
   1.669 +                canAdd = !yourID.equals(parentID);
   1.670 +            }
   1.671          }
   1.672 -        if(canAdd == true)
   1.673 -        {            
   1.674 -            if (item instanceof Node)
   1.675 -            {
   1.676 -                Node[] node ={(Node)item};
   1.677 +        if (canAdd == true) {
   1.678 +            if (item instanceof Node) {
   1.679 +                Node[] node = {(Node) item};
   1.680                  Children children = getChildren();
   1.681  
   1.682 -                if (children != null)
   1.683 +                if (children != null) {
   1.684                      children.add(node);
   1.685 +                }
   1.686              }
   1.687          }
   1.688 -	}
   1.689 -	
   1.690 -   /* (non-Javadoc)
   1.691 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#insertAt(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem, int)
   1.692 -	*/
   1.693 -	public void insertAt(ITreeItem item, int index)
   1.694 -	{
   1.695 -		// The NetBeans API does not allow you to add a child to a specific
   1.696 -		// index.  The children are sorted so this is not neccessary.
   1.697 -		addChild(item);
   1.698 -	}
   1.699 -	
   1.700 -   /* (non-Javadoc)
   1.701 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#removeChild(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem)
   1.702 -	*/
   1.703 -	public void removeChild(ITreeItem item)
   1.704 -	{
   1.705 -		if (item instanceof Node)
   1.706 -		{
   1.707 -			Node[] node = {(Node)item};
   1.708 -			Children children = getChildren();
   1.709 -			
   1.710 -			if (children != null)
   1.711 -				children.remove(node);
   1.712 -		}
   1.713 -	}
   1.714 -	
   1.715 -   /* (non-Javadoc)
   1.716 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#removeAllChildren()
   1.717 -	*/
   1.718 -	public void removeAllChildren()
   1.719 -	{
   1.720 -		Children children = getChildren();
   1.721 -		
   1.722 -		if ((children != null) && (children.getNodesCount() > 0))
   1.723 -			children.remove(children.getNodes());
   1.724 -	}
   1.725 -	
   1.726 -   /* (non-Javadoc)
   1.727 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getChild(int)
   1.728 -	*/
   1.729 -	public ITreeItem getChild(int index)
   1.730 -	{
   1.731 -		// TODO Auto-generated method stub
   1.732 -		return null;
   1.733 -	}
   1.734 -	
   1.735 -   /* (non-Javadoc)
   1.736 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#sortChildren()
   1.737 -	*/
   1.738 -	public void sortChildren() 
   1.739 -	{
   1.740 -		((UMLChildren)getChildren()).recalculateChildren();
   1.741 -	}
   1.742 -	
   1.743 -   /* (non-Javadoc)
   1.744 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#sortChildren(java.util.Comparator)
   1.745 -	*/
   1.746 -	public void sortChildren(Comparator compare) {}
   1.747 -	
   1.748 -   /* (non-Javadoc)
   1.749 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getData()
   1.750 -	*/
   1.751 -	public IProjectTreeItem getData()
   1.752 -	{
   1.753 -		return m_Data;
   1.754 -	}
   1.755 -	
   1.756 -	protected void setData(IProjectTreeItem data)
   1.757 -	{
   1.758 -		m_Data = data;
   1.759 -		
   1.760 -		if (data != null)
   1.761 -			m_Data.setProjectTreeSupportTreeItem(this);
   1.762 -	}
   1.763 -	
   1.764 -   /* (non-Javadoc)
   1.765 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getChildCount()
   1.766 -	*/
   1.767 -	public int getChildCount()
   1.768 -	{
   1.769 -		int retVal = 0;
   1.770 -		Children children = getChildren();
   1.771 -		
   1.772 -		if (children != null)
   1.773 -			retVal = children.getNodesCount();
   1.774 -		
   1.775 -		return retVal;
   1.776 -	}
   1.777 -	
   1.778 -   /* (non-Javadoc)
   1.779 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#isInitalized()
   1.780 -	*/
   1.781 -	public boolean isInitalized()
   1.782 -	{
   1.783 -		// TODO Auto-generated method stub
   1.784 -		return mIsInitialized;
   1.785 -	}
   1.786 -	
   1.787 -   /* (non-Javadoc)
   1.788 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setIsInitalized(boolean)
   1.789 -	*/
   1.790 -	public void setIsInitalized(boolean value)
   1.791 -	{
   1.792 -		mIsInitialized = value;
   1.793 -	}
   1.794 -	
   1.795 -   /* (non-Javadoc)
   1.796 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getSortPriority()
   1.797 -	*/
   1.798 -	public long getSortPriority()
   1.799 -	{
   1.800 -		// TODO Auto-generated method stub
   1.801 -		return m_Data.getSortPriority();
   1.802 -	}
   1.803 -	
   1.804 -   /* (non-Javadoc)
   1.805 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setSortPriority(long)
   1.806 -	*/
   1.807 -	public void setSortPriority(long value)
   1.808 -	{
   1.809 -		m_Data.setSortPriority(value);
   1.810 -	}
   1.811 -	
   1.812 -   /* (non-Javadoc)
   1.813 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setExpanded(boolean)
   1.814 -	*/
   1.815 -	public void setExpanded(boolean value){}
   1.816 -	
   1.817 -   /* (non-Javadoc)
   1.818 -	* @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setSelected(boolean)
   1.819 -	*/
   1.820 -	public void setSelected(boolean value) {}
   1.821 -	
   1.822 -	/**
   1.823 -	 * Retrieve a collection that contains all of the children contained by the
   1.824 -	 * node.
   1.825 -	 * <br>
   1.826 -	 * <i>Note:</i> This collection should be treated as <b>read-only</b>.  If a
   1.827 -	 * node is added to the returned collection any associated view will not be
   1.828 -	 * updated until a refresh is performed.
   1.829 -	 *
   1.830 -	 * @return The collection of children.
   1.831 -	 */
   1.832 -	public Enumeration<ITreeItem> getNodeChildren()
   1.833 -	{
   1.834 -		Children children = getChildren();
   1.835 -		
   1.836 -		return new TreeItemEnumeration(children);
   1.837 -	}
   1.838 -	
   1.839 -	//**************************************************
   1.840 -	// AbstractModelElement Implementation
   1.841 -	//**************************************************
   1.842 -	
   1.843 +    }
   1.844 +
   1.845 +    /* (non-Javadoc)
   1.846 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#insertAt(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem, int)
   1.847 +     */
   1.848 +    public void insertAt(ITreeItem item, int index) {
   1.849 +        // The NetBeans API does not allow you to add a child to a specific
   1.850 +        // index.  The children are sorted so this is not neccessary.
   1.851 +        addChild(item);
   1.852 +    }
   1.853 +
   1.854 +    /* (non-Javadoc)
   1.855 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#removeChild(org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem)
   1.856 +     */
   1.857 +    public void removeChild(ITreeItem item) {
   1.858 +        if (item instanceof Node) {
   1.859 +            Node[] node = {(Node) item};
   1.860 +            Children children = getChildren();
   1.861 +
   1.862 +            if (children != null) {
   1.863 +                children.remove(node);
   1.864 +            }
   1.865 +        }
   1.866 +    }
   1.867 +
   1.868 +    /* (non-Javadoc)
   1.869 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#removeAllChildren()
   1.870 +     */
   1.871 +    public void removeAllChildren() {
   1.872 +        Children children = getChildren();
   1.873 +
   1.874 +        if ((children != null) && (children.getNodesCount() > 0)) {
   1.875 +            children.remove(children.getNodes());
   1.876 +        }
   1.877 +    }
   1.878 +
   1.879 +    /* (non-Javadoc)
   1.880 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getChild(int)
   1.881 +     */
   1.882 +    public ITreeItem getChild(int index) {
   1.883 +        // TODO Auto-generated method stub
   1.884 +        return null;
   1.885 +    }
   1.886 +
   1.887 +    /* (non-Javadoc)
   1.888 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#sortChildren()
   1.889 +     */
   1.890 +    public void sortChildren() {
   1.891 +        ((UMLChildren) getChildren()).recalculateChildren();
   1.892 +    }
   1.893 +
   1.894 +    /* (non-Javadoc)
   1.895 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#sortChildren(java.util.Comparator)
   1.896 +     */
   1.897 +    public void sortChildren(Comparator compare) {
   1.898 +    }
   1.899 +
   1.900 +    /* (non-Javadoc)
   1.901 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getData()
   1.902 +     */
   1.903 +    public IProjectTreeItem getData() {
   1.904 +        return m_Data;
   1.905 +    }
   1.906 +
   1.907 +    protected void setData(IProjectTreeItem data) {
   1.908 +        m_Data = data;
   1.909 +
   1.910 +        if (data != null) {
   1.911 +            m_Data.setProjectTreeSupportTreeItem(this);
   1.912 +        }
   1.913 +    }
   1.914 +
   1.915 +    /* (non-Javadoc)
   1.916 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getChildCount()
   1.917 +     */
   1.918 +    public int getChildCount() {
   1.919 +        int retVal = 0;
   1.920 +        Children children = getChildren();
   1.921 +
   1.922 +        if (children != null) {
   1.923 +            retVal = children.getNodesCount();
   1.924 +        }
   1.925 +
   1.926 +        return retVal;
   1.927 +    }
   1.928 +
   1.929 +    /* (non-Javadoc)
   1.930 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#isInitalized()
   1.931 +     */
   1.932 +    public boolean isInitalized() {
   1.933 +        // TODO Auto-generated method stub
   1.934 +        return mIsInitialized;
   1.935 +    }
   1.936 +
   1.937 +    /* (non-Javadoc)
   1.938 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setIsInitalized(boolean)
   1.939 +     */
   1.940 +    public void setIsInitalized(boolean value) {
   1.941 +        mIsInitialized = value;
   1.942 +    }
   1.943 +
   1.944 +    /* (non-Javadoc)
   1.945 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#getSortPriority()
   1.946 +     */
   1.947 +    public long getSortPriority() {
   1.948 +        // TODO Auto-generated method stub
   1.949 +        return m_Data.getSortPriority();
   1.950 +    }
   1.951 +
   1.952 +    /* (non-Javadoc)
   1.953 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setSortPriority(long)
   1.954 +     */
   1.955 +    public void setSortPriority(long value) {
   1.956 +        m_Data.setSortPriority(value);
   1.957 +    }
   1.958 +
   1.959 +    /* (non-Javadoc)
   1.960 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setExpanded(boolean)
   1.961 +     */
   1.962 +    public void setExpanded(boolean value) {
   1.963 +    }
   1.964 +
   1.965 +    /* (non-Javadoc)
   1.966 +     * @see org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem#setSelected(boolean)
   1.967 +     */
   1.968 +    public void setSelected(boolean value) {
   1.969 +    }
   1.970 +
   1.971      /**
   1.972 -     * Retrieves the actions for the node.  This method only returns
   1.973 -     * the context sensitive actions.
   1.974 +     * Retrieve a collection that contains all of the children contained by the
   1.975 +     * node.
   1.976 +     * <br>
   1.977 +     * <i>Note:</i> This collection should be treated as <b>read-only</b>. If a
   1.978 +     * node is added to the returned collection any associated view will not be
   1.979 +     * updated until a refresh is performed.
   1.980 +     *
   1.981 +     * @return The collection of children.
   1.982 +     */
   1.983 +    public Enumeration<ITreeItem> getNodeChildren() {
   1.984 +        Children children = getChildren();
   1.985 +
   1.986 +        return new TreeItemEnumeration(children);
   1.987 +    }
   1.988 +
   1.989 +    //**************************************************
   1.990 +    // AbstractModelElement Implementation
   1.991 +    //**************************************************
   1.992 +    /**
   1.993 +     * Retrieves the actions for the node. This method only returns the context
   1.994 +     * sensitive actions.
   1.995       *
   1.996       * @param context Whether to find actions for context meaning or for the
   1.997 -     *                node itself
   1.998 +     * node itself
   1.999       * @return A list of actions (you may include nulls for separators)
  1.1000       */
  1.1001 -    public Action[] getActions(boolean context)
  1.1002 -    {
  1.1003 +    public Action[] getActions(boolean context) {
  1.1004  
  1.1005  // Source control Sub menu Actions are created based on the SCM status of the nodes (Class diagrams, classes) 
  1.1006  // so every time we need to get the actions afresh.  
  1.1007 -		
  1.1008 +
  1.1009  //			if (actions == null)
  1.1010 -		return super.getActions(context);
  1.1011 -		
  1.1012 -	}
  1.1013 -	
  1.1014 -	public Action getPreferredAction()
  1.1015 -	{
  1.1016 -		return SystemAction.get(OpenAction.class);
  1.1017 -	}
  1.1018 -	
  1.1019 +        return super.getActions(context);
  1.1020 +
  1.1021 +    }
  1.1022 +
  1.1023 +    public Action getPreferredAction() {
  1.1024 +        return SystemAction.get(OpenAction.class);
  1.1025 +    }
  1.1026 +
  1.1027      @Override
  1.1028 -    public Image getIcon(int type)
  1.1029 -    {
  1.1030 +    public Image getIcon(int type) {
  1.1031          Image retVal = null;
  1.1032          //	if(icon!=null) return icon;
  1.1033  
  1.1034          ITreeItem item = this;
  1.1035          IProjectTreeItem data = item.getData();
  1.1036  
  1.1037 -        if (icon!=null)
  1.1038 -        {
  1.1039 +        if (icon != null) {
  1.1040              retVal = icon;
  1.1041 -        }
  1.1042 +        } else {
  1.1043  
  1.1044 -        else
  1.1045 -        {
  1.1046 -
  1.1047 -            if (item instanceof ITreeFolder)
  1.1048 -            {
  1.1049 +            if (item instanceof ITreeFolder) {
  1.1050                  CommonResourceManager resource =
  1.1051 -                    CommonResourceManager.instance();
  1.1052 +                        CommonResourceManager.instance();
  1.1053  
  1.1054                  retVal = createImage(resource
  1.1055 -                    .getIconDetailsForElementType(item.getName()));
  1.1056 -            }
  1.1057 -
  1.1058 -            else if (item instanceof ITreeDiagram)
  1.1059 -            {
  1.1060 -                ITreeDiagram diagram = (ITreeDiagram)item;
  1.1061 +                        .getIconDetailsForElementType(item.getName()));
  1.1062 +            } else if (item instanceof ITreeDiagram) {
  1.1063 +                ITreeDiagram diagram = (ITreeDiagram) item;
  1.1064  
  1.1065                  CommonResourceManager resource =
  1.1066 -                    CommonResourceManager.instance();
  1.1067 +                        CommonResourceManager.instance();
  1.1068  
  1.1069                  retVal = createImage(resource
  1.1070 -                    .getIconDetailsForElementType(diagram.getDiagramType()));
  1.1071 +                        .getIconDetailsForElementType(diagram.getDiagramType()));
  1.1072  
  1.1073 -                if (diagram.getDiagram().getDiagramDetails() 
  1.1074 -                    instanceof TSDiagramDetails)
  1.1075 -                {
  1.1076 +                if (diagram.getDiagram().getDiagramDetails() instanceof TSDiagramDetails) {
  1.1077                      // this is an old TS diagram; when opened, it needs
  1.1078                      // to be converted to new Meteora diagram.
  1.1079                      // this code will badge the diagram icon with a
  1.1080                      // yellow triangle with an exclamation point to 
  1.1081                      // visually indicate the diagram's state
  1.1082                      retVal = ImageUtilities.mergeImages(
  1.1083 -                        retVal, createImage(ICON_BADGE_EXCLAMATION), 0, 0);
  1.1084 +                            retVal, createImage(ICON_BADGE_EXCLAMATION), 0, 0);
  1.1085                  }
  1.1086 -            }
  1.1087 -
  1.1088 -            else if (data.getModelElement() != null)
  1.1089 -            {
  1.1090 -                if (data.getModelElement() instanceof IProject)
  1.1091 +            } else if (data.getModelElement() != null) {
  1.1092 +                if (data.getModelElement() instanceof IProject) {
  1.1093                      retVal = super.getIcon(type);
  1.1094 -
  1.1095 -                else
  1.1096 -                {
  1.1097 +                } else {
  1.1098                      CommonResourceManager resource =
  1.1099 -                        CommonResourceManager.instance();
  1.1100 +                            CommonResourceManager.instance();
  1.1101  
  1.1102                      retVal = createImage(resource
  1.1103 -                        .getIconDetailsForDisp(data.getModelElement()));
  1.1104 +                            .getIconDetailsForDisp(data.getModelElement()));
  1.1105                  }
  1.1106 -            }
  1.1107 -
  1.1108 -            else if (data.isProject())
  1.1109 -            {
  1.1110 +            } else if (data.isProject()) {
  1.1111                  // CommonResourceManager resource = 
  1.1112                  //     CommonResourceManager.instance();
  1.1113                  // retVal = createImage(
  1.1114                  //     resource.getIconDetailsForElementType("WSProject"));
  1.1115  
  1.1116                  retVal = super.getIcon(type);
  1.1117 -            }
  1.1118 -
  1.1119 -            else if (data.isWorkspace())
  1.1120 -            {
  1.1121 +            } else if (data.isWorkspace()) {
  1.1122                  CommonResourceManager resource = CommonResourceManager.instance();
  1.1123                  // special case for design pattern catalog
  1.1124  
  1.1125                  if (data.getItemText().equals("DesignPatternCatalog")) // NOI18N
  1.1126                  {
  1.1127                      retVal = createImage(
  1.1128 -                        resource.getIconDetailsForElementType(
  1.1129 -                        "DesignPatternCatalog")); // NOI18N
  1.1130 +                            resource.getIconDetailsForElementType(
  1.1131 +                            "DesignPatternCatalog")); // NOI18N
  1.1132 +                } else {
  1.1133 +                    retVal = createImage(resource
  1.1134 +                            .getIconDetailsForElementType("Workspace")); // NOI18N
  1.1135                  }
  1.1136 -
  1.1137 -                else
  1.1138 -                {
  1.1139 -                    retVal = createImage(resource
  1.1140 -                        .getIconDetailsForElementType("Workspace")); // NOI18N
  1.1141 -                }
  1.1142 -            }
  1.1143 -
  1.1144 -            else
  1.1145 -            {
  1.1146 -                CommonResourceManager resource = 
  1.1147 -                    CommonResourceManager.instance();
  1.1148 +            } else {
  1.1149 +                CommonResourceManager resource =
  1.1150 +                        CommonResourceManager.instance();
  1.1151  
  1.1152                  retVal = createImage(
  1.1153 -                    resource.getIconDetailsForElementType(item.getName()));
  1.1154 +                        resource.getIconDetailsForElementType(item.getName()));
  1.1155              }
  1.1156          }
  1.1157  
  1.1158 -        if (retVal == null)
  1.1159 +        if (retVal == null) {
  1.1160              retVal = super.getIcon(type);
  1.1161 +        }
  1.1162  
  1.1163          //return getIconWithOverlay(retVal, this);
  1.1164 -        retVal=getIconWithOverlay(retVal, this);
  1.1165 +        retVal = getIconWithOverlay(retVal, this);
  1.1166  
  1.1167 -        icon=retVal;
  1.1168 +        icon = retVal;
  1.1169          return icon;
  1.1170      }
  1.1171 -    
  1.1172 -    public final static String ICON_BADGE_EXCLAMATION = 
  1.1173 -        ImageUtil.IMAGE_FOLDER + "broken-project-badge.gif";
  1.1174 -	
  1.1175 +    public final static String ICON_BADGE_EXCLAMATION =
  1.1176 +            ImageUtil.IMAGE_FOLDER + "broken-project-badge.gif";
  1.1177 +
  1.1178      @Override
  1.1179 -	public Image getOpenedIcon(int type)
  1.1180 -	{
  1.1181 -		return getIcon(type);
  1.1182 -	}
  1.1183 -	
  1.1184 -   /* (non-Javadoc)
  1.1185 -	* @see org.netbeans.modules.uml.netbeans.umlproject.ui.AbstractModelElementNode#getModelElement()
  1.1186 -	*/
  1.1187 -	public IElement getModelElement()
  1.1188 -	{
  1.1189 -		IElement retVal = null;
  1.1190 -		IProjectTreeItem item = getData();
  1.1191 -		
  1.1192 -		if (item != null)
  1.1193 -			retVal = item.getModelElement();
  1.1194 +    public Image getOpenedIcon(int type) {
  1.1195 +        return getIcon(type);
  1.1196 +    }
  1.1197  
  1.1198 -		return retVal;
  1.1199 -	}
  1.1200 -	
  1.1201 -	
  1.1202 -	//**************************************************
  1.1203 -	// CookieSet.Factory implementation
  1.1204 -	//**************************************************
  1.1205 -	
  1.1206 -	public Node.Cookie createCookie(Class klass)
  1.1207 -	{
  1.1208 -		Node.Cookie retVal = null;
  1.1209 -		
  1.1210 -		if (OpenCookie.class.equals(klass) == true)
  1.1211 -		{
  1.1212 -			if (mOpenCookie == null)
  1.1213 -				mOpenCookie = createOpenCookie();
  1.1214 -			
  1.1215 -			retVal = mOpenCookie;
  1.1216 -		}
  1.1217 -		
  1.1218 -		return retVal;
  1.1219 -	}
  1.1220 -	
  1.1221 -	
  1.1222 -	//**************************************************
  1.1223 -	// Helper Methods
  1.1224 -	//**************************************************
  1.1225 -	
  1.1226 -	public String toString()
  1.1227 -	{
  1.1228 -		String retVal = getDisplayedName();
  1.1229 -		
  1.1230 -		if ((retVal == null) || (retVal.length() <= 0))
  1.1231 -			retVal = getName();
  1.1232 -		
  1.1233 -		return retVal;
  1.1234 -	}
  1.1235 -	
  1.1236 -   /* (non-Javadoc)
  1.1237 -	* @see java.lang.Object#equals(java.lang.Object)
  1.1238 -	*/
  1.1239 -	public boolean equals(Object obj)
  1.1240 -	{
  1.1241 -		boolean retVal = false;
  1.1242 -		
  1.1243 -		if (obj != null && this.hashCode() == obj.hashCode())
  1.1244 -		    return true;
  1.1245 -        
  1.1246 -		IProjectTreeItem myItem = getData();
  1.1247 -		
  1.1248 -		if (obj instanceof IElement)
  1.1249 -		{
  1.1250 -			IElement myElement = myItem.getModelElement();
  1.1251 -			
  1.1252 -			if (myElement != null)
  1.1253 -				retVal = myElement.isSame((IElement)obj);
  1.1254 -		}
  1.1255 +    /* (non-Javadoc)
  1.1256 +     * @see org.netbeans.modules.uml.netbeans.umlproject.ui.AbstractModelElementNode#getModelElement()
  1.1257 +     */
  1.1258 +    public IElement getModelElement() {
  1.1259 +        IElement retVal = null;
  1.1260 +        IProjectTreeItem item = getData();
  1.1261  
  1.1262 -		else if (obj instanceof UMLElementNode)
  1.1263 -		{
  1.1264 -			UMLElementNode node = (UMLElementNode)obj;
  1.1265 -			IProjectTreeItem testItem = node.getData();
  1.1266 -			String testText = node.getDisplayedName();
  1.1267 -			String myText   = getDisplayedName();
  1.1268 -			
  1.1269 -			if ((testText != null) && (myText != null))
  1.1270 -				retVal = testText.equals(myText);
  1.1271 -			
  1.1272 -			else if ((testText == null) && (myText == null))
  1.1273 -				retVal =  super.equals(obj);
  1.1274 -			
  1.1275 -			if (retVal == true)
  1.1276 -			{
  1.1277 -				String testXMIID = testItem.getModelElementXMIID();
  1.1278 -				String myXMIID = myItem.getModelElementXMIID();
  1.1279 -				
  1.1280 -				if ((testXMIID != null) && (myXMIID != null))
  1.1281 -					retVal = testXMIID.equals(myXMIID);
  1.1282 -			}
  1.1283 -		}
  1.1284 -		
  1.1285 -		else
  1.1286 -		{  // Generic equals method.  This can be used to test
  1.1287 -			// to ITreeItem(s).
  1.1288 -			retVal =  super.equals(obj);
  1.1289 -		}
  1.1290 -		
  1.1291 -		return retVal;
  1.1292 -	}
  1.1293 -	
  1.1294 -	/**
  1.1295 -	 * Initializes the node with the default cookies.  <b>Note:</b>  Do not
  1.1296 -	 * call this method if a looup is added.  When a lookup is added then the
  1.1297 -	 * lookup is used to find the cookies.
  1.1298 -	 */
  1.1299 -	protected void initCookies()
  1.1300 -	{
  1.1301 -		Class[] cookies = {OpenCookie.class};
  1.1302 -		getCookieSet().add(cookies, this);
  1.1303 -	}
  1.1304 -	
  1.1305 -	/**
  1.1306 -	 * Creates the open cookie to use when opening the node.
  1.1307 -	 */
  1.1308 -	protected Node.Cookie createOpenCookie()
  1.1309 -	{
  1.1310 -		return new ModelElementOpen();
  1.1311 -	}
  1.1312 -	
  1.1313 -	
  1.1314 -	
  1.1315 -	/**
  1.1316 -	 * @param string
  1.1317 -	 * @return
  1.1318 -	 */
  1.1319 -	protected Image createImage(String iconLocation)
  1.1320 -	{
  1.1321 -		return ImageUtilities.loadImage( iconLocation, true );
  1.1322 -	}
  1.1323 -	
  1.1324 -	/**
  1.1325 -	 * Implementation of method from Comparable interface.
  1.1326 -	 * @return
  1.1327 -	 */
  1.1328 -	public int compareTo(Object o)
  1.1329 -	{
  1.1330 -	    return ProjectTreeComparable.compareTo(this, o);
  1.1331 -	}
  1.1332 -	
  1.1333 -	// to be overridden by subclasses as needed
  1.1334 -	public void registerListeners()
  1.1335 -	{}
  1.1336 -	
  1.1337 -	
  1.1338 -	public class ModelElementOpen implements OpenCookie
  1.1339 -	{
  1.1340 -		public void open()
  1.1341 -		{
  1.1342 -			DispatchHelper helper = new DispatchHelper();
  1.1343 -			IProjectTreeEventDispatcher disp = helper.getProjectTreeDispatcher();
  1.1344 -			if (disp != null)
  1.1345 -			{
  1.1346 -				IEventPayload payload = 
  1.1347 -					disp.createPayload("ProjectTreeDoubleClick"); // NOI18N
  1.1348 -				
  1.1349 -				helper.getProjectTreeDispatcher().fireDoubleClick(null,
  1.1350 -					getData(), false, false, false, false, payload);
  1.1351 -			}
  1.1352 -			
  1.1353 -			registerListeners();
  1.1354 -		}
  1.1355 -	}
  1.1356 -	
  1.1357 -	public class TreeItemEnumeration implements Enumeration < ITreeItem >
  1.1358 -	{
  1.1359 -		Enumeration m_ChildrenEnum = null;
  1.1360 -		
  1.1361 -		public TreeItemEnumeration(Children c)
  1.1362 -		{
  1.1363 -			m_ChildrenEnum = c.nodes();
  1.1364 -		}
  1.1365 -		
  1.1366 -		public boolean hasMoreElements()
  1.1367 -		{
  1.1368 -			return m_ChildrenEnum.hasMoreElements();
  1.1369 -		}
  1.1370 -		
  1.1371 -		public ITreeItem nextElement()
  1.1372 -		{
  1.1373 -			return (ITreeItem)m_ChildrenEnum.nextElement();
  1.1374 -		}
  1.1375 -	}
  1.1376 -	
  1.1377 -	
  1.1378 -	
  1.1379 -	public void vcsFeatureExecuted(/* SCMFeatureKind */ int kind)
  1.1380 -	{
  1.1381 -		if(kind == SCMFeatureKind.FK_CHECK_IN || 
  1.1382 -			kind == SCMFeatureKind.FK_CHECK_OUT ||
  1.1383 -			kind == SCMFeatureKind.FK_ADD_TO_SOURCE_CONTROL || 
  1.1384 -			kind == SCMFeatureKind.FK_REMOVE_FROM_SOURCE_CONTROL ||
  1.1385 -			kind == SCMFeatureKind.REFRESH_STATUS)
  1.1386 -		{
  1.1387 -			fireIconChange();
  1.1388 -		}
  1.1389 -	}
  1.1390 -	
  1.1391 -	protected Image getIconWithOverlay(Image image, ITreeItem item)
  1.1392 -	{
  1.1393 -		ImageIcon image1 = new ImageIcon(image);
  1.1394 -		
  1.1395 -		
  1.1396 -		if(!(item instanceof ITreeFolder))
  1.1397 -		{
  1.1398 -			Icon overlay = getOverlayIcon(item.getData());
  1.1399 -			
  1.1400 -			if((image1 != null) && (overlay != null))
  1.1401 -			{
  1.1402 -				GraphicsDevice[] gs = GraphicsEnvironment
  1.1403 -					.getLocalGraphicsEnvironment().getScreenDevices();
  1.1404 -				
  1.1405 -				GraphicsConfiguration[] gc = gs[0].getConfigurations();
  1.1406 -				
  1.1407 -				Image retImage = gc[0].createCompatibleVolatileImage(
  1.1408 -					image1.getIconWidth(), image1.getIconHeight());
  1.1409 -				
  1.1410 -				Graphics g = retImage.getGraphics();
  1.1411 -				
  1.1412 -				image1.paintIcon(null, g, 0, 0);
  1.1413 -				
  1.1414 -				int overlayY = image1.getIconHeight() - overlay.getIconHeight();
  1.1415 -				overlay.paintIcon(null, g, 0, overlayY);
  1.1416 -				
  1.1417 -				
  1.1418 -				image1 = new ImageIcon(retImage);
  1.1419 -			}
  1.1420 -		}
  1.1421 -		return image1.getImage();
  1.1422 -	}
  1.1423 -	
  1.1424 -	protected Icon getOverlayIcon(IProjectTreeItem item)
  1.1425 -	{
  1.1426 -		Icon retVal = null;
  1.1427 -		
  1.1428 -		
  1.1429 -		ISCMIntegrator gator = ProductHelper.getSCMIntegrator();
  1.1430 -		if(gator != null)
  1.1431 -		{
  1.1432 -			int kind = gator.getSCMMaskKind(item);
  1.1433 -			retVal = gator.getSCMMask(kind);
  1.1434 -		}
  1.1435 -		
  1.1436 -		return retVal;
  1.1437 -	}
  1.1438 +        if (item != null) {
  1.1439 +            retVal = item.getModelElement();
  1.1440 +        }
  1.1441 +
  1.1442 +        return retVal;
  1.1443 +    }
  1.1444 +
  1.1445 +    //**************************************************
  1.1446 +    // CookieSet.Factory implementation
  1.1447 +    //**************************************************
  1.1448 +    public Node.Cookie createCookie(Class klass) {
  1.1449 +        Node.Cookie retVal = null;
  1.1450 +
  1.1451 +        if (OpenCookie.class.equals(klass) == true) {
  1.1452 +            if (mOpenCookie == null) {
  1.1453 +                mOpenCookie = createOpenCookie();
  1.1454 +            }
  1.1455 +
  1.1456 +            retVal = mOpenCookie;
  1.1457 +        }
  1.1458 +
  1.1459 +        return retVal;
  1.1460 +    }
  1.1461 +
  1.1462 +    //**************************************************
  1.1463 +    // Helper Methods
  1.1464 +    //**************************************************
  1.1465 +    public String toString() {
  1.1466 +        String retVal = getDisplayedName();
  1.1467 +
  1.1468 +        if ((retVal == null) || (retVal.length() <= 0)) {
  1.1469 +            retVal = getName();
  1.1470 +        }
  1.1471 +
  1.1472 +        return retVal;
  1.1473 +    }
  1.1474 +
  1.1475 +    /* (non-Javadoc)
  1.1476 +     * @see java.lang.Object#equals(java.lang.Object)
  1.1477 +     */
  1.1478 +    public boolean equals(Object obj) {
  1.1479 +        boolean retVal = false;
  1.1480 +
  1.1481 +        if (obj != null && this.hashCode() == obj.hashCode()) {
  1.1482 +            return true;
  1.1483 +        }
  1.1484 +
  1.1485 +        IProjectTreeItem myItem = getData();
  1.1486 +
  1.1487 +        if (obj instanceof IElement) {
  1.1488 +            IElement myElement = myItem.getModelElement();
  1.1489 +
  1.1490 +            if (myElement != null) {
  1.1491 +                retVal = myElement.isSame((IElement) obj);
  1.1492 +            }
  1.1493 +        } else if (obj instanceof UMLElementNode) {
  1.1494 +            UMLElementNode node = (UMLElementNode) obj;
  1.1495 +            IProjectTreeItem testItem = node.getData();
  1.1496 +            String testText = node.getDisplayedName();
  1.1497 +            String myText = getDisplayedName();
  1.1498 +
  1.1499 +            if ((testText != null) && (myText != null)) {
  1.1500 +                retVal = testText.equals(myText);
  1.1501 +            } else if ((testText == null) && (myText == null)) {
  1.1502 +                retVal = super.equals(obj);
  1.1503 +            }
  1.1504 +
  1.1505 +            if (retVal == true) {
  1.1506 +                String testXMIID = testItem.getModelElementXMIID();
  1.1507 +                String myXMIID = myItem.getModelElementXMIID();
  1.1508 +
  1.1509 +                if ((testXMIID != null) && (myXMIID != null)) {
  1.1510 +                    retVal = testXMIID.equals(myXMIID);
  1.1511 +                }
  1.1512 +            }
  1.1513 +        } else {  // Generic equals method.  This can be used to test
  1.1514 +            // to ITreeItem(s).
  1.1515 +            retVal = super.equals(obj);
  1.1516 +        }
  1.1517 +
  1.1518 +        return retVal;
  1.1519 +    }
  1.1520 +
  1.1521 +    /**
  1.1522 +     * Initializes the node with the default cookies. <b>Note:</b> Do not call
  1.1523 +     * this method if a looup is added. When a lookup is added then the lookup
  1.1524 +     * is used to find the cookies.
  1.1525 +     */
  1.1526 +    protected void initCookies() {
  1.1527 +        Class[] cookies = {OpenCookie.class};
  1.1528 +        getCookieSet().add(cookies, this);
  1.1529 +    }
  1.1530 +
  1.1531 +    /**
  1.1532 +     * Creates the open cookie to use when opening the node.
  1.1533 +     */
  1.1534 +    protected Node.Cookie createOpenCookie() {
  1.1535 +        return new ModelElementOpen();
  1.1536 +    }
  1.1537 +
  1.1538 +    /**
  1.1539 +     * @param string
  1.1540 +     * @return
  1.1541 +     */
  1.1542 +    protected Image createImage(String iconLocation) {
  1.1543 +        return ImageUtilities.loadImage(iconLocation, true);
  1.1544 +    }
  1.1545 +
  1.1546 +    /**
  1.1547 +     * Implementation of method from Comparable interface.
  1.1548 +     *
  1.1549 +     * @return
  1.1550 +     */
  1.1551 +    public int compareTo(Object o) {
  1.1552 +        return ProjectTreeComparable.compareTo(this, o);
  1.1553 +    }
  1.1554 +
  1.1555 +    // to be overridden by subclasses as needed
  1.1556 +    public void registerListeners() {
  1.1557 +    }
  1.1558 +
  1.1559 +    public class ModelElementOpen implements OpenCookie {
  1.1560 +
  1.1561 +        public void open() {
  1.1562 +            DispatchHelper helper = new DispatchHelper();
  1.1563 +            IProjectTreeEventDispatcher disp = helper.getProjectTreeDispatcher();
  1.1564 +            if (disp != null) {
  1.1565 +                IEventPayload payload =
  1.1566 +                        disp.createPayload("ProjectTreeDoubleClick"); // NOI18N
  1.1567 +
  1.1568 +                helper.getProjectTreeDispatcher().fireDoubleClick(null,
  1.1569 +                        getData(), false, false, false, false, payload);
  1.1570 +            }
  1.1571 +
  1.1572 +            registerListeners();
  1.1573 +        }
  1.1574 +    }
  1.1575 +
  1.1576 +    public class TreeItemEnumeration implements Enumeration< ITreeItem> {
  1.1577 +
  1.1578 +        Enumeration m_ChildrenEnum = null;
  1.1579 +
  1.1580 +        public TreeItemEnumeration(Children c) {
  1.1581 +            m_ChildrenEnum = c.nodes();
  1.1582 +        }
  1.1583 +
  1.1584 +        public boolean hasMoreElements() {
  1.1585 +            return m_ChildrenEnum.hasMoreElements();
  1.1586 +        }
  1.1587 +
  1.1588 +        public ITreeItem nextElement() {
  1.1589 +            return (ITreeItem) m_ChildrenEnum.nextElement();
  1.1590 +        }
  1.1591 +    }
  1.1592 +
  1.1593 +    public void vcsFeatureExecuted(/* SCMFeatureKind */int kind) {
  1.1594 +        if (kind == SCMFeatureKind.FK_CHECK_IN
  1.1595 +                || kind == SCMFeatureKind.FK_CHECK_OUT
  1.1596 +                || kind == SCMFeatureKind.FK_ADD_TO_SOURCE_CONTROL
  1.1597 +                || kind == SCMFeatureKind.FK_REMOVE_FROM_SOURCE_CONTROL
  1.1598 +                || kind == SCMFeatureKind.REFRESH_STATUS) {
  1.1599 +            fireIconChange();
  1.1600 +        }
  1.1601 +    }
  1.1602 +
  1.1603 +    protected Image getIconWithOverlay(Image image, ITreeItem item) {
  1.1604 +        ImageIcon image1 = new ImageIcon(image);
  1.1605 +
  1.1606 +
  1.1607 +        if (!(item instanceof ITreeFolder)) {
  1.1608 +            Icon overlay = getOverlayIcon(item.getData());
  1.1609 +
  1.1610 +            if ((image1 != null) && (overlay != null)) {
  1.1611 +                GraphicsDevice[] gs = GraphicsEnvironment
  1.1612 +                        .getLocalGraphicsEnvironment().getScreenDevices();
  1.1613 +
  1.1614 +                GraphicsConfiguration[] gc = gs[0].getConfigurations();
  1.1615 +
  1.1616 +                Image retImage = gc[0].createCompatibleVolatileImage(
  1.1617 +                        image1.getIconWidth(), image1.getIconHeight());
  1.1618 +
  1.1619 +                Graphics g = retImage.getGraphics();
  1.1620 +
  1.1621 +                image1.paintIcon(null, g, 0, 0);
  1.1622 +
  1.1623 +                int overlayY = image1.getIconHeight() - overlay.getIconHeight();
  1.1624 +                overlay.paintIcon(null, g, 0, overlayY);
  1.1625 +
  1.1626 +
  1.1627 +                image1 = new ImageIcon(retImage);
  1.1628 +            }
  1.1629 +        }
  1.1630 +        return image1.getImage();
  1.1631 +    }
  1.1632 +
  1.1633 +    protected Icon getOverlayIcon(IProjectTreeItem item) {
  1.1634 +        Icon retVal = null;
  1.1635 +
  1.1636 +
  1.1637 +        ISCMIntegrator gator = ProductHelper.getSCMIntegrator();
  1.1638 +        if (gator != null) {
  1.1639 +            int kind = gator.getSCMMaskKind(item);
  1.1640 +            retVal = gator.getSCMMask(kind);
  1.1641 +        }
  1.1642 +
  1.1643 +        return retVal;
  1.1644 +    }
  1.1645 +
  1.1646 +    /**
  1.1647 +     * Factory by which children of Node will be initialized
  1.1648 +     */
  1.1649 +    class UMLChildFactory extends ChildFactory<ITreeItem> {
  1.1650 +
  1.1651 +        private ITreeItem item = null;
  1.1652 +
  1.1653 +        UMLChildFactory(ITreeItem item) {
  1.1654 +            this.item = item;
  1.1655 +        }
  1.1656 +
  1.1657 +        /**
  1.1658 +         * Initializes children of node by firing item expanding event.
  1.1659 +         *
  1.1660 +         * @param children a list to add object to, (for now not used)
  1.1661 +         *
  1.1662 +         * @return true if node is initialized completely; false if list has
  1.1663 +         * been partially populated and this method should be called again to
  1.1664 +         * retrieve more children
  1.1665 +         */
  1.1666 +        @Override
  1.1667 +        protected boolean createKeys(List<ITreeItem> children) {
  1.1668 +            final NetBeansUMLProjectTreeModel model = UMLModelRootNode.getProjectTreeModel();
  1.1669 +
  1.1670 +            // Debug.out.println("UMLChildren Firing node expand event");
  1.1671 +            if (model != null) {
  1.1672 +                model.fireItemExpanding(item);
  1.1673 +
  1.1674 +                item.setIsInitalized(true);
  1.1675 +
  1.1676 +                return true;
  1.1677 +            }
  1.1678 +
  1.1679 +            return false;
  1.1680 +        }
  1.1681 +
  1.1682 +        /**
  1.1683 +         * Enforce no WaitNode is shown by returning null
  1.1684 +         */
  1.1685 +        @Override
  1.1686 +        protected Node createWaitNode() {
  1.1687 +            return null;
  1.1688 +        }
  1.1689 +    }
  1.1690  }