14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 package com.nokia.carbide.cpp.sdk.ui; |
17 package com.nokia.carbide.cpp.sdk.ui; |
18 |
18 |
|
19 import java.util.ArrayList; |
|
20 import java.util.List; |
|
21 |
|
22 import org.eclipse.jface.action.Action; |
|
23 import org.eclipse.jface.action.IAction; |
19 import org.eclipse.swt.widgets.Composite; |
24 import org.eclipse.swt.widgets.Composite; |
20 import org.eclipse.swt.widgets.Control; |
25 import org.eclipse.swt.widgets.Control; |
21 import org.eclipse.ui.IEditorPart; |
26 import org.eclipse.ui.IEditorPart; |
22 import org.eclipse.ui.PlatformUI; |
27 import org.eclipse.ui.PlatformUI; |
23 |
28 |
|
29 import com.nokia.carbide.cpp.internal.sdk.ui.Messages; |
24 import com.nokia.carbide.cpp.internal.sdk.ui.SDKPreferencePage; |
30 import com.nokia.carbide.cpp.internal.sdk.ui.SDKPreferencePage; |
25 import com.nokia.carbide.internal.discovery.ui.extension.IActionBar; |
31 import com.nokia.carbide.internal.discovery.ui.extension.IActionBar; |
26 import com.nokia.carbide.internal.discovery.ui.extension.IActionUIUpdater; |
32 import com.nokia.carbide.internal.discovery.ui.extension.IActionUIUpdater; |
27 import com.nokia.carbide.internal.discovery.ui.extension.IPortalPageLayer; |
33 import com.nokia.carbide.internal.discovery.ui.extension.IPortalPageLayer; |
28 |
34 |
29 @SuppressWarnings("restriction") |
35 @SuppressWarnings("restriction") |
30 public class SDKPreferencesPortalPageLayer implements IPortalPageLayer { |
36 public class SDKPreferencesPortalPageLayer implements IPortalPageLayer { |
31 |
37 |
|
38 protected class SDKActionBar implements IActionBar { |
|
39 private IAction[] actions; |
|
40 |
|
41 public SDKActionBar(IEditorPart part) { |
|
42 actions = makeActions(part); |
|
43 } |
|
44 |
|
45 public String getTitle() { |
|
46 return Messages.getString("SDKPreferencePage.Manage_SDKs_Label"); |
|
47 } |
|
48 |
|
49 public IAction[] getActions() { |
|
50 return actions; |
|
51 } |
|
52 |
|
53 public String[] getHighlightedActionIds() { |
|
54 return null; |
|
55 } |
|
56 } |
|
57 |
32 private SDKPreferencePage preferencePage; |
58 private SDKPreferencePage preferencePage; |
33 |
59 |
34 public Control createControl(Composite parent, IEditorPart part) { |
60 public Control createControl(Composite parent, IEditorPart part) { |
35 preferencePage = new SDKPreferencePage(); |
61 preferencePage = new SDKPreferencePage(); |
36 preferencePage.createControl(parent); |
62 preferencePage.createControl(parent); |
|
63 preferencePage.updateForPortalLayer(); |
37 return preferencePage.getControl(); |
64 return preferencePage.getControl(); |
38 } |
65 } |
39 |
66 |
40 public void init() { |
67 public void init() { |
41 preferencePage.init(PlatformUI.getWorkbench()); |
68 preferencePage.init(PlatformUI.getWorkbench()); |
42 } |
69 } |
43 |
70 |
44 public IActionBar[] createCommandBars(IEditorPart part, IActionUIUpdater updater) { |
71 public IActionBar[] createCommandBars(IEditorPart part, IActionUIUpdater updater) { |
45 return null; |
72 return new IActionBar[] { new SDKActionBar(part) }; |
46 } |
73 } |
47 |
74 |
48 public void dispose() { |
75 public void dispose() { |
49 preferencePage.dispose(); |
76 preferencePage.dispose(); |
50 } |
77 } |
51 |
78 |
|
79 protected IAction[] makeActions(final IEditorPart part) { |
|
80 List<IAction> actions = new ArrayList<IAction>(); |
|
81 IAction action; |
|
82 |
|
83 // Add SDK |
|
84 action = new Action(Messages.getString("SDKPreferencePage.Add_Button_Label")) { |
|
85 public void run() { |
|
86 preferencePage.handleAddButton(); |
|
87 } |
|
88 }; |
|
89 action.setToolTipText(Messages.getString("SDKPreferencePage.Add_Button_ToolTip")); |
|
90 actions.add(action); |
|
91 |
|
92 // Delete SDK |
|
93 action = new Action(Messages.getString("SDKPreferencePage.Delete_Button_Label")) { |
|
94 public void run() { |
|
95 preferencePage.handleDeleteButton(); |
|
96 } |
|
97 }; |
|
98 action.setToolTipText(Messages.getString("SDKPreferencePage.Delete_Button_ToolTip")); |
|
99 actions.add(action); |
|
100 |
|
101 // SDK Properties |
|
102 action = new Action(Messages.getString("SDKPreferencePage.Properties_Button_Label")) { |
|
103 public void run() { |
|
104 preferencePage.handlePropertiesButton(); |
|
105 } |
|
106 }; |
|
107 action.setToolTipText(Messages.getString("SDKPreferencePage.Properties_Button_ToolTip")); |
|
108 actions.add(action); |
|
109 |
|
110 // Rescan SDKs |
|
111 action = new Action(Messages.getString("SDKPreferencePage.Rescan_Button_Label")) { |
|
112 public void run() { |
|
113 preferencePage.handleRescanButton(true); |
|
114 } |
|
115 }; |
|
116 action.setToolTipText(Messages.getString("SDKPreferencePage.Rescan_Button_ToolTip")); |
|
117 actions.add(action); |
|
118 |
|
119 return (IAction[]) actions.toArray(new IAction[actions.size()]); |
|
120 } |
52 } |
121 } |