use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class LiferayPropertiesSourceViewerConfiguration method getContentAssistant.
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
if (_propKeys == null) {
IEditorInput input = getEditor().getEditorInput();
// first fine runtime location to get properties definitions
IPath appServerPortalDir = _getAppServerPortalDir(input);
String propertiesEntry = _getPropertiesEntry(input);
PropKey[] keys = null;
if ((appServerPortalDir != null) && appServerPortalDir.toFile().exists()) {
try {
JarFile jar = new JarFile(appServerPortalDir.append("WEB-INF/lib/portal-impl.jar").toFile());
ZipEntry lang = jar.getEntry(propertiesEntry);
keys = _parseKeys(jar.getInputStream(lang));
jar.close();
} catch (Exception e) {
LiferayUIPlugin.logError("Unable to get portal properties file", e);
}
} else {
return _assitant;
}
Object adapter = input.getAdapter(IFile.class);
if (adapter instanceof IFile && _isHookProject(((IFile) adapter).getProject())) {
ILiferayProject liferayProject = LiferayCore.create(((IFile) adapter).getProject());
ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
if (portal != null) {
Set<String> hookProps = new HashSet<>();
Collections.addAll(hookProps, portal.getHookSupportedProperties());
List<PropKey> filtered = new ArrayList<>();
for (PropKey pk : keys) {
if (hookProps.contains(pk.getKey())) {
filtered.add(pk);
}
}
keys = filtered.toArray(new PropKey[0]);
}
}
_propKeys = keys;
}
if ((_propKeys != null) && (_assitant == null)) {
ContentAssistant ca = new ContentAssistant() {
@Override
public IContentAssistProcessor getContentAssistProcessor(String contentType) {
return new LiferayPropertiesContentAssistProcessor(_propKeys, contentType);
}
};
ca.setInformationControlCreator(getInformationControlCreator(sourceViewer));
_assitant = ca;
}
return _assitant;
}
use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class ServerUtil method getPortalDir.
public static IPath getPortalDir(IProject project) {
IPath retval = null;
final ILiferayProject liferayProject = LiferayCore.create(project);
if (liferayProject != null) {
final ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
if (portal != null) {
retval = portal.getAppServerPortalDir();
}
}
return retval;
}
use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class VersionsTests method testFindLiferayVersionByProperties.
@Test
public void testFindLiferayVersionByProperties() throws Exception {
IProject project = importProject("projects/versions/properties-portlet/pom.xml");
assertNotNull(project);
IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().create(project, monitor);
assertNotNull(facade);
final ILiferayProject lrproject = LiferayCore.create(project);
assertNotNull(lrproject);
final ILiferayPortal portal = lrproject.adapt(ILiferayPortal.class);
assertNotNull(portal);
assertEquals("6.2.1", portal.getVersion());
}
use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class ThemeCSSBuilder method applyDiffsDeltaToDocroot.
protected void applyDiffsDeltaToDocroot(IResourceDelta delta, IContainer docroot, IProgressMonitor monitor) {
int deltaKind = delta.getKind();
switch(deltaKind) {
case IResourceDelta.REMOVED_PHANTOM:
break;
}
IPath path = CoreUtil.getResourceLocation(docroot);
ILiferayProject liferayProject = LiferayCore.create(getProject());
String themeParent = liferayProject.getProperty("theme.parent", "_styled");
ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
if (portal != null) {
IPath themesPath = portal.getAppServerPortalDir().append("html/themes");
List<IPath> restorePaths = new ArrayList<>();
for (int i = 0; i < IPluginProjectDataModelProperties.THEME_PARENTS.length; i++) {
if (IPluginProjectDataModelProperties.THEME_PARENTS[i].equals(themeParent)) {
restorePaths.add(themesPath.append(IPluginProjectDataModelProperties.THEME_PARENTS[i]));
} else {
if (ListUtil.isNotEmpty(restorePaths)) {
restorePaths.add(themesPath.append(IPluginProjectDataModelProperties.THEME_PARENTS[i]));
}
}
}
new Job("publish theme delta") {
@Override
protected IStatus run(IProgressMonitor monitor) {
_buildHelper.publishDelta(delta, path, restorePaths.toArray(new IPath[0]), monitor);
try {
docroot.refreshLocal(IResource.DEPTH_INFINITE, monitor);
} catch (Exception e) {
ThemeCore.logError(e);
}
return Status.OK_STATUS;
}
}.schedule();
}
}
use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class ThemeCSSBuilder method ensureLookAndFeelFileExists.
public static void ensureLookAndFeelFileExists(IProject project) throws CoreException {
// IDE-110 IDE-648
IWebProject lrProject = LiferayCore.create(IWebProject.class, project);
if (lrProject == null) {
return;
}
IFile lookAndFeelFile = null;
IResource res = lrProject.findDocrootResource(new Path("WEB-INF/" + ILiferayConstants.LIFERAY_LOOK_AND_FEEL_XML_FILE));
if (res instanceof IFile && res.exists()) {
lookAndFeelFile = (IFile) res;
}
if (lookAndFeelFile == null) {
// need to generate a new lnf file in deafult docroot
String id = project.getName().replaceAll(ISDKConstants.THEME_PLUGIN_PROJECT_SUFFIX, StringPool.EMPTY);
IResource propertiesFileRes = lrProject.findDocrootResource(new Path("WEB-INF/" + ILiferayConstants.LIFERAY_PLUGIN_PACKAGE_PROPERTIES_FILE));
String name = id;
if (propertiesFileRes instanceof IFile && propertiesFileRes.exists()) {
Properties props = new Properties();
try {
IFile propsFile = (IFile) propertiesFileRes;
InputStream contents = propsFile.getContents();
props.load(contents);
contents.close();
String nameValue = props.getProperty("name");
if (!CoreUtil.isNullOrEmpty(nameValue)) {
name = nameValue;
}
ThemeDescriptorHelper themeDescriptorHelper = new ThemeDescriptorHelper(project);
ILiferayProject lProject = lrProject;
ILiferayPortal portal = lProject.adapt(ILiferayPortal.class);
String version = "6.2.0";
if (portal != null) {
version = portal.getVersion();
}
String themeType = lProject.getProperty("theme.type", "vm");
themeDescriptorHelper.createDefaultFile(lrProject.getDefaultDocrootFolder().getFolder("WEB-INF"), version, id, name, themeType);
} catch (IOException ioe) {
ThemeCore.logError("Unable to load plugin package properties.", ioe);
}
}
}
}
Aggregations