1 /**********************************************************************
2 * Copyright (c) 2012, 2014 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
.tracecompass
.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
;
76 // ------------------------------------------------------------------------
78 // ------------------------------------------------------------------------
81 * Constructor for R4EUIDialogFactory.
83 private TraceControlDialogFactory() {
86 // ------------------------------------------------------------------------
88 // ------------------------------------------------------------------------
91 * @return TraceControlDialogFactory instance
93 public static synchronized TraceControlDialogFactory
getInstance() {
94 if (fInstance
== null) {
95 fInstance
= new TraceControlDialogFactory();
101 * @return new connection dialog
103 public INewConnectionDialog
getNewConnectionDialog() {
104 if (fNewConnectionDialog
== null) {
105 fNewConnectionDialog
= new NewConnectionDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
107 return fNewConnectionDialog
;
111 * Sets a new connection dialog implementation.
112 * @param newConnectionDialog - new connection dialog implementation
114 public void setNewConnectionDialog(INewConnectionDialog newConnectionDialog
) {
115 fNewConnectionDialog
= newConnectionDialog
;
119 * @return enable channel dialog
121 public IEnableChannelDialog
getEnableChannelDialog() {
122 if (fEnableChannelDialog
== null) {
123 fEnableChannelDialog
= new EnableChannelDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
125 return fEnableChannelDialog
;
129 * Sets a enable channel dialog implementation.
130 * @param createEnableDialog - a create channel dialog implementation
132 public void setEnableChannelDialog(IEnableChannelDialog createEnableDialog
) {
133 fEnableChannelDialog
= createEnableDialog
;
137 * @return create session dialog implementation
139 public ICreateSessionDialog
getCreateSessionDialog() {
140 if (fCreateSessionDialog
== null) {
141 fCreateSessionDialog
= new CreateSessionDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
143 return fCreateSessionDialog
;
147 * @return command script selection dialog implementation
149 public ISelectCommandScriptDialog
getCommandScriptDialog() {
150 if (fCommandScriptDialog
== null) {
151 fCommandScriptDialog
= new OpenCommandScriptDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
153 return fCommandScriptDialog
;
157 * Sets a create session dialog implementation.
158 * @param createSessionDialog - a create session implementation.
160 public void setCreateSessionDialog(ICreateSessionDialog createSessionDialog
) {
161 fCreateSessionDialog
= createSessionDialog
;
165 * @return enable events dialog implementation.
167 public IEnableEventsDialog
getEnableEventsDialog() {
168 if (fEnableEventsDialog
== null) {
169 fEnableEventsDialog
= new EnableEventsDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
171 return fEnableEventsDialog
;
175 * Sets a enable events dialog implementation.
176 * @param enableEventsDialog - a enable events dialog implementation.
178 public void setEnableEventsDialog(IEnableEventsDialog enableEventsDialog
) {
179 fEnableEventsDialog
= enableEventsDialog
;
183 * @return get events info dialog implementation.
185 public IGetEventInfoDialog
getGetEventInfoDialog() {
186 if (fGetEventInfoDialog
== null) {
187 fGetEventInfoDialog
= new GetEventInfoDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
189 return fGetEventInfoDialog
;
193 * Sets a get events info dialog implementation.
194 * @param getEventInfoDialog - a get events info dialog implementation
196 public void setGetEventInfoDialog(IGetEventInfoDialog getEventInfoDialog
) {
197 fGetEventInfoDialog
= getEventInfoDialog
;
201 * @return the confirmation dialog implementation
203 public IConfirmDialog
getConfirmDialog() {
204 if (fConfirmDialog
== null) {
205 fConfirmDialog
= new ConfirmDialog();
207 return fConfirmDialog
;
211 * Sets the confirmation dialog implementation
212 * @param confirmDialog - a confirmation dialog implementation
214 public void setConfirmDialog(IConfirmDialog confirmDialog
) {
215 fConfirmDialog
= confirmDialog
;
219 * @return the add context dialog implementation
221 public IAddContextDialog
getAddContextDialog() {
222 if (fAddContextDialog
== null) {
223 fAddContextDialog
= new AddContextDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
225 return fAddContextDialog
;
229 * Sets the add context dialog information
230 * @param addContextDialog - a add context dialog implementation
232 public void setAddContextDialog(IAddContextDialog addContextDialog
) {
233 fAddContextDialog
= addContextDialog
;