KickJava   Java API By Example, From Geeks To Geeks.

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


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.io.IOException JavaDoc;
23 import java.lang.ref.WeakReference JavaDoc;
24 import java.util.ArrayList JavaDoc;
25 import java.util.Iterator JavaDoc;
26 import java.util.List JavaDoc;
27 import org.netbeans.api.project.Project;
28 import org.netbeans.spi.project.support.ant.AntBasedProjectType;
29 import org.netbeans.spi.project.support.ant.AntProjectHelper;
30
31 /**
32  * Factory for simple bluej based projects.
33  * @author Milos Kleint
34  */

35 public final class BluejProjectType implements AntBasedProjectType {
36
37     public static final String JavaDoc TYPE = "org.netbeans.bluej.bluejproject"; // NOI18N
38
private static final String JavaDoc PROJECT_CONFIGURATION_NAME = "data"; // NOI18N
39
public static final String JavaDoc PROJECT_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/bluej-project/1"; // NOI18N
40
private static final String JavaDoc PRIVATE_CONFIGURATION_NAME = "data"; // NOI18N
41
private static final String JavaDoc PRIVATE_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/bluej-project-private/1"; // NOI18N
42

43     private List JavaDoc weakList = new ArrayList JavaDoc();
44     /** Do nothing, just a service. */
45     public BluejProjectType() {}
46     
47     public String JavaDoc getType() {
48         return TYPE;
49     }
50     
51     public Project createProject(AntProjectHelper helper) throws IOException JavaDoc {
52         Iterator JavaDoc it = weakList.iterator();
53         while (it.hasNext()) {
54             WeakReference JavaDoc ref = (WeakReference JavaDoc) it.next();
55             Project elem = (Project)ref.get();
56             if (elem != null && elem.getProjectDirectory().equals(helper.getProjectDirectory())) {
57                 return elem;
58             }
59         }
60         Project toReturn = new BluejProject(helper);
61         weakList.add(new WeakReference JavaDoc(toReturn));
62         return toReturn;
63     }
64
65     public String JavaDoc getPrimaryConfigurationDataElementName(boolean shared) {
66         return shared ? PROJECT_CONFIGURATION_NAME : PRIVATE_CONFIGURATION_NAME;
67     }
68     
69     public String JavaDoc getPrimaryConfigurationDataElementNamespace(boolean shared) {
70         return shared ? PROJECT_CONFIGURATION_NAMESPACE : PRIVATE_CONFIGURATION_NAMESPACE;
71     }
72     
73 }
74
Popular Tags