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 factory allows for other factories to be substituted at runtime, for |
|
27 * purposes of injecting at runtime LaunchCreationWizard sub-classes created by |
|
28 * the ATF |
|
29 * |
|
30 */ |
|
31 public class LaunchCreationWizardFactory { |
|
32 |
|
33 // This is an abstract factory which maintains here the actual factory |
|
34 ILaunchCreationWizardFactory factory; |
|
35 |
|
36 private LaunchCreationWizardFactory() { |
|
37 setDefault(); |
|
38 } |
|
39 |
|
40 /** |
|
41 * Returns the LaunchCreationWizard generated by the factory. |
|
42 */ |
|
43 public LaunchCreationWizard get(IProject project, String configurationName, |
|
44 List<IPath> mmps, List<IPath> exes, IPath defaultExecutable, |
|
45 boolean isEmulation, boolean emulatorOnly, String mode) throws Exception { |
|
46 return factory.get(project, configurationName, mmps, exes, defaultExecutable, isEmulation, emulatorOnly, mode); |
|
47 } |
|
48 |
|
49 /** |
|
50 * Sets the factory to the default product implementation. Used by the default initializer and to clear a dependency previously set |
|
51 */ |
|
52 public void setDefault() { |
|
53 set(new ILaunchCreationWizardFactory() { |
|
54 |
|
55 public LaunchCreationWizard get(IProject project, String configurationName, |
|
56 List<IPath> mmps, List<IPath> exes, IPath defaultExecutable, |
|
57 boolean isEmulation, boolean emulatorOnly, String mode) |
|
58 throws Exception { |
|
59 return new LaunchCreationWizard(project, configurationName, mmps, exes, defaultExecutable, isEmulation, emulatorOnly, mode); |
|
60 |
|
61 } |
|
62 }); |
|
63 } |
|
64 |
|
65 /** |
|
66 * Intended to be used by tests to inject a custom factory |
|
67 */ |
|
68 public void set(ILaunchCreationWizardFactory factory) { |
|
69 this.factory = factory; |
|
70 } |
|
71 |
|
72 static private LaunchCreationWizardFactory abstractFactory = null; |
|
73 |
|
74 /** |
|
75 * Returns the singleton |
|
76 * @return |
|
77 */ |
|
78 public static LaunchCreationWizardFactory getInstance() { |
|
79 if (abstractFactory == null) { |
|
80 abstractFactory = new LaunchCreationWizardFactory(); |
|
81 } |
|
82 return abstractFactory; |
|
83 } |
|
84 } |
|