diff options
author | Ken Gilmer <kgilmer@gmail.com> | 2010-05-18 21:53:22 -0400 |
---|---|---|
committer | Ken Gilmer <kgilmer@gmail.com> | 2010-05-18 21:53:22 -0400 |
commit | a7e84830627e50adac5c81ae4dad69aa350933fb (patch) | |
tree | 219aa86f4d5f03b29d7bc56f8cdba2702d67082c /org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/newproject | |
parent | e27a6dcce13930bfa711a6e72992597a8d1d07c5 (diff) | |
download | eclipsetools-a7e84830627e50adac5c81ae4dad69aa350933fb.tar.gz |
org.openembedded.bc.ui: initial commit
Diffstat (limited to 'org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/newproject')
2 files changed, 166 insertions, 0 deletions
diff --git a/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java new file mode 100644 index 0000000..ae3f90c --- /dev/null +++ b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java @@ -0,0 +1,59 @@ +/***************************************************************************** + * Copyright (c) 2009 Ken Gilmer + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ken Gilmer - initial API and implementation + *******************************************************************************/ +package org.openembedded.bc.ui.wizards.newproject; + +import java.io.Writer; +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.openembedded.bc.bitbake.BBSession; +import org.openembedded.bc.bitbake.ProjectInfoHelper; +import org.openembedded.bc.ui.Activator; +import org.openembedded.bc.ui.model.ProjectInfo; + + +public class BBConfigurationInitializeOperation implements IRunnableWithProgress { + + private final ProjectInfo pinfo; + private final Writer writer; + + public BBConfigurationInitializeOperation(ProjectInfo pinfo) { + this.pinfo = pinfo; + writer = null; + } + + public BBConfigurationInitializeOperation(ProjectInfo pinfo, Writer writer) { + this.pinfo = pinfo; + this.writer = writer; + } + + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + BBSession session; + try { + ProjectInfoHelper.store(pinfo.getRootPath(), pinfo); + session = Activator.getBBSession(pinfo.getRootPath(), writer); + + if (!session.isInitialized()) { + session.initialize(); + } + + if (session.isEmpty()) { + Activator.clearBBSession(pinfo.getRootPath()); + throw new RuntimeException("Bitbake failed silently. No configuration is availalbe."); + } + + } catch (Exception e) { + Activator.clearBBSession(pinfo.getRootPath()); + throw new InvocationTargetException(e); + } + } +} diff --git a/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/newproject/CreateBBCProjectOperation.java b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/newproject/CreateBBCProjectOperation.java new file mode 100644 index 0000000..9e67e5b --- /dev/null +++ b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/newproject/CreateBBCProjectOperation.java @@ -0,0 +1,107 @@ +/***************************************************************************** + * Copyright (c) 2009 Ken Gilmer + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ken Gilmer - initial API and implementation + *******************************************************************************/ +package org.openembedded.bc.ui.wizards.newproject; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.Vector; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.core.runtime.Status; +import org.eclipse.ui.actions.WorkspaceModifyOperation; +import org.openembedded.bc.bitbake.ProjectInfoHelper; +import org.openembedded.bc.ui.Activator; +import org.openembedded.bc.ui.builder.BitbakeCommanderNature; +import org.openembedded.bc.ui.model.ProjectInfo; + + + +/** + * Creates a bbc project + * @author kgilmer + * + */ +public class CreateBBCProjectOperation extends WorkspaceModifyOperation { + + public static final String OEFS_SCHEME = "OEFS://"; + public static final QualifiedName BBC_PROJECT_INIT = new QualifiedName(null, "BBC_PROJECT_INIT"); + public static void addNatureToProject(IProject proj, String nature_id, IProgressMonitor monitor) throws CoreException { + IProjectDescription desc = proj.getDescription(); + Vector natureIds = new Vector(); + + natureIds.add(nature_id); + natureIds.addAll(Arrays.asList(desc.getNatureIds())); + desc.setNatureIds((String[]) natureIds.toArray(new String[natureIds.size()])); + + proj.setDescription(desc, monitor); + } + + private ProjectInfo projInfo; + + public CreateBBCProjectOperation(ProjectInfo projInfo) { + this.projInfo = projInfo; + } + + protected void addNatures(IProject proj, IProgressMonitor monitor) throws CoreException { + addNatureToProject(proj, BitbakeCommanderNature.NATURE_ID, monitor); + } + + private IProjectDescription createProjectDescription(IWorkspace workspace, ProjectInfo projInfo2) throws CoreException { + IProjectDescription desc = workspace.newProjectDescription(projInfo2.getProjectName()); + + try { + System.out.println("Calling creageProjeDesc"); + desc.setLocationURI(new URI(OEFS_SCHEME + projInfo2.getRootPath())); + } catch (URISyntaxException e) { + throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to load filesystem.", e)); + } + + return desc; + } + + @Override + protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { + System.out.println("Init: " + projInfo.getInitScriptPath()); + System.out.println("Proj: " + projInfo.getProjectName()); + System.out.println("Root: " + projInfo.getRootPath()); + + IProjectDescription desc = createProjectDescription(ResourcesPlugin.getWorkspace(), projInfo); + + IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot(); + + IProject proj = wsroot.getProject(projInfo.getProjectName()); + proj.create(desc, monitor); + try { + ProjectInfoHelper.store(proj.getLocationURI().getPath(), projInfo); + } catch (IOException e) { + throw new InvocationTargetException(e); + } + + proj.open(monitor); + + addNatures(proj, monitor); + } + + public ProjectInfo getProjectInfo() { + return projInfo; + } +} |