1 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 target=null; 30 protected String title=null; 31 protected String message=null; 32 33 public ExportDialog(Shell parentShell, String title, String 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 getTarget(){ 84 return target; 85 } 86 87 protected void okPressed(){ 88 String _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 |