KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > ajde > ui > StructureViewNodeFactory


1
2 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3  *
4  * This file is part of the IDE support for the AspectJ(tm)
5  * programming language; see http://aspectj.org
6  *
7  * The contents of this file are subject to the Mozilla Public License
8  * Version 1.1 (the "License"); you may not use this file except in
9  * compliance with the License. You may obtain a copy of the License at
10  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is AspectJ.
18  *
19  * The Initial Developer of the Original Code is Xerox Corporation. Portions
20  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
21  * All Rights Reserved.
22  *
23  * Contributor(s):
24  */

25  
26 package org.aspectj.ajde.ui;
27
28 import org.aspectj.asm.*;
29 import java.util.List JavaDoc;
30
31 /**
32  * @author Mik Kersten
33  */

34 public abstract class StructureViewNodeFactory {
35
36     private AbstractIconRegistry iconRegistry;
37
38     public StructureViewNodeFactory(AbstractIconRegistry iconRegistry) {
39         this.iconRegistry = iconRegistry;
40     }
41
42     public StructureViewNode createNode(StructureNode node) {
43         return createNode(node, null);
44     }
45
46     public StructureViewNode createNode(StructureNode node, List JavaDoc children) {
47         AbstractIcon icon;
48         if (node instanceof ProgramElementNode) {
49             ProgramElementNode pNode = (ProgramElementNode)node;
50             icon = iconRegistry.getStructureIcon(pNode.getProgramElementKind(), pNode.getAccessibility());
51         } else if (node instanceof RelationNode) {
52             RelationNode relationNode = (RelationNode)node;
53             icon = iconRegistry.getRelationIcon(relationNode.getRelation());
54         } else if (node instanceof LinkNode) {
55             LinkNode linkNode = (LinkNode)node;
56             icon = iconRegistry.getStructureIcon(
57                 linkNode.getProgramElementNode().getProgramElementKind(),
58                 linkNode.getProgramElementNode().getAccessibility());
59         } else {
60             icon = new AbstractIcon(null);
61         }
62         return createConcreteNode(node, icon, children);
63     }
64     
65     /**
66      * Implementors must override this method in order to create new nodes.
67      */

68     protected abstract StructureViewNode createConcreteNode(StructureNode node, AbstractIcon icon, List JavaDoc children);
69 }
70
Popular Tags