tmf.ui: Introduce TmfFileDialogFactory
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / dialogs / SaveDialog.java
1 /**********************************************************************
2 * Copyright (c) 2015 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.jface.dialogs.Dialog;
15 import org.eclipse.jface.dialogs.IDialogConstants;
16 import org.eclipse.swt.SWT;
17 import org.eclipse.swt.layout.GridData;
18 import org.eclipse.swt.layout.GridLayout;
19 import org.eclipse.swt.widgets.Button;
20 import org.eclipse.swt.widgets.Composite;
21 import org.eclipse.swt.widgets.Control;
22 import org.eclipse.swt.widgets.Shell;
23 import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
24 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
25
26 /**
27 * Dialog box for collecting parameter for loading a session.
28 *
29 * @author Bernd Hufmann
30 */
31 public class SaveDialog extends Dialog implements ISaveDialog {
32 // ------------------------------------------------------------------------
33 // Constants
34 // ------------------------------------------------------------------------
35 /** The icon file for this dialog box. */
36 public static final String EXPORT_ICON_FILE = "icons/elcl16/export_button.png"; //$NON-NLS-1$
37
38 // ------------------------------------------------------------------------
39 // Constants
40 // ------------------------------------------------------------------------
41 /**
42 * The dialog composite.
43 */
44 private Composite fDialogComposite = null;
45
46 private Button fForceButton = null;
47
48 private boolean fIsForce = true;
49
50 // ------------------------------------------------------------------------
51 // Constructors
52 // ------------------------------------------------------------------------
53 /**
54 * Constructor
55 *
56 * @param shell
57 * - a shell for the display of the dialog
58 */
59 public SaveDialog(Shell shell) {
60 super(shell);
61 setShellStyle(SWT.RESIZE | getShellStyle());
62 }
63
64 @Override
65 public boolean isForce() {
66 return fIsForce;
67 }
68
69 // ------------------------------------------------------------------------
70 // Operations
71 // ------------------------------------------------------------------------
72 @Override
73 protected void configureShell(Shell newShell) {
74 super.configureShell(newShell);
75 newShell.setText(Messages.TraceControl_SaveDialogTitle);
76 newShell.setImage(Activator.getDefault().loadIcon(EXPORT_ICON_FILE));
77 }
78
79 @Override
80 protected Control createDialogArea(Composite parent) {
81 // Main dialog panel
82 fDialogComposite = new Composite(parent, SWT.NONE);
83 GridLayout layout = new GridLayout(1, true);
84 fDialogComposite.setLayout(layout);
85 fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
86 createOptionComposite();
87 return fDialogComposite;
88 }
89
90 private void createOptionComposite() {
91 Composite group = new Composite(fDialogComposite, SWT.BORDER);
92 group.setLayout(new GridLayout(1, true));
93 group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
94
95 fForceButton = new Button(group, SWT.CHECK);
96 fForceButton.setSelection(true);
97 fForceButton.setText(Messages.TraceControl_ForceButtonText);
98 }
99
100 @Override
101 protected void createButtonsForButtonBar(final Composite parent) {
102 createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true);
103 createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
104 }
105
106 @Override
107 protected void okPressed() {
108 fIsForce = fForceButton.getSelection();
109 super.okPressed();
110 }
111
112 }
This page took 0.033656 seconds and 5 git commands to generate.