Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 250982 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/cdt/managedbuilder/ui/wizards/STDWizardHandler.java (-31 / +42 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Intel Corporation - initial API and implementation
9
 *     Intel Corporation - initial API and implementation
10
 *     IBM Corporation
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.managedbuilder.ui.wizards;
12
package org.eclipse.cdt.managedbuilder.ui.wizards;
12
13
Lines 26-31 Link Here
26
import org.eclipse.cdt.ui.newui.UIMessages;
27
import org.eclipse.cdt.ui.newui.UIMessages;
27
import org.eclipse.core.resources.IProject;
28
import org.eclipse.core.resources.IProject;
28
import org.eclipse.core.runtime.CoreException;
29
import org.eclipse.core.runtime.CoreException;
30
import org.eclipse.core.runtime.IProgressMonitor;
29
import org.eclipse.jface.wizard.IWizard;
31
import org.eclipse.jface.wizard.IWizard;
30
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.swt.widgets.Composite;
31
33
Lines 48-87 Link Here
48
	/**
50
	/**
49
	 * Note that configurations parameter is ignored
51
	 * Note that configurations parameter is ignored
50
	 */
52
	 */
51
	public void createProject(IProject project, boolean defaults, boolean onFinish)  throws CoreException {
53
	@Override
52
		ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
54
	public void createProject(IProject project, boolean defaults, boolean onFinish, IProgressMonitor monitor)  throws CoreException {
53
		ICProjectDescription des = mngr.createProjectDescription(project, false, !onFinish);
55
		try {
54
		ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
56
			monitor.beginTask("Create project", 100);
55
		ManagedProject mProj = new ManagedProject(des);
57
		
56
		info.setManagedProject(mProj);
58
			ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
57
59
			ICProjectDescription des = mngr.createProjectDescription(project, false, !onFinish);
58
		cfgs = CfgHolder.unique(fConfigPage.getCfgItems(defaults));
60
			ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
59
		cfgs = CfgHolder.reorder(cfgs);
61
			ManagedProject mProj = new ManagedProject(des);
60
			
62
			info.setManagedProject(mProj);
61
		for (int i=0; i<cfgs.length; i++) {
63
			monitor.worked(20);
62
			String s = (cfgs[i].getToolChain() == null) ? "0" : ((ToolChain)(cfgs[i].getToolChain())).getId();  //$NON-NLS-1$
64
			cfgs = CfgHolder.unique(fConfigPage.getCfgItems(defaults));
63
			Configuration cfg = new Configuration(mProj, (ToolChain)cfgs[i].getToolChain(), ManagedBuildManager.calculateChildId(s, null), cfgs[i].getName());
65
			cfgs = CfgHolder.reorder(cfgs);
64
			IBuilder bld = cfg.getEditableBuilder();
66
			int work = 50/cfgs.length;
65
			if (bld != null) {
67
			for (int i=0; i<cfgs.length; i++) {
66
				if(bld.isInternalBuilder()){
68
				String s = (cfgs[i].getToolChain() == null) ? "0" : ((ToolChain)(cfgs[i].getToolChain())).getId();  //$NON-NLS-1$
67
					IConfiguration prefCfg = ManagedBuildManager.getPreferenceConfiguration(false);
69
				Configuration cfg = new Configuration(mProj, (ToolChain)cfgs[i].getToolChain(), ManagedBuildManager.calculateChildId(s, null), cfgs[i].getName());
68
					IBuilder prefBuilder = prefCfg.getBuilder();
70
				IBuilder bld = cfg.getEditableBuilder();
69
					cfg.changeBuilder(prefBuilder, ManagedBuildManager.calculateChildId(cfg.getId(), null), prefBuilder.getName());
71
				if (bld != null) {
70
					bld = cfg.getEditableBuilder();
72
					if(bld.isInternalBuilder()){
71
					bld.setBuildPath(null);
73
						IConfiguration prefCfg = ManagedBuildManager.getPreferenceConfiguration(false);
74
						IBuilder prefBuilder = prefCfg.getBuilder();
75
						cfg.changeBuilder(prefBuilder, ManagedBuildManager.calculateChildId(cfg.getId(), null), prefBuilder.getName());
76
						bld = cfg.getEditableBuilder();
77
						bld.setBuildPath(null);
78
					}
79
					bld.setManagedBuildOn(false);
80
				} else {
81
					System.out.println(UIMessages.getString("StdProjectTypeHandler.3")); //$NON-NLS-1$
72
				}
82
				}
73
				bld.setManagedBuildOn(false);
83
				cfg.setArtifactName(removeSpaces(project.getName()));
74
			} else {
84
				CConfigurationData data = cfg.getConfigurationData();
75
				System.out.println(UIMessages.getString("StdProjectTypeHandler.3")); //$NON-NLS-1$
85
				des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
86
				monitor.worked(work);
76
			}
87
			}
77
			cfg.setArtifactName(removeSpaces(project.getName()));
88
			mngr.setProjectDescription(project, des);
78
			CConfigurationData data = cfg.getConfigurationData();
89
			
79
			des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
90
			doTemplatesPostProcess(project);
91
			doCustom(project);
92
			monitor.worked(30);
93
		} finally {
94
			monitor.done();
80
		}
95
		}
81
		mngr.setProjectDescription(project, des);
82
		
83
		doTemplatesPostProcess(project);
84
		doCustom(project);
85
	}
96
	}
86
	public boolean canCreateWithoutToolchain() { return true; } 
97
	public boolean canCreateWithoutToolchain() { return true; } 
87
	
98
	
(-)src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java (-48 / +58 lines)
Lines 55-60 Link Here
55
import org.eclipse.cdt.ui.wizards.IWizardItemsListListener;
55
import org.eclipse.cdt.ui.wizards.IWizardItemsListListener;
56
import org.eclipse.core.resources.IProject;
56
import org.eclipse.core.resources.IProject;
57
import org.eclipse.core.runtime.CoreException;
57
import org.eclipse.core.runtime.CoreException;
58
import org.eclipse.core.runtime.IProgressMonitor;
58
import org.eclipse.core.runtime.IStatus;
59
import org.eclipse.core.runtime.IStatus;
59
import org.eclipse.core.runtime.Status;
60
import org.eclipse.core.runtime.Status;
60
import org.eclipse.jface.operation.IRunnableWithProgress;
61
import org.eclipse.jface.operation.IRunnableWithProgress;
Lines 502-555 Link Here
502
	}
