Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: df4c889aa9d518129901bf121e02596f609cd70c (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
91
92
93
94
95
96
97
98
99
100
101
102
103
/*******************************************************************************
 * Copyright (c) 2000, 2007 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     Atsuhiko Yamanaka, JCraft,Inc. - initial API and implementation.
 *     IBM Corporation - ongoing maintenance
 *     Sebastian Davids (sdavids@gmx.de) - Bug 54599 [SSH2] Export SSH Key ... Dialog does not standard margins
 *******************************************************************************/
package org.eclipse.jsch.internal.ui.preference;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jsch.internal.ui.Messages;
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;

class ExportDialog extends Dialog{
	protected Text field;
	protected String target=null;
	protected String title=null;
	protected String message=null;

	public ExportDialog(Shell parentShell, String title, String message){
		super(parentShell);
		this.title=title;
		this.message=message;
	}

	protected void configureShell(Shell newShell){
		super.configureShell(newShell);
		newShell.setText(title);
	}

	public void create(){
		super.create();
		field.setFocus();
	}

	protected Control createDialogArea(Composite parent){
		initializeDialogUnits(parent);
		Composite main=new Composite(parent, SWT.NONE);
		GridLayout layout=new GridLayout();
		layout.numColumns=2;
		layout.marginHeight=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
		layout.marginWidth=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
		layout.verticalSpacing=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
		layout.horizontalSpacing=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
		main.setLayout(layout);
		main.setLayoutData(new GridData(GridData.FILL_BOTH));

		if(message!=null){
			Label messageLabel=new Label(main, SWT.WRAP);
			messageLabel.setText(message);
			GridData data=new GridData(GridData.FILL_HORIZONTAL);
			data.horizontalSpan=2;
			messageLabel.setLayoutData(data);
		}

		createTargetFields(main);
		Dialog.applyDialogFont(main);
		return main;
	}

	protected void createTargetFields(Composite parent){
		new Label(parent, SWT.NONE).setText(Messages.CVSSSH2PreferencePage_125);

		field=new Text(parent, SWT.BORDER);
		GridData data=new GridData(GridData.FILL_HORIZONTAL);
		data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
		field.setLayoutData(data);
	}

	public String getTarget(){
		return target;
	}

	protected void okPressed(){
		String _target=field.getText();
		if(_target==null||_target.length()==0){
			return;
		}
		target=_target;
		super.okPressed();
	}

	protected void cancelPressed(){
		target=null;
		super.cancelPressed();
	}
}

Back to the top