01: package org.enhydra.jawe.components.graph.actions;
02:
03: import java.awt.Point;
04: import java.awt.event.ActionEvent;
05:
06: import org.enhydra.jawe.ActionBase;
07: import org.enhydra.jawe.JaWEComponent;
08: import org.enhydra.jawe.JaWEManager;
09: import org.enhydra.jawe.base.controller.JaWEActions;
10: import org.enhydra.jawe.base.controller.JaWEController;
11: import org.enhydra.jawe.components.graph.CopyOrCutInfo;
12: import org.enhydra.jawe.components.graph.Graph;
13: import org.enhydra.jawe.components.graph.GraphController;
14: import org.enhydra.jawe.components.graph.GraphManager;
15:
16: /**
17: * Class that realizes <B>paste</B> action.
18: * @author Sasa Bojanic
19: */
20: public class GraphPaste extends ActionBase {
21:
22: public GraphPaste(JaWEComponent jawecomponent) {
23: super (jawecomponent);
24: }
25:
26: public void enableDisableAction() {
27: GraphController gc = (GraphController) jawecomponent;
28: Graph selectedGraph = gc.getSelectedGraph();
29: boolean en = false;
30: if (JaWEManager.getInstance().getJaWEController()
31: .getJaWEActions().getAction(JaWEActions.PASTE_ACTION)
32: .isEnabled()
33: && selectedGraph != null) {
34: GraphManager gm = selectedGraph.getGraphManager();
35: en = gc.getCopyOrCutInfo() != null
36: && gm.doesRootParticipantExist();
37: }
38: setEnabled(en);
39: }
40:
41: public void actionPerformed(ActionEvent e) {
42: JaWEController jc = JaWEManager.getInstance()
43: .getJaWEController();
44:
45: GraphController gc = (GraphController) jawecomponent;
46: Graph selectedGraph = gc.getSelectedGraph();
47: if (selectedGraph == null)
48: return;
49:
50: Point pasteTo = gc.getGraphMarqueeHandler().getPopupPoint();
51: CopyOrCutInfo copyOrCutInfo = gc.getCopyOrCutInfo();
52: copyOrCutInfo.setPastePoint(pasteTo);
53:
54: jc.getEdit().paste();
55:
56: copyOrCutInfo.setPastePoint(null);
57: }
58: }
|