Author: dazarov
Date: 2010-10-28 12:04:27 -0400 (Thu, 28 Oct 2010)
New Revision: 26110
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddSetterMarkerResolution.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/SeamProblemMarkerResolutionGenerator.java
Log:
https://jira.jboss.org/browse/JBIDE-6872
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddSetterMarkerResolution.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddSetterMarkerResolution.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddSetterMarkerResolution.java 2010-10-28
16:04:27 UTC (rev 26110)
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.marker;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.internal.corext.codemanipulation.GetterSetterUtil;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IMarkerResolution2;
+import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamProperty;
+import org.jboss.tools.seam.ui.SeamGuiPlugin;
+import org.jboss.tools.seam.ui.SeamUIMessages;
+
+/**
+ * @author Daniel Azarov
+ */
+public class AddSetterMarkerResolution implements IMarkerResolution2{
+ private ISeamProperty property;
+ private ISeamJavaComponentDeclaration javaDeclaration;
+
+ private String label;
+
+ public AddSetterMarkerResolution(ISeamProperty property, ISeamJavaComponentDeclaration
javaDeclaration){
+ this.property = property;
+ this.javaDeclaration = javaDeclaration;
+ this.label = MessageFormat.format(SeamUIMessages.ADD_SETTER_MARKER_RESOLUTION_TITLE,
new Object[]{property.getName(), javaDeclaration.getClassName()});
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void run(IMarker marker) {
+ IType type = (IType)javaDeclaration.getSourceMember();
+ try{
+ ICompilationUnit original = type.getCompilationUnit();
+ ICompilationUnit compilationUnit = original.getWorkingCopy(new
NullProgressMonitor());
+ IType createdType = compilationUnit.getType(type.getElementName());
+
+ final String lineDelim= compilationUnit.findRecommendedLineSeparator();
+
+ IField field = createdType.getField(property.getName());
+ String propertyType="";
+ if(field != null && field.exists()){
+ propertyType = field.getTypeSignature();
+ }else{
+ propertyType = "String";
+ field = createdType.createField(lineDelim+"private "+propertyType+"
"+property.getName()+";", null, false, null);
+// synchronized(compilationUnit) {
+// compilationUnit.reconcile(ICompilationUnit.NO_AST, false, null, null);
+// }
+ }
+ String setterName = GetterSetterUtil.getSetterName(field, null);
+
+ createMethod(createdType, propertyType, setterName, lineDelim);
+
+ compilationUnit.commitWorkingCopy(true, new NullProgressMonitor());
+ }catch(CoreException ex){
+ SeamGuiPlugin.getPluginLog().logError(ex);
+ }
+ }
+
+ private IMethod createMethod(IType type, String typeName, String methodName, String
lineDelim) throws CoreException{
+ StringBuffer buf= new StringBuffer();
+
+ buf.append(lineDelim);
+ buf.append("public void "+methodName+"("+typeName+"
"+property.getName()+") {"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
+ buf.append(lineDelim);
+ buf.append("this."+property.getName()+" =
"+property.getName()+";"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append(lineDelim);
+ buf.append("}"); //$NON-NLS-1$
+ return type.createMethod(buf.toString(), null, false, null);
+ }
+
+ public String getDescription() {
+ return null;
+ }
+
+ public Image getImage() {
+ return null;
+ }
+
+}
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddSetterMarkerResolution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/SeamProblemMarkerResolutionGenerator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/SeamProblemMarkerResolutionGenerator.java 2010-10-28
15:51:28 UTC (rev 26109)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/SeamProblemMarkerResolutionGenerator.java 2010-10-28
16:04:27 UTC (rev 26110)
@@ -10,11 +10,24 @@
******************************************************************************/
package org.jboss.tools.seam.ui.marker;
+import java.util.Collection;
+import java.util.Set;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.IMarkerResolutionGenerator2;
+import org.jboss.tools.common.text.ITextSourceReference;
+import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.ISeamProperty;
+import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
import org.jboss.tools.seam.internal.core.validation.SeamCoreValidator;
import org.jboss.tools.seam.ui.SeamGuiPlugin;
import org.jboss.tools.seam.ui.SeamUIMessages;
@@ -22,109 +35,217 @@
/**
* @author Daniel Azarov
*/
-public class SeamProblemMarkerResolutionGenerator implements IMarkerResolutionGenerator2
{
+public class SeamProblemMarkerResolutionGenerator implements
+ IMarkerResolutionGenerator2 {
private static final String JAVA_EXTENSION = "java"; //$NON-NLS-1$
+ private static final String XML_EXTENSION = "xml"; //$NON-NLS-1$
public IMarkerResolution[] getResolutions(IMarker marker) {
- try{
+ try {
return findResolutions(marker);
- }catch(CoreException ex){
+ } catch (CoreException ex) {
SeamGuiPlugin.getPluginLog().logError(ex);
}
- return new IMarkerResolution[]{};
+ return new IMarkerResolution[] {};
}
-
- private IMarkerResolution[] findResolutions(IMarker marker) throws CoreException{
- Integer attribute =
((Integer)marker.getAttribute(SeamCoreValidator.MESSAGE_ID_ATTRIBUTE_NAME));
- if(attribute == null)
- return new IMarkerResolution[]{};
-
+
+ private IMarkerResolution[] findResolutions(IMarker marker)
+ throws CoreException {
+ Integer attribute = ((Integer) marker
+ .getAttribute(SeamCoreValidator.MESSAGE_ID_ATTRIBUTE_NAME));
+ if (attribute == null)
+ return new IMarkerResolution[] {};
+
int messageId = attribute.intValue();
-
- IFile file = (IFile)marker.getResource();
-
- if(!JAVA_EXTENSION.equals(file.getFileExtension()))
- return new IMarkerResolution[]{};
-
- attribute = ((Integer)marker.getAttribute(IMarker.CHAR_START));
- if(attribute == null)
- return new IMarkerResolution[]{};
+
+ IFile file = (IFile) marker.getResource();
+
+ attribute = ((Integer) marker.getAttribute(IMarker.CHAR_START));
+ if (attribute == null)
+ return new IMarkerResolution[] {};
int start = attribute.intValue();
-
- attribute = ((Integer)marker.getAttribute(IMarker.CHAR_END));
- if(attribute == null)
- return new IMarkerResolution[]{};
+
+ attribute = ((Integer) marker.getAttribute(IMarker.CHAR_END));
+ if (attribute == null)
+ return new IMarkerResolution[] {};
int end = attribute.intValue();
-
- if(messageId == SeamCoreValidator.NONUNIQUE_COMPONENT_NAME_MESSAGE_ID){
- return new IMarkerResolution[]{
- new
RenameAnnotationMarkerResolution(SeamUIMessages.RENAME_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Name", file, start, end),
- new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Name",file, start, end)
- };
- } else if(messageId == SeamCoreValidator.DUPLICATE_REMOVE_MESSAGE_ID)
- return new IMarkerResolution[]{new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_REMOVE_ANNOTATION_MARKER_RESOLUTION_TITLE,
"javax.ejb.Remove", file, start, end)};
- else if(messageId == SeamCoreValidator.DUPLICATE_DESTROY_MESSAGE_ID)
- return new IMarkerResolution[]{new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_DESTROY_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Destroy", file, start, end)};
- else if(messageId == SeamCoreValidator.DUPLICATE_CREATE_MESSAGE_ID)
- return new IMarkerResolution[]{new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_CREATE_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Create", file, start, end)};
- else if(messageId == SeamCoreValidator.DUPLICATE_UNWRAP_MESSAGE_ID)
- return new IMarkerResolution[]{new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_UNWRAP_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Unwrap", file, start, end)};
- else if(messageId ==
SeamCoreValidator.DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN_MESSAGE_ID)
- return new IMarkerResolution[]{new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_DESTROY_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Destroy", file, start, end)};
- else if(messageId == SeamCoreValidator.CREATE_DOESNT_BELONG_TO_COMPONENT_MESSAGE_ID)
- return new IMarkerResolution[]{
- new
AddAnnotationMarkerResolution(SeamUIMessages.ADD_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Name", file, start, end, true),
- new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_CREATE_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Create", file, start, end)
- };
- else if(messageId == SeamCoreValidator.UNWRAP_DOESNT_BELONG_TO_COMPONENT_MESSAGE_ID)
- return new IMarkerResolution[]{
- new
AddAnnotationMarkerResolution(SeamUIMessages.ADD_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Name", file, start, end, true),
- new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_UNWRAP_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Unwrap", file, start, end)
- };
- else if(messageId == SeamCoreValidator.OBSERVER_DOESNT_BELONG_TO_COMPONENT_MESSAGE_ID)
- return new IMarkerResolution[]{
- new
AddAnnotationMarkerResolution(SeamUIMessages.ADD_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Name", file, start, end, true),
- new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_OBSERVER_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Observer", file, start, end)
- };
- else if(messageId == SeamCoreValidator.STATEFUL_COMPONENT_DOES_NOT_CONTAIN_REMOVE_ID)
- return new IMarkerResolution[]{new
AddAnnotatedMethodMarkerResolution(SeamUIMessages.ADD_ANNOTATED_REMOVE_METHOD_MARKER_RESOLUTION_TITLE,
"javax.ejb.Remove", file, start, end)};
- else if(messageId == SeamCoreValidator.STATEFUL_COMPONENT_DOES_NOT_CONTAIN_DESTROY_ID)
- return new IMarkerResolution[]{new
AddAnnotatedMethodMarkerResolution(SeamUIMessages.ADD_ANNOTATED_DESTROY_METHOD_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Destroy", file, start, end)};
- else if(messageId == SeamCoreValidator.STATEFUL_COMPONENT_WRONG_SCOPE_ID)
- return new IMarkerResolution[]{
- new
ChangeScopeMarkerResolution(SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
"ScopeType.APPLICATION", file, start, end),
- new
ChangeScopeMarkerResolution(SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
"ScopeType.BUSINESS_PROCESS", file, start, end),
- new
ChangeScopeMarkerResolution(SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
"ScopeType.CONVERSATION", file, start, end),
- new
ChangeScopeMarkerResolution(SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
"ScopeType.EVENT", file, start, end),
- new
ChangeScopeMarkerResolution(SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
"ScopeType.METHOD", file, start, end),
- new
ChangeScopeMarkerResolution(SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
"ScopeType.SESSION", file, start, end),
- new
ChangeScopeMarkerResolution(SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
"ScopeType.UNSPECIFIED", file, start, end)
- };
- else if(messageId == SeamCoreValidator.ENTITY_COMPONENT_WRONG_SCOPE_ID)
- return new IMarkerResolution[]{
- new
ChangeScopeMarkerResolution(SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
"ScopeType.APPLICATION", file, start, end),
- new
ChangeScopeMarkerResolution(SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
"ScopeType.BUSINESS_PROCESS", file, start, end),
- new
ChangeScopeMarkerResolution(SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
"ScopeType.CONVERSATION", file, start, end),
- new
ChangeScopeMarkerResolution(SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
"ScopeType.EVENT", file, start, end),
- new
ChangeScopeMarkerResolution(SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
"ScopeType.METHOD", file, start, end),
- new
ChangeScopeMarkerResolution(SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
"ScopeType.PAGE", file, start, end),
- new
ChangeScopeMarkerResolution(SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
"ScopeType.SESSION", file, start, end),
- new
ChangeScopeMarkerResolution(SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
"ScopeType.UNSPECIFIED", file, start, end)
- };
-
- return new IMarkerResolution[]{};
+ if (JAVA_EXTENSION.equals(file.getFileExtension())) {
+ if (messageId == SeamCoreValidator.NONUNIQUE_COMPONENT_NAME_MESSAGE_ID) {
+ return new IMarkerResolution[] {
+ new RenameAnnotationMarkerResolution(
+ SeamUIMessages.RENAME_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
+ "org.jboss.seam.annotations.Name", file, start,
+ end),
+ new DeleteAnnotationMarkerResolution(
+ SeamUIMessages.DELETE_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
+ "org.jboss.seam.annotations.Name", file, start,
+ end) };
+ } else if (messageId == SeamCoreValidator.DUPLICATE_REMOVE_MESSAGE_ID)
+ return new IMarkerResolution[] { new DeleteAnnotationMarkerResolution(
+ SeamUIMessages.DELETE_REMOVE_ANNOTATION_MARKER_RESOLUTION_TITLE,
+ "javax.ejb.Remove", file, start, end) };
+ else if (messageId == SeamCoreValidator.DUPLICATE_DESTROY_MESSAGE_ID)
+ return new IMarkerResolution[] { new DeleteAnnotationMarkerResolution(
+ SeamUIMessages.DELETE_DESTROY_ANNOTATION_MARKER_RESOLUTION_TITLE,
+ "org.jboss.seam.annotations.Destroy", file, start, end) };
+ else if (messageId == SeamCoreValidator.DUPLICATE_CREATE_MESSAGE_ID)
+ return new IMarkerResolution[] { new DeleteAnnotationMarkerResolution(
+ SeamUIMessages.DELETE_CREATE_ANNOTATION_MARKER_RESOLUTION_TITLE,
+ "org.jboss.seam.annotations.Create", file, start, end) };
+ else if (messageId == SeamCoreValidator.DUPLICATE_UNWRAP_MESSAGE_ID)
+ return new IMarkerResolution[] { new DeleteAnnotationMarkerResolution(
+ SeamUIMessages.DELETE_UNWRAP_ANNOTATION_MARKER_RESOLUTION_TITLE,
+ "org.jboss.seam.annotations.Unwrap", file, start, end) };
+ else if (messageId ==
SeamCoreValidator.DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN_MESSAGE_ID)
+ return new IMarkerResolution[] { new DeleteAnnotationMarkerResolution(
+ SeamUIMessages.DELETE_DESTROY_ANNOTATION_MARKER_RESOLUTION_TITLE,
+ "org.jboss.seam.annotations.Destroy", file, start, end) };
+ else if (messageId == SeamCoreValidator.CREATE_DOESNT_BELONG_TO_COMPONENT_MESSAGE_ID)
+ return new IMarkerResolution[] {
+ new AddAnnotationMarkerResolution(
+ SeamUIMessages.ADD_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
+ "org.jboss.seam.annotations.Name", file, start,
+ end, true),
+ new DeleteAnnotationMarkerResolution(
+ SeamUIMessages.DELETE_CREATE_ANNOTATION_MARKER_RESOLUTION_TITLE,
+ "org.jboss.seam.annotations.Create", file,
+ start, end) };
+ else if (messageId == SeamCoreValidator.UNWRAP_DOESNT_BELONG_TO_COMPONENT_MESSAGE_ID)
+ return new IMarkerResolution[] {
+ new AddAnnotationMarkerResolution(
+ SeamUIMessages.ADD_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
+ "org.jboss.seam.annotations.Name", file, start,
+ end, true),
+ new DeleteAnnotationMarkerResolution(
+ SeamUIMessages.DELETE_UNWRAP_ANNOTATION_MARKER_RESOLUTION_TITLE,
+ "org.jboss.seam.annotations.Unwrap", file,
+ start, end) };
+ else if (messageId ==
SeamCoreValidator.OBSERVER_DOESNT_BELONG_TO_COMPONENT_MESSAGE_ID)
+ return new IMarkerResolution[] {
+ new AddAnnotationMarkerResolution(
+ SeamUIMessages.ADD_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
+ "org.jboss.seam.annotations.Name", file, start,
+ end, true),
+ new DeleteAnnotationMarkerResolution(
+ SeamUIMessages.DELETE_OBSERVER_ANNOTATION_MARKER_RESOLUTION_TITLE,
+ "org.jboss.seam.annotations.Observer", file,
+ start, end) };
+ else if (messageId ==
SeamCoreValidator.STATEFUL_COMPONENT_DOES_NOT_CONTAIN_REMOVE_ID)
+ return new IMarkerResolution[] { new AddAnnotatedMethodMarkerResolution(
+ SeamUIMessages.ADD_ANNOTATED_REMOVE_METHOD_MARKER_RESOLUTION_TITLE,
+ "javax.ejb.Remove", file, start, end) };
+ else if (messageId ==
SeamCoreValidator.STATEFUL_COMPONENT_DOES_NOT_CONTAIN_DESTROY_ID)
+ return new IMarkerResolution[] { new AddAnnotatedMethodMarkerResolution(
+ SeamUIMessages.ADD_ANNOTATED_DESTROY_METHOD_MARKER_RESOLUTION_TITLE,
+ "org.jboss.seam.annotations.Destroy", file, start, end) };
+ else if (messageId == SeamCoreValidator.STATEFUL_COMPONENT_WRONG_SCOPE_ID)
+ return new IMarkerResolution[] {
+ new ChangeScopeMarkerResolution(
+ SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
+ "ScopeType.APPLICATION", file, start, end),
+ new ChangeScopeMarkerResolution(
+ SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
+ "ScopeType.BUSINESS_PROCESS", file, start, end),
+ new ChangeScopeMarkerResolution(
+ SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
+ "ScopeType.CONVERSATION", file, start, end),
+ new ChangeScopeMarkerResolution(
+ SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
+ "ScopeType.EVENT", file, start, end),
+ new ChangeScopeMarkerResolution(
+ SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
+ "ScopeType.METHOD", file, start, end),
+ new ChangeScopeMarkerResolution(
+ SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
+ "ScopeType.SESSION", file, start, end),
+ new ChangeScopeMarkerResolution(
+ SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
+ "ScopeType.UNSPECIFIED", file, start, end) };
+ else if (messageId == SeamCoreValidator.ENTITY_COMPONENT_WRONG_SCOPE_ID)
+ return new IMarkerResolution[] {
+ new ChangeScopeMarkerResolution(
+ SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
+ "ScopeType.APPLICATION", file, start, end),
+ new ChangeScopeMarkerResolution(
+ SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
+ "ScopeType.BUSINESS_PROCESS", file, start, end),
+ new ChangeScopeMarkerResolution(
+ SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
+ "ScopeType.CONVERSATION", file, start, end),
+ new ChangeScopeMarkerResolution(
+ SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
+ "ScopeType.EVENT", file, start, end),
+ new ChangeScopeMarkerResolution(
+ SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
+ "ScopeType.METHOD", file, start, end),
+ new ChangeScopeMarkerResolution(
+ SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
+ "ScopeType.PAGE", file, start, end),
+ new ChangeScopeMarkerResolution(
+ SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
+ "ScopeType.SESSION", file, start, end),
+ new ChangeScopeMarkerResolution(
+ SeamUIMessages.CHANGE_SCOPETYPE_MARKER_RESOLUTION_TITLE,
+ "ScopeType.UNSPECIFIED", file, start, end) };
+ }else if(XML_EXTENSION.equals(file.getFileExtension())){
+ if (messageId == SeamCoreValidator.UNKNOWN_COMPONENT_PROPERTY_ID){
+ ISeamProperty property = findSeamProperty(file, start, end);
+ if(property != null){
+ if(property.getParent() != null && property.getParent() instanceof
SeamComponentDeclaration){
+ SeamComponentDeclaration xmlDeclaration =
(SeamComponentDeclaration)property.getParent();
+ if(xmlDeclaration == null){
+ return new IMarkerResolution[] {};
+ }
+ for(ISeamComponent component : xmlDeclaration.getComponents()){
+ ISeamJavaComponentDeclaration javaDeclaration = component.getJavaDeclaration();
+ if(javaDeclaration != null)
+ return new IMarkerResolution[] { new AddSetterMarkerResolution(property,
javaDeclaration) };
+ }
+ }
+ }
+ }
+ }
+
+ return new IMarkerResolution[] {};
}
+ private ISeamProperty findSeamProperty(IFile file, int start, int end){
+ if(file == null)
+ return null;
+ IProject project = file.getProject();
+ if(project == null)
+ return null;
+
+ ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, false);
+ if(seamProject == null)
+ return null;
+
+ Set<ISeamComponent> components =
seamProject.getComponentsByPath(file.getFullPath());
+ for(ISeamComponent component : components){
+ Set<ISeamXmlComponentDeclaration> declarations =
component.getXmlDeclarations();
+ for(ISeamXmlComponentDeclaration declaration : declarations){
+ Collection<ISeamProperty> properties = declaration.getProperties();
+ for(ISeamProperty property : properties){
+ ITextSourceReference location =
property.getLocationFor(ISeamXmlComponentDeclaration.NAME);
+ if(location.getStartPosition() <= start &&
(location.getStartPosition()+location.getLength()) >= end)
+ return property;
+ }
+ }
+ }
+
+ return null;
+ }
+
public boolean hasResolutions(IMarker marker) {
- try{
- if(findResolutions(marker).length != 0)
+ try {
+ if (findResolutions(marker).length != 0)
return true;
- }catch(CoreException ex){
+ } catch (CoreException ex) {
SeamGuiPlugin.getPluginLog().logError(ex);
}
return false;
}
-
+
}