use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class CustomJspPossibleValuesService method compute.
@Override
protected void compute(final Set<String> values) {
if (_possibleValues == null) {
IProject project = project();
ILiferayProject liferayProject = LiferayCore.create(project);
if (liferayProject != null) {
ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
if (portal != null) {
_portalDir = new Path(portal.getAppServerPortalDir().toPortableString());
if (_portalDir != null) {
File portalDirFile = _portalDir.toFile();
File htmlDirFile = new File(portalDirFile, "html");
List<File> fileValues = new LinkedList<>();
if (FileUtil.exists(htmlDirFile)) {
_findJSPFiles(new File[] { htmlDirFile }, fileValues);
} else {
File[] files = portalDirFile.listFiles(_jspfilter);
_findJSPFiles(files, fileValues);
}
_possibleValues = fileValues.toArray(new File[0]);
}
}
}
}
if (_possibleValues != null) {
for (File file : _possibleValues) {
values.add(new Path(file.getAbsolutePath()).makeRelativeTo(_portalDir).toPortableString());
}
}
}
use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class NewPortletClassDataModelProvider method getEntryCategories.
protected Properties getEntryCategories() {
// removed if not null return directly, because it won't update when switch
// projects of different portal versions
ILiferayProject liferayProject = LiferayCore.create(getProject());
if (liferayProject == null) {
try {
liferayProject = LiferayCore.create(getRuntime());
} catch (CoreException ce) {
PortletCore.logError(ce);
}
}
ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
if (portal != null) {
return portal.getPortletEntryCategories();
} else {
return null;
}
}
use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class NewPortletClassDataModelProvider method getDefaultProperty.
@Override
public Object getDefaultProperty(String propertyName) {
if (SUPERCLASS.equals(propertyName)) {
return QUALIFIED_MVC_PORTLET;
} else if (CONSTRUCTOR.equals(propertyName)) {
return false;
} else if (INIT_OVERRIDE.equals(propertyName) || DOVIEW_OVERRIDE.equals(propertyName)) {
return true;
} else if (DESTROY_OVERRIDE.equals(propertyName)) {
return false;
} else if (JAVA_PACKAGE.equals(propertyName)) {
return "com.test";
} else if (CLASS_NAME.equals(propertyName)) {
return "NewPortlet";
} else if (PORTLET_NAME.equals(propertyName) || LIFERAY_PORTLET_NAME.equals(propertyName)) {
return getPortletNameFromClassName(getStringProperty(CLASS_NAME));
} else if (DISPLAY_NAME.equals(propertyName) || TITLE.equals(propertyName) || SHORT_TITLE.equals(propertyName)) {
return _getDisplayNameFromPortletName(getStringProperty(PORTLET_NAME));
} else if (KEYWORDS.equals(propertyName)) {
return StringPool.EMPTY;
} else if (INIT_PARAMS.equals(propertyName)) {
return getInitParams();
} else if (VIEW_MODE.equals(propertyName)) {
return true;
} else if (CREATE_JSPS.equals(propertyName)) {
return true;
} else if (CREATE_JSPS_FOLDER.equals(propertyName)) {
if (getBooleanProperty(CREATE_NEW_PORTLET_CLASS)) {
String tempStr = getProperty(CLASS_NAME).toString();
String property = tempStr.toLowerCase();
return "/html/" + property.replaceAll(_PORTLET_SUFFIX_PATTERN, "");
} else {
String tempStr = getProperty(PORTLET_NAME).toString();
String property = tempStr.toLowerCase();
return "/html/" + property.replaceAll(_PORTLET_SUFFIX_PATTERN, "");
}
} else if (ICON_FILE.equals(propertyName)) {
return "/icon.png";
} else if (CREATE_RESOURCE_BUNDLE_FILE.equals(propertyName)) {
return false;
} else if (CREATE_RESOURCE_BUNDLE_FILE_PATH.equals(propertyName)) {
return "content/Language.properties";
} else if (ALLOW_MULTIPLE.equals(propertyName)) {
return false;
} else if (CSS_FILE.equals(propertyName)) {
return "/css/main.css";
} else if (JAVASCRIPT_FILE.equals(propertyName)) {
return "/js/main.js";
} else if (CSS_CLASS_WRAPPER.equals(propertyName)) {
String property = getProperty(PORTLET_NAME).toString();
return property.toLowerCase() + "-portlet";
} else if (ID.equals(propertyName)) {
return getProperty(PORTLET_NAME);
} else if (CATEGORY.equals(propertyName)) {
return "category.sample";
} else if (ENTRY_CATEGORY.equals(propertyName)) {
return "category.my";
} else if (ENTRY_WEIGHT.equals(propertyName)) {
return "1.5";
} else if (ENTRY_CLASS_NAME.equals(propertyName)) {
return getStringProperty(CLASS_NAME) + "ControlPanelEntry";
} else if (SHOW_NEW_CLASS_OPTION.equals(propertyName)) {
return true;
} else if (CREATE_NEW_PORTLET_CLASS.equals(propertyName)) {
return true;
} else if (USE_DEFAULT_PORTLET_CLASS.equals(propertyName)) {
return false;
} else if (QUALIFIED_CLASS_NAME.equals(propertyName)) {
if (getBooleanProperty(USE_DEFAULT_PORTLET_CLASS)) {
return QUALIFIED_MVC_PORTLET;
}
} else if (PROJECT_NAME.equals(propertyName) && (initialProject != null)) {
return initialProject.getName();
} else if (INIT_PARAMETER_NAME.equals(propertyName)) {
String initParameterName = "template";
ILiferayProject liferayProject = LiferayCore.create(getProject());
ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
if (portal != null) {
String version = portal.getVersion();
if (version != null) {
Version portalVersion = Version.parseVersion(version);
if (CoreUtil.compareVersions(portalVersion, ILiferayConstants.V610) < 0) {
initParameterName = "jsp";
}
return initParameterName;
}
}
}
return super.getDefaultProperty(propertyName);
}
use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class LiferayDescriptorHelper method getDescriptorVersion.
public static String getDescriptorVersion(IProject project, String defaultValue) {
String retval = defaultValue;
try {
ILiferayProject lProject = LiferayCore.create(project);
if (lProject != null) {
ILiferayPortal portal = lProject.adapt(ILiferayPortal.class);
if (portal != null) {
String versionStr = portal.getVersion();
retval = getDescriptorVersionFromPortalVersion(versionStr);
}
}
} catch (Exception e) {
LiferayCore.logError("Could not get liferay runtime.", e);
}
if ("0.0.0".equals(retval)) {
retval = defaultValue;
}
return retval;
}
use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class LiferayHookModelTests method strutsActionPathPossibleValuesCacheService.
@Test
public void strutsActionPathPossibleValuesCacheService() throws Exception {
if (shouldSkipBundleTests())
return;
final NewLiferayPluginProjectOp op = newProjectOp("testPossibleValuesCache");
op.setPluginType(PluginType.hook);
final IProject hookProject = createAntProject(op);
final IFolder webappRoot = LiferayCore.create(IWebProject.class, hookProject).getDefaultDocrootFolder();
assertNotNull(webappRoot);
final IFile hookXml = webappRoot.getFile("WEB-INF/liferay-hook.xml");
assertEquals(true, hookXml.exists());
final Hook hook = Hook6xx.TYPE.instantiate(new RootXmlResource(new XmlResourceStore(hookXml.getContents())));
assertNotNull(hook);
final ILiferayProject liferayProject = LiferayCore.create(hookProject);
final ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
final IPath strutsConfigPath = portal.getAppServerPortalDir().append("WEB-INF/struts-config.xml");
final StrutsAction strutsAction = hook.getStrutsActions().insert();
final Value<String> strutsActionPath = strutsAction.getStrutsActionPath();
final TreeSet<String> vals1 = strutsActionPath.service(StrutsActionPathPossibleValuesCacheService.class).getPossibleValuesForPath(strutsConfigPath);
final TreeSet<String> vals2 = strutsActionPath.service(StrutsActionPathPossibleValuesCacheService.class).getPossibleValuesForPath(strutsConfigPath);
assertTrue(vals1 == vals2);
}
Aggregations