503
	}
503
		
504
		
504
	@Override
505
	@Override
505
	public void createProject(IProject project, boolean defaults, boolean onFinish) throws CoreException {
506
	public void createProject(IProject project, boolean defaults, boolean onFinish, IProgressMonitor monitor) throws CoreException {
506
		ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
507
		try {
507
		ICProjectDescription des = mngr.createProjectDescription(project, false, !onFinish);
508
			monitor.beginTask("Create project", 100);
508
		ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
509
			ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
509
510
			ICProjectDescription des = mngr.createProjectDescription(project, false, !onFinish);
510
		cfgs = fConfigPage.getCfgItems(false);
511
			ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
511
		if (cfgs == null || cfgs.length == 0) 
512
			monitor.worked(10);
512
			cfgs = CDTConfigWizardPage.getDefaultCfgs(this);
513
			cfgs = fConfigPage.getCfgItems(false);
513
		
514
			if (cfgs == null || cfgs.length == 0) 
514
		if (cfgs == null || cfgs.length == 0 || cfgs[0].getConfiguration() == null) {
515
				cfgs = CDTConfigWizardPage.getDefaultCfgs(this);
515
			throw new CoreException(new Status(IStatus.ERROR, 
516
			
516
					ManagedBuilderUIPlugin.getUniqueIdentifier(),
517
			if (cfgs == null || cfgs.length == 0 || cfgs[0].getConfiguration() == null) {
517
					Messages.getString("CWizardHandler.6"))); //$NON-NLS-1$
518
				throw new CoreException(new Status(IStatus.ERROR, 
518
		}
519
						ManagedBuilderUIPlugin.getUniqueIdentifier(),
519
		Configuration cf = (Configuration)cfgs[0].getConfiguration();
520
						Messages.getString("CWizardHandler.6"))); //$NON-NLS-1$
520
		ManagedProject mProj = new ManagedProject(project, cf.getProjectType());
521
			}
521
		info.setManagedProject(mProj);
522
			Configuration cf = (Configuration)cfgs[0].getConfiguration();
522
523
			ManagedProject mProj = new ManagedProject(project, cf.getProjectType());
523
		cfgs = CfgHolder.unique(cfgs);
524
			info.setManagedProject(mProj);
524
		cfgs = CfgHolder.reorder(cfgs);
525
			monitor.worked(10);
525
		
526
			cfgs = CfgHolder.unique(cfgs);
526
		ICConfigurationDescription cfgDebug = null;
527
			cfgs = CfgHolder.reorder(cfgs);
527
		ICConfigurationDescription cfgFirst = null;
528
			
528
		
529
			ICConfigurationDescription cfgDebug = null;
529
		for(int i = 0; i < cfgs.length; i++){
530
			ICConfigurationDescription cfgFirst = null;
530
			cf = (Configuration)cfgs[i].getConfiguration();
531
			
531
			String id = ManagedBuildManager.calculateChildId(cf.getId(), null);
532
			int work = 50/cfgs.length;
532
			Configuration config = new Configuration(mProj, cf, id, false, true);
533
			
533
			CConfigurationData data = config.getConfigurationData();
534
			for(int i = 0; i < cfgs.length; i++){
534
			ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
535
				cf = (Configuration)cfgs[i].getConfiguration();
535
			config.setConfigurationDescription(cfgDes);
536
				String id = ManagedBuildManager.calculateChildId(cf.getId(), null);
536
			config.exportArtifactInfo();
537
				Configuration config = new Configuration(mProj, cf, id, false, true);
537
538
				CConfigurationData data = config.getConfigurationData();
538
			IBuilder bld = config.getEditableBuilder();
539
				ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
539
			if (bld != null) { 	bld.setManagedBuildOn(true); }
540
				config.setConfigurationDescription(cfgDes);
540
			
541
				config.exportArtifactInfo();
541
			config.setName(cfgs[i].getName());
542
	
542
			config.setArtifactName(removeSpaces(project.getName()));
543
				IBuilder bld = config.getEditableBuilder();
543
			
544
				if (bld != null) { 	bld.setManagedBuildOn(true); }
544
			IBuildProperty b = config.getBuildProperties().getProperty(PROPERTY);
545
				
545
			if (cfgDebug == null && b != null && b.getValue() != null && PROP_VAL.equals(b.getValue().getId()))
546
				config.setName(cfgs[i].getName());
546
				cfgDebug = cfgDes;
547
				config.setArtifactName(removeSpaces(project.getName()));
547
			if (cfgFirst == null) // select at least first configuration 
548
				
548
				cfgFirst = cfgDes; 
549
				IBuildProperty b = config.getBuildProperties().getProperty(PROPERTY);
549
		}
550
				if (cfgDebug == null && b != null && b.getValue() != null && PROP_VAL.equals(b.getValue().getId()))
550
		mngr.setProjectDescription(project, des);
551
					cfgDebug = cfgDes;
551
		doTemplatesPostProcess(project);
552
				if (cfgFirst == null) // select at least first configuration 
552
		doCustom(project);
553
					cfgFirst = cfgDes; 
554
				monitor.worked(work);
555
			}
556
			mngr.setProjectDescription(project, des);
557
			doTemplatesPostProcess(project);
558
			doCustom(project);
559
			monitor.worked(30);
560
		} finally {
561
			monitor.done();
562
		}
553
	}
563
	}
