Search in sources :

Example 1 with IFacetedProjectBase

use of org.eclipse.wst.common.project.facet.core.IFacetedProjectBase in project liferay-ide by liferay.

the class LiferayRuntimePropertyTester method test.

public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    boolean retval = false;
    try {
        EnablementExpressionContext ctx = (EnablementExpressionContext) receiver;
        IFacetedProjectBase projectBase = ctx.getFacetedProject();
        IRuntime serverRuntime = FacetUtil.getRuntime(projectBase.getPrimaryRuntime());
        String runtimeId = serverRuntime.getRuntimeType().getId();
        if (runtimeId.startsWith("com.liferay.")) {
            retval = true;
        }
    } catch (Throwable t) {
    // don't log error just means test returns false;
    }
    return retval;
}
Also used : EnablementExpressionContext(org.eclipse.jst.common.project.facet.core.libprov.EnablementExpressionContext) IFacetedProjectBase(org.eclipse.wst.common.project.facet.core.IFacetedProjectBase) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 2 with IFacetedProjectBase

use of org.eclipse.wst.common.project.facet.core.IFacetedProjectBase in project liferay-ide by liferay.

the class SDKClasspathContainerInstallOperation method execute.

@Override
public void execute(LibraryProviderOperationConfig config, IProgressMonitor monitor) throws CoreException {
    IFacetedProjectBase facetedProject = config.getFacetedProject();
    IProject project = facetedProject.getProject();
    IJavaProject javaProject = JavaCore.create(project);
    IPath containerPath = getClasspathContainerPath();
    // IDE-413 check to make sure that the containerPath doesn't already existing.
    IClasspathEntry[] entries = javaProject.getRawClasspath();
    for (IClasspathEntry entry : entries) {
        if (entry.getPath().equals(containerPath)) {
            return;
        }
    }
    IAccessRule[] accessRules = {};
    IClasspathAttribute[] attributes = { JavaCore.newClasspathAttribute(IClasspathDependencyConstants.CLASSPATH_COMPONENT_NON_DEPENDENCY, StringPool.EMPTY) };
    IClasspathEntry newEntry = JavaCore.newContainerEntry(containerPath, accessRules, attributes, false);
    IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
    System.arraycopy(entries, 0, newEntries, 0, entries.length);
    newEntries[entries.length] = newEntry;
    javaProject.setRawClasspath(newEntries, monitor);
}
Also used : IClasspathAttribute(org.eclipse.jdt.core.IClasspathAttribute) IJavaProject(org.eclipse.jdt.core.IJavaProject) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IProject(org.eclipse.core.resources.IProject) IFacetedProjectBase(org.eclipse.wst.common.project.facet.core.IFacetedProjectBase) IAccessRule(org.eclipse.jdt.core.IAccessRule)

Aggregations

IFacetedProjectBase (org.eclipse.wst.common.project.facet.core.IFacetedProjectBase)2 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1 IAccessRule (org.eclipse.jdt.core.IAccessRule)1 IClasspathAttribute (org.eclipse.jdt.core.IClasspathAttribute)1 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 EnablementExpressionContext (org.eclipse.jst.common.project.facet.core.libprov.EnablementExpressionContext)1 IRuntime (org.eclipse.wst.server.core.IRuntime)1