use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.
the class ExtPluginFacetInstall method fixTilesDefExtFile.
protected void fixTilesDefExtFile() {
IWebProject webproject = LiferayCore.create(IWebProject.class, project);
IFolder webappRoot = webproject.getDefaultDocrootFolder();
IFile tilesDefExtFile = webappRoot.getFile("WEB-INF/ext-web/docroot/WEB-INF/tiles-defs-ext.xml");
if (FileUtil.notExists(tilesDefExtFile)) {
return;
}
try {
IDOMModel domModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(tilesDefExtFile);
domModel.aboutToChangeModel();
IDOMDocument document = domModel.getDocument();
Element root = document.getDocumentElement();
Element def = document.createElement("definition");
def.setAttribute("name", StringPool.EMPTY);
root.appendChild(def);
root.appendChild(document.createTextNode("\n"));
new FormatProcessorXML().formatNode(def);
domModel.changedModel();
domModel.save();
domModel.releaseFromEdit();
tilesDefExtFile.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (Exception e) {
ProjectCore.logError(e);
}
}
use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.
the class ExtPluginFacetInstall method _removeUnneededFolders.
private void _removeUnneededFolders(IProject project) throws CoreException {
IWebProject webproject = LiferayCore.create(IWebProject.class, project);
if ((webproject != null) && (webproject.getDefaultDocrootFolder() != null)) {
IFolder webappRoot = webproject.getDefaultDocrootFolder();
deleteFolder(webappRoot.getFolder("WEB-INF/lib"));
}
}
use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.
the class ProjectUtil method getPortletXmlFile.
public static IFile getPortletXmlFile(IProject project) {
if ((project == null) || !isLiferayFacetedProject(project)) {
return null;
}
IWebProject webProject = LiferayCore.create(IWebProject.class, project);
if (webProject == null) {
return null;
}
IFolder defaultDocrootFolder = webProject.getDefaultDocrootFolder();
if (defaultDocrootFolder == null) {
return null;
}
IFile portletXml = defaultDocrootFolder.getFile(new Path("WEB-INF/portlet.xml"));
if ((portletXml != null) && portletXml.exists()) {
return portletXml;
}
return null;
}
use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.
the class IvyUtil method configureIvyProject.
public static IStatus configureIvyProject(final IProject project, IProgressMonitor monitor) throws CoreException {
SDK sdk = SDKUtil.getSDK(project);
// check for 6.1.2 and greater but not 6.1.10 which is older EE release
// and match 6.2.0 and greater
final Version version = new Version(sdk.getVersion());
if (((CoreUtil.compareVersions(version, ILiferayConstants.V611) >= 0) && (CoreUtil.compareVersions(version, ILiferayConstants.V6110) < 0)) || (CoreUtil.compareVersions(version, ILiferayConstants.V620) >= 0)) {
IFile ivyXmlFile = project.getFile(ISDKConstants.IVY_XML_FILE);
if (ivyXmlFile.exists()) {
// IDE-1044
addIvyNature(project, monitor);
IvyClasspathContainer ivycp = addIvyLibrary(project, monitor);
if (ivycp != null) {
IStatus status = ivycp.launchResolve(false, monitor);
if (status.isOK()) {
final IWebProject webproject = LiferayCore.create(IWebProject.class, project);
if (webproject != null) {
final IFolder webinfFolder = webproject.getDefaultDocrootFolder().getFolder("WEB-INF");
if (webinfFolder != null) {
ComponentUtil.validateFolder(webinfFolder, monitor);
}
}
} else {
return status;
}
}
}
}
return Status.OK_STATUS;
}
use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.
the class LiferayLanguageFileEncodingTests method testHookProjectEncoding.
@Ignore
@Test
public void testHookProjectEncoding() throws Exception {
if (shouldSkipBundleTests())
return;
final IProject hookProject = importProject("hooks", "Hook-Encoding-Test-hook");
assertEquals(true, ProjectUtil.isHookProject(hookProject));
final IFolder defaultDocrootFolder = LiferayCore.create(IWebProject.class, hookProject).getDefaultDocrootFolder();
assertNotNull(defaultDocrootFolder);
assertEquals(true, defaultDocrootFolder.exists());
final IFolder defaultSrcFolder = defaultDocrootFolder.getFolder(new Path("WEB-INF/src/content/"));
assertNotNull(defaultSrcFolder);
assertEquals(true, defaultSrcFolder.exists());
final IFile fileNameWithoutUnderscore = defaultSrcFolder.getFile("FileNameWithoutUnderscore.properties");
assertEquals(true, isLanguagePropertiesFile(fileNameWithoutUnderscore));
final IFile fileNameWithoutUnderscore_CorrectEncoding = defaultSrcFolder.getFile("FileNameWithoutUnderscore_CorrectEncoding.properties");
assertEquals(true, isLanguagePropertiesFile(fileNameWithoutUnderscore_CorrectEncoding));
final IFile fileNameWithoutUnderscore_IncorrectEncoding = defaultSrcFolder.getFile("FileNameWithoutUnderscore_IncorrectEncoding.properties");
assertEquals(true, isLanguagePropertiesFile(fileNameWithoutUnderscore_IncorrectEncoding));
final IFile fileNameWithUnderscore_CorrectEncoding = defaultSrcFolder.getFile("FileNameWithUnderscore_CorrectEncoding.properties");
assertEquals(true, isLanguagePropertiesFile(fileNameWithUnderscore_CorrectEncoding));
final IFile fileNameWithUnderscore_IncorrectEncoding = defaultSrcFolder.getFile("FileNameWithUnderscore_IncorrectEncoding.properties");
assertEquals(true, isLanguagePropertiesFile(fileNameWithUnderscore_IncorrectEncoding));
final IFile fileNameWithStar = defaultSrcFolder.getFile("FileNameWithStar.properties");
assertEquals(true, isLanguagePropertiesFile(fileNameWithStar));
final IFile fileNameWithStarCorrectEncoding = defaultSrcFolder.getFile("FileNameWithStarCorrectEncoding.properties");
assertEquals(true, isLanguagePropertiesFile(fileNameWithStarCorrectEncoding));
final IFile fileNameWithStarIncorrectEncoding = defaultSrcFolder.getFile("FileNameWithStarIncorrectEncoding.properties");
assertEquals(true, isLanguagePropertiesFile(fileNameWithStarIncorrectEncoding));
final IFile removeThisLineTest = defaultSrcFolder.getFile("RemoveThisLineTest.properties");
assertEquals(true, isLanguagePropertiesFile(removeThisLineTest));
waitForBuildAndValidation(hookProject);
// test the filename without underscore
assertEquals(false, hasEncodingMarker(fileNameWithoutUnderscore));
assertEquals(false, hasEncodingMarker(fileNameWithoutUnderscore_CorrectEncoding));
assertEquals(true, hasEncodingMarker(fileNameWithoutUnderscore_IncorrectEncoding));
// test the filename with underscore
assertEquals(false, hasEncodingMarker(fileNameWithUnderscore_CorrectEncoding));
assertEquals(true, hasEncodingMarker(fileNameWithUnderscore_IncorrectEncoding));
// test the filename with a wildcard "*"
assertEquals(false, hasEncodingMarker(fileNameWithStar));
assertEquals(false, hasEncodingMarker(fileNameWithStarCorrectEncoding));
assertEquals(true, hasEncodingMarker(fileNameWithStarIncorrectEncoding));
// test an incorrect encoding file referenced by liferay-hook.xml
// remove the reference line, the marker will disappear.
assertEquals(true, hasEncodingMarker(removeThisLineTest));
IWebProject webProject = LiferayCore.create(IWebProject.class, hookProject);
final IFile liferayHookXml = webProject.getDescriptorFile(ILiferayConstants.LIFERAY_HOOK_XML_FILE);
assertNotNull(liferayHookXml);
removeSpecifiedNode(liferayHookXml, "language-properties", "content/RemoveThisLineTest.properties");
waitForBuildAndValidation(hookProject);
assertEquals(false, hasEncodingMarker(removeThisLineTest));
/*
* Both encoding action and quick fix of the encoding marker invoke method
* PropertiesUtils.encodeLanguagePropertiesFilesToDefault(),
* so here we only test this method and re-check the existence of markers.
*/
// test encoding one properties file to default, take FileNameWithoutUnderscore_IncorrectEncoding for example.
PropertiesUtil.encodeLanguagePropertiesFilesToDefault(fileNameWithoutUnderscore_IncorrectEncoding, new NullProgressMonitor());
waitForBuildAndValidation(hookProject);
assertEquals(false, hasEncodingMarker(fileNameWithoutUnderscore_IncorrectEncoding));
// test encoding all properties files of this project to default.
PropertiesUtil.encodeLanguagePropertiesFilesToDefault(hookProject, new NullProgressMonitor());
waitForBuildAndValidation(hookProject);
assertEquals(false, hasEncodingMarker(fileNameWithUnderscore_IncorrectEncoding));
assertEquals(false, hasEncodingMarker(fileNameWithStarIncorrectEncoding));
}
Aggregations