76 setWindowTitle("New WRT Widget"); |
76 setWindowTitle("New WRT Widget"); |
77 setNeedsProgressMonitor(true); |
77 setNeedsProgressMonitor(true); |
78 } |
78 } |
79 |
79 |
80 public boolean performFinish() { |
80 public boolean performFinish() { |
|
81 final IProject[] holder = new IProject[1]; |
81 try { |
82 try { |
82 getContainer().run(true, true, new IRunnableWithProgress() { |
83 getContainer().run(true, true, new IRunnableWithProgress() { |
83 public void run(IProgressMonitor monitor) |
84 public void run(IProgressMonitor monitor) |
84 throws InvocationTargetException, InterruptedException { |
85 throws InvocationTargetException, InterruptedException { |
85 action(monitor); |
86 holder[0] = action(monitor); |
86 } |
87 } |
87 }); |
88 }); |
88 } catch (InvocationTargetException e) { |
89 } catch (InvocationTargetException e) { |
89 Activator.log(e); |
90 Activator.log(e); |
90 } catch (InterruptedException e) { |
91 } catch (InterruptedException e) { |
91 Activator.log(e); |
92 Activator.log(e); |
92 } |
93 } |
93 BasicNewProjectResourceWizard.updatePerspective(config); |
94 BasicNewProjectResourceWizard.updatePerspective(config); |
|
95 if (holder[0] != null) { |
|
96 ProjectUtils.focusOn(holder[0]); |
|
97 } |
94 return true; |
98 return true; |
95 } |
99 } |
96 |
100 |
97 protected void action(IProgressMonitor monitor) { |
101 protected IProject action(IProgressMonitor monitor) { |
|
102 final IProject[] holder = new IProject[1]; |
98 try { |
103 try { |
99 ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { |
104 ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { |
100 public void run(IProgressMonitor monitor) throws CoreException { |
105 public void run(IProgressMonitor monitor) throws CoreException { |
101 createAndInitProject(monitor); |
106 holder[0] = createAndInitProject(monitor); |
102 } |
107 } |
103 }, monitor); |
108 }, monitor); |
104 } catch (CoreException e) { |
109 } catch (CoreException e) { |
105 Activator.log(e); |
110 Activator.log(e); |
106 } |
111 } |
107 } |
112 return holder[0]; |
108 |
113 } |
109 protected void createAndInitProject(IProgressMonitor monitor) |
114 |
|
115 protected IProject createAndInitProject(IProgressMonitor monitor) |
110 throws CoreException { |
116 throws CoreException { |
111 monitor.beginTask("Creating project", 100); |
117 monitor.beginTask("Creating project", 100); |
112 IProject project = ProjectUtils.createWrtProject(context.getProjectName(), context.getProjectUri(), new SubProgressMonitor(monitor, 30)); |
118 IProject project = ProjectUtils.createWrtProject(context.getProjectName(), context.getProjectUri(), new SubProgressMonitor(monitor, 30)); |
113 populateProject(project, new SubProgressMonitor(monitor, 30)); |
119 populateProject(project, new SubProgressMonitor(monitor, 30)); |
114 try { |
120 try { |
115 initLibraries(project, context.getTemplate().getLibraryIds(), new SubProgressMonitor(monitor, 40)); |
121 initLibraries(project, context.getTemplate().getLibraryIds(), new SubProgressMonitor(monitor, 40)); |
116 } catch (IOException e) { |
122 } catch (IOException e) { |
117 throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to setup libraries", e)); |
123 throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to setup libraries", e)); |
118 } |
124 } |
119 monitor.done(); |
125 monitor.done(); |
|
126 return project; |
120 } |
127 } |
121 |
128 |
122 private void initLibraries(IProject project, String[] libraryIds, IProgressMonitor progressMonitor) throws IOException, CoreException { |
129 private void initLibraries(IProject project, String[] libraryIds, IProgressMonitor progressMonitor) throws IOException, CoreException { |
123 if (libraryIds.length == 0) { |
130 if (libraryIds.length == 0) { |
124 progressMonitor.done(); |
131 progressMonitor.done(); |