Search in sources :

Example 41 with ILiferayProject

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

the class LiferayPropertiesSourceViewerConfiguration method _getAppServerPortalDir.

private IPath _getAppServerPortalDir(IEditorInput input) {
    IPath retval = null;
    IFile ifile = input.getAdapter(IFile.class);
    if (ifile != null) {
        ILiferayProject project = LiferayCore.create(ifile.getProject());
        if (project != null) {
            ILiferayPortal portal = project.adapt(ILiferayPortal.class);
            if (portal != null) {
                retval = portal.getAppServerPortalDir();
            }
        }
    } else {
        File file = input.getAdapter(File.class);
        if ((file == null) && input instanceof FileStoreEditorInput) {
            FileStoreEditorInput fInput = (FileStoreEditorInput) input;
            file = new File(fInput.getURI().getPath());
        }
        if ((file != null) && file.exists()) {
            try {
                IPath propsParentPath = new Path(file.getParentFile().getCanonicalPath());
                for (IRuntime runtime : ServerCore.getRuntimes()) {
                    if (propsParentPath.equals(runtime.getLocation()) || propsParentPath.isPrefixOf(runtime.getLocation())) {
                        ILiferayRuntime lr = ServerUtil.getLiferayRuntime(runtime);
                        retval = lr.getAppServerPortalDir();
                        break;
                    }
                }
            } catch (Exception e) {
                LiferayUIPlugin.logError("Unable to get portal language properties file", e);
            }
        }
    }
    return retval;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) ILiferayProject(com.liferay.ide.core.ILiferayProject) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) JarFile(java.util.jar.JarFile) IFile(org.eclipse.core.resources.IFile) File(java.io.File) FileStoreEditorInput(org.eclipse.ui.ide.FileStoreEditorInput) IOException(java.io.IOException) ConfigurationException(org.apache.commons.configuration.ConfigurationException) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 42 with ILiferayProject

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

the class AddResourceBundleFileMarkerResolution method resolve.

@Override
protected void resolve(IMarker marker) {
    IProject project = marker.getResource().getProject();
    if ((getResourceKey(marker) == null) || (project == null)) {
        return;
    }
    try {
        _checkResourceBundleElement(project);
        ILiferayProject liferayProject = LiferayCore.create(project);
        if (liferayProject == null) {
            return;
        }
        IFolder folder = liferayProject.getSourceFolder("resources").getFolder(_resourceBundlePackage);
        if (!folder.exists()) {
            CoreUtil.makeFolders(folder);
        }
        IFile resourceBundle = folder.getFile(_resourceBundleName + ".properties");
        String resourceKey = getResourceKey(marker);
        if (CoreUtil.isNullOrEmpty(resourceKey)) {
            return;
        }
        String resourceValue = getDefaultResourceValue(resourceKey);
        String resourcePropertyLine = resourceKey + "=" + resourceValue + "\n";
        int contentOffset = 0;
        int resourcePropertyLineOffset = resourcePropertyLine.getBytes().length;
        if (!resourceBundle.exists()) {
            IFolder parent = (IFolder) resourceBundle.getParent();
            CoreUtil.prepareFolder(parent);
            resourceBundle.create(new ByteArrayInputStream(resourcePropertyLine.getBytes("UTF-8")), IResource.FORCE, null);
            contentOffset = resourcePropertyLineOffset;
        } else {
            String contents = CoreUtil.readStreamToString(resourceBundle.getContents());
            StringBuffer sb = new StringBuffer();
            sb.append(contents);
            sb.append(resourcePropertyLine);
            String string = sb.toString();
            byte[] bytes = string.trim().getBytes("UTF-8");
            contentOffset = bytes.length;
            resourceBundle.setContents(new ByteArrayInputStream(bytes), IResource.FORCE, new NullProgressMonitor());
        }
        openEditor(resourceBundle, contentOffset - resourcePropertyLineOffset, contentOffset - 1);
    } catch (Exception e) {
        LiferayXMLSearchUI.logError(e);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) ByteArrayInputStream(java.io.ByteArrayInputStream) ILiferayProject(com.liferay.ide.core.ILiferayProject) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Example 43 with ILiferayProject

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

the class EmailAddressValidationService method _getSchemaVersion.

private Version _getSchemaVersion() {
    Version schemaVersion = new Version(KaleoCore.DEFAULT_KALEO_VERSION);
    if (context(WorkflowDefinition.class) != null) {
        WorkflowDefinition workflowDefinition = context(WorkflowDefinition.class);
        Value<Version> version = workflowDefinition.getSchemaVersion();
        schemaVersion = version.content();
    } else if (context(NewNodeOp.class) != null) {
        NewNodeOp newNodeOp = context(NewNodeOp.class);
        ElementHandle<WorkflowDefinition> workflowDef = newNodeOp.getWorkflowDefinition();
        WorkflowDefinition workflowDefinition = workflowDef.content();
        Value<Version> version = workflowDefinition.getSchemaVersion();
        schemaVersion = version.content();
    } else if (context(NewWorkflowDefinitionOp.class) != null) {
        NewWorkflowDefinitionOp newWorkflowDenitionOp = context(NewWorkflowDefinitionOp.class);
        ReferenceValue<String, IProject> opProject = newWorkflowDenitionOp.getProject();
        IProject project = opProject.target();
        ILiferayProject liferayProj = LiferayCore.create(project);
        ILiferayPortal portal = liferayProj.adapt(ILiferayPortal.class);
        if (portal != null) {
            schemaVersion = new Version(portal.getVersion());
        }
    }
    return schemaVersion;
}
Also used : Version(org.eclipse.sapphire.Version) ILiferayProject(com.liferay.ide.core.ILiferayProject) NewNodeOp(com.liferay.ide.kaleo.core.op.NewNodeOp) ReferenceValue(org.eclipse.sapphire.ReferenceValue) Value(org.eclipse.sapphire.Value) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) ElementHandle(org.eclipse.sapphire.ElementHandle) NewWorkflowDefinitionOp(com.liferay.ide.kaleo.core.op.NewWorkflowDefinitionOp) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IProject(org.eclipse.core.resources.IProject)

