KickJava   Java API By Example, From Geeks To Geeks.

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


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;
22
23
24 import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils;
25 import org.apache.directory.ldapstudio.browser.core.model.ISearch;
26
27 import org.eclipse.jface.dialogs.Dialog;
28 import org.eclipse.jface.dialogs.IDialogConstants;
29 import org.eclipse.swt.SWT;
30 import org.eclipse.swt.layout.GridData;
31 import org.eclipse.swt.widgets.Button;
32 import org.eclipse.swt.widgets.Composite;
33 import org.eclipse.swt.widgets.Control;
34 import org.eclipse.swt.widgets.Group;
35 import org.eclipse.swt.widgets.Shell;
36
37
38 public class ScopeDialog extends Dialog
39 {
40
41     private String JavaDoc dialogTitle;
42
43     private boolean multi;
44
45     private int scope = -1;
46
47     private Button objectScopeButton;
48
49     private Button onelevelScopeButton;
50
51     private Button subtreeScopeButton;
52
53
54     public ScopeDialog( Shell parentShell, String JavaDoc dialogTitle, boolean multi )
55     {
56         super( parentShell );
57         super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
58         this.dialogTitle = dialogTitle;
59         this.multi = multi;
60     }
61
62
63     protected void configureShell( Shell shell )
64     {
65         super.configureShell( shell );
66         shell.setText( dialogTitle );
67     }
68
69
70     public boolean close()
71     {
72         return super.close();
73     }
74
75
76     protected void okPressed()
77     {
78         this.scope = this.objectScopeButton.getSelection() ? ISearch.SCOPE_OBJECT : this.onelevelScopeButton
79             .getSelection() ? ISearch.SCOPE_ONELEVEL : ISearch.SCOPE_SUBTREE;
80         super.okPressed();
81     }
82
83
84     protected void createButtonsForButtonBar( Composite parent )
85     {
86         createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
87         createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
88     }
89
90
91     protected Control createDialogArea( Composite parent )
92     {
93
94         Composite composite = ( Composite ) super.createDialogArea( parent );
95         GridData gd = new GridData( GridData.FILL_BOTH );
96         composite.setLayoutData( gd );
97
98         Group group = BaseWidgetUtils.createGroup( composite, "Please select the copy depth", 1 );
99         this.objectScopeButton = new Button( group, SWT.RADIO );
100         this.objectScopeButton.setSelection( true );
101         this.objectScopeButton.setText( this.multi ? "&Object (Only the copied entries)"
102             : "&Object (Only the copied entry)" );
103         this.onelevelScopeButton = new Button( group, SWT.RADIO );
104         this.onelevelScopeButton.setText( this.multi ? "O&ne Level (The copied entries and their direct children)"
105             : "O&ne Level (The copied entry and its direct children)" );
106         this.subtreeScopeButton = new Button( group, SWT.RADIO );
107         this.subtreeScopeButton.setText( this.multi ? "&Subtree (The whole subtrees)" : "&Subtree (The whole subtree)" );
108
109         applyDialogFont( composite );
110         return composite;
111
112     }
113
114
115     public int getScope()
116     {
117         return this.scope;
118     }
119
120 }
121
Popular Tags