blob: 8f0f2e9dfb5b3cefac38aeeafe8b1cbdf4426575 [file] [log] [blame]
/*
* Copyright (c) 2014 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Eike Stepper - initial API and implementation
*/
package org.eclipse.oomph.targlets.internal.core.variables;
import org.eclipse.oomph.p2.core.Profile;
import org.eclipse.oomph.targlets.core.ITargletContainerDescriptor;
import org.eclipse.oomph.targlets.internal.core.TargletContainerDescriptorManager;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.variables.IDynamicVariable;
import org.eclipse.core.variables.IDynamicVariableResolver;
/**
* @author Eike Stepper
*/
public class TargletContainerProfileDirectory implements IDynamicVariableResolver
{
public String resolveValue(IDynamicVariable variable, String containerID) throws CoreException
{
return getProfileDirectory(containerID);
}
public static String getProfileDirectory(String containerID) throws CoreException
{
ITargletContainerDescriptor descriptor = TargletContainerDescriptorManager.getInstance().getDescriptor(containerID, new NullProgressMonitor());
if (descriptor != null)
{
Profile profile = descriptor.getWorkingProfile();
if (profile != null)
{
return profile.getLocation().getAbsolutePath();
}
}
return null;
}
}