1 /***
2 *
3 */
4 package org.telscenter.pas.steps;
5
6 import java.awt.BorderLayout;
7 import java.awt.Color;
8 import java.awt.Component;
9 import java.awt.Dimension;
10 import java.awt.FlowLayout;
11 import java.awt.GridBagLayout;
12 import java.awt.GridBagConstraints;
13 import java.awt.Font;
14 import java.util.logging.Logger;
15
16 import javax.swing.BorderFactory;
17 import javax.swing.Box;
18 import javax.swing.BoxLayout;
19 import javax.swing.ImageIcon;
20 import javax.swing.JLabel;
21 import javax.swing.JPanel;
22 import javax.swing.JScrollPane;
23 import javax.swing.JTabbedPane;
24
25 import org.telscenter.pas.beans.PasProject;
26 import org.telscenter.pas.beans.PasStep;
27 import org.telscenter.pas.common.ui.panel.SimpleGradientPanel;
28 import org.telscenter.pas.common.ui.tab.PasProjInfoTabbedPaneUI;
29 import org.telscenter.pas.common.ui.tab.PasTabbedPaneUI;
30 import org.telscenter.pas.service.PasProjectServiceProvider;
31 import org.telscenter.pas.ui.frames.PasFrame;
32 import org.telscenter.pas.ui.util.PasColors;
33
34
35
36
37 /***
38 * A generic Pas step type, used for testing and demonstration purposes.
39 * This PasStep does not get initialized like the other Pas steps,
40 * so consumeService cannot be used.
41 *
42 * @author Archana
43 */
44 public class ProjectInfoStep extends PasStep{
45 private static final long serialVersionUID = 1L;
46
47 PasProjectServiceProvider provider;
48 PasProject project;
49
50 private static final Logger logger = Logger
51 .getLogger(ProjectInfoStep.class.getName());
52
53 public ProjectInfoStep(PasProject project){
54 this.project = project;
55 }
56
57
58 public Component getComponent() {
59 JPanel projInfoTitlePanel = createProjInfoTitlePanel();
60 JPanel titlePanel = new JPanel(new BorderLayout(0,0));
61 titlePanel.add(projInfoTitlePanel, BorderLayout.NORTH);
62 String[] headings = {"Getting Started", "Icon Key", "Learning Goals", "Credits"};
63
64 JPanel mainInfoPanel = new JPanel(new BorderLayout(0,0));
65 mainInfoPanel.setBackground(PasColors.pandaPanelBackgroundColor);
66 mainInfoPanel.add(titlePanel, BorderLayout.NORTH);
67 JTabbedPane tabbedPane = new JTabbedPane();
68 tabbedPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
69 tabbedPane.setBackground(PasColors.projectInfoBackgroundColor);
70 PasTabbedPaneUI thisUI = new PasProjInfoTabbedPaneUI();
71 tabbedPane.setUI(thisUI);
72
73
74
75 JPanel rowPanel = new JPanel(new FlowLayout());
76 JPanel boxPanel = new JPanel();
77 boxPanel.setLayout(new BoxLayout(boxPanel, BoxLayout.Y_AXIS));
78 for(int i = 0; i < headings.length; i++){
79 JPanel projInfoItemPanel = createProjInfoItemPanel(headings[i]);
80
81 JPanel wpanel = new JPanel(new BorderLayout(0,0));
82 wpanel.setBackground(PasColors.noteTextInteractionFillPanelBackgrounColor);
83 wpanel.add(projInfoItemPanel, BorderLayout.CENTER);
84
85 JScrollPane scrollPane = new JScrollPane();
86 scrollPane.getViewport().add(wpanel);
87 scrollPane
88 .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
89 scrollPane
90 .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
91 scrollPane.setBorder(BorderFactory.createEmptyBorder());
92 scrollPane
93 .setBackground(PasColors.noteTextInteractionFillPanelBackgrounColor);
94 scrollPane
95 .setBorder(BorderFactory.createLineBorder(Color.white, 2));
96
97 tabbedPane.addTab(headings[i], scrollPane);
98 tabbedPane.validate();
99 }
100
101
102 mainInfoPanel.add(tabbedPane, BorderLayout.CENTER);
103 return mainInfoPanel;
104
105 }
106
107 private JPanel createProjInfoTitlePanel(){
108 float headerFontSize=28.0f;
109 JLabel projectInfoTitle = new JLabel("Project Information");
110 projectInfoTitle.setFont(projectInfoTitle.getFont().deriveFont(Font.BOLD, headerFontSize));
111 projectInfoTitle.setForeground(new Color(202,225,255));
112 projectInfoTitle.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
113 projectInfoTitle.setBackground(projectInfoTitle.getBackground().brighter());
114
115 SimpleGradientPanel projInfoTitlePanel = createSimpleGradientPanel();
116 GridBagConstraints c = createGridBagConstraint();
117 projInfoTitlePanel.add(projectInfoTitle, c);
118 return projInfoTitlePanel;
119 }
120
121 /***
122 * creates a simple gradient panel for background
123 *
124 * @return mainPanel
125 */
126 private SimpleGradientPanel createSimpleGradientPanel() {
127 SimpleGradientPanel mainPanel = new SimpleGradientPanel();
128 mainPanel.setDirection(SimpleGradientPanel.VERTICAL);
129 mainPanel.setStartColor(PasColors.vleHeadingBackgroundStartColor);
130 mainPanel.setEndColor(PasColors.vleHeadingBackgroundEndColor);
131 mainPanel.setLayout(new GridBagLayout());
132 return mainPanel;
133 }
134
135 /***
136 * @return c
137 * creates the position of the component to be shown via grid bag layout
138 */
139 private GridBagConstraints createGridBagConstraint() {
140 GridBagConstraints c = new GridBagConstraints();
141 c.fill = GridBagConstraints.BOTH;
142
143 c.weightx = 1;
144 c.gridx = 0;
145 c.gridy = 0;
146
147
148 c.gridx = 0;
149 c.gridy = 0;
150
151
152 c.weighty = 1;
153 c.gridx = 0;
154 c.gridy = 0;
155 c.fill = GridBagConstraints.BOTH;
156 return c;
157 }
158
159 /***
160 * creates a project info item panel, with four subparts (getting started, icon key, learning goals, credits)
161 *
162 * @return mainPanel
163 */
164 private JPanel createProjInfoItemPanel(String heading){
165 JPanel projInfoItemPanel = new JPanel();
166 projInfoItemPanel.setLayout(new BoxLayout(projInfoItemPanel, BoxLayout.Y_AXIS));
167
168 JPanel mainPanel = new JPanel(new BorderLayout(0,0));
169
170 if(heading.equals("Getting Started")){
171 projInfoItemPanel = gettingStartedItemPanel(projInfoItemPanel);
172 }else if(heading.equals("Icon Key")){
173 projInfoItemPanel = iconKeyItemPanel(projInfoItemPanel);
174 }else if(heading.equals("Learning Goals")){
175 projInfoItemPanel = learningGoalsItemPanel(projInfoItemPanel);
176 }else if(heading.equals("Credits")){
177 projInfoItemPanel = creditsItemPanel(projInfoItemPanel);
178 }else{}
179
180 projInfoItemPanel.setBackground(PasColors.projectInfoBackgroundColor);
181 mainPanel.add(projInfoItemPanel, BorderLayout.CENTER);
182 return mainPanel;
183 }
184
185
186
187 /***
188 * creates a getting started panel for the project information
189 *
190 * @return projInfoItemPanel
191 */
192 private JPanel gettingStartedItemPanel(JPanel projInfoItemPanel){
193 PasFrame projectFrame = project.getProjectFrame();
194 String userNameMessage = "Welcome";
195 if(projectFrame != null)
196 userNameMessage = projectFrame.getWelcomeMessageForUsers();
197
198 JLabel headingLabel = new JLabel(userNameMessage);
199 headingLabel.setFont(headingLabel.getFont().deriveFont(Font.BOLD, 20.0f));
200 projInfoItemPanel.add(headingLabel);
201 projInfoItemPanel.add(new JLabel("To learn more about this project and how to navigate, click on any tab above."));
202 projInfoItemPanel.add(new JLabel(""));
203 projInfoItemPanel.add(new JLabel("To get started with this project:"));
204 projInfoItemPanel.add(new JLabel(" * Click on Activity 1: [Name of Activity]"));
205 projInfoItemPanel.add(new JLabel(" * Click on Step 1: [Name of Step 1]"));
206 projInfoItemPanel.add(new JLabel(" * Read carefully and begin your exploration!"));
207 return projInfoItemPanel;
208 }
209
210 /***
211 * creates a icon key panel for the project information
212 *
213 * @return projInfoItemPanel
214 */
215 private JPanel iconKeyItemPanel(JPanel projInfoItemPanel){
216 JLabel headingLabel = new JLabel("KEY TO ICONS IN THIS PROJECT:");
217 headingLabel.setFont(headingLabel.getFont().deriveFont(Font.BOLD, 16.0f));
218 headingLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
219 projInfoItemPanel.add(headingLabel);
220
221 ImageIcon[] icons = {
222 new ImageIcon(this.getClass().getResource("/org/telscenter/pas/ui/sidebar/icons/shrinkButtonNormal.png")),
223 new ImageIcon(this.getClass().getResource("/org/telscenter/pas/navigation/icons/projectInfoActive.png")),
224 new ImageIcon(this.getClass().getResource("/org/telscenter/pas/navigation/icons/allNotesActive.png")),
225 new ImageIcon(this.getClass().getResource("/org/telscenter/pas/ui/icons/phoneIconActive.png")),
226 new ImageIcon(this.getClass().getResource("/org/telscenter/pas/navigation/icons/exitButtonActive.png")),
227 new ImageIcon(this.getClass().getResource("/org/telscenter/pas/ui/icons/hintButtonActive.png")),
228 new ImageIcon(this.getClass().getResource("/org/telscenter/pas/ui/icons/directions_16a.png"))
229 };
230
231
232 String[] iconInfo = {"Shrink Button", "Project Information", "Show Progress & Scores", "Report a Problem",
233 "Exit", "Hint", "Directions"};
234
235
236 String[] iconDesc = {"Click to shrink Navigation bar and increase your viewing area.",
237 "Click to display the Project Key & Project Credits",
238 "Click to display all of your work at once, your current project score, and your pending revisions.",
239 " Send a message to WISE reporting a technical or content problem.",
240 "Click to exit the project. All of your latest work will be automatically saved.",
241 "When this button appears, click it to get a hint.",
242 "Click to see directions for a Step or Module."
243 };
244
245 GridBagLayout gridbag = new GridBagLayout();
246 GridBagConstraints c = new GridBagConstraints();
247
248 c.fill = GridBagConstraints.BOTH;
249
250 JPanel iconRowPanel = new JPanel();
251 iconRowPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK,2));
252 iconRowPanel.setLayout(gridbag);
253
254
255
256 for(int y = 0; y < iconInfo.length; y++){
257 c.fill = GridBagConstraints.HORIZONTAL;
258 c.gridx = 0;
259 c.gridy = y;
260
261 JLabel iconPlaceholder = new JLabel(icons[y]);
262 iconPlaceholder.setBorder(BorderFactory.createMatteBorder(0,0,2,2,Color.BLACK));
263
264 iconRowPanel.add(iconPlaceholder,c);
265
266 JLabel iconInformation = new JLabel(iconInfo[y]);
267 c.gridx = 1;
268 c.gridy = y;
269 c.gridwidth=3;
270 iconInformation.setPreferredSize(new Dimension(iconInformation.getPreferredSize().width+10, iconPlaceholder.getPreferredSize().height));
271 iconInformation.setMaximumSize(new Dimension(iconInformation.getPreferredSize().width+10, iconPlaceholder.getPreferredSize().height));
272 iconInformation.setBorder(BorderFactory.createMatteBorder(0,0,2,2,Color.BLACK));
273 iconRowPanel.add(iconInformation,c);
274
275
276 JLabel iconDescription = new JLabel(iconDesc[y]);
277 c.gridx = 4;
278 c.gridy = y;
279 iconDescription.setPreferredSize(new Dimension(iconDescription.getPreferredSize().width, iconPlaceholder.getPreferredSize().height));
280 iconDescription.setMaximumSize(new Dimension(iconDescription.getPreferredSize().width, iconPlaceholder.getPreferredSize().height));
281 iconDescription.setBorder(BorderFactory.createMatteBorder(0,0,2,2,Color.BLACK));
282
283 iconRowPanel.add(iconDescription,c);
284 }
285 iconRowPanel.setBackground(PasColors.projectInfoBackgroundColor);
286 projInfoItemPanel.add(iconRowPanel);
287
288 return projInfoItemPanel;
289 }
290
291 /***
292 * creates a learning goals panel for the project information
293 *
294 * @return projInfoItemPanel
295 */
296 private JPanel learningGoalsItemPanel(JPanel projInfoItemPanel){
297 JLabel headingLabel = new JLabel("Learning Goals For This Project");
298 headingLabel.setFont(headingLabel.getFont().deriveFont(Font.BOLD, 16.0f));
299 headingLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
300
301 JLabel contentMessageLabel = new JLabel("There are no Learning Goals for this project yet");
302 contentMessageLabel.setFont(contentMessageLabel.getFont().deriveFont(Font.BOLD, 14.0f));
303 contentMessageLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
304
305 projInfoItemPanel.add(headingLabel);
306 projInfoItemPanel.add(contentMessageLabel);
307 return projInfoItemPanel;
308
309 }
310
311 /***
312 * creates a credits panel for the project information
313 *
314 * @return projInfoItemPanel
315 */
316 private JPanel creditsItemPanel(JPanel projInfoItemPanel){
317 JLabel headingLabel = new JLabel("Credits For This Project");
318 headingLabel.setFont(headingLabel.getFont().deriveFont(Font.BOLD, 16.0f));
319 headingLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
320
321 JLabel contentMessageLabel = new JLabel("There are no Credits for this project yet");
322 contentMessageLabel.setFont(contentMessageLabel.getFont().deriveFont(Font.BOLD, 14.0f));
323 contentMessageLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
324
325 projInfoItemPanel.add(headingLabel);
326 projInfoItemPanel.add(contentMessageLabel);
327 return projInfoItemPanel;
328 }
329
330
331 }
332