| /******************************************************************************* |
| * Copyright (c) 2008-2011 Chair for Applied Software Engineering, |
| * Technische Universitaet Muenchen. |
| * 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: |
| * pfeifferc |
| ******************************************************************************/ |
| package org.eclipse.emf.emfstore.internal.client.ui.views.emfstorebrowser.views; |
| |
| import org.eclipse.jface.dialogs.Dialog; |
| import org.eclipse.jface.dialogs.IDialogConstants; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.layout.GridData; |
| 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; |
| |
| /** |
| * The CertificateAliasDialog allows the user to choose a designation for the |
| * certificate being imported. |
| * |
| * @author pfeifferc |
| */ |
| @Deprecated |
| public class CertificateAliasDialog extends Dialog { |
| |
| /** |
| * The message to display, or <code>null</code> if none. |
| */ |
| private final String message; |
| |
| /** |
| * The input value; the empty string by default. |
| */ |
| private String value = "";//$NON-NLS-1$ |
| |
| /** |
| * Input text widget. |
| */ |
| private Text text; |
| |
| private final String dialogTitle; |
| |
| /** |
| * Creates an input dialog with OK and Cancel buttons. Note that the dialog |
| * will have no visual representation (no widgets) until it is told to open. |
| * <p> |
| * Note that the <code>open</code> method blocks for input dialogs. |
| * </p> |
| * |
| * @param parentShell |
| * the parent shell, or <code>null</code> to create a top-level |
| * shell |
| * @param dialogTitle |
| * the dialog title, or <code>null</code> if none |
| * @param dialogMessage |
| * the dialog message, or <code>null</code> if none |
| * @param initialValue |
| * the initial input value, or <code>null</code> if none |
| * (equivalent to the empty string) |
| */ |
| public CertificateAliasDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue) { |
| super(parentShell); |
| this.dialogTitle = dialogTitle; |
| configureShell(parentShell); |
| message = dialogMessage; |
| if (initialValue == null) { |
| value = "";//$NON-NLS-1$ |
| } else { |
| value = initialValue; |
| } |
| } |
| |
| /** |
| * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
| * @param parent |
| * Parent Composite |
| * @return the composite |
| */ |
| @Override |
| protected Control createDialogArea(Composite parent) { |
| // create composite |
| final Composite composite = (Composite) super.createDialogArea(parent); |
| // create message |
| if (message != null) { |
| final Label label = new Label(composite, SWT.WRAP); |
| label.setText(message); |
| final GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL |
| | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); |
| data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); |
| label.setLayoutData(data); |
| label.setFont(parent.getFont()); |
| } |
| text = new Text(composite, SWT.SINGLE | SWT.BORDER); |
| text.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); |
| applyDialogFont(composite); |
| return composite; |
| } |
| |
| /** |
| * Returns the text area. |
| * |
| * @return the text area |
| */ |
| protected Text getText() { |
| return text; |
| } |
| |
| /** |
| * Returns the string typed into this input dialog. |
| * |
| * @return the input string |
| */ |
| public String getValue() { |
| return value; |
| } |
| |
| /** |
| * Configure the shell. |
| * |
| * @param shell |
| * shell |
| * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) |
| */ |
| @Override |
| protected void configureShell(Shell shell) { |
| super.configureShell(shell); |
| shell.setText(dialogTitle); |
| } |
| |
| } |