### Eclipse Workspace Patch 1.0 #P org.eclipse.jst.jee.ui Index: src/org/eclipse/jst/jee/ui/internal/Messages.java =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.jee.ui/src/org/eclipse/jst/jee/ui/internal/Messages.java,v retrieving revision 1.5 diff -u -r1.5 Messages.java --- src/org/eclipse/jst/jee/ui/internal/Messages.java 26 Mar 2008 16:44:20 -0000 1.5 +++ src/org/eclipse/jst/jee/ui/internal/Messages.java 19 Oct 2009 14:45:34 -0000 @@ -23,6 +23,9 @@ public static String INVALID_DEP_DESC_SELECTION_TITLE; public static String INFORM_INVALID_DEP_DESC_SELECTION; + public static String DeleteJEEResourceChange_deleting; + public static String DeleteJEEResourceChange_error_resource_not_exists; + public static String DeleteJEEResourceChange_name; public static String DEPLOYMENT_DESCRIPTOR; public static String SESSION_BEANS; public static String ENTITY_BEANS; @@ -39,9 +42,6 @@ public static String WELCOME_PAGES_ITEM_PROVIDER; public static String CONTEXT_PARAMS_ITEM_PROVIDER; - - - public static String REFERENCES; public static String BUNDLED_LIBRARIES_NODE; public static String LIBRARY_DIRECTORY; @@ -59,6 +59,26 @@ public static String ImportJEEModuleDropAssistant_Importing_Java_Enterprise_Edition_artifacts; public static String ImportJEEModuleDropAssistant_Could_not_recognize_extension_0_; + public static String RefactoringWebArtifactsWizard_label_multi; + public static String RefactoringWebArtifactsWizard_label_multi_linked; + public static String RefactoringWebArtifactsWizard_label_multi_projects; + public static String RefactoringWebArtifactsWizard_label_single; + public static String RefactoringWebArtifactsWizard_label_single_linked; + public static String RefactoringWebArtifactsWizard_label_single_project; + public static String RefactoringWebArtifactsWizard_page_title; + public static String RefactoringWebArtifactsWizard_project_deleteContents; + public static String RefactoringWebArtifactsWizard_window_title; + + public static String JEEDeleteProcessor_change_name; + public static String JEEDeleteProcessor_create_task; + public static String JEEDeleteProcessor_delete_error_mixed_types; + public static String JEEDeleteProcessor_delete_error_phantom; + public static String JEEDeleteProcessor_delete_error_read_only; + public static String JEEDeleteProcessor_processor_name; + public static String JEEDeleteProcessor_warning_out_of_sync_file; + public static String JEEDeleteProcessor_warning_out_of_sync_container; + public static String JEEDeleteProcessor_warning_unsaved_file; + static { NLS.initializeMessages(BUNDLE_NAME, Messages.class); } Index: src/org/eclipse/jst/jee/ui/internal/messages.properties =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.jee.ui/src/org/eclipse/jst/jee/ui/internal/messages.properties,v retrieving revision 1.9 diff -u -r1.9 messages.properties --- src/org/eclipse/jst/jee/ui/internal/messages.properties 27 Aug 2009 09:57:45 -0000 1.9 +++ src/org/eclipse/jst/jee/ui/internal/messages.properties 19 Oct 2009 14:45:35 -0000 @@ -1,5 +1,8 @@ INVALID_DEP_DESC_SELECTION_TITLE=Invalid Selection INFORM_INVALID_DEP_DESC_SELECTION=One or more Java EE projects selected already has a Deployment Descriptor. +DeleteJEEResourceChange_deleting=Deleting resources... +DeleteJEEResourceChange_error_resource_not_exists=Can not delete resource. Resource does not exist. +DeleteJEEResourceChange_name=Delete ''{0}'' DEPLOYMENT_DESCRIPTOR=Deployment Descriptor: {0} SESSION_BEANS=Session Beans ENTITY_BEANS=Entity Beans (1.x-2.x) @@ -32,3 +35,24 @@ AddModuleToEarDropAssistant_Adding_module_to_ea_=Adding module to ear ImportJEEModuleDropAssistant_Importing_Java_Enterprise_Edition_artifacts=Importing Java Enterprise Edition artifacts ImportJEEModuleDropAssistant_Could_not_recognize_extension_0_=Could not recognize extension + +RefactoringWebArtifactsWizard_label_multi=Are you sure you want to delete the {0} selected resources from the file system? +RefactoringWebArtifactsWizard_label_multi_linked=Are you sure you want to delete these {0} resources?\n\nSelection contains linked resources.\nOnly the workspace links will be deleted. Link targets will remain unchanged. +RefactoringWebArtifactsWizard_label_multi_projects=Are you sure you want to remove these {0} projects from the workspace? +RefactoringWebArtifactsWizard_label_single=Are you sure you want to delete ''{0}'' from the file system? +RefactoringWebArtifactsWizard_label_single_linked=Are you sure you want to delete linked resource ''{0}''?\n\nOnly the workspace link will be deleted. Link target will remain unchanged. +RefactoringWebArtifactsWizard_label_single_project=Are you sure you want to remove project ''{0}'' from the workspace? +RefactoringWebArtifactsWizard_page_title=Delete Resources +RefactoringWebArtifactsWizard_project_deleteContents=&Delete project contents on disk (cannot be undone) +RefactoringWebArtifactsWizard_window_title=Delete Resources +JEEDeleteProcessor_change_name=Delete changes +JEEDeleteProcessor_create_task=Creating pending deletes... +JEEDeleteProcessor_delete_error_mixed_types=Cannot delete projects and other resources in the same operation. +JEEDeleteProcessor_delete_error_phantom=Cannot delete phantom resource ''{0}''. +JEEDeleteProcessor_delete_error_read_only=Cannot delete content for read-only resource ''{0}''. +JEEDeleteProcessor_processor_name=Delete Resource +JEEDeleteProcessor_warning_out_of_sync_file=''{0}'' is not in sync. Press continue to force delete. +JEEDeleteProcessor_warning_out_of_sync_container=''{0}'' contains resources that are not in sync. Press continue to force delete. +JEEDeleteProcessor_warning_unsaved_file=File ''{0}'' has unsaved changes. + + Index: about.html =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.jee.ui/about.html,v retrieving revision 1.2 diff -u -r1.2 about.html --- about.html 13 May 2008 23:48:29 -0000 1.2 +++ about.html 19 Oct 2009 14:45:34 -0000 @@ -14,21 +14,21 @@

