KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > editor > model > AntProjectNode


1 /*******************************************************************************
2  * Copyright (c) 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ant.internal.ui.editor.model;
13
14 import java.util.HashMap JavaDoc;
15 import java.util.Map JavaDoc;
16 import org.apache.tools.ant.Project;
17 import org.eclipse.ant.internal.ui.editor.outline.AntModel;
18 import org.eclipse.ant.internal.ui.editor.outline.AntModelProject;
19 import org.eclipse.ant.internal.ui.editor.outline.XMLProblem;
20 import org.eclipse.ant.internal.ui.model.AntUIImages;
21 import org.eclipse.ant.internal.ui.model.IAntUIConstants;
22 import org.eclipse.jface.resource.ImageDescriptor;
23
24
25 public class AntProjectNode extends AntElementNode {
26
27     private AntModelProject fProject;
28     private AntModel fModel;
29     private Map JavaDoc fNameToDefiningNodeMap;
30     
31     public AntProjectNode(AntModelProject project, AntModel antModel) {
32         super("project"); //$NON-NLS-1$
33
fProject= project;
34         fModel= antModel;
35     }
36     
37     /* (non-Javadoc)
38      * @see org.eclipse.ant.internal.ui.editor.model.AntElementNode#getDisplayName()
39      */

40     public String JavaDoc getLabel() {
41         String JavaDoc projectName= fProject.getName();
42         if (projectName == null || projectName.length() == 0) {
43             projectName= "project"; //$NON-NLS-1$
44
}
45         return projectName;
46     }
47     /* (non-Javadoc)
48      * @see org.eclipse.ant.internal.ui.editor.model.AntElementNode#getBaseImageDescriptor()
49      */

50     protected ImageDescriptor getBaseImageDescriptor() {
51         return AntUIImages.getImageDescriptor(IAntUIConstants.IMG_ANT_PROJECT);
52     }
53
54     /**
55      * Returns the Ant project associated with this project node.
56      * @return the Ant project
57      */

58     public Project getProject() {
59         return fProject;
60     }
61     
62     protected AntModel getAntModel() {
63         return fModel;
64     }
65     
66     /* (non-Javadoc)
67      * @see org.eclipse.ant.internal.ui.editor.model.AntElementNode#reset()
68      */

69     public void reset() {
70         super.reset();
71         fProject.reset();
72         if (fNameToDefiningNodeMap != null) {
73             getAntModel().setNamesOfOldDefiningNodes(fNameToDefiningNodeMap.keySet());
74         }
75         fNameToDefiningNodeMap= null;
76         setProblemSeverity(XMLProblem.NO_PROBLEM);
77     }
78     
79     public void addDefiningTaskNode(AntDefiningTaskNode node) {
80         if (fNameToDefiningNodeMap == null) {
81             fNameToDefiningNodeMap= new HashMap JavaDoc();
82         }
83         String JavaDoc label= node.getLabel();
84         if (label.equalsIgnoreCase("macrodef") //$NON-NLS-1$
85
|| label.equalsIgnoreCase("presetdef") //$NON-NLS-1$
86
|| label.equalsIgnoreCase("typedef") //$NON-NLS-1$
87
|| label.equalsIgnoreCase("taskdef")) { //$NON-NLS-1$
88
//only add user defined names
89
return;
90         }
91         fNameToDefiningNodeMap.put(node.getLabel(), node);
92     }
93     
94     public AntDefiningTaskNode getDefininingTaskNode(String JavaDoc nodeName) {
95         if (fNameToDefiningNodeMap != null) {
96             return (AntDefiningTaskNode)fNameToDefiningNodeMap.get(nodeName);
97         }
98         return null;
99     }
100 }
101
Popular Tags