1 /*******************************************************************************
2  * Copyright (c) 2007 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.core.resources.team;
15 
16 import org.eclipse.core.resources.IWorkspace;
17 
18 /**
19  * A context that is used in conjunction with the {@link FileModificationValidator}
20  * to indicate that UI-based validation is desired.
21  * <p>
22  * This class is not intended to be instantiated or subclassed by clients.
23  *
24  * @see FileModificationValidator
25  * @since 3.3
26  */
27 public class FileModificationValidationContext {
28 
29 	/**
30 	 * Constant that can be passed to {@link IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], Object)}
31 	 * to indicate that the caller does not have access to a UI context but would still
32 	 * like to have UI-based validation if possible.
33 	 */
34 	public static final FileModificationValidationContext VALIDATE_PROMPT = new FileModificationValidationContext(null);
35 
36 	private final Object shell;
37 
38 	/**
39 	 * Create a context with the given shell.
40 	 *
41 	 * @param shell the shell
42 	 */
FileModificationValidationContext(Object shell)43 	FileModificationValidationContext(Object shell) {
44 		this.shell = shell;
45 	}
46 
47 	/**
48 	 * Return the <code>org.eclipse.swt.widgets.Shell</code> that is to be used to
49 	 * parent any dialogs with the user, or <code>null</code> if there is no UI context
50 	 * available (declared as an <code>Object</code> to avoid any direct references on the SWT component).
51 	 * If there is no shell, the {@link FileModificationValidator} may still perform
52 	 * UI-based validation if they can obtain a Shell from another source.
53 	 * @return the <code>org.eclipse.swt.widgets.Shell</code> that is to be used to
54 	 *    parent any dialogs with the user, or <code>null</code>
55 	 */
getShell()56 	public Object getShell() {
57 		return shell;
58 	}
59 }