1 11 package org.eclipse.ant.internal.ui.launchConfigurations; 12 13 import com.ibm.icu.text.MessageFormat; 14 15 import org.eclipse.ant.internal.ui.AntUIPlugin; 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.debug.core.ILaunchConfiguration; 18 import org.eclipse.jdt.internal.debug.ui.launcher.WorkingDirectoryBlock; 19 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; 20 import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; 21 22 23 public class AntWorkingDirectoryBlock extends WorkingDirectoryBlock { 24 25 private String fDefaultWorkingDirPath; 26 27 31 public String getDefaultWorkingDirPath() { 32 return fDefaultWorkingDirPath; 33 } 34 35 38 protected void setDefaultWorkingDir() { 39 if (fDefaultWorkingDirPath == null) { 40 super.setDefaultWorkingDir(); 41 return; 42 } 43 setDefaultWorkingDirectoryText(fDefaultWorkingDirPath); 44 } 45 46 49 public void initializeFrom(ILaunchConfiguration configuration) { 50 setLaunchConfiguration(configuration); 51 try { 52 try { 53 fDefaultWorkingDirPath= ExternalToolsUtil.getLocation(configuration).removeLastSegments(1).toOSString(); 54 } 55 catch(CoreException ce){} 56 String wd = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String )null); 57 setDefaultWorkingDir(); 58 if (wd != null || !isSameAsDefault(wd)) { 59 setOtherWorkingDirectoryText(wd); 60 } 61 } catch (CoreException e) { 62 setErrorMessage(MessageFormat.format(AntLaunchConfigurationMessages.AntWorkingDirectoryBlock_0, new String [] {e.getStatus().getMessage()})); 63 AntUIPlugin.log(e); 64 } 65 } 66 67 private boolean isSameAsDefault(String workingDir) { 68 return workingDir == null || (workingDir.equals(fDefaultWorkingDirPath) || workingDir.equals(System.getProperty("user.dir"))); } 70 71 74 protected void setEnabled(boolean enabled) { 75 super.setEnabled(enabled); 76 } 77 } 78 | Popular Tags |