1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| package org.ericmignot.modeler.gui.palette; |
19 |
| |
20 |
| import java.awt.event.MouseEvent; |
21 |
| |
22 |
| import org.ericmignot.modeler.action.CreationAction; |
23 |
| import org.ericmignot.modeler.data.BusinessObject; |
24 |
| import org.ericmignot.modeler.gui.workarea.Item; |
25 |
| import org.ericmignot.modeler.util.action.NotifyableAction; |
26 |
| |
27 |
| public abstract class AbstractCreationTool extends PaletteTool |
28 |
| { |
29 |
| |
30 |
0
| public final boolean shouldWorkAreaRegister()
|
31 |
| { |
32 |
0
| return true;
|
33 |
| } |
34 |
0
| public final boolean shouldItemRegister(Item item)
|
35 |
| { |
36 |
0
| return false;
|
37 |
| } |
38 |
0
| public final void registerItem(Item item){}
|
39 |
0
| public final void unregisterItem(Item item){}
|
40 |
| |
41 |
0
| public void mousePressed(MouseEvent e){e.consume();}
|
42 |
0
| public final void itemPressed(Item item, int x, int y) {}
|
43 |
| |
44 |
0
| public void mouseDragged(MouseEvent e) {e.consume();}
|
45 |
0
| public final void itemDragged(int x, int y) {}
|
46 |
| |
47 |
| |
48 |
0
| public void mouseReleased(MouseEvent e)
|
49 |
| { |
50 |
0
| if (e.isConsumed()) return;
|
51 |
0
| double zoom = this.getController().getZoomFactor();
|
52 |
0
| int x = (int) (e.getX() / zoom);
|
53 |
0
| int y = (int) (e.getY() / zoom);
|
54 |
| |
55 |
0
| this.workAreaReleased(x, y);
|
56 |
0
| this.getController().treatExecute(this.manageReleased());
|
57 |
0
| e.consume();
|
58 |
| |
59 |
| } |
60 |
0
| public final NotifyableAction manageReleased()
|
61 |
| { |
62 |
0
| CreationAction action = new CreationAction(
|
63 |
| this.getController().getModel(), this.buildBusinessObject()); |
64 |
0
| action.setDoEvent(this.getDoEvent());
|
65 |
0
| action.setUndoEvent(this.getUndoEvent());
|
66 |
0
| return action;
|
67 |
| } |
68 |
| |
69 |
| public abstract void workAreaReleased(int x, int y); |
70 |
| public abstract BusinessObject buildBusinessObject(); |
71 |
| } |