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