1 20 21 package org.apache.directory.ldapstudio.browser.common.widgets.search; 22 23 24 import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils; 25 import org.apache.directory.ldapstudio.browser.common.widgets.BrowserWidget; 26 import org.apache.directory.ldapstudio.browser.core.model.IConnection; 27 import org.eclipse.swt.events.SelectionAdapter; 28 import org.eclipse.swt.events.SelectionEvent; 29 import org.eclipse.swt.widgets.Button; 30 import org.eclipse.swt.widgets.Composite; 31 import org.eclipse.swt.widgets.Group; 32 33 34 42 public class AliasesDereferencingWidget extends BrowserWidget 43 { 44 45 46 private int initialAliasesDereferencingMethod; 47 48 49 private Group group; 50 51 52 private Button findingButton; 53 54 55 private Button searchButton; 56 57 58 66 public AliasesDereferencingWidget( int initialAliasesDereferencingMethod ) 67 { 68 this.initialAliasesDereferencingMethod = initialAliasesDereferencingMethod; 69 } 70 71 72 76 public AliasesDereferencingWidget() 77 { 78 this.initialAliasesDereferencingMethod = IConnection.DEREFERENCE_ALIASES_NEVER; 79 } 80 81 82 87 public void createWidget( Composite parent ) 88 { 89 90 group = BaseWidgetUtils.createGroup( parent, "Aliases Dereferencing", 1 ); 91 Composite groupComposite = BaseWidgetUtils.createColumnContainer( group, 1, 1 ); 92 93 findingButton = BaseWidgetUtils.createCheckbox( groupComposite, "Finding Base DN", 1 ); 94 findingButton.addSelectionListener( new SelectionAdapter() 95 { 96 public void widgetSelected( SelectionEvent e ) 97 { 98 notifyListeners(); 99 } 100 } ); 101 102 searchButton = BaseWidgetUtils.createCheckbox( groupComposite, "Search", 1 ); 103 searchButton.addSelectionListener( new SelectionAdapter() 104 { 105 public void widgetSelected( SelectionEvent e ) 106 { 107 notifyListeners(); 108 } 109 } ); 110 111 setAliasesDereferencingMethod( initialAliasesDereferencingMethod ); 112 } 113 114 115 122 public void setAliasesDereferencingMethod( int aliasesDereferencingMethod ) 123 { 124 initialAliasesDereferencingMethod = aliasesDereferencingMethod; 125 findingButton.setSelection( initialAliasesDereferencingMethod == IConnection.DEREFERENCE_ALIASES_FINDING 126 || initialAliasesDereferencingMethod == IConnection.DEREFERENCE_ALIASES_ALWAYS ); 127 searchButton.setSelection( initialAliasesDereferencingMethod == IConnection.DEREFERENCE_ALIASES_SEARCH 128 || initialAliasesDereferencingMethod == IConnection.DEREFERENCE_ALIASES_ALWAYS ); 129 } 130 131 132 139 public int getAliasesDereferencingMethod() 140 { 141 if ( findingButton.getSelection() && searchButton.getSelection() ) 142 { 143 return IConnection.DEREFERENCE_ALIASES_ALWAYS; 144 } 145 else if ( findingButton.getSelection() ) 146 { 147 return IConnection.DEREFERENCE_ALIASES_FINDING; 148 } 149 else if ( searchButton.getSelection() ) 150 { 151 return IConnection.DEREFERENCE_ALIASES_SEARCH; 152 } 153 else 154 { 155 return IConnection.DEREFERENCE_ALIASES_NEVER; 156 } 157 } 158 159 160 165 public void setEnabled( boolean b ) 166 { 167 group.setEnabled( b ); 168 findingButton.setEnabled( b ); 169 searchButton.setEnabled( b ); 170 } 171 172 } 173 | Popular Tags |