1 package org.telscenter.pas.service;
2
3 import java.awt.event.ActionEvent;
4
5 import javax.swing.AbstractAction;
6 import javax.swing.Action;
7 import javax.swing.Icon;
8
9 import org.telscenter.pas.beans.PasStep;
10 import org.telscenter.pas.navigation.PasProjectNavigationTaskPanel;
11 import org.telscenter.pas.steps.Note;
12
13 public class NavigateAction extends AbstractAction {
14
15 protected INavigationService navigationService;
16
17 private PasStep step;
18 private PasProjectNavigationTaskPanel nav;
19
20 public NavigateAction() {
21 super();
22 }
23
24 public NavigateAction(String name, INavigationService navigationService) {
25 super(name);
26 this.navigationService = navigationService;
27 }
28
29 public NavigateAction(String name, Icon icon) {
30 super(name, icon);
31 }
32
33
34
35 /***
36 * @param step
37 */
38 public NavigateAction(PasStep step, INavigationService navigationService, PasProjectNavigationTaskPanel nav) {
39 this.step = step;
40 this.navigationService = navigationService;
41 this.nav = nav;
42 this.setEnabled(true);
43 this.putValue(Action.NAME, step.getTitle());
44 }
45
46 public void actionPerformed(ActionEvent e) {
47
48 if( step instanceof Note ) {
49 Note note = (Note)step;
50
51 if( note.getNoteUI() != null ) {
52 if( note.getNoteUI().isNoteOpen() ) {
53 note.showNoteAlreadyOpenDialog(nav.getProjectFrame());
54 } else {
55 navigationService.setCurrentStep(step);
56 nav.adjustPanelSelection(step);
57 }
58 } else {
59 navigationService.setCurrentStep(step);
60 nav.adjustPanelSelection(step);
61 }
62 } else {
63 navigationService.setCurrentStep(step);
64 nav.adjustPanelSelection(step);
65 }
66
67 }
68 }