Search in sources :

Example 46 with NewLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.

the class NewLiferayModuleProjectWizard method performPostFinish.

@Override
protected void performPostFinish() {
    super.performPostFinish();
    final List<IProject> projects = new ArrayList<>();
    final NewLiferayModuleProjectOp op = element().nearest(NewLiferayModuleProjectOp.class);
    ElementList<ProjectName> projectNames = op.getProjectNames();
    for (ProjectName projectName : projectNames) {
        final IProject newProject = CoreUtil.getProject(projectName.getName().content());
        if (newProject != null) {
            projects.add(newProject);
        }
    }
    for (final IProject project : projects) {
        try {
            addToWorkingSets(project);
        } catch (Exception ex) {
            ProjectUI.logError("Unable to add project to working set", ex);
        }
    }
    if (ListUtil.isNotEmpty(projects)) {
        IProject finalProject = projects.get(0);
        openLiferayPerspective(finalProject);
    }
}
Also used : ProjectName(com.liferay.ide.project.core.model.ProjectName) NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject)

Example 47 with NewLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.

the class NewLiferayComponentOpTests method testNewLiferayComponentBndAndGradleForPortleActionCommandAndRest.

@Test
public void testNewLiferayComponentBndAndGradleForPortleActionCommandAndRest() throws Exception {
    NewLiferayModuleProjectOp pop = NewLiferayModuleProjectOp.TYPE.instantiate();
    pop.setProjectName("testGradleModuleComponentBnd");
    pop.setProjectTemplateName("portlet");
    pop.setProjectProvider("gradle-module");
    Status modulePorjectStatus = NewLiferayModuleProjectOpMethods.execute(pop, ProgressMonitorBridge.create(new NullProgressMonitor()));
    assertTrue(modulePorjectStatus.ok());
    IProject modPorject = CoreUtil.getProject(pop.getProjectName().content());
    modPorject.open(new NullProgressMonitor());
    NewLiferayComponentOp cop = NewLiferayComponentOp.TYPE.instantiate();
    cop.setProjectName(pop.getProjectName().content());
    cop.setComponentClassTemplateName("PortletActionCommand");
    NewLiferayComponentOpMethods.execute(cop, ProgressMonitorBridge.create(new NullProgressMonitor()));
    IFile bgd = modPorject.getFile("bnd.bnd");
    String bndcontent = FileUtil.readContents(bgd.getLocation().toFile(), true);
    String bndConfig = "-includeresource: \\" + System.getProperty("line.separator") + "\t" + "@com.liferay.util.bridges-2.0.0.jar!/com/liferay/util/bridges/freemarker/FreeMarkerPortlet.class,\\" + System.getProperty("line.separator") + "\t" + "@com.liferay.util.taglib-2.0.0.jar!/META-INF/*.tld" + System.getProperty("line.separator");
    assertTrue(bndcontent.contains(bndConfig));
    IFile buildgrade = modPorject.getFile("build.gradle");
    String buildgradeContent = FileUtil.readContents(buildgrade.getLocation().toFile(), true);
    assertTrue(buildgradeContent.contains("compile group: \"com.liferay.portal\", name:\"com.liferay.util.bridges\", version:\"2.0.0\""));
    assertTrue(buildgradeContent.contains("compile group: \"org.osgi\", name:\"org.osgi.service.component.annotations\", version:\"1.3.0\""));
    NewLiferayComponentOp copRest = NewLiferayComponentOp.TYPE.instantiate();
    copRest.setProjectName(pop.getProjectName().content());
    copRest.setComponentClassTemplateName("RestService");
    NewLiferayComponentOpMethods.execute(copRest, ProgressMonitorBridge.create(new NullProgressMonitor()));
    bgd = modPorject.getFile("bnd.bnd");
    bndcontent = FileUtil.readContents(bgd.getLocation().toFile(), true);
    assertTrue(bndcontent.contains(bndConfig));
    final String restConfig = "Require-Capability: osgi.contract; filter:=\"(&(osgi.contract=JavaJAXRS)(version=2))\"";
    assertTrue(bndcontent.contains(restConfig));
    buildgrade = modPorject.getFile("build.gradle");
    buildgradeContent = FileUtil.readContents(buildgrade.getLocation().toFile(), true);
    assertTrue(buildgradeContent.contains("compile group: \"javax.ws.rs\", name:\"javax.ws.rs-api\", version:\"2.0.1\""));
    NewLiferayComponentOp copAuth = NewLiferayComponentOp.TYPE.instantiate();
    copAuth.setProjectName(pop.getProjectName().content());
    copAuth.setComponentClassTemplateName("Authenticator");
    NewLiferayComponentOpMethods.execute(copAuth, ProgressMonitorBridge.create(new NullProgressMonitor()));
    bgd = modPorject.getFile("bnd.bnd");
    bndcontent = FileUtil.readContents(bgd.getLocation().toFile(), true);
    bndConfig = "-includeresource: \\" + System.getProperty("line.separator") + "\t" + "@com.liferay.util.bridges-2.0.0.jar!/com/liferay/util/bridges/freemarker/FreeMarkerPortlet.class,\\" + System.getProperty("line.separator") + "\t" + "@com.liferay.util.taglib-2.0.0.jar!/META-INF/*.tld,\\" + System.getProperty("line.separator") + "\t" + "@shiro-core-1.1.0.jar";
    assertTrue(bndcontent.contains(bndConfig));
    buildgrade = modPorject.getFile("build.gradle");
    buildgradeContent = FileUtil.readContents(buildgrade.getLocation().toFile(), true);
    assertTrue(buildgradeContent.contains("compile group: \"org.apache.shiro\", name:\"shiro-core\", version:\"1.1.0\""));
    NewLiferayComponentOp copStruts = NewLiferayComponentOp.TYPE.instantiate();
    copStruts.setProjectName(pop.getProjectName().content());
    copStruts.setComponentClassTemplateName("StrutsAction");
    NewLiferayComponentOpMethods.execute(copStruts, ProgressMonitorBridge.create(new NullProgressMonitor()));
    bgd = modPorject.getFile("bnd.bnd");
    bndcontent = FileUtil.readContents(bgd.getLocation().toFile(), true);
    bndConfig = "Web-ContextPath: /TestgradlemodulecomponentbndStrutsAction";
    assertTrue(bndcontent.contains(bndConfig));
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) NewLiferayComponentOp(com.liferay.ide.project.core.modules.NewLiferayComponentOp) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 48 with NewLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.

