1 11 package org.eclipse.ant.internal.ui.launchConfigurations; 12 13 import org.eclipse.core.resources.IFile; 14 import org.eclipse.core.resources.IResource; 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.core.variables.VariablesPlugin; 17 import org.eclipse.debug.core.DebugPlugin; 18 import org.eclipse.debug.core.ILaunchConfiguration; 19 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 20 import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; 21 import org.eclipse.debug.ui.CommonTab; 22 import org.eclipse.debug.ui.DebugUITools; 23 import org.eclipse.debug.ui.IDebugUIConstants; 24 import org.eclipse.debug.ui.ILaunchConfigurationDialog; 25 import org.eclipse.debug.ui.ILaunchConfigurationTab; 26 import org.eclipse.debug.ui.RefreshTab; 27 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; 28 import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants; 29 30 public class AntTabGroup extends AbstractLaunchConfigurationTabGroup { 31 32 35 public void initializeFrom(ILaunchConfiguration configuration) { 36 try { 37 boolean captureOutput = configuration.getAttribute(IExternalToolConstants.ATTR_CAPTURE_OUTPUT, true); 38 if (!captureOutput && configuration instanceof ILaunchConfigurationWorkingCopy) { 39 ILaunchConfigurationWorkingCopy copy = (ILaunchConfigurationWorkingCopy) configuration; 40 copy.setAttribute(IExternalToolConstants.ATTR_CAPTURE_OUTPUT, (String )null); 41 copy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, false); 42 copy.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, false); 43 } 44 } catch (CoreException e) { 45 } 46 super.initializeFrom(configuration); 47 } 48 49 52 public void createTabs(ILaunchConfigurationDialog dialog, String mode) { 53 ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] { 54 new AntMainTab(), 55 new RefreshTab(), 56 new AntBuildTab(), 57 new AntTargetsTab(), 58 new AntClasspathTab(), 59 new AntPropertiesTab(), 60 new AntJRETab(), 61 new AntEnvironmentTab(), 62 new CommonTab() 63 }; 64 setTabs(tabs); 65 } 66 67 70 public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { 71 IResource resource = DebugUITools.getSelectedResource(); 73 if (resource != null && resource instanceof IFile) { 74 IFile file = (IFile)resource; 75 String extension = file.getFileExtension(); 76 if (extension != null && extension.equalsIgnoreCase("xml")) { String projectName= file.getProject().getName(); 78 StringBuffer buffer = new StringBuffer (projectName); 79 buffer.append(' '); 80 buffer.append(file.getName()); 81 String name = buffer.toString().trim(); 82 name= DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(name); 83 configuration.rename(name); 84 configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName); 86 configuration.setAttribute(IExternalToolConstants.ATTR_LOCATION, 87 VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc", file.getFullPath().toString())); } 89 } 90 configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, "org.eclipse.ant.ui.AntClasspathProvider"); super.setDefaults(configuration); 92 } 93 } 94 | Popular Tags |