KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jsch > internal > ui > preference > ExportDialog


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * Atsuhiko Yamanaka, JCraft,Inc. - initial API and implementation.
10  * IBM Corporation - ongoing maintenance
11  * Sebastian Davids (sdavids@gmx.de) - Bug 54599 [SSH2] Export SSH Key ... Dialog does not standard margins
12  *******************************************************************************/

13 package org.eclipse.jsch.internal.ui.preference;
14
15 import org.eclipse.jface.dialogs.Dialog;
16 import org.eclipse.jface.dialogs.IDialogConstants;
17 import org.eclipse.jsch.internal.ui.Messages;
18 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.layout.GridData;
20 import org.eclipse.swt.layout.GridLayout;
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.swt.widgets.Control;
23 import org.eclipse.swt.widgets.Label;
24 import org.eclipse.swt.widgets.Shell;
25 import org.eclipse.swt.widgets.Text;
26
27 class ExportDialog extends Dialog{
28   protected Text field;
29   protected String JavaDoc target=null;
30   protected String JavaDoc title=null;
31   protected String JavaDoc message=null;
32
33   public ExportDialog(Shell parentShell, String JavaDoc title, String JavaDoc message){
34     super(parentShell);
35     this.title=title;
36     this.message=message;
37   }
38
39   protected void configureShell(Shell newShell){
40     super.configureShell(newShell);
41     newShell.setText(title);
42   }
43
44   public void create(){
45     super.create();
46     field.setFocus();
47   }
48
49   protected Control createDialogArea(Composite parent){
50     initializeDialogUnits(parent);
51     Composite main=new Composite(parent, SWT.NONE);
52     GridLayout layout=new GridLayout();
53     layout.numColumns=2;
54     layout.marginHeight=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
55     layout.marginWidth=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
56     layout.verticalSpacing=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
57     layout.horizontalSpacing=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
58     main.setLayout(layout);
59     main.setLayoutData(new GridData(GridData.FILL_BOTH));
60
61     if(message!=null){
62       Label messageLabel=new Label(main, SWT.WRAP);
63       messageLabel.setText(message);
64       GridData data=new GridData(GridData.FILL_HORIZONTAL);
65       data.horizontalSpan=2;
66       messageLabel.setLayoutData(data);
67     }
68
69     createTargetFields(main);
70     Dialog.applyDialogFont(main);
71     return main;
72   }
73
74   protected void createTargetFields(Composite parent){
75     new Label(parent, SWT.NONE).setText(Messages.CVSSSH2PreferencePage_125);
76
77     field=new Text(parent, SWT.BORDER);
78     GridData data=new GridData(GridData.FILL_HORIZONTAL);
79     data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
80     field.setLayoutData(data);
81   }
82
83   public String JavaDoc getTarget(){
84     return target;
85   }
86
87   protected void okPressed(){
88     String JavaDoc _target=field.getText();
89     if(_target==null||_target.length()==0){
90       return;
91     }
92     target=_target;
93     super.okPressed();
94   }
95
96   protected void cancelPressed(){
97     target=null;
98     super.cancelPressed();
99   }
100 }
101
Popular Tags