the class NewLiferayComponentOpTests method testNewLiferayComponentStrutsAction.

@Test
public void testNewLiferayComponentStrutsAction() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("testGradleStrutsActionComponent");
    op.setProjectTemplateName("portlet");
    op.setProjectProvider("gradle-module");
    Status modulePorjectStatus = NewLiferayModuleProjectOpMethods.execute(op, ProgressMonitorBridge.create(new NullProgressMonitor()));
    assertTrue(modulePorjectStatus.ok());
    IProject modProject = CoreUtil.getProject(op.getProjectName().content());
    modProject.open(new NullProgressMonitor());
    NewLiferayComponentOp cop = NewLiferayComponentOp.TYPE.instantiate();
    cop.setProjectName(op.getProjectName().content());
    cop.setComponentClassTemplateName("StrutsAction");
    Status status = NewLiferayComponentOpMethods.execute(cop, ProgressMonitorBridge.create(new NullProgressMonitor()));
    assertEquals(Status.createOkStatus(), status);
    IFile javaFile = modProject.getFile("/src/main/java/testGradleStrutsActionComponent" + "/portlet/TestgradlestrutsactioncomponentStrutsAction.java");
    assertTrue(javaFile.exists());
    String javaFileContent = FileUtil.readContents(javaFile.getLocation().toFile(), true);
    assertTrue(javaFileContent.contains("osgi.web.symbolicname=testGradleStrutsActionComponent"));
    IFile jspFile = modProject.getFile("/src/main/resources/META-INF/resources" + "/testgradlestrutsactioncomponentstrutsaction/html/portal/testgradlestrutsactioncomponent.jsp");
    assertTrue(jspFile.exists());
    String jspFileContent = FileUtil.readContents(jspFile.getLocation().toFile(), true);
    assertTrue(jspFileContent.contains("/testgradlestrutsactioncomponentstrutsaction/html/init.jsp"));
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) NewLiferayComponentOp(com.liferay.ide.project.core.modules.NewLiferayComponentOp) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 49 with NewLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.

the class NewLiferayModuleProjectOpTests method testNewLiferayModuleProjectDefaultValueServiceIsListeningToProjectTemplateName.

@Test
@Ignore
public void testNewLiferayModuleProjectDefaultValueServiceIsListeningToProjectTemplateName() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("my.test.project");
    op.setProjectTemplateName("activator");
    assertEquals("MyTestProject", op.getComponentName().content(true));
    op.setProjectTemplateName("portlet");
    assertEquals("MyTestProject", op.getComponentName().content(true));
    op.setProjectTemplateName("mvc-portlet");
    assertEquals("MyTestProject", op.getComponentName().content(true));
    op.setProjectTemplateName("service");
    assertEquals("MyTestProject", op.getComponentName().content(true));
    op.setProjectTemplateName("service-wrapper");
    assertEquals("MyTestProject", op.getComponentName().content(true));
    op.setProjectTemplateName("service-builder");
    assertEquals("MyTestProject", op.getComponentName().content(true));
}
Also used : NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 50 with NewLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.

the class NewLiferayModuleProjectOpTests method testNewLiferayModuleProjectDefaultValueServiceDashes.

@Test
@Ignore
public void testNewLiferayModuleProjectDefaultValueServiceDashes() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("my-test-project");
    op.setProjectTemplateName("portlet");
    assertEquals("MyTestProject", op.getComponentName().content(true));
}
Also used : NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

NewLiferayModuleProjectOp (com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp)95 Test (org.junit.Test)94 IProject (org.eclipse.core.resources.IProject)30 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)18 IFile (org.eclipse.core.resources.IFile)12 Status (org.eclipse.sapphire.modeling.Status)9 Ignore (org.junit.Ignore)6 IBundleProject (com.liferay.ide.core.IBundleProject)5 NewLiferayComponentOp (com.liferay.ide.project.core.modules.NewLiferayComponentOp)5 PropertyKey (com.liferay.ide.project.core.modules.PropertyKey)3 SearchFilesVisitor (com.liferay.ide.project.core.util.SearchFilesVisitor)3 IPath (org.eclipse.core.runtime.IPath)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 File (java.io.File)2 URL (java.net.URL)2 ILiferayProjectImporter (com.liferay.ide.core.ILiferayProjectImporter)1 IProjectBuilder (com.liferay.ide.project.core.IProjectBuilder)1 ProjectName (com.liferay.ide.project.core.model.ProjectName)1 NewLiferayWorkspaceOp (com.liferay.ide.project.core.workspace.NewLiferayWorkspaceOp)1 ArrayList (java.util.ArrayList)1