Author: dgeraskov
Date: 2008-11-13 07:18:06 -0500 (Thu, 13 Nov 2008)
New Revision: 11755
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationCreationWizard.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2734
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationCreationWizard.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationCreationWizard.java 2008-11-13
11:58:19 UTC (rev 11754)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationCreationWizard.java 2008-11-13
12:18:06 UTC (rev 11755)
@@ -108,115 +108,6 @@
return true;
}
- // Only used by tests - see JBIDE-2734
- static protected void createConsoleConfiguration(
- final Shell shell,
- final EclipseConsoleConfiguration oldConfig,
- final String configName,
- ConfigurationMode cmode, final String projectName, boolean useProjectClasspath, String
entityResolver, IPath propertyFilename,
- IPath cfgFile, IPath[] mappings, IPath[] classpaths, String persistenceUnitName,
String namingStrategy, IProgressMonitor monitor)
- throws CoreException {
-
- monitor.beginTask(HibernateConsoleMessages.ConsoleConfigurationCreationWizard_configuring_hibernate_console,
IProgressMonitor.UNKNOWN);
-
- if(oldConfig!=null) {
- KnownConfigurations.getInstance().removeConfiguration( oldConfig, false );
- }
-
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType(
ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID );
- String launchName =
launchManager.generateUniqueLaunchConfigurationNameFrom(configName);
- ILaunchConfigurationWorkingCopy wc = launchConfigurationType.newInstance(null,
launchName);
- wc.setAttribute( IConsoleConfigurationLaunchConstants.CONFIGURATION_FACTORY,
cmode.toString());
- wc.setAttribute( IConsoleConfigurationLaunchConstants.PROJECT_NAME, projectName );
-
- wc.setAttribute( IConsoleConfigurationLaunchConstants.PROPERTY_FILE,
safePathName(propertyFilename) );
- wc.setAttribute( IConsoleConfigurationLaunchConstants.CFG_XML_FILE,
safePathName(cfgFile) );
- wc.setAttribute( IConsoleConfigurationLaunchConstants.PERSISTENCE_UNIT_NAME,
persistenceUnitName );
-
- wc.setAttribute( IConsoleConfigurationLaunchConstants.NAMING_STRATEGY, namingStrategy
);
- wc.setAttribute( IConsoleConfigurationLaunchConstants.ENTITY_RESOLVER, entityResolver
);
-
- IRuntimeClasspathEntry[] projectEntries = new IRuntimeClasspathEntry[0];
- if(useProjectClasspath) {
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
- projectEntries = JavaRuntime.computeUnresolvedRuntimeClasspath(wc);
-
- }
-
- if(classpaths.length>0) {
- List<String> user = new ArrayList<String>();
- for (int i = 0; i < projectEntries.length; i++) {
- user.add( projectEntries[i].getMemento() );
- }
- for (int i = 0; i < classpaths.length; i++) {
- IPath entry = classpaths[i];
- IRuntimeClasspathEntry userEntry = JavaRuntime.newArchiveRuntimeClasspathEntry( entry
);
- user.add( userEntry.getMemento() );
- }
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, user);
- } else {
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, (String)null);
- }
-
- List<String> mappingFiles = new ArrayList<String>();
- for (int i = 0; i < mappings.length; i++) {
- mappingFiles.add(mappings[i].toPortableString());
- }
- wc.setAttribute( IConsoleConfigurationLaunchConstants.FILE_MAPPINGS, mappingFiles );
-
- wc.doSave();
-
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- if(StringHelper.isNotEmpty( projectName )) {
- IJavaProject project = ProjectUtils.findJavaProject( projectName );
- if(project.exists()) {
- HibernateNature hibernateNature = HibernateNature.getHibernateNature( project
);
- if(hibernateNature==null) { // project not enabled at all
- String out =
NLS.bind(HibernateConsoleMessages.ConsoleConfigurationCreationWizard_the_project,
projectName, configName);
- if( MessageDialog.openConfirm( shell,
HibernateConsoleMessages.ConsoleConfigurationCreationWizard_enable_hibernate_features,
out)) {
- ProjectUtils.toggleHibernateOnProject( project.getProject(), true,
configName );
- }
- }
- else {
- String defaultConsoleConfigurationName =
hibernateNature.getDefaultConsoleConfigurationName();
-
- if((oldConfig!=null &&
oldConfig.getName().equals(defaultConsoleConfigurationName)) ||
-
defaultConsoleConfigurationName.equals(hibernateNature.getDefaultConsoleConfigurationName()))
{ // an update so its just forced in there.
- ProjectUtils.toggleHibernateOnProject( project.getProject(), true,
configName );
- } else if(defaultConsoleConfigurationName==null) {
- String out =
NLS.bind(HibernateConsoleMessages.ConsoleConfigurationCreationWizard_the_project_named,
projectName, configName);
- if(MessageDialog.openConfirm( shell,
HibernateConsoleMessages.ConsoleConfigurationCreationWizard_enable_hibernate_features,
out)) {
- ProjectUtils.toggleHibernateOnProject( project.getProject(), true,
configName );
- }
- } else { // hibernate enabled, but not this exact one
- String out =
NLS.bind(HibernateConsoleMessages.ConsoleConfigurationCreationWizard_the_project_named_have,
new Object[]{ projectName, defaultConsoleConfigurationName, configName });
- if(MessageDialog.openConfirm( shell,
HibernateConsoleMessages.ConsoleConfigurationCreationWizard_enable_hibernate_features,
out)) {
- ProjectUtils.toggleHibernateOnProject( project.getProject(), true,
configName );
- }
- }
- }
- }
- }
-
- }});
- monitor.worked(1);
- }
-
- private static String safePathName(IPath propertyFilename) {
- if(propertyFilename==null) {
- return null;
- } else {
- return propertyFilename.toOSString();
- }
- }
-
-
-
-
/**
* We will accept the selection in the workbench to see if
* we can initialize from it.