Commit | Line | Data |
---|---|---|
dbd4432d | 1 | /********************************************************************** |
ed902a2b | 2 | * Copyright (c) 2012, 2014 Ericsson |
77735e82 | 3 | * |
dbd4432d BH |
4 | * All rights reserved. This program and the accompanying materials are |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
77735e82 BH |
8 | * |
9 | * Contributors: | |
dbd4432d BH |
10 | * Bernd Hufmann - Initial API and implementation |
11 | **********************************************************************/ | |
9bc60be7 | 12 | package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs; |
d132bcc7 BH |
13 | |
14 | import org.eclipse.ui.PlatformUI; | |
15 | ||
dbd4432d BH |
16 | /** |
17 | * <p> | |
18 | * Factory for generating dialog boxes. It allows to overwrite the dialog implementation. | |
77735e82 | 19 | * Useful also for testing purposes. |
dbd4432d | 20 | * </p> |
77735e82 | 21 | * |
dbd4432d BH |
22 | * @author Bernd Hufmann |
23 | * | |
24 | */ | |
77735e82 | 25 | public final class TraceControlDialogFactory { |
d132bcc7 BH |
26 | |
27 | // ------------------------------------------------------------------------ | |
28 | // Members | |
29 | // ------------------------------------------------------------------------ | |
30 | ||
31 | /** | |
32 | * The factory instance. | |
33 | */ | |
34 | private static TraceControlDialogFactory fInstance; | |
35 | ||
36 | /** | |
37 | * The new connection dialog reference. | |
38 | */ | |
39 | private INewConnectionDialog fNewConnectionDialog; | |
77735e82 | 40 | |
d132bcc7 | 41 | /** |
d62bfa55 | 42 | * The enable channel dialog |
d132bcc7 | 43 | */ |
d62bfa55 | 44 | private IEnableChannelDialog fEnableChannelDialog; |
77735e82 | 45 | |
d132bcc7 BH |
46 | /** |
47 | * The create session dialog. | |
48 | */ | |
49 | private ICreateSessionDialog fCreateSessionDialog; | |
77735e82 | 50 | |
64a37b87 BH |
51 | /** |
52 | * The command script selection dialog. | |
53 | */ | |
54 | private ISelectCommandScriptDialog fCommandScriptDialog; | |
55 | ||
d132bcc7 BH |
56 | /** |
57 | * The enable events dialog. | |
58 | */ | |
59 | private IEnableEventsDialog fEnableEventsDialog; | |
77735e82 | 60 | |
d132bcc7 BH |
61 | /** |
62 | * The get event info dialog. | |
63 | */ | |
64 | private IGetEventInfoDialog fGetEventInfoDialog; | |
77735e82 | 65 | |
d132bcc7 | 66 | /** |
291cbdbf | 67 | * The confirmation dialog implementation. |
d132bcc7 BH |
68 | */ |
69 | private IConfirmDialog fConfirmDialog; | |
77735e82 | 70 | |
b793fbe1 | 71 | /** |
291cbdbf | 72 | * The add context dialog implementation. |
b793fbe1 BH |
73 | */ |
74 | private IAddContextDialog fAddContextDialog; | |
77735e82 | 75 | |
d132bcc7 BH |
76 | // ------------------------------------------------------------------------ |
77 | // Constructors | |
78 | // ------------------------------------------------------------------------ | |
79 | ||
80 | /** | |
81 | * Constructor for R4EUIDialogFactory. | |
82 | */ | |
83 | private TraceControlDialogFactory() { | |
84 | } | |
85 | ||
86 | // ------------------------------------------------------------------------ | |
87 | // Operations | |
88 | // ------------------------------------------------------------------------ | |
89 | ||
90 | /** | |
91 | * @return TraceControlDialogFactory instance | |
92 | */ | |
046b6849 | 93 | public static synchronized TraceControlDialogFactory getInstance() { |
c56972bb | 94 | if (fInstance == null) { |
d132bcc7 BH |
95 | fInstance = new TraceControlDialogFactory(); |
96 | } | |
97 | return fInstance; | |
98 | } | |
99 | ||
100 | /** | |
101 | * @return new connection dialog | |
102 | */ | |
103 | public INewConnectionDialog getNewConnectionDialog() { | |
c56972bb | 104 | if (fNewConnectionDialog == null) { |
d132bcc7 BH |
105 | fNewConnectionDialog = new NewConnectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); |
106 | } | |
107 | return fNewConnectionDialog; | |
108 | } | |
109 | ||
110 | /** | |
111 | * Sets a new connection dialog implementation. | |
112 | * @param newConnectionDialog - new connection dialog implementation | |
113 | */ | |
114 | public void setNewConnectionDialog(INewConnectionDialog newConnectionDialog) { | |
115 | fNewConnectionDialog = newConnectionDialog; | |
116 | } | |
77735e82 | 117 | |
d132bcc7 | 118 | /** |
d62bfa55 | 119 | * @return enable channel dialog |
d132bcc7 | 120 | */ |
d62bfa55 BH |
121 | public IEnableChannelDialog getEnableChannelDialog() { |
122 | if (fEnableChannelDialog == null) { | |
123 | fEnableChannelDialog = new EnableChannelDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); | |
d132bcc7 | 124 | } |
d62bfa55 | 125 | return fEnableChannelDialog; |
d132bcc7 BH |
126 | } |
127 | ||
128 | /** | |
d62bfa55 BH |
129 | * Sets a enable channel dialog implementation. |
130 | * @param createEnableDialog - a create channel dialog implementation | |
d132bcc7 | 131 | */ |
d62bfa55 BH |
132 | public void setEnableChannelDialog(IEnableChannelDialog createEnableDialog) { |
133 | fEnableChannelDialog = createEnableDialog; | |
d132bcc7 | 134 | } |
77735e82 | 135 | |
d132bcc7 BH |
136 | /** |
137 | * @return create session dialog implementation | |
138 | */ | |
139 | public ICreateSessionDialog getCreateSessionDialog() { | |
c56972bb | 140 | if (fCreateSessionDialog == null) { |
d132bcc7 BH |
141 | fCreateSessionDialog = new CreateSessionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); |
142 | } | |
143 | return fCreateSessionDialog; | |
144 | } | |
145 | ||
64a37b87 BH |
146 | /** |
147 | * @return command script selection dialog implementation | |
148 | */ | |
149 | public ISelectCommandScriptDialog getCommandScriptDialog() { | |
150 | if (fCommandScriptDialog == null) { | |
151 | fCommandScriptDialog = new OpenCommandScriptDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); | |
152 | } | |
153 | return fCommandScriptDialog; | |
154 | } | |
155 | ||
d132bcc7 BH |
156 | /** |
157 | * Sets a create session dialog implementation. | |
158 | * @param createSessionDialog - a create session implementation. | |
159 | */ | |
160 | public void setCreateSessionDialog(ICreateSessionDialog createSessionDialog) { | |
161 | fCreateSessionDialog = createSessionDialog; | |
162 | } | |
163 | ||
164 | /** | |
165 | * @return enable events dialog implementation. | |
166 | */ | |
167 | public IEnableEventsDialog getEnableEventsDialog() { | |
c56972bb | 168 | if (fEnableEventsDialog == null) { |
d132bcc7 BH |
169 | fEnableEventsDialog = new EnableEventsDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); |
170 | } | |
171 | return fEnableEventsDialog; | |
172 | } | |
173 | ||
174 | /** | |
175 | * Sets a enable events dialog implementation. | |
176 | * @param enableEventsDialog - a enable events dialog implementation. | |
177 | */ | |
178 | public void setEnableEventsDialog(IEnableEventsDialog enableEventsDialog) { | |
179 | fEnableEventsDialog = enableEventsDialog; | |
180 | } | |
181 | ||
182 | /** | |
183 | * @return get events info dialog implementation. | |
184 | */ | |
185 | public IGetEventInfoDialog getGetEventInfoDialog() { | |
c56972bb | 186 | if (fGetEventInfoDialog == null) { |
d132bcc7 BH |
187 | fGetEventInfoDialog = new GetEventInfoDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); |
188 | } | |
189 | return fGetEventInfoDialog; | |
190 | } | |
191 | ||
192 | /** | |
193 | * Sets a get events info dialog implementation. | |
194 | * @param getEventInfoDialog - a get events info dialog implementation | |
195 | */ | |
196 | public void setGetEventInfoDialog(IGetEventInfoDialog getEventInfoDialog) { | |
197 | fGetEventInfoDialog = getEventInfoDialog; | |
198 | } | |
77735e82 | 199 | |
d132bcc7 BH |
200 | /** |
201 | * @return the confirmation dialog implementation | |
202 | */ | |
203 | public IConfirmDialog getConfirmDialog() { | |
c56972bb | 204 | if (fConfirmDialog == null) { |
d132bcc7 BH |
205 | fConfirmDialog = new ConfirmDialog(); |
206 | } | |
207 | return fConfirmDialog; | |
208 | } | |
77735e82 | 209 | |
d132bcc7 BH |
210 | /** |
211 | * Sets the confirmation dialog implementation | |
291cbdbf | 212 | * @param confirmDialog - a confirmation dialog implementation |
d132bcc7 BH |
213 | */ |
214 | public void setConfirmDialog(IConfirmDialog confirmDialog) { | |
215 | fConfirmDialog = confirmDialog; | |
216 | } | |
77735e82 | 217 | |
b793fbe1 BH |
218 | /** |
219 | * @return the add context dialog implementation | |
220 | */ | |
221 | public IAddContextDialog getAddContextDialog() { | |
222 | if (fAddContextDialog == null) { | |
223 | fAddContextDialog = new AddContextDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); | |
224 | } | |
225 | return fAddContextDialog; | |
226 | } | |
77735e82 | 227 | |
b793fbe1 BH |
228 | /** |
229 | * Sets the add context dialog information | |
291cbdbf | 230 | * @param addContextDialog - a add context dialog implementation |
b793fbe1 BH |
231 | */ |
232 | public void setAddContextDialog(IAddContextDialog addContextDialog) { | |
233 | fAddContextDialog = addContextDialog; | |
234 | } | |
77735e82 | 235 | |
d132bcc7 BH |
236 | } |
237 |