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 command script selection dialog.
59 private ILoadDialog fLoadDialog
;
62 * The enable events dialog.
64 private IEnableEventsDialog fEnableEventsDialog
;
67 * The get event info dialog.
69 private IGetEventInfoDialog fGetEventInfoDialog
;
72 * The confirmation dialog implementation.
74 private IConfirmDialog fConfirmDialog
;
77 * The add context dialog implementation.
79 private IAddContextDialog fAddContextDialog
;
81 // ------------------------------------------------------------------------
83 // ------------------------------------------------------------------------
86 * Constructor for R4EUIDialogFactory.
88 private TraceControlDialogFactory() {
91 // ------------------------------------------------------------------------
93 // ------------------------------------------------------------------------
96 * @return TraceControlDialogFactory instance
98 public static synchronized TraceControlDialogFactory
getInstance() {
99 if (fInstance
== null) {
100 fInstance
= new TraceControlDialogFactory();
106 * @return new connection dialog
108 public INewConnectionDialog
getNewConnectionDialog() {
109 if (fNewConnectionDialog
== null) {
110 fNewConnectionDialog
= new NewConnectionDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
112 return fNewConnectionDialog
;
116 * Sets a new connection dialog implementation.
117 * @param newConnectionDialog - new connection dialog implementation
119 public void setNewConnectionDialog(INewConnectionDialog newConnectionDialog
) {
120 fNewConnectionDialog
= newConnectionDialog
;
124 * @return enable channel dialog
126 public IEnableChannelDialog
getEnableChannelDialog() {
127 if (fEnableChannelDialog
== null) {
128 fEnableChannelDialog
= new EnableChannelDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
130 return fEnableChannelDialog
;
134 * Sets a enable channel dialog implementation.
135 * @param createEnableDialog - a create channel dialog implementation
137 public void setEnableChannelDialog(IEnableChannelDialog createEnableDialog
) {
138 fEnableChannelDialog
= createEnableDialog
;
142 * @return create session dialog implementation
144 public ICreateSessionDialog
getCreateSessionDialog() {
145 if (fCreateSessionDialog
== null) {
146 fCreateSessionDialog
= new CreateSessionDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
148 return fCreateSessionDialog
;
152 * @return command script selection dialog implementation
154 public ISelectCommandScriptDialog
getCommandScriptDialog() {
155 if (fCommandScriptDialog
== null) {
156 fCommandScriptDialog
= new OpenCommandScriptDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
158 return fCommandScriptDialog
;
162 * @return command script selection dialog implementation
164 public ILoadDialog
getLoadDialog() {
165 if (fLoadDialog
== null) {
166 fLoadDialog
= new LoadDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
172 * Sets a load dialog implementation
174 * a load dialog implementation
176 public void setLoadDialog(ILoadDialog loadDialog
) {
177 fLoadDialog
= loadDialog
;
181 * Sets a create session dialog implementation.
182 * @param createSessionDialog - a create session implementation.
184 public void setCreateSessionDialog(ICreateSessionDialog createSessionDialog
) {
185 fCreateSessionDialog
= createSessionDialog
;
189 * @return enable events dialog implementation.
191 public IEnableEventsDialog
getEnableEventsDialog() {
192 if (fEnableEventsDialog
== null) {
193 fEnableEventsDialog
= new EnableEventsDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
195 return fEnableEventsDialog
;
199 * Sets a enable events dialog implementation.
200 * @param enableEventsDialog - a enable events dialog implementation.
202 public void setEnableEventsDialog(IEnableEventsDialog enableEventsDialog
) {
203 fEnableEventsDialog
= enableEventsDialog
;
207 * @return get events info dialog implementation.
209 public IGetEventInfoDialog
getGetEventInfoDialog() {
210 if (fGetEventInfoDialog
== null) {
211 fGetEventInfoDialog
= new GetEventInfoDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
213 return fGetEventInfoDialog
;
217 * Sets a get events info dialog implementation.
218 * @param getEventInfoDialog - a get events info dialog implementation
220 public void setGetEventInfoDialog(IGetEventInfoDialog getEventInfoDialog
) {
221 fGetEventInfoDialog
= getEventInfoDialog
;
225 * @return the confirmation dialog implementation
227 public IConfirmDialog
getConfirmDialog() {
228 if (fConfirmDialog
== null) {
229 fConfirmDialog
= new ConfirmDialog();
231 return fConfirmDialog
;
235 * Sets the confirmation dialog implementation
236 * @param confirmDialog - a confirmation dialog implementation
238 public void setConfirmDialog(IConfirmDialog confirmDialog
) {
239 fConfirmDialog
= confirmDialog
;
243 * @return the add context dialog implementation
245 public IAddContextDialog
getAddContextDialog() {
246 if (fAddContextDialog
== null) {
247 fAddContextDialog
= new AddContextDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
249 return fAddContextDialog
;
253 * Sets the add context dialog information
254 * @param addContextDialog - a add context dialog implementation
256 public void setAddContextDialog(IAddContextDialog addContextDialog
) {
257 fAddContextDialog
= addContextDialog
;