1 20 21 package org.apache.directory.ldapstudio.browser.common.dialogs; 22 23 24 import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils; 25 import org.apache.directory.ldapstudio.browser.core.model.ISearch; 26 27 import org.eclipse.jface.dialogs.Dialog; 28 import org.eclipse.jface.dialogs.IDialogConstants; 29 import org.eclipse.swt.SWT; 30 import org.eclipse.swt.layout.GridData; 31 import org.eclipse.swt.widgets.Button; 32 import org.eclipse.swt.widgets.Composite; 33 import org.eclipse.swt.widgets.Control; 34 import org.eclipse.swt.widgets.Group; 35 import org.eclipse.swt.widgets.Shell; 36 37 38 public class ScopeDialog extends Dialog 39 { 40 41 private String dialogTitle; 42 43 private boolean multi; 44 45 private int scope = -1; 46 47 private Button objectScopeButton; 48 49 private Button onelevelScopeButton; 50 51 private Button subtreeScopeButton; 52 53 54 public ScopeDialog( Shell parentShell, String dialogTitle, boolean multi ) 55 { 56 super( parentShell ); 57 super.setShellStyle( super.getShellStyle() | SWT.RESIZE ); 58 this.dialogTitle = dialogTitle; 59 this.multi = multi; 60 } 61 62 63 protected void configureShell( Shell shell ) 64 { 65 super.configureShell( shell ); 66 shell.setText( dialogTitle ); 67 } 68 69 70 public boolean close() 71 { 72 return super.close(); 73 } 74 75 76 protected void okPressed() 77 { 78 this.scope = this.objectScopeButton.getSelection() ? ISearch.SCOPE_OBJECT : this.onelevelScopeButton 79 .getSelection() ? ISearch.SCOPE_ONELEVEL : ISearch.SCOPE_SUBTREE; 80 super.okPressed(); 81 } 82 83 84 protected void createButtonsForButtonBar( Composite parent ) 85 { 86 createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false ); 87 createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false ); 88 } 89 90 91 protected Control createDialogArea( Composite parent ) 92 { 93 94 Composite composite = ( Composite ) super.createDialogArea( parent ); 95 GridData gd = new GridData( GridData.FILL_BOTH ); 96 composite.setLayoutData( gd ); 97 98 Group group = BaseWidgetUtils.createGroup( composite, "Please select the copy depth", 1 ); 99 this.objectScopeButton = new Button( group, SWT.RADIO ); 100 this.objectScopeButton.setSelection( true ); 101 this.objectScopeButton.setText( this.multi ? "&Object (Only the copied entries)" 102 : "&Object (Only the copied entry)" ); 103 this.onelevelScopeButton = new Button( group, SWT.RADIO ); 104 this.onelevelScopeButton.setText( this.multi ? "O&ne Level (The copied entries and their direct children)" 105 : "O&ne Level (The copied entry and its direct children)" ); 106 this.subtreeScopeButton = new Button( group, SWT.RADIO ); 107 this.subtreeScopeButton.setText( this.multi ? "&Subtree (The whole subtrees)" : "&Subtree (The whole subtree)" ); 108 109 applyDialogFont( composite ); 110 return composite; 111 112 } 113 114 115 public int getScope() 116 { 117 return this.scope; 118 } 119 120 } 121 | Popular Tags |