KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > refactoring > ui > tree > FauxTreeElement


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.refactoring.ui.tree;
21
22 import java.beans.BeanInfo JavaDoc;
23 import java.text.MessageFormat JavaDoc;
24 import java.util.HashMap JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.Map JavaDoc;
27 import javax.swing.Icon JavaDoc;
28 import javax.swing.ImageIcon JavaDoc;
29
30 import org.netbeans.modules.refactoring.api.RefactoringElement;
31 import org.netbeans.modules.refactoring.spi.ui.TreeElementFactory;
32 import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation;
33 import org.netbeans.modules.refactoring.spi.ui.*;
34 import org.netbeans.modules.xml.nbprefuse.AnalysisConstants;
35 import org.netbeans.modules.xml.refactoring.RefactoringManager;
36 import org.netbeans.modules.xml.refactoring.Usage;
37 import org.netbeans.modules.xml.refactoring.spi.UIHelper;
38 import org.netbeans.modules.xml.refactoring.ui.readers.WhereUsedReader;
39 import org.netbeans.modules.xml.refactoring.ui.util.AnalysisUtilities;
40 import org.netbeans.modules.xml.xam.Component;
41 import org.netbeans.modules.xml.xam.Referenceable;
42 import org.netbeans.modules.xml.xam.dom.DocumentModel;
43 import org.openide.filesystems.FileObject;
44 import org.openide.nodes.Node;
45 import org.openide.util.NbBundle;
46
47 /**
48  *
49  * @author Jan Becicka
50  */

51 public class FauxTreeElement implements TreeElement {
52     
53     RefactoringElement element;
54     Usage usage;
55     UIHelper uiHelper;
56     Node node;
57     Referenceable ref;
58     FileObject targetFobj;
59        
60     FauxTreeElement(RefactoringElement element) {
61         this.element = element;
62         this.ref = (Referenceable) element.getComposite();
63         
64         Component targetComponent = ref instanceof Component ? (Component) ref : ref instanceof DocumentModel ? ((DocumentModel) ref).getRootComponent() :null;
65             assert targetComponent != null : "target is not Component or DocumentModel";
66             targetFobj = AnalysisUtilities.getFileObject(targetComponent);
67                       
68             UIHelper helper = RefactoringManager.getInstance().getTargetComponentUIHelper(ref);
69             if (helper == null){
70                 helper = new UIHelper();
71             }
72             node = AnalysisUtilities.getDisplayNode(ref);
73         }
74             
75    
76     
77     public TreeElement getParent(boolean isLogical) {
78                  
79          return TreeElementFactory.getTreeElement(targetFobj);
80        
81     }
82                 
83          
84  
85     public Icon JavaDoc getIcon() {
86       
87         return new ImageIcon JavaDoc(node.getIcon(BeanInfo.ICON_COLOR_16x16));
88         
89     }
90
91     public String JavaDoc getText(boolean isLogical) {
92         String JavaDoc name = AnalysisUtilities.getName(ref);
93         return name;
94         
95        
96        
97     }
98
99     public Object JavaDoc getUserObject() {
100         return ref;
101     }
102 }
103
Popular Tags