569
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
package com.nokia.cdt.internal.debug.launch.wizard;
|
|
18 |
|
|
19 |
import java.util.List;
|
|
20 |
|
|
21 |
import org.eclipse.core.resources.IProject;
|
|
22 |
import org.eclipse.core.runtime.IPath;
|
|
23 |
|
|
24 |
/**
|
|
25 |
* Created for purposes of dependency injection on the LaunchCreationWizard.
|
|
26 |
* This instance allows for other factories to be substituted at runtime, for
|
|
27 |
* purposes of injecting at runtime LaunchCreationWizard sub-classes created by
|
|
28 |
* the automated tests
|
|
29 |
*
|
|
30 |
*/
|
|
31 |
public class LaunchCreationWizardInstance {
|
|
32 |
|
|
33 |
// The delegate factory
|
|
34 |
ILaunchCreationWizardFactory factory;
|
|
35 |
|
|
36 |
static private LaunchCreationWizardInstance instance = null;
|
|
37 |
|
|
38 |
/**
|
|
39 |
* Returns the singleton
|
|
40 |
* @return
|
|
41 |
*/
|
|
42 |
public static LaunchCreationWizardInstance getInstance() {
|
|
43 |
if (instance == null) {
|
|
44 |
instance = new LaunchCreationWizardInstance();
|
|
45 |
}
|
|
46 |
return instance;
|
|
47 |
}
|
|
48 |
|
|
49 |
private LaunchCreationWizardInstance() {
|
|
50 |
setDefault();
|
|
51 |
}
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Returns the LaunchCreationWizard generated by the factory.
|
|
55 |
*/
|
|
56 |
public LaunchCreationWizard create(IProject project, String configurationName,
|
|
57 |
List<IPath> mmps, List<IPath> exes, IPath defaultExecutable,
|
|
58 |
boolean isEmulation, boolean emulatorOnly, String mode) throws Exception {
|
|
59 |
return factory.create(project, configurationName, mmps, exes, defaultExecutable, isEmulation, emulatorOnly, mode);
|
|
60 |
}
|
|
61 |
|
|
62 |
/**
|
|
63 |
* Sets the factory to the default product implementation. Used by the default initializer and to clear a dependency previously set
|
|
64 |
*/
|
|
65 |
public void setDefault() {
|
|
66 |
set(new ILaunchCreationWizardFactory() {
|
|
67 |
|
|
68 |
public LaunchCreationWizard create(IProject project, String configurationName,
|
|
69 |
List<IPath> mmps, List<IPath> exes, IPath defaultExecutable,
|
|
70 |
boolean isEmulation, boolean emulatorOnly, String mode)
|
|
71 |
throws Exception {
|
|
72 |
return new LaunchCreationWizard(project, configurationName, mmps, exes, defaultExecutable, isEmulation, emulatorOnly, mode);
|
|
73 |
|
|
74 |
}
|
|
75 |
});
|
|
76 |
}
|
|
77 |
|
|
78 |
/**
|
|
79 |
* Intended to be used by tests to inject a custom factory
|
|
80 |
*/
|
|
81 |
public void set(ILaunchCreationWizardFactory factory) {
|
|
82 |
this.factory = factory;
|
|
83 |
}
|
|
84 |
}
|