--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpeclipse.wiki.actions.category;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * A dialog for prompting for a category and fPassword
+ */
+public class CategoryDialog extends Dialog {
+ // widgets
+ protected Text categoryField;
+
+ protected String category = null;
+
+ /**
+ * Creates a new CategoryDialog.
+ *
+ * @param parentShell
+ * the parent shell
+ * @param location
+ * the location
+ * @param defaultName
+ * the default fUser name
+ * @param message
+ * a mesage to display to the fUser
+ */
+ public CategoryDialog(Shell parentShell) {
+ super(parentShell);
+ }
+
+ /**
+ * @see Window#configureShell
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(Messages.getString("CategoryDialog.required")); //$NON-NLS-1$
+ // set F1 help
+ // WorkbenchHelp.setHelp(newShell, IHelpContextIds.USER_VALIDATION_DIALOG);
+ }
+
+ /**
+ * @see Window#create
+ */
+ public void create() {
+ super.create();
+ // add some default values
+ categoryField.setFocus();
+ }
+
+ /**
+ * @see Dialog#createDialogArea
+ */
+ protected Control createDialogArea(Composite parent) {
+ Composite top = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+
+ top.setLayout(layout);
+ top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Composite imageComposite = new Composite(top, SWT.NONE);
+ layout = new GridLayout();
+ imageComposite.setLayout(layout);
+ imageComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+
+ Composite main = new Composite(top, SWT.NONE);
+ layout = new GridLayout();
+ layout.numColumns = 3;
+ main.setLayout(layout);
+ main.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
+
+ createCategoryFields(main);
+
+ Dialog.applyDialogFont(parent);
+
+ return main;
+ }
+
+ /**
+ * Create a spacer.
+ */
+ // protected void createSpacer(Composite top, int columnSpan, int vertSpan) {
+ // Label l = new Label(top, SWT.NONE);
+ // GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
+ // data.horizontalSpan = columnSpan;
+ // data.verticalSpan = vertSpan;
+ // l.setLayoutData(data);
+ // }
+ /**
+ * Creates the three widgets that represent the fPassword entry area.
+ *
+ * @param parent
+ * the parent of the widgets
+ */
+ // protected void createPasswordFields(Composite parent) {
+ // new Label(parent, SWT.NONE).setText(Messages.getString("CategoryDialog.password")); //$NON-NLS-1$
+ //
+ // passwordField = new Text(parent, SWT.BORDER | SWT.PASSWORD);
+ // GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ // data.horizontalSpan = 2;
+ // data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
+ // passwordField.setLayoutData(data);
+ // }
+ /**
+ * Creates the three widgets that represent the fUser name entry area.
+ *
+ * @param parent
+ * the parent of the widgets
+ */
+ protected void createCategoryFields(Composite parent) {
+ new Label(parent, SWT.NONE).setText(Messages.getString("CategoryDialog.category")); //$NON-NLS-1$
+
+ categoryField = new Text(parent, SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
+ data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
+ categoryField.setLayoutData(data);
+ }
+
+ /**
+ * Returns the category entered by the fUser, or null if the fUser canceled.
+ *
+ * @return the entered category
+ */
+ public String getCategory() {
+ return category;
+ }
+
+ /**
+ * Notifies that the ok button of this dialog has been pressed.
+ * <p>
+ * The default implementation of this framework method sets this dialog's return code to <code>Window.OK</code> and closes the
+ * dialog. Subclasses may override.
+ * </p>
+ */
+ protected void okPressed() {
+ category = categoryField.getText();
+
+ super.okPressed();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#close()
+ */
+ public boolean close() {
+ return super.close();
+ }
+}
\ No newline at end of file