Search in sources :

Example 21 with ILiferayProject

use of com.liferay.ide.core.ILiferayProject in project liferay-ide by liferay.

the class ProjectUtil method is7xServerDeployableProject.

public static boolean is7xServerDeployableProject(IProject project) {
    ILiferayProject liferayProject = LiferayCore.create(project);
    if (liferayProject instanceof IBundleProject) {
        if (liferayProject instanceof PluginsSDKBundleProject) {
            PluginsSDKBundleProject sdkProject = (PluginsSDKBundleProject) liferayProject;
            SDK sdk = sdkProject.getSDK();
            if (sdk != null) {
                IPath location = sdkProject.getProject().getLocation();
                String projectType = getLiferayPluginType(location.toPortableString());
                Version version = new Version(sdk.getVersion());
                Version sdk70 = ILiferayConstants.V700;
                if ((CoreUtil.compareVersions(version, sdk70) >= 0) && !ISDKConstants.EXT_PLUGIN_PROJECT_FOLDER.equals(projectType)) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        } else {
            return true;
        }
    } else {
        return false;
    }
}
Also used : IBundleProject(com.liferay.ide.core.IBundleProject) IPath(org.eclipse.core.runtime.IPath) PluginsSDKBundleProject(com.liferay.ide.project.core.PluginsSDKBundleProject) Version(org.osgi.framework.Version) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) ILiferayProject(com.liferay.ide.core.ILiferayProject) SDK(com.liferay.ide.sdk.core.SDK)

Example 22 with ILiferayProject

use of com.liferay.ide.core.ILiferayProject in project liferay-ide by liferay.

the class ThemeCSSBuilder method applyDiffsDeltaToDocroot.

protected void applyDiffsDeltaToDocroot(IResourceDelta delta, IContainer docroot, IProgressMonitor monitor) {
    int deltaKind = delta.getKind();
    switch(deltaKind) {
        case IResourceDelta.REMOVED_PHANTOM:
            break;
    }
    IPath path = CoreUtil.getResourceLocation(docroot);
    ILiferayProject liferayProject = LiferayCore.create(getProject());
    String themeParent = liferayProject.getProperty("theme.parent", "_styled");
    ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
    if (portal != null) {
        IPath themesPath = portal.getAppServerPortalDir().append("html/themes");
        List<IPath> restorePaths = new ArrayList<>();
        for (int i = 0; i < IPluginProjectDataModelProperties.THEME_PARENTS.length; i++) {
            if (IPluginProjectDataModelProperties.THEME_PARENTS[i].equals(themeParent)) {
                restorePaths.add(themesPath.append(IPluginProjectDataModelProperties.THEME_PARENTS[i]));
            } else {
                if (ListUtil.isNotEmpty(restorePaths)) {
                    restorePaths.add(themesPath.append(IPluginProjectDataModelProperties.THEME_PARENTS[i]));
                }
            }
        }
        new Job("publish theme delta") {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
                _buildHelper.publishDelta(delta, path, restorePaths.toArray(new IPath[0]), monitor);
                try {
                    docroot.refreshLocal(IResource.DEPTH_INFINITE, monitor);
                } catch (Exception e) {
                    ThemeCore.logError(e);
                }
                return Status.OK_STATUS;
            }
        }.schedule();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) ILiferayProject(com.liferay.ide.core.ILiferayProject) ArrayList(java.util.ArrayList) Job(org.eclipse.core.runtime.jobs.Job) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException)

Example 23 with ILiferayProject

use of com.liferay.ide.core.ILiferayProject in project liferay-ide by liferay.

the class ThemeCSSBuilder method ensureLookAndFeelFileExists.

