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 ReferralsHandlingWidget extends BrowserWidget 43 { 44 45 46 private int initialReferralsHandlingMethod; 47 48 49 private Group group; 50 51 52 private Button ignoreButton; 53 54 55 private Button followButton; 56 57 58 66 public ReferralsHandlingWidget( int initialReferralsHandlingMethod ) 67 { 68 this.initialReferralsHandlingMethod = initialReferralsHandlingMethod; 69 } 70 71 72 76 public ReferralsHandlingWidget() 77 { 78 this.initialReferralsHandlingMethod = IConnection.HANDLE_REFERRALS_IGNORE; 79 } 80 81 82 87 public void createWidget( Composite parent ) 88 { 89 90 group = BaseWidgetUtils.createGroup( parent, "Referrals Handling", 1 ); 91 Composite groupComposite = BaseWidgetUtils.createColumnContainer( group, 1, 1 ); 92 93 ignoreButton = BaseWidgetUtils.createRadiobutton( groupComposite, "Ignore", 1 ); 94 ignoreButton.addSelectionListener( new SelectionAdapter() 95 { 96 public void widgetSelected( SelectionEvent e ) 97 { 98 notifyListeners(); 99 } 100 } ); 101 102 followButton = BaseWidgetUtils.createRadiobutton( groupComposite, "Follow", 1 ); 103 followButton.addSelectionListener( new SelectionAdapter() 104 { 105 public void widgetSelected( SelectionEvent e ) 106 { 107 notifyListeners(); 108 } 109 } ); 110 111 setReferralsHandlingMethod( initialReferralsHandlingMethod ); 112 } 113 114 115 122 public void setReferralsHandlingMethod( int referralsHandlingMethod ) 123 { 124 initialReferralsHandlingMethod = referralsHandlingMethod; 125 ignoreButton.setSelection( initialReferralsHandlingMethod == IConnection.HANDLE_REFERRALS_IGNORE ); 126 followButton.setSelection( initialReferralsHandlingMethod == IConnection.HANDLE_REFERRALS_FOLLOW ); 127 } 128 129 130 137 public int getReferralsHandlingMethod() 138 { 139 if ( ignoreButton.getSelection() ) 140 { 141 return IConnection.HANDLE_REFERRALS_IGNORE; 142 } 143 else 144 { 145 return IConnection.HANDLE_REFERRALS_FOLLOW; 146 } 147 } 148 149 150 155 public void setEnabled( boolean b ) 156 { 157 group.setEnabled( b ); 158 ignoreButton.setEnabled( b ); 159 followButton.setEnabled( b ); 160 } 161 162 } 163 | Popular Tags |