1
1
/**********************************************************************
2
* Copyright (c) 2005, 2008 IBM Corporation and others.
3
* Copyright (c) 2011, 2012 Ericsson.
2
* Copyright (c) 2005, 2013 IBM Corporation, Ericsson
5
3
* All rights reserved. This program and the accompanying materials
6
4
* are made available under the terms of the Eclipse Public License v1.0
7
5
* which accompanies this distribution, and is available at
8
6
* http://www.eclipse.org/legal/epl-v10.html
11
* IBM - Initial API and implementation
12
* Bernd Hufmann - Updated for TMF
9
* IBM - Initial API and implementation
10
* Bernd Hufmann - Updated for TMF
13
11
**********************************************************************/
14
13
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs;
16
15
import java.text.MessageFormat;
67
66
* The set horizontal pages number.
69
protected Button fSetHPagesNumber;
68
private Button fSetHPagesNumber;
71
70
* The set vertical pages number.
73
protected Button fSetVPagesNumber;
72
private Button fSetVPagesNumber;
75
74
* Flag whether to use current zoom or not.
77
protected Button fUseCurrentZoom;
76
private Button fUseCurrentZoom;
79
78
* Flag whether to print all pages or not
81
protected Button fAllPages;
80
private Button fAllPages;
83
82
* Flag whether to print current page only
85
protected Button fCurrentPage;
84
private Button fCurrentPage;
87
86
* Button to select a page list.
89
protected Button fPageList;
88
private Button fPageList;
91
90
* Button to select a page range.
93
protected Button fPageRange;
92
private Button fPageRange;
95
94
* Text field to enter from page.
97
protected Text fFromPage;
96
private Text fFromPage;
99
98
* Text field to enter to page.
101
protected Text fToPage;
100
private Text fToPage;
103
102
* The sequence diagram widget reference.
105
protected SDWidget fSdView;
104
private SDWidget fSdView;
107
106
* Text field for number of horizontal pages
109
protected Text fHorPagesNum;
108
private Text fHorPagesNum;
111
110
* Text field for number of vertical pages
113
protected Text fVertPagesNum;
112
private Text fVertPagesNum;
115
114
* Text field for toal number of pages
117
protected Text fTotalPages;
116
private Text fTotalPages;
119
118
* A modify listener implementation to handle modifications.
121
protected ModifyListener fModifyListener;
120
private ModifyListener fModifyListener;
123
122
* A selection listener implementation to handle selections.
125
protected SelectionListener fSelectionListener;
124
private SelectionListener fSelectionListener;
127
126
* Local canvas displaying sequence diagram overview.
129
protected LocalSD fOverviewCanvas;
128
private LocalSD fOverviewCanvas;
131
130
* Number of pages
133
protected int fNbPages = 0;
132
private int fNbPages = 0;
135
134
* Number of selected pages.
137
protected int fPageNum = -1;
136
private int fPageNum = -1;
139
138
* Number of first page.
141
protected int fFirstPage = -1;
140
private int fFirstPage = -1;
143
142
* List of pages to print.
145
protected int fPagesList[];
147
* Values for dividing sequence diagram into pages.
149
protected float fStepX, fStepY, sTX, sTY;
144
private int fPagesList[];
147
* Value for dividing the sequence diagram into pages
149
private float fStepX;
152
* Value for dividing the sequence diagram into pages
154
private float fStepY;
157
* Value for dividing the sequence diagram into pages
162
* Value for dividing the sequence diagram into pages
151
167
* Page which to print from.
155
171
* Page which to print to.
159
175
* Flag for enabling multi-selection.
161
protected boolean fMultiSelection = false;
177
private boolean fMultiSelection = false;
163
179
* Flag for enabling area selection.
165
protected boolean fAreaSelection = false;
181
private boolean fAreaSelection = false;
167
183
* Flag for printing all.
169
protected boolean fPrintAll;
185
private boolean fPrintAll;
171
187
* Flag for printing current page only.
173
protected boolean fPrintCurrent;
189
private boolean fPrintCurrent;
175
191
* Flag for printing a selection of pages.
177
protected boolean fPrintSelection;
193
private boolean fPrintSelection;
179
195
* Flag for printing a range of pages.
181
protected boolean fPrintRange;
197
private boolean fPrintRange;
183
199
* Number of selected rows
185
protected int fNbRows;
187
203
* Number of selected lines
189
protected int fNbLines;
205
private int fNbLines;
191
207
* The zoom factor.
193
protected float fZoomFactor;
209
private float fZoomFactor;
195
211
* The printer data reference.
197
protected PrinterData fPrinterData;
213
private PrinterData fPrinterData;
199
215
* The diagram tooltip to show if necessary.
201
protected DiagramToolTip fToolTip = null;
217
private DiagramToolTip fToolTip = null;
203
219
* Label for current selection.
205
protected Label fCurrentSelection;
221
private Label fCurrentSelection;
207
223
* The shell reference.
209
protected Shell fShell;
225
private Shell fShell;
211
227
* Button to open printer dialog from OS.
213
protected Button fPrinterDialog;
229
private Button fPrinterDialog;
215
231
* Flag for showing print button.
217
protected boolean fShowPrintButton;
233
private boolean fShowPrintButton;
221
protected int fTest = 3;
237
private int fTest = 3;
223
239
* Parent wizard page if used as wizard
225
protected WizardPage fParentWizardPage = null;
241
private WizardPage fParentWizardPage = null;
227
243
* Reference to parent print dialog.
229
protected SDPrintDialog fParentDialog = null;
245
private SDPrintDialog fParentDialog = null;
231
247
// ------------------------------------------------------------------------
311
315
Image toDel = over;
312
316
if (fOverviewCanvas.isFocusControl()) {
313
over = new Image(super.getShell().getDisplay(), drawRegionSelected(toDel, new Rectangle(contentsToViewX((int) (row * stepX * fOverviewCanvas.fZoomValue)), contentsToViewY((int) (line * stepY * fOverviewCanvas.fZoomValue)),
314
((int) (stepX * fOverviewCanvas.fZoomValue)), ((int) (stepY * fOverviewCanvas.fZoomValue))), new RGB(0, 0, 128)));
317
over = new Image(super.getShell().getDisplay(), drawRegionSelected(toDel, new Rectangle(contentsToViewX((int) (row * stepX * fOverviewCanvas.getZoomValue())), contentsToViewY((int) (line * stepY * fOverviewCanvas.getZoomValue())),
318
((int) (stepX * fOverviewCanvas.getZoomValue())), ((int) (stepY * fOverviewCanvas.getZoomValue()))), new RGB(0, 0, 128)));
316
over = new Image(super.getShell().getDisplay(), drawRegionSelected(toDel, new Rectangle(contentsToViewX((int) (row * stepX * fOverviewCanvas.fZoomValue)), contentsToViewY((int) (line * stepY * fOverviewCanvas.fZoomValue)),
317
((int) (stepX * fOverviewCanvas.fZoomValue)), ((int) (stepY * fOverviewCanvas.fZoomValue))), new RGB(221, 208, 200)));
320
over = new Image(super.getShell().getDisplay(), drawRegionSelected(toDel, new Rectangle(contentsToViewX((int) (row * stepX * fOverviewCanvas.getZoomValue())), contentsToViewY((int) (line * stepY * fOverviewCanvas.getZoomValue())),
321
((int) (stepX * fOverviewCanvas.getZoomValue())), ((int) (stepY * fOverviewCanvas.getZoomValue()))), new RGB(221, 208, 200)));
797
764
parent.setLayout(parentLayout);
799
766
Group g1 = new Group(parent, SWT.SHADOW_NONE);
800
g1.setText(SDMessages._113);
767
g1.setText(Messages.SequenceDiagram_ZoomOption);
801
768
g1.setLayoutData(newGridData(3));
802
769
GridLayout g1layout = new GridLayout();
803
770
g1layout.numColumns = 2;
804
771
g1.setLayout(g1layout);
806
773
fUseCurrentZoom = new Button(g1, SWT.RADIO);
807
fUseCurrentZoom.setText(SDMessages._112);
774
fUseCurrentZoom.setText(Messages.SequenceDiagram_UseCurrentZoom);
808
775
fUseCurrentZoom.setLayoutData(newGridData(2));
809
776
fUseCurrentZoom.addSelectionListener(fSelectionListener);
811
778
fSetHPagesNumber = new Button(g1, SWT.RADIO);
812
fSetHPagesNumber.setText(SDMessages._110);
779
fSetHPagesNumber.setText(Messages.SequenceDiagram_NumberOfHorizontalPages);
813
780
fSetHPagesNumber.setLayoutData(newGridData(1));
814
781
fSetHPagesNumber.addSelectionListener(fSelectionListener);
886
853
fCurrentSelection.setLayoutData(newGridData(1));
888
855
Group g3 = new Group(parent, SWT.SHADOW_NONE);
889
g3.setText(SDMessages._118);
856
g3.setText(Messages.SequenceDiagram_PrintRange);
890
857
g3.setLayoutData(newGridData(3));
891
858
GridLayout g3layout = new GridLayout();
892
859
g3layout.numColumns = 4;
893
860
g3.setLayout(g3layout);
895
862
fAllPages = new Button(g3, SWT.RADIO);
896
fAllPages.setText(SDMessages._108);
863
fAllPages.setText(Messages.SequenceDiagram_AllPages);
897
864
fAllPages.setLayoutData(newGridData(4));
898
865
fAllPages.addSelectionListener(fSelectionListener);
900
867
fCurrentPage = new Button(g3, SWT.RADIO);
901
fCurrentPage.setText(SDMessages._107);
868
fCurrentPage.setText(Messages.SequenceDiagram_CurrentView);
902
869
fCurrentPage.setLayoutData(newGridData(4));
903
870
fCurrentPage.setEnabled(true);
904
871
fCurrentPage.setSelection(true);
905
872
fCurrentPage.addSelectionListener(fSelectionListener);
907
874
fPageList = new Button(g3, SWT.RADIO);
908
fPageList.setText(SDMessages._106);
875
fPageList.setText(Messages.SequenceDiagram_SelectedPages);
909
876
fPageList.setLayoutData(newGridData(4));
910
877
fPageList.addSelectionListener(fSelectionListener);
912
879
fPageRange = new Button(g3, SWT.RADIO);
913
fPageRange.setText(SDMessages._103);
880
fPageRange.setText(Messages.SequenceDiagram_FromPage);
914
881
fPageRange.setLayoutData(newGridData(1));
915
882
fPageRange.addSelectionListener(fSelectionListener);
917
884
fFromPage = new Text(g3, SWT.SINGLE | SWT.BORDER);
919
886
Label labelTo = new Label(g3, SWT.CENTER);
920
labelTo.setText(SDMessages._105);
887
labelTo.setText(Messages.SequenceDiagram_to);
922
889
fToPage = new Text(g3, SWT.SINGLE | SWT.BORDER);
924
891
fToolTip = new DiagramToolTip(fOverviewCanvas);
926
893
fOverviewCanvas.getViewControl().addMouseTrackListener(new MouseTrackListener() {
929
* @see org.eclipse.swt.events.MouseTrackListener#mouseEnter(org.eclipse.swt.events.MouseEvent)
932
895
public void mouseEnter(MouseEvent e) {
933
896
fToolTip.hideToolTip();
938
* @see org.eclipse.swt.events.MouseTrackListener#mouseExit(org.eclipse.swt.events.MouseEvent)
941
900
public void mouseExit(MouseEvent e) {
942
901
fToolTip.hideToolTip();
947
* @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent)
950
905
public void mouseHover(MouseEvent e) {
951
int x1 = (int) (fOverviewCanvas.viewToContentsX(e.x) / fOverviewCanvas.fZoomValue / fStepX);
952
int x2 = (int) (fOverviewCanvas.viewToContentsY(e.y) / fOverviewCanvas.fZoomValue / fStepY);
906
int x1 = (int) (fOverviewCanvas.viewToContentsX(e.x) / fOverviewCanvas.getZoomValue() / fStepX);
907
int x2 = (int) (fOverviewCanvas.viewToContentsY(e.y) / fOverviewCanvas.getZoomValue() / fStepY);
953
908
int num = x1 + x2 * getNbRow() + 1;
954
909
if (num > maxNumOfPages()) {
1051
989
fFrom = Integer.valueOf(fFromPage.getText()).intValue();
1052
990
fTo = Integer.valueOf(fToPage.getText()).intValue();
1053
991
if (fFrom > maxNumOfPages() || fTo > maxNumOfPages() || fFrom <= 0 || fTo <= 0) {
1054
MessageDialog.openError(getShell(), SDMessages._98, SDMessages._99);
992
MessageDialog.openError(getShell(), Messages.SequenceDiagram_Error, Messages.SequenceDiagram_InvalidRange);
1057
995
} else if (fSetHPagesNumber.getSelection() && fNbPages <= 0) {
1058
MessageDialog.openError(getShell(), SDMessages._98, SDMessages._101);
996
MessageDialog.openError(getShell(), Messages.SequenceDiagram_Error, Messages.SequenceDiagram_InvalidNbHorizontal);
1060
998
} else if (fSetVPagesNumber.getSelection() && fNbPages <= 0) {
1061
MessageDialog.openError(getShell(), SDMessages._98, SDMessages._100);
999
MessageDialog.openError(getShell(), Messages.SequenceDiagram_Error, Messages.SequenceDiagram_InvalidNbVertical);
1063
1001
} else if (fPrintSelection && getPageList().length <= 0) {
1064
MessageDialog.openError(getShell(), SDMessages._98, SDMessages._102);
1002
MessageDialog.openError(getShell(), Messages.SequenceDiagram_Error, Messages.SequenceDiagram_NoPageSelected);
1068
1006
} catch (Exception e) {
1069
MessageDialog.openError(getShell(), SDMessages._98, SDMessages._99);
1007
MessageDialog.openError(getShell(), Messages.SequenceDiagram_Error, Messages.SequenceDiagram_InvalidRange);