blob: 75a8ce3cdb4aa7adc94a88452ae2855ce550a6b1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/*******************************************************************************
* Copyright (c) 2003 - 2005 University Of British Columbia and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* University Of British Columbia - initial API and implementation
*******************************************************************************/
package org.eclipse.mylar.bugzilla.saveQuery;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
/**
* Dialog for naming a saved query.
*/
public class SaveQueryDialog extends Dialog
{
private Text queryName;
/**
* The Ok button.
*/
private Button okButton;
/**
* The title of the dialog.
*/
private String title;
public SaveQueryDialog(Shell parentShell, String dialogTitle) {
super(parentShell);
this.title = dialogTitle;
setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
}
@Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText(title);
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
// create OK and cancel buttons
okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
okButton.setEnabled(false);
}
@Override
protected Control createDialogArea(Composite parent) {
// create composite
Composite composite = (Composite)super.createDialogArea(parent);
createMainDialogArea(composite);
return composite;
}
protected void createMainDialogArea(Composite parent) {
queryName = new Text(parent, SWT.SINGLE | SWT.BORDER);
queryName.setLayoutData(new GridData(GridData.BEGINNING | GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
queryName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (queryName.getText().compareTo("") != 0 && queryName.getText() != null)
okButton.setEnabled(true);
else
okButton.setEnabled(false);
queryNameText = queryName.getText();
}
});
}
String queryNameText;
public String getText() {
return queryNameText;
}
}
|