Contribution for Bug352466: [TMF] Implement UML2 Sequence Diagram
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / util / SDPrintDialog.java
CommitLineData
73005152
BH
1/**********************************************************************
2 * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
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 * $Id: SDPrintDialog.java,v 1.3 2008/01/24 02:28:52 apnan Exp $
8 *
9 * Contributors:
10 * IBM - Initial API and implementation
11 * Bernd Hufmann - Updated for TMF
12 **********************************************************************/
13
14package org.eclipse.linuxtools.tmf.ui.views.uml2sd.util;
15
16import org.eclipse.jface.dialogs.Dialog;
17import org.eclipse.jface.dialogs.IDialogConstants;
18import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget;
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/**
30 * @author sveyrier
31 */
32public class SDPrintDialog extends Dialog {
33
34 protected SDWidget view;
35
36 protected SDPrintDialogUI dialogUI;
37
38 protected String errorMessage = null;
39 protected Label messageLabel = null;
40 protected boolean isPageComplete = true;
41
42 public SDPrintDialog(Shell s, SDWidget v) {
43 super(s);
44 view = v;
45
46 dialogUI = new SDPrintDialogUI(s, view);
47 dialogUI.setParentDialog(this);
48 }
49
50 @Override
51 protected Control createDialogArea(Composite p) {
52 p.getShell().setText(SDMessages._114);
53 Composite parent = (Composite) super.createDialogArea(p);
54
55 dialogUI.createDialogArea(parent);
56
57 // bug 195026
58 messageLabel = new Label(parent, SWT.NONE);
59 GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
60 gridData.horizontalSpan = 6;
61 messageLabel.setLayoutData(gridData);
62 setErrorMessage(errorMessage);
63
64 return parent;
65 }
66
67 @Override
68 protected void okPressed() {
69
70 if (dialogUI.okPressed())
71 super.okPressed();
72 }
73
74 @Override
75 protected void createButtonsForButtonBar(Composite parent) {
76
77 super.createButtonsForButtonBar(parent);
78 createButton(parent, IDialogConstants.CLIENT_ID, SDMessages._115, false);
79
80 getButton(IDialogConstants.CLIENT_ID).addSelectionListener(new SelectionListener() {
81
82 @Override
83 public void widgetSelected(SelectionEvent e) {
84
85 dialogUI.printButtonSelected();
86 }
87
88 @Override
89 public void widgetDefaultSelected(SelectionEvent e) {
90 }
91
92 });
93
94 updateButtons();
95 }
96
97 public SDPrintDialogUI getDialogUI() {
98 return dialogUI;
99 }
100
101 public void setErrorMessage(String message) {
102 errorMessage = message;
103 if (messageLabel != null) {
104 if (errorMessage == null) {
105 messageLabel.setText(""); //$NON-NLS-1$
106 } else {
107 messageLabel.setText(errorMessage);
108 }
109 }
110 }
111
112 public void setPageComplete(boolean complete) {
113 isPageComplete = complete;
114 updateButtons();
115 }
116
117 public void updateButtons() {
118 Button okButton = getButton(IDialogConstants.OK_ID);
119 if (isPageComplete) {
120 if (okButton != null) {
121 okButton.setEnabled(true);
122 }
123 } else {
124 if (okButton != null) {
125 okButton.setEnabled(false);
126 }
127 }
128 }
129
130}
This page took 0.041543 seconds and 5 git commands to generate.