554
	
564
	
555
	@Override
565
	@Override
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.ui; singleton:=true
4
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.ui; singleton:=true
5
Bundle-Version: 5.0.1.qualifier
5
Bundle-Version: 5.0.2.qualifier
6
Bundle-Activator: org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin
6
Bundle-Activator: org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin
7
Bundle-Vendor: %providerName
7
Bundle-Vendor: %providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
(-)src/org/eclipse/cdt/ui/wizards/CWizardHandler.java (-1 / +22 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Intel Corporation - initial API and implementation
9
 *     Intel Corporation - initial API and implementation
10
 *     IBM Corporation
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.ui.wizards;
12
package org.eclipse.cdt.ui.wizards;
12
13
Lines 14-19 Link Here
14
15
15
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.core.runtime.NullProgressMonitor;
17
import org.eclipse.jface.wizard.IWizardPage;
20
import org.eclipse.jface.wizard.IWizardPage;
18
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.graphics.Image;
22
import org.eclipse.swt.graphics.Image;
Lines 148-161 Link Here
148
	 * @param proj - simple project to be used as base
151
	 * @param proj - simple project to be used as base
149
	 * @param defaults - true if called from 1st Wizard page
152
	 * @param defaults - true if called from 1st Wizard page
150
	 * @param onFinish - true when the project creation is performed on finish. false -otherwise
153
	 * @param onFinish - true when the project creation is performed on finish. false -otherwise
151
	 * false means that the project created is actually a temporary one that can be removed in case cancell is pressed
154
	 * false means that the project created is actually a temporary one that can be removed in case cancel is pressed
152
	 * 
155
	 * 
153
	 * @throws CoreException
156
	 * @throws CoreException
154
	 */
157
	 */
155
	public void createProject(IProject proj, boolean defaults, boolean onFinish)
158
	public void createProject(IProject proj, boolean defaults, boolean onFinish)
156
			throws CoreException {
159
			throws CoreException {
160
		createProject(proj, defaults, onFinish, new NullProgressMonitor());
161
	}
162
	
163
	/**
164
	 * Creates project
165
	 * 
166
	 * @param proj - simple project to be used as base
167
	 * @param defaults - true if called from 1st Wizard page
168
	 * @param onFinish - true when the project creation is performed on finish. false -otherwise
169
	 * false means that the project created is actually a temporary one that can be removed in case cancel is pressed
170
	 * @param monitor - progress monitor to track the creation process
171
	 * 
172
	 * @throws CoreException
173
	 * @since 5.0
174
	 */
175
	public void createProject(IProject proj, boolean defaults, boolean onFinish, IProgressMonitor monitor)
176
			throws CoreException {
157
		createProject(proj, defaults);
177
		createProject(proj, defaults);
158
	}
178
	}
179
	
159
	/**
180
	/**
160
	 * 
181
	 * 
161
	 * @return true if settings were changed 
182
	 * @return true if settings were changed 
(-)src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java (-12 / +63 lines)
Lines 30-35 Link Here
30
import org.eclipse.core.runtime.IExecutableExtension;
30
import org.eclipse.core.runtime.IExecutableExtension;
31
import org.eclipse.core.runtime.IProgressMonitor;
31
import org.eclipse.core.runtime.IProgressMonitor;
32
import org.eclipse.core.runtime.NullProgressMonitor;
32
import org.eclipse.core.runtime.NullProgressMonitor;
33
import org.eclipse.core.runtime.SubProgressMonitor;
33
import org.eclipse.jface.dialogs.MessageDialog;
34
import org.eclipse.jface.dialogs.MessageDialog;
34
import org.eclipse.jface.operation.IRunnableWithProgress;
35
import org.eclipse.jface.operation.IRunnableWithProgress;
35
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
36
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
Lines 222-244 Link Here
222
		final boolean defaults = _defaults;
223
		final boolean defaults = _defaults;
223
		return new IRunnableWithProgress() {
224
		return new IRunnableWithProgress() {
224
			public void run(IProgressMonitor imonitor) throws InvocationTargetException, InterruptedException {
225
			public void run(IProgressMonitor imonitor) throws InvocationTargetException, InterruptedException {
226
				final Exception except[] = new Exception[1];
225
				getShell().getDisplay().syncExec(new Runnable() {
227
				getShell().getDisplay().syncExec(new Runnable() {
226
					public void run() { 
228
					public void run() {
229
						IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
230
							public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
231
								final IProgressMonitor fMonitor;
232
								if (monitor == null) {
233
									fMonitor= new NullProgressMonitor();
234
								} else {
235
									fMonitor = monitor;
236
								}
237
								fMonitor.beginTask(CUIPlugin.getResourceString("CProjectWizard.op_description"), 100); //$NON-NLS-1$
238
								fMonitor.worked(10);
239
								try {							
240
									newProject = createIProject(lastProjectName, lastProjectLocation, new SubProgressMonitor(fMonitor, 40));
241
//									fMonitor.worked(60);
242
									if (newProject != null) 
243
										fMainPage.h_selected.createProject(newProject, defaults, onFinish, new SubProgressMonitor(fMonitor, 40));
244
									fMonitor.worked(10);
245
								} catch (CoreException e) {	CUIPlugin.log(e); }
246
								finally {
247
									fMonitor.done();
248
								}
249
							}
250
						});
227
						try {
251
						try {
228
							newProject = createIProject(lastProjectName, lastProjectLocation);
252
							getContainer().run(false, true, op);
229
							if (newProject != null) 
253
						} catch (InvocationTargetException e) {
230
								fMainPage.h_selected.createProject(newProject, defaults, onFinish);
254
							except[0] = e;
231
						} catch (CoreException e) {	CUIPlugin.log(e); }
255
						} catch (InterruptedException e) {
256
							except[0] = e;
257
						}
232
					}
258
					}
233
				});
259
				});
260
				if (except[0] != null) {
261
					if (except[0] instanceof InvocationTargetException) {
262
						throw (InvocationTargetException)except[0];
263
					}
264
					if (except[0] instanceof InterruptedException) {
265
						throw (InterruptedException)except[0];
266
					}
267
					throw new InvocationTargetException(except[0]);
268
				}					
234
			}
269
			}
235
		};
270
		};
236
	}
271
	}
272
	
273
	public IProject createIProject(final String name, final URI location) throws CoreException{
274
		return createIProject(name, location, new NullProgressMonitor());
275
	}
237
276
238
	/**
277
	/**
278
	 * @param monitor 
279
	 * @since 5.0
239
	 * 
280
	 * 
240
	 */	
281
	 */	
241
	public IProject createIProject(final String name, final URI location) throws CoreException{
282
	public IProject createIProject(final String name, final URI location, IProgressMonitor monitor) throws CoreException{
283
		
284
		monitor.beginTask("createIProject", 100);
285
		
242
		if (newProject != null)	return newProject;
286
		if (newProject != null)	return newProject;
243
		
287
		
244
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
288
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
Lines 252-277 Link Here
252
			IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
296
			IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
253
			if(location != null)
297
			if(location != null)
254
				description.setLocationURI(location);
298
				description.setLocationURI(location);
255
			newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, new NullProgressMonitor());
299
			newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, new SubProgressMonitor(monitor,25));
256
		} else {
300
		} else {
257
			IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
301
			IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
258
				public void run(IProgressMonitor monitor) throws CoreException {
302
				public void run(IProgressMonitor monitor) throws CoreException {
259
					newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor);
303
					newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor);
260
				}
304
				}
261
			};
305
			};
262
			NullProgressMonitor monitor = new NullProgressMonitor();
306
//			NullProgressMonitor monitor = new NullProgressMonitor();
263
			workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, monitor);
307
			workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, new SubProgressMonitor(monitor,25));
264
			newProject = newProjectHandle;
308
			newProject = newProjectHandle;
265
		}
309
		}
266
        
310
        
267
		// Open the project if we have to
311
		// Open the project if we have to
268
		if (!newProject.isOpen()) {
312
		if (!newProject.isOpen()) {
269
			newProject.open(new NullProgressMonitor());
313
			newProject.open(new SubProgressMonitor(monitor,25));
270
		}
314
		}
271
		return continueCreation(newProject);	
315
		
316
		IProject proj = continueCreation(newProject);
317
		monitor.worked(25);
318
		
319
		monitor.done();
320
		
321
		return proj;	
272
	}
322
	}
273
	
323
274
	protected abstract IProject continueCreation(IProject prj); 
324
	protected abstract IProject continueCreation(IProject prj); 
325
	
275
	public abstract String[] getNatures();
326
	public abstract String[] getNatures();
276
	
327
	
277
	@Override
328
	@Override

Return to bug 250982