1 /**********************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.dialogs
;
14 import org
.eclipse
.ui
.PlatformUI
;
18 * Factory for generating dialog boxes. It allows to overwrite the dialog implementation.
19 * Useful also for testing purposes.
22 * @author Bernd Hufmann
25 public final class TraceControlDialogFactory
{
27 // ------------------------------------------------------------------------
29 // ------------------------------------------------------------------------
32 * The factory instance.
34 private static TraceControlDialogFactory fInstance
;
37 * The new connection dialog reference.
39 private INewConnectionDialog fNewConnectionDialog
;
42 * The enable channel dialog
44 private IEnableChannelDialog fEnableChannelDialog
;
47 * The create session dialog.
49 private ICreateSessionDialog fCreateSessionDialog
;
52 * The command script selection dialog.
54 private ISelectCommandScriptDialog fCommandScriptDialog
;
57 * The enable events dialog.
59 private IEnableEventsDialog fEnableEventsDialog
;
62 * The get event info dialog.
64 private IGetEventInfoDialog fGetEventInfoDialog
;
67 * The confirmation dialog implementation.
69 private IConfirmDialog fConfirmDialog
;
72 * The add context dialog implementation.
74 private IAddContextDialog fAddContextDialog
;
77 * The import dialog implementation.
79 private IImportDialog fImportDialog
;
82 * The import confirmation dialog.
84 private IImportConfirmationDialog fImportConfirmationDialog
;
86 // ------------------------------------------------------------------------
88 // ------------------------------------------------------------------------
91 * Constructor for R4EUIDialogFactory.
93 private TraceControlDialogFactory() {
96 // ------------------------------------------------------------------------
98 // ------------------------------------------------------------------------
101 * @return TraceControlDialogFactory instance
103 public static synchronized TraceControlDialogFactory
getInstance() {
104 if (fInstance
== null) {
105 fInstance
= new TraceControlDialogFactory();
111 * @return new connection dialog
113 public INewConnectionDialog
getNewConnectionDialog() {
114 if (fNewConnectionDialog
== null) {
115 fNewConnectionDialog
= new NewConnectionDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
117 return fNewConnectionDialog
;
121 * Sets a new connection dialog implementation.
122 * @param newConnectionDialog - new connection dialog implementation
124 public void setNewConnectionDialog(INewConnectionDialog newConnectionDialog
) {
125 fNewConnectionDialog
= newConnectionDialog
;
129 * @return enable channel dialog
131 public IEnableChannelDialog
getEnableChannelDialog() {
132 if (fEnableChannelDialog
== null) {
133 fEnableChannelDialog
= new EnableChannelDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
135 return fEnableChannelDialog
;
139 * Sets a enable channel dialog implementation.
140 * @param createEnableDialog - a create channel dialog implementation
142 public void setEnableChannelDialog(IEnableChannelDialog createEnableDialog
) {
143 fEnableChannelDialog
= createEnableDialog
;
147 * @return create session dialog implementation
149 public ICreateSessionDialog
getCreateSessionDialog() {
150 if (fCreateSessionDialog
== null) {
151 fCreateSessionDialog
= new CreateSessionDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
153 return fCreateSessionDialog
;
157 * @return command script selection dialog implementation
159 public ISelectCommandScriptDialog
getCommandScriptDialog() {
160 if (fCommandScriptDialog
== null) {
161 fCommandScriptDialog
= new OpenCommandScriptDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
163 return fCommandScriptDialog
;
167 * Sets a create session dialog implementation.
168 * @param createSessionDialog - a create session implementation.
170 public void setCreateSessionDialog(ICreateSessionDialog createSessionDialog
) {
171 fCreateSessionDialog
= createSessionDialog
;
175 * @return enable events dialog implementation.
177 public IEnableEventsDialog
getEnableEventsDialog() {
178 if (fEnableEventsDialog
== null) {
179 fEnableEventsDialog
= new EnableEventsDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
181 return fEnableEventsDialog
;
185 * Sets a enable events dialog implementation.
186 * @param enableEventsDialog - a enable events dialog implementation.
188 public void setEnableEventsDialog(IEnableEventsDialog enableEventsDialog
) {
189 fEnableEventsDialog
= enableEventsDialog
;
193 * @return get events info dialog implementation.
195 public IGetEventInfoDialog
getGetEventInfoDialog() {
196 if (fGetEventInfoDialog
== null) {
197 fGetEventInfoDialog
= new GetEventInfoDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
199 return fGetEventInfoDialog
;
203 * Sets a get events info dialog implementation.
204 * @param getEventInfoDialog - a get events info dialog implementation
206 public void setGetEventInfoDialog(IGetEventInfoDialog getEventInfoDialog
) {
207 fGetEventInfoDialog
= getEventInfoDialog
;
211 * @return the confirmation dialog implementation
213 public IConfirmDialog
getConfirmDialog() {
214 if (fConfirmDialog
== null) {
215 fConfirmDialog
= new ConfirmDialog();
217 return fConfirmDialog
;
221 * Sets the confirmation dialog implementation
222 * @param confirmDialog - a confirmation dialog implementation
224 public void setConfirmDialog(IConfirmDialog confirmDialog
) {
225 fConfirmDialog
= confirmDialog
;
229 * @return the add context dialog implementation
231 public IAddContextDialog
getAddContextDialog() {
232 if (fAddContextDialog
== null) {
233 fAddContextDialog
= new AddContextDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
235 return fAddContextDialog
;
239 * Sets the add context dialog information
240 * @param addContextDialog - a add context dialog implementation
242 public void setAddContextDialog(IAddContextDialog addContextDialog
) {
243 fAddContextDialog
= addContextDialog
;
247 * @return the import dialog implementation
249 public IImportDialog
getImportDialog() {
250 if (fImportDialog
== null) {
251 fImportDialog
= new ImportDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
253 return fImportDialog
;
257 * Sets the import dialog implementation.
258 * @param importDialog - a import dialog implementation
260 public void setImportDialog(IImportDialog importDialog
) {
261 fImportDialog
= importDialog
;
265 * @return the import confirmation dialog implementation.
267 public IImportConfirmationDialog
getImportConfirmationDialog() {
268 if (fImportConfirmationDialog
== null) {
269 fImportConfirmationDialog
= new ImportConfirmationDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
271 return fImportConfirmationDialog
;
275 * Sets the import confirmation dialog implementation.
276 * @param confirmDialog - a import confirmation dialog implementation.
278 public void setImportConfirmationDialog(IImportConfirmationDialog confirmDialog
) {
279 fImportConfirmationDialog
= confirmDialog
;