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
21
22
23 import org.vectomatic.client.rep.RepApplication;
24 import org.vectomatic.client.rep.command.ICommand;
25 import org.vectomatic.client.rep.command.ResizeDrawingCommand;
26 import org.vectomatic.client.rep.view.DrawingView;
27 import org.vectomatic.common.rpc.Representation;
28
29 import com.google.gwt.user.client.ui.MenuItem;
30
31 public class ResizeController extends ControllerBase {
32 private RepresentationController _repController;
33 private ResizeDrawingPanel _panel;
34
35 public ResizeController(RepApplication app, RepresentationController repController) {
36 super(app);
37 _repController = repController;
38 _panel = new ResizeDrawingPanel(this);
39 }
40
41 @Override
42 public void activate(DrawingView view) {
43 Representation rep = _repController.getCurrentRep();
44 _panel.show(rep.getWidth(), rep.getHeight());
45 }
46
47 public MenuItem getResizeMenuItem(DrawingView view) {
48 return new ControllerContextItem(view, _app.getConstants().resizeDrawingCommand(), this);
49 }
50
51 public void resize(int width, int height) {
52 Representation rep = _repController.getCurrentRep();
53 if (rep.getWidth() != width || rep.getHeight() != height) {
54 ICommand command = new ResizeDrawingCommand(_app, _repController, width, height);
55 command.execute();
56 _app.getHistory().addCommand(command);
57 }
58 }
59
60 }