use of com.liferay.ide.project.core.ProjectRecord in project liferay-ide by liferay.
the class SDKProjectsImportWizardPage method getProjectRecords.
public Object[] getProjectRecords() {
List projectRecords = new ArrayList();
for (int i = 0; i < selectedProjects.length; i++) {
ProjectRecord projectRecord = (ProjectRecord) selectedProjects[i];
if (isProjectInWorkspace(projectRecord.getProjectName())) {
projectRecord.setHasConflicts(true);
}
projectRecords.add(selectedProjects[i]);
}
return (ProjectRecord[]) projectRecords.toArray(new ProjectRecord[projectRecords.size()]);
}
use of com.liferay.ide.project.core.ProjectRecord in project liferay-ide by liferay.
the class SDKProjectsImportWizardPage 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() {
/*
* (non-Javadoc)
*
* @see IRunnableWithProgress#run(org
* .eclipse.core.runtime.IProgressMonitor)
*/
public void run(IProgressMonitor monitor) {
monitor.beginTask(Msgs.searchingMessage, 100);
selectedProjects = new ProjectRecord[0];
Collection<File> eclipseProjectFiles = new ArrayList<>();
Collection<File> liferayProjectDirs = new ArrayList<>();
monitor.worked(10);
if (dirSelected && directory.isDirectory()) {
if (!ProjectUtil.collectSDKProjectsFromDirectory(eclipseProjectFiles, liferayProjectDirs, directory, null, true, monitor)) {
return;
}
selectedProjects = new ProjectRecord[eclipseProjectFiles.size() + liferayProjectDirs.size()];
int index = 0;
monitor.worked(50);
monitor.subTask(Msgs.processingMessage);
for (File eclipseProjectFile : eclipseProjectFiles) {
selectedProjects[index++] = new ProjectRecord(eclipseProjectFile);
}
for (File liferayProjectDir : liferayProjectDirs) {
selectedProjects[index++] = new ProjectRecord(liferayProjectDir);
}
} else {
monitor.worked(60);
}
monitor.done();
}
});
} catch (InvocationTargetException ite) {
ProjectUI.logError(ite);
} catch (InterruptedException ie) {
}
projectsList.refresh(true);
Object[] projects = getProjectRecords();
boolean displayWarning = false;
for (int i = 0; i < projects.length; i++) {
ProjectRecord projectRecord = (ProjectRecord) projects[i];
if (projectRecord.hasConflicts()) {
displayWarning = true;
projectsList.setGrayed(projects[i], true);
}
// else {
// projectsList.setChecked(projects[i], true);
// }
}
if (displayWarning) {
setMessage(Msgs.projectsInWorkspace, WARNING);
} else {
setMessage(Msgs.importProjectsDescription);
}
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);
}
}
use of com.liferay.ide.project.core.ProjectRecord in project liferay-ide by liferay.
the class SDKProjectsImportWizardPage method handleCheckStateChangedEvent.
protected void handleCheckStateChangedEvent(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()));
}
use of com.liferay.ide.project.core.ProjectRecord in project liferay-ide by liferay.
the class ImportSDKProjectsCheckboxCustomPart method _updateProjectsList.
private ProjectRecord[] _updateProjectsList(final String path) {
if ((path == null) || (path.length() == 0)) {
selectedProjects = new ProjectRecord[0];
return null;
}
final File directory = new File(path);
long modified = directory.lastModified();
lastModified = modified;
final boolean dirSelected = true;
try {
selectedProjects = new ProjectRecord[0];
Collection<File> eclipseProjectFiles = new ArrayList<>();
Collection<File> liferayProjectDirs = new ArrayList<>();
if (dirSelected && directory.isDirectory()) {
if (!ProjectUtil.collectSDKProjectsFromDirectory(eclipseProjectFiles, liferayProjectDirs, directory, null, true, new NullProgressMonitor())) {
return null;
}
selectedProjects = new ProjectRecord[eclipseProjectFiles.size() + liferayProjectDirs.size()];
int index = 0;
for (File eclipseProjectFile : eclipseProjectFiles) {
selectedProjects[index++] = new ProjectRecord(eclipseProjectFile);
}
for (File liferayProjectDir : liferayProjectDirs) {
selectedProjects[index++] = new ProjectRecord(liferayProjectDir);
}
}
} catch (Exception e) {
ProjectUI.logError(e);
}
Object[] projects = _getProjectRecords();
return (ProjectRecord[]) projects;
}
use of com.liferay.ide.project.core.ProjectRecord in project liferay-ide by liferay.
the class ProjectImportUtil method createSDKPluginProject.
/**
* @param dataModel
* @param pluginBinaryRecord
* @param liferaySDK
* @return
* @throws IOException
*/
public static ProjectRecord createSDKPluginProject(BridgedRuntime bridgedRuntime, BinaryProjectRecord pluginBinaryRecord, SDK liferaySDK) throws IOException {
ProjectRecord projectRecord = null;
if (!pluginBinaryRecord.isConflicts()) {
String displayName = pluginBinaryRecord.getDisplayName();
File binaryFile = pluginBinaryRecord.getBinaryFile();
IPath projectPath = null;
IPath sdkPluginProjectFolder = liferaySDK.getLocation();
// IDE-110 IDE-648
String webappRootFolder = null;
IProgressMonitor npm = new NullProgressMonitor();
ArrayList<String> arguments = new ArrayList<>();
arguments.add(displayName);
arguments.add(displayName);
if (pluginBinaryRecord.isHook()) {
sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.HOOK_PLUGIN_PROJECT_FOLDER);
try {
projectPath = liferaySDK.createNewProject(displayName, arguments, "hook", sdkPluginProjectFolder.toOSString(), npm);
} catch (CoreException ce) {
ProjectCore.logError(ce);
}
webappRootFolder = IPluginFacetConstants.HOOK_PLUGIN_SDK_CONFIG_FOLDER;
} else if (pluginBinaryRecord.isPortlet()) {
IPortletFramework[] portletFrameworks = ProjectCore.getPortletFrameworks();
String portletFrameworkName = null;
for (int i = 0; i < portletFrameworks.length; i++) {
IPortletFramework portletFramework = portletFrameworks[i];
if (portletFramework.isDefault() && !portletFramework.isAdvanced()) {
portletFrameworkName = portletFramework.getShortName();
break;
}
}
sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.PORTLET_PLUGIN_PROJECT_FOLDER);
arguments.add(portletFrameworkName);
try {
projectPath = liferaySDK.createNewProject(displayName, arguments, "portlet", sdkPluginProjectFolder.toOSString(), npm);
} catch (CoreException ce) {
ProjectCore.logError(ce);
}
webappRootFolder = IPluginFacetConstants.PORTLET_PLUGIN_SDK_CONFIG_FOLDER;
} else if (pluginBinaryRecord.isTheme()) {
sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.THEME_PLUGIN_PROJECT_FOLDER);
try {
projectPath = liferaySDK.createNewProject(displayName, arguments, "theme", sdkPluginProjectFolder.toOSString(), npm);
} catch (CoreException ce) {
ProjectCore.logError(ce);
}
webappRootFolder = IPluginFacetConstants.THEME_PLUGIN_SDK_CONFIG_FOLDER;
} else if (pluginBinaryRecord.isLayoutTpl()) {
sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.LAYOUTTPL_PLUGIN_PROJECT_FOLDER);
try {
projectPath = liferaySDK.createNewProject(displayName, arguments, "layouttpl", sdkPluginProjectFolder.toOSString(), npm);
} catch (CoreException ce) {
ProjectCore.logError(ce);
}
webappRootFolder = IPluginFacetConstants.LAYOUTTPL_PLUGIN_SDK_CONFIG_FOLDER;
} else if (pluginBinaryRecord.isExt()) {
sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.EXT_PLUGIN_PROJECT_FOLDER);
try {
projectPath = liferaySDK.createNewProject(displayName, arguments, "ext", sdkPluginProjectFolder.toOSString(), npm);
} catch (CoreException ce) {
ProjectCore.logError(ce);
}
webappRootFolder = IPluginFacetConstants.EXT_PLUGIN_SDK_CONFIG_FOLDER;
} else if (pluginBinaryRecord.isWeb()) {
sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.WEB_PLUGIN_PROJECT_FOLDER);
try {
projectPath = liferaySDK.createNewProject(displayName, arguments, "web", sdkPluginProjectFolder.toOSString(), npm);
} catch (CoreException ce) {
ProjectCore.logError(ce);
}
webappRootFolder = IPluginFacetConstants.WEB_PLUGIN_SDK_CONFIG_FOLDER;
}
// Extract the contents
File webappRoot = new File(projectPath.toFile(), webappRootFolder);
ZipUtil.unzip(binaryFile, webappRoot);
// IDE-569 check to see if the project already has .project
File projectFile = new File(projectPath.toFile(), ".project");
if (FileUtil.exists(projectFile)) {
projectRecord = new ProjectRecord(projectFile);
} else {
projectRecord = new ProjectRecord(projectPath.toFile());
}
}
return projectRecord;
}
Aggregations