Author: dazarov
Date: 2009-06-09 08:31:48 -0400 (Tue, 09 Jun 2009)
New Revision: 15815
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreMessages.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
Log:
Seam Refactor: Added warning message if component has a declaration which is located in
jar file
https://jira.jboss.org/jira/browse/JBIDE-1077
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreMessages.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreMessages.java 2009-06-09
12:12:35 UTC (rev 15814)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreMessages.java 2009-06-09
12:31:48 UTC (rev 15815)
@@ -44,4 +44,5 @@
public static String RENAME_SEAM_COMPONENT_PROCESSOR_TITLE;
public static String RENAME_SEAM_COMPONENT_PROCESSOR_THIS_IS_NOT_A_SEAM_COMPONENT;
public static String RENAME_SEAM_CONTEXT_VARIABLE_PROCESSOR_TITLE;
+ public static String SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR;
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties 2009-06-09
12:12:35 UTC (rev 15814)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties 2009-06-09
12:31:48 UTC (rev 15815)
@@ -32,4 +32,5 @@
RENAME_SEAM_COMPONENT_PROCESSOR_TITLE=Rename Seam Component
RENAME_SEAM_COMPONENT_PROCESSOR_THIS_IS_NOT_A_SEAM_COMPONENT=This is not a Seam
Component.
RENAME_SEAM_CONTEXT_VARIABLE_PROCESSOR_TITLE=Rename Seam Context Variable
+SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR=This component has a declaration
which is located in jar file
SEAM_INSTALL_WIZARD_PROJECT_NAME_WITH_UPPERCASE=Project names which start with a capital
letter may break Seam/JSF applications; use lower case.
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-06-09
12:12:35 UTC (rev 15814)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-06-09
12:31:48 UTC (rev 15815)
@@ -56,7 +56,10 @@
public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
CheckConditionsContext context) throws CoreException,
OperationCanceledException {
- return new RefactoringStatus();
+ RefactoringStatus status = new RefactoringStatus();
+ if(component != null && isJarDeclarations(component))
+ status.addWarning(SeamCoreMessages.SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR);
+ return status;
}
/*
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java 2009-06-09
12:12:35 UTC (rev 15814)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java 2009-06-09
12:31:48 UTC (rev 15815)
@@ -53,7 +53,11 @@
public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
CheckConditionsContext context) throws CoreException,
OperationCanceledException {
- return new RefactoringStatus();
+ RefactoringStatus status = new RefactoringStatus();
+ ISeamComponent component = checkComponent();
+ if(component != null && isJarDeclarations(component))
+ status.addWarning(SeamCoreMessages.SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR);
+ return status;
}
/*
@@ -64,9 +68,6 @@
public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
throws CoreException, OperationCanceledException {
RefactoringStatus result = new RefactoringStatus();
-// if(getNewName()==null) {
-// result.addFatalError(SeamCoreMessages.RENAME_SEAM_COMPONENT_PROCESSOR_THIS_IS_NOT_A_SEAM_COMPONENT);
-// }
return result;
}
@@ -77,6 +78,7 @@
@Override
public Change createChange(IProgressMonitor pm) throws CoreException,
OperationCanceledException {
+
rootChange = new
CompositeChange(SeamCoreMessages.RENAME_SEAM_CONTEXT_VARIABLE_PROCESSOR_TITLE);
ISeamComponent component = checkComponent();
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-06-09
12:12:35 UTC (rev 15814)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-06-09
12:31:48 UTC (rev 15815)
@@ -22,6 +22,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.internal.ui.text.FastJavaPartitionScanner;
import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.jface.text.BadLocationException;
@@ -29,6 +30,7 @@
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.Token;
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.RenameProcessor;
import org.eclipse.text.edits.MultiTextEdit;
@@ -59,6 +61,7 @@
import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
+import org.jboss.tools.seam.core.SeamCoreMessages;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.SeamProjectsSet;
import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
@@ -80,7 +83,7 @@
protected static final String SEAM_PROPERTIES_FILE = "seam.properties";
//$NON-NLS-1$
private SeamContextValidationHelper coreHelper = new SeamContextValidationHelper();
-
+
protected CompositeChange rootChange;
protected TextFileChange lastChange;
protected IFile declarationFile=null;
@@ -315,8 +318,24 @@
}
}
+ protected boolean isJarDeclarations(ISeamComponent component) throws CoreException{
+ if(component.getJavaDeclaration() != null){
+ if(coreHelper.isJar(component.getJavaDeclaration()))
+ return true;
+ }
+
+ Set<ISeamXmlComponentDeclaration> xmlDecls = component.getXmlDeclarations();
+
+ for(ISeamXmlComponentDeclaration xmlDecl : xmlDecls){
+ if(coreHelper.isJar(xmlDecl))
+ return true;
+ }
+ return false;
+ }
+
private void renameJavaDeclaration(ISeamJavaComponentDeclaration javaDecl) throws
CoreException{
IFile file = (IFile)javaDecl.getResource();
+
if(file != null && !coreHelper.isJar(javaDecl)){
ITextSourceReference location =
((SeamComponentDeclaration)javaDecl).getLocationFor(ISeamXmlComponentDeclaration.NAME);
if(location != null && !isBadLocation(location)){
@@ -328,8 +347,9 @@
declarationFile = file;
}
- private void renameXMLDeclaration(ISeamXmlComponentDeclaration xmlDecl){
+ private void renameXMLDeclaration(ISeamXmlComponentDeclaration xmlDecl) throws
CoreException{
IFile file = (IFile)xmlDecl.getResource();
+
if(file != null && !coreHelper.isJar(xmlDecl)){
ITextSourceReference location =
((SeamComponentDeclaration)xmlDecl).getLocationFor(ISeamXmlComponentDeclaration.NAME);
if(location != null && !isBadLocation(location))