Author: max.andersen(a)jboss.com
Date: 2007-11-16 12:16:23 -0500 (Fri, 16 Nov 2007)
New Revision: 4951
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/LaunchHelper.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsolePlugin.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/AddConfigurationAction.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/DeleteConfigurationAction.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/EditConsoleConfiguration.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/ProjectUtils.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationsViewActionGroup.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationCreationWizard.java
Log:
JBIDE-1326 exception creating hibernate configuration
(we deleted the configuration instead of just reset it when a launchconfiguration is
changed)
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsolePlugin.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsolePlugin.java 2007-11-16
16:13:53 UTC (rev 4950)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsolePlugin.java 2007-11-16
17:16:23 UTC (rev 4951)
@@ -184,11 +184,7 @@
ConsoleConfiguration oldcfg = instance.find( configuration.getName() );
if(oldcfg!=null) {
oldcfg.reset(); // reset it no matter what.
-
- instance.removeConfiguration(oldcfg, true);
-
- ConsoleConfigurationPreferences adapter =
buildConfigurationPreferences(configuration);
- instance.addConfiguration(new ConsoleConfiguration(adapter), true);
+
}
}
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/AddConfigurationAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/AddConfigurationAction.java 2007-11-16
16:13:53 UTC (rev 4950)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/AddConfigurationAction.java 2007-11-16
17:16:23 UTC (rev 4951)
@@ -21,6 +21,8 @@
*/
package org.hibernate.eclipse.console.actions;
+import java.util.Map;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -36,7 +38,9 @@
import org.hibernate.console.ImageConstants;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.utils.EclipseImages;
+import org.hibernate.eclipse.console.utils.LaunchHelper;
import org.hibernate.eclipse.console.wizards.ConsoleConfigurationCreationWizard;
+import org.hibernate.eclipse.launch.ICodeGenerationLaunchConstants;
/**
*
@@ -68,11 +72,11 @@
try {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType(
"org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType" );
+ ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType(
ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID );
String launchName =
launchManager.generateUniqueLaunchConfigurationNameFrom("hibernate");
//ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(
launchConfigurationType );
ILaunchConfigurationWorkingCopy wc = launchConfigurationType.newInstance(null,
launchName);
- ILaunchConfiguration saved = wc.doSave();
+ ILaunchConfiguration saved = wc.doSave();
int i = DebugUITools.openLaunchConfigurationPropertiesDialog(
part.getSite().getShell(), saved, "org.eclipse.debug.ui.launchGroup.run" );
if(i!=Window.OK) {
saved.delete();
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/DeleteConfigurationAction.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/DeleteConfigurationAction.java 2007-11-16
16:13:53 UTC (rev 4950)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/DeleteConfigurationAction.java 2007-11-16
17:16:23 UTC (rev 4951)
@@ -25,6 +25,8 @@
import java.util.List;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.ui.IViewPart;
import org.eclipse.ui.actions.SelectionListenerAction;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.KnownConfigurations;
@@ -35,9 +37,12 @@
*/
public class DeleteConfigurationAction extends SelectionListenerAction {
- public DeleteConfigurationAction() {
+ private StructuredViewer part;
+
+ public DeleteConfigurationAction(StructuredViewer selectionProvider) {
super("Delete Configuration");
setEnabled(false);
+ this.part = selectionProvider;
}
public void run() {
@@ -48,6 +53,8 @@
ConsoleConfiguration element = (ConsoleConfiguration) iter.next();
KnownConfigurations.getInstance().removeConfiguration(element, false);
}
+
+ part.refresh();
}
protected boolean updateSelection(IStructuredSelection selection) {
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/EditConsoleConfiguration.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/EditConsoleConfiguration.java 2007-11-16
16:13:53 UTC (rev 4950)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/EditConsoleConfiguration.java 2007-11-16
17:16:23 UTC (rev 4951)
@@ -39,6 +39,7 @@
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.wizards.ConsoleConfigurationCreationWizard;
+import org.hibernate.eclipse.launch.ICodeGenerationLaunchConstants;
/**
* @author max
@@ -95,14 +96,16 @@
try {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType(
"org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType" );
+ ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType(
ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID );
ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(
launchConfigurationType );
for (int i = 0; i < launchConfigurations.length; i++) { // can't believe there
is no look up by name API
ILaunchConfiguration launchConfiguration = launchConfigurations[i];
if(launchConfiguration.getName().equals(config.getName())) {
DebugUITools.openLaunchConfigurationPropertiesDialog( win.getShell(),
launchConfiguration, "org.eclipse.debug.ui.launchGroup.run" );
+ return;
}
- }
+ }
+ HibernateConsolePlugin.getDefault().showError(win.getShell(), "Could not find
launch configuration for '" + config.getName() + "'", new
IllegalStateException("No launch configuration matched the configuration named "
+ config.getName()));
} catch (CoreException ce) {
HibernateConsolePlugin.getDefault().showError( win.getShell(), "Problem adding a
console configuration", ce);
}
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/LaunchHelper.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/LaunchHelper.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/LaunchHelper.java 2007-11-16
17:16:23 UTC (rev 4951)
@@ -0,0 +1,35 @@
+package org.hibernate.eclipse.console.utils;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchManager;
+
+public class LaunchHelper {
+
+ static public ILaunchConfiguration findLaunchConfigurationByName(String
launchConfigurationTypeId, String name) throws CoreException {
+ Assert.isNotNull(launchConfigurationTypeId, "Launch configuration type cannot be
null");
+ ILaunchManager launchManager = DebugPlugin.getDefault()
+ .getLaunchManager();
+
+
+ ILaunchConfigurationType launchConfigurationType = launchManager
+ .getLaunchConfigurationType(launchConfigurationTypeId);
+
+ ILaunchConfiguration[] launchConfigurations = launchManager
+ .getLaunchConfigurations(launchConfigurationType);
+
+ for (int i = 0; i < launchConfigurations.length; i++) { // can't believe
+ // there is no
+ // look up by
+ // name API
+ ILaunchConfiguration launchConfiguration = launchConfigurations[i];
+ if (launchConfiguration.getName().equals(name)) {
+ return launchConfiguration;
+ }
+ }
+ return null;
+ }
+}
\ No newline at end of file
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/ProjectUtils.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/ProjectUtils.java 2007-11-16
16:13:53 UTC (rev 4950)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/ProjectUtils.java 2007-11-16
17:16:23 UTC (rev 4951)
@@ -43,6 +43,7 @@
import org.eclipse.ui.IFileEditorInput;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.launch.ICodeGenerationLaunchConstants;
import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
import org.hibernate.util.StringHelper;
import org.osgi.service.prefs.BackingStoreException;
@@ -174,7 +175,7 @@
IJavaProject proj = null;
if (consoleConfiguration != null) {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType(
"org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType" );
+ ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType(
ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID );
ILaunchConfiguration[] launchConfigurations;
try {
launchConfigurations = launchManager.getLaunchConfigurations( launchConfigurationType
);
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationsViewActionGroup.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationsViewActionGroup.java 2007-11-16
16:13:53 UTC (rev 4950)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationsViewActionGroup.java 2007-11-16
17:16:23 UTC (rev 4951)
@@ -59,7 +59,7 @@
this.selectionProvider = selectionProvider;
addConfigurationAction = new AddConfigurationAction(part);
- deleteConfigurationAction = new DeleteConfigurationAction();
+ deleteConfigurationAction = new DeleteConfigurationAction(selectionProvider);
selectionProvider.addSelectionChangedListener(deleteConfigurationAction);
IActionBars actionBars= part.getViewSite().getActionBars();
actionBars.setGlobalActionHandler(
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 2007-11-16
16:13:53 UTC (rev 4950)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationCreationWizard.java 2007-11-16
17:16:23 UTC (rev 4951)
@@ -61,6 +61,7 @@
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.utils.EclipseImages;
import org.hibernate.eclipse.console.utils.ProjectUtils;
+import org.hibernate.eclipse.launch.ICodeGenerationLaunchConstants;
import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
import org.hibernate.eclipse.nature.HibernateNature;
import org.hibernate.util.StringHelper;
@@ -162,7 +163,7 @@
}
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType(
"org.hibernate.eclipse.launch.ConsoleConfigurationLaunchConfigurationType" );
+ 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());