1 11 12 package org.eclipse.debug.internal.ui.views.memory; 13 14 import org.eclipse.swt.events.SelectionEvent; 15 import org.eclipse.swt.events.SelectionListener; 16 import org.eclipse.swt.widgets.TabFolder; 17 import org.eclipse.swt.widgets.TabItem; 18 19 24 public class ViewTabEnablementManager implements SelectionListener { 25 26 29 public void widgetSelected(SelectionEvent e) { 30 if (e.getSource() instanceof TabFolder) 31 { 32 handleTabFolderSelection(e); 33 } 34 } 35 36 39 public void widgetDefaultSelected(SelectionEvent e) { 40 41 42 } 43 44 private void handleTabFolderSelection(SelectionEvent event) 45 { 46 TabFolder folder = (TabFolder)event.getSource(); 47 48 TabItem[] selectedItems = folder.getSelection(); 49 TabItem selectedItem; 50 IMemoryViewTab selectedViewTab; 51 52 if (selectedItems.length > 0) 54 { 55 selectedItem = selectedItems[0]; 56 57 Object obj = selectedItem.getData(); 58 59 if (obj instanceof IMemoryViewTab) 60 { 61 selectedViewTab = (IMemoryViewTab)obj; 62 } 63 else 64 { 65 return; 66 } 67 } 68 else 69 { 70 return; 71 } 72 73 TabItem[] allTabs = folder.getItems(); 75 76 for (int i=0; i<allTabs.length; i++) 78 { 79 IMemoryViewTab viewTab; 80 Object obj = allTabs[i].getData(); 81 82 if (obj instanceof IMemoryViewTab) 83 { 84 viewTab = (IMemoryViewTab)obj; 85 86 if (viewTab == selectedViewTab && !viewTab.isEnabled() ) 88 { 89 viewTab.setEnabled(true); 92 viewTab.getRendering().activated(); 93 94 } 95 else if (viewTab != selectedViewTab && viewTab.isEnabled()) 96 { 97 viewTab.setEnabled(false); 99 viewTab.getRendering().deactivated(); 100 } 101 } 102 } 103 } 104 105 } 106 | Popular Tags |