use of org.eclipse.wst.common.project.facet.core.runtime.IRuntime 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.IRuntime in project liferay-ide by liferay.
the class SDKProjectConvertOperation method convertExistingProject.
protected IProject convertExistingProject(ProjectRecord record, IProgressMonitor monitor) throws CoreException {
String projectName = record.getProjectName();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject project = workspace.getRoot().getProject(projectName);
if (record.description == null) {
// error case
record.description = workspace.newProjectDescription(projectName);
IPath locationPath = new Path(record.projectSystemFile.getAbsolutePath());
if (Platform.getLocation().isPrefixOf(locationPath)) {
record.description.setLocation(null);
} else {
record.description.setLocation(locationPath);
}
} else {
record.description.setName(projectName);
}
monitor.beginTask(Msgs.importingProject, 100);
project.open(IResource.FORCE, CoreUtil.newSubMonitor(monitor, 70));
IFacetedProject fProject = ProjectFacetsManager.create(project, true, monitor);
FacetedProjectWorkingCopy fpwc = new FacetedProjectWorkingCopy(fProject);
String sdkLocation = getDataModel().getStringProperty(SDK_LOCATION);
IRuntime runtime = (IRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
String pluginType = ProjectUtil.guessPluginType(fpwc);
SDKPluginFacetUtil.configureProjectAsRuntimeProject(fpwc, runtime, pluginType, sdkLocation, record);
fpwc.commitChanges(monitor);
monitor.done();
return project;
}
use of org.eclipse.wst.common.project.facet.core.runtime.IRuntime in project liferay-ide by liferay.
the class SDKProjectsImportOperation 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);
WorkspaceJob workspaceJob = new WorkspaceJob(Msgs.creatingSDKProjects) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
try {
ProjectImportUtil.createWorkspaceProjects(projects, runtime, sdkLocation, monitor);
} catch (Exception ex) {
return ProjectCore.createErrorStatus(ex);
}
return Status.OK_STATUS;
}
};
workspaceJob.setUser(true);
workspaceJob.schedule();
return Status.OK_STATUS;
}
use of org.eclipse.wst.common.project.facet.core.runtime.IRuntime in project webtools.sourceediting by eclipse.
the class ProductManager method getDefaultRuntimes.
@SuppressWarnings("unchecked")
public static List<IRuntime> getDefaultRuntimes() {
List<IRuntime> theRuntimes = null;
Set<IRuntime> runtimes = RuntimeManager.getRuntimes();
if (!runtimes.isEmpty()) {
IRuntime defaultRuntime = null;
// First check if defaults are defined
for (int i = 0; i < DEFAULT_RUNTIME_KEYS.length; i++) {
defaultRuntime = getMatchingRuntime(DEFAULT_RUNTIME_KEYS[i], runtimes);
if (defaultRuntime != null) {
if (theRuntimes == null) {
theRuntimes = new ArrayList<>(DEFAULT_RUNTIME_KEYS.length);
}
theRuntimes.add(defaultRuntime);
}
}
}
if (theRuntimes == null) {
theRuntimes = Collections.EMPTY_LIST;
}
return theRuntimes;
}
use of org.eclipse.wst.common.project.facet.core.runtime.IRuntime in project webtools.sourceediting by eclipse.
the class NewProjectDataModelFacetWizard method synchRuntimes.
protected void synchRuntimes() {
final Boolean[] suppressBackEvents = { Boolean.FALSE };
model.addListener(new IDataModelListener() {
@Override
public void propertyChanged(DataModelEvent event) {
if (IDataModel.VALUE_CHG == event.getFlag() || IDataModel.DEFAULT_CHG == event.getFlag()) {
if (FACET_RUNTIME.equals(event.getPropertyName())) {
if (!suppressBackEvents[0].booleanValue()) {
IRuntime runtime = (IRuntime) event.getProperty();
setRuntimeAndDefaultFacets(runtime);
}
}
}
}
});
getFacetedProjectWorkingCopy().addListener(new IFacetedProjectListener() {
@Override
public void handleEvent(final IFacetedProjectEvent event) {
suppressBackEvents[0] = Boolean.TRUE;
model.setProperty(FACET_RUNTIME, getFacetedProjectWorkingCopy().getPrimaryRuntime());
suppressBackEvents[0] = Boolean.FALSE;
}
}, IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED);
}
Aggregations