1 20 21 package org.apache.directory.ldapstudio.browser.ui.wizards; 22 23 24 import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils; 25 import org.eclipse.jface.wizard.WizardPage; 26 import org.eclipse.swt.SWT; 27 import org.eclipse.swt.events.SelectionEvent; 28 import org.eclipse.swt.events.SelectionListener; 29 import org.eclipse.swt.layout.GridData; 30 import org.eclipse.swt.layout.GridLayout; 31 import org.eclipse.swt.widgets.Button; 32 import org.eclipse.swt.widgets.Composite; 33 34 35 public class BatchOperationTypeWizardPage extends WizardPage 36 { 37 38 public final static int OPERATION_TYPE_NONE = -1; 39 40 public final static int OPERATION_TYPE_MODIFY = 0; 41 42 public final static int OPERATION_TYPE_DELETE = 1; 43 44 public final static int OPERATION_TYPE_CREATE_LDIF = 2; 45 46 private final static String [] OPERATION_TYPES = 47 { "Modify entries", "Delete entries", "Execute LDIF changetype fragment on each entry" }; 48 49 private Button[] operationTypeButtons; 50 51 52 public BatchOperationTypeWizardPage( String pageName, BatchOperationWizard wizard ) 53 { 54 super( pageName ); 55 super.setTitle( "Select Operation Type" ); 56 super.setDescription( "Please select the batch operation type." ); 57 super.setPageComplete( false ); 58 } 59 60 61 private void validate() 62 { 63 setPageComplete( getOperationType() != OPERATION_TYPE_NONE ); 64 } 65 66 67 public void createControl( Composite parent ) 68 { 69 70 Composite composite = new Composite( parent, SWT.NONE ); 71 GridLayout gl = new GridLayout( 1, false ); 72 composite.setLayout( gl ); 73 composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); 74 75 operationTypeButtons = new Button[OPERATION_TYPES.length]; 76 for ( int i = 0; i < operationTypeButtons.length; i++ ) 77 { 78 operationTypeButtons[i] = BaseWidgetUtils.createRadiobutton( composite, OPERATION_TYPES[i], 1 ); 79 operationTypeButtons[i].addSelectionListener( new SelectionListener() 80 { 81 public void widgetDefaultSelected( SelectionEvent e ) 82 { 83 validate(); 84 } 85 86 87 public void widgetSelected( SelectionEvent e ) 88 { 89 validate(); 90 } 91 } ); 92 } 93 operationTypeButtons[0].setSelection( true ); 94 95 validate(); 96 97 setControl( composite ); 98 99 } 100 101 102 public int getOperationType() 103 { 104 105 for ( int i = 0; i < operationTypeButtons.length; i++ ) 106 { 107 if ( operationTypeButtons[i].getSelection() ) 108 { 109 return i; 110 } 111 } 112 113 return OPERATION_TYPE_NONE; 114 } 115 116 } | Popular Tags |