001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.visualweb.gravy.model.project;
043:
044: import org.netbeans.modules.visualweb.gravy.Bundle;
045:
046: import java.util.ArrayList;
047: import java.util.List;
048: import javax.swing.tree.TreePath;
049:
050: /**
051: * Class for root entry of the Project.
052: */
053:
054: public class RootEntry implements ProjectEntry {
055:
056: private final static String bundle = "org.netbeans.modules.visualweb.gravy.model.project.Bundle";
057:
058: public final static String sourcePackagesName = Bundle
059: .getStringTrimmed(Bundle.getStringTrimmed(bundle,
060: "WebProjectsBundle"), Bundle.getStringTrimmed(
061: bundle, "SourcePackages"));
062: public final static String webPagesName = Bundle.getStringTrimmed(
063: Bundle.getStringTrimmed(bundle, "WebProjectsBundle"),
064: Bundle.getStringTrimmed(bundle, "WebPages"));
065:
066: /**
067: * Project which the root entry created for.
068: */
069: Project project;
070:
071: /**
072: * Child project entries of the root entry.
073: */
074: List childList = new ArrayList();
075:
076: /**
077: * Creates a new instance of root entry.
078: */
079: public RootEntry(Project project) {
080: this .project = project;
081: }
082:
083: /**
084: * Save root entry.
085: */
086: public void save() {
087: }
088:
089: /**
090: * Save root entry as root entry with specified name.
091: */
092: public void saveAs(String name) {
093: }
094:
095: /**
096: * @return Project which the root entry belong to.
097: */
098: public Project getProject() {
099: return project;
100: }
101:
102: /**
103: * Get name of root entry.
104: * @return Name of the root entry.
105: */
106: public String getName() {
107: return null;
108: }
109:
110: /**
111: * @return TreePath of the root entry.
112: */
113: public TreePath getTreePath() {
114: return null;
115: }
116:
117: /**
118: * @return Parent of the root entry.
119: */
120: public ProjectEntry getParent() {
121: return null;
122: }
123:
124: /**
125: * @return Child project entries of the root entry.
126: */
127: public ProjectEntry[] getChildren() {
128: return ((ProjectEntry[]) childList
129: .toArray(new ProjectEntry[childList.size()]));
130: }
131:
132: /**
133: * @return Web Page root folder.
134: */
135: public WebPageFolder getWebPageRootFolder() {
136: ProjectEntry[] prjEntries = getChildren();
137: for (int i = 0; i < prjEntries.length; i++) {
138: if (prjEntries[i] instanceof WebPageFolder
139: && ((WebPageFolder) prjEntries[i]).getName()
140: .equals(webPagesName)) {
141: return ((WebPageFolder) prjEntries[i]);
142: }
143: }
144: return null;
145: }
146:
147: /**
148: * @return Source root folder.
149: */
150: public SourceFolder getSourceRootFolder() {
151: ProjectEntry[] prjEntries = getChildren();
152: for (int i = 0; i < prjEntries.length; i++) {
153: if (prjEntries[i] instanceof SourceFolder
154: && ((SourceFolder) prjEntries[i]).getName().equals(
155: sourcePackagesName)) {
156: return ((SourceFolder) prjEntries[i]);
157: }
158: }
159: return null;
160: }
161:
162: /**
163: * Remove root entry.
164: */
165: public void delete() {
166: }
167: }
|