01: /*
02: * To change this template, choose Tools | Templates
03: * and open the template in the editor.
04: */
05:
06: package org.netbeans.modules.bpel.design.actions;
07:
08: import java.awt.event.ActionEvent;
09: import javax.swing.Action;
10: import org.netbeans.modules.bpel.design.DesignView;
11: import org.netbeans.modules.bpel.design.model.patterns.Pattern;
12: import org.netbeans.modules.bpel.nodes.actions.GoToAction;
13: import org.openide.nodes.Node;
14: import org.openide.util.actions.SystemAction;
15:
16: /**
17: *
18: * @author Alexey
19: */
20: public class GoToSourceAction extends DesignModeAction {
21: private static final long serialVersionUID = 1L;
22:
23: public GoToSourceAction(DesignView view) {
24: super (view);
25: }
26:
27: public void actionPerformed(ActionEvent e) {
28: Pattern selected = getDesignView().getSelectionModel()
29: .getSelectedPattern();
30:
31: if (selected == null) {
32: return;
33: }
34:
35: Node node = getDesignView().getNodeForPattern(selected);
36:
37: if (node == null) {
38: return;
39: }
40:
41: Action[] actions = node.getActions(true);
42: if (actions == null) {
43: return;
44: }
45:
46: for (int i = actions.length - 1; i >= 0; i--) {
47: Action action = actions[i];
48: if (action instanceof GoToAction) {
49: org.netbeans.modules.bpel.nodes.actions.GoToSourceAction gotoAction = SystemAction
50: .get(org.netbeans.modules.bpel.nodes.actions.GoToSourceAction.class);
51: Node[] nodes = new Node[] { node };
52: if (gotoAction != null && gotoAction.enable(nodes)) {
53: gotoAction.performAction(nodes);
54: }
55: break;
56: }
57: }
58: }
59: }
|