A massive organize imports and formatting of the sources using default Eclipse code...
[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         private Text fLocalPathText;
34
35         private Text fRemotePathText;
36
37         private String[] fInitialValues;
38
39         private String fLocalPath;
40
41         private String fRemotePath;
42
43         public EditPathMapDialog(Shell parentShell, String aDialogTitle,
44                         String[] initialValues) {
45                 super(parentShell);
46                 setTitle(aDialogTitle);
47                 fInitialValues = initialValues;
48         }
49
50         protected void okPressed() {
51                 fLocalPath = fLocalPathText.getText();
52                 fRemotePath = fRemotePathText.getText();
53                 super.okPressed();
54         }
55
56         protected Control createDialogArea(Composite composite) {
57                 Composite comp = new Composite(composite, SWT.NONE);
58                 comp.setLayout(new GridLayout());
59
60                 Composite fileComp = new Composite(comp, SWT.NONE);
61                 GridLayout gridLayout = new GridLayout();
62                 gridLayout.numColumns = 3;
63                 // gridLayout.marginHeight = 0;
64                 // gridLayout.marginWidth = 0;
65                 fileComp.setLayout(gridLayout);
66
67                 Label label = new Label(fileComp, SWT.NONE);
68                 label
69                                 .setText(PHPDebugUiMessages
70                                                 .getString("EditPathDialog.Local_Path"));//$NON-NLS-1$
71
72                 fLocalPathText = new Text(fileComp, SWT.SINGLE | SWT.BORDER);
73                 GridData gd = new GridData();
74                 gd.widthHint = 250;
75                 fLocalPathText.setLayoutData(gd);
76                 fLocalPathText.setText(fInitialValues[0]);
77                 Button button = new Button(fileComp, SWT.PUSH);
78                 button
79                                 .setText(PHPDebugUiMessages
80                                                 .getString("EditPathMapDialog.Browse")); //$NON-NLS-1$
81                 button.addSelectionListener(new SelectionAdapter() {
82                         public void widgetSelected(SelectionEvent e) {
83                                 handleBrowseButtonSelected();
84                         }
85                 });
86                 label = new Label(fileComp, SWT.NONE);
87                 label.setText(PHPDebugUiMessages
88                                 .getString("EditPathMapDialog.Remote_Path")); //$NON-NLS-1$
89                 fRemotePathText = new Text(fileComp, SWT.SINGLE | SWT.BORDER);
90                 fRemotePathText.setText(fInitialValues[1]);
91                 gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
92                 gd.horizontalSpan = 2;
93                 fRemotePathText.setLayoutData(gd);
94
95                 return composite;
96         }
97
98         public String[] getPathPair() {
99                 return new String[] { fLocalPath, fRemotePath };
100         }
101
102         private void handleBrowseButtonSelected() {
103                 DirectoryDialog dd = new DirectoryDialog(getShell(), SWT.OPEN);
104                 dd.setMessage(PHPDebugUiMessages
105                                 .getString("EditPathMapDialog.Select_the_directory_to_map")); //$NON-NLS-1$
106                 String path = dd.open();
107
108                 if (path != null)
109                         fLocalPathText.setText(path);
110
111         }
112
113 }