Organized imports
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.ui / src / net / sourceforge / phpdt / internal / debug / ui / preferences / EditPathMapDialog.java
1 /*
2  * Created on 12.02.2004
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */
7 package net.sourceforge.phpdt.internal.debug.ui.preferences;
8
9 import net.sourceforge.phpdt.internal.debug.ui.PHPDebugUiMessages;
10 import net.sourceforge.phpdt.internal.ui.dialogs.StatusDialog;
11
12 import org.eclipse.swt.SWT;
13 import org.eclipse.swt.events.SelectionAdapter;
14 import org.eclipse.swt.events.SelectionEvent;
15 import org.eclipse.swt.layout.GridData;
16 import org.eclipse.swt.layout.GridLayout;
17 import org.eclipse.swt.widgets.Button;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.swt.widgets.Control;
20 import org.eclipse.swt.widgets.DirectoryDialog;
21 import org.eclipse.swt.widgets.Label;
22 import org.eclipse.swt.widgets.Shell;
23 import org.eclipse.swt.widgets.Text;
24
25 /**
26  * @author Christian
27  *
28  * To change the template for this generated type comment go to
29  * Window>Preferences>Java>Code Generation>Code and Comments
30  */
31 public class EditPathMapDialog extends StatusDialog {
32         
33
34         private Text fLocalPathText;
35         private Text fRemotePathText;
36         private String[] fInitialValues;
37         private String fLocalPath;
38         private String fRemotePath; 
39         
40         public EditPathMapDialog(Shell parentShell, String aDialogTitle, String[] initialValues) {
41                 super(parentShell);
42                 setTitle(aDialogTitle);
43                 fInitialValues= initialValues;
44         }
45         
46         protected void okPressed() {
47                 fLocalPath= fLocalPathText.getText();
48                 fRemotePath = fRemotePathText.getText();
49                 super.okPressed();
50         }
51         protected Control createDialogArea(Composite composite) {
52                 Composite comp = new Composite(composite, SWT.NONE);
53                 comp.setLayout(new GridLayout());       
54                                 
55                 Composite fileComp= new Composite(comp,SWT.NONE);
56                 GridLayout gridLayout = new GridLayout();               
57                 gridLayout.numColumns = 3;
58 //              gridLayout.marginHeight = 0;
59 //              gridLayout.marginWidth = 0;
60                 fileComp.setLayout(gridLayout);
61                                 
62                 Label label= new Label(fileComp,SWT.NONE);
63                 label.setText(PHPDebugUiMessages.getString("EditPathDialog.Local_Path"));//$NON-NLS-1$
64                 
65                 
66                 fLocalPathText = new Text(fileComp,SWT.SINGLE | SWT.BORDER);
67                 GridData gd = new GridData();
68                 gd.widthHint=250;
69                 fLocalPathText.setLayoutData(gd);
70                 fLocalPathText.setText(fInitialValues[0]);
71                 Button button= new Button(fileComp, SWT.PUSH);
72                 button.setText(PHPDebugUiMessages.getString("EditPathMapDialog.Browse")); //$NON-NLS-1$
73                 button.addSelectionListener(new SelectionAdapter() {
74                         public void widgetSelected(SelectionEvent e) {
75                                 handleBrowseButtonSelected();
76                         }
77                 });
78                 label= new Label(fileComp,SWT.NONE);
79                 label.setText(PHPDebugUiMessages.getString("EditPathMapDialog.Remote_Path")); //$NON-NLS-1$
80                 fRemotePathText = new Text(fileComp,SWT.SINGLE | SWT.BORDER);
81                 fRemotePathText.setText(fInitialValues[1]);
82                 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
83                 gd.horizontalSpan = 2;
84                 fRemotePathText.setLayoutData(gd);
85                 
86                 return composite;
87         }
88         
89         public String[] getPathPair() {
90                 return new String[] {fLocalPath,fRemotePath};
91         }
92         
93         
94         private void handleBrowseButtonSelected() {
95                 DirectoryDialog dd = new DirectoryDialog(getShell(),SWT.OPEN);
96                 dd.setMessage(PHPDebugUiMessages.getString("EditPathMapDialog.Select_the_directory_to_map")); //$NON-NLS-1$
97                 String path=dd.open();
98                 
99                 if (path != null)
100                         fLocalPathText.setText(path);
101                 
102         }
103
104
105 }