1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.vectomatic.client.rep.controller;
19
20 import org.vectomatic.client.UIConstants;
21 import org.vectomatic.client.rep.RepApplication;
22 import org.vectomatic.client.rep.view.Spinner;
23
24 import com.google.gwt.user.client.ui.Button;
25 import com.google.gwt.user.client.ui.ClickListener;
26 import com.google.gwt.user.client.ui.DialogBox;
27 import com.google.gwt.user.client.ui.FlexTable;
28 import com.google.gwt.user.client.ui.FlowPanel;
29 import com.google.gwt.user.client.ui.HasHorizontalAlignment;
30 import com.google.gwt.user.client.ui.HasVerticalAlignment;
31 import com.google.gwt.user.client.ui.Label;
32 import com.google.gwt.user.client.ui.Widget;
33 import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
34
35
36
37
38 public class ResizeDrawingPanel extends DialogBox {
39 private Spinner _widthSpinner;
40 private Spinner _heightSpinner;
41
42 public ResizeDrawingPanel(final ResizeController resizeController) {
43 super(false, true);
44 UIConstants constants = RepApplication.app._constants;
45 setText(constants.dimensionsPanel());
46 Label widthLabel = new Label(constants.widthLabel());
47 _widthSpinner = new Spinner(1, 1024, 100);
48 Label heightLabel = new Label(constants.heightLabel());
49 _heightSpinner = new Spinner(1, 1024, 100);
50 FlexTable contentTable = new FlexTable();
51 contentTable.setWidget(0, 0, widthLabel);
52 contentTable.setWidget(0, 1, _widthSpinner);
53 contentTable.setWidget(1, 0, heightLabel);
54 contentTable.setWidget(1, 1, _heightSpinner);
55
56 Button okButton = new Button(constants.okButton());
57 okButton.setWidth("150px");
58 okButton.addClickListener(new ClickListener() {
59 public void onClick(Widget sender) {
60 resizeController.resize(_widthSpinner.getValue(), _heightSpinner.getValue());
61 hide();
62 }
63 });
64 Button cancelButton = new Button(constants.cancelButton());
65 cancelButton.setWidth("150px");
66 cancelButton.addClickListener(new ClickListener() {
67 public void onClick(Widget sender) {
68 hide();
69 }
70 });
71 FlexTable layoutTable = new FlexTable();
72 FlexCellFormatter cellFormatter = layoutTable.getFlexCellFormatter();
73 layoutTable.setWidget(0, 0, contentTable);
74 FlowPanel flowPanel = new FlowPanel();
75 flowPanel.add(cancelButton);
76 flowPanel.add(okButton);
77 layoutTable.setWidget(1, 0, flowPanel);
78 cellFormatter.setAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_MIDDLE);
79 setWidget(layoutTable);
80 }
81
82 public void show(int width, int height) {
83 _widthSpinner.setValue(width);
84 _heightSpinner.setValue(height);
85 show();
86 }
87 }