49 |
51 |
50 // TODO: Temporary map. We need a way to ensure we only get the alias map |
52 // TODO: Temporary map. We need a way to ensure we only get the alias map |
51 // when needed and that the data we are getting is properly cached to avoid |
53 // when needed and that the data we are getting is properly cached to avoid |
52 // having to run Raptor queries too often |
54 // having to run Raptor queries too often |
53 private static HashMap<String, String> aliasMap = new HashMap<String, String>(); |
55 private static HashMap<String, String> aliasMap = new HashMap<String, String>(); |
54 |
56 private static List<String> productVariantList = new ArrayList<String>(); |
55 private CheckboxTableViewer tableViewer; |
57 |
|
58 private CheckboxTableViewer buildAliasTableViewer; |
|
59 private CheckboxTableViewer customVariantTableViewer; |
56 private Button refreshButton; |
60 private Button refreshButton; |
|
61 private Button addVariantButton; |
57 |
62 |
58 |
63 |
59 SBSv2PlatformFilterComposite(Composite parent) { |
64 SBSv2PlatformFilterComposite(Composite parent) { |
60 super(parent, SWT.NONE); |
65 super(parent, SWT.NONE); |
61 } |
66 } |
62 |
67 |
63 public void createControls() { |
68 public void createControls() { |
64 GridLayout gridLayout = new GridLayout(); |
69 GridLayout gridLayout = new GridLayout(); |
|
70 gridLayout.numColumns = 2; |
65 setLayout(gridLayout); |
71 setLayout(gridLayout); |
66 |
72 |
67 Group platformsGroup = new Group(this, SWT.NONE); |
73 Group aliasGroup = new Group(this, SWT.NONE); |
68 platformsGroup.setText(Messages.getString("SBSv2PlatformFilterComposite.PlatformsGroupText")); //$NON-NLS-1$ |
74 aliasGroup.setText(Messages.getString("SBSv2PlatformFilterComposite.PlatformsGroupText")); //$NON-NLS-1$ |
69 platformsGroup.setToolTipText(Messages.getString("SBSv2PlatformFilterComposite.PlatformsGroupToolTip")); //$NON-NLS-1$ |
75 aliasGroup.setToolTipText(Messages.getString("SBSv2PlatformFilterComposite.PlatformsGroupToolTip")); //$NON-NLS-1$ |
70 GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); |
76 GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); |
71 gd.widthHint = 350; |
77 gd.widthHint = 200; |
72 platformsGroup.setLayoutData(gd); |
78 gd.heightHint = 350; |
73 platformsGroup.setLayout(new GridLayout()); |
79 aliasGroup.setLayoutData(gd); |
74 |
80 aliasGroup.setLayout(new GridLayout()); |
75 tableViewer = CheckboxTableViewer.newCheckList(platformsGroup, SWT.BORDER); |
81 |
76 tableViewer.getTable().setLayoutData(gd); |
82 buildAliasTableViewer = CheckboxTableViewer.newCheckList(aliasGroup, SWT.BORDER); |
77 tableViewer.setContentProvider(new ArrayContentProvider()); |
83 buildAliasTableViewer.getTable().setLayoutData(gd); |
78 tableViewer.setLabelProvider(new LabelProvider()); |
84 buildAliasTableViewer.setContentProvider(new ArrayContentProvider()); |
|
85 buildAliasTableViewer.setLabelProvider(new LabelProvider()); |
|
86 |
|
87 Group customConfigGroup = new Group(this, SWT.NONE); |
|
88 customConfigGroup.setText(Messages.getString("SBSv2PlatformFilterComposite.ProductsGroupText")); //$NON-NLS-1$ |
|
89 customConfigGroup.setToolTipText(Messages.getString("SBSv2PlatformFilterComposite.ProductsGroupToolTip")); //$NON-NLS-1$ |
|
90 GridData gd2 = new GridData(SWT.FILL, SWT.CENTER, true, false); |
|
91 gd2.widthHint = 200; |
|
92 gd2.heightHint = 350; |
|
93 customConfigGroup.setLayoutData(gd2); |
|
94 customConfigGroup.setLayout(new GridLayout()); |
|
95 |
|
96 customVariantTableViewer = CheckboxTableViewer.newCheckList(customConfigGroup, SWT.BORDER); |
|
97 customVariantTableViewer.getTable().setLayoutData(gd); |
|
98 customVariantTableViewer.setContentProvider(new ArrayContentProvider()); |
|
99 customVariantTableViewer.setLabelProvider(new LabelProvider()); |
79 |
100 |
80 refreshButton = new Button(this, SWT.NONE); |
101 refreshButton = new Button(this, SWT.NONE); |
81 refreshButton.setText(Messages.getString("SBSv2PlatformFilterComposite.RefreshButtonText")); //$NON-NLS-1$ |
102 refreshButton.setText(Messages.getString("SBSv2PlatformFilterComposite.RefreshButtonText")); //$NON-NLS-1$ |
82 refreshButton.setToolTipText(Messages.getString("SBSv2PlatformFilterComposite.RefreshButtonToolTip")); //$NON-NLS-1$ |
103 refreshButton.setToolTipText(Messages.getString("SBSv2PlatformFilterComposite.RefreshButtonToolTip")); //$NON-NLS-1$ |
83 refreshButton.addSelectionListener(new SelectionListener() { |
104 refreshButton.addSelectionListener(new SelectionListener() { |
84 |
105 |
85 public void widgetDefaultSelected(SelectionEvent e) { |
106 public void widgetDefaultSelected(SelectionEvent e) { |
86 widgetSelected(e); |
107 widgetSelected(e); |
87 } |
108 } |
88 |
109 |
89 public void widgetSelected(SelectionEvent e) { |
110 public void widgetSelected(SelectionEvent e) { |
90 initTable(true); |
111 initTable(true); |
91 } |
112 } |
92 |
113 |
93 }); |
114 }); |
94 |
115 |
|
116 addVariantButton = new Button(this, SWT.NONE); |
|
117 addVariantButton.setText(Messages.getString("SBSv2PlatformFilterComposite.AddProductButtonText")); //$NON-NLS-1$ |
|
118 addVariantButton.setToolTipText(Messages.getString("SBSv2PlatformFilterComposite.AddProductButtonToolTip")); //$NON-NLS-1$ |
|
119 addVariantButton.addSelectionListener(new SelectionListener() { |
|
120 |
|
121 public void widgetDefaultSelected(SelectionEvent e) {widgetSelected(e);} |
|
122 public void widgetSelected(SelectionEvent e) { |
|
123 if (aliasMap.size() == 0){ |
|
124 MessageDialog.openError(getShell(), "No build configurations found.", "No build configurations (aliases) were found from any SDKs. Attempted 'sbs --query=aliases' but found no results."); |
|
125 } else if (productVariantList.size() == 0){ |
|
126 MessageDialog.openError(getShell(), "No products found.", "No products were found from any SDKs. Attempted 'sbs --query=products' but found no results."); |
|
127 } else { |
|
128 AddSBSv2ProductVariant addVariantDlg = new AddSBSv2ProductVariant(getShell(), aliasMap, productVariantList); |
|
129 if (addVariantDlg.open() == TrayDialog.OK){ |
|
130 if (customVariantTableViewer.testFindItem(addVariantDlg.getUserCreatedVariant()) == null){ |
|
131 // doesn't exist, add it. if it does exist just ignore it |
|
132 customVariantTableViewer.add(addVariantDlg.getUserCreatedVariant()); |
|
133 customVariantTableViewer.setChecked(addVariantDlg.getUserCreatedVariant(), true); |
|
134 } |
|
135 } |
|
136 } |
|
137 } |
|
138 |
|
139 }); |
95 initTable(false); |
140 initTable(false); |
96 } |
141 } |
97 |
142 |
98 public void performOk() { |
143 public void performOk() { |
99 // save the list of unchecked configs |
144 // save the list of unchecked configs |
100 List<String> checkedConfigs = new ArrayList<String>(); |
145 List<String> checkedConfigs = new ArrayList<String>(); |
101 for (TableItem item : tableViewer.getTable().getItems()) { |
146 for (TableItem item : buildAliasTableViewer.getTable().getItems()) { |
102 if (tableViewer.getChecked(item.getData())) { |
147 if (buildAliasTableViewer.getChecked(item.getData())) { |
|
148 checkedConfigs.add(item.getText()); |
|
149 } |
|
150 } |
|
151 |
|
152 for (TableItem item : customVariantTableViewer.getTable().getItems()) { |
|
153 if (customVariantTableViewer.getChecked(item.getData())) { |
103 checkedConfigs.add(item.getText()); |
154 checkedConfigs.add(item.getText()); |
104 } |
155 } |
105 } |
156 } |
106 |
157 |
107 SBSv2Utils.setSBSv2FilteredConfigs(checkedConfigs.toArray(new String[checkedConfigs.size()])); |
158 SBSv2Utils.setSBSv2FilteredConfigs(checkedConfigs.toArray(new String[checkedConfigs.size()])); |
124 MessageDialog.openError(getShell(), "Minimum sbs version not met.", e.getMessage()); |
175 MessageDialog.openError(getShell(), "Minimum sbs version not met.", e.getMessage()); |
125 } |
176 } |
126 } |
177 } |
127 } |
178 } |
128 |
179 |
129 List<String> sbsAliases = new ArrayList<String>(); |
180 if (productVariantList.size() == 0){ |
130 for (String key : aliasMap.keySet()) |
181 try { |
|
182 productVariantList = SBSv2QueryUtils.getCompleteProductVariantList(); |
|
183 } catch (SBSv2MinimumVersionException e) { |
|
184 |
|
185 } |
|
186 } |
|
187 // get saved configs in the store |
|
188 List<String> checkedConfigsFromStore = SBSv2Utils.getSBSv2FilteredConfigPreferences(); |
|
189 |
|
190 List<String> sbsAliases = new ArrayList<String>(); // global build aliases |
|
191 List<String> savedVariants = new ArrayList<String>(); // custom variants |
|
192 for (String key : aliasMap.keySet()){ |
131 sbsAliases.add(key); |
193 sbsAliases.add(key); |
|
194 } |
|
195 |
|
196 for (String config : checkedConfigsFromStore){ |
|
197 if (config.contains(".")){ |
|
198 savedVariants.add(config); |
|
199 } |
|
200 } |
|
201 |
132 Collections.sort(sbsAliases); |
202 Collections.sort(sbsAliases); |
133 tableViewer.setInput(sbsAliases); |
203 buildAliasTableViewer.setInput(sbsAliases); |
|
204 customVariantTableViewer.setInput(savedVariants); |
134 |
205 |
135 // check all configs |
206 // check all configs |
136 tableViewer.setAllChecked(false); |
207 buildAliasTableViewer.setAllChecked(false); |
137 |
208 customVariantTableViewer.setAllChecked(true); |
138 // now check ones from the store |
209 |
139 List<String> uncheckedConfigs = SBSv2Utils.getSBSv2FilteredConfigPreferences(); |
210 |
140 for (String config : uncheckedConfigs) { |
211 for (String config : checkedConfigsFromStore) { |
141 for (TableItem item : tableViewer.getTable().getItems()) { |
212 for (TableItem item : buildAliasTableViewer.getTable().getItems()) { |
142 if (item.getText().equals(config)) { |
213 if (item.getText().equals(config) && !item.getText().contains(".")) { |
143 tableViewer.setChecked(item.getData(), true); |
214 buildAliasTableViewer.setChecked(item.getData(), true); |
144 break; |
215 break; |
145 } |
216 } |
146 } |
217 } |
147 } |
218 } |
|
219 |
|
220 for (String config : checkedConfigsFromStore) { |
|
221 for (TableItem item : customVariantTableViewer.getTable().getItems()) { |
|
222 if (item.getText().equals(config) && item.getText().contains(".")) { |
|
223 customVariantTableViewer.setChecked(item.getData(), true); |
|
224 break; |
|
225 } |
|
226 } |
|
227 } |
|
228 |
|
229 |
148 } |
230 } |
149 |
231 |
150 public void setDefaults(){ |
232 public void setDefaults(){ |
151 initTable(true); |
233 initTable(true); |
152 for (TableItem item : tableViewer.getTable().getItems()) { |
234 for (TableItem item : buildAliasTableViewer.getTable().getItems()) { |
153 if (item.getText().toLowerCase().equals("armv5_udeb") || |
235 if (item.getText().toLowerCase().equals("armv5_udeb") || |
154 item.getText().toLowerCase().equals("armv5_urel") || |
236 item.getText().toLowerCase().equals("armv5_urel") || |
155 item.getText().toLowerCase().equals("armv5_udeb_gcce") || |
237 item.getText().toLowerCase().equals("armv5_udeb_gcce") || |
156 item.getText().toLowerCase().equals("armv5_urel_gcce") || |
238 item.getText().toLowerCase().equals("armv5_urel_gcce") || |
157 item.getText().toLowerCase().equals("winscw_udeb") || |
239 item.getText().toLowerCase().equals("winscw_udeb") || |
158 item.getText().toLowerCase().equals("winscw_urel")) { |
240 item.getText().toLowerCase().equals("winscw_urel")) { |
159 tableViewer.setChecked(item.getData(), true); |
241 buildAliasTableViewer.setChecked(item.getData(), true); |
160 } else { |
242 } else { |
161 tableViewer.setChecked(item.getData(), false); |
243 buildAliasTableViewer.setChecked(item.getData(), false); |
162 } |
244 } |
163 } |
245 } |
164 } |
246 } |
165 } |
247 } |