use of org.eclipse.wst.common.project.facet.core.IFacetedProject in project liferay-ide by liferay.
the class UpgradeRuntimeHandler method execute.
@Override
public Status execute(IProject project, String runtimeName, IProgressMonitor monitor, int perUnit) {
Status retval = Status.createOkStatus();
try {
int worked = 0;
IProgressMonitor submon = CoreUtil.newSubMonitor(monitor, 25);
submon.subTask("Update project runtime");
org.eclipse.wst.common.project.facet.core.runtime.IRuntime runtime = RuntimeManager.getRuntime(runtimeName);
if (runtime != null) {
worked = worked + perUnit;
submon.worked(worked);
if (runtime != null) {
IFacetedProject fProject = ProjectUtil.getFacetedProject(project);
org.eclipse.wst.common.project.facet.core.runtime.IRuntime primaryRuntime = fProject.getPrimaryRuntime();
if (!runtime.equals(primaryRuntime)) {
worked = worked + perUnit;
submon.worked(worked);
fProject.setTargetedRuntimes(Collections.singleton(runtime), monitor);
worked = worked + perUnit;
submon.worked(worked);
fProject.setPrimaryRuntime(runtime, monitor);
worked = worked + perUnit;
submon.worked(worked);
}
}
}
} catch (Exception e) {
IStatus error = ProjectCore.createErrorStatus("Unable to upgrade target runtime for " + project.getName(), e);
ProjectCore.logError(error);
retval = StatusBridge.create(error);
}
return retval;
}
use of org.eclipse.wst.common.project.facet.core.IFacetedProject in project liferay-ide by liferay.
the class PrimaryRuntimeNotLiferayRuntimeResolution method run.
public void run(IMarker marker) {
IFacetedProject fproj = ProjectUtil.getFacetedProject((IProject) marker.getResource());
try {
fproj.setPrimaryRuntime(null, null);
fproj.setTargetedRuntimes(null, null);
} catch (CoreException ce) {
ProjectUI.logError(ce);
}
super.run(marker);
}
use of org.eclipse.wst.common.project.facet.core.IFacetedProject in project liferay-ide by liferay.
the class PrimaryRuntimeNotSetResolution method run.
/**
* IDE-1179, Quick fix for the project of which primary runtime is not set.
*/
public void run(IMarker marker) {
if (marker.getResource() instanceof IProject) {
final IProject proj = (IProject) marker.getResource();
final IFacetedProject fproj = ProjectUtil.getFacetedProject(proj);
/*
* Let users set a Liferay server runtime when there is no available one.
*/
if (ServerUtil.getAvailableLiferayRuntimes().size() == 0) {
boolean openNewRuntimeWizard = MessageDialog.openQuestion(null, null, Msgs.noLiferayRuntimeAvailable);
if (openNewRuntimeWizard) {
ServerUIUtil.showNewRuntimeWizard(null, null, null, "com.liferay.");
}
}
/*
* Let users confirm when there is only one available Liferay runtime.
*
* If the previous judgment block is executed, the size of available targeted
* runtimes will increase to 1.
*/
if (ServerUtil.getAvailableLiferayRuntimes().size() == 1) {
final Set<IRuntime> availableFacetRuntimes = _convertToFacetRuntimes(ServerUtil.getAvailableLiferayRuntimes());
String runtimeName = ((IRuntime) availableFacetRuntimes.toArray()[0]).getName();
boolean setAsPrimary = MessageDialog.openQuestion(null, null, NLS.bind(Msgs.setOnlyRuntimeAsPrimary, runtimeName));
if (setAsPrimary) {
try {
fproj.setTargetedRuntimes(availableFacetRuntimes, null);
fproj.setPrimaryRuntime((IRuntime) availableFacetRuntimes.toArray()[0], null);
} catch (CoreException ce) {
ProjectUI.logError(ce);
}
}
}
/*
* Open the "Targeted Runtimes" property page and let users set a runtime as the
* primary one when there are multiple Liferay runtimes available.
*/
if (ServerUtil.getAvailableLiferayRuntimes().size() > 1) {
boolean openRuntimesProperty = MessageDialog.openQuestion(null, null, Msgs.multipleAvailableRuntimes);
if (openRuntimesProperty) {
PropertyDialog.createDialogOn(null, TARGETED_RUNTIMES_PROPERTY_PAGE_ID, proj).open();
}
}
}
}
use of org.eclipse.wst.common.project.facet.core.IFacetedProject in project liferay-ide by liferay.
the class ProjectCoreBase method createProject.
public IProject createProject(NewLiferayPluginProjectOp op, String projectName) {
Status status = op.execute(ProgressMonitorBridge.create(new NullProgressMonitor()));
assertNotNull(status);
assertEquals(status.toString(), Status.createOkStatus().message().toLowerCase(), status.message().toLowerCase());
if (projectName == null || op.getProjectProvider().content().getShortName().equalsIgnoreCase("ant")) {
projectName = op.getFinalProjectName().content();
}
// if( op.getProjectProvider().content().getShortName().equalsIgnoreCase( "maven" ) )
// {
// if( op.getPluginType().content().equals( PluginType.ext ) )
// {
// projectName = projectName + "-ext";
// }
// else if( op.getPluginType().content().equals( PluginType.servicebuilder ) )
// {
// projectName = projectName + "-portlet";
// }
// }
final IProject newLiferayPluginProject = project(projectName);
assertNotNull(newLiferayPluginProject);
assertEquals(true, newLiferayPluginProject.exists());
final IFacetedProject facetedProject = ProjectUtil.getFacetedProject(newLiferayPluginProject);
assertNotNull(facetedProject);
final IProjectFacet liferayFacet = ProjectUtil.getLiferayFacet(facetedProject);
assertNotNull(liferayFacet);
final PluginType pluginTypeValue = op.getPluginType().content(true);
if (pluginTypeValue.equals(PluginType.servicebuilder)) {
assertEquals("liferay.portlet", liferayFacet.getId());
} else {
assertEquals("liferay." + pluginTypeValue, liferayFacet.getId());
}
return newLiferayPluginProject;
}
use of org.eclipse.wst.common.project.facet.core.IFacetedProject in project liferay-ide by liferay.
the class LiferayPublishHelper method prePublishModule.
public static boolean prePublishModule(ServerBehaviourDelegate delegate, int kind, int deltaKind, IModule[] moduleTree, IModuleResourceDelta[] resourceDelta, IProgressMonitor monitor) {
boolean retval = true;
if (ListUtil.isNotEmpty(moduleTree) && moduleTree[0].getProject() != null) {
IProject project = moduleTree[0].getProject();
IFacetedProject facetedProject = ServerUtil.getFacetedProject(project);
if (facetedProject != null) {
IProjectFacet liferayFacet = ServerUtil.getLiferayFacet(facetedProject);
if (liferayFacet != null) {
String facetId = liferayFacet.getId();
IRuntime runtime = null;
try {
runtime = delegate.getServer().getRuntime();
if (runtime != null) {
IPluginPublisher pluginPublisher = LiferayServerCore.getPluginPublisher(facetId, runtime.getRuntimeType().getId());
if (pluginPublisher != null) {
retval = pluginPublisher.prePublishModule(delegate, kind, deltaKind, moduleTree, resourceDelta, monitor);
}
}
} catch (Exception e) {
// $NON-NLS-1$
LiferayServerCore.logError("Plugin publisher failed", e);
}
}
}
}
return retval;
}
Aggregations