License

-

The Eclipse Foundation makes available all content in this plug-in -("Content"). Unless otherwise indicated below, the Content is provided to you -under the terms and conditions of the Eclipse Public License Version 1.0 -("EPL"). A copy of the EPL is available at -http://www.eclipse.org/org/documents/epl-v10.php. +

The Eclipse Foundation makes available all content in this +plug-in ("Content"). Unless otherwise indicated below, the Content is +provided to you under the terms and conditions of the Eclipse Public +License Version 1.0 ("EPL"). A copy of the EPL is available at http://www.eclipse.org/org/documents/epl-v10.php. For purposes of the EPL, "Program" will mean the Content.

-

If you did not receive this Content directly from the Eclipse Foundation, the -Content is being redistributed by another party ("Redistributor") and different -terms and conditions may apply to your use of any object code in the Content. -Check the Redistributor's license that was provided with the Content. If no such -license exists, contact the Redistributor. Unless otherwise indicated below, the -terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at -http://www.eclipse.org/.

+

If you did not receive this Content directly from the Eclipse +Foundation, the Content is being redistributed by another party +("Redistributor") and different terms and conditions may apply to your +use of any object code in the Content. Check the Redistributor's license +that was provided with the Content. If no such license exists, contact +the Redistributor. Unless otherwise indicated below, the terms and +conditions of the EPL still apply to any source code in the Content and +such source code may be obtained at http://www.eclipse.org/.

