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.rep.RepApplication;
21 import org.vectomatic.client.rep.command.CommandHistory;
22 import org.vectomatic.client.rep.events.ICommandHistoryListener;
23 import org.vectomatic.client.rep.view.DrawingView;
24 import org.vectomatic.common.rpc.Representation;
25
26
27
28
29
30 public class RepresentationController extends ControllerBase implements ICommandHistoryListener {
31 private Representation _representation;
32 private boolean _persisted;
33 private ControllerPushButton _saveButton;
34
35 public RepresentationController(RepApplication app) {
36 super(app);
37 _app.getHistory().addCommandHistoryListener(this);
38
39 _representation = new Representation(Representation.DEFAULT_DRAWING_WIDTH, Representation.DEFAULT_DRAWING_HEIGHT, "");
40
41 _saveButton = new ControllerPushButton(_app.getView(), _app.getIcons().saveIcon().createImage(), _app.getIcons().saveDisabledIcon().createImage(), _app.getConstants().saveCommand(), new ControllerBase(_app) {
42 @Override
43 public void activate(DrawingView view) {
44 save();
45 }
46 });
47
48 refresh();
49 }
50
51 public void commandHistoryChange(CommandHistory commandHistory) {
52 refresh();
53 }
54
55 private void refresh() {
56 _saveButton.setEnabled(_persisted && _app.getHistory().needsSaving());
57 }
58
59 public void open() {
60 }
61
62 public void save() {
63 }
64
65 public ControllerPushButton getSaveButton() {
66 return _saveButton;
67 }
68
69 public Representation getCurrentRep() {
70 return _representation;
71 }
72
73 }