tmf: Update copyright headers in tmf.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / dialogs / SDPrintDialog.java
CommitLineData
c8422608
AM
1/**********************************************************************
2 * Copyright (c) 2005, 2012 IBM Corporation, Ericsson
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
73005152
BH
11 **********************************************************************/
12
df0b8ff4 13package org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs;
73005152
BH
14
15import org.eclipse.jface.dialogs.Dialog;
16import org.eclipse.jface.dialogs.IDialogConstants;
17import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget;
df0b8ff4 18import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
73005152
BH
19import org.eclipse.swt.SWT;
20import org.eclipse.swt.events.SelectionEvent;
21import org.eclipse.swt.events.SelectionListener;
22import org.eclipse.swt.layout.GridData;
23import org.eclipse.swt.widgets.Button;
24import org.eclipse.swt.widgets.Composite;
25import org.eclipse.swt.widgets.Control;
26import org.eclipse.swt.widgets.Label;
27import org.eclipse.swt.widgets.Shell;
28
29/**
df0b8ff4 30 * This class implements a dialog box for collecting printing information.
c8422608 31 *
df0b8ff4 32 * @version 1.0
73005152
BH
33 * @author sveyrier
34 */
35public class SDPrintDialog extends Dialog {
36
df0b8ff4
BH
37 // ------------------------------------------------------------------------
38 // Attributes
39 // ------------------------------------------------------------------------
40 /**
41 * The sequence dialog widget reference.
42 */
eb63f5ff 43 protected SDWidget fSdView;
df0b8ff4
BH
44 /**
45 * Sequence dialog print dialog UI
46 */
eb63f5ff 47 protected SDPrintDialogUI fDialogUI;
df0b8ff4
BH
48 /**
49 * Error message to display.
50 */
eb63f5ff 51 protected String fErrorMessage = null;
df0b8ff4
BH
52 /**
53 * A message label.
54 */
eb63f5ff 55 protected Label fMessageLabel = null;
df0b8ff4
BH
56 /**
57 * Flag whether the page is complete or not
58 */
eb63f5ff 59 protected boolean fIsPageComplete = true;
73005152 60
df0b8ff4
BH
61 // ------------------------------------------------------------------------
62 // Constructors
63 // ------------------------------------------------------------------------
64 /**
65 * Standard constructor
c8422608 66 *
df0b8ff4
BH
67 * @param shell Shell reference
68 * @param viewer Sequence diagram widget reference
69 */
70 public SDPrintDialog(Shell shell, SDWidget viewer) {
71 super(shell);
eb63f5ff 72 fSdView = viewer;
df0b8ff4 73
eb63f5ff
BH
74 fDialogUI = new SDPrintDialogUI(shell, fSdView);
75 fDialogUI.setParentDialog(this);
73005152
BH
76 }
77
df0b8ff4
BH
78 // ------------------------------------------------------------------------
79 // Methods
80 // ------------------------------------------------------------------------
81 /*
82 * (non-Javadoc)
83 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
84 */
73005152
BH
85 @Override
86 protected Control createDialogArea(Composite p) {
87 p.getShell().setText(SDMessages._114);
88 Composite parent = (Composite) super.createDialogArea(p);
89
eb63f5ff 90 fDialogUI.createDialogArea(parent);
73005152 91
eb63f5ff 92 fMessageLabel = new Label(parent, SWT.NONE);
73005152
BH
93 GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
94 gridData.horizontalSpan = 6;
eb63f5ff
BH
95 fMessageLabel.setLayoutData(gridData);
96 setErrorMessage(fErrorMessage);
73005152
BH
97
98 return parent;
99 }
c8422608 100
df0b8ff4
BH
101 /*
102 * (non-Javadoc)
103 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
104 */
73005152
BH
105 @Override
106 protected void okPressed() {
107
c8422608 108 if (fDialogUI.okPressed()) {
73005152 109 super.okPressed();
c8422608 110 }
73005152
BH
111 }
112
df0b8ff4
BH
113 /*
114 * (non-Javadoc)
115 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
116 */
73005152
BH
117 @Override
118 protected void createButtonsForButtonBar(Composite parent) {
119
120 super.createButtonsForButtonBar(parent);
121 createButton(parent, IDialogConstants.CLIENT_ID, SDMessages._115, false);
122
123 getButton(IDialogConstants.CLIENT_ID).addSelectionListener(new SelectionListener() {
df0b8ff4
BH
124 /*
125 * (non-Javadoc)
126 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
127 */
73005152
BH
128 @Override
129 public void widgetSelected(SelectionEvent e) {
130
eb63f5ff 131 fDialogUI.printButtonSelected();
73005152 132 }
df0b8ff4
BH
133 /*
134 * (non-Javadoc)
135 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
136 */
73005152
BH
137 @Override
138 public void widgetDefaultSelected(SelectionEvent e) {
139 }
73005152
BH
140 });
141
142 updateButtons();
143 }
144
df0b8ff4
BH
145 /**
146 * @return the dialog UI
147 */
73005152 148 public SDPrintDialogUI getDialogUI() {
eb63f5ff 149 return fDialogUI;
73005152
BH
150 }
151
df0b8ff4
BH
152 /**
153 * Sets the error message.
c8422608 154 *
df0b8ff4
BH
155 * @param message error message to set
156 */
73005152 157 public void setErrorMessage(String message) {
eb63f5ff
BH
158 fErrorMessage = message;
159 if (fMessageLabel != null) {
160 if (fErrorMessage == null) {
161 fMessageLabel.setText(""); //$NON-NLS-1$
73005152 162 } else {
eb63f5ff 163 fMessageLabel.setText(fErrorMessage);
73005152
BH
164 }
165 }
166 }
167
df0b8ff4
BH
168 /**
169 * Sets the page complete flag.
170 * @param complete whether page is complete or not
171 */
73005152 172 public void setPageComplete(boolean complete) {
eb63f5ff 173 fIsPageComplete = complete;
73005152
BH
174 updateButtons();
175 }
176
df0b8ff4
BH
177 /**
178 * Udates the button enable state.
179 */
73005152
BH
180 public void updateButtons() {
181 Button okButton = getButton(IDialogConstants.OK_ID);
eb63f5ff 182 if (fIsPageComplete) {
73005152
BH
183 if (okButton != null) {
184 okButton.setEnabled(true);
185 }
186 } else {
187 if (okButton != null) {
188 okButton.setEnabled(false);
189 }
190 }
191 }
192
193}
This page took 0.042437 seconds and 5 git commands to generate.