diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:23:09 +0200 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:24:09 +0200 |
commit | c7da892cb23d50d4d85746c9a0b6b14bf570989d (patch) | |
tree | e7136073f386d6156f51766c498c52c30c8df85f /plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java | |
download | eclipse-poky-kepler-c7da892cb23d50d4d85746c9a0b6b14bf570989d.tar.gz |
initial commit for Enea Linux 4.0daisy
Migrated from the internal git server on the daisy-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java')
-rw-r--r-- | plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java new file mode 100644 index 0000000..54f16c3 --- /dev/null +++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java | |||
@@ -0,0 +1,93 @@ | |||
1 | /***************************************************************************** | ||
2 | * Copyright (c) 2013 Ken Gilmer, Intel Corporation | ||
3 | * All rights reserved. This program and the accompanying materials | ||
4 | * are made available under the terms of the Eclipse Public License v1.0 | ||
5 | * which accompanies this distribution, and is available at | ||
6 | * http://www.eclipse.org/legal/epl-v10.html | ||
7 | * | ||
8 | * Contributors: | ||
9 | * Ken Gilmer - initial API and implementation | ||
10 | * Ioana Grigoropol (Intel) - adapt class for remote support | ||
11 | *******************************************************************************/ | ||
12 | package org.yocto.bc.ui.wizards.newproject; | ||
13 | |||
14 | import java.io.IOException; | ||
15 | import java.lang.reflect.InvocationTargetException; | ||
16 | import java.net.URI; | ||
17 | import java.net.URISyntaxException; | ||
18 | import java.util.Arrays; | ||
19 | import java.util.Vector; | ||
20 | |||
21 | import org.eclipse.core.resources.IProject; | ||
22 | import org.eclipse.core.resources.IProjectDescription; | ||
23 | import org.eclipse.core.resources.IWorkspace; | ||
24 | import org.eclipse.core.resources.IWorkspaceRoot; | ||
25 | import org.eclipse.core.resources.ResourcesPlugin; | ||
26 | import org.eclipse.core.runtime.CoreException; | ||
27 | import org.eclipse.core.runtime.IProgressMonitor; | ||
28 | import org.eclipse.core.runtime.IStatus; | ||
29 | import org.eclipse.core.runtime.QualifiedName; | ||
30 | import org.eclipse.core.runtime.Status; | ||
31 | import org.eclipse.ui.actions.WorkspaceModifyOperation; | ||
32 | |||
33 | import org.yocto.bc.bitbake.ProjectInfoHelper; | ||
34 | import org.yocto.bc.ui.Activator; | ||
35 | import org.yocto.bc.ui.builder.BitbakeCommanderNature; | ||
36 | import org.yocto.bc.ui.model.ProjectInfo; | ||
37 | |||
38 | |||
39 | /** | ||
40 | * Creates a bbc project | ||
41 | * @author kgilmer | ||
42 | * | ||
43 | */ | ||
44 | public class CreateBBCProjectOperation extends WorkspaceModifyOperation { | ||
45 | |||
46 | public static final String OEFS_SCHEME = "OEFS://"; | ||
47 | public static final QualifiedName BBC_PROJECT_INIT = new QualifiedName(null, "BBC_PROJECT_INIT"); | ||
48 | public static void addNatureToProject(IProject proj, String nature_id, IProgressMonitor monitor) throws CoreException { | ||
49 | IProjectDescription desc = proj.getDescription(); | ||
50 | Vector natureIds = new Vector(); | ||
51 | |||
52 | natureIds.add(nature_id); | ||
53 | natureIds.addAll(Arrays.asList(desc.getNatureIds())); | ||
54 | desc.setNatureIds((String[]) natureIds.toArray(new String[natureIds.size()])); | ||
55 | |||
56 | proj.setDescription(desc, monitor); | ||
57 | } | ||
58 | |||
59 | private ProjectInfo projInfo; | ||
60 | |||
61 | public CreateBBCProjectOperation(ProjectInfo projInfo) { | ||
62 | this.projInfo = projInfo; | ||
63 | } | ||
64 | |||
65 | protected void addNatures(IProject proj, IProgressMonitor monitor) throws CoreException { | ||
66 | addNatureToProject(proj, BitbakeCommanderNature.NATURE_ID, monitor); | ||
67 | } | ||
68 | |||
69 | private IProjectDescription createProjectDescription(IWorkspace workspace, ProjectInfo projInfo) throws CoreException { | ||
70 | IProjectDescription desc = workspace.newProjectDescription(projInfo.getProjectName()); | ||
71 | |||
72 | desc.setLocationURI(projInfo.getOEFSURI()); | ||
73 | return desc; | ||
74 | } | ||
75 | |||
76 | @Override | ||
77 | protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { | ||
78 | IProjectDescription desc = createProjectDescription(ResourcesPlugin.getWorkspace(), projInfo); | ||
79 | |||
80 | IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot(); | ||
81 | |||
82 | IProject proj = wsroot.getProject(projInfo.getProjectName()); | ||
83 | proj.create(desc, monitor); | ||
84 | |||
85 | proj.open(monitor); | ||
86 | |||
87 | addNatures(proj, monitor); | ||
88 | } | ||
89 | |||
90 | public ProjectInfo getProjectInfo() { | ||
91 | return projInfo; | ||
92 | } | ||
93 | } | ||