use of com.liferay.ide.project.core.ProjectRecord in project liferay-ide by liferay.
the class LiferayLanguageFileEncodingTests method importProject.
private IProject importProject(String path, String name) throws Exception {
final IPath sdkLocation = SDKManager.getInstance().getDefaultSDK().getLocation();
final IPath hooksFolder = sdkLocation.append(path);
final URL hookZipUrl = Platform.getBundle("com.liferay.ide.project.core.tests").getEntry("projects/" + name + ".zip");
final File hookZipFile = new File(FileLocator.toFileURL(hookZipUrl).getFile());
ZipUtil.unzip(hookZipFile, hooksFolder.toFile());
final IPath projectFolder = hooksFolder.append(name);
assertEquals(true, projectFolder.toFile().exists());
final ProjectRecord projectRecord = ProjectUtil.getProjectRecordForDir(projectFolder.toOSString());
assertNotNull(projectRecord);
final IProject project = ProjectImportUtil.importProject(projectRecord, ServerUtil.getFacetRuntime(getRuntime()), sdkLocation.toOSString(), new NullProgressMonitor());
assertNotNull(project);
assertEquals("Expected new project to exist.", true, project.exists());
return project;
}
use of com.liferay.ide.project.core.ProjectRecord in project liferay-ide by liferay.
the class ProjectImportUtil method createWorkspaceProjects.
/**
* This will create the Eclipse Workspace projects
*
* @param monitor
* @throws CoreException
*/
public static void createWorkspaceProjects(Object[] projects, IRuntime runtime, String sdkLocation, IProgressMonitor monitor) throws CoreException {
List<IProject> createdProjects = new ArrayList<>();
monitor.beginTask(Msgs.creatingSDKWorkspaceProjects, projects.length);
if (ListUtil.isNotEmpty(projects)) {
SDK sdk = SDKManager.getInstance().getSDK(new Path(sdkLocation));
if (sdk == null) {
sdk = SDKUtil.createSDKFromLocation(new Path(sdkLocation));
}
if ((sdk != null) && sdk.isValid() && !(SDKManager.getInstance().containsSDK(sdk))) {
SDKManager.getInstance().addSDK(sdk);
}
}
for (int i = 0; i < projects.length; i++) {
if (projects[i] instanceof ProjectRecord) {
IProject project = importProject((ProjectRecord) projects[i], runtime, sdkLocation, monitor);
if (project != null) {
createdProjects.add(project);
monitor.worked(createdProjects.size());
}
}
}
}
use of com.liferay.ide.project.core.ProjectRecord in project liferay-ide by liferay.
the class ProjectUtil method getProjectRecordForDir.
public static ProjectRecord getProjectRecordForDir(String dir) {
ProjectRecord projectRecord = null;
File projectDir = new File(dir);
if (isLiferaySDKProjectDir(projectDir)) {
// determine if this is a previous eclipse project or vanilla
String[] files = projectDir.list();
for (String file : files) {
if (IProjectDescription.DESCRIPTION_FILE_NAME.equals(file)) {
projectRecord = new ProjectRecord(new File(projectDir, file));
}
}
if (projectRecord == null) {
projectRecord = new ProjectRecord(projectDir);
}
}
return projectRecord;
}
use of com.liferay.ide.project.core.ProjectRecord in project liferay-ide by liferay.
the class XmlTestsBase method importProject.
@Override
protected IProject importProject(String path, String bundleId, String projectName) throws Exception {
final IPath sdkLocation = SDKManager.getInstance().getDefaultSDK().getLocation();
final IPath projectFolder = sdkLocation.append(path);
final URL projectZipUrl = Platform.getBundle(bundleId).getEntry("projects/" + projectName + ".zip");
final File projectZipFile = new File(FileLocator.toFileURL(projectZipUrl).getFile());
ZipUtil.unzip(projectZipFile, projectFolder.toFile());
final IPath projectPath = projectFolder.append(projectName);
assertEquals(true, projectPath.toFile().exists());
final ProjectRecord projectRecord = ProjectUtil.getProjectRecordForDir(projectPath.toOSString());
assertNotNull(projectRecord);
final IRuntime runtime = ServerCore.findRuntime(getRuntimeVersion());
assertNotNull(runtime);
final IProject project = ProjectImportUtil.importProject(projectRecord, ServerUtil.getFacetRuntime(runtime), sdkLocation.toOSString(), new NullProgressMonitor());
assertNotNull(project);
assertEquals("Expected new project to exist.", true, project.exists());
return project;
}
use of com.liferay.ide.project.core.ProjectRecord in project liferay-ide by liferay.
the class SDKProjectConvertWizardPage method updateProjectsList.
public void updateProjectsList(final String path) {
if ((path == null) || (path.length() == 0)) {
setMessage(Msgs.importProjectsDescription);
selectedProjects = new ProjectRecord[0];
projectsList.refresh(true);
projectsList.setCheckedElements(selectedProjects);
setPageComplete(ListUtil.isNotEmpty(projectsList.getCheckedElements()));
lastPath = path;
return;
}
final File directory = new File(path);
long modified = directory.lastModified();
if (path.equals(lastPath) && (lastModified == modified)) {
return;
}
lastPath = path;
lastModified = modified;
final boolean dirSelected = true;
try {
getContainer().run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
monitor.beginTask(Msgs.searchingMessage, 100);
monitor.worked(10);
if (dirSelected && directory.isDirectory()) {
ProjectRecord[] projectToConvert = (ProjectRecord[]) getDataModel().getProperty(SELECTED_PROJECTS);
IPath dir = new Path(directory.getPath());
if (dir.isPrefixOf(projectToConvert[0].getProjectLocation())) {
selectedProjects = projectToConvert;
} else {
selectedProjects = new ProjectRecord[0];
}
} else {
monitor.worked(60);
}
monitor.done();
}
});
} catch (InvocationTargetException ite) {
IDEWorkbenchPlugin.log(ite.getMessage(), ite);
} catch (InterruptedException ie) {
}
projectsList.refresh(true);
if (ListUtil.isNotEmpty(selectedProjects)) {
projectsList.setChecked(selectedProjects[0], true);
}
setPageComplete(ListUtil.isNotEmpty(projectsList.getCheckedElements()));
if (selectedProjects.length == 0) {
setMessage(Msgs.noProjectsToImport, WARNING);
}
Object[] checkedProjects = projectsList.getCheckedElements();
if (ListUtil.isNotEmpty(checkedProjects)) {
selectedProjects = new ProjectRecord[checkedProjects.length];
for (int i = 0; i < checkedProjects.length; i++) {
selectedProjects[i] = (ProjectRecord) checkedProjects[i];
}
getDataModel().setProperty(SELECTED_PROJECTS, selectedProjects);
}
}
Aggregations