1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpeclipse.wiki.actions.category;
13 import org.eclipse.jface.dialogs.Dialog;
14 import org.eclipse.jface.dialogs.IDialogConstants;
15 import org.eclipse.jface.window.Window;
16 import org.eclipse.swt.SWT;
17 import org.eclipse.swt.layout.GridData;
18 import org.eclipse.swt.layout.GridLayout;
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.swt.widgets.Control;
21 import org.eclipse.swt.widgets.Label;
22 import org.eclipse.swt.widgets.Shell;
23 import org.eclipse.swt.widgets.Text;
26 * A dialog for prompting for a category and fPassword
28 public class CategoryDialog extends Dialog {
30 protected Text categoryField;
32 protected String category = null;
35 * Creates a new CategoryDialog.
42 * the default fUser name
44 * a mesage to display to the fUser
46 public CategoryDialog(Shell parentShell) {
51 * @see Window#configureShell
53 protected void configureShell(Shell newShell) {
54 super.configureShell(newShell);
55 newShell.setText(Messages.getString("CategoryDialog.required")); //$NON-NLS-1$
57 // WorkbenchHelp.setHelp(newShell, IHelpContextIds.USER_VALIDATION_DIALOG);
63 public void create() {
65 // add some default values
66 categoryField.setFocus();
70 * @see Dialog#createDialogArea
72 protected Control createDialogArea(Composite parent) {
73 Composite top = new Composite(parent, SWT.NONE);
74 GridLayout layout = new GridLayout();
75 layout.numColumns = 2;
77 top.setLayout(layout);
78 top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
80 Composite imageComposite = new Composite(top, SWT.NONE);
81 layout = new GridLayout();
82 imageComposite.setLayout(layout);
83 imageComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
85 Composite main = new Composite(top, SWT.NONE);
86 layout = new GridLayout();
87 layout.numColumns = 3;
88 main.setLayout(layout);
89 main.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
91 GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
93 createCategoryFields(main);
95 Dialog.applyDialogFont(parent);
103 // protected void createSpacer(Composite top, int columnSpan, int vertSpan) {
104 // Label l = new Label(top, SWT.NONE);
105 // GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
106 // data.horizontalSpan = columnSpan;
107 // data.verticalSpan = vertSpan;
108 // l.setLayoutData(data);
111 * Creates the three widgets that represent the fPassword entry area.
114 * the parent of the widgets
116 // protected void createPasswordFields(Composite parent) {
117 // new Label(parent, SWT.NONE).setText(Messages.getString("CategoryDialog.password")); //$NON-NLS-1$
119 // passwordField = new Text(parent, SWT.BORDER | SWT.PASSWORD);
120 // GridData data = new GridData(GridData.FILL_HORIZONTAL);
121 // data.horizontalSpan = 2;
122 // data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
123 // passwordField.setLayoutData(data);
126 * Creates the three widgets that represent the fUser name entry area.
129 * the parent of the widgets
131 protected void createCategoryFields(Composite parent) {
132 new Label(parent, SWT.NONE).setText(Messages.getString("CategoryDialog.category")); //$NON-NLS-1$
134 categoryField = new Text(parent, SWT.BORDER);
135 GridData data = new GridData(GridData.FILL_HORIZONTAL);
136 data.horizontalSpan = 2;
137 data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
138 categoryField.setLayoutData(data);
142 * Returns the category entered by the fUser, or null if the fUser canceled.
144 * @return the entered category
146 public String getCategory() {
151 * Notifies that the ok button of this dialog has been pressed.
153 * The default implementation of this framework method sets this dialog's return code to <code>Window.OK</code> and closes the
154 * dialog. Subclasses may override.
157 protected void okPressed() {
158 category = categoryField.getText();
166 * @see org.eclipse.jface.dialogs.Dialog#close()
168 public boolean close() {
169 return super.close();