1 20 21 package org.apache.directory.ldapstudio.browser.common.widgets.connection; 22 23 24 import org.eclipse.jface.action.IMenuManager; 25 import org.eclipse.jface.action.MenuManager; 26 import org.eclipse.jface.viewers.TableViewer; 27 import org.eclipse.swt.widgets.Menu; 28 29 30 38 public class ConnectionConfiguration 39 { 40 41 42 private boolean disposed = false; 43 44 45 private ConnectionContentProvider contentProvider; 46 47 48 private ConnectionLabelProvider labelProvider; 49 50 51 private MenuManager contextMenuManager; 52 53 54 57 public ConnectionConfiguration() 58 { 59 } 60 61 62 65 public void dispose() 66 { 67 if ( !disposed ) 68 { 69 70 if ( contentProvider != null ) 71 { 72 contentProvider.dispose(); 73 contentProvider = null; 74 } 75 76 if ( labelProvider != null ) 77 { 78 labelProvider.dispose(); 79 labelProvider = null; 80 } 81 82 if ( contextMenuManager != null ) 83 { 84 contextMenuManager.dispose(); 85 contextMenuManager = null; 86 } 87 88 disposed = true; 89 } 90 } 91 92 93 100 public IMenuManager getContextMenuManager( TableViewer viewer ) 101 { 102 if ( this.contextMenuManager == null ) 103 { 104 this.contextMenuManager = new MenuManager(); 105 Menu menu = this.contextMenuManager.createContextMenu( viewer.getControl() ); 106 viewer.getControl().setMenu( menu ); 107 } 108 return this.contextMenuManager; 109 } 110 111 112 119 public ConnectionContentProvider getContentProvider( TableViewer viewer ) 120 { 121 if ( contentProvider == null ) 122 { 123 contentProvider = new ConnectionContentProvider(); 124 } 125 126 return contentProvider; 127 } 128 129 130 137 public ConnectionLabelProvider getLabelProvider( TableViewer viewer ) 138 { 139 if ( labelProvider == null ) 140 { 141 labelProvider = new ConnectionLabelProvider(); 142 } 143 144 return labelProvider; 145 } 146 147 } 148 | Popular Tags |