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