1 /***
2 * Created on Feb 13, 2006, Copyright UC Regents
3 */
4 package org.telscenter.pas.authortool.toolbar;
5
6 import java.awt.Insets;
7
8 import javax.swing.Action;
9 import javax.swing.BorderFactory;
10 import javax.swing.JButton;
11 import javax.swing.JToolBar;
12
13 import org.telscenter.pas.authortool.actions.HelpContextAction;
14 import org.telscenter.pas.authortool.actions.PasCustomizerAction;
15 import org.telscenter.pas.authortool.actions.PasLivePreviewCurnitAction;
16 import org.telscenter.pas.authortool.context.CurnitAuthoringContext;
17
18
19 /***
20 * @author aperritano
21 *
22 */
23 public class ToolBarProvider {
24
25 private final JToolBar toolbar = new JToolBar();
26 private CurnitAuthoringContext curnitAuthoringContext;
27
28 public ToolBarProvider(final CurnitAuthoringContext curnitAuthoringContext) {
29 this.curnitAuthoringContext = curnitAuthoringContext;
30
31 initSettings();
32 initDefaultActions();
33 }
34
35 /***
36 *
37 */
38 protected void initSettings() {
39 toolbar.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
40 toolbar.setMargin(new Insets(2,2,2,2));
41 toolbar.setFloatable(false);
42 toolbar.setRollover(true);
43 }
44
45 /***
46 *
47 */
48 protected void initDefaultActions() {
49 addToolbarAction2(PasCustomizerAction.class);
50 addToolbarAction2(PasLivePreviewCurnitAction.class);
51 addToolbarAction2(HelpContextAction.class);
52 }
53
54 /***
55 * @param toolTip
56 *
57 */
58 public void addToolbarAction(final Action action, String toolTip) {
59 JButton button = new JButton(action);
60 button.setText((String) action.getValue(Action.NAME));
61 button.setToolTipText(toolTip);
62 toolbar.add(button);
63
64 }
65
66 public void addToolbarAction2(Class actionClass) {
67 Action action = curnitAuthoringContext.getAction(actionClass);
68 JButton button = new JButton(action);
69
70
71
72
73
74
75 toolbar.add(button);
76
77 }
78
79 /***
80 * @return Returns the toolbar.
81 */
82 public JToolBar getToolbar() {
83 return toolbar;
84 }
85 }