use of com.liferay.ide.core.ILiferayProject in project liferay-ide by liferay.
the class LiferayDependencyQuickFix method _createDepProposal.
private IJavaCompletionProposal _createDepProposal(IInvocationContext context, ServiceContainer bundle) {
final String bundleGroup = bundle.getBundleGroup();
final String bundleName = bundle.getBundleName();
final String bundleVersion = bundle.getBundleVersion();
return new CUCorrectionProposal("Add module dependency " + bundleName, context.getCompilationUnit(), null, -0) {
@Override
public void apply(IDocument document) {
try {
IJavaProject javaProject = context.getCompilationUnit().getJavaProject();
IProject project = javaProject.getProject();
ILiferayProject liferayProject = LiferayCore.create(project);
final IProjectBuilder builder = liferayProject.adapt(IProjectBuilder.class);
if (builder != null) {
Version retriveVersion = new Version(bundleVersion);
String[] dependency = { bundleGroup, bundleName, retriveVersion.getMajor() + "." + retriveVersion.getMinor() + ".0" };
List<String[]> dependencyList = new ArrayList<>();
dependencyList.add(dependency);
builder.updateProjectDependency(project, dependencyList);
}
} catch (Exception e) {
ProjectUI.logError("Error adding module dependency", e);
}
}
@Override
public Object getAdditionalProposalInfo(IProgressMonitor monitor) {
return "Add module dependency";
}
@Override
public Image getImage() {
return ProjectUI.getPluginImageRegistry().get(ProjectUI.MODULE_DEPENDENCY_IAMGE_ID);
}
};
}
use of com.liferay.ide.core.ILiferayProject in project liferay-ide by liferay.
the class PortalResourcesProvider method getResources.
@Override
public File[] getResources(IWebResourcesContext context) {
File[] retval = null;
IFile htmlFile = context.getHtmlFile();
ILiferayProject project = LiferayCore.create(htmlFile.getProject());
if ((htmlFile != null) && (project != null)) {
ILiferayPortal portal = project.adapt(ILiferayPortal.class);
if ((portal != null) && ProjectUtil.isPortletProject(htmlFile.getProject())) {
IPath portalDir = portal.getAppServerPortalDir();
if (portalDir != null) {
IPath cssPath = portalDir.append("html/themes/_unstyled/css");
if (FileUtil.exists(cssPath)) {
synchronized (_fileCache) {
Collection<File> cachedFiles = _fileCache.get(cssPath);
if (cachedFiles != null) {
retval = cachedFiles.toArray(new File[0]);
} else {
String types = new String[] { "css", "scss" };
Collection<File> files = FileUtils.listFiles(cssPath.toFile(), types, true);
Collection<File> cached = new HashSet<>();
for (File file : files) {
if (file.getName().endsWith("scss")) {
File cachedFile = new File(file.getParent(), ".sass-cache/" + file.getName().replaceAll("scss$", "css"));
if (FileUtil.exists(cachedFile)) {
cached.add(file);
}
}
}
files.removeAll(cached);
if (files != null) {
retval = files.toArray(new File[0]);
}
_fileCache.put(cssPath, files);
}
}
}
}
} else if ((portal != null) && ProjectUtil.isLayoutTplProject(htmlFile.getProject())) {
// return the static css resource for layout template names based on the version
String version = portal.getVersion();
try {
if ((version != null) && (version.startsWith("6.0") || version.startsWith("6.1"))) {
retval = _createLayoutHelperFiles("resources/layouttpl-6.1.css");
} else if (version != null) {
retval = _createLayoutHelperFiles("resources/layouttpl-6.2.css");
}
} catch (IOException ioe) {
AlloyCore.logError("Unable to load layout template helper css files", ioe);
}
}
}
return retval;
}
use of com.liferay.ide.core.ILiferayProject in project liferay-ide by liferay.
the class PropertiesUtil method getLanguagePropertiesFromPortletXml.
/**
* Search all resource bundle and supported locale files referenced by portlet.xml.
*/
public static IFile[] getLanguagePropertiesFromPortletXml(IFile portletXml) {
List<IFile> retval = new ArrayList<>();
IProject project = CoreUtil.getLiferayProject(portletXml);
if (project == null) {
return new IFile[0];
}
ILiferayProject lrproject = LiferayCore.create(project);
IFolder[] srcFolders = lrproject.getSourceFolders();
if (ListUtil.isEmpty(srcFolders)) {
return new IFile[0];
}
if (FileUtil.notExists(portletXml)) {
return new IFile[0];
}
for (IFolder srcFolder : srcFolders) {
if (FileUtil.notExists(srcFolder)) {
continue;
}
ResourceNodeInfo resourceNodeInfo = _getResourceNodeInfo(portletXml);
for (String resourceBundleValue : resourceNodeInfo.getResourceBundlePatterns()) {
IFile[] resourceBundleFiles = visitPropertiesFiles(srcFolder, resourceBundleValue);
if (ListUtil.isNotEmpty(resourceBundleFiles)) {
Collections.addAll(retval, resourceBundleFiles);
}
}
for (String supportedLocaleValue : resourceNodeInfo.getSupportedLocalePatterns()) {
IFile[] supportedLocaleFiles = visitPropertiesFiles(srcFolder, supportedLocaleValue);
if (ListUtil.isNotEmpty(supportedLocaleFiles)) {
Collections.addAll(retval, supportedLocaleFiles);
}
}
}
return retval.toArray(new IFile[0]);
}
use of com.liferay.ide.core.ILiferayProject in project liferay-ide by liferay.
the class AddLayoutTplOperation method _isBootstrapStyle.
private boolean _isBootstrapStyle() {
ILiferayProject lrproject = LiferayCore.create(getTargetProject());
ILiferayPortal portal = lrproject.adapt(ILiferayPortal.class);
if (portal != null) {
Version version = new Version(portal.getVersion());
if (CoreUtil.compareVersions(version, ILiferayConstants.V620) >= 0) {
return true;
}
return false;
}
return true;
}
use of com.liferay.ide.core.ILiferayProject in project liferay-ide by liferay.
the class LayoutTplEditor method _isBootstrapStyle.
private boolean _isBootstrapStyle() {
boolean retval = true;
try {
ILiferayProject lrproject = LiferayCore.create(getFile().getProject());
ILiferayPortal portal = lrproject.adapt(ILiferayPortal.class);
Version version = new Version(portal.getVersion());
if (CoreUtil.compareVersions(version, ILiferayConstants.V620) < 0) {
retval = false;
}
} catch (Exception e) {
}
return retval;
}
Aggregations