Author: dazarov
Date: 2011-02-25 16:56:09 -0500 (Fri, 25 Feb 2011)
New Revision: 29353
Modified:
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreMessages.java
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/messages.properties
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRenameProcessor.java
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionRefactoringProcessor.java
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ElCoreMessages.java
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELReferencesQueryParticipant.java
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameMethodParticipant.java
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ELRenameProcessor.java
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameMessagePropertyProcessor.java
branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreMessages.java
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
Log:
https://issues.jboss.org/browse/JBIDE-8476
Modified:
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreMessages.java
===================================================================
---
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreMessages.java 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreMessages.java 2011-02-25
21:56:09 UTC (rev 29353)
@@ -26,9 +26,11 @@
public static String CDI_FACET_INSTALL_ABSTRACT_DELEGATE_CHECK_ERROR_LOG_VIEW;
public static String CDI_FACET_INSTALL_ABSTRACT_DELEGATE_ERROR;
- public static String CDI_RENAME_PROCESSOR_OUT_OF_SYNC_FILE;
- public static String CDI_RENAME_PROCESSOR_ERROR_PHANTOM_FILE;
+ public static String CDI_RENAME_PROCESSOR_OUT_OF_SYNC_PROJECT;
public static String CDI_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE;
+ public static String CDI_RENAME_PROCESSOR_QUESTION_DIALOG_TITLE;
+ public static String CDI_RENAME_PROCESSOR_QUESTION_DIALOG_MESSAGE;
+
public static String RENAME_NAMED_BEAN_PROCESSOR_TITLE;
public static String RENAME_NAMED_BEAN_PROCESSOR_ERROR;
public static String CDI_RENAME_PROCESSOR_BEAN_HAS_NO_FILE;
Modified:
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/messages.properties
===================================================================
---
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/messages.properties 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/messages.properties 2011-02-25
21:56:09 UTC (rev 29353)
@@ -1,9 +1,10 @@
CDI_FACET_INSTALL_ABSTRACT_DELEGATE_ERROR=Error
CDI_FACET_INSTALL_ABSTRACT_DELEGATE_ERRORS_OCCURED=Error occured during installing CDI
facet
CDI_FACET_INSTALL_ABSTRACT_DELEGATE_CHECK_ERROR_LOG_VIEW=Check Errors View for details
-CDI_RENAME_PROCESSOR_OUT_OF_SYNC_FILE=Cannot change file. File ''{0}'' is
not in sync.
-CDI_RENAME_PROCESSOR_ERROR_PHANTOM_FILE=Cannot change phantom file:
''{0}''.
+CDI_RENAME_PROCESSOR_OUT_OF_SYNC_PROJECT=Cannot change file(s). Project
''{0}'' is not in sync.
CDI_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE=Cannot change read-only file:
''{0}''.
+CDI_RENAME_PROCESSOR_QUESTION_DIALOG_TITLE=Read-only File Encountered
+CDI_RENAME_PROCESSOR_QUESTION_DIALOG_MESSAGE=File ''{0}'' is read-only.
Do you wish to make it writable?
RENAME_NAMED_BEAN_PROCESSOR_TITLE=Rename @Named Bean
RENAME_NAMED_BEAN_PROCESSOR_ERROR=This is not a @Named Bean
CDI_RENAME_PROCESSOR_BEAN_HAS_NO_FILE=Named Bean does not have a file
Modified:
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRenameProcessor.java
===================================================================
---
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRenameProcessor.java 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIRenameProcessor.java 2011-02-25
21:56:09 UTC (rev 29353)
@@ -15,7 +15,6 @@
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -24,7 +23,7 @@
import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
-import org.eclipse.ltk.internal.core.refactoring.Messages;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
@@ -121,22 +120,6 @@
change(declarationFile, nameLocation.getStartPosition(), nameLocation.getLength(),
newText);
}
-
- protected boolean isFileCorrect(IFile file){
- if(!file.isSynchronized(IResource.DEPTH_ZERO)){
- status.addFatalError(Messages.format(CDICoreMessages.CDI_RENAME_PROCESSOR_OUT_OF_SYNC_FILE,
file.getFullPath().toString()));
- return false;
- }else if(file.isPhantom()){
- status.addFatalError(Messages.format(CDICoreMessages.CDI_RENAME_PROCESSOR_ERROR_PHANTOM_FILE,
file.getFullPath().toString()));
- return false;
- }else if(file.isReadOnly()){
- status.addFatalError(Messages.format(CDICoreMessages.CDI_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
- return false;
- }
- return true;
- }
-
-
protected void renameBean(IProgressMonitor pm, IBean bean)throws CoreException{
pm.beginTask("", 3);
@@ -179,13 +162,16 @@
}
@Override
- protected boolean isFileCorrect(IFile file) {
- return CDIRenameProcessor.this.isFileCorrect(file);
+ protected void outOfSynch(IProject project) {
+ status.addFatalError(NLS.bind(CDICoreMessages.CDI_RENAME_PROCESSOR_OUT_OF_SYNC_PROJECT,
project.getFullPath().toString()));
}
@Override
protected void match(IFile file, int offset, int length) {
- change(file, offset, length, newName);
+ if(isFileReadOnly(file)){
+ status.addFatalError(NLS.bind(CDICoreMessages.CDI_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
+ }else
+ change(file, offset, length, newName);
}
protected ELInvocationExpression findComponentReference(ELInvocationExpression
invocationExpression){
Modified:
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionRefactoringProcessor.java
===================================================================
---
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionRefactoringProcessor.java 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionRefactoringProcessor.java 2011-02-25
21:56:09 UTC (rev 29353)
@@ -26,7 +26,7 @@
import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
-import org.eclipse.ltk.internal.core.refactoring.Messages;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -107,13 +107,12 @@
private boolean isFileCorrect(IFile file){
if(!file.isSynchronized(IResource.DEPTH_ZERO)){
- status.addFatalError(Messages.format(CDICoreMessages.CDI_RENAME_PROCESSOR_OUT_OF_SYNC_FILE,
file.getFullPath().toString()));
+ status.addFatalError(NLS.bind(CDICoreMessages.CDI_RENAME_PROCESSOR_OUT_OF_SYNC_PROJECT,
file.getProject().getFullPath().toString()));
return false;
}else if(file.isPhantom()){
- status.addFatalError(Messages.format(CDICoreMessages.CDI_RENAME_PROCESSOR_ERROR_PHANTOM_FILE,
file.getFullPath().toString()));
return false;
}else if(file.isReadOnly()){
- status.addFatalError(Messages.format(CDICoreMessages.CDI_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
+ status.addFatalError(NLS.bind(CDICoreMessages.CDI_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
return false;
}
return true;
Modified:
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ElCoreMessages.java
===================================================================
---
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ElCoreMessages.java 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ElCoreMessages.java 2011-02-25
21:56:09 UTC (rev 29353)
@@ -23,9 +23,11 @@
public static String StringTokenDescription_Name;
public static String WhiteSpaceTokenDescription_Name;
- public static String EL_RENAME_PROCESSOR_OUT_OF_SYNC_FILE;
- public static String EL_RENAME_PROCESSOR_ERROR_PHANTOM_FILE;
+ public static String EL_RENAME_PROCESSOR_OUT_OF_SYNC_PROJECT;
public static String EL_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE;
+ public static String EL_RENAME_PROCESSOR_QUESTION_DIALOG_TITLE;
+ public static String EL_RENAME_PROCESSOR_QUESTION_DIALOG_MESSAGE;
+
public static String RENAME_EL_VARIABLE_PROCESSOR_TITLE;
public static String RENAME_MESSAGE_PROPERTY_PROCESSOR_TITLE;
public static String RENAME_EL_VARIABLE_PROCESSOR_CAN_NOT_FIND_EL_VARIABLE;
Modified:
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties
===================================================================
---
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties 2011-02-25
21:56:09 UTC (rev 29353)
@@ -16,9 +16,11 @@
PrimitiveValueTokenDescription_Name=Primitive
StringTokenDescription_Name=String
WhiteSpaceTokenDescription_Name=Whitespace
-EL_RENAME_PROCESSOR_OUT_OF_SYNC_FILE=Cannot change file. File ''{0}'' is
not in sync.
-EL_RENAME_PROCESSOR_ERROR_PHANTOM_FILE=Cannot change phantom file:
''{0}''.
+EL_RENAME_PROCESSOR_OUT_OF_SYNC_PROJECT=Cannot change file(s). Project
''{0}'' is not in sync.
EL_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE=Cannot change read-only file:
''{0}''.
+EL_RENAME_PROCESSOR_QUESTION_DIALOG_TITLE=Read-only File Encountered
+EL_RENAME_PROCESSOR_QUESTION_DIALOG_MESSAGE=File ''{0}'' is read-only. Do
you wish to make it writable?
+
RENAME_EL_VARIABLE_PROCESSOR_TITLE=Rename EL Variable
RENAME_MESSAGE_PROPERTY_PROCESSOR_TITLE=Rename Resource Bundle Message
RENAME_EL_VARIABLE_PROCESSOR_CAN_NOT_FIND_EL_VARIABLE=Can not find EL Variable:
''{0}''.
Modified:
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ELRenameProcessor.java
===================================================================
---
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ELRenameProcessor.java 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ELRenameProcessor.java 2011-02-25
21:56:09 UTC (rev 29353)
@@ -15,7 +15,6 @@
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.ltk.core.refactoring.CompositeChange;
@@ -23,7 +22,7 @@
import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
-import org.eclipse.ltk.internal.core.refactoring.Messages;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
@@ -33,7 +32,6 @@
import org.jboss.tools.common.el.core.resolver.ELResolver;
import org.jboss.tools.common.el.core.resolver.IRelevanceCheck;
import org.jboss.tools.common.model.project.ProjectHome;
-import org.jboss.tools.common.text.ITextSourceReference;
import org.jboss.tools.jst.web.kb.refactoring.RefactorSearcher;
/**
@@ -108,20 +106,6 @@
return lastChange;
}
- private boolean isBadLocation(ITextSourceReference location, IFile file){
- boolean flag;
- if(location == null)
- flag = true;
- else
- flag = location.getStartPosition() == 0 && location.getLength() == 0;
-
-// if(flag)
-// status.addFatalError(Messages.format(ElCoreMessages.EL_RENAME_PROCESSOR_LOCATION_NOT_FOUND,
file.getFullPath().toString()));
- return flag;
- }
-
-
-
private void change(IFile file, int offset, int length, String text){
String key = file.getFullPath().toString()+" "+offset;
if(!keys.contains(key)){
@@ -132,21 +116,6 @@
}
}
- protected boolean isFileCorrect(IFile file){
- if(!file.isSynchronized(IResource.DEPTH_ZERO)){
- status.addFatalError(Messages.format(ElCoreMessages.EL_RENAME_PROCESSOR_OUT_OF_SYNC_FILE,
file.getFullPath().toString()));
- return false;
- }else if(file.isPhantom()){
- status.addFatalError(Messages.format(ElCoreMessages.EL_RENAME_PROCESSOR_ERROR_PHANTOM_FILE,
file.getFullPath().toString()));
- return false;
- }else if(file.isReadOnly()){
- status.addFatalError(Messages.format(ElCoreMessages.EL_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
- return false;
- }
- return true;
- }
-
-
public class ELSearcher extends RefactorSearcher{
public ELSearcher(IFile file, String oldName){
@@ -191,12 +160,15 @@
@Override
protected void match(IFile file, int offset, int length) {
- change(file, offset, length, newName);
+ if(isFileReadOnly(file)){
+ status.addFatalError(NLS.bind(ElCoreMessages.EL_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
+ }else
+ change(file, offset, length, newName);
}
@Override
- protected boolean isFileCorrect(IFile file) {
- return ELRenameProcessor.this.isFileCorrect(file);
+ protected void outOfSynch(IProject project) {
+ status.addFatalError(NLS.bind(ElCoreMessages.EL_RENAME_PROCESSOR_OUT_OF_SYNC_PROJECT,
project.getFullPath().toString()));
}
protected ELInvocationExpression findComponentReference(ELInvocationExpression
invocationExpression){
Modified:
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameMessagePropertyProcessor.java
===================================================================
---
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameMessagePropertyProcessor.java 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameMessagePropertyProcessor.java 2011-02-25
21:56:09 UTC (rev 29353)
@@ -23,10 +23,10 @@
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
import org.jboss.tools.common.el.core.ELReference;
-import org.eclipse.ltk.internal.core.refactoring.Messages;
import org.jboss.tools.common.el.core.ElCoreMessages;
import org.jboss.tools.common.el.core.model.ELExpression;
import org.jboss.tools.common.el.core.resolver.ELCompletionEngine;
@@ -89,7 +89,7 @@
RefactoringStatus result = new RefactoringStatus();
if(!validateSegment())
- result.addFatalError(Messages.format(ElCoreMessages.RENAME_MESSAGE_PROPERTY_PROCESSOR_CAN_NOT_FIND_MESSAGE_PROPERTY,
getOldName()));
+ result.addFatalError(NLS.bind(ElCoreMessages.RENAME_MESSAGE_PROPERTY_PROCESSOR_CAN_NOT_FIND_MESSAGE_PROPERTY,
getOldName()));
return result;
}
Modified:
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java
===================================================================
---
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java 2011-02-25
21:56:09 UTC (rev 29353)
@@ -19,10 +19,12 @@
public static String RENAME_METHOD_PARTICIPANT_GETTER_WARNING;
public static String RENAME_METHOD_PARTICIPANT_SETTER_WARNING;
- public static String RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_FILE;
- public static String RENAME_METHOD_PARTICIPANT_ERROR_PHANTOM_FILE;
+ public static String RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_PROJECT;
public static String RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE;
public static String RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES;
+ public static String RENAME_METHOD_PARTICIPANT_QUESTION_DIALOG_TITLE;
+ public static String RENAME_METHOD_PARTICIPANT_QUESTION_DIALOG_MESSAGE;
+
public static String RESOURCE_BUNDLES_RENAME_PARTICIPANT_UPDATE_BUNDLE_REFERENCES;
public static String REFACTOR_CONTRIBUTOR_MAIN_MENU;
Modified:
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELReferencesQueryParticipant.java
===================================================================
---
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELReferencesQueryParticipant.java 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELReferencesQueryParticipant.java 2011-02-25
21:56:09 UTC (rev 29353)
@@ -13,7 +13,6 @@
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -92,15 +91,8 @@
}
- protected boolean isFileCorrect(IFile file){
- if(!file.isSynchronized(IResource.DEPTH_ZERO)){
- return false;
- }else if(file.isPhantom()){
- return false;
- }else if(file.isReadOnly()){
- return false;
- }
- return true;
+ protected void outOfSynch(IProject file){
+ // do nothing
}
@Override
Modified:
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameMethodParticipant.java
===================================================================
---
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameMethodParticipant.java 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameMethodParticipant.java 2011-02-25
21:56:09 UTC (rev 29353)
@@ -15,7 +15,6 @@
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -30,7 +29,7 @@
import org.eclipse.ltk.core.refactoring.participants.ISharableParticipant;
import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
-import org.eclipse.ltk.internal.core.refactoring.Messages;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
@@ -180,24 +179,16 @@
}
}
- @Override
- protected boolean isFileCorrect(IFile file) {
- if(!file.isSynchronized(IResource.DEPTH_ZERO)){
- status.addFatalError(Messages.format(JsfUIMessages.RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_FILE,
file.getFullPath().toString()));
- return false;
- }else if(file.isPhantom()){
- status.addFatalError(Messages.format(JsfUIMessages.RENAME_METHOD_PARTICIPANT_ERROR_PHANTOM_FILE,
file.getFullPath().toString()));
- return false;
- }else if(file.isReadOnly()){
- status.addFatalError(Messages.format(JsfUIMessages.RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
- return false;
- }
- return true;
+ protected void outOfSynch(IProject project){
+ status.addFatalError(NLS.bind(JsfUIMessages.RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_PROJECT,
project.getFullPath().toString()));
}
@Override
protected void match(IFile file, int offset, int length) {
- change(file, offset, length, newName);
+ if(isFileReadOnly(file)){
+ status.addFatalError(NLS.bind(JsfUIMessages.RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
+ }else
+ change(file, offset, length, newName);
}
protected IProject[] getProjects(){
Modified:
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties
===================================================================
---
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties 2011-02-25
21:56:09 UTC (rev 29353)
@@ -12,10 +12,11 @@
LinkEditPart_Link=Link
RENAME_METHOD_PARTICIPANT_GETTER_WARNING=Be sure, may be you also should rename setter
method to avoid compilation problems.
RENAME_METHOD_PARTICIPANT_SETTER_WARNING=Be sure, may be you also should rename getter
method to avoid compilation problems.
-RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_FILE=Cannot change file. File
''{0}'' is not in sync.
-RENAME_METHOD_PARTICIPANT_ERROR_PHANTOM_FILE=Cannot change phantom file:
''{0}''.
+RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_PROJECT=Cannot change file(s). Project
''{0}'' is not in sync.
RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE=Cannot change read-only file:
''{0}''.
RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES=Update method references in EL
+RENAME_METHOD_PARTICIPANT_QUESTION_DIALOG_TITLE=Read-only File Encountered
+RENAME_METHOD_PARTICIPANT_QUESTION_DIALOG_MESSAGE=File ''{0}'' is
read-only. Do you wish to make it writable?
EL_REFACTOR_RENAME_HANDLER_ERROR=Operation failed
RESOURCE_BUNDLES_RENAME_PARTICIPANT_UPDATE_BUNDLE_REFERENCES=Update bundle references in
EL
REFACTOR_CONTRIBUTOR_MAIN_MENU=EL Refactor
Modified:
branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java
===================================================================
---
branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java 2011-02-25
21:56:09 UTC (rev 29353)
@@ -11,7 +11,6 @@
package org.jboss.tools.jst.web.kb.refactoring;
import java.io.InputStream;
-import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
@@ -30,13 +29,9 @@
import org.jboss.tools.common.el.core.ELCorePlugin;
import org.jboss.tools.common.el.core.ELReference;
import org.jboss.tools.common.el.core.model.ELExpression;
-import org.jboss.tools.common.el.core.model.ELInstance;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
import org.jboss.tools.common.el.core.model.ELMethodInvocation;
-import org.jboss.tools.common.el.core.model.ELModel;
import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
-import org.jboss.tools.common.el.core.parser.ELParser;
-import org.jboss.tools.common.el.core.parser.ELParserUtil;
import org.jboss.tools.common.el.core.resolver.ELCompletionEngine;
import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.el.core.resolver.ELResolution;
@@ -59,9 +54,9 @@
protected static final String JSP_EXT = "jsp"; //$NON-NLS-1$
protected static final String PROPERTIES_EXT = "properties"; //$NON-NLS-1$
- private static final String GET = "get"; //$NON-NLS-1$
- private static final String SET = "set"; //$NON-NLS-1$
- private static final String IS = "is"; //$NON-NLS-1$
+// private static final String GET = "get"; //$NON-NLS-1$
+// private static final String SET = "set"; //$NON-NLS-1$
+// private static final String IS = "is"; //$NON-NLS-1$
protected static final String SEAM_PROPERTIES_FILE = "seam.properties";
//$NON-NLS-1$
@@ -70,7 +65,6 @@
protected IJavaElement javaElement;
protected IJavaSearchScope searchScope;
-
public RefactorSearcher(IFile baseFile, String propertyName){
this.baseFile = baseFile;
this.propertyName = propertyName;
@@ -106,18 +100,31 @@
if(javaProject != null){
for(IResource resource : EclipseResourceUtil.getJavaSourceRoots(project)){
if(resource instanceof IFolder)
- scanForJava((IFolder) resource);
+ if(!scanForJava((IFolder) resource)){
+ outOfSynch(((IFolder) resource).getProject());
+ return;
+ }
else if(resource instanceof IFile)
- scanForJava((IFile) resource);
+ if(!scanForJava((IFile) resource)){
+ outOfSynch(((IFile) resource).getProject());
+ return;
+ }
}
}
// searching jsp, xhtml and xml files in WebContent folders
- if(getViewFolder(project) != null)
- scan(getViewFolder(project));
- else
- scan(project);
+ if(getViewFolder(project) != null){
+ if(!scan(getViewFolder(project))){
+ outOfSynch(project);
+ return;
+ }
+ }else{
+ if(!scan(project)){
+ outOfSynch(project);
+ return;
+ }
+ }
}
//stopStatistic();
}
@@ -130,36 +137,44 @@
protected abstract IContainer getViewFolder(IProject project);
- private void scanForJava(IContainer container){
+ private boolean scanForJava(IContainer container){
if(container.getName().startsWith(".")) //$NON-NLS-1$
- return;
+ return true;
try{
for(IResource resource : container.members()){
- if(resource instanceof IFolder)
- scanForJava((IFolder) resource);
- else if(resource instanceof IFile)
- scanForJava((IFile) resource);
+ if(resource instanceof IFolder){
+ if(!scanForJava((IFolder) resource))
+ return false;
+ }else if(resource instanceof IFile){
+ if(!scanForJava((IFile) resource))
+ return false;
+ }
}
}catch(CoreException ex){
ELCorePlugin.getDefault().logError(ex);
}
+ return true;
}
- private void scan(IContainer container){
+ private boolean scan(IContainer container){
if(container.getName().startsWith(".")) //$NON-NLS-1$
- return;
+ return true;
try{
for(IResource resource : container.members()){
- if(resource instanceof IFolder)
- scan((IFolder) resource);
- else if(resource instanceof IFile)
- scan((IFile) resource);
+ if(resource instanceof IFolder){
+ if(!scan((IFolder) resource))
+ return false;
+ }else if(resource instanceof IFile){
+ if(!scan((IFile) resource))
+ return false;
+ }
}
}catch(CoreException ex){
ELCorePlugin.getDefault().logError(ex);
}
+ return true;
}
private String getFileContent(IFile file){
@@ -172,32 +187,56 @@
return null;
}
- private void scanForJava(IFile file){
- if(isFileCorrect(file)) {
- if(PROPERTIES_EXT.equalsIgnoreCase(file.getFileExtension())){
- if(file.getName().equals(SEAM_PROPERTIES_FILE)){
- String content = getFileContent(file);
- scanProperties(file, content);
- }else
- searchInCach(file);
- } else if (JAVA_EXT.equalsIgnoreCase(file.getFileExtension())
- || JSP_EXT.equalsIgnoreCase(file.getFileExtension())
- || XHTML_EXT.equalsIgnoreCase(file.getFileExtension())
- || XML_EXT.equalsIgnoreCase(file.getFileExtension())) {
+ /**
+ *
+ * @param file
+ * @return
+ * true - in order to continue searching
+ * false - in order to stop searching
+ */
+ private boolean scanForJava(IFile file){
+ if(isFilePhantom(file))
+ return true;
+
+ if(isFileOutOfSynch(file))
+ return false;
+
+ if(PROPERTIES_EXT.equalsIgnoreCase(file.getFileExtension())){
+ if(file.getName().equals(SEAM_PROPERTIES_FILE)){
+ String content = getFileContent(file);
+ scanProperties(file, content);
+ }else
searchInCach(file);
- }
+ } else if (JAVA_EXT.equalsIgnoreCase(file.getFileExtension())
+ || JSP_EXT.equalsIgnoreCase(file.getFileExtension())
+ || XHTML_EXT.equalsIgnoreCase(file.getFileExtension())
+ || XML_EXT.equalsIgnoreCase(file.getFileExtension())) {
+ searchInCach(file);
}
+ return true;
}
- private void scan(IFile file){
- if(isFileCorrect(file)) {
- String ext = file.getFileExtension();
- if(XML_EXT.equalsIgnoreCase(ext)
- || XHTML_EXT.equalsIgnoreCase(ext)
- || JSP_EXT.equalsIgnoreCase(ext)) {
- searchInCach(file);
- }
+ /**
+ *
+ * @param file
+ * @return
+ * true - in order to continue searching
+ * false - in order to stop searching
+ */
+ private boolean scan(IFile file){
+ if(isFilePhantom(file))
+ return true;
+
+ if(isFileOutOfSynch(file))
+ return false;
+
+ String ext = file.getFileExtension();
+ if(XML_EXT.equalsIgnoreCase(ext)
+ || XHTML_EXT.equalsIgnoreCase(ext)
+ || JSP_EXT.equalsIgnoreCase(ext)) {
+ searchInCach(file);
}
+ return true;
}
protected void searchInCach(IFile file){
@@ -375,8 +414,20 @@
return invocationExpression;
}
- protected abstract boolean isFileCorrect(IFile file);
+ protected boolean isFileOutOfSynch(IFile file){
+ return !file.isSynchronized(IResource.DEPTH_ZERO);
+ }
+ protected boolean isFilePhantom(IFile file){
+ return file.isPhantom();
+ }
+
+ protected boolean isFileReadOnly(IFile file){
+ return file.isReadOnly();
+ }
+
+ protected abstract void outOfSynch(IProject file);
+
protected abstract void match(IFile file, int offset, int length);
protected void checkMatch(IFile file, ELExpression operand, int offset, int length){
Modified:
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreMessages.java
===================================================================
---
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreMessages.java 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreMessages.java 2011-02-25
21:56:09 UTC (rev 29353)
@@ -55,12 +55,14 @@
public static String RENAME_SEAM_CONTEXT_VARIABLE_PROCESSOR_TITLE;
public static String
RENAME_SEAM_CONTEXT_VARIABLE_PROCESSOR_CAN_NOT_FIND_CONTEXT_VARIABLE;
public static String SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR;
- public static String SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_FILE;
- public static String SEAM_RENAME_PROCESSOR_ERROR_PHANTOM_FILE;
+ public static String SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_PROJECT;
public static String SEAM_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE;
public static String SEAM_RENAME_PROCESSOR_LOCATION_NOT_FOUND;
public static String SEAM_RENAME_PROCESSOR_DECLARATION_NOT_FOUND;
public static String SEAM_RENAME_PROCESSOR_COMPONENT_HAS_BROKEN_DECLARATION;
+ public static String SEAM_RENAME_PROCESSOR_QUESTION_DIALOG_TITLE;
+ public static String SEAM_RENAME_PROCESSOR_QUESTION_DIALOG_MESSAGE;
+
public static String SEAM_RENAME_METHOD_PARTICIPANT_SETTER_WARNING;
public static String SEAM_RENAME_METHOD_PARTICIPANT_GETTER_WARNING;
}
\ No newline at end of file
Modified:
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties
===================================================================
---
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties 2011-02-25
21:56:09 UTC (rev 29353)
@@ -34,11 +34,13 @@
RENAME_SEAM_CONTEXT_VARIABLE_PROCESSOR_TITLE=Rename Seam Context Variable
RENAME_SEAM_CONTEXT_VARIABLE_PROCESSOR_CAN_NOT_FIND_CONTEXT_VARIABLE=Can not find Seam
Context Variable: ''{0}''.
SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR=Component
''{0}'' has a declaration which is located in jar file:
''{1}''. Press next to force rename.
-SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_FILE=Cannot change file. File ''{0}''
is not in sync.
+SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_PROJECT=Cannot change file(s). Project
''{0}'' is not in sync.
SEAM_RENAME_PROCESSOR_LOCATION_NOT_FOUND=Location for declaration or annotation not found
in file: ''{0}''
SEAM_RENAME_PROCESSOR_DECLARATION_NOT_FOUND=Component: ''{0}'' does not
have any declarations
-SEAM_RENAME_PROCESSOR_ERROR_PHANTOM_FILE=Cannot change phantom file:
''{0}''.
SEAM_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE=Cannot change read-only file:
''{0}''.
SEAM_RENAME_PROCESSOR_COMPONENT_HAS_BROKEN_DECLARATION=Declaration of component
''{0}'' is broken.
+SEAM_RENAME_PROCESSOR_QUESTION_DIALOG_TITLE=Read-only File Encountered
+SEAM_RENAME_PROCESSOR_QUESTION_DIALOG_MESSAGE=File ''{0}'' is read-only.
Do you wish to make it writable?
+
SEAM_RENAME_METHOD_PARTICIPANT_SETTER_WARNING=Be sure, may be you also should rename
getter method to avoid compilation problems.
SEAM_RENAME_METHOD_PARTICIPANT_GETTER_WARNING=Be sure, may be you also should rename
setter method to avoid compilation problems.
Modified:
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java
===================================================================
---
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java 2011-02-25
21:56:09 UTC (rev 29353)
@@ -16,7 +16,6 @@
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.IJavaElement;
import org.jboss.tools.common.el.core.model.ELExpression;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
@@ -68,15 +67,8 @@
}
@Override
- protected boolean isFileCorrect(IFile file){
- if(!file.isSynchronized(IResource.DEPTH_ZERO)){
- return false;
- }else if(file.isPhantom()){
- return false;
- }else if(file.isReadOnly()){
- return false;
- }
- return true;
+ protected void outOfSynch(IProject file){
+ // do nothing
}
protected void checkMatch(IFile file, ELExpression operand, int offset, int length){
Modified:
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
===================================================================
---
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2011-02-25
21:47:58 UTC (rev 29352)
+++
branches/jbosstools-3.2.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2011-02-25
21:56:09 UTC (rev 29353)
@@ -17,14 +17,13 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
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.RefactoringParticipant;
import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
-import org.eclipse.ltk.internal.core.refactoring.Messages;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
@@ -140,7 +139,7 @@
protected void findAnnotations(){
if(declarationFile == null){
- status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_DECLARATION_NOT_FOUND,
getOldName()));
+ status.addFatalError(NLS.bind(SeamCoreMessages.SEAM_RENAME_PROCESSOR_DECLARATION_NOT_FOUND,
getOldName()));
return;
}
@@ -183,7 +182,10 @@
for(IBijectedAttribute attribute : attributes){
ITextSourceReference location = attribute.getLocationFor(locationPath);
- changeAnnotation(location, (IFile)attribute.getResource());
+ if(!changeAnnotation(location, (IFile)attribute.getResource())){
+ status.addFatalError(NLS.bind(SeamCoreMessages.SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_PROJECT,
seamProject.getProject().getFullPath().toString()));
+ return;
+ }
}
}
@@ -192,12 +194,16 @@
if(file.getFileExtension().equalsIgnoreCase(JAVA_EXT)){
ITextSourceReference location =
factory.getLocationFor(SeamAnnotations.FACTORY_ANNOTATION_TYPE);
- changeAnnotation(location, file);
-
+ if(!changeAnnotation(location, file)){
+ status.addFatalError(NLS.bind(SeamCoreMessages.SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_PROJECT,
file.getProject().getFullPath().toString()));
+ return;
+ }
}else{
ITextSourceReference location =
factory.getLocationFor(ISeamXmlComponentDeclaration.NAME);
- changeXMLNode(location, file);
-
+ if(!changeXMLNode(location, file)){
+ status.addFatalError(NLS.bind(SeamCoreMessages.SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_PROJECT,
file.getProject().getFullPath().toString()));
+ return;
+ }
}
}
@@ -209,16 +215,19 @@
flag = location.getStartPosition() == 0 && location.getLength() == 0;
if(flag)
- status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_LOCATION_NOT_FOUND,
file.getFullPath().toString()));
+ status.addFatalError(NLS.bind(SeamCoreMessages.SEAM_RENAME_PROCESSOR_LOCATION_NOT_FOUND,
file.getFullPath().toString()));
return flag;
}
- private void changeXMLNode(ITextSourceReference location, IFile file){
+ private boolean changeXMLNode(ITextSourceReference location, IFile file){
if(isBadLocation(location, file))
- return;
+ return true;
- if(!isFileCorrect(file))
- return;
+ if(file.isPhantom())
+ return true;
+
+ if(!file.isSynchronized(IResource.DEPTH_ZERO))
+ return false;
String content = null;
try {
@@ -237,14 +246,18 @@
}else{
change(file, location.getStartPosition(), location.getLength(), getNewName());
}
+ return true;
}
- private void changeAnnotation(ITextSourceReference location, IFile file){
+ private boolean changeAnnotation(ITextSourceReference location, IFile file){
if(isBadLocation(location, file))
- return;
+ return true;
- if(!isFileCorrect(file))
- return;
+ if(file.isPhantom())
+ return true;
+
+ if(!file.isSynchronized(IResource.DEPTH_ZERO))
+ return false;
String content = null;
try {
@@ -289,6 +302,7 @@
String newText = "(\""+getNewName()+"\")"; //$NON-NLS-1$
//$NON-NLS-2$
change(file, location.getStartPosition()+location.getLength(), 0, newText);
}
+ return true;
}
@@ -307,34 +321,33 @@
protected void checkDeclarations(ISeamComponent component) throws CoreException{
if(component.getJavaDeclaration() != null){
if(component.getJavaDeclaration().getResource() == null)
- status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_COMPONENT_HAS_BROKEN_DECLARATION,
new String[]{component.getName()}));
+ status.addFatalError(NLS.bind(SeamCoreMessages.SEAM_RENAME_PROCESSOR_COMPONENT_HAS_BROKEN_DECLARATION,
new String[]{component.getName()}));
else if(SeamUtil.isJar(component.getJavaDeclaration()) &&
component.getJavaDeclaration().getName() != null)
- status.addInfo(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR,
new String[]{component.getName(),
component.getJavaDeclaration().getResource().getFullPath().toString()}));
+ status.addInfo(NLS.bind(SeamCoreMessages.SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR,
new String[]{component.getName(),
component.getJavaDeclaration().getResource().getFullPath().toString()}));
}
Set<ISeamXmlComponentDeclaration> xmlDecls = component.getXmlDeclarations();
for(ISeamXmlComponentDeclaration xmlDecl : xmlDecls){
if(xmlDecl.getResource() == null)
- status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_COMPONENT_HAS_BROKEN_DECLARATION,
new String[]{component.getName()}));
+ status.addFatalError(NLS.bind(SeamCoreMessages.SEAM_RENAME_PROCESSOR_COMPONENT_HAS_BROKEN_DECLARATION,
new String[]{component.getName()}));
else if(SeamUtil.isJar(xmlDecl) && xmlDecl.getName() != null)
- status.addInfo(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR,
new String[]{component.getName(), xmlDecl.getResource().getFullPath().toString()}));
+ status.addInfo(NLS.bind(SeamCoreMessages.SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR,
new String[]{component.getName(), xmlDecl.getResource().getFullPath().toString()}));
}
}
- protected boolean isFileCorrect(IFile file){
- if(!file.isSynchronized(IResource.DEPTH_ZERO)){
- status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_FILE,
file.getFullPath().toString()));
- return false;
- }else if(file.isPhantom()){
- status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_ERROR_PHANTOM_FILE,
file.getFullPath().toString()));
- return false;
- }else if(file.isReadOnly()){
- status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
- return false;
- }
- return true;
- }
+// protected boolean isFileCorrect(IFile file){
+// if(!file.isSynchronized(IResource.DEPTH_ZERO)){
+// status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_PROJECT,
file.getProject().getFullPath().toString()));
+// return false;
+// }else if(file.isPhantom()){
+// return false;
+// }else if(file.isReadOnly()){
+// status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
+// return false;
+// }
+// return true;
+// }
private void renameJavaDeclaration(ISeamJavaComponentDeclaration javaDecl) throws
CoreException{
IFile file = (IFile)javaDecl.getResource();
@@ -359,19 +372,6 @@
declarationFile = file;
}
-
- private boolean checkFolder(IResource resource, IResource[] sources, IPath output){
- for(IResource folder : sources){
- if(resource.equals(folder))
- return false;
- }
-
- if(resource.getFullPath().equals(output))
- return false;
-
- return true;
- }
-
protected void renameComponent(IProgressMonitor pm, ISeamComponent component)throws
CoreException{
pm.beginTask("", 3);
@@ -442,7 +442,10 @@
}
private void change(IFile file, int offset, int length, String text){
- //System.out.println("change file - "+file.getFullPath()+" offset -
"+offset+" len - "+length+" text"+text);
+ if(file.isReadOnly()){
+ status.addFatalError(NLS.bind(SeamCoreMessages.SEAM_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
+ return;
+ }
String key = file.getFullPath().toString()+" "+offset;
if(!keys.contains(key)){
TextFileChange change = getChange(file);
@@ -472,13 +475,16 @@
}
@Override
- protected boolean isFileCorrect(IFile file) {
- return SeamRenameProcessor.this.isFileCorrect(file);
+ protected void outOfSynch(IProject project) {
+ status.addFatalError(NLS.bind(SeamCoreMessages.SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_PROJECT,
project.getFullPath().toString()));
}
@Override
protected void match(IFile file, int offset, int length) {
- change(file, offset, length, newName);
+ if(isFileReadOnly(file)){
+ status.addFatalError(NLS.bind(SeamCoreMessages.SEAM_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
+ }else
+ change(file, offset, length, newName);
}
protected ELInvocationExpression findComponentReference(ELInvocationExpression
invocationExpression){