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\""));
}
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"));
}
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()]);
}
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;
}
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\""));
}
Aggregations