X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/php/launching/PHPMainTab.java b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/php/launching/PHPMainTab.java index ba510c2..ac4628a 100644 --- a/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/php/launching/PHPMainTab.java +++ b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/php/launching/PHPMainTab.java @@ -1,10 +1,13 @@ package net.sourceforge.phpeclipse.xdebug.ui.php.launching; import java.io.File; +//import java.text.MessageFormat; + import net.sourceforge.phpdt.internal.ui.PHPUiImages; import net.sourceforge.phpdt.internal.ui.util.PHPFileSelector; import net.sourceforge.phpdt.internal.ui.util.PHPProjectSelector; -import net.sourceforge.phpeclipse.xdebug.core.XDebugCorePlugin; +//import net.sourceforge.phpeclipse.xdebug.core.IXDebugPreferenceConstants; +//import net.sourceforge.phpeclipse.xdebug.core.XDebugCorePlugin; import net.sourceforge.phpeclipse.xdebug.php.launching.IXDebugConstants; import org.eclipse.core.resources.IFile; @@ -34,6 +37,7 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; public class PHPMainTab extends AbstractLaunchConfigurationTab { @@ -56,7 +60,7 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { public void createControl(Composite parent) { Font font = parent.getFont(); - + Composite comp = new Composite(parent, SWT.NONE); setControl(comp); // PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_MAIN_TAB); @@ -64,17 +68,17 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { topLayout.verticalSpacing = 0; comp.setLayout(topLayout); comp.setFont(font); - + createProjectEditor(comp); createVerticalSpacer(comp, 1); createMainTypeEditor(comp); createVerticalSpacer(comp, 1); createInterpreterEditor(comp); } - + /** * Creates the widgets for specifying a main type. - * + * * @param parent the parent composite */ private void createProjectEditor(Composite parent) { @@ -96,18 +100,18 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { updateLaunchConfigurationDialog(); } }); - } - + } + /** * Creates the widgets for specifying a php file. - * + * * @param parent the parent composite */ private void createMainTypeEditor(Composite parent) { Font font= parent.getFont(); Group mainGroup= new Group(parent, SWT.NONE); - mainGroup.setText("File: "); + mainGroup.setText("File: "); GridData gd = new GridData(GridData.FILL_HORIZONTAL); mainGroup.setLayoutData(gd); GridLayout layout = new GridLayout(); @@ -124,23 +128,23 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { } }); } - + /** * Creates the widgets for specifying debug settings. - * + * * @param parent the parent composite */ private void createInterpreterEditor(Composite parent) { Font font= parent.getFont(); Group interpreterGroup= new Group(parent, SWT.NONE); - interpreterGroup.setText("Interpreter: "); + interpreterGroup.setText("Interpreter: "); GridData gd = new GridData(GridData.FILL_HORIZONTAL); interpreterGroup.setLayoutData(gd); GridLayout layout = new GridLayout(); layout.numColumns = 2; interpreterGroup.setLayout(layout); interpreterGroup.setFont(font); - + fInterpreterText= new Text(interpreterGroup, SWT.SINGLE | SWT.BORDER); gd= new GridData(GridData.FILL_HORIZONTAL); fInterpreterText.setLayoutData(gd); @@ -151,14 +155,14 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { } }); - + fInterpreterButton= createPushButton(interpreterGroup,"Browse..", null); fInterpreterButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { handleBrowseSellected(event); } }); - + fUseDefaultInterpreterButton = new Button(interpreterGroup,SWT.CHECK); fUseDefaultInterpreterButton.setText("Use default interpreter"); gd = new GridData(GridData.FILL_HORIZONTAL); @@ -171,7 +175,7 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { }); } - + /** * Set the appropriate enabled state for the appletviewqer text widget. */ @@ -184,7 +188,7 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { fInterpreterButton.setEnabled(true); } } - + /** * Returns whether the default appletviewer is to be used */ @@ -213,7 +217,7 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { } protected IProject getContext() { - IWorkbenchPage page= XDebugCorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPage page= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); if (page != null) { ISelection selection = page.getSelection(); if (selection instanceof IStructuredSelection) { @@ -235,6 +239,7 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { } return null; } + public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { IProject project = getContext(); @@ -247,13 +252,13 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { try { String project = configuration.getAttribute(IXDebugConstants.ATTR_PHP_PROJECT, (String)null); if (project != null) { - projectSelector.setSelectionText(project); + projectSelector.setSelectionText(project); } String file = configuration.getAttribute(IXDebugConstants.ATTR_PHP_FILE, (String)null); if (file != null) { fileSelector.setSelectionText(file); } - + String interpreterFile=configuration.getAttribute(IXDebugConstants.ATTR_PHP_INTERPRETER, (String) null); if(interpreterFile!=null) fInterpreterText.setText(interpreterFile); @@ -280,7 +285,7 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { configuration.setAttribute(IXDebugConstants.ATTR_PHP_INTERPRETER, this.fInterpreterText.getText()); } - + /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration) */ @@ -292,17 +297,18 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { setErrorMessage("Project does not exist"); return false; } - String fileName=fileSelector.getSelectionText().trim(); - if (fileName.equals("")) { - setErrorMessage("No file selected."); - return false; - } - IFile file=project.getFile(fileName); - if (!file.exists()) { + String fileString=fileSelector.getSelectionText().trim(); + if (!"".equals(fileString)) { + IFile file=project.getFile(fileSelector.getSelectionText().trim()); + if (!file.exists()) { + setErrorMessage("File does not exist"); + return false; + } + } else { setErrorMessage("File does not exist"); return false; } - if (!fUseDefaultInterpreterButton.getSelection()) { + if (!fUseDefaultInterpreterButton.getSelection()) { File exe = new File(fInterpreterText.getText()); System.out.println(exe.toString()); if (!exe.exists()) { @@ -312,11 +318,11 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { } return true; } - + public Image getImage() { return PHPUiImages.get(PHPUiImages.IMG_CTOOLS_PHP_PAGE); } - + public String getName() { return "Main"; }