use of com.liferay.ide.project.core.ProjectRecord in project liferay-ide by liferay.
the class ProjectImportUtil method importProject.
public static IProject importProject(IPath projectdir, IProgressMonitor monitor, NewLiferayPluginProjectOp op) throws CoreException {
IProject project = null;
ProjectRecord projectRecord = ProjectUtil.getProjectRecordForDir(projectdir.toPortableString());
File projectDir = projectRecord.getProjectLocation().toFile();
SDK sdk = SDKUtil.getSDKFromProjectDir(projectDir);
if (sdk == null) {
return null;
}
if (projectRecord.projectSystemFile != null) {
try {
project = ProjectUtil.createExistingProject(projectRecord, sdk.getLocation(), monitor);
} catch (CoreException ce) {
throw new CoreException(ProjectCore.createErrorStatus(ce));
}
} else if (projectRecord.liferayProjectDir != null) {
try {
project = ProjectUtil.createNewSDKProject(projectRecord, sdk.getLocation(), monitor, op);
} catch (CoreException ce) {
throw new CoreException(ProjectCore.createErrorStatus(ce));
}
}
File parent = projectdir.removeLastSegments(1).toFile();
String parentName = parent.getName();
IProject sdkProject = CoreUtil.getProject(sdk.getName());
IFolder folder = sdkProject.getFolder(parentName);
ResourceFilterUtil.addResourceFilter(folder, project.getName(), monitor);
return project;
}
use of com.liferay.ide.project.core.ProjectRecord in project liferay-ide by liferay.
the class ProjectImportUtil method validateSDKProjectPath.
public static IStatus validateSDKProjectPath(String currentPath) {
IStatus retVal = validatePath(currentPath);
if (!retVal.isOK()) {
return retVal;
}
ProjectRecord record = ProjectUtil.getProjectRecordForDir(currentPath);
if (record == null) {
return ProjectCore.createErrorStatus("Invalid project location");
}
String projectName = record.getProjectName();
IProject existingProject = CoreUtil.getWorkspaceRoot().getProject(projectName);
if (FileUtil.exists(existingProject)) {
return ProjectCore.createErrorStatus("Project name already exists.");
}
File projectDir = record.getProjectLocation().toFile();
SDK sdk = SDKUtil.getSDKFromProjectDir(projectDir);
if (sdk == null) {
return ProjectCore.createErrorStatus("Could not determine SDK from project location " + currentPath);
}
try {
IProject workspaceSdkProject = SDKUtil.getWorkspaceSDKProject();
if ((workspaceSdkProject != null) && !workspaceSdkProject.getLocation().equals(sdk.getLocation())) {
return ProjectCore.createErrorStatus("This project has different sdk than current workspace sdk");
}
} catch (CoreException ce) {
return ProjectCore.createErrorStatus("Can't find sdk in workspace");
}
return sdk.validate(true);
}
use of com.liferay.ide.project.core.ProjectRecord in project liferay-ide by liferay.
the class ProjectCoreBase method importProject.
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 File projectZipFile = getProjectZip(bundleId, projectName);
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 createProjectsList.
protected void createProjectsList(Composite workArea) {
Label title = new Label(workArea, SWT.NONE);
title.setText(Msgs.importProjectLabel);
title.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
// Composite listComposite = new Composite(workArea, SWT.NONE);
// GridLayout layout = new GridLayout();
// layout.numColumns = 2;
// layout.marginWidth = 0;
// layout.makeColumnsEqualWidth = false;
// listComposite.setLayout(layout);
// GridData gd = new GridData(GridData.GRAB_HORIZONTAL
// | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
// gd.grabExcessHorizontalSpace = true;
// gd.horizontalSpan = 3;
// listComposite.setLayoutData(gd);
projectsList = new CheckboxTreeViewer(workArea, SWT.BORDER);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
projectsList.getControl().setLayoutData(gridData);
projectsList.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
return null;
}
public Object[] getElements(Object inputElement) {
return (Object[]) getDataModel().getProperty(SELECTED_PROJECTS);
}
public Object getParent(Object element) {
return null;
}
public boolean hasChildren(Object element) {
return false;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
projectsList.setLabelProvider(new ProjectLabelProvider());
projectsList.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
ProjectRecord element = (ProjectRecord) event.getElement();
if (element.hasConflicts()) {
projectsList.setChecked(element, false);
}
getDataModel().setProperty(SELECTED_PROJECTS, projectsList.getCheckedElements());
setPageComplete(ListUtil.isNotEmpty(projectsList.getCheckedElements()));
}
});
projectsList.setInput(this);
projectsList.setComparator(new ViewerComparator());
}
use of com.liferay.ide.project.core.ProjectRecord in project liferay-ide by liferay.
the class SDKProjectsImportWizardPage method handleSelectAll.
protected void handleSelectAll(SelectionEvent e) {
for (int i = 0; i < selectedProjects.length; i++) {
ProjectRecord projectRecord = (ProjectRecord) selectedProjects[i];
if (projectRecord.hasConflicts()) {
projectsList.setChecked(projectRecord, false);
} else {
projectsList.setChecked(projectRecord, true);
}
}
getDataModel().setProperty(SELECTED_PROJECTS, projectsList.getCheckedElements());
validatePage(true);
// setPageComplete(projectsList.getCheckedElements().length >
// 0);
}
Aggregations