1 20 21 package org.apache.directory.ldapstudio.browser.ui.editors.searchresult; 22 23 24 import org.apache.directory.ldapstudio.valueeditors.ValueEditorManager; 25 import org.eclipse.jface.action.IMenuManager; 26 import org.eclipse.jface.action.MenuManager; 27 import org.eclipse.jface.viewers.TableViewer; 28 import org.eclipse.swt.widgets.Menu; 29 import org.eclipse.ui.IWorkbenchPart; 30 31 32 public class SearchResultEditorConfiguration 33 { 34 35 private boolean disposed = false; 36 37 protected SearchResultEditorCursor cursor; 38 39 protected SearchResultEditorSorter sorter; 40 41 protected SearchResultEditorFilter filter; 42 43 protected SearchResultEditorContentProvider contentProvider; 44 45 protected SearchResultEditorLabelProvider labelProvider; 46 47 protected SearchResultEditorCellModifier cellModifier; 48 49 protected ValueEditorManager valueEditorManager; 50 51 protected MenuManager contextMenuManager; 52 53 54 public SearchResultEditorConfiguration( IWorkbenchPart part ) 55 { 56 super(); 57 } 58 59 60 public void dispose() 61 { 62 if ( !this.disposed ) 63 { 64 65 if ( this.contentProvider != null ) 66 this.contentProvider.dispose(); 67 this.contentProvider = null; 68 69 if ( this.labelProvider != null ) 70 this.labelProvider.dispose(); 71 this.labelProvider = null; 72 73 if ( this.cellModifier != null ) 74 this.cellModifier.dispose(); 75 this.cellModifier = null; 76 77 if ( this.valueEditorManager != null ) 78 this.valueEditorManager.dispose(); 79 this.valueEditorManager = null; 80 81 if ( this.contextMenuManager != null ) 82 this.contextMenuManager.dispose(); 83 this.contextMenuManager = null; 84 85 if ( this.cursor != null ) 86 this.cursor.dispose(); 87 this.cursor = null; 88 89 this.disposed = true; 90 } 91 } 92 93 94 public SearchResultEditorSorter getSorter() 95 { 96 if ( this.sorter == null ) 97 this.sorter = new SearchResultEditorSorter(); 98 99 return sorter; 100 } 101 102 103 public SearchResultEditorFilter getFilter() 104 { 105 if ( this.filter == null ) 106 this.filter = new SearchResultEditorFilter(); 107 108 return filter; 109 } 110 111 112 public IMenuManager getContextMenuManager( TableViewer viewer ) 113 { 114 if ( this.contextMenuManager == null ) 115 { 116 this.contextMenuManager = new MenuManager(); 117 Menu menu = this.contextMenuManager.createContextMenu( viewer.getControl() ); 118 getCursor( viewer ).setMenu( menu ); 119 } 120 return this.contextMenuManager; 121 } 122 123 124 public SearchResultEditorContentProvider getContentProvider( SearchResultEditorWidget mainWidget ) 125 { 126 if ( this.contentProvider == null ) 127 this.contentProvider = new SearchResultEditorContentProvider( mainWidget, this ); 128 129 return contentProvider; 130 } 131 132 133 public SearchResultEditorLabelProvider getLabelProvider( TableViewer viewer ) 134 { 135 if ( this.labelProvider == null ) 136 this.labelProvider = new SearchResultEditorLabelProvider( viewer, this.getValueEditorManager( viewer ) ); 137 138 return labelProvider; 139 } 140 141 142 public SearchResultEditorCellModifier getCellModifier( TableViewer viewer ) 143 { 144 if ( this.cellModifier == null ) 145 this.cellModifier = new SearchResultEditorCellModifier( viewer, this.getValueEditorManager( viewer ) ); 146 147 return cellModifier; 148 } 149 150 151 public SearchResultEditorCursor getCursor( TableViewer viewer ) 152 { 153 if ( this.cursor == null ) 154 this.cursor = new SearchResultEditorCursor( viewer ); 155 156 return cursor; 157 } 158 159 160 public ValueEditorManager getValueEditorManager( TableViewer viewer ) 161 { 162 if ( this.valueEditorManager == null ) 163 this.valueEditorManager = new ValueEditorManager( viewer.getTable() ); 164 165 return valueEditorManager; 166 } 167 168 } 169 | Popular Tags |