KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > resources > IFileModificationValidator


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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  *******************************************************************************/

11 package org.eclipse.core.resources;
12
13 import org.eclipse.core.resources.team.FileModificationValidator;
14 import org.eclipse.core.runtime.IStatus;
15
16 /**
17  * The file modification validator is a Team-related hook for pre-checking operations
18  * that modify the contents of files.
19  * <p>
20  * This interface is used only in conjunction with the
21  * "org.eclipse.core.resources.fileModificationValidator"
22  * extension point. It is intended to be implemented only
23  * by the Eclipse Platform Team plug-in.
24  * </p>
25  *
26  * @since 2.0
27  * @deprecated clients should subclass {@link FileModificationValidator} instead
28  * of implementing this interface
29  */

30 public interface IFileModificationValidator {
31     /**
32      * Validates that the given files can be modified. The files must all exist
33      * in the workspace. The optional context object may be supplied if
34      * UI-based validation is required. If the context is <code>null</code>, the
35      * validator must attempt to perform the validation in a headless manner.
36      * The returned status is <code>IStatus.OK</code> if this validator
37      * believes the given file can be modified. Other return statuses indicate
38      * the reason why the individual files cannot be modified.
39      *
40      * @param files the files that are to be modified; these files must all exist in the workspace
41      * @param context the <code>org.eclipse.swt.widgets.Shell</code> that is to be used to
42      * parent any dialogs with the user, or <code>null</code> if there is no UI context (declared
43      * as an <code>Object</code> to avoid any direct references on the SWT component)
44      * @return a status object that is OK if things are fine, otherwise a status describing
45      * reasons why modifying the given files is not reasonable
46      * @see IWorkspace#validateEdit(IFile[], Object)
47      */

48     public IStatus validateEdit(IFile[] files, Object JavaDoc context);
49
50     /**
51      * Validates that the given file can be saved. This method is called from
52      * <code>IFile#setContents</code> and <code>IFile#appendContents</code>
53      * before any attempt to write data to disk. The returned status is
54      * <code>IStatus.OK</code> if this validator believes the given file can be
55      * successfully saved. In all other cases the return value is a non-OK status.
56      * Note that a return value of <code>IStatus.OK</code> does not guarantee
57      * that the save will succeed.
58      *
59      * @param file the file that is to be modified; this file must exist in the workspace
60      * @return a status indicating whether or not it is reasonable to try writing to the given file;
61      * <code>IStatus.OK</code> indicates a save should be attempted.
62      *
63      * @see IFile#setContents(java.io.InputStream, int, org.eclipse.core.runtime.IProgressMonitor)
64      * @see IFile#appendContents(java.io.InputStream, int, org.eclipse.core.runtime.IProgressMonitor)
65      */

66     public IStatus validateSave(IFile file);
67 }
68
Popular Tags