Buggy code:
private ActionSetDisplayItem ( CustomizePerspectiveDialog . ActionSetDisplayItem parent , String id , String text , int type ) { } private CustomizePerspectiveDialog . ActionSetDisplayItem find ( String itemId ) { } public void fillMenusFor ( String actionSetId , IContributionItem item ) { } public void fillToolsFor ( String actionSetId , CoolBarManager mgr ) { } int getDepth ( ) { } String getDisplayText ( ) { } protected boolean isTopLevelMenu ( ) { } public String toString ( ) { } } public class CustomizeActionBars extends AbstractActionBarConfigurer implements IActionBars2 { IWorkbenchWindowConfigurer configurer ; MenuManager menuManager = new MenuManager ( ) ; CoolBarManager coolBarManager = new CoolBarManager ( ) ; StatusLineManager statusLineManager = new StatusLineManager ( ) ; public CustomizeActionBars ( IWorkbenchWindowConfigurer configurer ) { } public IWorkbenchWindowConfigurer getWindowConfigurer ( ) { } public IMenuManager getMenuManager ( ) { } public IStatusLineManager getStatusLineManager ( ) { } public ICoolBarManager getCoolBarManager ( ) { } public IToolBarManager getToolBarManager ( ) { } public void setGlobalActionHandler ( String actionID , IAction handler ) { } public void updateActionBars ( ) { } public void clearGlobalActionHandlers ( ) { } public IAction getGlobalActionHandler ( String actionId ) { } public void registerGlobalAction ( IAction action ) { } public void dispose ( ) { } } class ShortcutMenuItemContentProvider implements IStructuredContentProvider { ShortcutMenuItemContentProvider ( ) { } public Object [ ] getElements ( Object input ) { } public void inputChanged ( Viewer viewer , Object oldInput , Object newInput ) { } public void dispose ( ) { } } class ShortcutMenuItemLabelProvider extends LabelProvider implements ITableLabelProvider { private Map imageTable = new Hashtable ( ) ; private static final int COLUMN_ID = 0 ; private static final int COLUMN_DESCRIPTION = 1 ; ShortcutMenuItemLabelProvider ( ) { } public final void dispose ( ) { } public Image getColumnImage ( Object element , int index ) { } public String getColumnText ( Object element , int columnIndex ) { } public String getText ( Object element ) { } } class ShortcutMenu extends Object { private static final String ID_VIEW = "org.eclipse.ui.views" ; private static final String ID_WIZARD = "org.eclipse.ui.wizards" ; private static final String ID_PERSP = "org.eclipse.ui.perspectives" ; String id ; String label ; private ArrayList items = new ArrayList ( ) ; private ArrayList checkedItems = new ArrayList ( ) ; ArrayList children = new ArrayList ( ) ; CustomizePerspectiveDialog . ShortcutMenu parent = null ; ShortcutMenu ( CustomizePerspectiveDialog . ShortcutMenu parent , String id , String label ) { } void addItem ( Object item ) { } void addCheckedItem ( Object item ) { } public String toString ( ) { } ArrayList getCheckedItems ( ) { } ArrayList getCheckedItemIds ( ) { } ArrayList getChildren ( ) { } ArrayList getItems ( ) { } private String getMenuId ( ) { } ArrayList getSubtreeItems ( ) { } Object getItem ( String menuItemId ) { } boolean isFullyChecked ( ) { } boolean isFullyUnchecked ( ) { } void removeCheckedItem ( Object item ) { } void checked ( boolean checked ) { } } class TreeContentProvider implements ITreeContentProvider { public void dispose ( ) { } public Object [ ] getChildren ( Object element ) { } public Object [ ] getElements ( Object element ) { } public Object getParent ( Object element ) { } public boolean hasChildren ( Object element ) { } public void inputChanged ( Viewer viewer , Object oldInput , Object newInput ) { } } class ActionSetLabelProvider extends LabelProvider { private Map imageTable = new Hashtable ( ) ; public void dispose ( ) { } public Image getImage ( Object element ) { } public String getText ( Object element ) { } } public CustomizePerspectiveDialog ( IWorkbenchWindowConfigurer configurer , Perspective persp ) { } private void addActionSetsListeners ( ) { } private void addShortcutListeners ( ) { } private void buildMenusAndToolbarsFor ( CustomizePerspectiveDialog . CustomizeActionBars customizeActionBars , ActionSetDescriptor actionSetDesc ) { } private void checkInitialActionSetSelections ( ) { } private void checkInitialMenuCategorySelections ( CustomizePerspectiveDialog . ShortcutMenu menu ) { } public boolean close ( ) { if ( showShortcutTab ( ) ) { CustomizePerspectiveDialog . lastSelectedMenuIndex = menusCombo . getSelectionIndex ( ) ; } CustomizePerspectiveDialog . lastSelectedTab = tabFolder . getSelectionIndex ( ) ; <START_BUG> StructuredSelection selection = ( ( StructuredSelection ) ( actionSetsViewer . getSelection ( ) ) ) ; <END_BUG> if ( selection . isEmpty ( ) ) CustomizePerspectiveDialog . lastSelectedActionSetId = null ; else CustomizePerspectiveDialog . lastSelectedActionSetId = ( ( ActionSetDescriptor ) ( selection . getFirstElement ( ) ) ) . getId ( ) ; return super . close ( ) ; } protected void configureShell ( Shell shell ) { } boolean containsActionSet ( MenuManager mgr , String actionSetId ) { } private Composite createActionSetsPage ( Composite parent ) { } private boolean showShortcutTab ( ) { } protected Control createDialogArea ( Composite parent ) { } private Composite createMenusPage ( Composite parent ) { } void handleActionSetMenuViewerKeyPressed ( KeyEvent event ) { } void handleActionSetSelected ( SelectionChangedEvent event ) { } void handleActionSetToolbarViewerKeyPressed ( KeyEvent event ) { } void handleActionSetViewerKeyPressed ( KeyEvent event ) { } void handleMenuCategoryChecked ( CheckStateChangedEvent event ) { } void handleMenuCategorySelected ( SelectionChangedEvent event ) { } void handleMenuItemChecked ( CheckStateChangedEvent event ) { } void handleMenuModified ( ) { } void handleMenuSelected ( ) { } void handleMenuSelected ( CustomizePerspectiveDialog . ShortcutMenu element ) { } void handleTabSelected ( SelectionEvent event ) { } private void initializeActionSetInput ( ) { } private void initializeShortCutMenu ( CustomizePerspectiveDialog . ShortcutMenu menu , IWizardCategory element , List activeIds ) { } private void initializeShortcutMenuInput ( ) { } protected void okPressed ( ) { } private void popUp ( String description ) { } String removeShortcut ( String label ) { } private void setInitialSelections ( ) { } private void updateMenuCategoryCheckedState ( CustomizePerspectiveDialog . ShortcutMenu menu ) { } protected boolean applyDialogFont ( ) { } }

Fix:
IStructuredSelection selection = ( ( IStructuredSelection ) ( actionSetsViewer . getSelection ( ) ) ) ;