From: bananeweizen Date: Wed, 1 Feb 2006 22:43:11 +0000 (+0000) Subject: avoid exception for empty file name X-Git-Url: http://git.phpeclipse.com avoid exception for empty file name --- 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 6927ed2..ba510c2 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,12 +1,9 @@ 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.IXDebugPreferenceConstants; import net.sourceforge.phpeclipse.xdebug.core.XDebugCorePlugin; import net.sourceforge.phpeclipse.xdebug.php.launching.IXDebugConstants; @@ -59,7 +56,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); @@ -67,17 +64,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) { @@ -99,18 +96,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(); @@ -127,23 +124,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); @@ -154,14 +151,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); @@ -174,7 +171,7 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { }); } - + /** * Set the appropriate enabled state for the appletviewqer text widget. */ @@ -187,7 +184,7 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { fInterpreterButton.setEnabled(true); } } - + /** * Returns whether the default appletviewer is to be used */ @@ -256,7 +253,7 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { if (file != null) { fileSelector.setSelectionText(file); } - + String interpreterFile=configuration.getAttribute(IXDebugConstants.ATTR_PHP_INTERPRETER, (String) null); if(interpreterFile!=null) fInterpreterText.setText(interpreterFile); @@ -283,7 +280,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) */ @@ -295,12 +292,17 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { setErrorMessage("Project does not exist"); return false; } - IFile file=project.getFile(fileSelector.getSelectionText().trim()); + String fileName=fileSelector.getSelectionText().trim(); + if (fileName.equals("")) { + setErrorMessage("No file selected."); + return false; + } + IFile file=project.getFile(fileName); if (!file.exists()) { 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()) { @@ -310,11 +312,11 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab { } return true; } - + public Image getImage() { return PHPUiImages.get(PHPUiImages.IMG_CTOOLS_PHP_PAGE); } - + public String getName() { return "Main"; }