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