KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > common > dialogs > preferences > SyntaxDialog


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

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 JavaDoc[] syntaxOids;
43
44     private BinarySyntax returnSyntax;
45
46     private Combo oidCombo;
47
48
49     public SyntaxDialog( Shell parentShell, BinarySyntax currentSyntax, String JavaDoc[] 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