Index: CodeGenerationLaunchDelegate.java =================================================================== --- CodeGenerationLaunchDelegate.java (revision 28039) +++ CodeGenerationLaunchDelegate.java (working copy) @@ -26,6 +26,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.lang.reflect.Constructor; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -56,7 +57,6 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.ui.RefreshTab; import org.eclipse.jdt.core.IJavaProject; @@ -174,6 +174,28 @@ createFile(externalPropFileName, propFileContentPreSave); } + public class MockLaunchConfig extends LaunchConfigDecorator { + + protected Map tmpAttr = new HashMap(); + + public MockLaunchConfig(ILaunchConfiguration original) throws CoreException { + super(original); + } + + public void setTmpAttribute(String attributeName, String value) { + tmpAttr.put(attributeName, value); + } + + @Override + public String getAttribute(String attributeName, String defaultValue) throws CoreException { + String res = tmpAttr.get(attributeName); + if (res == null) { + res = super.getAttribute(attributeName, defaultValue); + } + return res; + } + } + /** * Update launch configuration with attributes required for external process codegen. * @@ -182,7 +204,7 @@ * @throws CoreException */ public ILaunchConfiguration updateLaunchConfig(ILaunchConfiguration lc) throws CoreException { - ILaunchConfigurationWorkingCopy lcwc = lc.getWorkingCopy(); + MockLaunchConfig mlc = new MockLaunchConfig(lc); String fileName = null; try { fileName = getPath2GenBuildXml().toString(); @@ -190,15 +212,15 @@ throw new CoreException(HibernateConsolePlugin.throwableToStatus(e, 666)); } // setup location of Ant build.xml file - lcwc.setAttribute(IExternalToolConstants.ATTR_LOCATION, fileName); + mlc.setTmpAttribute(IExternalToolConstants.ATTR_LOCATION, fileName); // setup Ant runner main type - lcwc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, + mlc.setTmpAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, IAntLaunchConstants.MAIN_TYPE_NAME); // setup ant remote process factory - lcwc.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, "org.eclipse.ant.ui.remoteAntProcessFactory"); //$NON-NLS-1$ + mlc.setTmpAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, "org.eclipse.ant.ui.remoteAntProcessFactory"); //$NON-NLS-1$ // refresh whole workspace - //lcwc.setAttribute(RefreshUtil.ATTR_REFRESH_SCOPE, RefreshUtil.MEMENTO_WORKSPACE); - return lcwc; + //mlc.setTmpAttribute(RefreshUtil.ATTR_REFRESH_SCOPE, RefreshUtil.MEMENTO_WORKSPACE); + return mlc; } public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) Index: LaunchConfigDecorator.java =================================================================== --- LaunchConfigDecorator.java (revision 0) +++ LaunchConfigDecorator.java (revision 0) @@ -0,0 +1,188 @@ +package org.hibernate.eclipse.launch; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchDelegate; + +public class LaunchConfigDecorator implements ILaunchConfiguration { + + private final ILaunchConfiguration lc; + + public LaunchConfigDecorator(ILaunchConfiguration lc) { + this.lc = lc; + } + + @Override + public Object getAdapter(Class adapter) { + return lc.getAdapter(adapter); + } + + @Override + public boolean contentsEqual(ILaunchConfiguration configuration) { + return lc.contentsEqual(configuration); + } + + @Override + public ILaunchConfigurationWorkingCopy copy(String name) throws CoreException { + return lc.copy(name); + } + + @Override + public void delete() throws CoreException { + lc.delete(); + } + + @Override + public boolean exists() { + return lc.exists(); + } + + @Override + public boolean getAttribute(String attributeName, boolean defaultValue) throws CoreException { + return lc.getAttribute(attributeName, defaultValue); + } + + @Override + public int getAttribute(String attributeName, int defaultValue) throws CoreException { + return lc.getAttribute(attributeName, defaultValue); + } + + @Override + public List getAttribute(String attributeName, List defaultValue) throws CoreException { + return lc.getAttribute(attributeName, defaultValue); + } + + @Override + public Set getAttribute(String attributeName, Set defaultValue) throws CoreException { + return lc.getAttribute(attributeName, defaultValue); + } + + @Override + public Map getAttribute(String attributeName, Map defaultValue) throws CoreException { + return lc.getAttribute(attributeName, defaultValue); + } + + @Override + public String getAttribute(String attributeName, String defaultValue) throws CoreException { + return lc.getAttribute(attributeName, defaultValue); + } + + @Override + public Map getAttributes() throws CoreException { + return lc.getAttributes(); + } + + @Override + public String getCategory() throws CoreException { + return lc.getCategory(); + } + + @Override + public IFile getFile() { + return lc.getFile(); + } + + @Override + public IPath getLocation() { + return lc.getLocation(); + } + + @Override + public IResource[] getMappedResources() throws CoreException { + return lc.getMappedResources(); + } + + @Override + public String getMemento() throws CoreException { + return lc.getMemento(); + } + + @Override + public String getName() { + return lc.getName(); + } + + @Override + public Set getModes() throws CoreException { + return lc.getModes(); + } + + @Override + public ILaunchDelegate getPreferredDelegate(Set modes) throws CoreException { + return lc.getPreferredDelegate(modes); + } + + @Override + public ILaunchConfigurationType getType() throws CoreException { + return lc.getType(); + } + + @Override + public ILaunchConfigurationWorkingCopy getWorkingCopy() throws CoreException { + return lc.getWorkingCopy(); + } + + @Override + public boolean hasAttribute(String attributeName) throws CoreException { + return lc.hasAttribute(attributeName); + } + + @Override + public boolean isLocal() { + return lc.isLocal(); + } + + @Override + public boolean isMigrationCandidate() throws CoreException { + return lc.isMigrationCandidate(); + } + + @Override + public boolean isWorkingCopy() { + return lc.isWorkingCopy(); + } + + @Override + public ILaunch launch(String mode, IProgressMonitor monitor) throws CoreException { + return lc.launch(mode, monitor); + } + + @Override + public ILaunch launch(String mode, IProgressMonitor monitor, boolean build) + throws CoreException { + return lc.launch(mode, monitor, build); + } + + @Override + public ILaunch launch(String mode, IProgressMonitor monitor, boolean build, boolean register) + throws CoreException { + return lc.launch(mode, monitor, build, register); + } + + @Override + public void migrate() throws CoreException { + lc.migrate(); + } + + @Override + public boolean supportsMode(String mode) throws CoreException { + return lc.supportsMode(mode); + } + + @Override + public boolean isReadOnly() { + return lc.isReadOnly(); + } + +}