use of org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime in project liferay-ide by liferay.
the class BinaryProjectsImportOperation method execute.
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
String sdkLocation = model.getStringProperty(ISDKProjectsImportDataModelProperties.SDK_LOCATION);
IRuntime runtime = (IRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
Object[] projects = (Object[]) model.getProperty(ISDKProjectsImportDataModelProperties.SELECTED_PROJECTS);
BridgedRuntime bridgedRuntime = (BridgedRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
WorkspaceJob job = new WorkspaceJob(Msgs.importingBinaryProjectPlugins) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
if (projects == null) {
return Status.OK_STATUS;
}
SDKManager sdkManager = SDKManager.getInstance();
SDK liferaySDK = sdkManager.getSDK(new Path(sdkLocation));
Object[] seleBinaryRecords = (Object[]) projects;
monitor.beginTask(Msgs.creatingSDKProjects, seleBinaryRecords.length);
ProjectRecord[] projectRecords = new ProjectRecord[seleBinaryRecords.length];
for (int i = 0; i < seleBinaryRecords.length; i++) {
BinaryProjectRecord pluginBinaryRecord = (BinaryProjectRecord) seleBinaryRecords[i];
try {
monitor.subTask(Msgs.creatingPlugin + pluginBinaryRecord.getLiferayPluginName());
projectRecords[i] = ProjectImportUtil.createSDKPluginProject(bridgedRuntime, pluginBinaryRecord, liferaySDK);
monitor.worked(1);
} catch (IOException ioe) {
throw new CoreException(ProjectCore.createErrorStatus("Error creating project.", ioe));
}
}
monitor.done();
ProjectImportUtil.createWorkspaceProjects(projectRecords, runtime, sdkLocation, monitor);
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
return Status.OK_STATUS;
}
use of org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime in project liferay-ide by liferay.
the class SDKProjectsImportDataModelProvider method validate.
@Override
public IStatus validate(String name) {
if (SDK_LOCATION.equals(name)) {
String sdkLocation = getStringProperty(SDK_LOCATION);
if (SDKUtil.isValidSDKLocation(sdkLocation)) {
return Status.OK_STATUS;
} else {
return ProjectCore.createErrorStatus(Msgs.invalidPluginSDKLocation);
}
} else if (SDK_VERSION.equals(name)) {
String sdkVersion = getStringProperty(SDK_VERSION);
if (SDKUtil.isValidSDKVersion(sdkVersion, SDKManager.getLeastValidVersion())) {
Object runtime = getProperty(FACET_RUNTIME);
if (_compareSDKRuntimeVersion(sdkVersion, runtime)) {
return Status.OK_STATUS;
} else {
return ProjectCore.createWarningStatus(Msgs.versionUnequal);
}
} else {
return ProjectCore.createErrorStatus(Msgs.invalidPluginSDKVersion + SDKManager.getLeastValidVersion());
}
} else if (SELECTED_PROJECTS.equals(name)) {
Object val = getProperty(SELECTED_PROJECTS);
if (val instanceof Object[]) {
Object[] selectedProjects = (Object[]) val;
if (selectedProjects.length >= 1) {
for (Object project : selectedProjects) {
if (project instanceof BinaryProjectRecord) {
BinaryProjectRecord binaryProject = (BinaryProjectRecord) project;
Version sdkVersion = new Version(getStringProperty(SDK_VERSION));
if (binaryProject.isWeb() && (CoreUtil.compareVersions(sdkVersion, ILiferayConstants.V700) < 0)) {
return ProjectCore.createErrorStatus(Msgs.unableSupportWebPluginType);
}
}
}
return Status.OK_STATUS;
}
}
return createSelectedProjectsErrorStatus();
} else if (FACET_RUNTIME.equals(name)) {
Object runtime = getProperty(FACET_RUNTIME);
if (!(runtime instanceof BridgedRuntime)) {
return ProjectCore.createErrorStatus(Msgs.selectValidLiferayRuntime);
} else {
String sdkVersion = getStringProperty(SDK_VERSION);
if (_compareSDKRuntimeVersion(sdkVersion, runtime)) {
return Status.OK_STATUS;
} else {
return ProjectCore.createWarningStatus(Msgs.versionUnequal);
}
}
} else if (FACET_PROJECT_NAME.equals(name)) {
return Status.OK_STATUS;
}
return super.validate(name);
}
use of org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime in project liferay-ide by liferay.
the class LiferayProjectImportDataModelProvider method validate.
@Override
public IStatus validate(String name) {
if (PROJECT_LOCATION.equals(name)) {
String projectLocation = getStringProperty(PROJECT_LOCATION);
ProjectRecord record = ProjectUtil.getProjectRecordForDir(projectLocation);
if (record != null) {
String projectName = record.getProjectName();
IProject existingProject = CoreUtil.getWorkspaceRoot().getProject(projectName);
if (FileUtil.exists(existingProject)) {
return ProjectCore.createErrorStatus(Msgs.projectNameExists);
}
File projectDir = record.getProjectLocation().toFile();
// go up to the SDK level
SDK sdk = SDKUtil.getSDKFromProjectDir(projectDir);
if (sdk != null) {
return Status.OK_STATUS;
} else {
return ProjectCore.createErrorStatus(Msgs.projectNotLocated);
}
}
return ProjectCore.createErrorStatus(Msgs.invalidProjectLocation);
} else if (SDK_VERSION.equals(name)) {
IStatus locationStatus = validate(PROJECT_LOCATION);
if (locationStatus.isOK()) {
Version version = new Version(getStringProperty(SDK_VERSION));
if (CoreUtil.compareVersions(version, SDKManager.getLeastValidVersion()) >= 0) {
return Status.OK_STATUS;
} else {
return ProjectCore.createErrorStatus(Msgs.invalidPluginSDKVersion + SDKManager.getLeastValidVersion());
}
} else {
return locationStatus;
}
} else if (PLUGIN_TYPE.equals(name)) {
if (ProjectUtil.isLiferayPluginType(getStringProperty(PLUGIN_TYPE))) {
return Status.OK_STATUS;
} else {
return ProjectCore.createErrorStatus(Msgs.invalidLiferayPluginType);
}
} else if (FACET_RUNTIME.equals(name)) {
Object runtime = getProperty(FACET_RUNTIME);
if (!(runtime instanceof BridgedRuntime)) {
return ProjectCore.createErrorStatus(Msgs.validLiferayRuntimeSelected);
} else {
return Status.OK_STATUS;
}
} else if (FACET_PROJECT_NAME.equals(name)) {
return Status.OK_STATUS;
}
return super.validate(name);
}
use of org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime in project liferay-ide by liferay.
the class PluginsSDKProjectRuntimeValidator method validate.
public void validate(IFacetedProject fproj) throws CoreException {
IProject project = fproj.getProject();
if (!ProjectUtil.isLiferayFacetedProject(project)) {
return;
}
_clearMarkers(project);
if (SDKUtil.isSDKProject(fproj.getProject())) {
IJavaProject javaProject = JavaCore.create(project);
for (IClasspathEntry entry : javaProject.getRawClasspath()) {
String segment = entry.getPath().segment(0);
if ((entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) && segment.equals(SDKClasspathContainer.ID)) {
return;
}
}
if (fproj.getPrimaryRuntime() == null) {
_setMarker(project, ProjectCore.LIFERAY_PROJECT_MARKER_TYPE, IMarker.SEVERITY_ERROR, MSG_PRIMARY_RUNTIME_NOT_SET, LOCATION_TARGETED_RUNTIMES, ID_PRIMARY_RUNTIME_NOT_SET);
} else {
if (!ServerUtil.isLiferayRuntime((BridgedRuntime) fproj.getPrimaryRuntime())) {
_setMarker(project, ProjectCore.LIFERAY_PROJECT_MARKER_TYPE, IMarker.SEVERITY_ERROR, MSG_PRIMARY_RUNTIME_NOT_LIFERAY_RUNTIME, LOCATION_TARGETED_RUNTIMES, ID_PRIMARY_RUNTIME_NOT_LIFERAY_RUNTIME);
}
}
} else if (!ProjectUtil.isMavenProject(project)) {
_setMarker(project, ProjectCore.LIFERAY_PROJECT_MARKER_TYPE, IMarker.SEVERITY_ERROR, Msgs.pluginSDKNotSet, LOCATION_TARGETED_SDK, ID_PLUGINS_SDK_NOT_SET);
}
}
use of org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime in project liferay-ide by liferay.
the class PluginFacetProjectCreationDataModelProvider method init.
@Override
public void init() {
super.init();
getDataModel().setProperty(LIFERAY_USE_SDK_LOCATION, true);
DataModelPropertyDescriptor[] validDescriptors = getDataModel().getValidPropertyDescriptors(FACET_RUNTIME);
for (DataModelPropertyDescriptor desc : validDescriptors) {
Object runtime = desc.getPropertyValue();
if (runtime instanceof BridgedRuntime && ServerUtil.isLiferayRuntime((BridgedRuntime) runtime)) {
getDataModel().setProperty(FACET_RUNTIME, runtime);
break;
}
}
ProjectCore.getPortletFrameworks();
}
Aggregations