Commit | Line | Data |
---|---|---|
dbd4432d | 1 | /********************************************************************** |
60ae41e1 | 2 | * Copyright (c) 2012, 2013 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 | **********************************************************************/ | |
8e8c0226 | 12 | package org.eclipse.linuxtools.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 | |
291cbdbf BH |
76 | /** |
77 | * The import dialog implementation. | |
78 | */ | |
79 | private IImportDialog fImportDialog; | |
77735e82 | 80 | |
291cbdbf BH |
81 | /** |
82 | * The import confirmation dialog. | |
83 | */ | |
84 | private IImportConfirmationDialog fImportConfirmationDialog; | |
d132bcc7 BH |
85 | |
86 | // ------------------------------------------------------------------------ | |
87 | // Constructors | |
88 | // ------------------------------------------------------------------------ | |
89 | ||
90 | /** | |
91 | * Constructor for R4EUIDialogFactory. | |
92 | */ | |
93 | private TraceControlDialogFactory() { | |
94 | } | |
95 | ||
96 | // ------------------------------------------------------------------------ | |
97 | // Operations | |
98 | // ------------------------------------------------------------------------ | |
99 | ||
100 | /** | |
101 | * @return TraceControlDialogFactory instance | |
102 | */ | |
046b6849 | 103 | public static synchronized TraceControlDialogFactory getInstance() { |
c56972bb | 104 | if (fInstance == null) { |
d132bcc7 BH |
105 | fInstance = new TraceControlDialogFactory(); |
106 | } | |
107 | return fInstance; | |
108 | } | |
109 | ||
110 | /** | |
111 | * @return new connection dialog | |
112 | */ | |
113 | public INewConnectionDialog getNewConnectionDialog() { | |
c56972bb | 114 | if (fNewConnectionDialog == null) { |
d132bcc7 BH |
115 | fNewConnectionDialog = new NewConnectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); |
116 | } | |
117 | return fNewConnectionDialog; | |
118 | } | |
119 | ||
120 | /** | |
121 | * Sets a new connection dialog implementation. | |
122 | * @param newConnectionDialog - new connection dialog implementation | |
123 | */ | |
124 | public void setNewConnectionDialog(INewConnectionDialog newConnectionDialog) { | |
125 | fNewConnectionDialog = newConnectionDialog; | |
126 | } | |
77735e82 | 127 | |
d132bcc7 | 128 | /** |
d62bfa55 | 129 | * @return enable channel dialog |
d132bcc7 | 130 | */ |
d62bfa55 BH |
131 | public IEnableChannelDialog getEnableChannelDialog() { |
132 | if (fEnableChannelDialog == null) { | |
133 | fEnableChannelDialog = new EnableChannelDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); | |
d132bcc7 | 134 | } |
d62bfa55 | 135 | return fEnableChannelDialog; |
d132bcc7 BH |
136 | } |
137 | ||
138 | /** | |
d62bfa55 BH |
139 | * Sets a enable channel dialog implementation. |
140 | * @param createEnableDialog - a create channel dialog implementation | |
d132bcc7 | 141 | */ |
d62bfa55 BH |
142 | public void setEnableChannelDialog(IEnableChannelDialog createEnableDialog) { |
143 | fEnableChannelDialog = createEnableDialog; | |
d132bcc7 | 144 | } |
77735e82 | 145 | |
d132bcc7 BH |
146 | /** |
147 | * @return create session dialog implementation | |
148 | */ | |
149 | public ICreateSessionDialog getCreateSessionDialog() { | |
c56972bb | 150 | if (fCreateSessionDialog == null) { |
d132bcc7 BH |
151 | fCreateSessionDialog = new CreateSessionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); |
152 | } | |
153 | return fCreateSessionDialog; | |
154 | } | |
155 | ||
64a37b87 BH |
156 | /** |
157 | * @return command script selection dialog implementation | |
158 | */ | |
159 | public ISelectCommandScriptDialog getCommandScriptDialog() { | |
160 | if (fCommandScriptDialog == null) { | |
161 | fCommandScriptDialog = new OpenCommandScriptDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); | |
162 | } | |
163 | return fCommandScriptDialog; | |
164 | } | |
165 | ||
d132bcc7 BH |
166 | /** |
167 | * Sets a create session dialog implementation. | |
168 | * @param createSessionDialog - a create session implementation. | |
169 | */ | |
170 | public void setCreateSessionDialog(ICreateSessionDialog createSessionDialog) { | |
171 | fCreateSessionDialog = createSessionDialog; | |
172 | } | |
173 | ||
174 | /** | |
175 | * @return enable events dialog implementation. | |
176 | */ | |
177 | public IEnableEventsDialog getEnableEventsDialog() { | |
c56972bb | 178 | if (fEnableEventsDialog == null) { |
d132bcc7 BH |
179 | fEnableEventsDialog = new EnableEventsDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); |
180 | } | |
181 | return fEnableEventsDialog; | |
182 | } | |
183 | ||
184 | /** | |
185 | * Sets a enable events dialog implementation. | |
186 | * @param enableEventsDialog - a enable events dialog implementation. | |
187 | */ | |
188 | public void setEnableEventsDialog(IEnableEventsDialog enableEventsDialog) { | |
189 | fEnableEventsDialog = enableEventsDialog; | |
190 | } | |
191 | ||
192 | /** | |
193 | * @return get events info dialog implementation. | |
194 | */ | |
195 | public IGetEventInfoDialog getGetEventInfoDialog() { | |
c56972bb | 196 | if (fGetEventInfoDialog == null) { |
d132bcc7 BH |
197 | fGetEventInfoDialog = new GetEventInfoDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); |
198 | } | |
199 | return fGetEventInfoDialog; | |
200 | } | |
201 | ||
202 | /** | |
203 | * Sets a get events info dialog implementation. | |
204 | * @param getEventInfoDialog - a get events info dialog implementation | |
205 | */ | |
206 | public void setGetEventInfoDialog(IGetEventInfoDialog getEventInfoDialog) { | |
207 | fGetEventInfoDialog = getEventInfoDialog; | |
208 | } | |
77735e82 | 209 | |
d132bcc7 BH |
210 | /** |
211 | * @return the confirmation dialog implementation | |
212 | */ | |
213 | public IConfirmDialog getConfirmDialog() { | |
c56972bb | 214 | if (fConfirmDialog == null) { |
d132bcc7 BH |
215 | fConfirmDialog = new ConfirmDialog(); |
216 | } | |
217 | return fConfirmDialog; | |
218 | } | |
77735e82 | 219 | |
d132bcc7 BH |
220 | /** |
221 | * Sets the confirmation dialog implementation | |
291cbdbf | 222 | * @param confirmDialog - a confirmation dialog implementation |
d132bcc7 BH |
223 | */ |
224 | public void setConfirmDialog(IConfirmDialog confirmDialog) { | |
225 | fConfirmDialog = confirmDialog; | |
226 | } | |
77735e82 | 227 | |
b793fbe1 BH |
228 | /** |
229 | * @return the add context dialog implementation | |
230 | */ | |
231 | public IAddContextDialog getAddContextDialog() { | |
232 | if (fAddContextDialog == null) { | |
233 | fAddContextDialog = new AddContextDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); | |
234 | } | |
235 | return fAddContextDialog; | |
236 | } | |
77735e82 | 237 | |
b793fbe1 BH |
238 | /** |
239 | * Sets the add context dialog information | |
291cbdbf | 240 | * @param addContextDialog - a add context dialog implementation |
b793fbe1 BH |
241 | */ |
242 | public void setAddContextDialog(IAddContextDialog addContextDialog) { | |
243 | fAddContextDialog = addContextDialog; | |
244 | } | |
77735e82 | 245 | |
291cbdbf BH |
246 | /** |
247 | * @return the import dialog implementation | |
248 | */ | |
249 | public IImportDialog getImportDialog() { | |
250 | if (fImportDialog == null) { | |
251 | fImportDialog = new ImportDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); | |
252 | } | |
253 | return fImportDialog; | |
254 | } | |
77735e82 | 255 | |
291cbdbf BH |
256 | /** |
257 | * Sets the import dialog implementation. | |
258 | * @param importDialog - a import dialog implementation | |
259 | */ | |
260 | public void setImportDialog(IImportDialog importDialog) { | |
261 | fImportDialog = importDialog; | |
262 | } | |
77735e82 | 263 | |
291cbdbf BH |
264 | /** |
265 | * @return the import confirmation dialog implementation. | |
266 | */ | |
267 | public IImportConfirmationDialog getImportConfirmationDialog() { | |
268 | if (fImportConfirmationDialog == null) { | |
269 | fImportConfirmationDialog = new ImportConfirmationDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); | |
270 | } | |
271 | return fImportConfirmationDialog; | |
272 | } | |
77735e82 | 273 | |
291cbdbf BH |
274 | /** |
275 | * Sets the import confirmation dialog implementation. | |
77735e82 | 276 | * @param confirmDialog - a import confirmation dialog implementation. |
291cbdbf BH |
277 | */ |
278 | public void setImportConfirmationDialog(IImportConfirmationDialog confirmDialog) { | |
279 | fImportConfirmationDialog = confirmDialog; | |
280 | } | |
d132bcc7 BH |
281 | } |
282 |