Search in sources :

Example 1 with SearchFilesVisitor

use of com.liferay.ide.project.core.util.SearchFilesVisitor in project liferay-ide by liferay.

the class NewLiferayModuleProjectOpTests method testNewLiferayModuleProjectNewProperties.

@Test
public void testNewLiferayModuleProjectNewProperties() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("test-properties-in-portlet");
    op.setProjectTemplateName("portlet");
    op.setComponentName("Test");
    PropertyKey pk = op.getPropertyKeys().insert();
    pk.setName("property-test-key");
    pk.setValue("property-test-value");
    Status exStatus = NewLiferayModuleProjectOpMethods.execute(op, ProgressMonitorBridge.create(new NullProgressMonitor()));
    assertEquals("OK", exStatus.message());
    IProject modPorject = CoreUtil.getProject(op.getProjectName().content());
    modPorject.open(new NullProgressMonitor());
    SearchFilesVisitor sv = new SearchFilesVisitor();
    List<IFile> searchFiles = sv.searchFiles(modPorject, "TestPortlet.java");
    IFile componentClassFile = searchFiles.get(0);
    assertEquals(componentClassFile.exists(), true);
    String actual = CoreUtil.readStreamToString(componentClassFile.getContents());
    assertTrue(actual, actual.contains("\"property-test-key=property-test-value\""));
}
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) SearchFilesVisitor(com.liferay.ide.project.core.util.SearchFilesVisitor) PropertyKey(com.liferay.ide.project.core.modules.PropertyKey) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 2 with SearchFilesVisitor

use of com.liferay.ide.project.core.util.SearchFilesVisitor in project liferay-ide by liferay.

the class NewLiferayModuleProjectOpTests method testNewLiferayPortletProviderNewProperties.

@Test
public void testNewLiferayPortletProviderNewProperties() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("test-properties-in-portlet-provider");
    op.setComponentName("Test");
    op.setProjectTemplateName("portlet-provider");
    PropertyKey pk = op.getPropertyKeys().insert();
    pk.setName("property-test-key");
    pk.setValue("property-test-value");
    Status exStatus = NewLiferayModuleProjectOpMethods.execute(op, ProgressMonitorBridge.create(new NullProgressMonitor()));
    assertTrue(exStatus.message(), exStatus.ok());
    IProject modPorject = CoreUtil.getProject(op.getProjectName().content());
    modPorject.open(new NullProgressMonitor());
    IFile testAddPortletProvider = modPorject.getFile("src/main/java/test/properties/in/portlet/provider/portlet/TestAddPortletProvider.java");
    assertTrue(testAddPortletProvider.exists());
    SearchFilesVisitor sv = new SearchFilesVisitor();
    List<IFile> searchFiles = sv.searchFiles(modPorject, "TestAddPortletProvider.java");
    IFile componentClassFile = searchFiles.get(0);
    assertEquals(componentClassFile.exists(), true);
    String actual = CoreUtil.readStreamToString(componentClassFile.getContents());
    assertTrue(actual.contains("property-test-key=property-test-value"));
}
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) SearchFilesVisitor(com.liferay.ide.project.core.util.SearchFilesVisitor) PropertyKey(com.liferay.ide.project.core.modules.PropertyKey) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 3 with SearchFilesVisitor

use of com.liferay.ide.project.core.util.SearchFilesVisitor in project liferay-ide by liferay.

the class DescriptorsPage method getAvaiableUpgradeFiles.

@Override
protected IFile[] getAvaiableUpgradeFiles(IProject project) {
    List<IFile> files = new ArrayList<>();
    for (String[] descriptors : _descriptorsAndImages) {
        final String searchName = descriptors[0];
        List<IFile> searchFiles = new SearchFilesVisitor().searchFiles(project, searchName);
        files.addAll(searchFiles);
    }
    return files.toArray(new IFile[files.size()]);
}
Also used : IFile(org.eclipse.core.resources.IFile) SearchFilesVisitor(com.liferay.ide.project.core.util.SearchFilesVisitor) ArrayList(java.util.ArrayList)

Example 4 with SearchFilesVisitor

use of com.liferay.ide.project.core.util.SearchFilesVisitor in project liferay-ide by liferay.

the class NewPortletClassDataModelProvider method _validateFolder.

private IStatus _validateFolder(IFolder folder, String folderValue) {
    if ((folder == null) || (folderValue == null)) {
        return null;
    }
    if (!Path.ROOT.isValidPath(folderValue)) {
        return LiferayCore.createErrorStatus(Msgs.folderValueInvalid);
    }
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IFolder fold = folder.getFolder(folderValue);
    String path = fold.getFullPath().toString();
    IStatus result = workspace.validatePath(path, IResource.FOLDER);
    if (!result.isOK()) {
        return LiferayCore.createErrorStatus(Msgs.folderValueInvalid);
    }
    if (folder.getFolder(new Path(folderValue)).exists()) {
        List<IFile> viewJspFiles = new SearchFilesVisitor().searchFiles(folder, "view.jsp");
        if (ListUtil.isNotEmpty(viewJspFiles)) {
            return LiferayCore.createWarningStatus(Msgs.viewJspAlreadyExists);
        }
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) IWorkspace(org.eclipse.core.resources.IWorkspace) SearchFilesVisitor(com.liferay.ide.project.core.util.SearchFilesVisitor) IFolder(org.eclipse.core.resources.IFolder)

Example 5 with SearchFilesVisitor

use of com.liferay.ide.project.core.util.SearchFilesVisitor in project liferay-ide by liferay.

the class MavenModuleProjectTests method testNewLiferayModuleProjectNewProperties.

@Test
public void testNewLiferayModuleProjectNewProperties() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("test-properties-in-portlet");
    op.setProjectProvider("maven-module");
    op.setProjectTemplateName("portlet");
    op.setComponentName("Test");
    PropertyKey pk = op.getPropertyKeys().insert();
    pk.setName("property-test-key");
    pk.setValue("property-test-value");
    Status exStatus = NewLiferayModuleProjectOpMethods.execute(op, ProgressMonitorBridge.create(monitor));
    assertEquals("OK", exStatus.message());
    IProject modProject = CoreUtil.getProject(op.getProjectName().content());
    modProject.open(new NullProgressMonitor());
    SearchFilesVisitor sv = new SearchFilesVisitor();
    List<IFile> searchFiles = sv.searchFiles(modProject, "TestPortlet.java");
    IFile componentClassFile = searchFiles.get(0);
    assertEquals(componentClassFile.exists(), true);
    String actual = CoreUtil.readStreamToString(componentClassFile.getContents());
    assertTrue(actual, actual.contains("\"property-test-key=property-test-value\""));
}
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) SearchFilesVisitor(com.liferay.ide.project.core.util.SearchFilesVisitor) PropertyKey(com.liferay.ide.project.core.modules.PropertyKey) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Aggregations

SearchFilesVisitor (com.liferay.ide.project.core.util.SearchFilesVisitor)5 IFile (org.eclipse.core.resources.IFile)5 NewLiferayModuleProjectOp (com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp)3 PropertyKey (com.liferay.ide.project.core.modules.PropertyKey)3 IProject (org.eclipse.core.resources.IProject)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 Status (org.eclipse.sapphire.modeling.Status)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)1 IFolder (org.eclipse.core.resources.IFolder)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 Path (org.eclipse.core.runtime.Path)1