1 20 package org.apache.directory.ldapstudio.apacheds.configuration.dialogs; 21 22 23 import org.eclipse.jface.dialogs.Dialog; 24 import org.eclipse.swt.SWT; 25 import org.eclipse.swt.events.ModifyEvent; 26 import org.eclipse.swt.events.ModifyListener; 27 import org.eclipse.swt.layout.GridData; 28 import org.eclipse.swt.layout.GridLayout; 29 import org.eclipse.swt.widgets.Composite; 30 import org.eclipse.swt.widgets.Control; 31 import org.eclipse.swt.widgets.Label; 32 import org.eclipse.swt.widgets.Shell; 33 import org.eclipse.swt.widgets.Text; 34 import org.eclipse.ui.PlatformUI; 35 36 37 43 public class BinaryAttributeDialog extends Dialog 44 { 45 46 private String initialValue; 47 48 49 private String returnValue; 50 51 52 private boolean dirty = false; 53 54 private Text attributeText; 56 57 58 61 public BinaryAttributeDialog( String initialValue ) 62 { 63 super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() ); 64 this.initialValue = initialValue; 65 } 66 67 68 71 protected void configureShell( Shell newShell ) 72 { 73 super.configureShell( newShell ); 74 newShell.setText( "Binary Attribute Dialog" ); 75 } 76 77 78 81 protected Control createDialogArea( Composite parent ) 82 { 83 Composite composite = new Composite( parent, SWT.NONE ); 84 GridLayout layout = new GridLayout( 2, false ); 85 composite.setLayout( layout ); 86 composite.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true ) ); 87 88 Label attributeLabel = new Label( composite, SWT.NONE ); 89 attributeLabel.setText( "Attribute:" ); 90 91 attributeText = new Text( composite, SWT.BORDER ); 92 attributeText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); 93 94 initFromInput(); 95 addListeners(); 96 97 return composite; 98 } 99 100 101 104 private void initFromInput() 105 { 106 attributeText.setText( ( initialValue == null ) ? "" : initialValue ); 107 } 108 109 110 113 private void addListeners() 114 { 115 attributeText.addModifyListener( new ModifyListener() 116 { 117 public void modifyText( ModifyEvent e ) 118 { 119 dirty = true; 120 } 121 } ); 122 } 123 124 125 128 protected void okPressed() 129 { 130 returnValue = attributeText.getText(); 131 132 super.okPressed(); 133 } 134 135 136 142 public String getAttribute() 143 { 144 return returnValue; 145 } 146 147 148 154 public boolean isDirty() 155 { 156 return dirty; 157 } 158 } 159 | Popular Tags |