blob: 49d677f4cf3773bcfbce4e57a071e4b30cb63fd9 [file] [log] [blame]
cbridgha9a27ef82004-11-24 13:18:26 +00001/*******************************************************************************
2 * Copyright (c) 2001, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11package org.eclipse.wst.validation.internal.operations;
12
13import org.eclipse.core.resources.IFile;
14import org.eclipse.core.resources.IProject;
15import org.eclipse.core.resources.IResource;
vbhadrir7218e672005-04-08 13:59:55 +000016import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
cbridgha9a27ef82004-11-24 13:18:26 +000017
18
19
20
21/**
vbhadrir5f826112005-03-31 15:44:59 +000022 * In the eclipse environment, not only does the IValidationContext need to be able to load the MOF model, it
cbridgha9a27ef82004-11-24 13:18:26 +000023 * also needs to load items from the eclipse workbench. This interface should be extended by
24 * workbench IHelpers, so that items can be added to, and from, the task list.
25 */
vbhadrirbaad6402005-04-12 19:36:01 +000026public interface IWorkbenchContext extends IValidationContext {
cbridgha9a27ef82004-11-24 13:18:26 +000027 /**
vbhadrirbaad6402005-04-12 19:36:01 +000028 * When the validation is complete, this method will be called so that the IWorkbenchContext can
cbridgha9a27ef82004-11-24 13:18:26 +000029 * clean up any resources it allocated during the validation.
30 *
31 * If the cleanup is a long-running operation, subtask messages should be sent to the IReporter.
32 */
33 public void cleanup(WorkbenchReporter reporter);
34
35 /**
36 * When the IProject is closing, perform any cleanup that needs to be done. When this method is
37 * called, if the helper has cached any resources from the IProject, it should release those
38 * resources. If you do not allocate resources in your helper, then this method should be a
39 * no-op.
40 */
41 public void closing();
42
43 /**
44 * When the IProject is being deleted, perform any cleanup that needs to be done. When this
45 * method is called, if the helper has cached any resources from the IProject, it should release
46 * those resources. If you do not allocate resources in your helper, then this method should be
47 * a no-op.
48 */
49 public void deleting();
50
51 /**
52 * Given an Object, if the object has a corresponding IFile in the workbench, return the IFile.
53 * Otherwise return null.
54 *
55 * This method is used by the WorkbenchReporter. In eclipse, in order to add or remove a task
56 * list entry, the IResource, to which the entry applies, must be identified. The IReporter
57 * interface passes in an Object in these methods:
58 *
59 * addValidationMessage(IValidator, IMessage) // Object is a part of IMessage
60 *
61 * removeAllMessages(IValidator, Object),
62 *
63 * Thus, the WorkbenchReporter needs to know how, given the Object, which IFile that the Object
64 * represents in the workbench, in order to be able to add the task list entry.
65 *
66 * If this method returns null, then the WorkbenchReporter will add the message to the IProject
67 * instead of an IFile.
68 *
69 * @deprecated Implement getResource(Object) instead.
70 */
71 public IFile getFile(Object object);
72
73 /**
74 * Given an Object, if the object has a corresponding IResource in the workbench, return the
75 * IResourcee. Otherwise return null.
76 *
77 * This method is used by the WorkbenchReporter. In eclipse, in order to add or remove a task
78 * list entry, the IResource, to which the entry applies, must be identified. The IReporter
79 * interface passes in an Object in these methods:
80 *
81 * addValidationMessage(IValidator, IMessage) // Object is a part of IMessage
82 *
83 * removeAllMessages(IValidator, Object),
84 *
85 * Thus, the WorkbenchReporter needs to know how, given the Object, which IFile that the Object
86 * represents in the workbench, in order to be able to add the task list entry.
87 *
88 * If this method returns null, then the WorkbenchReporter will add the message to the IProject
89 * instead of an IResource.
90 */
91 public IResource getResource(Object object);
92
93 /**
94 * Given an IMessage's target object, return the line number, of the IFile, which the target
95 * object represents, if possible. If the object is null, or if access to line numbers is not
96 * possible, return a text description of the location.
97 *
98 * This method will be called whether or not the IResource is an IFile, IFolder, or IProject.
99 * Line numbers are valid only for IFile types; if the resource is not an IFile, then a text
100 * description of the location must be returned.
101 */
102 public String getLocation(Object object);
103
104 /**
105 * Return the name of the resource, without the project-specific information in front.
106 *
107 * This method is used by ValidationOperation to calculate the non-environment specific names of
vbhadrirbaad6402005-04-12 19:36:01 +0000108 * the files. Only the IWorkbenchContext implementation knows how much information to strip off
cbridgha9a27ef82004-11-24 13:18:26 +0000109 * of the IResource name. For example, if there is an EJB Project named "MyEJBProject", and it
110 * uses the default names for the source and output folders, "source" and "ejbModule",
111 * respectively, then the current implementation of EJB Helper knows how much of that structure
112 * is eclipse-specific.
113 *
114 * Since the "source" folder contains Java source files, a portable name would be the
115 * fully-qualified name of the Java class, without the eclipse-specific project and folder names
116 * in front of the file name. The EJBHelper knows that everything up to the "source" folder, for
117 * example, can be removed, because, according to the definition of the EJB Project, everything
118 * contained in the source folder is java source code. So if there is an IResource in an EJB
119 * Project named "/MyEJBProject/source/com/ibm/myclasses/MyJavaFile.java", this method would
120 * make this name portable by stripping off the "/MyEJBProject/source", and returning
121 * "com/ibm/myclasses/MyJavaFile.java".
122 *
123 * The output of this method is used by the ValidationOperation, when it is calculating the list
124 * of added/changed/deleted file names for incremental validation. If getPortableName(IResource)
vbhadrirbaad6402005-04-12 19:36:01 +0000125 * returns null, that means that the IWorkbenchContext's implementation does not support that
cbridgha9a27ef82004-11-24 13:18:26 +0000126 * particular type of resource, and the resource should not be included in the array of
127 * IFileDelta objects in the IValidator's "validate" method.
128 */
129 public String getPortableName(IResource resource);
130
131 /**
vbhadrirbaad6402005-04-12 19:36:01 +0000132 * Return the IProject which is about to be validated. Each IWorkbenchContext knows how to
cbridgha9a27ef82004-11-24 13:18:26 +0000133 * traverse a certain type of IProject, for example, an EJB project or a web project.
134 */
135 public IProject getProject();
136
137 /**
138 * When an IValidator associates a target object with an IMessage, the WorkbenchReporter
139 * eventually resolves that target object with an IResource. Sometimes more than one target
140 * object resolves to the same IResource (usually the IProject, which is the default IResource
141 * when an IFile cannot be found). This method is called, by the WorkbenchReporter, so that the
142 * WorkbenchReporter can distinguish between the IMessages which are on the same IResource, but
143 * refer to different target objects. This is needed for the removeAllMessages(IValidator,
144 * Object) method, so that when one target object removes all of its messages, that it doesn't
145 * remove another target object's messages.
146 *
147 * This method may return null only if object is null. Otherwise, an id which can uniquely
148 * identify a particular object must be returned. The id needs to be unique only within one
149 * particular IValidator.
150 */
151 public String getTargetObjectName(Object object);
152
153 /**
154 * Whether full or incremental validation is running, this method will be called, by the
155 * Validation Framework, for every IResource which is filtered in by the IValidator, so that the
vbhadrir5f826112005-03-31 15:44:59 +0000156 * IValidationContext can receive notification that one of the resources, which validation will run on, is
cbridgha9a27ef82004-11-24 13:18:26 +0000157 * being filtered in.
158 */
159 public void registerResource(IResource resource);
160
161 /**
vbhadrirbaad6402005-04-12 19:36:01 +0000162 * This method is called by the Validation Framework, to initialize the IWorkbenchContext so that
cbridgha9a27ef82004-11-24 13:18:26 +0000163 * it can gather information from the current project.
164 */
165 public void setProject(IProject project);
166
167 /**
vbhadrirbaad6402005-04-12 19:36:01 +0000168 * Notifies this IWorkbenchContext that the Validation Framework is shutting down. There will be
cbridgha9a27ef82004-11-24 13:18:26 +0000169 * calls to closing(IProject) and possibly deleting(IProject) following this call, but the
170 * resources may already be closed by the time that those methods are called, so EVERYTHING
171 * should be cleaned up in this method. The parameter passed in is the project which is about to
172 * shut down. This method will be called once for every IProject in the workbench. The IProject
173 * may, or may not, be closed.
174 */
175 public void shutdown();
176}