1
2
3
4 package org.telscenter.pas.service;
5
6 import java.awt.Dimension;
7 import java.awt.Frame;
8 import java.awt.event.WindowAdapter;
9 import java.awt.event.WindowEvent;
10 import java.beans.BeanInfo;
11
12 import javax.swing.ImageIcon;
13 import javax.swing.JComponent;
14 import javax.swing.JDialog;
15 import javax.swing.JPanel;
16
17 import org.telscenter.pas.steps.INoteStep;
18 import org.telscenter.pas.steps.icons.PasStepIconProvider;
19 import org.telscenter.pas.ui.util.PasColors;
20 import org.xito.dialog.CustomDialog;
21 import org.xito.dialog.DialogDescriptor;
22 import org.xito.dialog.DialogManager;
23
24 /***
25 * @author turadg
26 * @author aperritano
27 */
28 public class NoteService implements INoteService {
29
30 private Frame rootFrame;
31
32 public NoteService(Frame rootFrame) {
33 this.rootFrame = rootFrame;
34 }
35
36 public void popupNote(final INoteStep note, final int width,
37 final int height) {
38 final DialogDescriptor descriptor = new DialogDescriptor();
39
40 final JComponent component = (JComponent) note.getComponent();
41 descriptor.setIcon(new ImageIcon(PasStepIconProvider.getIcon("note",
42 BeanInfo.ICON_COLOR_32x32)));
43 descriptor.setWindowTitle(note.getTitle());
44 descriptor.setTitle("Note");
45 descriptor.setSubtitle("Fill out each note part and save your answer.");
46 descriptor.setCustomPanel((JPanel) component);
47 descriptor.setGradiantColor(PasColors.noteGradiantColor);
48
49 descriptor.setWidth(width);
50 descriptor.setHeight(height);
51 descriptor.setShowButtonSeparator(false);
52 descriptor.setGradiantOffsetRatio(.30f);
53 descriptor.setResizable(true);
54 descriptor.setType(DialogManager.NONE);
55
56
57
58 final CustomDialog cd = new CustomDialog(rootFrame, descriptor, false);
59 cd.setFocusable(true);
60 cd.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
61 cd.addWindowListener(new WindowAdapter() {
62 public void windowActivated(final WindowEvent e) {
63
64 note.getNoteUI().setNoteOpen(true);
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 }
81
82 public void windowClosing(final WindowEvent we) {
83 closeNote(note, cd);
84 }
85
86 public void windowClosed(WindowEvent e) {
87 note.getNoteUI().setNoteOpen(false);
88
89 }
90
91 });
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109 cd.setSize(new Dimension(450, 500));
110
111
112 cd.setVisible(true);
113
114 }
115
116
117 /***
118 * @param note
119 * @param cd
120 */
121 protected void closeNote(final INoteStep note, final CustomDialog cd) {
122
123
124 note.getNoteUI().getSaveAction().actionPerformed(null);
125 cd.dispose();
126
127
128
129
130
131
132
133
134 note.getNoteUI().setNoteOpen(false);
135
136 }
137
138 }