KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > bluej > BluejSources


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.bluej;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.List JavaDoc;
25 import javax.swing.Icon JavaDoc;
26 import javax.swing.ImageIcon JavaDoc;
27 import javax.swing.event.ChangeEvent JavaDoc;
28 import javax.swing.event.ChangeListener JavaDoc;
29 import org.openide.filesystems.FileObject;
30 import org.netbeans.api.project.Sources;
31 import org.netbeans.api.project.SourceGroup;
32 import org.netbeans.api.java.project.JavaProjectConstants;
33 import org.openide.util.NbBundle;
34 import org.openide.util.Utilities;
35
36
37 /**
38  * Implementation of {@link Sources} interface for BluejProject.
39  * @author Milos Kleint
40  */

41 public class BluejSources implements Sources {
42     
43     private SourceGroup[] javaSources;
44
45     private SourceGroup[] genericSources;
46
47     BluejSources(BluejProject project) {
48         javaSources = new SourceGroup[] {new TheOneSourceGroup(project.getProjectDirectory())};
49         genericSources = new SourceGroup[] {new TheOneSourceGroup(project.getProjectDirectory())};
50     }
51
52     /**
53      */

54     public SourceGroup[] getSourceGroups(final String JavaDoc type) {
55         if (JavaProjectConstants.SOURCES_TYPE_JAVA.equals(type)) {
56             return javaSources;
57         }
58         if (Sources.TYPE_GENERIC.equals(type)) {
59             return genericSources;
60         }
61         return new SourceGroup[0];
62     }
63
64
65     public void addChangeListener(ChangeListener JavaDoc changeListener) {
66         // we never fire anything
67
}
68
69     public void removeChangeListener(ChangeListener JavaDoc changeListener) {
70         // we never fire anything..
71
}
72
73     
74     private static class TheOneSourceGroup implements SourceGroup {
75
76         private FileObject root;
77         
78         private TheOneSourceGroup(FileObject root) {
79             this.root = root;
80         }
81         
82         public FileObject getRootFolder() {
83             return root;
84         }
85
86         public String JavaDoc getName() {
87             return "Sources"; // NOI18N
88
}
89
90         public String JavaDoc getDisplayName() {
91             return NbBundle.getMessage(BluejSources.class, "Source_Group_Display_Name");
92         }
93
94         public Icon JavaDoc getIcon(boolean b) {
95             return new ImageIcon JavaDoc(Utilities.loadImage("/org/netbeans/bluej/resources/bluejproject.png")); // NOI18N
96
}
97
98         public boolean contains(FileObject fileObject) throws IllegalArgumentException JavaDoc {
99             if ("bluej.pkg".equals(fileObject.getNameExt())) { // NOI18N
100
return false;
101             }
102             if ("build.xml".equals(fileObject.getNameExt())) { // NOI18N
103
return false;
104             }
105             if (fileObject.isFolder() && fileObject.getFileObject("bluej.pkg") == null) { // NOI18N
106
return false;
107             }
108             return true;
109         }
110
111         public void addPropertyChangeListener(PropertyChangeListener JavaDoc propertyChangeListener) {
112         // we never fire anything
113
}
114
115         public void removePropertyChangeListener(PropertyChangeListener JavaDoc propertyChangeListener) {
116         // we never fire anything
117
}
118         
119     }
120 }
121
Popular Tags