Author: dgeraskov
Date: 2009-05-29 09:43:33 -0400 (Fri, 29 May 2009)
New Revision: 15596
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/EditConsoleConfiguration.java
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/ProjectUtils.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySource.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/HibernateRefactoringUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3786
Name changes in Properties view calls ConsoleConfiguration rename(If the name is valid)
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 2009-05-29
13:40:46 UTC (rev 15595)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsolePlugin.java 2009-05-29
13:43:33 UTC (rev 15596)
@@ -37,7 +37,6 @@
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationListener;
-import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.ui.text.JavaTextTools;
@@ -62,6 +61,7 @@
import org.hibernate.console.KnownConfigurationsListener;
import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
import org.hibernate.eclipse.console.actions.AddConfigurationAction;
+import org.hibernate.eclipse.console.utils.LaunchHelper;
import org.hibernate.eclipse.console.workbench.ConfigurationAdapterFactory;
import org.hibernate.eclipse.criteriaeditor.CriteriaEditorInput;
import org.hibernate.eclipse.criteriaeditor.CriteriaEditorStorage;
@@ -252,10 +252,7 @@
private void loadExistingConfigurations() throws CoreException {
- final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
-
- ILaunchConfigurationType lct = launchManager.getLaunchConfigurationType(
ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID );
- ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(
lct );
+ ILaunchConfiguration[] launchConfigurations =
LaunchHelper.findHibernateLaunchConfigs();
for (int i = 0; i < launchConfigurations.length; i++) {
KnownConfigurations.getInstance().addConfiguration(
new ConsoleConfiguration(new
EclipseLaunchConsoleConfigurationPreferences(launchConfigurations[i])), false );
@@ -274,25 +271,9 @@
}
}
- private ILaunchConfiguration findLaunchConfig(String name)
+ public ILaunchConfiguration findLaunchConfig(String name)
throws CoreException {
- ILaunchManager launchManager = DebugPlugin.getDefault()
- .getLaunchManager();
- 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(name)) {
- return launchConfiguration;
- }
- }
- return null;
+ return LaunchHelper.findHibernateLaunchConfig(name);
}
/**
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 2009-05-29
13:40:46 UTC (rev 15595)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/AddConfigurationAction.java 2009-05-29
13:43:33 UTC (rev 15596)
@@ -38,7 +38,7 @@
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.utils.EclipseImages;
-import org.hibernate.eclipse.launch.ICodeGenerationLaunchConstants;
+import org.hibernate.eclipse.console.utils.LaunchHelper;
/**
*
@@ -91,7 +91,7 @@
throws CoreException {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType(
ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID );
+ ILaunchConfigurationType launchConfigurationType =
LaunchHelper.getHibernateLaunchConfigsType();
String launchName =
launchManager.generateUniqueLaunchConfigurationNameFrom(HibernateConsoleMessages.AddConfigurationAction_hibernate);
//ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(
launchConfigurationType );
ILaunchConfigurationWorkingCopy wc = launchConfigurationType.newInstance(null,
launchName);
@@ -118,12 +118,8 @@
static private List<ILaunchConfiguration> getTemporaryLaunchConfigurations()
throws CoreException {
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
-
- ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType(
ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID );
-
List<ILaunchConfiguration> listTempConfigs = new
ArrayList<ILaunchConfiguration>();
- ILaunchConfiguration[] configs =
launchManager.getLaunchConfigurations(launchConfigurationType);
+ ILaunchConfiguration[] configs = LaunchHelper.findHibernateLaunchConfigs();
for (int i = 0; i < configs.length; i++) {
boolean temporary =
configs[i].getAttribute(AddConfigurationAction.TEMPORARY_CONFIG_FLAG, false);
if (temporary) {
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 2009-05-29
13:40:46 UTC (rev 15595)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/EditConsoleConfiguration.java 2009-05-29
13:43:33 UTC (rev 15596)
@@ -24,10 +24,7 @@
import java.util.Iterator;
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;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IWorkbenchWindow;
@@ -36,7 +33,7 @@
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
-import org.hibernate.eclipse.launch.ICodeGenerationLaunchConstants;
+import org.hibernate.eclipse.console.utils.LaunchHelper;
/**
* @author max
@@ -82,32 +79,17 @@
private void edit(final ConsoleConfiguration config) {
IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- /*if(MessageDialog.openQuestion( null, "Use old dialog ?", "Use old
dialog" )) {
- ConsoleConfigurationCreationWizard wizard = new ConsoleConfigurationCreationWizard();
- wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(config) );
-
-
- WizardDialog dialog = new WizardDialog(win.getShell(), wizard);
- dialog.open(); // This opens a dialog
- } else {*/
- try {
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
-
- 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" ); //$NON-NLS-1$
- return;
- }
- }
- String out =
NLS.bind(HibernateConsoleMessages.EditConsoleConfiguration_could_not_find_launch_cfg,
config.getName());
- HibernateConsolePlugin.getDefault().showError(win.getShell(), out, new
IllegalStateException(HibernateConsoleMessages.EditConsoleConfiguration_no_launch_cfg_matched
+ config.getName()));
- } catch (CoreException ce) {
- HibernateConsolePlugin.getDefault().showError( win.getShell(),
HibernateConsoleMessages.EditConsoleConfiguration_problem_adding_console_cfg, ce);
+ try {
+ ILaunchConfiguration launchConfiguration =
LaunchHelper.findHibernateLaunchConfig(config.getName());
+ if(launchConfiguration != null) {
+ DebugUITools.openLaunchConfigurationPropertiesDialog( win.getShell(),
launchConfiguration, "org.eclipse.debug.ui.launchGroup.run" ); //$NON-NLS-1$
+ return;
}
- //}
+ String out =
NLS.bind(HibernateConsoleMessages.EditConsoleConfiguration_could_not_find_launch_cfg,
config.getName());
+ HibernateConsolePlugin.getDefault().showError(win.getShell(), out, new
IllegalStateException(HibernateConsoleMessages.EditConsoleConfiguration_no_launch_cfg_matched
+ config.getName()));
+ } catch (CoreException ce) {
+ HibernateConsolePlugin.getDefault().showError( win.getShell(),
HibernateConsoleMessages.EditConsoleConfiguration_problem_adding_console_cfg, ce);
+ }
}
protected boolean updateState(ConsoleConfiguration consoleConfiguration) {
Modified:
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 2009-05-29
13:40:46 UTC (rev 15595)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/LaunchHelper.java 2009-05-29
13:43:33 UTC (rev 15596)
@@ -2,20 +2,39 @@
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.osgi.util.NLS;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.actions.AddConfigurationAction;
+import org.hibernate.eclipse.launch.ICodeGenerationLaunchConstants;
public class LaunchHelper {
+
+ public static ILaunchConfiguration findHibernateLaunchConfig(String name) throws
CoreException {
+ return findLaunchConfigurationByName(
+ ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID, name);
+ }
+
+ public static ILaunchConfigurationType getHibernateLaunchConfigsType(){
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ return launchManager.getLaunchConfigurationType(
+ ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID);
+ }
+
+ public static ILaunchConfiguration[] findHibernateLaunchConfigs() throws CoreException
{
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ return launchManager.getLaunchConfigurations(getHibernateLaunchConfigsType());
+ }
- static public ILaunchConfiguration findLaunchConfigurationByName(String
launchConfigurationTypeId, String name) throws CoreException {
+ public static ILaunchConfiguration findLaunchConfigurationByName(String
launchConfigurationTypeId, String name) throws CoreException {
Assert.isNotNull(launchConfigurationTypeId,
HibernateConsoleMessages.LaunchHelper_launch_cfg_type_cannot_be_null);
- ILaunchManager launchManager = DebugPlugin.getDefault()
- .getLaunchManager();
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
-
ILaunchConfigurationType launchConfigurationType = launchManager
.getLaunchConfigurationType(launchConfigurationTypeId);
@@ -33,4 +52,48 @@
}
return null;
}
+
+ public static String verifyConfigurationName(String currentName) {
+ if (currentName == null || currentName.length() < 1) {
+ return HibernateConsoleMessages.ConsoleConfigurationWizardPage_name_must_specified;
+ }
+ if (Platform.OS_WIN32.equals(Platform.getOS())) {
+ String[] badnames = new String[] { "aux", "clock$",
"com1", "com2", "com3", "com4", //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "com5", "com6", "com7", "com8",
"com9", "con", "lpt1", "lpt2", //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
//$NON-NLS-8$
+ "lpt3", "lpt4", "lpt5", "lpt6",
"lpt7", "lpt8", "lpt9", "nul", "prn" };
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
//$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+ for (int i = 0; i < badnames.length; i++) {
+ if (currentName.equals(badnames[i])) {
+ return NLS.bind(HibernateConsoleMessages.ConsoleConfigurationWizardPage_bad_name,
currentName);
+ }
+ }
+ }
+ // See if name contains any characters that we deem illegal.
+ // '@' and '&' are disallowed because they corrupt menu items.
+ char[] disallowedChars = new char[] { '@', '&', '\\',
'/', ':', '*', '?', '"', '<',
'>', '|', '\0' };
+ for (int i = 0; i < disallowedChars.length; i++) {
+ char c = disallowedChars[i];
+ if (currentName.indexOf(c) > -1) {
+ return NLS.bind(HibernateConsoleMessages.ConsoleConfigurationWizardPage_bad_char,
c);
+ }
+ }
+
+ if(existingLaunchConfiguration(currentName)) {
+ return
HibernateConsoleMessages.ConsoleConfigurationWizardPage_config_name_already_exist;
+ }
+ return null;
+ }
+
+ public static boolean existingLaunchConfiguration(String name) {
+ try {
+ ILaunchConfiguration config = findHibernateLaunchConfig(name);
+ if(config != null &&
!config.getAttribute(AddConfigurationAction.TEMPORARY_CONFIG_FLAG, false)) {
+ if (name.equalsIgnoreCase(config.getName())) {
+ return true;
+ }
+ }
+ } catch (CoreException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage(e.getMessage(), e);
+ }
+ return false;
+ }
}
\ 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 2009-05-29
13:40:46 UTC (rev 15595)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/ProjectUtils.java 2009-05-29
13:43:33 UTC (rev 15596)
@@ -43,10 +43,7 @@
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
@@ -65,7 +62,6 @@
import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
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;
@@ -216,27 +212,20 @@
* @return a handle to the project resource
*/
public static IProject findProject(ConsoleConfiguration consoleConfiguration) {
- IProject res = null;
if (consoleConfiguration != null) {
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType launchConfigurationType =
launchManager.getLaunchConfigurationType(
ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID );
try {
- ILaunchConfiguration[] launchConfigurations =
- launchManager.getLaunchConfigurations( launchConfigurationType );
- // can't believe there is no look up by name API
- for (int i = 0; i < launchConfigurations.length && res == null; i++) {
- ILaunchConfiguration launchConfiguration = launchConfigurations[i];
- if (launchConfiguration.getName().equals(consoleConfiguration.getName())) {
- String projName = launchConfiguration.getAttribute(
- IConsoleConfigurationLaunchConstants.PROJECT_NAME, ""); //$NON-NLS-1$
- res = findProject(projName);
- }
+ ILaunchConfiguration launchConfiguration = LaunchHelper.findHibernateLaunchConfig(
+ consoleConfiguration.getName());
+ if(launchConfiguration != null) {
+ String projName = launchConfiguration.getAttribute(
+ IConsoleConfigurationLaunchConstants.PROJECT_NAME, ""); //$NON-NLS-1$
+ return findProject(projName);
}
} catch (CoreException e1) {
HibernateConsolePlugin.getDefault().log(e1);
}
}
- return res;
+ return null;
}
/**
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySource.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySource.java 2009-05-29
13:40:46 UTC (rev 15595)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySource.java 2009-05-29
13:43:33 UTC (rev 15596)
@@ -24,19 +24,24 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.utils.LaunchHelper;
public class ConsoleConfigurationPropertySource implements IPropertySource {
- private final ConsoleConfiguration cfg;
+ private ConsoleConfiguration cfg;
-
static IPropertyDescriptor[] pd;
static {
List<IPropertyDescriptor> l = new ArrayList<IPropertyDescriptor>();
@@ -93,6 +98,27 @@
}
public void setPropertyValue(Object id, Object value) {
+ if("name".equals(id) && value instanceof String) { //$NON-NLS-1$
+ String newName = (String) value;
+ if (LaunchHelper.verifyConfigurationName(newName) != null) {
+ return;//just do not change name
+ }
+ String oldName = cfg.getName();
+ try {
+ ILaunchConfiguration lc =
HibernateConsolePlugin.getDefault().findLaunchConfig(oldName);
+ if (lc != null){
+ ILaunchConfigurationWorkingCopy wc = lc.getWorkingCopy();
+ wc.rename(newName);
+ wc.doSave();
+ //find newly created console configuration
+ cfg = KnownConfigurations.getInstance().find(newName);
+ } else {
+ HibernateConsolePlugin.getDefault().log("Can't find Console Configuration
\"" + oldName + "\"");
+ }
+ } catch (CoreException e) {
+ HibernateConsolePlugin.getDefault().log(e);
+ }
}
+ }
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java 2009-05-29
13:40:46 UTC (rev 15595)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java 2009-05-29
13:43:33 UTC (rev 15596)
@@ -31,10 +31,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
@@ -72,9 +69,9 @@
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.actions.AddConfigurationAction;
+import org.hibernate.eclipse.console.utils.LaunchHelper;
import org.hibernate.eclipse.launch.ConsoleConfigurationMainTab;
import org.hibernate.eclipse.launch.ConsoleConfigurationTabGroup;
-import org.hibernate.eclipse.launch.ICodeGenerationLaunchConstants;
import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
import org.hibernate.util.StringHelper;
@@ -264,7 +261,7 @@
if (name != null) {
name = name.trim();
}
- messageError = verifyConfigurationName(name);
+ messageError = LaunchHelper.verifyConfigurationName(name);
if (messageError != null) {
setMessage(messageWarning);
updateStatus(messageError);
@@ -295,26 +292,6 @@
updateStatus(messageError);
}
- private boolean existingLaunchConfiguration(String name) {
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType launchConfigurationType = launchManager
- .getLaunchConfigurationType(ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID);
- try {
- ILaunchConfiguration[] configs;
- configs = launchManager.getLaunchConfigurations(launchConfigurationType);
- for (int i = 0; i < configs.length; i++) {
- if(!configs[i].getAttribute(AddConfigurationAction.TEMPORARY_CONFIG_FLAG, false)) {
- if (name.equalsIgnoreCase(configs[i].getName())) {
- return true;
- }
- }
- }
- } catch (CoreException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage(e.getMessage(), e);
- }
- return false;
- }
-
/**
* Notification that a tab has been selected
*
@@ -368,36 +345,6 @@
return null;
}
- protected String verifyConfigurationName(String currentName) {
- if (currentName == null || currentName.length() < 1) {
- return HibernateConsoleMessages.ConsoleConfigurationWizardPage_name_must_specified;
- }
- if (Platform.OS_WIN32.equals(Platform.getOS())) {
- String[] badnames = new String[] { "aux", "clock$",
"com1", "com2", "com3", "com4", //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- "com5", "com6", "com7", "com8",
"com9", "con", "lpt1", "lpt2", //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
//$NON-NLS-8$
- "lpt3", "lpt4", "lpt5", "lpt6",
"lpt7", "lpt8", "lpt9", "nul", "prn" };
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
//$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
- for (int i = 0; i < badnames.length; i++) {
- if (currentName.equals(badnames[i])) {
- return NLS.bind(HibernateConsoleMessages.ConsoleConfigurationWizardPage_bad_name,
currentName);
- }
- }
- }
- // See if name contains any characters that we deem illegal.
- // '@' and '&' are disallowed because they corrupt menu items.
- char[] disallowedChars = new char[] { '@', '&', '\\',
'/', ':', '*', '?', '"', '<',
'>', '|', '\0' };
- for (int i = 0; i < disallowedChars.length; i++) {
- char c = disallowedChars[i];
- if (currentName.indexOf(c) > -1) {
- return NLS.bind(HibernateConsoleMessages.ConsoleConfigurationWizardPage_bad_char,
c);
- }
- }
-
- if(existingLaunchConfiguration(currentName)) {
- return
HibernateConsoleMessages.ConsoleConfigurationWizardPage_config_name_already_exist;
- }
- return null;
- }
-
private String getConfigurationName() {
return nameWidget.getText();
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/HibernateRefactoringUtil.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/HibernateRefactoringUtil.java 2009-05-29
13:40:46 UTC (rev 15595)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/HibernateRefactoringUtil.java 2009-05-29
13:43:33 UTC (rev 15596)
@@ -27,7 +27,6 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -38,9 +37,6 @@
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jdt.core.IJavaModel;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
import org.eclipse.jdt.launching.JavaRuntime;
@@ -48,8 +44,8 @@
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.utils.LaunchHelper;
import org.hibernate.eclipse.launch.HibernateLaunchConstants;
-import org.hibernate.eclipse.launch.ICodeGenerationLaunchConstants;
import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -334,10 +330,9 @@
public static ILaunchConfiguration[] getAffectedLaunchConfigurations(IPath path){
ILaunchConfiguration[] configs = null;
try {
- configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations();
+ configs = LaunchHelper.findHibernateLaunchConfigs();
List<ILaunchConfiguration> list = new ArrayList<ILaunchConfiguration>();
for(int i = 0; i < configs.length && configs[i].exists(); i++) {//refactor
only hibernate launch configurations
- if
(!ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID.equals(configs[i].getType().getIdentifier()))
continue;
if (HibernateRefactoringUtil.isConfigurationAffected(configs[i], path))
list.add(configs[i]);
}
configs = list.toArray(new ILaunchConfiguration[list.size()]);
@@ -353,10 +348,9 @@
public static ILaunchConfiguration[] getAffectedLaunchConfigurations(IConnectionProfile
profile){
ILaunchConfiguration[] configs = null;
try {
- configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations();
+ configs = LaunchHelper.findHibernateLaunchConfigs();
List<ILaunchConfiguration> list = new ArrayList<ILaunchConfiguration>();
for(int i = 0; i < configs.length && configs[i].exists(); i++) {//refactor
only hibernate launch configurations
- if
(!ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID.equals(configs[i].getType().getIdentifier()))
continue;
if
(profile.getName().equals(configs[i].getAttribute(IConsoleConfigurationLaunchConstants.CONNECTION_PROFILE_NAME,
""))) //$NON-NLS-1$
list.add(configs[i]);
}