use of org.eclipse.wst.common.project.facet.core.runtime.IRuntime in project liferay-ide by liferay.
the class LiferayProjectImportOperation method execute.
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
ProjectRecord projectRecord = (ProjectRecord) getDataModel().getProperty(PROJECT_RECORD);
if (projectRecord == null) {
return ProjectCore.createErrorStatus("Project record to import is null.");
}
File projectDir = projectRecord.getProjectLocation().toFile();
SDK sdk = SDKUtil.getSDKFromProjectDir(projectDir);
if ((sdk != null) && !(SDKManager.getInstance().containsSDK(sdk))) {
SDKManager.getInstance().addSDK(sdk);
}
IRuntime runtime = (IRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
try {
ProjectImportUtil.importProject(projectRecord, runtime, sdk.getLocation().toOSString(), monitor);
} catch (CoreException ce) {
return ProjectCore.createErrorStatus(ce);
}
return Status.OK_STATUS;
}
use of org.eclipse.wst.common.project.facet.core.runtime.IRuntime in project liferay-ide by liferay.
the class SDKPluginFacetUtil method configureProjectAsSDKProject.
public static void configureProjectAsSDKProject(IFacetedProjectWorkingCopy fpjwc, String pluginType, String sdkLocation, ProjectRecord projectRecord) throws CoreException {
IFacetedProjectTemplate template = getLiferayTemplateForProject(pluginType);
IPreset preset = getLiferayPresetForProject(pluginType);
if (preset == null) {
throw new CoreException(ProjectCore.createErrorStatus(NLS.bind(Msgs.noFacetPreset, fpjwc.getProjectName())));
}
IRuntime primaryRuntime = fpjwc.getPrimaryRuntime();
if (primaryRuntime != null) {
fpjwc.removeTargetedRuntime(primaryRuntime);
}
Set<IProjectFacetVersion> currentProjectFacetVersions = fpjwc.getProjectFacets();
Set<IProjectFacet> requiredFacets = template.getFixedProjectFacets();
for (IProjectFacet requiredFacet : requiredFacets) {
boolean hasRequiredFacet = false;
for (IProjectFacetVersion currentFacetVersion : currentProjectFacetVersions) {
if (currentFacetVersion.getProjectFacet().equals(requiredFacet)) {
// TODO how to check the bundle support status?
boolean requiredVersion = _isRequiredVersion(currentFacetVersion);
if (requiredVersion) {
hasRequiredFacet = true;
} else {
fpjwc.removeProjectFacet(currentFacetVersion);
}
break;
}
}
if (!hasRequiredFacet) {
IProjectFacetVersion requiredFacetVersion = _getRequiredFacetVersionFromPreset(requiredFacet, preset);
if (requiredFacetVersion != null) {
fpjwc.addProjectFacet(requiredFacetVersion);
if (ProjectUtil.isJavaFacet(requiredFacetVersion)) {
configureJavaFacet(fpjwc, requiredFacetVersion.getProjectFacet(), preset, projectRecord);
} else if (ProjectUtil.isDynamicWebFacet(requiredFacetVersion)) {
configureWebFacet(fpjwc, requiredFacetVersion.getProjectFacet(), preset);
}
}
} else {
if (ProjectUtil.isJavaFacet(requiredFacet)) {
configureJavaFacet(fpjwc, requiredFacet, preset, projectRecord);
} else if (ProjectUtil.isDynamicWebFacet(requiredFacet)) {
configureWebFacet(fpjwc, requiredFacet, preset);
}
}
}
}
use of org.eclipse.wst.common.project.facet.core.runtime.IRuntime 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();
}
}
}
}
Aggregations