1 package net.sourceforge.phpdt.externaltools.variable;
3 /**********************************************************************
4 Copyright (c) 2002 IBM Corp. and others. All rights reserved.
5 This file is made available under the terms of the Common Public License v1.0
6 which accompanies this distribution, and is available at
7 http://www.eclipse.org/legal/cpl-v10.html
10 **********************************************************************/
12 import net.sourceforge.phpdt.externaltools.model.IExternalToolConstants;
14 import org.eclipse.core.resources.IProject;
15 import org.eclipse.core.resources.IResource;
16 import org.eclipse.core.resources.IncrementalProjectBuilder;
19 * Represents the context the external tool is running in that a variable uses
22 public final class ExpandVariableContext {
23 public static final ExpandVariableContext EMPTY_CONTEXT = new ExpandVariableContext(
26 private IProject project = null;
28 private IResource selectedResource = null;
30 private String buildType = IExternalToolConstants.BUILD_TYPE_NONE;
33 * Create a context for an external tool running as a builder on the given
37 * the <code>IProject</code> being built.
39 * the kind of build being performed (see
40 * <code>IncrementalProjectBuilder</code>).
42 public ExpandVariableContext(IProject project, int buildKind) {
44 this.project = project;
46 case IncrementalProjectBuilder.INCREMENTAL_BUILD:
47 this.buildType = IExternalToolConstants.BUILD_TYPE_INCREMENTAL;
49 case IncrementalProjectBuilder.FULL_BUILD:
50 this.buildType = IExternalToolConstants.BUILD_TYPE_FULL;
52 case IncrementalProjectBuilder.AUTO_BUILD:
53 this.buildType = IExternalToolConstants.BUILD_TYPE_AUTO;
56 this.buildType = IExternalToolConstants.BUILD_TYPE_NONE;
62 * Create a context for an external tool running with the given resource
65 * @param selectedResource
66 * the <code>IResource</code> selected or <code>null</code>
69 public ExpandVariableContext(IResource selectedResource) {
71 if (selectedResource != null) {
72 this.selectedResource = selectedResource;
73 this.project = selectedResource.getProject();
78 * Returns the build type being performed if the external tool is being run
79 * as a project builder.
81 * @return one of the <code>IExternalToolConstants.BUILD_TYPE_*</code>
84 public String getBuildType() {
89 * Returns the project which the variable can use. This will the the project
90 * being built if the tool is being run as a builder. Otherwise, it is the
91 * project of the selected resource, or <code>null</code> if none.
93 * @return the <code>IProject</code> or <code>null</code> if none
95 public IProject getProject() {
100 * Returns the resource selected at the time the tool is run, or
101 * <code>null</code> if none selected.
103 * @return the <code>IResource</code> selected, or <code>null</code> if
106 public IResource getSelectedResource() {
107 return selectedResource;