control: Add enhanced support for loading of sessions
[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 command script selection dialog.
58 */
59 private ILoadDialog fLoadDialog;
60
61 /**
62 * The enable events dialog.
63 */
64 private IEnableEventsDialog fEnableEventsDialog;
65
66 /**
67 * The get event info dialog.
68 */
69 private IGetEventInfoDialog fGetEventInfoDialog;
70
71 /**
72 * The confirmation dialog implementation.
73 */
74 private IConfirmDialog fConfirmDialog;
75
76 /**
77 * The add context dialog implementation.
78 */
79 private IAddContextDialog fAddContextDialog;
80
81 // ------------------------------------------------------------------------
82 // Constructors
83 // ------------------------------------------------------------------------
84
85 /**
86 * Constructor for R4EUIDialogFactory.
87 */
88 private TraceControlDialogFactory() {
89 }
90
91 // ------------------------------------------------------------------------
92 // Operations
93 // ------------------------------------------------------------------------
94
95 /**
96 * @return TraceControlDialogFactory instance
97 */
98 public static synchronized TraceControlDialogFactory getInstance() {
99 if (fInstance == null) {
100 fInstance = new TraceControlDialogFactory();
101 }
102 return fInstance;
103 }
104
105 /**
106 * @return new connection dialog
107 */
108 public INewConnectionDialog getNewConnectionDialog() {
109 if (fNewConnectionDialog == null) {
110 fNewConnectionDialog = new NewConnectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
111 }
112 return fNewConnectionDialog;
113 }
114
115 /**
116 * Sets a new connection dialog implementation.
117 * @param newConnectionDialog - new connection dialog implementation
118 */
119 public void setNewConnectionDialog(INewConnectionDialog newConnectionDialog) {
120 fNewConnectionDialog = newConnectionDialog;
121 }
122
123 /**
124 * @return enable channel dialog
125 */
126 public IEnableChannelDialog getEnableChannelDialog() {
127 if (fEnableChannelDialog == null) {
128 fEnableChannelDialog = new EnableChannelDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
129 }
130 return fEnableChannelDialog;
131 }
132
133 /**
134 * Sets a enable channel dialog implementation.
135 * @param createEnableDialog - a create channel dialog implementation
136 */
137 public void setEnableChannelDialog(IEnableChannelDialog createEnableDialog) {
138 fEnableChannelDialog = createEnableDialog;
139 }
140
141 /**
142 * @return create session dialog implementation
143 */
144 public ICreateSessionDialog getCreateSessionDialog() {
145 if (fCreateSessionDialog == null) {
146 fCreateSessionDialog = new CreateSessionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
147 }
148 return fCreateSessionDialog;
149 }
150
151 /**
152 * @return command script selection dialog implementation
153 */
154 public ISelectCommandScriptDialog getCommandScriptDialog() {
155 if (fCommandScriptDialog == null) {
156 fCommandScriptDialog = new OpenCommandScriptDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
157 }
158 return fCommandScriptDialog;
159 }
160
161 /**
162 * @return command script selection dialog implementation
163 */
164 public ILoadDialog getLoadDialog() {
165 if (fLoadDialog == null) {
166 fLoadDialog = new LoadDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
167 }
168 return fLoadDialog;
169 }
170
171 /**
172 * Sets a load dialog implementation
173 * @param loadDialog
174 * a load dialog implementation
175 */
176 public void setLoadDialog(ILoadDialog loadDialog) {
177 fLoadDialog = loadDialog;
178 }
179
180 /**
181 * Sets a create session dialog implementation.
182 * @param createSessionDialog - a create session implementation.
183 */
184 public void setCreateSessionDialog(ICreateSessionDialog createSessionDialog) {
185 fCreateSessionDialog = createSessionDialog;
186 }
187
188 /**
189 * @return enable events dialog implementation.
190 */
191 public IEnableEventsDialog getEnableEventsDialog() {
192 if (fEnableEventsDialog == null) {
193 fEnableEventsDialog = new EnableEventsDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
194 }
195 return fEnableEventsDialog;
196 }
197
198 /**
199 * Sets a enable events dialog implementation.
200 * @param enableEventsDialog - a enable events dialog implementation.
201 */
202 public void setEnableEventsDialog(IEnableEventsDialog enableEventsDialog) {
203 fEnableEventsDialog = enableEventsDialog;
204 }
205
206 /**
207 * @return get events info dialog implementation.
208 */
209 public IGetEventInfoDialog getGetEventInfoDialog() {
210 if (fGetEventInfoDialog == null) {
211 fGetEventInfoDialog = new GetEventInfoDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
212 }
213 return fGetEventInfoDialog;
214 }
215
216 /**
217 * Sets a get events info dialog implementation.
218 * @param getEventInfoDialog - a get events info dialog implementation
219 */
220 public void setGetEventInfoDialog(IGetEventInfoDialog getEventInfoDialog) {
221 fGetEventInfoDialog = getEventInfoDialog;
222 }
223
224 /**
225 * @return the confirmation dialog implementation
226 */
227 public IConfirmDialog getConfirmDialog() {
228 if (fConfirmDialog == null) {
229 fConfirmDialog = new ConfirmDialog();
230 }
231 return fConfirmDialog;
232 }
233
234 /**
235 * Sets the confirmation dialog implementation
236 * @param confirmDialog - a confirmation dialog implementation
237 */
238 public void setConfirmDialog(IConfirmDialog confirmDialog) {
239 fConfirmDialog = confirmDialog;
240 }
241
242 /**
243 * @return the add context dialog implementation
244 */
245 public IAddContextDialog getAddContextDialog() {
246 if (fAddContextDialog == null) {
247 fAddContextDialog = new AddContextDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
248 }
249 return fAddContextDialog;
250 }
251
252 /**
253 * Sets the add context dialog information
254 * @param addContextDialog - a add context dialog implementation
255 */
256 public void setAddContextDialog(IAddContextDialog addContextDialog) {
257 fAddContextDialog = addContextDialog;
258 }
259
260 }
261
This page took 0.043984 seconds and 5 git commands to generate.