import net.sourceforge.phpdt.internal.ui.util.PHPProjectSelector;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
public class PHPEntryPointTab extends AbstractLaunchConfigurationTab {
protected String originalFileName, originalProjectName;
+
protected PHPProjectSelector projectSelector;
+
protected PHPFileSelector fileSelector;
public PHPEntryPointTab() {
new Label(composite, SWT.NONE).setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEntryPoint.projectLabel"));
projectSelector = new PHPProjectSelector(composite);
- projectSelector.setBrowseDialogMessage(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEntryPoint.projectSelectorMessage"));
+ projectSelector.setBrowseDialogMessage(PHPDebugUiMessages
+ .getString("LaunchConfigurationTab.PHPEntryPoint.projectSelectorMessage"));
projectSelector.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
projectSelector.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) {
});
}
- protected IProject getContext() {
+ protected IResource getContext() {
IWorkbenchPage page = PHPDebugUiPlugin.getActivePage();
if (page != null) {
ISelection selection = page.getSelection();
if (!ss.isEmpty()) {
Object obj = ss.getFirstElement();
if (obj instanceof IResource)
- return ((IResource) obj).getProject();
+ return ((IResource) obj);
}
}
IEditorPart part = page.getActiveEditor();
if (part != null) {
IEditorInput input = part.getEditorInput();
IResource file = (IResource) input.getAdapter(IResource.class);
- return file.getProject();
+ if (file != null) {
+ return file;
+ }
}
}
return null;
}
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
- IProject project = getContext();
- if (project != null)
- configuration.setAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME, project.getName());
+ IResource file = getContext();
+ if (file != null) {
+ configuration.setAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME, file.getProject().getName());
+ configuration.setAttribute(PHPLaunchConfigurationAttribute.FILE_NAME,file.getProjectRelativePath().toOSString());
+ }
}
public void initializeFrom(ILaunchConfiguration configuration) {
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME, projectSelector.getSelectionText());
IFile file = fileSelector.getSelection();
- configuration.setAttribute(PHPLaunchConfigurationAttribute.FILE_NAME, file == null ? "" : file.getProjectRelativePath().toString());
+ configuration.setAttribute(PHPLaunchConfigurationAttribute.FILE_NAME, file == null ? "" : file.getProjectRelativePath()
+ .toString());
}
protected Composite createPageRoot(Composite parent) {
public boolean isValid(ILaunchConfiguration launchConfig) {
try {
-
+
String projectName = launchConfig.getAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME, "");
if (projectName.length() == 0) {
setErrorMessage(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEntryPoint.invalidProjectSelectionMessage"));
} catch (CoreException e) {
log(e);
}
-
+
setErrorMessage(null);
return true;
}
protected void log(Throwable t) {
- PHPDebugUiPlugin.getDefault().log(t);
+ PHPDebugUiPlugin.log(t);
}
public boolean canSave() {
public Image getImage() {
return PHPUiImages.get(PHPUiImages.IMG_CTOOLS_PHP_PAGE);
- }
+ }
}
\ No newline at end of file