22 |
22 |
23 import org.eclipse.jface.action.IAction; |
23 import org.eclipse.jface.action.IAction; |
24 import org.eclipse.jface.layout.GridDataFactory; |
24 import org.eclipse.jface.layout.GridDataFactory; |
25 import org.eclipse.jface.layout.RowDataFactory; |
25 import org.eclipse.jface.layout.RowDataFactory; |
26 import org.eclipse.jface.layout.RowLayoutFactory; |
26 import org.eclipse.jface.layout.RowLayoutFactory; |
|
27 import org.eclipse.jface.resource.JFaceResources; |
27 import org.eclipse.swt.SWT; |
28 import org.eclipse.swt.SWT; |
28 import org.eclipse.swt.widgets.Composite; |
29 import org.eclipse.swt.widgets.Composite; |
29 import org.eclipse.swt.widgets.Label; |
30 import org.eclipse.swt.widgets.Label; |
30 import org.eclipse.ui.forms.events.HyperlinkEvent; |
31 import org.eclipse.ui.forms.events.HyperlinkEvent; |
31 import org.eclipse.ui.forms.events.IHyperlinkListener; |
32 import org.eclipse.ui.forms.events.IHyperlinkListener; |
32 import org.eclipse.ui.forms.widgets.Hyperlink; |
33 import org.eclipse.ui.forms.widgets.Hyperlink; |
33 |
34 |
34 import com.nokia.carbide.internal.discovery.ui.extension.IPortalPage.IActionBar; |
35 import com.nokia.carbide.internal.discovery.ui.extension.IPortalPage.IActionBar; |
35 |
36 |
36 class TaskBar extends RoundedCornerComposite { |
37 class TaskBar extends RoundedCornerComposite { |
37 |
|
38 private static final String FONT_NAME = "Arial"; //$NON-NLS-1$ |
|
39 |
38 |
40 private final class ActionListener implements IHyperlinkListener { |
39 private final class ActionListener implements IHyperlinkListener { |
41 @Override |
40 @Override |
42 public void linkActivated(HyperlinkEvent e) { |
41 public void linkActivated(HyperlinkEvent e) { |
43 Hyperlink link = (Hyperlink) e.getSource(); |
42 Hyperlink link = (Hyperlink) e.getSource(); |
55 Hyperlink link = (Hyperlink) e.getSource(); |
54 Hyperlink link = (Hyperlink) e.getSource(); |
56 link.setUnderlined(false); |
55 link.setUnderlined(false); |
57 } |
56 } |
58 } |
57 } |
59 |
58 |
60 private PortalEditor portalEditor; |
|
61 private Map<Hyperlink, IAction> linkToActionMap; |
59 private Map<Hyperlink, IAction> linkToActionMap; |
62 private ActionListener listener; |
60 private ActionListener listener; |
63 |
61 |
64 public TaskBar(Composite parent, PortalEditor portalEditor, IActionBar actionBar) { |
62 public TaskBar(Composite parent, PortalEditor portalEditor, IActionBar actionBar) { |
65 super(parent, portalEditor.getBackgroundParent(), |
63 super(parent, portalEditor.getBackgroundParent(), |
66 parent.getDisplay().getSystemColor(SWT.COLOR_BLACK), |
64 parent.getDisplay().getSystemColor(SWT.COLOR_BLACK), |
67 parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); |
65 parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); |
68 this.portalEditor = portalEditor; |
|
69 createTitle(actionBar); |
66 createTitle(actionBar); |
70 createActions(actionBar); |
67 createActions(actionBar); |
71 GridDataFactory.swtDefaults().grab(true, true).align(SWT.CENTER, SWT.BEGINNING).applyTo(this); |
68 GridDataFactory.swtDefaults().grab(true, true).align(SWT.CENTER, SWT.BEGINNING).applyTo(this); |
72 RowLayoutFactory.swtDefaults().type(SWT.VERTICAL).margins(10, 10).extendedMargins(5, 5, 5, 10).fill(true).wrap(false).applyTo(this); |
69 RowLayoutFactory.swtDefaults().type(SWT.VERTICAL).margins(10, 10).extendedMargins(5, 5, 5, 10).fill(true).wrap(false).applyTo(this); |
73 } |
70 } |
74 |
71 |
75 private void createTitle(IActionBar actionBar) { |
72 private void createTitle(IActionBar actionBar) { |
76 Label l = new Label(this, SWT.LEFT); |
73 Label l = new Label(this, SWT.LEFT); |
77 l.setFont(portalEditor.createFont(FONT_NAME, 10, SWT.BOLD)); |
74 l.setFont(JFaceResources.getBannerFont()); |
78 l.setBackground(l.getDisplay().getSystemColor(SWT.COLOR_WHITE)); |
75 l.setBackground(l.getDisplay().getSystemColor(SWT.COLOR_WHITE)); |
79 l.setText(actionBar.getTitle()); |
76 l.setText(actionBar.getTitle()); |
80 RowDataFactory.swtDefaults().applyTo(l); |
77 RowDataFactory.swtDefaults().applyTo(l); |
81 l = new Label(this, SWT.HORIZONTAL | SWT.SEPARATOR); |
78 l = new Label(this, SWT.HORIZONTAL | SWT.SEPARATOR); |
82 RowDataFactory.swtDefaults().applyTo(l); |
79 RowDataFactory.swtDefaults().applyTo(l); |
93 link.setToolTipText(toolTipText); |
90 link.setToolTipText(toolTipText); |
94 link.setBackground(link.getDisplay().getSystemColor(SWT.COLOR_WHITE)); |
91 link.setBackground(link.getDisplay().getSystemColor(SWT.COLOR_WHITE)); |
95 linkToActionMap.put(link, action); |
92 linkToActionMap.put(link, action); |
96 link.addHyperlinkListener(listener); |
93 link.addHyperlinkListener(listener); |
97 } |
94 } |
98 // updateAllActionsUI(); |
|
99 } |
95 } |
100 |
96 |
101 public void runAction(Hyperlink link) { |
97 public void runAction(Hyperlink link) { |
102 IAction action = linkToActionMap.get(link); |
98 IAction action = linkToActionMap.get(link); |
103 action.run(); |
99 action.run(); |