/** * Helper method that fills the values of the "root element" combo box based on the currently * selected type radio button. Also disables the combo is there's only one choice. Always select * the first root element for the given type. * * @param type The currently selected {@link TypeInfo}, or null */ private void updateRootCombo(TypeInfo type) { IBaseLabelProvider labelProvider = new ColumnLabelProvider() { @Override public Image getImage(Object element) { return IconFactory.getInstance().getIcon(element.toString()); } }; mRootTableViewer.setContentProvider(new ArrayContentProvider()); mRootTableViewer.setLabelProvider(labelProvider); if (type != null) { // get the list of roots. The list can be empty but not null. ArrayList<String> roots = type.getRoots(); mRootTableViewer.setInput(roots.toArray()); int index = 0; // default is to select the first one String defaultRoot = type.getDefaultRoot(mValues.project); if (defaultRoot != null) { index = roots.indexOf(defaultRoot); } mRootTable.select(index < 0 ? 0 : index); mRootTable.showSelection(); } }