Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 195026
Collapse All | Expand All

(-)src-uml2sd/org/eclipse/hyades/uml2sd/util/SDMessages.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 154-159 Link Here
154
	public static String _132;
154
	public static String _132;
155
	public static String _133;
155
	public static String _133;
156
	public static String _134;
156
	public static String _134;
157
	public static String _135;
157
158
158
	static {
159
	static {
159
		NLS.initializeMessages(BUNDLE_NAME, SDMessages.class);
160
		NLS.initializeMessages(BUNDLE_NAME, SDMessages.class);
(-)src-uml2sd/org/eclipse/hyades/uml2sd/util/messages.properties (+2 lines)
Lines 156-158 Link Here
156
_133 = \u00B5s
156
_133 = \u00B5s
157
157
158
_134  = Min Time {0} \n\nCurrent Time {1} \n\nMaxTime {2}
158
_134  = Min Time {0} \n\nCurrent Time {1} \n\nMaxTime {2}
159
160
_135 = There is no default printer. Click Printer button first and select a printer.
(-)src-uml2sd/org/eclipse/hyades/uml2sd/util/SDPrintDialog.java (-4 / +51 lines)
Lines 1-5 Link Here
1
/********************************************************************** 
1
/********************************************************************** 
2
 * Copyright (c) 2005, 2006  IBM Corporation and others. 
2
 * Copyright (c) 2005, 2007  IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
5
 * which accompanies this distribution, and is available at 
Lines 15-24 Link Here
15
import org.eclipse.hyades.uml2sd.ui.view.SDWidget;
15
import org.eclipse.hyades.uml2sd.ui.view.SDWidget;
16
import org.eclipse.jface.dialogs.Dialog;
16
import org.eclipse.jface.dialogs.Dialog;
17
import org.eclipse.jface.dialogs.IDialogConstants;
17
import org.eclipse.jface.dialogs.IDialogConstants;
18
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.events.SelectionListener;
20
import org.eclipse.swt.events.SelectionListener;
21
import org.eclipse.swt.layout.GridData;
22
import org.eclipse.swt.widgets.Button;
20
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Control;
24
import org.eclipse.swt.widgets.Control;
25
import org.eclipse.swt.widgets.Label;
22
import org.eclipse.swt.widgets.Shell;
26
import org.eclipse.swt.widgets.Shell;
23
27
24
28
Lines 33-44 Link Here
33
	private SDWidget view;
37
	private SDWidget view;
34
38
35
	private SDPrintDialogUI dialogUI;
39
	private SDPrintDialogUI dialogUI;
36
	
40
41
	private String errorMessage = null;
42
	private Label messageLabel = null;
43
	private boolean isPageComplete = true;
44
37
	public SDPrintDialog(Shell s, SDWidget v) {
45
	public SDPrintDialog(Shell s, SDWidget v) {
38
		super(s);
46
		super(s);
39
		view = v;
47
		view = v;
40
		
48
		
41
		dialogUI = new SDPrintDialogUI(s, view);		
49
		dialogUI = new SDPrintDialogUI(s, view);		
50
		dialogUI.setParentDialog(this);
42
	}
51
	}
43
52
44
	protected Control createDialogArea(Composite p) {
53
	protected Control createDialogArea(Composite p) {
Lines 47-53 Link Here
47
		Composite parent = (Composite) super.createDialogArea(p);
56
		Composite parent = (Composite) super.createDialogArea(p);
48
		
57
		
49
		dialogUI.createDialogArea(parent);
58
		dialogUI.createDialogArea(parent);
50
		
59
60
		// bug 195026
61
		messageLabel = new Label(parent, SWT.NONE);
62
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
63
		gridData.horizontalSpan = 6;
64
		messageLabel.setLayoutData(gridData);
65
		setErrorMessage(errorMessage);
66
51
		return parent;
67
		return parent;
52
	}
68
	}
53
69
Lines 80-89 Link Here
80
			}
96
			}
81
			
97
			
82
		});
98
		});
83
		
99
100
		updateButtons();
84
	}
101
	}
85
102
86
	public SDPrintDialogUI getDialogUI() {
103
	public SDPrintDialogUI getDialogUI() {
87
		return dialogUI;
104
		return dialogUI;
88
	}
105
	}
106
107
	public void setErrorMessage(String message) {
108
		errorMessage = message;
109
		if (messageLabel != null) {
110
			if (errorMessage == null) {
111
				messageLabel.setText(""); //$NON-NLS-1$
112
			} else {
113
				messageLabel.setText(errorMessage);
114
			}
115
		}
116
	}
117
118
	public void setPageComplete(boolean complete) {
119
		isPageComplete = complete;
120
		updateButtons();
121
	}
122
123
	public void updateButtons() {
124
		Button okButton = getButton(IDialogConstants.OK_ID);
125
		if (isPageComplete) {
126
			if (okButton != null) {
127
				okButton.setEnabled(true);
128
			}
129
		} else {
130
			if (okButton != null) {
131
				okButton.setEnabled(false);
132
			}
133
		}
134
	}
135
89
}
136
}
(-)src-uml2sd/org/eclipse/hyades/uml2sd/util/SDPrintDialogUI.java (-36 / +87 lines)
Lines 1-5 Link Here
1
/********************************************************************** 
1
/********************************************************************** 
2
 * Copyright (c) 2005, 2006  IBM Corporation and others. 
2
 * Copyright (c) 2005, 2007  IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
5
 * which accompanies this distribution, and is available at 
Lines 18-23 Link Here
18
import org.eclipse.hyades.uml2sd.ui.view.NGC;
18
import org.eclipse.hyades.uml2sd.ui.view.NGC;
19
import org.eclipse.hyades.uml2sd.ui.view.SDWidget;
19
import org.eclipse.hyades.uml2sd.ui.view.SDWidget;
20
import org.eclipse.jface.dialogs.MessageDialog;
20
import org.eclipse.jface.dialogs.MessageDialog;
21
import org.eclipse.jface.wizard.WizardPage;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.events.FocusEvent;
23
import org.eclipse.swt.events.FocusEvent;
23
import org.eclipse.swt.events.FocusListener;
24
import org.eclipse.swt.events.FocusListener;
Lines 132-138 Link Here
132
	int test=3;
133
	int test=3;
133
	
134
	
134
	public static int r=0;
135
	public static int r=0;
135
	
136
137
	// bug 195026
138
	private WizardPage parentWizardPage = null;
139
	private SDPrintDialog parentDialog = null;
140
136
	private class LocalSD extends SDWidget
141
	private class LocalSD extends SDWidget
137
	{
142
	{
138
143
Lines 500-508 Link Here
500
		setShell(s);
505
		setShell(s);
501
		view = v;
506
		view = v;
502
		showPrintButton = showPrintBtn;
507
		showPrintButton = showPrintBtn;
503
		
508
504
		printerData=Printer.getDefaultPrinterData();
509
		printerData = Printer.getDefaultPrinterData();
505
		printerData.scope = PrinterData.SELECTION;	
510
		if (printerData != null) {
511
			printerData.scope = PrinterData.SELECTION;
512
		}
506
513
507
		pagesList = new int[0];
514
		pagesList = new int[0];
508
515
Lines 823-829 Link Here
823
			});
830
			});
824
		}
831
		}
825
832
826
		
833
		updatePrinterStatus();
834
827
		return parent;
835
		return parent;
828
	}
836
	}
829
837
Lines 943-977 Link Here
943
		float cw =overviewCanvas.getContentsWidth()/overviewCanvas.zoomValue;
951
		float cw =overviewCanvas.getContentsWidth()/overviewCanvas.zoomValue;
944
		float ch =overviewCanvas.getContentsHeight()/overviewCanvas.zoomValue;
952
		float ch =overviewCanvas.getContentsHeight()/overviewCanvas.zoomValue;
945
		try {
953
		try {
946
			Printer printer = new Printer(printerData);
954
			if (printerData == null) {
947
			if (setHPagesNumber.getSelection()) {		
955
				stepX = 0;
948
				nbPages = Integer.valueOf(hPagesNum.getText()).intValue();
956
				stepY = 0;
949
				float z1 = (float)view.getContentsWidth() / (cw);
957
				nbPages = 0;
950
				float z2 = printer.getClientArea().width
958
				zoomFactor = 0;
951
						/ ((float)view.getContentsWidth() / nbPages);
959
			} else {
952
960
				Printer printer = new Printer(printerData);
953
				stepY = printer.getClientArea().height / z1 / z2;
961
				if (setHPagesNumber.getSelection()) {
954
				stepX = cw / nbPages;
962
					nbPages = Integer.valueOf(hPagesNum.getText()).intValue();
955
			} else if (setVPagesNumber.getSelection()) {
963
					float z1 = (float) view.getContentsWidth() / (cw);
956
				nbPages = Integer.valueOf(vPagesNum.getText()).intValue();
964
					float z2 = printer.getClientArea().width / ((float) view.getContentsWidth() / nbPages);
957
				float z1 = (float)view.getContentsHeight() / (ch);
965
958
				float z2 = printer.getClientArea().height
966
					stepY = printer.getClientArea().height / z1 / z2;
959
						/ ((float)view.getContentsHeight() / nbPages);
967
					stepX = cw / nbPages;
960
				stepX = printer.getClientArea().width / z1 / z2;
968
				} else if (setVPagesNumber.getSelection()) {
961
				stepY = ch / nbPages;
969
					nbPages = Integer.valueOf(vPagesNum.getText()).intValue();
962
			}
970
					float z1 = (float) view.getContentsHeight() / (ch);
963
			else
971
					float z2 = printer.getClientArea().height / ((float) view.getContentsHeight() / nbPages);
964
			{
972
					stepX = printer.getClientArea().width / z1 / z2;
965
				float z1 = view.getContentsWidth() / (cw);
973
					stepY = ch / nbPages;
966
				stepX= ((float)view.getVisibleWidth() /z1 );
974
				} else {
967
				nbPages=Math.round(cw/stepX);
975
					float z1 = view.getContentsWidth() / (cw);
968
				if (nbPages==0)
976
					stepX = ((float) view.getVisibleWidth() / z1);
969
					nbPages=1;
977
					nbPages = Math.round(cw / stepX);
970
				int pw=printer.getClientArea().width;
978
					if (nbPages == 0)
971
				int ph=printer.getClientArea().height;
979
						nbPages = 1;
972
				float z2 = pw
980
					int pw = printer.getClientArea().width;
973
					/ ((float)view.getContentsWidth() / nbPages);
981
					int ph = printer.getClientArea().height;
974
				stepY = ((float)ph / z1 / z2);
982
					float z2 = pw / ((float) view.getContentsWidth() / nbPages);
983
					stepY = ((float) ph / z1 / z2);
984
				}
975
			}
985
			}
976
		} catch (Exception e) {
986
		} catch (Exception e) {
977
			stepX=stepY=nbPages=0;
987
			stepX=stepY=nbPages=0;
Lines 1135-1141 Link Here
1135
			printer.setStartPage(from);
1145
			printer.setStartPage(from);
1136
			printer.setEndPage(to);
1146
			printer.setEndPage(to);
1137
		}
1147
		}
1138
		printerData=printer.open();
1148
1149
		PrinterData newPrinterData = printer.open();
1150
		if (newPrinterData != null) {
1151
			printerData = newPrinterData;
1152
		}
1153
		updatePrinterStatus();
1154
1139
		if (printer.getScope()==PrinterData.ALL_PAGES)
1155
		if (printer.getScope()==PrinterData.ALL_PAGES)
1140
		{
1156
		{
1141
			allPages.setSelection(true);
1157
			allPages.setSelection(true);
Lines 1159-1162 Link Here
1159
		computeStepXY();
1175
		computeStepXY();
1160
		overviewCanvas.redraw();
1176
		overviewCanvas.redraw();
1161
	}
1177
	}
1178
1179
	public void setParentWizardPage(WizardPage parent) {
1180
		parentWizardPage = parent;
1181
	}
1182
1183
	public void setParentDialog(SDPrintDialog parent) {
1184
		parentDialog = parent;
1185
	}
1186
1187
	protected void updatePrinterStatus() {
1188
		if (parentWizardPage != null) {
1189
			// used in the wizard dialog
1190
			if (printerData == null) {
1191
				// show error message and disable Finish button
1192
				parentWizardPage.setErrorMessage(SDMessages._135);
1193
				parentWizardPage.setPageComplete(false);
1194
			} else {
1195
				// clear error message and enable Finish button
1196
				parentWizardPage.setErrorMessage(null);
1197
				parentWizardPage.setPageComplete(true);
1198
			}
1199
		} else if (parentDialog != null) {
1200
			// used in the print dialog
1201
			if (printerData == null) {
1202
				// show error message and disable OK button
1203
				parentDialog.setErrorMessage(SDMessages._135);
1204
				parentDialog.setPageComplete(false);
1205
			} else {
1206
				// clear error message and enable OK button
1207
				parentDialog.setErrorMessage(null);
1208
				parentDialog.setPageComplete(true);
1209
			}
1210
		}
1211
	}
1212
1162
}
1213
}
(-)src-uml2sd/org/eclipse/hyades/uml2sd/internal/reports/PrintSDViewReportWizard.java (-11 / +2 lines)
Lines 1-5 Link Here
1
/* ***********************************************************
1
/* ***********************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 81-96 Link Here
81
    protected void addReportPages() throws Exception {
81
    protected void addReportPages() throws Exception {
82
        addPage(reportPage);
82
        addPage(reportPage);
83
    }
83
    }
84
  
84
85
    /**
86
     * @see org.eclipse.jface.wizard.IWizard#canFinish()
87
     */
88
    public boolean canFinish() {
89
    	
90
    	return true;
91
    	
92
     }
93
    
94
    /**
85
    /**
95
     * 
86
     * 
96
     * @param viewer
87
     * @param viewer
(-)src-uml2sd/org/eclipse/hyades/uml2sd/internal/reports/PrintSDViewReportPage.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/********************************************************************** 
1
/********************************************************************** 
2
 * Copyright (c) 2005, 2006  IBM Corporation and others. 
2
 * Copyright (c) 2005, 2007  IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
5
 * which accompanies this distribution, and is available at 
Lines 39-45 Link Here
39
	public void createControl(Composite parent) {
39
	public void createControl(Composite parent) {
40
		
40
		
41
		dialogUI = new SDPrintDialogUI(getShell(), view.getSDWidget(), true);	
41
		dialogUI = new SDPrintDialogUI(getShell(), view.getSDWidget(), true);	
42
		
42
		dialogUI.setParentWizardPage(this);
43
43
        Composite composite = new Composite(parent, SWT.NONE);
44
        Composite composite = new Composite(parent, SWT.NONE);
44
        GridLayout layout = new GridLayout();
45
        GridLayout layout = new GridLayout();
45
        composite.setLayout(layout);
46
        composite.setLayout(layout);

Return to bug 195026