public static void ensureLookAndFeelFileExists(IProject project) throws CoreException {
    // IDE-110 IDE-648
    IWebProject lrProject = LiferayCore.create(IWebProject.class, project);
    if (lrProject == null) {
        return;
    }
    IFile lookAndFeelFile = null;
    IResource res = lrProject.findDocrootResource(new Path("WEB-INF/" + ILiferayConstants.LIFERAY_LOOK_AND_FEEL_XML_FILE));
    if (res instanceof IFile && res.exists()) {
        lookAndFeelFile = (IFile) res;
    }
    if (lookAndFeelFile == null) {
        // need to generate a new lnf file in deafult docroot
        String id = project.getName().replaceAll(ISDKConstants.THEME_PLUGIN_PROJECT_SUFFIX, StringPool.EMPTY);
        IResource propertiesFileRes = lrProject.findDocrootResource(new Path("WEB-INF/" + ILiferayConstants.LIFERAY_PLUGIN_PACKAGE_PROPERTIES_FILE));
        String name = id;
        if (propertiesFileRes instanceof IFile && propertiesFileRes.exists()) {
            Properties props = new Properties();
            try {
                IFile propsFile = (IFile) propertiesFileRes;
                InputStream contents = propsFile.getContents();
                props.load(contents);
                contents.close();
                String nameValue = props.getProperty("name");
                if (!CoreUtil.isNullOrEmpty(nameValue)) {
                    name = nameValue;
                }
                ThemeDescriptorHelper themeDescriptorHelper = new ThemeDescriptorHelper(project);
                ILiferayProject lProject = lrProject;
                ILiferayPortal portal = lProject.adapt(ILiferayPortal.class);
                String version = "6.2.0";
                if (portal != null) {
                    version = portal.getVersion();
                }
                String themeType = lProject.getProperty("theme.type", "vm");
                themeDescriptorHelper.createDefaultFile(lrProject.getDefaultDocrootFolder().getFolder("WEB-INF"), version, id, name, themeType);
            } catch (IOException ioe) {
                ThemeCore.logError("Unable to load plugin package properties.", ioe);
            }
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IWebProject(com.liferay.ide.core.IWebProject) InputStream(java.io.InputStream) ILiferayProject(com.liferay.ide.core.ILiferayProject) IOException(java.io.IOException) Properties(java.util.Properties) IPluginProjectDataModelProperties(com.liferay.ide.project.core.facet.IPluginProjectDataModelProperties) ThemeDescriptorHelper(com.liferay.ide.theme.core.operation.ThemeDescriptorHelper) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IResource(org.eclipse.core.resources.IResource)

Example 24 with ILiferayProject

use of com.liferay.ide.core.ILiferayProject in project liferay-ide by liferay.

the class AddServiceBuilderOperation method createDefaultServiceBuilderFile.

public void createDefaultServiceBuilderFile(IFile serviceBuilderFile, IProgressMonitor monitor) throws CoreException {
    String descriptorVersion = null;
    try {
        ILiferayProject liferayProject = LiferayCore.create(serviceBuilderFile.getProject());
        ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
        Version portalVersion = new Version(portal.getVersion());
        descriptorVersion = portalVersion.getMajor() + "." + portalVersion.getMinor() + ".0";
    } catch (Exception e) {
        ProjectCore.logError("Could not determine liferay runtime version", e);
        descriptorVersion = "6.0.0";
    }
    WizardUtil.createDefaultServiceBuilderFile(serviceBuilderFile, descriptorVersion, getDataModel().getBooleanProperty(USE_SAMPLE_TEMPLATE), getDataModel().getStringProperty(PACKAGE_PATH), getDataModel().getStringProperty(NAMESPACE), getDataModel().getStringProperty(AUTHOR), monitor);
    getDataModel().setProperty(CREATED_SERVICE_FILE, serviceBuilderFile);
}
Also used : Version(org.osgi.framework.Version) ILiferayProject(com.liferay.ide.core.ILiferayProject) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) CoreException(org.eclipse.core.runtime.CoreException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 25 with ILiferayProject

use of com.liferay.ide.core.ILiferayProject in project liferay-ide by liferay.

the class BuildServiceJob method getProjectBuilder.

protected IProjectBuilder getProjectBuilder() throws CoreException {
    ILiferayProject liferayProject = LiferayCore.create(getProject());
    if (liferayProject == null) {
        throw new CoreException(ServiceCore.createErrorStatus(NLS.bind(Msgs.couldNotCreateLiferayProject, getProject())));
    }
    IProjectBuilder builder = liferayProject.adapt(IProjectBuilder.class);
    if (builder == null) {
        throw new CoreException(ServiceCore.createErrorStatus(NLS.bind(Msgs.couldNotCreateProjectBuilder, getProject())));
    }
    return builder;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ILiferayProject(com.liferay.ide.core.ILiferayProject) IProjectBuilder(com.liferay.ide.project.core.IProjectBuilder)

Aggregations

ILiferayProject (com.liferay.ide.core.ILiferayProject)45 ILiferayPortal (com.liferay.ide.core.ILiferayPortal)29 IProject (org.eclipse.core.resources.IProject)21 IPath (org.eclipse.core.runtime.IPath)18 IFile (org.eclipse.core.resources.IFile)17 CoreException (org.eclipse.core.runtime.CoreException)15 ArrayList (java.util.ArrayList)9 IFolder (org.eclipse.core.resources.IFolder)8 Version (org.osgi.framework.Version)8 IOException (java.io.IOException)7 File (java.io.File)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 Test (org.junit.Test)5 IProjectBuilder (com.liferay.ide.project.core.IProjectBuilder)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IStatus (org.eclipse.core.runtime.IStatus)4 Path (org.eclipse.core.runtime.Path)4 IWebProject (com.liferay.ide.core.IWebProject)3 Hook (com.liferay.ide.hook.core.model.Hook)3 IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)3