Added: small label to make an effect of RemoteSourcePath clear
authortoshihiro <toshihiro>
Sun, 19 Aug 2007 07:57:24 +0000 (07:57 +0000)
committertoshihiro <toshihiro>
Sun, 19 Aug 2007 07:57:24 +0000 (07:57 +0000)
net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/PHPDebugUiMessages.properties
net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/launcher/PHPEnvironmentTab.java

index 0a7abc1..cee0129 100644 (file)
@@ -29,7 +29,7 @@ LaunchConfigurationTab.PHPEnvironment.interpreter_not_selected_error_message=No
 
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.label=Remote &Debug
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteCheckBox.label=Remote &Debug
-LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteTranslate.label=Cross Plattform debugging
+LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteTranslate.label=Cross Platform debugging
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteSourcePath.label=Remote &Sourcepath:
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.OpenDBGSessionInBrowserCheckBox.label=Open with DBGSession URL in internal Browser
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.label=Mapped Path:
@@ -38,6 +38,7 @@ LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Table.Title.local=l
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Add.label=Add
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Edit.label=Edit
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.Button.Remove.label=Remove
+LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.TargetFile.label=Target File:
 
 LaunchConfigurationShortcut.PHP.multipleConfigurationsError=The file you are trying to launch has multiple configurations associated with it.\nPlease launch using 'Run...' and choose a configuration.
 
index 877147d..d7a6527 100644 (file)
@@ -34,6 +34,7 @@ import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
@@ -74,6 +75,10 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
 
        protected TabFolder tabFolder;
 
+       private Text targetFile;
+
+       private String originalFileName = "";
+
        private class RemoteDebugTabListener extends SelectionAdapter implements
                        ModifyListener {
 
@@ -84,6 +89,7 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                 */
                public void modifyText(ModifyEvent e) {
                        updateLaunchConfigurationDialog();
+                       makeupTargetFile();
                }
 
                /*
@@ -107,8 +113,8 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                                setRemoteTabEnableState();
                        } else {
                                updateLaunchConfigurationDialog();
-                               ;
                        }
+                       makeupTargetFile();
 
                }
 
@@ -192,6 +198,34 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                fRemoteSourcePath.setLayoutData(gd);
                fRemoteSourcePath.addModifyListener(fListener);
 
+               // addendum - make an effect of RemoteSourcePath clear
+               Composite targetComp = new Composite(comp, SWT.NONE);
+               targetComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               GridLayout targetLayout = new GridLayout(4, false);
+               targetLayout.marginHeight = 0;
+               targetLayout.marginWidth = 3;
+               targetComp.setLayout(targetLayout);
+               Color targetColor = new Color(null, 160, 160, 160);
+               Label label_lp = new Label(targetComp, SWT.NONE);
+               label_lp.setText("(");
+               label_lp.setForeground(targetColor);
+               label_lp.setLayoutData(new GridData(GridData.BEGINNING));
+               Label targetLabel = new Label(targetComp, SWT.NONE);
+               targetLabel
+                               .setText(PHPDebugUiMessages
+                                               .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.TargetFile.label"));
+               targetLabel.setForeground(targetColor);
+               targetLabel.setLayoutData(new GridData(GridData.BEGINNING));
+               targetFile = new Text(targetComp, SWT.SINGLE);
+               targetFile.setForeground(targetColor);
+               targetFile.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               targetFile.setEditable(false);
+               Label label_rp = new Label(targetComp, SWT.NONE);
+               label_rp.setText(")");
+               label_rp.setForeground(targetColor);
+               label_rp.setLayoutData(new GridData(GridData.END));
+               // addendum
+
                createVerticalSpacer(comp, 1);
 
                Composite pathMapComp = new Composite(comp, SWT.NONE);
@@ -446,8 +480,8 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                Composite interpreterComposite = new Composite(tabFolder, SWT.NONE);
                GridLayout layout = new GridLayout();
                layout.numColumns = 2;
-//             layout.marginHeight = 0;
-//             layout.marginWidth = 0;
+               // layout.marginHeight = 0;
+               // layout.marginWidth = 0;
                interpreterComposite.setLayout(layout);
                interpreterComposite.setLayoutData(new GridData(
                                GridData.FILL_HORIZONTAL));
@@ -534,8 +568,7 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                                }
                        }
                } catch (CoreException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
+                       log(e);
                }
        }
 
@@ -580,6 +613,14 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
 
                updatePathMapFromConfig(configuration);
 
+               try {
+                       originalFileName = configuration.getAttribute(
+                                       PHPLaunchConfigurationAttribute.FILE_NAME, "");
+                       makeupTargetFile();
+               } catch (CoreException ce) {
+                       originalFileName = "";
+               }
+
        }
 
        private void updatePathMapFromConfig(ILaunchConfiguration config) {
@@ -772,4 +813,63 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                return PHPUiImages.get(PHPUiImages.IMG_CTOOLS_PHP);
        }
 
+       private void makeupTargetFile() {
+               if (!fRemoteDebugCheckBox.getSelection() || originalFileName.equals("")) {
+                       targetFile.setText("");
+                       return;
+               }
+
+               // see net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy.MapPath(PHPLineBreakpoint)
+
+               IPath remoteSourcePath = new Path(fRemoteSourcePath.getText());
+               IPath filename = new Path(originalFileName);
+               filename = remoteSourcePath.append(filename);
+               String path = filename.toOSString();
+               Map pathmap = getMapFromPathMapTable();
+
+               if (pathmap != null) {
+                       Iterator it = pathmap.keySet().iterator();
+                       while (it.hasNext()) {
+                               String k = (String) it.next();
+                               if (path.startsWith(k)) {
+                                       path = pathmap.get(k) + path.substring(k.length());
+                                       break;
+                               }
+                       }
+               }
+
+               if (remoteSourcePath.isEmpty()) {
+                       if (pathmap != null) {
+                               Iterator it = pathmap.keySet().iterator();
+                               while (it.hasNext()) {
+                                       String local = (String) it.next();
+                                       IPath remotePath = new Path((String) pathmap.get(local));
+                                       IPath localPath = new Path(local);
+                                       if (localPath.isPrefixOf(filename)) {
+                                               IPath newpath = filename.removeFirstSegments(localPath
+                                                               .matchingFirstSegments(filename));
+                                               newpath = remotePath.append(newpath);
+                                               path = newpath.toString();
+                                               if (path.substring(0, 1).equals("/")) {
+                                                       path = path.replace('\\', '/');
+                                               } else {
+                                                       path = path.replace('/', '\\');
+                                               }
+                                               break;
+                                       }
+                               }
+                       }
+               } else {
+                       if (fRemoteDebugTranslate.getSelection()) {
+                               if (remoteSourcePath.toString().substring(0, 1).equals("/")) {
+                                       path = path.replace('\\', '/');
+                               } else {
+                                       path = path.replace('/', '\\');
+                               }
+                       }
+               }
+
+               targetFile.setText(path);
+       }
+
 }
\ No newline at end of file