use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class AddServiceBuilderOperation method createDefaultServiceBuilderFile.
public void createDefaultServiceBuilderFile(IFile serviceBuilderFile, IProgressMonitor monitor) throws CoreException {
String descriptorVersion = null;
try {
ILiferayProject liferayProject = LiferayCore.create(serviceBuilderFile.getProject());
ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
Version portalVersion = new Version(portal.getVersion());
descriptorVersion = portalVersion.getMajor() + "." + portalVersion.getMinor() + ".0";
} catch (Exception e) {
ProjectCore.logError("Could not determine liferay runtime version", e);
descriptorVersion = "6.0.0";
}
WizardUtil.createDefaultServiceBuilderFile(serviceBuilderFile, descriptorVersion, getDataModel().getBooleanProperty(USE_SAMPLE_TEMPLATE), getDataModel().getStringProperty(PACKAGE_PATH), getDataModel().getStringProperty(NAMESPACE), getDataModel().getStringProperty(AUTHOR), monitor);
getDataModel().setProperty(CREATED_SERVICE_FILE, serviceBuilderFile);
}
use of com.liferay.ide.core.ILiferayPortal 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.ILiferayPortal 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.ILiferayPortal 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;
}
use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class PortalFilterNamesPossibleValuesService method compute.
@Override
protected void compute(Set<String> values) {
if (_servletFilterNames == null) {
Element element = context().find(Element.class);
IFile hookFile = element.adapt(IFile.class);
if (hookFile != null) {
try {
ILiferayProject liferayProject = LiferayCore.create(hookFile.getProject());
if (liferayProject != null) {
ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
if (portal != null) {
IPath appServerPortalDir = portal.getAppServerPortalDir();
if (appServerPortalDir != null) {
_servletFilterNames = ServerUtil.getServletFilterNames(appServerPortalDir);
}
}
}
} catch (Exception e) {
}
}
}
if (_servletFilterNames != null) {
Collections.addAll(values, _servletFilterNames);
}
}
Aggregations