/*
 * DBeaver - Universal Database Manager
 * Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jkiss.dbeaver.ui.dialogs;

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.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.jkiss.dbeaver.ui.UIUtils;

public class EnterNameDialog extends Dialog {

    private String propertyName;
    private String propertyValue;
    private Text propNameText;
    private String result;

    public EnterNameDialog(Shell parentShell, String propertyName, String propertyValue)
    {
        super(parentShell);
        this.propertyName = propertyName;
        this.propertyValue = propertyValue;
    }

    @Override
    protected boolean isResizable() {
        return true;
    }

    public String getResult()
    {
        return result;
    }

    @Override
    protected Control createDialogArea(Composite parent)
    {
        getShell().setText(propertyName);

        Composite propGroup = new Composite(parent, SWT.NONE);
        GridLayout gl = new GridLayout(1, false);
        gl.marginHeight = 10;
        gl.marginWidth = 10;
        propGroup.setLayout(gl);
        GridData gd = new GridData(GridData.FILL_BOTH);
        propGroup.setLayoutData(gd);

        propNameText = UIUtils.createLabelText(propGroup, propertyName, null);
        if (propertyValue != null) {
            propNameText.setText(propertyValue);
            propNameText.selectAll();
        }

        return propGroup;
    }

    @Override
    protected void okPressed()
    {
        result = propNameText.getText();
        super.okPressed();
    }

    public String chooseName()
    {
        if (open() == IDialogConstants.OK_ID) {
            return result;
        } else {
            return null;
        }
    }

    public static String chooseName(Shell parentShell, String propertyName)
    {
        return chooseName(parentShell, propertyName, null);
    }

    public static String chooseName(Shell parentShell, String propertyName, String propertyValue)
    {
        EnterNameDialog dialog = new EnterNameDialog(parentShell, propertyName, propertyValue);
        return dialog.chooseName();
    }
}

@@ -806,16 +806,67 @@
 tants;%0D%0A
+import org.eclipse.jface.dialogs.IDialogSettings;%0D%0A
 import o
@@ -1651,32 +1651,199 @@
 true;%0D%0A    %7D%0D%0A%0D%0A
+    @Override%0D%0A    protected IDialogSettings getDialogBoundsSettings() %7B%0D%0A        return UIUtils.getDialogSettings(%22DBeaver.EnterNameDialog%22); //$NON-NLS-1$%0D%0A    %7D%0D%0A%0D%0A
     public Strin

Rename dialog persistent settings