KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > apacheds > configuration > dialogs > BinaryAttributeDialog


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 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 /**
38  * This class implements the Dialog for Binary Attribute.
39  *
40  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
41  * @version $Rev$, $Date$
42  */

43 public class BinaryAttributeDialog extends Dialog
44 {
45     /** The initial value */
46     private String JavaDoc initialValue;
47
48     /** The return value */
49     private String JavaDoc returnValue;
50
51     /** The dirty flag */
52     private boolean dirty = false;
53
54     // UI Fields
55
private Text attributeText;
56
57
58     /**
59      * Creates a new instance of AttributeValueDialog.
60      */

61     public BinaryAttributeDialog( String JavaDoc initialValue )
62     {
63         super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
64         this.initialValue = initialValue;
65     }
66
67
68     /* (non-Javadoc)
69      * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
70      */

71     protected void configureShell( Shell newShell )
72     {
73         super.configureShell( newShell );
74         newShell.setText( "Binary Attribute Dialog" );
75     }
76
77
78     /* (non-Javadoc)
79      * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
80      */

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     /**
102      * Initializes the UI from the input.
103      */

104     private void initFromInput()
105     {
106         attributeText.setText( ( initialValue == null ) ? "" : initialValue );
107     }
108
109
110     /**
111      * Adds listeners to the UI Fields.
112      */

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     /* (non-Javadoc)
126      * @see org.eclipse.jface.dialogs.Dialog#okPressed()
127      */

128     protected void okPressed()
129     {
130         returnValue = attributeText.getText();
131
132         super.okPressed();
133     }
134
135
136     /**
137      * Gets the Attribute.
138      *
139      * @return
140      * the Attribute
141      */

142     public String JavaDoc getAttribute()
143     {
144         return returnValue;
145     }
146
147
148     /**
149      * Returns the dirty flag of the dialog.
150      *
151      * @return
152      * the dirty flag of the dialog
153      */

154     public boolean isDirty()
155     {
156         return dirty;
157     }
158 }
159
Popular Tags