Index: .classpath =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.jee.ui/.classpath,v retrieving revision 1.3 diff -u -r1.3 .classpath --- .classpath 10 May 2007 22:56:55 -0000 1.3 +++ .classpath 19 Oct 2009 14:45:34 -0000 @@ -1,7 +1,9 @@ - - - - + + + + Index: plugin.xml =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.jee.ui/plugin.xml,v retrieving revision 1.30 diff -u -r1.30 plugin.xml --- plugin.xml 29 Apr 2009 14:24:43 -0000 1.30 +++ plugin.xml 19 Oct 2009 14:45:34 -0000 @@ -1,1321 +1,1252 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + - - - + adaptableType="org.eclipse.jst.javaee.ejb.SessionBean"> + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %ENTERPRISE_BEAN_DECORATOR.DESCRIPTION + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %ENTERPRISE_BEAN_DECORATOR.DESCRIPTION - - - - - - - - - - - - - - - - - - - - - - - - - - - %jeeProjectDecorator.description + + + + + + + + + + + + + + + + + + + + + + + + + + + %jeeProjectDecorator.description - - - - - - - - - - %JAVA_EE_5_PROBLEM_MARKER_RESOURCE_DECORATOR.DESCRIPTION + + + + + + + + + + %JAVA_EE_5_PROBLEM_MARKER_RESOURCE_DECORATOR.DESCRIPTION - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: plugin.properties =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.jee.ui/plugin.properties,v retrieving revision 1.8 diff -u -r1.8 plugin.properties --- plugin.properties 24 May 2009 21:44:15 -0000 1.8 +++ plugin.properties 19 Oct 2009 14:45:34 -0000 @@ -20,6 +20,7 @@ JAVA_EE_5_PROBLEM_MARKER_RESOURCE_DECORATOR.DESCRIPTION=Resource Decorator enables error markers to be put on the project node. jeeProjectDecorator=Java EE 5 Project Decorator jeeProjectDecorator.description=Decorator is used to mark Java EE 5 projects +REMOVE_ARTIFACT_ACTION = Remove ADD_REMOVE_MODULE_DEPENDENCIES_ACTION = Add/Remove EJB_NAVIGATOR_CONTENT = JEE Navigator Content EJB WEB_NAVIGATOR_CONTENT = JEE Navigator Content WEB Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.jee.ui/META-INF/MANIFEST.MF,v retrieving revision 1.27 diff -u -r1.27 MANIFEST.MF --- META-INF/MANIFEST.MF 1 Oct 2009 13:31:12 -0000 1.27 +++ META-INF/MANIFEST.MF 19 Oct 2009 14:45:34 -0000 @@ -37,7 +37,11 @@ org.eclipse.jst.server.core;bundle-version="[1.0.102,2.0.0)", org.eclipse.jst.common.frameworks;bundle-version="[1.1.0,2.0.0)", org.eclipse.jst.j2ee.jca;bundle-version="[1.1.0,2.0.0)", - org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)" + org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)", + org.eclipse.ltk.core.refactoring;bundle-version="3.5.100", + org.eclipse.ltk.ui.refactoring;bundle-version="3.4.100", + org.eclipse.core.filebuffers;bundle-version="3.5.0", + org.eclipse.jface.text;bundle-version="3.5.100" Eclipse-LazyStart: true Bundle-Localization: plugin Bundle-Vendor: %Bundle-Vendor.0 Index: src/org/eclipse/jst/jee/ui/internal/refactoring/JEEDeleteProcessor.java =================================================================== RCS file: src/org/eclipse/jst/jee/ui/internal/refactoring/JEEDeleteProcessor.java diff -N src/org/eclipse/jst/jee/ui/internal/refactoring/JEEDeleteProcessor.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jst/jee/ui/internal/refactoring/JEEDeleteProcessor.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,391 @@ +package org.eclipse.jst.jee.ui.internal.refactoring; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.core.filebuffers.FileBuffers; +import org.eclipse.core.filebuffers.ITextFileBuffer; +import org.eclipse.core.filebuffers.LocationKind; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceVisitor; +import org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.Document; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jst.jee.ui.internal.Messages; +import org.eclipse.ltk.core.refactoring.Change; +import org.eclipse.ltk.core.refactoring.CompositeChange; +import org.eclipse.ltk.core.refactoring.RefactoringStatus; +import org.eclipse.ltk.core.refactoring.TextFileChange; +import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; +import org.eclipse.ltk.core.refactoring.participants.DeleteArguments; +import org.eclipse.ltk.core.refactoring.participants.DeleteProcessor; +import org.eclipse.ltk.core.refactoring.participants.ParticipantManager; +import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant; +import org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker; +import org.eclipse.ltk.core.refactoring.participants.SharableParticipants; +import org.eclipse.ltk.internal.core.refactoring.Resources; +import org.eclipse.ltk.internal.core.refactoring.resource.ResourceProcessors; +import org.eclipse.osgi.util.NLS; +import org.eclipse.text.edits.DeleteEdit; +import org.eclipse.text.edits.MultiTextEdit; + +public class JEEDeleteProcessor extends DeleteProcessor{ + + private IResource[] fResources; + private boolean fDeleteContents; + private String fObjectFullyQualifiedName; + private String fObjectName; + private String fStartTag; + private String fEndTag; + private String fMappingStartTag; + private String fMappingEndTag; + private int offset; + private int length; + + + + public JEEDeleteProcessor(IResource[] resources, String objectFullyQualifiedName, String objectName, String startTag, String endTag, String mappingStartTag, String mappingEndTag) { + this(resources, objectFullyQualifiedName, objectName, startTag, endTag, mappingStartTag, mappingEndTag, false); + } + + + public JEEDeleteProcessor(IResource[] resources, String objectFullyQualifiedName, String objectName, String startTag, String endTag, String mappingStartTag, String mappingEndTag, boolean deleteContents) { + fResources = removeDescendants(resources); + fObjectFullyQualifiedName = objectFullyQualifiedName; + fObjectName = objectName; + fStartTag = startTag; + fEndTag = endTag; + fMappingStartTag = mappingStartTag; + fMappingEndTag = mappingEndTag; + fDeleteContents= deleteContents; + } + + + @Override + public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { + // allow only projects or only non-projects to be selected; + // note that the selection may contain multiple types of resource + if (!(Resources.containsOnlyProjects(fResources) || Resources.containsOnlyNonProjects(fResources))) { + return RefactoringStatus.createFatalErrorStatus(Messages.JEEDeleteProcessor_delete_error_mixed_types); + } + + return new RefactoringStatus(); + } + + @Override + public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException { + pm.beginTask("", 1); //$NON-NLS-1$ + try { + RefactoringStatus result= new RefactoringStatus(); + + for (int i= 0; i < fResources.length; i++) { + IResource resource= fResources[i]; + if (!resource.isSynchronized(IResource.DEPTH_INFINITE)) { + if (resource instanceof IFile) { + result.addInfo(NLS.bind(Messages.JEEDeleteProcessor_warning_out_of_sync_file, BasicElementsLabels.getPathLabel(resource.getFullPath(), false))); + } else { + result.addInfo(NLS.bind(Messages.JEEDeleteProcessor_warning_out_of_sync_container, BasicElementsLabels.getPathLabel(resource.getFullPath(), false))); + } + } + } + + checkDirtyResources(result); + + ResourceChangeChecker checker= (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class); + IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory(); + for (int i= 0; i < fResources.length; i++) { + if (fResources[i].isPhantom()) { + result.addFatalError(NLS.bind(Messages.JEEDeleteProcessor_delete_error_phantom, BasicElementsLabels.getPathLabel(fResources[i].getFullPath(), false))); + } else if (fDeleteContents && Resources.isReadOnly(fResources[i])) { + result.addFatalError(NLS.bind(Messages.JEEDeleteProcessor_delete_error_read_only, BasicElementsLabels.getPathLabel(fResources[i].getFullPath(), false))); + } else { + deltaFactory.delete(fResources[i]); + } + } + return result; + } finally { + pm.done(); + } + } + + private void checkDirtyResources(final RefactoringStatus result) throws CoreException { + for (int i= 0; i < fResources.length; i++) { + IResource resource= fResources[i]; + if (resource instanceof IProject && !((IProject) resource).isOpen()) + continue; + resource.accept(new IResourceVisitor() { + public boolean visit(IResource visitedResource) throws CoreException { + if (visitedResource instanceof IFile) { + checkDirtyFile(result, (IFile)visitedResource); + } + return true; + } + }, IResource.DEPTH_INFINITE, false); + } + } + + private void checkDirtyFile(RefactoringStatus result, IFile file) { + if (!file.exists()) + return; + ITextFileBuffer buffer= FileBuffers.getTextFileBufferManager().getTextFileBuffer(file.getFullPath(), LocationKind.IFILE); + if (buffer != null && buffer.isDirty()) { + String message= Messages.JEEDeleteProcessor_warning_unsaved_file; + if (buffer.isStateValidated() && buffer.isSynchronized()) { + result.addWarning(NLS.bind(message, BasicElementsLabels.getPathLabel(file.getFullPath(), false))); + } else { + result.addFatalError(NLS.bind(message, BasicElementsLabels.getPathLabel(file.getFullPath(), false))); + } + } + } + + + + @Override + public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { + pm.beginTask(Messages.JEEDeleteProcessor_create_task, fResources.length); + try { + + CompositeChange change = new CompositeChange(Messages.JEEDeleteProcessor_change_name); + change.markAsSynthetic(); + + for (int i= 0; i < fResources.length; i++) { + pm.worked(1); + + if(fResources[i].getName().endsWith(".xml")){ //$NON-NLS-1$ + + IFile file = (IFile) fResources[i]; + TextFileChange result = new TextFileChange( file.getName(), file ); + modifyWebXML(file, result); + change.add(result); + + } else { + DeleteJEEResourceChange dc= new DeleteJEEResourceChange(fResources[i].getFullPath(), true, fDeleteContents); + change.add(dc); + } + } + return change; + } finally { + pm.done(); + } + } + + + private void modifyWebXML(IFile file, TextFileChange result) + throws CoreException { + String xmlContent = result.getCurrentContent(new NullProgressMonitor()); + + List listString = new ArrayList(); + + IDocument doc = new Document(); + doc.set(xmlContent); + + MultiTextEdit fileChangeRootEdit = new MultiTextEdit(); + result.setEdit( fileChangeRootEdit ); + + if(fStartTag!=null && fEndTag!=null && xmlContent.contains(fStartTag) && xmlContent.contains(fEndTag)){ + String identifyObject = fStartTag.replace(">", "-class>") + fObjectFullyQualifiedName + fEndTag.replace(">", "-class>"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + createXMLChangeToBeShown(xmlContent, listString, doc, fileChangeRootEdit, identifyObject, fStartTag, fEndTag); + } + + if(fMappingStartTag!=null && fMappingEndTag!=null && xmlContent.contains(fMappingStartTag) && xmlContent.contains(fMappingEndTag)){ + String identifyObject = fMappingStartTag.replace("mapping>", "name>") + fObjectName + fMappingEndTag.replace("mapping>", "name>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$ + createXMLChangeToBeShown(xmlContent, listString, doc, fileChangeRootEdit, identifyObject, fMappingStartTag, fMappingEndTag); + } + + saveFileIfNeeded(file, new NullProgressMonitor()); + } + + + private void createXMLChangeToBeShown(String xmlContent, List listStrings, + IDocument doc, MultiTextEdit fileChangeRootEdit, + String identifyObject , String tag, String enclosingTag) { + List strings = markTextToBeDeletedFromXML(doc, tag, enclosingTag); + findStartAndEndPoint(xmlContent, listStrings, strings, doc, tag, enclosingTag, identifyObject); + DeleteEdit edit = new DeleteEdit( offset, length); + fileChangeRootEdit.addChild( edit ); + } + + private static void saveFileIfNeeded(IFile file, IProgressMonitor pm) throws CoreException { + ITextFileBuffer buffer= FileBuffers.getTextFileBufferManager().getTextFileBuffer(file.getFullPath(), LocationKind.IFILE); + if (buffer != null && buffer.isDirty() && buffer.isStateValidated() && buffer.isSynchronized()) { + pm.beginTask("", 2); //$NON-NLS-1$ + buffer.commit(new SubProgressMonitor(pm, 1), false); + file.refreshLocal(IResource.DEPTH_ONE, new SubProgressMonitor(pm, 1)); + pm.done(); + } else { + pm.beginTask("", 1); //$NON-NLS-1$ + pm.worked(1); + pm.done(); + } + } + + private void findStartAndEndPoint(String xmlContent, List textStrings, + List strings, IDocument doc, String startTag, String endTag, String identifyObject) { + String s = ""; //$NON-NLS-1$ + for(int p=0;p strings1 = markTextToBeDeletedFromXML(doc1, startTag, endTag); + findStartAndEndPoint(xmlContent, textStrings, strings1, doc, startTag, endTag, identifyObject); + } + } + + private List markTextToBeDeletedFromXML( + IDocument doc, String startTag, String endTag) { + int linesSum = doc.getNumberOfLines(); + List strings = new ArrayList(); + findElementInXML: + for(int l=0; l result= new ArrayList(); + if (!isApplicable()) { + return new RefactoringParticipant[0]; + } + + final String[] affectedNatures= ResourceProcessors.computeAffectedNatures(fResources); + final DeleteArguments deleteArguments= new DeleteArguments(); + for (int i= 0; i < fResources.length; i++) { + result.addAll(Arrays.asList(ParticipantManager.loadDeleteParticipants(status, this, fResources[i], deleteArguments, affectedNatures, sharedParticipants))); + } + + return result.toArray(new RefactoringParticipant[result.size()]); + } + + + public void setResourcesToDelete(IResource[] resources) { + this.fResources = resources; + } + public IResource[] getResourcesToDelete() { + return fResources; + } + public void setDeleteContents(boolean deleteContents) { + this.fDeleteContents = deleteContents; + } + public boolean isDeleteContents() { + return fDeleteContents; + } + + private static IResource[] removeDescendants(IResource[] resources) { + ArrayList result= new ArrayList(); + for (int i= 0; i < resources.length; i++) { + addToList(result, resources[i]); + } + return result.toArray(new IResource[result.size()]); + } + + private static void addToList(ArrayList result, IResource curr) { + IPath currPath= curr.getFullPath(); + for (int k= result.size() - 1; k >= 0 ; k--) { + IResource other= result.get(k); + IPath otherPath= other.getFullPath(); + if (otherPath.isPrefixOf(currPath)) { + return; + } + if (currPath.isPrefixOf(otherPath)) { + result.remove(k); + } + } + result.add(curr); + } + + public void setLength(int length) { + this.length = length; + } + + public int getLength() { + return length; + } + + public void setOffset(int offset) { + this.offset = offset; + } + + public int getOffset() { + return offset; + } + +} Index: src/org/eclipse/jst/jee/ui/internal/refactoring/DeleteJEEResourceChange.java =================================================================== RCS file: src/org/eclipse/jst/jee/ui/internal/refactoring/DeleteJEEResourceChange.java diff -N src/org/eclipse/jst/jee/ui/internal/refactoring/DeleteJEEResourceChange.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jst/jee/ui/internal/refactoring/DeleteJEEResourceChange.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,128 @@ +package org.eclipse.jst.jee.ui.internal.refactoring; + +import org.eclipse.core.filebuffers.FileBuffers; +import org.eclipse.core.filebuffers.ITextFileBuffer; +import org.eclipse.core.filebuffers.LocationKind; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceVisitor; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.jst.jee.ui.internal.Messages; +import org.eclipse.jst.jee.ui.plugin.JEEUIPlugin; +import org.eclipse.ltk.core.refactoring.Change; +import org.eclipse.ltk.core.refactoring.resource.ResourceChange; +import org.eclipse.ltk.internal.core.refactoring.resource.UndoDeleteResourceChange; +import org.eclipse.ltk.internal.core.refactoring.resource.undostates.ResourceUndoState; +import org.eclipse.osgi.util.NLS; + +/** + * {@link Change} that deletes a resource. + * + * @since 3.4 + */ +public class DeleteJEEResourceChange extends ResourceChange { + + private IPath fResourcePath; + private boolean fForceOutOfSync; + private boolean fDeleteContent; + + + public DeleteJEEResourceChange(IPath resourcePath, boolean forceOutOfSync) { + this(resourcePath, forceOutOfSync, false); + } + + + public DeleteJEEResourceChange(IPath resourcePath, boolean forceOutOfSync, boolean deleteContent) { + fResourcePath= resourcePath; + fForceOutOfSync= forceOutOfSync; + fDeleteContent= deleteContent; + setValidationMethod(SAVE_IF_DIRTY); + } + + @Override + protected IResource getModifiedResource() { + return getResource(); + } + + private IResource getResource() { + return ResourcesPlugin.getWorkspace().getRoot().findMember(fResourcePath); + } + + + @Override + public String getName() { + return NLS.bind(Messages.DeleteJEEResourceChange_name, BasicElementsLabels.getPathLabel(fResourcePath.makeRelative(), false)); + } + + @Override + public Change perform(IProgressMonitor pm) throws CoreException { + pm.beginTask("", 10); //$NON-NLS-1$ + pm.setTaskName(Messages.DeleteJEEResourceChange_deleting); + + try { + IResource resource= getResource(); + if (resource == null || !resource.exists()) { + throw new CoreException(new Status(IStatus.ERROR, JEEUIPlugin.PLUGIN_ID, Messages.DeleteJEEResourceChange_error_resource_not_exists)); + } + + // make sure all files inside the resource are saved so restoring works + if (resource.isAccessible()) { + resource.accept(new IResourceVisitor() { + public boolean visit(IResource curr) throws CoreException { + try { + if (curr instanceof IFile) { + // progress is covered outside. + saveFileIfNeeded((IFile) curr, new NullProgressMonitor()); + } + } catch (CoreException e) { + // ignore + } + return true; + } + }, IResource.DEPTH_INFINITE, false); + } + + ResourceUndoState desc= ResourceUndoState.fromResource(resource); + if (resource instanceof IProject) { + ((IProject) resource).delete(fDeleteContent, fForceOutOfSync, new SubProgressMonitor(pm, 10)); + } else { + int updateFlags; + if (fForceOutOfSync) { + updateFlags= IResource.KEEP_HISTORY | IResource.FORCE; + } else { + updateFlags= IResource.KEEP_HISTORY; + } + if(!resource.getName().endsWith(".xml")){ //$NON-NLS-1$ + resource.delete(updateFlags, new SubProgressMonitor(pm, 5)); + } + desc.recordStateFromHistory(resource, new SubProgressMonitor(pm, 5)); + } + return new UndoDeleteResourceChange(desc); + } finally { + pm.done(); + } + } + + private static void saveFileIfNeeded(IFile file, IProgressMonitor pm) throws CoreException { + ITextFileBuffer buffer= FileBuffers.getTextFileBufferManager().getTextFileBuffer(file.getFullPath(), LocationKind.IFILE); + if (buffer != null && buffer.isDirty() && buffer.isStateValidated() && buffer.isSynchronized()) { + pm.beginTask("", 2); //$NON-NLS-1$ + buffer.commit(new SubProgressMonitor(pm, 1), false); + file.refreshLocal(IResource.DEPTH_ONE, new SubProgressMonitor(pm, 1)); + pm.done(); + } else { + pm.beginTask("", 1); //$NON-NLS-1$ + pm.worked(1); + pm.done(); + } + } + +} Index: src/org/eclipse/jst/jee/ui/internal/refactoring/BasicElementsLabels.java =================================================================== RCS file: src/org/eclipse/jst/jee/ui/internal/refactoring/BasicElementsLabels.java diff -N src/org/eclipse/jst/jee/ui/internal/refactoring/BasicElementsLabels.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jst/jee/ui/internal/refactoring/BasicElementsLabels.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,58 @@ +package org.eclipse.jst.jee.ui.internal.refactoring; + +import org.eclipse.osgi.util.TextProcessor; + +import org.eclipse.core.runtime.IPath; + +import org.eclipse.core.resources.IResource; + + +/** + * A label provider for basic elements like paths. The label provider will make sure that the labels are correctly + * shown in RTL environments. + * + * @since 3.4 + */ +public class BasicElementsLabels { + + private BasicElementsLabels(){} + + /** + * Adds special marks so that that the given string is readable in a BIDI environment. + * + * @param string the string + * @param delimiters the additional delimiters + * @return the processed styled string + */ + private static String markLTR(String string, String delimiters) { + return TextProcessor.process(string, delimiters); + } + + /** + * Returns the label of a path. + * + * @param path the path + * @param isOSPath if true, the path represents an OS path, if false it is a workspace path. + * @return the label of the path to be used in the UI. + */ + public static String getPathLabel(IPath path, boolean isOSPath) { + String label; + if (isOSPath) { + label= path.toOSString(); + } else { + label= path.makeRelative().toString(); + } + return markLTR(label, "/\\:."); //$NON-NLS-1$ + } + + /** + * Returns a label for a resource name. + * + * @param resource the resource + * @return the label of the resource name. + */ + public static String getResourceName(IResource resource) { + return markLTR(resource.getName(), ":."); //$NON-NLS-1$ + } + +} Index: src/org/eclipse/jst/jee/ui/internal/navigator/DeleteWebArtifacts.java =================================================================== RCS file: src/org/eclipse/jst/jee/ui/internal/navigator/DeleteWebArtifacts.java diff -N src/org/eclipse/jst/jee/ui/internal/navigator/DeleteWebArtifacts.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jst/jee/ui/internal/navigator/DeleteWebArtifacts.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,136 @@ +package org.eclipse.jst.jee.ui.internal.navigator; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.IPackageFragment; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jem.util.emf.workbench.ProjectUtilities; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jst.j2ee.internal.web.operations.WebPropertiesUtil; +import org.eclipse.jst.j2ee.model.IModelProvider; +import org.eclipse.jst.j2ee.model.ModelProviderManager; +import org.eclipse.jst.javaee.core.Listener; +import org.eclipse.jst.javaee.web.Filter; +import org.eclipse.jst.javaee.web.Servlet; +import org.eclipse.jst.javaee.web.WebApp; +import org.eclipse.jst.jee.ui.internal.navigator.web.WebAppProvider; +import org.eclipse.jst.jee.ui.internal.refactoring.RefactoringWebArtifactsWizard; +import org.eclipse.jst.jee.ui.plugin.JEEUIPlugin; +import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; + +public class DeleteWebArtifacts implements IObjectActionDelegate{ + + private ISelection sel; + private IWorkbenchPart targetPart; + + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + this.setTargetPart(targetPart); + + } + + public void run(IAction action) { + if (sel == null) + return; + IStructuredSelection selection = (StructuredSelection) sel; + if (!selection.isEmpty()) { + Object object = selection.getFirstElement(); + IProject project = ProjectUtilities.getProject(object); + IModelProvider modelProvider = ModelProviderManager.getModelProvider(project); + WebApp webApp = (WebApp) modelProvider.getModelObject(); + String container = WebPropertiesUtil.getJavaSourceFolder(project).getName(); + + WebAppProvider prov = new WebAppProvider(webApp, project); + IFile webXML = prov.getDDFile(); + + if (object instanceof Servlet) { + deleteResources(webXML, + ((Servlet) object).getServletClass(), project, + container, ((Servlet) object).getServletName(), + "", "", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$ + } else if (object instanceof Filter) { + deleteResources(webXML, + ((Filter) object).getFilterClass(), project, + container, ((Filter) object).getFilterName(), + "", "", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$ + } else if (object instanceof Listener) { + deleteResources(webXML, ((Listener) object).getListenerClass(), + project, container, null, + "", "", null, null); //$NON-NLS-1$ //$NON-NLS-2$ + } + + } + } + + private void deleteResources(IFile webXML, String fullyQualifiedName, IProject project, + String container, String objectName, String startTag, String endTag, String mappingStartTag, String mappingEndTag) { + IResource resource = project + .getFile(new Path( + container + "/" + (fullyQualifiedName).replace(".", "/") + ".java")); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + IResource res = resource.getParent(); + IResource [] resources = null; + + + if(getWebArtifactPackage(fullyQualifiedName, fullyQualifiedName.replaceAll(res.getName() + ".", ""), project)){ //$NON-NLS-1$ //$NON-NLS-2$ + resources = new IResource[] {resource, res, webXML}; + } else { + resources = new IResource[] {resource, webXML}; + } + RefactoringWebArtifactsWizard wiz = new RefactoringWebArtifactsWizard(resources, fullyQualifiedName, objectName, startTag, endTag, mappingStartTag, mappingEndTag); + + RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wiz); + try { + String titleForFailedChecks = ""; //$NON-NLS-1$ + op.run(new Shell(), titleForFailedChecks ); + } catch( InterruptedException irex ) { + // operation was cancelled + } + } + + private boolean getWebArtifactPackage( + String webArtifactClass, String webArtifactName, IProject project) { + IPackageFragment webArtifactPackage = null; + try { + IType webArtifact = JavaCore.create(project).findType(webArtifactClass); + if(webArtifact!=null){ + webArtifactPackage = webArtifact.getPackageFragment(); + if(webArtifactPackage.hasChildren()){ + IJavaElement[] el = webArtifactPackage.getChildren(); + if(el.length==1){ + if(el[0].getElementName().equals(webArtifactName+".java")){ //$NON-NLS-1$ + return true; + } + } + } else { + return true; + } + } + } catch (JavaModelException e1) { + JEEUIPlugin.logError("Cannot find resource.", e1); //$NON-NLS-1$ + } + return false; + } + + public void selectionChanged(IAction action, ISelection selection) { + sel = selection; + } + + public void setTargetPart(IWorkbenchPart targetPart) { + this.targetPart = targetPart; + } + + public IWorkbenchPart getTargetPart() { + return targetPart; + } + +} Index: src/org/eclipse/jst/jee/ui/internal/refactoring/JEERefactoring.java =================================================================== RCS file: src/org/eclipse/jst/jee/ui/internal/refactoring/JEERefactoring.java diff -N src/org/eclipse/jst/jee/ui/internal/refactoring/JEERefactoring.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jst/jee/ui/internal/refactoring/JEERefactoring.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,31 @@ +package org.eclipse.jst.jee.ui.internal.refactoring; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.ltk.core.refactoring.participants.DeleteProcessor; +import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring; +import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor; + +public class JEERefactoring extends ProcessorBasedRefactoring { + + private DeleteProcessor fProcessor; + + /** + * Constructs a new delete refactoring for the given processor. + * + * @param processor the delete processor + */ + public JEERefactoring(DeleteProcessor processor) { + super(processor); + Assert.isNotNull(processor); + fProcessor= processor; + } + + /** + * {@inheritDoc} + */ + @Override + public RefactoringProcessor getProcessor() { + return fProcessor; + } + +} Index: src/org/eclipse/jst/jee/ui/internal/refactoring/RefactoringWebArtifactsWizard.java =================================================================== RCS file: src/org/eclipse/jst/jee/ui/internal/refactoring/RefactoringWebArtifactsWizard.java diff -N src/org/eclipse/jst/jee/ui/internal/refactoring/RefactoringWebArtifactsWizard.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jst/jee/ui/internal/refactoring/RefactoringWebArtifactsWizard.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,146 @@ +package org.eclipse.jst.jee.ui.internal.refactoring; + +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.layout.LayoutConstants; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jst.jee.ui.internal.Messages; +import org.eclipse.ltk.internal.core.refactoring.Resources; +import org.eclipse.ltk.ui.refactoring.RefactoringWizard; +import org.eclipse.ltk.ui.refactoring.UserInputWizardPage; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +public class RefactoringWebArtifactsWizard extends RefactoringWizard { + + + public RefactoringWebArtifactsWizard(IResource[] resources, String objectFullyQualifiedName, String objectName, String startTag, String endTag, String mappingStartTag, String mappingEndTag) { + super(new JEERefactoring(new JEEDeleteProcessor(resources, objectFullyQualifiedName, objectName, startTag, endTag, mappingStartTag, mappingEndTag, false)), DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE); + setDefaultPageTitle(Messages.RefactoringWebArtifactsWizard_page_title); + setWindowTitle(Messages.RefactoringWebArtifactsWizard_window_title); + } + + + @Override + protected void addUserInputPages() { + JEEDeleteProcessor processor= (JEEDeleteProcessor) getRefactoring().getAdapter(JEEDeleteProcessor.class); + addPage(new DeleteJEEResourcesRefactoringConfigurationPage(processor)); + } + + private static class DeleteJEEResourcesRefactoringConfigurationPage extends UserInputWizardPage { + + private JEEDeleteProcessor fRefactoringProcessor; + private Button fDeleteContentsButton; + + public DeleteJEEResourcesRefactoringConfigurationPage(JEEDeleteProcessor processor) { + super("DeleteResourcesRefactoringConfigurationPage"); //$NON-NLS-1$ + fRefactoringProcessor= processor; + } + + public void createControl(Composite parent) { + initializeDialogUnits(parent); + + Point defaultSpacing= LayoutConstants.getSpacing(); + + Composite composite= new Composite(parent, SWT.NONE); + GridLayout gridLayout= new GridLayout(2, false); + gridLayout.horizontalSpacing= defaultSpacing.x * 2; + gridLayout.verticalSpacing= defaultSpacing.y; + + composite.setLayout(gridLayout); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + composite.setFont(parent.getFont()); + + Image image= parent.getDisplay().getSystemImage(SWT.ICON_QUESTION); + Label imageLabel = new Label(composite, SWT.NULL); + imageLabel.setBackground(image.getBackground()); + imageLabel.setImage(image); + imageLabel.setLayoutData(new GridData(SWT.CENTER, SWT.BEGINNING, false, false)); + + IResource[] resources= fRefactoringProcessor.getResourcesToDelete(); + Label label= new Label(composite, SWT.WRAP); + label.setFont(composite.getFont()); + + if (Resources.containsOnlyProjects(resources)) { + if (resources.length == 1) { + label.setText(NLS.bind(Messages.RefactoringWebArtifactsWizard_label_single_project, BasicElementsLabels.getResourceName(resources[0]))); + } else { + label.setText(NLS.bind(Messages.RefactoringWebArtifactsWizard_label_multi_projects, new Integer(resources.length))); + } + } else if (containsLinkedResource(resources)) { + if (resources.length == 1) { + label.setText(NLS.bind(Messages.RefactoringWebArtifactsWizard_label_single_linked, BasicElementsLabels.getResourceName(resources[0]))); + } else { + label.setText(NLS.bind(Messages.RefactoringWebArtifactsWizard_label_multi_linked, new Integer(resources.length))); + } + } else { + if (resources.length == 1) { + label.setText(NLS.bind(Messages.RefactoringWebArtifactsWizard_label_single, BasicElementsLabels.getResourceName(resources[0]))); + } else { + label.setText(NLS.bind(Messages.RefactoringWebArtifactsWizard_label_multi, new Integer(resources.length))); + } + } + GridData gridData= new GridData(SWT.FILL, SWT.FILL, true, false); + gridData.widthHint= convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); + label.setLayoutData(gridData); + + Composite supportArea= new Composite(composite, SWT.NONE); + supportArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); + gridLayout= new GridLayout(1, false); + gridLayout.horizontalSpacing= defaultSpacing.x * 2; + gridLayout.verticalSpacing= defaultSpacing.y; + + supportArea.setLayout(gridLayout); + + if (Resources.containsOnlyProjects(resources)) { + fDeleteContentsButton= new Button(supportArea, SWT.CHECK); + fDeleteContentsButton.setFont(composite.getFont()); + fDeleteContentsButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + fDeleteContentsButton.setText(Messages.RefactoringWebArtifactsWizard_project_deleteContents); + fDeleteContentsButton.setFocus(); + } + setControl(composite); + + } + + private boolean containsLinkedResource(IResource[] resources) { + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + if (resource != null && resource.isLinked()) { // paranoia code, can not be null + return true; + } + } + return false; + } + + @Override + protected boolean performFinish() { + initializeRefactoring(); + storeSettings(); + return super.performFinish(); + } + + @Override + public IWizardPage getNextPage() { + initializeRefactoring(); + storeSettings(); + return super.getNextPage(); + } + + private void initializeRefactoring() { + fRefactoringProcessor.setDeleteContents(fDeleteContentsButton == null ? false : fDeleteContentsButton.getSelection()); + } + + private void storeSettings() { + } + + } +} +