home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Main.bin
/
VisualProject.java
< prev
next >
Wrap
Text File
|
1998-11-11
|
24KB
|
615 lines
/*
* Copyright 1998 Symantec Corporation, All Rights Reserved.
*/
package com.symantec.itools.vcafe.openapi;
import com.symantec.itools.vcafe.openapi.options.ProjectOptionSet;
import com.symantec.itools.vcafe.openapi.dtreflect.DTClass;
import com.symantec.itools.vcafe.openapi.dtreflect.DTListener;
import java.io.File;
import java.util.Enumeration;
import java.net.URL;
/**
* The API used to represent and access a Visual Cafe project.
*
* To get a <code>VisualProject</code> to work with, use one of the following <code>VisualCafe</code> methods:<ul style=circle>
* <li><code>getProjects()</code> to get all open projects,
* <li><code>getTargetProject()</code> to get the currently active project,
* <li><code>getProject()</code> to get an open project with a given name,
* <li><code>openProject()</code> to open a project,
* <li><code>createProject()</code> to create a new project,
* <li><code>createEmptyProject()</code> to create a new empty project, or
* <li><code>createDefaultProject()</code> to create a new project from the default project template.
* </ul>
*
* The implementation of all of <code>VisualProject</code>'s abstract methods first calls
* checkValidity(). Any method could therefore throw an <code>InvalidVisualProjectException</code>.
* This exception extends <code>RuntimeException</code>, so doesn't have to be explicity declared or
* caught. A <code>VisualProject</code> can become invalid if it is closed, and the corresponding
* <code>ProjectListener</code> message is ignored, for example.
*
* @see VisualCafe
* @see VisualCafe#getProjects
* @see VisualCafe#getTargetProject
* @see VisualCafe#getProject
* @see VisualCafe#openProject
* @see VisualCafe#createProject
* @see VisualCafe#createEmptyProject
* @see VisualCafe#createDefaultProject
*
* @author Symantec Internet Tools Division
* @version 1.0
* @since VCafe 3.0
*/
public abstract class VisualProject
{
/**
* Gets the name of the project.
*
* @return name of the project.
*/
public abstract String getProjectName();
/**
* Gets the built project's document base.
*
* @return the document base for this project's executable.
*/
public abstract URL getDocumentBase() throws java.net.MalformedURLException;
/**
* Gets the <code>File</code> associated with this <code>VisualProject</code> file.
* @return this <code>VisualProject</code>'s <code>File</code>.
*/
public abstract File getFile();
/**
* Mark this <code>VisualProject</code>'s contents modified.
* This can be useful if you save persistent attributes in response to
* <code>ProjectListener.aboutToSaveProject()</code>.
* @see ProjectListener#aboutToSaveProject
*/
public abstract void setModified();
/**
* Saves this <code>VisualProject</code>.
*/
public abstract void save();
/**
* Saves this <code>VisualProject</code> to a new name.
* @param newFile where to save this <code>VisualProject</code>.
*/
public abstract void saveAs(File newFile);
/**
* Closes this <code>VisualProject</code>.
*/
public abstract void close();
/**
* Gets the class that allows access to this project's <code>VisualObjects</code>.
*
* @return this project's object library
* @see VisualRepository
*/
public abstract VisualRepository getObjectLibrary();
/**
* Get the <code>Attributes</code> object that allows project-related named value storage.
*
* The values stored in the returned <code>Attributes</code> object are assoicated with this
* specific <code>VisualProject</code>, not with the Visual Cafe program in general. To create
* global name values (not specific to any one project), use <code>VisualCafe</code>'s
* <code>getAttributes</code> method.
* @return this project's <code>Attributes</code> storage object.
* @see ProjectInputStream
* @see Attributes
*/
public abstract Attributes getAttributes();
/**
* Gets the <code>ClassLoader</code> for objects/classes in this project.
*
* @return this project's <code>ClassLoader</code>.
*/
public abstract ClassLoader getClassLoader();
/**
* Gets this project's 'type'. More specific than the project's target type.
* @return the project's type.
* @see symantec.itools.projecttemplates.ProjectTemplateInterface;
* @see com.symantec.itools.vcafe.openapi.options.ProjectOptions#getTargetType
*/
public abstract int getProjectType();
/**
* Sets this project's 'type'. More specific than the project's target type. The Target Type
* is updated in all of the project's option sets (Debug and Final).
* @param projectType the project's new type.
* @see symantec.itools.projecttemplates.ProjectTemplateInterface;
* @see com.symantec.itools.vcafe.openapi.options.ProjectOptions#getTargetType
*/
public abstract void setProjectType(int projectType);
/**
* Gets this project's options.
* The returned <code>ProjectOptionSet</code> allows access to the options for this project.
*
* @return the project's options.
* @see com.symantec.itools.vcafe.openapi.options.ProjectOptionSet
*/
public abstract ProjectOptionSet getOptionSet();
/**
* Gets the class that allows access to this project's build commands.
* @return this project's <code>BuildManager</code>
* @see BuildManager
*/
public abstract BuildManager getBuildManager();
/**
* Builds the project and runs the resulting program.
* The debugger is <i>not</i> used to run the program.
* @see BuildManager#build
*/
public abstract void execute();
/**
* Builds the project and runs the resulting program under the debugger.
* @see BuildManager#build
*/
public abstract void runInDebugger();
/**
* Gets the Design-Time Reflection <code>DTClass</code> object associated with the class
* with the given string name.
* @param className the name of a class in the project to find a design-time reflection class for.
* @return a <code>DTClass</code> object for the class.
*/
public abstract DTClass getDTClassObject(String className);
/**
* Parses the files in the project. Only outdated files are parsed. This causes
* the project's Design-Time Reflection classes to be updated.
*/
public abstract void parseOutstandingFiles();
/**
* Tells this project to suspend the background parsing of <code>DTClass</code> information.
* @param bringUpToDate if <code>true</code>, make sure the state of the <code>DTClass</code> information is
* brought up to date before suspending the parser.
* This method <b>must</b> be matched by a call to <code>resumeBackgroundParser()</code>.
* example usage:<code>
* visualProject.suspendBackgroundParser(false);
* try {
* ...
* ... lots of processing here that causes parsing ...
* ...
* } finally {
* visualProject.resumeBackgroundParser(true);
* }</code>
*/
public abstract void suspendBackgroundParser(boolean bringUpToDate);
/**
* Tells the project that it can resume the background parsing of <code>DTClass</code> information.
* @param bringUpToDate if true, update the <code>DTClass</code> information.
*/
public abstract void resumeBackgroundParser(boolean bringUpToDate);
/**
* Gets all of the files in this project.
* An array is returned containing all of the files. If there are no files in the project, a
* zero-length array is returned.
*
* @return array of <code>ProjectFile</code> objects
* @see #getProjectFiles(int)
* @see #getProjectFile(String)
* @see #getProjectFile(int)
* @see ProjectFile
*/
public abstract ProjectFile[] getProjectFiles();
/**
* Gets all of the files in this project added by the specified source.
* An array is returned containing all of the added files. If there are no files, a
* zero-length array is returned.
* @param addedBy the source that added the file to the project, is a mask containing any of:<ul type=circle>
* <li>USER_ADDED - files added by the user.
* <li>COMPILER_ADDED - files added by the compiler.
* <li>PARSER_ADDED - files added by the parser.
* <li>UNKNOWN_ADDED - files added by an unknown source.
* <li>SHARED_DATABASE_ADDED - files added by the database.
* <li>ERAD_WIZARD_ADDED - the file was added by one of the ERAD wizards.
* <li>ALL_FILE_ADDED - files added by any source.
* </ul>
* @return array of <code>ProjectFile</code> objects
* @see #getProjectFiles()
* @see #getProjectFile(String)
* @see #getProjectFile(int)
* @see ProjectFile
* @see ProjectFile#getFileAddedBy
*/
public abstract ProjectFile[] getProjectFiles(int addedBy);
/**
* Gets a <code>ProjectFile</code> that corresponds to the file with the given name.
* If the file isn't in this project, <code>null</code> is returned.
* @param fileName the name of the desired file.
* @return a <code>ProjectFile</code> object, or <code>null</code> if not found.
* @see #getProjectFiles()
* @see #getProjectFile(int)
* @see ProjectFile
*/
public abstract ProjectFile getProjectFile(String fileName);
/**
* Gets a <code>ProjectFile</code> that corresponds to the file id.
* If the file isn't in this project, <code>null</code> is returned.
* @param projectFileId the id of the desired file.
* @return a <code>ProjectFile</code> object, or <code>null</code> if not found.
* @see #getProjectFiles()
* @see #getProjectFile(String)
* @see ProjectFile
*/
public abstract ProjectFile getProjectFile(int projectFileID);
/**
* Adds a [relative, ProjectFile.USER_ADDED, ENABLE_RAD_DEFAULT, UPDATE_PROJECT_BEANS_NO] file to this <code>VisualProject</code>.
* @param file file to be added.
* @return the resultant <code>ProjectFile</code> object.
* @exception IllegalArgumentException if the file doesn't exist or is a diretory.
* @see ProjectFile
*/
public abstract ProjectFile addFile(File file);
/**
* An <code>addFile</code> "enableRAD" value indicating the file should added with RAD enabled.
* @see #addFile(String, boolean, int, int)
*/
public static final int ENABLE_RAD_ON = 0;
/**
* An <code>addFile</code> "enableRAD" value indicating the file should added with RAD disabled.
* @see #addFile(String, boolean, int, int)
*/
public static final int ENABLE_RAD_OFF = 1;
/**
* An <code>addFile</code> "enableRAD" value indicating the file should added with RAD set to the default
* value for the project.
* @see #addFile(String, boolean, int, int)
*/
public static final int ENABLE_RAD_DEFAULT = 2;
/**
* An <code>addFile</code> "updateProjectBeans" value indicating that after the file is added, project beans should be
* updated.
* @see #addFile(String, boolean, int, int)
*/
public static final int UPDATE_PROJECT_BEANS_YES = 0;
/**
* An <code>addFile</code> "updateProjectBeans" value indicating that after the file is added, project beans should be
* NOT be updated.
* @see #addFile(String, boolean, int, int)
*/
public static final int UPDATE_PROJECT_BEANS_NO = 1;
/**
* An <code>addFile</code> "updateProjectBeans" value indicating that after the file is added, the user should be prompted
* about updating project beans.
* @see #addFile(String, boolean, int, int)
*/
public static final int UPDATE_PROJECT_BEANS_ASK = 2;
/**
* Adds a [ProjectFile.USER_ADDED] file to this <code>VisualProject</code>.
* @param fileName the name of the file to be added.
* @param makeRelative option to make the file relative to the project or not.
* @param enableRAD should RAD be turned on for this file. Can be one of ENABLE_RAD_ON, ENABLE_RAD_OFF
* or ENABLE_RAD_DEFAULT.
* @param updateProjectBeans should local beans be updated after this file is added. Can be one of UPDATE_PROJECT_BEANS_YES,
* UPDATE_PROJECT_BEANS_NO, or UPDATE_PROJECT_BEANS_ASK.
* @return the resultant <code>ProjectFile</code> object.
* @exception IllegalArgumentException if the file doesn't exist or is a diretory.
* @see ProjectFile
*/
public abstract ProjectFile addFile(String fileName, boolean makeRelative, int enableRAD, int updateProjectBeans);
/**
* Adds a [ENABLE_RAD_DEFAULT, UPDATE_PROJECT_BEANS_NO] file to this <code>VisualProject</code>.
*
* @param fileName name of the file to be added.
* @param addedBy who is adding this file.
* @param makeRelative option to make the file relative to the project or not.
* @return the resultant <code>ProjectFile</code> object.
* @exception IllegalArgumentException if the file doesn't exist or is a diretory.
* @see ProjectFile
*/
public abstract ProjectFile addFile(String fileName, int addedBy, boolean makeRelative);
/**
* Removes a <code>ProjectFile</code> from this project.
* @param file the <code>ProjectFile</code> to remove.
* @see ProjectFile
*/
public abstract void removeFile(ProjectFile file);
/**
* Removes a <code>ProjectFile</code> from this project.
* @param file the File to remove.
* @exception IllegalArgumentException if the file doesn't exist, is a directory, or isn't
* part of this project.
*/
public abstract void removeFile(File file);
/**
* Renames a file in this project. The new file name must be fully qualified.
* This method optionally overwrites any existing file with the same new name.
* The old file with the original name is deleted.
*
* @param file the <code>ProjectFile</code> that will be renamed.
* @param newName the new fully qualified name for this file.
* @param replace <code>true</code> to overwrite any file that might already have the new name.
*/
public abstract void renameFile(ProjectFile file, String newName, boolean replace);
/**
* Creates a file in this <code>VisualProject</code>. The file will be created relative to the project's
* location.
*
* @param fileName the name of the new <code>ProjectFile</code>.
* @param contents the text contents to put in this file.
* @param enableRAD should RAD be turned on for this file.
* @return the resultant <code>ProjectFile</code> object.
* @see ProjectFile
*/
public abstract ProjectFile createFile(String fileName, String contents, int enableRAD);
/**
* Creates a file in this <code>VisualProject</code>. The file will be created relative to the project's
* location.
*
* @param fileName the name of the new <code>ProjectFile</code>.
* @param contents the binary contents to put in this file.
* @param enableRAD should RAD be turned on for this file.
* @return the resultant <code>ProjectFile</code> object.
* @see ProjectFile
*/
public abstract ProjectFile createFile(String fileName, byte[] contents, int enableRAD);
/**
* This method triggers the <code>aboutToChangeProjectEntries()</code> message to be
* sent to all <code>ProjectListeners</code> registered to this project.
*
* @see ProjectListener#aboutToChangeProjectEntries
* @see #doneChangingProjectEntries
*/
public abstract void aboutToChangeProjectEntries();
/**
* This method triggers the <code>doneChangingProjectEntries()</code> message to be
* sent to all <code>ProjectListeners</code> registered to this project.
*
* @see ProjectListener#doneChangingProjectEntries
* @see #aboutToChangeProjectEntries
*/
public abstract void doneChangingProjectEntries();
/**
* Forces all of the project's local beans to be updated.
*/
public abstract void updateProjectBeans();
/**
* Indicates the "Objects" tab is selected in the project window.
* @see #getSelectedTab
*/
public static final int OBJECTS_TAB = 0;
/**
* Indicates the "Packages" tab is selected in the project window.
* @see #getSelectedTab
*/
public static final int PACKAGES_TAB = 1;
/**
* Indicates the "Files" tab is selected in the project window.
* @see #getSelectedTab
*/
public static final int FILES_TAB = 2;
/**
* Determines which tab is selected in the project window.
* @return an integer that identifies the selected tab, one of:<ul type=circle>
* <li>OBJECTS_TAB - the "Objects" tab is selected,
* <li>PACKAGES_TAB - the "Packages" tab is selected, or
* <li>FILES_TAB - the "Files" tab is selected
* </ul>
* @see #setSelectedTab
*/
public abstract int getSelectedTab();
/**
* Selects the tab in the project window.
* @param selectedTab an integer that identifies the selected tab, one of:<ul type=circle>
* <li>OBJECTS_TAB - the "Objects" tab is selected,
* <li>PACKAGES_TAB - the "Packages" tab is selected, or
* <li>FILES_TAB - the "Files" tab is selected
* </ul>
* @see #getSelectedTab
*/
public abstract void setSelectedTab(int selectedTab);
/**
* Gets a list of the selected objects in this project window.
* If no objects are selected a zero-length array is returned.
* @return an array of selected <code>VisualObject</code> objects.
*/
public abstract VisualObject[] getSelectedObjects();
/**
* Get a list of the selected files in this project window.
* If no files are selected a zero-length array is returned.
* @return an array of selected <code>ProjectFile</code> objects.
*/
public abstract ProjectFile[] getSelectedFiles();
/**
* Add a listener to this project.
* Changes to this project are broadcast to the listeners registered with it.
* To be notified of changes, a plug-in implements the <code>ProjectListener</code> interface, then calls
* this method to place itself on the notification list. When this <code>VisualProject</code> changes, the
* appropriate listener method is called.
* @param listener the object that receives notifications of changes to this project.
*
* @see ProjectListener
* @see #removeProjectListener
*/
public abstract void addProjectListener(ProjectListener projectListener);
/**
* Remove a listener from this project. Stops the listener from receiving notifications of
* changes to this project.
* @param listener the object that was receiving notifications.
*
* @see ProjectListener
* @see #addProjectListener
*/
public abstract void removeProjectListener(ProjectListener projectListener);
/**
* Add a <code>DTListener</code> to this project.
* Changes to this project's Design-Time Reflection classes are broadcast to the listeners registered with it.
* To be notified of changes, a plug-in implements the <code>com.symantec.itools.vcafe.openapi.dtreflect.DTListener</code>
* interface, then calls this method to place itself on the notification list. When this <code>VisualProject</code>'s
* Design-Time Reflection information changes, the listener is called.
*
* @param listener the object that receives notifications
* @see #removeDTListener
* @see VisualCafe#addDTListener
* @see com.symantec.itools.vcafe.openapi.dtreflect.DTListener
*/
public abstract void addDTListener(DTListener listener);
/**
* Remove a <code>DTListener</code> from this project. Stops the listener from receiving notifications of
* changes to this project's Design-Time Reflection classes.
*
* @param listener the object that was receiving notifications
* @see #addDTListener
* @see VisualCafe#removeDTListener
* @see com.symantec.itools.vcafe.openapi.dtreflect.DTListener
*/
public abstract void removeDTListener(DTListener listener);
/**
* Creates a new interaction and opens an editor to edit it.
*
* <p>The method returns before editing begins. There is no guarantee that
* an interaction involving the objects specified will result, e.g., the
* user may cancel the interaction or specify other from and to objects.
* If called while the wizard is running (not likely because the wizard
* is modal, but possible) the wizard will queue the request to be performed
* after the current session is completed.
*
* @param from the <code>VisualObject</code> that fires the event; must not be <code>null</code>.
* @param to the <code>VisualObject</code> that is affected by the interaction;
* may be <code>null</code>.
*/
public abstract void createNewInteraction(VisualObject from, VisualObject to);
/**
* Create a new interaction and open an editor to edit it.
*
* <p>Same as above except sets the interaction editor preference based on
* the preferEditor argument. The editor preference applies to all subsequent
* createNewInteraction calls without the third argument, in any project.
*
* @param from the <code>VisualObject</code> that fires the event; must not be <code>null</code>.
* @param to the <code>VisualObject</code> that is affected by the interaction;
* may be <code>null</code>.
* @param useEditor <code>true</code> if the interaction editor is to be used,
* <code>false</code> if the interaction wizard is to be used.
*/
public abstract void createNewInteraction(VisualObject from, VisualObject to, boolean useEditor);
/**
* Determines if this <code>VisualProject</code> corresponds to a valid project in Visual Cafe.
* @return <code>true</code> if so, <code>false</code> otherwise.
* @see #checkValidity
*/
public abstract boolean isValid();
/**
* Checks that this <code>VisualProject</code> corresponds to a valid project in Visual Cafe.
* Note that the implementation of all of <code>VisualProject</code>'s abstract methods first call
* checkValidity(). Any method could therefore throw an <code>InvalidVisualProjectException</code>.
* @exception com.symantec.itools.vcafe.openapi.InvalidVisualProjectException
* when the VisualProject has been closed, for example.
*/
public void checkValidity() throws InvalidVisualProjectException {
if (!isValid()) throw new InvalidVisualProjectException();
}
/**
* Gets a <code>String</code> that represents this object.
* @return the <code>String</code>,
*/
public String toString() {
if (!isValid()) return "invalid VisualProject: " + super.toString();
return "VisualProject[" + getProjectName() + "]";
}
/**
* ObjectInputStream with getProject() method for streaming
* in objects that require a project to instantiate themselves.
* A VisualProject's Persistent Attributes are retrieved using a ProjectInputStream
* (via VisualProject.getAttributes().getPersistentAttributeValue(Class, String)),
* so that your Serialized attribute can reconstitute itself in its readObject() using
* the project's information.
*
*/
public class ProjectInputStream extends java.io.ObjectInputStream
{
public ProjectInputStream(java.io.InputStream in) throws java.io.IOException {
super(in);
try {
enableResolveObject(true);
} catch (Exception e) {
System.err.println("ERROR IN PROJECTINPUT STREAM");
e.printStackTrace();
}
}
public VisualProject getProject() {
return VisualProject.this;
}
protected Object resolveObject(Object obj)
{
if (obj != null && obj instanceof DTClass) {
DTClass clazz = (DTClass) obj;
if (clazz.isPrimitive()) {
DTClass replacement = DTClass.getPrimitiveClass(clazz.getName());
if (replacement != null)
return replacement;
}
}
return obj;
}
}
}