use of com.liferay.ide.core.ILiferayProject 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.ILiferayProject in project liferay-ide by liferay.
the class RemoteServerBehavior method publishModuleDelta.
protected int publishModuleDelta(IModule[] module, IProgressMonitor monitor) throws CoreException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
IProject moduleProject = module[0].getProject();
IModuleResourceDelta[] delta = getPublishedResourceDelta(module);
if (shouldPublishModuleFull(delta)) {
return publishModuleFull(module, CHANGED, monitor);
}
final String appName = ComponentUtilities.getServerContextRoot(moduleProject);
// $NON-NLS-1$ //$NON-NLS-2$
monitor.subTask("Creating partial " + moduleProject.getName() + " update archive...");
final ILiferayProject liferayProject = LiferayCore.create(moduleProject);
final IRemoteServerPublisher publisher = liferayProject.adapt(IRemoteServerPublisher.class);
if (publisher == null) {
setModuleStatus(module, null);
throw new CoreException(LiferayServerCore.error(Msgs.publishingModuleProject));
}
final IPath warPath = publisher.publishModuleDelta(appName + ".war", delta, "liferay", true);
monitor.worked(25);
if (monitor != null && monitor.isCanceled()) {
return IServer.PUBLISH_STATE_UNKNOWN;
}
monitor.subTask(Msgs.gettingLiferayConnection);
IServerManagerConnection connection = getServerManagerConnection();
monitor.subTask(NLS.bind(Msgs.updatingModuleProject, moduleProject.getName()));
Object error = null;
try {
error = connection.updateApplication(appName, warPath.toOSString(), monitor);
} catch (APIException e) {
error = e.getMessage();
}
monitor.worked(90);
if (error != null) {
throw new CoreException(LiferayServerCore.error(error.toString()));
}
monitor.done();
return IServer.PUBLISH_STATE_NONE;
}
use of com.liferay.ide.core.ILiferayProject 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.ILiferayProject in project liferay-ide by liferay.
the class MavenModuleProjectTests method testMavenDependencyUpdate.
@Test
public void testMavenDependencyUpdate() throws Exception {
String[][] dependency = new String[][] { { "com.liferay.portal", "com.liferay.portal.kernel", "2.6.0" } };
Dependency mavenDependency = new Dependency();
mavenDependency.setGroupId(dependency[0][0]);
mavenDependency.setArtifactId(dependency[0][1]);
mavenDependency.setVersion(dependency[0][2]);
final URL wsZipUrl = Platform.getBundle("com.liferay.ide.maven.core.tests").getEntry("projects/MavenDependencyTestProject.zip");
final File wsZipFile = new File(FileLocator.toFileURL(wsZipUrl).getFile());
File eclipseWorkspaceLocation = CoreUtil.getWorkspaceRoot().getLocation().toFile();
ZipUtil.unzip(wsZipFile, eclipseWorkspaceLocation);
File mavenDependencyTestProjectFolder = new File(eclipseWorkspaceLocation, "MavenDependencyTestProject");
MavenUtil.importProject(mavenDependencyTestProjectFolder.getAbsolutePath(), monitor);
waitForJobsToComplete(monitor);
IProject mavenDependencyTestProject = CoreUtil.getProject("MavenDependencyTestProject");
assertNotNull(mavenDependencyTestProject);
assertTrue(mavenDependencyTestProject.exists());
IMavenProjectFacade projectFacade = MavenUtil.getProjectFacade(mavenDependencyTestProject, new NullProgressMonitor());
assertNotNull(projectFacade);
MavenProject mavenProject = projectFacade.getMavenProject(new NullProgressMonitor());
List<Dependency> existedDependencies = mavenProject.getDependencies();
assertFalse(checkDependency(existedDependencies, mavenDependency));
ILiferayProject liferayMavenDependencyProject = LiferayCore.create(mavenDependencyTestProject);
IProjectBuilder projectBuilder = liferayMavenDependencyProject.adapt(IProjectBuilder.class);
projectBuilder.updateProjectDependency(mavenDependencyTestProject, Arrays.asList(dependency));
waitForJobsToComplete(monitor);
MavenProject updateMavenProject = projectFacade.getMavenProject(new NullProgressMonitor());
List<Dependency> updateDependencies = updateMavenProject.getDependencies();
assertTrue(checkDependency(updateDependencies, mavenDependency));
}
use of com.liferay.ide.core.ILiferayProject 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());
}
Aggregations