Author: dgeraskov
Date: 2009-11-18 05:46:33 -0500 (Wed, 18 Nov 2009)
New Revision: 18726
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/DeleteProjectParticipant.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationDeleteJavaProjectChange.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/HibernateRefactoringUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4899
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2009-11-18
10:24:52 UTC (rev 18725)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2009-11-18
10:46:33 UTC (rev 18726)
@@ -707,7 +707,7 @@
</enablement>
</moveParticipant>
<moveParticipant
-
class="org.hibernate.eclipse.launch.core.refactoring.ConsoleConfigurationITypeMoveParticipant"
+
class="org.hibernate.eclipse.launch.core.refactoring.MoveResourceParticipant"
name="Console Configuration IType Participant"
id="org.hibernate.eclipse.launch.core.refactoring.ConsoleConfigurationITypeMoveParticipant">
<enablement>
@@ -724,6 +724,21 @@
</extension>
<extension
+ point="org.eclipse.ltk.core.refactoring.deleteParticipants">
+ <deleteParticipant
+ class="org.hibernate.eclipse.console.DeleteProjectParticipant"
+ id="org.hibernate.eclipse.console.deleteProjectParticipant"
+ name="Console Configuration Project delete participant">
+ <enablement>
+ <with
+ variable="element">
+ <instanceof
+ value="org.eclipse.core.resources.IProject">
+ </instanceof>
+ </with></enablement>
+ </deleteParticipant>
+ </extension>
+ <extension
point="org.eclipse.ui.popupMenus">
<!--<objectContribution
id="org.hibernate.eclipse.console.objectContribution2"
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/DeleteProjectParticipant.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/DeleteProjectParticipant.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/DeleteProjectParticipant.java 2009-11-18
10:46:33 UTC (rev 18726)
@@ -0,0 +1,52 @@
+package org.hibernate.eclipse.console;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.DeleteParticipant;
+import
org.hibernate.eclipse.launch.core.refactoring.ConsoleConfigurationDeleteJavaProjectChange;
+import org.hibernate.eclipse.launch.core.refactoring.HibernateRefactoringUtil;
+
+public class DeleteProjectParticipant extends DeleteParticipant {
+
+ private IProject javaProject;
+
+ @Override
+ public RefactoringStatus checkConditions(IProgressMonitor pm,
+ CheckConditionsContext context) throws OperationCanceledException {
+ return new RefactoringStatus();
+ }
+
+ @Override
+ public Change createChange(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ ILaunchConfiguration[] configs =
HibernateRefactoringUtil.getAffectedLaunchConfigurations(javaProject);
+
+ List<Change> changes = new ArrayList<Change>();
+ for (int i= 0; i < configs.length; i++) {
+ changes.add(new ConsoleConfigurationDeleteJavaProjectChange(configs[i]));
+ }
+
+ return HibernateRefactoringUtil.createChangesFromList(changes, getName());
+ }
+
+ @Override
+ public String getName() {
+ return
HibernateConsoleMessages.DeleteProjectParticipant_console_configurations_updates;
+ }
+
+ @Override
+ protected boolean initialize(Object element) {
+ javaProject = (IProject)element;
+ return true;
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/DeleteProjectParticipant.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2009-11-18
10:24:52 UTC (rev 18725)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2009-11-18
10:46:33 UTC (rev 18726)
@@ -495,6 +495,9 @@
public static String ConnectionProfileRenameChange_update_connection_profile_name;
public static String ConnectionProfileRenameParticipant_launch_configurations_updates;
+
+ public static String DeleteProjectParticipant_console_configurations_updates;
+ public static String DeleteProjectParticipant_delete_console_configuration;
//
static {
// initialize resource bundle
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2009-11-18
10:24:52 UTC (rev 18725)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2009-11-18
10:46:33 UTC (rev 18726)
@@ -482,6 +482,8 @@
LaunchConfigurationResourceNameChange_update_resource_path_in_launch_cfg=Update resource
path in launch configuration
MoveResourceParticipant_launch_configurations_updates=Launch Configurations updates
RenameResourceParticipant_launch_configurations_updates=Launch Configurations updates
+DeleteProjectParticipant_console_configurations_updates=Delete related Console
Configurations
+DeleteProjectParticipant_delete_console_configuration=Delete Console Configuration
''{0}''
ConsoleConfigurationITypeRenameParticipant_update=Console configuration participant
ConsoleConfigurationITypeRenameParticipant_update_names=Console configuration update time
names
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationDeleteJavaProjectChange.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationDeleteJavaProjectChange.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationDeleteJavaProjectChange.java 2009-11-18
10:46:33 UTC (rev 18726)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.hibernate.eclipse.launch.core.refactoring;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.osgi.util.NLS;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class ConsoleConfigurationDeleteJavaProjectChange extends Change {
+
+ private ILaunchConfiguration fLaunchConfiguration;
+
+ public ConsoleConfigurationDeleteJavaProjectChange(
+ ILaunchConfiguration iLaunchConfiguration) {
+ this.fLaunchConfiguration = iLaunchConfiguration;
+ }
+
+ @Override
+ public Object getModifiedElement() {
+ return fLaunchConfiguration;
+ }
+
+ @Override
+ public String getName() {
+ return
NLS.bind(HibernateConsoleMessages.DeleteProjectParticipant_delete_console_configuration,
+ fLaunchConfiguration.getName());
+ }
+
+ @Override
+ public void initializeValidationData(IProgressMonitor pm) {}
+
+ @Override
+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ return new RefactoringStatus();
+ }
+
+ @Override
+ public Change perform(IProgressMonitor pm) throws CoreException {
+ fLaunchConfiguration.delete();
+ return null;
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationDeleteJavaProjectChange.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
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-11-18
10:24:52 UTC (rev 18725)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/HibernateRefactoringUtil.java 2009-11-18
10:46:33 UTC (rev 18726)
@@ -27,6 +27,7 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -351,6 +352,24 @@
return configs;
}
+ public static ILaunchConfiguration[] getAffectedLaunchConfigurations(IProject project){
+ ILaunchConfiguration[] configs = null;
+ try {
+ 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
+ String projectName =
configs[i].getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
(String)null);
+ if (project.getName().equals(projectName)) list.add(configs[i]);
+ }
+ configs = list.toArray(new ILaunchConfiguration[list.size()]);
+ }
+ catch(CoreException e) {
+ configs = new ILaunchConfiguration[0];
+ HibernateConsolePlugin.getDefault().logErrorMessage( ERROR_MESS, e );
+ }
+ return configs;
+ }
+
public static ILaunchConfiguration[] getAffectedLaunchConfigurations(IConnectionProfile
profile){
ILaunchConfiguration[] configs = null;
try {