use of com.liferay.ide.server.core.ILiferayRuntime in project liferay-ide by liferay.
the class PropertiesContentProvider method getPipelinedChildren.
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getPipelinedChildren(Object parent, Set currentChildren) {
if (shouldAddChildren(parent)) {
final IServer server = (IServer) parent;
PropertiesFile[] propertiesFiles = this.propertiesFilesMap.get(server.getId());
if (ListUtil.isEmpty(propertiesFiles)) {
final ILiferayRuntime runtime = ServerUtil.getLiferayRuntime(server);
if (runtime != null) {
File[] files = getExtPropertiesFiles(runtime);
final List<PropertiesFile> newFiles = new ArrayList<PropertiesFile>();
for (File file : files) {
newFiles.add(new PropertiesFile(file));
}
propertiesFiles = newFiles.toArray(new PropertiesFile[0]);
this.propertiesFilesMap.put(server.getId(), propertiesFiles);
}
}
if (ListUtil.isNotEmpty(propertiesFiles)) {
for (PropertiesFile propertiesFile : propertiesFiles) {
currentChildren.add(propertiesFile);
}
}
}
}
use of com.liferay.ide.server.core.ILiferayRuntime in project liferay-ide by liferay.
the class PropertiesContentProvider method hasChildren.
@Override
public boolean hasChildren(Object element) {
boolean retVal = false;
if (element instanceof IServer) {
final IServer server = (IServer) element;
ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(server);
if (liferayRuntime != null) {
File[] files = getExtPropertiesFiles(liferayRuntime);
return ListUtil.isNotEmpty(files);
}
}
return retVal;
}
use of com.liferay.ide.server.core.ILiferayRuntime in project liferay-ide by liferay.
the class PluginClasspathContainerInitializer method requestClasspathContainerUpdate.
@Override
public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException {
String key = PluginClasspathContainer.getDecorationManagerKey(project.getProject(), containerPath.toString());
IClasspathEntry[] entries = containerSuggestion.getClasspathEntries();
cpDecorations.clearAllDecorations(key);
for (int i = 0; i < entries.length; i++) {
IClasspathEntry entry = entries[i];
IPath srcpath = entry.getSourceAttachmentPath();
IPath srcrootpath = entry.getSourceAttachmentRootPath();
IClasspathAttribute[] attrs = entry.getExtraAttributes();
if ((srcpath != null) || ListUtil.isNotEmpty(attrs)) {
String eid = entry.getPath().toString();
ClasspathDecorations dec = new ClasspathDecorations();
dec.setSourceAttachmentPath(srcpath);
dec.setSourceAttachmentRootPath(srcrootpath);
dec.setExtraAttributes(attrs);
cpDecorations.setDecorations(key, eid, dec);
}
}
cpDecorations.save();
IPath portalDir = null;
String javadocURL = null;
IPath sourceLocation = null;
if (containerSuggestion instanceof PluginClasspathContainer) {
portalDir = ((PluginClasspathContainer) containerSuggestion).getPortalDir();
javadocURL = ((PluginClasspathContainer) containerSuggestion).getJavadocURL();
sourceLocation = ((PluginClasspathContainer) containerSuggestion).getSourceLocation();
} else {
portalDir = ServerUtil.getPortalDir(project);
try {
ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(project.getProject());
if (liferayRuntime != null) {
javadocURL = liferayRuntime.getJavadocURL();
sourceLocation = liferayRuntime.getSourceLocation();
}
} catch (Exception e) {
ProjectCore.logError(e);
}
}
if (portalDir != null) {
IClasspathContainer newContainer = getCorrectContainer(containerPath, containerPath.segment(1), project, portalDir, javadocURL, sourceLocation);
IJavaProject[] projects = { project };
IClasspathContainer[] containers = { newContainer };
JavaCore.setClasspathContainer(containerPath, projects, containers, null);
}
}
use of com.liferay.ide.server.core.ILiferayRuntime in project liferay-ide by liferay.
the class PluginsSDKProjectProvider method provide.
@Override
public ILiferayProject provide(Object type) {
if (type instanceof IProject) {
IProject project = (IProject) type;
if (!SDKUtil.isSDKProject(project)) {
return null;
}
try {
IJavaProject javaProject = JavaCore.create(project);
boolean hasNewSdk = ClasspathUtil.hasNewLiferaySDKContainer(javaProject.getRawClasspath());
if (hasNewSdk) {
PortalBundle portalBundle = ServerUtil.getPortalBundle(project);
if (portalBundle != null) {
return new PluginsSDKBundleProject(project, portalBundle);
}
} else {
ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(project);
if (liferayRuntime != null) {
return new PluginsSDKRuntimeProject(project, liferayRuntime);
}
}
} catch (CoreException ce) {
}
} else if (type instanceof IRuntime) {
try {
IRuntime runtime = (IRuntime) type;
ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(runtime);
if (liferayRuntime != null) {
return new PluginsSDKRuntimeProject(null, liferayRuntime);
}
} catch (Exception e) {
}
}
return null;
}
use of com.liferay.ide.server.core.ILiferayRuntime in project liferay-ide by liferay.
the class CustomJspConverter method _convertToCoreJspHook.
private void _convertToCoreJspHook(String sourcePath, String customJspPath, String targetPath, boolean liferayWorkspace) throws Exception {
File commonDir = _getMovedDir(sourcePath, customJspPath, "common");
File portalDir = _getMovedDir(sourcePath, customJspPath, "portal");
File taglibDir = _getMovedDir(sourcePath, customJspPath, "taglib");
if ((commonDir != null) || (portalDir != null) || (taglibDir != null)) {
File[] dirs = new File[3];
dirs[0] = commonDir;
dirs[1] = portalDir;
dirs[2] = taglibDir;
File location = new File(targetPath);
Bundle bundle = ProjectUI.getDefault().getBundle();
final URL projectZipUrl = bundle.getEntry("resources/codeupgrade.corejsphook.zip");
final File projectZipFile = new File(FileLocator.toFileURL(projectZipUrl).getFile());
ZipUtil.unzip(projectZipFile, location);
// File jspDir = new File( location, coreJspHookResourcesPath + "html" );
File ignoreFolder = new File(location, _coreJspHookResourcesPath + ".ignore/");
File destFolder = new File(location, _coreJspHookResourcesPath);
ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(getLiferay70Runtime());
for (File dir : dirs) {
if (dir != null) {
// File dest = new File( jspDir, dir.getName() );
// dest.mkdirs();
// IOUtil.copyDirToDir( dir, dest );
// copy 70 original jsp file to converted project ignore folder
List<String> fileRelativizePaths = _getAllRelativizeFilePaths(dir);
for (String fileRelativizePath : fileRelativizePaths) {
File original62File = new File(_get62HtmlDir() + dir.getName() + "/" + fileRelativizePath);
IPath appServerPortalDir = liferayRuntime.getAppServerPortalDir().removeLastSegments(1);
File original70File = appServerPortalDir.append("ROOT/html/" + dir.getName() + "/" + fileRelativizePath).toFile();
if (original62File.exists() && original70File.exists()) {
File target62File = new File(ignoreFolder, "html/" + dir.getName() + "/" + fileRelativizePath + ".62");
File target70File = new File(destFolder, "html/" + dir.getName() + "/" + fileRelativizePath);
_makeParentDir(target62File);
_makeParentDir(target70File);
FileUtil.copyFile(original62File, target62File);
FileUtil.copyFile(original70File, target70File);
}
}
}
}
String sourceProjectName = (new File(sourcePath)).getName();
File projectFolder = new File(location, "codeupgrade.corejsphook");
File gradleWsFile = new File(projectFolder, "build-ws.gradle");
File gradleFile = new File(projectFolder, "build.gradle");
if (liferayWorkspace) {
gradleFile.delete();
gradleWsFile.renameTo(gradleFile);
} else {
gradleWsFile.delete();
}
File newFolder = new File(location, sourceProjectName + ".corejsphook");
projectFolder.renameTo(newFolder);
_resultProp.setProperty(resultPrefix + "." + sourceProjectName + "/portalCore", newFolder.getAbsolutePath().replace("\\\\", "/"));
}
}
Aggregations