KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > AntPropertyValueProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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
12 package org.eclipse.ant.internal.ui;
13
14 import org.eclipse.ant.core.IAntPropertyValueProvider;
15 import org.eclipse.core.runtime.IPath;
16 import org.eclipse.jdt.core.JavaCore;
17
18 /**
19  * Dynamic provider for Ant properties.
20  *
21  * Provides the dynamic values for the following Ant properties:
22  *
23  * <ul>
24  * <li><code>eclipse.target</code> - set to the Eclipse target platform location</li>
25  * </ul>
26  *
27  * @since 3.1
28  */

29 public class AntPropertyValueProvider implements IAntPropertyValueProvider {
30     /**
31      * Returns the dynamic property values for Ant properties.
32      *
33      * @param propertyName The name of the property to resolve the value for
34      * @return The resolved value for the property
35      * @see org.eclipse.ant.core.IAntPropertyValueProvider#getAntPropertyValue(String)
36      */

37     public String JavaDoc getAntPropertyValue(String JavaDoc propertyName) {
38         String JavaDoc value = null;
39         if ("eclipse.target".equals(propertyName)) { //$NON-NLS-1$
40
try {
41                 IPath home= JavaCore.getClasspathVariable("ECLIPSE_HOME"); //$NON-NLS-1$
42
if (home != null) {
43                     value = home.toFile().getAbsolutePath();
44                     if (value.endsWith("/")) { //$NON-NLS-1$
45
value = value.substring(0, value.length() - 1);
46                     }
47                 }
48             } catch (Exception JavaDoc e) {
49                 AntUIPlugin.log(e);
50             }
51         }
52         return value;
53     }
54 }
55
Popular Tags