1 /**********************************************************************
2 * Copyright (c) 2012 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
.ui
.views
.control
.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 final public 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 enable events dialog.
54 private IEnableEventsDialog fEnableEventsDialog
;
57 * The get event info dialog.
59 private IGetEventInfoDialog fGetEventInfoDialog
;
62 * The confirmation dialog implementation.
64 private IConfirmDialog fConfirmDialog
;
67 * The add context dialog implementation.
69 private IAddContextDialog fAddContextDialog
;
72 * The import dialog implementation.
74 private IImportDialog fImportDialog
;
77 * The import confirmation dialog.
79 private IImportConfirmationDialog fImportConfirmationDialog
;
81 // ------------------------------------------------------------------------
83 // ------------------------------------------------------------------------
86 * Constructor for R4EUIDialogFactory.
88 private TraceControlDialogFactory() {
91 // ------------------------------------------------------------------------
93 // ------------------------------------------------------------------------
96 * @return TraceControlDialogFactory instance
98 public synchronized static 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 * Sets a create session dialog implementation.
153 * @param createSessionDialog - a create session implementation.
155 public void setCreateSessionDialog(ICreateSessionDialog createSessionDialog
) {
156 fCreateSessionDialog
= createSessionDialog
;
160 * @return enable events dialog implementation.
162 public IEnableEventsDialog
getEnableEventsDialog() {
163 if (fEnableEventsDialog
== null) {
164 fEnableEventsDialog
= new EnableEventsDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
166 return fEnableEventsDialog
;
170 * Sets a enable events dialog implementation.
171 * @param enableEventsDialog - a enable events dialog implementation.
173 public void setEnableEventsDialog(IEnableEventsDialog enableEventsDialog
) {
174 fEnableEventsDialog
= enableEventsDialog
;
178 * @return get events info dialog implementation.
180 public IGetEventInfoDialog
getGetEventInfoDialog() {
181 if (fGetEventInfoDialog
== null) {
182 fGetEventInfoDialog
= new GetEventInfoDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
184 return fGetEventInfoDialog
;
188 * Sets a get events info dialog implementation.
189 * @param getEventInfoDialog - a get events info dialog implementation
191 public void setGetEventInfoDialog(IGetEventInfoDialog getEventInfoDialog
) {
192 fGetEventInfoDialog
= getEventInfoDialog
;
196 * @return the confirmation dialog implementation
198 public IConfirmDialog
getConfirmDialog() {
199 if (fConfirmDialog
== null) {
200 fConfirmDialog
= new ConfirmDialog();
202 return fConfirmDialog
;
206 * Sets the confirmation dialog implementation
207 * @param confirmDialog - a confirmation dialog implementation
209 public void setConfirmDialog(IConfirmDialog confirmDialog
) {
210 fConfirmDialog
= confirmDialog
;
214 * @return the add context dialog implementation
216 public IAddContextDialog
getAddContextDialog() {
217 if (fAddContextDialog
== null) {
218 fAddContextDialog
= new AddContextDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
220 return fAddContextDialog
;
224 * Sets the add context dialog information
225 * @param addContextDialog - a add context dialog implementation
227 public void setAddContextDialog(IAddContextDialog addContextDialog
) {
228 fAddContextDialog
= addContextDialog
;
232 * @return the import dialog implementation
234 public IImportDialog
getImportDialog() {
235 if (fImportDialog
== null) {
236 fImportDialog
= new ImportDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
238 return fImportDialog
;
242 * Sets the import dialog implementation.
243 * @param importDialog - a import dialog implementation
245 public void setImportDialog(IImportDialog importDialog
) {
246 fImportDialog
= importDialog
;
250 * @return the import confirmation dialog implementation.
252 public IImportConfirmationDialog
getImportConfirmationDialog() {
253 if (fImportConfirmationDialog
== null) {
254 fImportConfirmationDialog
= new ImportConfirmationDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
256 return fImportConfirmationDialog
;
260 * Sets the import confirmation dialog implementation.
261 * @param confirmDialog - a import confirmation dialog implementation.
263 public void setImportConfirmationDialog(IImportConfirmationDialog confirmDialog
) {
264 fImportConfirmationDialog
= confirmDialog
;