1 20 21 package org.apache.directory.ldapstudio.browser.common.dialogs.preferences; 22 23 24 import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils; 25 import org.apache.directory.ldapstudio.browser.core.model.schema.BinarySyntax; 26 27 import org.eclipse.jface.dialogs.Dialog; 28 import org.eclipse.jface.dialogs.IDialogConstants; 29 import org.eclipse.swt.events.ModifyEvent; 30 import org.eclipse.swt.events.ModifyListener; 31 import org.eclipse.swt.widgets.Combo; 32 import org.eclipse.swt.widgets.Composite; 33 import org.eclipse.swt.widgets.Control; 34 import org.eclipse.swt.widgets.Shell; 35 36 37 public class SyntaxDialog extends Dialog 38 { 39 40 private BinarySyntax currentSyntax; 41 42 private String [] syntaxOids; 43 44 private BinarySyntax returnSyntax; 45 46 private Combo oidCombo; 47 48 49 public SyntaxDialog( Shell parentShell, BinarySyntax currentSyntax, String [] syntaxOids ) 50 { 51 super( parentShell ); 52 this.currentSyntax = currentSyntax; 53 this.syntaxOids = syntaxOids; 54 55 this.returnSyntax = null; 56 } 57 58 59 protected void configureShell( Shell newShell ) 60 { 61 super.configureShell( newShell ); 62 newShell.setText( "Select Syntax OID" ); 63 } 64 65 66 protected void okPressed() 67 { 68 this.returnSyntax = new BinarySyntax( oidCombo.getText() ); 69 super.okPressed(); 70 } 71 72 73 protected Control createDialogArea( Composite parent ) 74 { 75 76 Composite composite = ( Composite ) super.createDialogArea( parent ); 77 78 Composite c = BaseWidgetUtils.createColumnContainer( composite, 2, 1 ); 79 BaseWidgetUtils.createLabel( c, "Attribute Type or OID:", 1 ); 80 this.oidCombo = BaseWidgetUtils.createCombo( c, this.syntaxOids, -1, 1 ); 81 if ( this.currentSyntax != null ) 82 { 83 this.oidCombo.setText( currentSyntax.getSyntaxNumericOid() ); 84 } 85 this.oidCombo.addModifyListener( new ModifyListener() 86 { 87 public void modifyText( ModifyEvent e ) 88 { 89 validate(); 90 } 91 } ); 92 93 return composite; 94 } 95 96 97 private void validate() 98 { 99 super.getButton( IDialogConstants.OK_ID ).setEnabled( !"".equals( this.oidCombo.getText() ) ); 100 } 101 102 103 public BinarySyntax getSyntax() 104 { 105 return returnSyntax; 106 } 107 108 } 109 | Popular Tags |