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-2006 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.apache.tools.ant.module.api;
043:
044: import javax.swing.event.ChangeListener;
045: import java.io.File;
046: import org.w3c.dom.Document;
047: import org.w3c.dom.Element;
048: import org.openide.nodes.Node;
049: import org.openide.filesystems.FileObject;
050:
051: /**
052: * Cookie containing the state of an Ant Project.
053: * Note that there is a document, and also a parse exception.
054: * At least one must be non-null; it is possible for both to be
055: * non-null in case there was a valid parse before, and some changes
056: * are now invalid.
057: */
058: public interface AntProjectCookie extends Node.Cookie {
059: /** Get the disk file for the build script.
060: * @return the disk file, or null if none (but must be a file object)
061: */
062: File getFile();
063:
064: /** Get the file object for the build script.
065: * @return the file object, or null if none (but must be a disk file)
066: */
067: FileObject getFileObject();
068:
069: /** Get the DOM document for the build script.
070: * @return the document, or null if it could not be parsed
071: */
072: Document getDocument();
073:
074: /** Get the DOM root element (<code><project></code>) for the build script.
075: * @return the root element, or null if it could not be parsed
076: */
077: Element getProjectElement();
078:
079: /** Get the last parse-related exception, if there was one.
080: * @return the parse exception, or null if it is valid
081: */
082: Throwable getParseException();
083:
084: /** Add a listener to changes in the document.
085: * @param l the listener to add
086: */
087: void addChangeListener(ChangeListener l);
088:
089: /** Remove a listener to changes in the document.
090: * @param l the listener to remove
091: */
092: void removeChangeListener(ChangeListener l);
093:
094: /** Extended cookie permitting queries of parse status.
095: * If only the basic cookie is available, you cannot
096: * determine if a project is already parsed or not, and
097: * methods which require it to be parsed for them to return
098: * may block until a parse is complete.
099: * @since 2.10
100: */
101: interface ParseStatus extends AntProjectCookie {
102: /** Check whether the project is currently parsed.
103: * Note that "parsed in error" is still considered parsed.
104: * <p>If not parsed, then if and when it does later become
105: * parsed, a change event should be fired. A project
106: * might become unparsed after being parsed, due to e.g.
107: * garbage collection; this need not fire any event.
108: * <p>If the project is currently parsed, the methods
109: * {@link AntProjectCookie#getDocument},
110: * {@link AntProjectCookie#getProjectElement}, and
111: * {@link AntProjectCookie#getParseException} should
112: * not block.
113: * @return true if this project is currently parsed
114: */
115: boolean isParsed();
116: }
117:
118: }
|