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.common.widgets.DnBuilderWidget; 26 import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyEvent; 27 import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyListener; 28 import org.apache.directory.ldapstudio.browser.core.model.DN; 29 import org.apache.directory.ldapstudio.browser.core.model.IEntry; 30 31 import org.eclipse.jface.dialogs.Dialog; 32 import org.eclipse.jface.dialogs.IDialogConstants; 33 import org.eclipse.swt.SWT; 34 import org.eclipse.swt.layout.GridData; 35 import org.eclipse.swt.widgets.Button; 36 import org.eclipse.swt.widgets.Composite; 37 import org.eclipse.swt.widgets.Control; 38 import org.eclipse.swt.widgets.Shell; 39 40 41 public class MoveEntriesDialog extends Dialog implements WidgetModifyListener 42 { 43 44 public static final String DIALOG_TITLE = "Move Entries"; 45 46 private IEntry[] entries; 47 48 private DnBuilderWidget dnBuilderWidget; 49 50 private Button simulateMoveButton; 51 52 private Button okButton; 53 54 private DN parentDn; 55 56 private boolean simulateMove; 57 58 59 public MoveEntriesDialog( Shell parentShell, IEntry[] entries ) 60 { 61 super( parentShell ); 62 super.setShellStyle( super.getShellStyle() | SWT.RESIZE ); 63 this.entries = entries; 64 this.parentDn = null; 65 } 66 67 68 protected void configureShell( Shell shell ) 69 { 70 super.configureShell( shell ); 71 shell.setText( DIALOG_TITLE ); 72 } 73 74 75 public boolean close() 76 { 77 this.dnBuilderWidget.removeWidgetModifyListener( this ); 78 this.dnBuilderWidget.dispose(); 79 return super.close(); 80 } 81 82 83 protected void okPressed() 84 { 85 this.parentDn = this.dnBuilderWidget.getParentDn(); 86 this.simulateMove = this.simulateMoveButton.getSelection(); 87 88 this.dnBuilderWidget.saveDialogSettings(); 89 90 super.okPressed(); 91 } 92 93 94 protected void createButtonsForButtonBar( Composite parent ) 95 { 96 okButton = createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true ); 97 createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false ); 98 } 99 100 101 protected Control createDialogArea( Composite parent ) 102 { 103 104 Composite composite = ( Composite ) super.createDialogArea( parent ); 105 GridData gd = new GridData( GridData.FILL_BOTH ); 106 gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ) * 3 / 2; 107 composite.setLayoutData( gd ); 108 109 BaseWidgetUtils.createLabel( composite, 110 "Please enter/select the parent DN where the selected entries should be moved to.", 1 ); 111 112 this.dnBuilderWidget = new DnBuilderWidget( false, true ); 113 this.dnBuilderWidget.addWidgetModifyListener( this ); 114 this.dnBuilderWidget.createContents( composite ); 115 this.dnBuilderWidget.setInput( this.entries[0].getConnection(), null, null, this.entries[0].getDn() 116 .getParentDn() ); 117 118 this.simulateMoveButton = BaseWidgetUtils.createCheckbox( composite, 119 "Simulate subtree moving by searching/adding/deleting recursively", 1 ); 120 this.simulateMoveButton.setSelection( false ); 121 this.simulateMoveButton.setEnabled( false ); 122 123 applyDialogFont( composite ); 124 return composite; 125 } 126 127 128 public void widgetModified( WidgetModifyEvent event ) 129 { 130 if ( this.okButton != null ) 131 { 132 this.okButton.setEnabled( this.dnBuilderWidget.getParentDn() != null ); 133 } 134 } 135 136 137 public DN getParentDn() 138 { 139 return this.parentDn; 140 } 141 142 143 public boolean isSimulateMove() 144 { 145 return simulateMove; 146 } 147 148 } 149 | Popular Tags |