control: Base code for profile dialog window
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / dialogs / TraceControlDialogFactory.java
1 /**********************************************************************
2 * Copyright (c) 2012, 2014 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
13
14 import org.eclipse.ui.PlatformUI;
15
16 /**
17 * <p>
18 * Factory for generating dialog boxes. It allows to overwrite the dialog implementation.
19 * Useful also for testing purposes.
20 * </p>
21 *
22 * @author Bernd Hufmann
23 *
24 */
25 public final class TraceControlDialogFactory {
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;
40
41 /**
42 * The enable channel dialog
43 */
44 private IEnableChannelDialog fEnableChannelDialog;
45
46 /**
47 * The create session dialog.
48 */
49 private ICreateSessionDialog fCreateSessionDialog;
50
51 /**
52 * The command script selection dialog.
53 */
54 private ISelectCommandScriptDialog fCommandScriptDialog;
55
56 /**
57 * The enable events dialog.
58 */
59 private IEnableEventsDialog fEnableEventsDialog;
60
61 /**
62 * The get event info dialog.
63 */
64 private IGetEventInfoDialog fGetEventInfoDialog;
65
66 /**
67 * The confirmation dialog implementation.
68 */
69 private IConfirmDialog fConfirmDialog;
70
71 /**
72 * The add context dialog implementation.
73 */
74 private IAddContextDialog fAddContextDialog;
75
76 // ------------------------------------------------------------------------
77 // Constructors
78 // ------------------------------------------------------------------------
79
80 /**
81 * Constructor for R4EUIDialogFactory.
82 */
83 private TraceControlDialogFactory() {
84 }
85
86 // ------------------------------------------------------------------------
87 // Operations
88 // ------------------------------------------------------------------------
89
90 /**
91 * @return TraceControlDialogFactory instance
92 */
93 public static synchronized TraceControlDialogFactory getInstance() {
94 if (fInstance == null) {
95 fInstance = new TraceControlDialogFactory();
96 }
97 return fInstance;
98 }
99
100 /**
101 * @return new connection dialog
102 */
103 public INewConnectionDialog getNewConnectionDialog() {
104 if (fNewConnectionDialog == null) {
105 fNewConnectionDialog = new NewConnectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
106 }
107 return fNewConnectionDialog;
108 }
109
110 /**
111 * Sets a new connection dialog implementation.
112 * @param newConnectionDialog - new connection dialog implementation
113 */
114 public void setNewConnectionDialog(INewConnectionDialog newConnectionDialog) {
115 fNewConnectionDialog = newConnectionDialog;
116 }
117
118 /**
119 * @return enable channel dialog
120 */
121 public IEnableChannelDialog getEnableChannelDialog() {
122 if (fEnableChannelDialog == null) {
123 fEnableChannelDialog = new EnableChannelDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
124 }
125 return fEnableChannelDialog;
126 }
127
128 /**
129 * Sets a enable channel dialog implementation.
130 * @param createEnableDialog - a create channel dialog implementation
131 */
132 public void setEnableChannelDialog(IEnableChannelDialog createEnableDialog) {
133 fEnableChannelDialog = createEnableDialog;
134 }
135
136 /**
137 * @return create session dialog implementation
138 */
139 public ICreateSessionDialog getCreateSessionDialog() {
140 if (fCreateSessionDialog == null) {
141 fCreateSessionDialog = new CreateSessionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
142 }
143 return fCreateSessionDialog;
144 }
145
146 /**
147 * @return command script selection dialog implementation
148 */
149 public ISelectCommandScriptDialog getCommandScriptDialog() {
150 if (fCommandScriptDialog == null) {
151 fCommandScriptDialog = new OpenCommandScriptDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
152 }
153 return fCommandScriptDialog;
154 }
155
156 /**
157 * Sets a create session dialog implementation.
158 * @param createSessionDialog - a create session implementation.
159 */
160 public void setCreateSessionDialog(ICreateSessionDialog createSessionDialog) {
161 fCreateSessionDialog = createSessionDialog;
162 }
163
164 /**
165 * @return enable events dialog implementation.
166 */
167 public IEnableEventsDialog getEnableEventsDialog() {
168 if (fEnableEventsDialog == null) {
169 fEnableEventsDialog = new EnableEventsDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
170 }
171 return fEnableEventsDialog;
172 }
173
174 /**
175 * Sets a enable events dialog implementation.
176 * @param enableEventsDialog - a enable events dialog implementation.
177 */
178 public void setEnableEventsDialog(IEnableEventsDialog enableEventsDialog) {
179 fEnableEventsDialog = enableEventsDialog;
180 }
181
182 /**
183 * @return get events info dialog implementation.
184 */
185 public IGetEventInfoDialog getGetEventInfoDialog() {
186 if (fGetEventInfoDialog == null) {
187 fGetEventInfoDialog = new GetEventInfoDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
188 }
189 return fGetEventInfoDialog;
190 }
191
192 /**
193 * Sets a get events info dialog implementation.
194 * @param getEventInfoDialog - a get events info dialog implementation
195 */
196 public void setGetEventInfoDialog(IGetEventInfoDialog getEventInfoDialog) {
197 fGetEventInfoDialog = getEventInfoDialog;
198 }
199
200 /**
201 * @return the confirmation dialog implementation
202 */
203 public IConfirmDialog getConfirmDialog() {
204 if (fConfirmDialog == null) {
205 fConfirmDialog = new ConfirmDialog();
206 }
207 return fConfirmDialog;
208 }
209
210 /**
211 * Sets the confirmation dialog implementation
212 * @param confirmDialog - a confirmation dialog implementation
213 */
214 public void setConfirmDialog(IConfirmDialog confirmDialog) {
215 fConfirmDialog = confirmDialog;
216 }
217
218 /**
219 * @return the add context dialog implementation
220 */
221 public IAddContextDialog getAddContextDialog() {
222 if (fAddContextDialog == null) {
223 fAddContextDialog = new AddContextDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
224 }
225 return fAddContextDialog;
226 }
227
228 /**
229 * Sets the add context dialog information
230 * @param addContextDialog - a add context dialog implementation
231 */
232 public void setAddContextDialog(IAddContextDialog addContextDialog) {
233 fAddContextDialog = addContextDialog;
234 }
235
236 }
237
This page took 0.03683 seconds and 5 git commands to generate.