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
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
11 **********************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.dialogs
;
15 import org
.eclipse
.jface
.dialogs
.Dialog
;
16 import org
.eclipse
.jface
.dialogs
.IDialogConstants
;
17 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.SDWidget
;
18 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.util
.SDMessages
;
19 import org
.eclipse
.swt
.SWT
;
20 import org
.eclipse
.swt
.events
.SelectionEvent
;
21 import org
.eclipse
.swt
.events
.SelectionListener
;
22 import org
.eclipse
.swt
.layout
.GridData
;
23 import org
.eclipse
.swt
.widgets
.Button
;
24 import org
.eclipse
.swt
.widgets
.Composite
;
25 import org
.eclipse
.swt
.widgets
.Control
;
26 import org
.eclipse
.swt
.widgets
.Label
;
27 import org
.eclipse
.swt
.widgets
.Shell
;
30 * This class implements a dialog box for collecting printing information.
35 public class SDPrintDialog
extends Dialog
{
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
41 * The sequence dialog widget reference.
43 protected SDWidget fSdView
;
45 * Sequence dialog print dialog UI
47 protected SDPrintDialogUI fDialogUI
;
49 * Error message to display.
51 protected String fErrorMessage
= null;
55 protected Label fMessageLabel
= null;
57 * Flag whether the page is complete or not
59 protected boolean fIsPageComplete
= true;
61 // ------------------------------------------------------------------------
63 // ------------------------------------------------------------------------
65 * Standard constructor
67 * @param shell Shell reference
68 * @param viewer Sequence diagram widget reference
70 public SDPrintDialog(Shell shell
, SDWidget viewer
) {
74 fDialogUI
= new SDPrintDialogUI(shell
, fSdView
);
75 fDialogUI
.setParentDialog(this);
78 // ------------------------------------------------------------------------
80 // ------------------------------------------------------------------------
83 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
86 protected Control
createDialogArea(Composite p
) {
87 p
.getShell().setText(SDMessages
._114
);
88 Composite parent
= (Composite
) super.createDialogArea(p
);
90 fDialogUI
.createDialogArea(parent
);
92 fMessageLabel
= new Label(parent
, SWT
.NONE
);
93 GridData gridData
= new GridData(SWT
.FILL
, SWT
.FILL
, true, true);
94 gridData
.horizontalSpan
= 6;
95 fMessageLabel
.setLayoutData(gridData
);
96 setErrorMessage(fErrorMessage
);
103 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
106 protected void okPressed() {
108 if (fDialogUI
.okPressed()) {
115 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
118 protected void createButtonsForButtonBar(Composite parent
) {
120 super.createButtonsForButtonBar(parent
);
121 createButton(parent
, IDialogConstants
.CLIENT_ID
, SDMessages
._115
, false);
123 getButton(IDialogConstants
.CLIENT_ID
).addSelectionListener(new SelectionListener() {
126 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
129 public void widgetSelected(SelectionEvent e
) {
131 fDialogUI
.printButtonSelected();
135 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
138 public void widgetDefaultSelected(SelectionEvent e
) {
146 * @return the dialog UI
148 public SDPrintDialogUI
getDialogUI() {
153 * Sets the error message.
155 * @param message error message to set
157 public void setErrorMessage(String message
) {
158 fErrorMessage
= message
;
159 if (fMessageLabel
!= null) {
160 if (fErrorMessage
== null) {
161 fMessageLabel
.setText(""); //$NON-NLS-1$
163 fMessageLabel
.setText(fErrorMessage
);
169 * Sets the page complete flag.
170 * @param complete whether page is complete or not
172 public void setPageComplete(boolean complete
) {
173 fIsPageComplete
= complete
;
178 * Udates the button enable state.
180 public void updateButtons() {
181 Button okButton
= getButton(IDialogConstants
.OK_ID
);
182 if (fIsPageComplete
) {
183 if (okButton
!= null) {
184 okButton
.setEnabled(true);
187 if (okButton
!= null) {
188 okButton
.setEnabled(false);