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