Copyright header update, 2015 edition
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / views / uml2sd / dialogs / SDPrintDialog.java
CommitLineData
c8422608 1/**********************************************************************
ed902a2b 2 * Copyright (c) 2005, 2014 IBM Corporation, Ericsson
c8422608
AM
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
2bdf0193 13package org.eclipse.tracecompass.tmf.ui.views.uml2sd.dialogs;
73005152
BH
14
15import org.eclipse.jface.dialogs.Dialog;
16import org.eclipse.jface.dialogs.IDialogConstants;
73005152
BH
17import org.eclipse.swt.SWT;
18import org.eclipse.swt.events.SelectionEvent;
19import org.eclipse.swt.events.SelectionListener;
20import org.eclipse.swt.layout.GridData;
21import org.eclipse.swt.widgets.Button;
22import org.eclipse.swt.widgets.Composite;
23import org.eclipse.swt.widgets.Control;
24import org.eclipse.swt.widgets.Label;
25import org.eclipse.swt.widgets.Shell;
2bdf0193
AM
26import org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDWidget;
27import org.eclipse.tracecompass.tmf.ui.views.uml2sd.util.Messages;
73005152
BH
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 */
cab6c8ff 43 private SDWidget fSdView;
df0b8ff4
BH
44 /**
45 * Sequence dialog print dialog UI
46 */
cab6c8ff 47 private SDPrintDialogUI fDialogUI;
df0b8ff4
BH
48 /**
49 * Error message to display.
50 */
cab6c8ff 51 private String fErrorMessage = null;
df0b8ff4
BH
52 /**
53 * A message label.
54 */
cab6c8ff 55 private Label fMessageLabel = null;
df0b8ff4
BH
56 /**
57 * Flag whether the page is complete or not
58 */
cab6c8ff 59 private 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 // ------------------------------------------------------------------------
11252342 81
73005152
BH
82 @Override
83 protected Control createDialogArea(Composite p) {
92330441 84 p.getShell().setText(Messages.SequenceDiagram_Print);
73005152
BH
85 Composite parent = (Composite) super.createDialogArea(p);
86
eb63f5ff 87 fDialogUI.createDialogArea(parent);
73005152 88
eb63f5ff 89 fMessageLabel = new Label(parent, SWT.NONE);
73005152
BH
90 GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
91 gridData.horizontalSpan = 6;
eb63f5ff
BH
92 fMessageLabel.setLayoutData(gridData);
93 setErrorMessage(fErrorMessage);
73005152
BH
94
95 return parent;
96 }
c8422608 97
73005152
BH
98 @Override
99 protected void okPressed() {
100
c8422608 101 if (fDialogUI.okPressed()) {
73005152 102 super.okPressed();
c8422608 103 }
73005152
BH
104 }
105
106 @Override
107 protected void createButtonsForButtonBar(Composite parent) {
108
109 super.createButtonsForButtonBar(parent);
92330441 110 createButton(parent, IDialogConstants.CLIENT_ID, Messages.SequenceDiagram_Printer, false);
73005152
BH
111
112 getButton(IDialogConstants.CLIENT_ID).addSelectionListener(new SelectionListener() {
73005152
BH
113 @Override
114 public void widgetSelected(SelectionEvent e) {
eb63f5ff 115 fDialogUI.printButtonSelected();
73005152 116 }
11252342 117
73005152
BH
118 @Override
119 public void widgetDefaultSelected(SelectionEvent e) {
120 }
73005152
BH
121 });
122
123 updateButtons();
124 }
125
df0b8ff4
BH
126 /**
127 * @return the dialog UI
128 */
73005152 129 public SDPrintDialogUI getDialogUI() {
eb63f5ff 130 return fDialogUI;
73005152
BH
131 }
132
df0b8ff4
BH
133 /**
134 * Sets the error message.
c8422608 135 *
df0b8ff4
BH
136 * @param message error message to set
137 */
73005152 138 public void setErrorMessage(String message) {
eb63f5ff
BH
139 fErrorMessage = message;
140 if (fMessageLabel != null) {
141 if (fErrorMessage == null) {
142 fMessageLabel.setText(""); //$NON-NLS-1$
73005152 143 } else {
eb63f5ff 144 fMessageLabel.setText(fErrorMessage);
73005152
BH
145 }
146 }
147 }
148
df0b8ff4
BH
149 /**
150 * Sets the page complete flag.
151 * @param complete whether page is complete or not
152 */
73005152 153 public void setPageComplete(boolean complete) {
eb63f5ff 154 fIsPageComplete = complete;
73005152
BH
155 updateButtons();
156 }
157
df0b8ff4
BH
158 /**
159 * Udates the button enable state.
160 */
73005152
BH
161 public void updateButtons() {
162 Button okButton = getButton(IDialogConstants.OK_ID);
eb63f5ff 163 if (fIsPageComplete) {
73005152
BH
164 if (okButton != null) {
165 okButton.setEnabled(true);
166 }
167 } else {
168 if (okButton != null) {
169 okButton.setEnabled(false);
170 }
171 }
172 }
173
174}
This page took 0.072496 seconds and 5 git commands to generate.