Example 44 with ILiferayProject

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

the class LiferayMavenProjectTests method testNewLiferayRemoteServiceBuilderProject.

@Test
public void testNewLiferayRemoteServiceBuilderProject() throws Exception {
    if (shouldSkipBundleTests())
        return;
    NewLiferayPluginProjectOp op = NewLiferayPluginProjectOp.TYPE.instantiate();
    op.setProjectName("servicebuilder");
    op.setProjectProvider("maven");
    op.setPluginType(PluginType.servicebuilder);
    createTestBundleProfile(op);
    final IProject project = base.createProject(op, op.getProjectName() + "-portlet");
    assertEquals(project.getName(), op.getProjectName() + "-portlet");
    assertNotNull(project);
    String pomContents = CoreUtil.readStreamToString(project.getFile("pom.xml").getContents());
    assertTrue(pomContents.contains("<artifactId>servicebuilder-portlet</artifactId>"));
    assertTrue(pomContents.contains("<artifactId>liferay-maven-plugin</artifactId>"));
    assertTrue(pomContents.contains("<name>servicebuilder Portlet</name>"));
    waitForJobsToComplete();
    project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
    waitForJobsToComplete();
    IVirtualComponent projectComponent = ComponentCore.createComponent(project);
    assertEquals("servicebuilder-portlet", projectComponent.getDeployedName());
    final ILiferayProject liferayProject = LiferayCore.create(project);
    final IRemoteServerPublisher publisher = liferayProject.adapt(IRemoteServerPublisher.class);
    final IPath warPath = publisher.publishModuleFull(monitor);
    assertTrue(warPath.toFile().exists());
}
Also used : IPath(org.eclipse.core.runtime.IPath) ILiferayProject(com.liferay.ide.core.ILiferayProject) IRemoteServerPublisher(com.liferay.ide.server.remote.IRemoteServerPublisher) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) IVirtualComponent(org.eclipse.wst.common.componentcore.resources.IVirtualComponent) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 45 with ILiferayProject

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

the class VersionsTests method testFindLiferayVersionByDeps.

@Test
public void testFindLiferayVersionByDeps() throws Exception {
    IProject project = importProject("projects/versions/deps-portlet/pom.xml");
    assertNotNull(project);
    IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().create(project, monitor);
    assertNotNull(facade);
    final ILiferayProject lrproject = LiferayCore.create(project);
    assertNotNull(lrproject);
    final ILiferayPortal portal = lrproject.adapt(ILiferayPortal.class);
    assertNotNull(portal);
    assertEquals("6.2.1", portal.getVersion());
}
Also used : ILiferayProject(com.liferay.ide.core.ILiferayProject) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

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