1 /**********************************************************************
2 * Copyright (c) 2005, 2013 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
.Messages
;
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 private SDWidget fSdView
;
45 * Sequence dialog print dialog UI
47 private SDPrintDialogUI fDialogUI
;
49 * Error message to display.
51 private String fErrorMessage
= null;
55 private Label fMessageLabel
= null;
57 * Flag whether the page is complete or not
59 private 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 protected Control
createDialogArea(Composite p
) {
84 p
.getShell().setText(Messages
.SequenceDiagram_Print
);
85 Composite parent
= (Composite
) super.createDialogArea(p
);
87 fDialogUI
.createDialogArea(parent
);
89 fMessageLabel
= new Label(parent
, SWT
.NONE
);
90 GridData gridData
= new GridData(SWT
.FILL
, SWT
.FILL
, true, true);
91 gridData
.horizontalSpan
= 6;
92 fMessageLabel
.setLayoutData(gridData
);
93 setErrorMessage(fErrorMessage
);
99 protected void okPressed() {
101 if (fDialogUI
.okPressed()) {
107 protected void createButtonsForButtonBar(Composite parent
) {
109 super.createButtonsForButtonBar(parent
);
110 createButton(parent
, IDialogConstants
.CLIENT_ID
, Messages
.SequenceDiagram_Printer
, false);
112 getButton(IDialogConstants
.CLIENT_ID
).addSelectionListener(new SelectionListener() {
114 public void widgetSelected(SelectionEvent e
) {
115 fDialogUI
.printButtonSelected();
119 public void widgetDefaultSelected(SelectionEvent e
) {
127 * @return the dialog UI
129 public SDPrintDialogUI
getDialogUI() {
134 * Sets the error message.
136 * @param message error message to set
138 public void setErrorMessage(String message
) {
139 fErrorMessage
= message
;
140 if (fMessageLabel
!= null) {
141 if (fErrorMessage
== null) {
142 fMessageLabel
.setText(""); //$NON-NLS-1$
144 fMessageLabel
.setText(fErrorMessage
);
150 * Sets the page complete flag.
151 * @param complete whether page is complete or not
153 public void setPageComplete(boolean complete
) {
154 fIsPageComplete
= complete
;
159 * Udates the button enable state.
161 public void updateButtons() {
162 Button okButton
= getButton(IDialogConstants
.OK_ID
);
163 if (fIsPageComplete
) {
164 if (okButton
!= null) {
165 okButton
.setEnabled(true);
168 if (okButton
!= null) {
169 okButton
.setEnabled(false);