JBoss Tools SVN: r33050 - in trunk/cdi/plugins: org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2011-07-19 16:45:55 -0400 (Tue, 19 Jul 2011)
New Revision: 33050
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeRetentionAnnotationMarkerResolution.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationErrorManager.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java
Log:
https://issues.jboss.org/browse/JBIDE-7631
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java 2011-07-19 18:55:40 UTC (rev 33049)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java 2011-07-19 20:45:55 UTC (rev 33050)
@@ -15,6 +15,8 @@
public String TARGET_ANNOTATION_TYPE_NAME = "java.lang.annotation.Target";
public String RETENTION_ANNOTATION_TYPE_NAME = "java.lang.annotation.Retention";
+ public String RETENTION_POLICY_RUNTIME_TYPE_NAME = "java.lang.annotation.RetentionPolicy.RUNTIME";
+
public String QUALIFIER_ANNOTATION_TYPE_NAME = "javax.inject.Qualifier";
public String NAMED_QUALIFIER_TYPE_NAME = "javax.inject.Named";
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java 2011-07-19 18:55:40 UTC (rev 33049)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java 2011-07-19 20:45:55 UTC (rev 33050)
@@ -70,7 +70,7 @@
/*
* Stereotype annotation type should be annotated with @Retention(RUNTIME)
*/
- validateRetentionAnnotation(stereotype, CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE, resource);
+ validateRetentionAnnotation(stereotype, CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE, resource, CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE_ID);
IAnnotationDeclaration target = stereotype.getAnnotationDeclaration(CDIConstants.TARGET_ANNOTATION_TYPE_NAME);
if(target!=null) {
@@ -182,13 +182,13 @@
/*
* Scope annotation type should be annotated with @Retention(RUNTIME)
*/
- validateRetentionAnnotation(scope, CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE, resource);
+ validateRetentionAnnotation(scope, CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE, resource, CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE_ID);
}
- void validateRetentionAnnotation(ICDIAnnotation type, String message, IResource resource) throws JavaModelException {
+ void validateRetentionAnnotation(ICDIAnnotation type, String message, IResource resource, int message_id) throws JavaModelException {
IAnnotationDeclaration retention = type.getAnnotationDeclaration(CDIConstants.RETENTION_ANNOTATION_TYPE_NAME);
if(retention == null) {
- validator.addError(message, CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, CDIUtil.convertToSourceReference(type.getSourceType().getNameRange(), resource), resource);
+ validator.addError(message, CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, CDIUtil.convertToSourceReference(type.getSourceType().getNameRange(), resource), resource, message_id);
} else {
boolean ok = false;
Object o = retention.getMemberValue(null);
@@ -200,7 +200,7 @@
if(!"RUNTIME".equals(s)) ok = false;
}
if(!ok) {
- validator.addError(message, CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, retention, resource);
+ validator.addError(message, CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, retention, resource, message_id);
}
}
}
@@ -215,7 +215,7 @@
/*
* Qualifier annotation type should be annotated with @Retention(RUNTIME)
*/
- validateRetentionAnnotation(qualifier, CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_QUALIFIER_TYPE, resource);
+ validateRetentionAnnotation(qualifier, CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_QUALIFIER_TYPE, resource, CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_QUALIFIER_TYPE_ID);
}
private void validateTargetAnnotation(ICDIAnnotation annotationType, String[][] variants, String message, IResource resource) throws JavaModelException {
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationErrorManager.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationErrorManager.java 2011-07-19 18:55:40 UTC (rev 33049)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationErrorManager.java 2011-07-19 20:45:55 UTC (rev 33050)
@@ -29,6 +29,9 @@
public static final int AMBIGUOUS_INJECTION_POINTS_ID = 8;
public static final int NOT_PASSIVATION_CAPABLE_BEAN_ID = 9;
public static final int ILLEGAL_SCOPE_FOR_MANAGED_BEAN_WITH_PUBLIC_FIELD_ID = 10;
+ public static final int MISSING_RETENTION_ANNOTATION_IN_QUALIFIER_TYPE_ID = 11;
+ public static final int MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE_ID = 12;
+ public static final int MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE_ID = 13;
/*
* (non-Javadoc)
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java 2011-07-19 18:55:40 UTC (rev 33049)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.java 2011-07-19 20:45:55 UTC (rev 33050)
@@ -103,6 +103,8 @@
public static String ADD_SERIALIZABLE_INTERFACE_MARKER_RESOLUTION_TITLE;
public static String MAKE_BEAN_SCOPED_DEPENDENT_MARKER_RESOLUTION_TITLE;
public static String MAKE_FIELD_PROTECTED_MARKER_RESOLUTION_TITLE;
+ public static String ADD_RETENTION_MARKER_RESOLUTION_TITLE;
+ public static String CHANGE_RETENTION_MARKER_RESOLUTION_TITLE;
public static String QUESTION;
public static String DECREASING_FIELD_VISIBILITY_MAY_CAUSE_COMPILATION_PROBLEMS;
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2011-07-19 18:55:40 UTC (rev 33049)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties 2011-07-19 20:45:55 UTC (rev 33050)
@@ -87,6 +87,8 @@
ADD_SERIALIZABLE_INTERFACE_MARKER_RESOLUTION_TITLE=Add java.io.Serializable interface to ''{0}'' class
MAKE_BEAN_SCOPED_DEPENDENT_MARKER_RESOLUTION_TITLE=Make ''{0}'' bean scoped @Dependent
MAKE_FIELD_PROTECTED_MARKER_RESOLUTION_TITLE=Make ''{0}'' field protected
+ADD_RETENTION_MARKER_RESOLUTION_TITLE=Add @Retention(RUNTIME) annotation to ''{0}'' class
+CHANGE_RETENTION_MARKER_RESOLUTION_TITLE=Change ''{0}'' annotation to @Retention(RUNTIME)
QUESTION=Question
DECREASING_FIELD_VISIBILITY_MAY_CAUSE_COMPILATION_PROBLEMS=Decreasing field visibility may cause compilation problems. Do you want to continue?
Added: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java 2011-07-19 20:45:55 UTC (rev 33050)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.cdi.ui.marker;
+
+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.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IMarkerResolution2;
+import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
+import org.jboss.tools.cdi.ui.CDIUIPlugin;
+
+public class AddRetentionAnnotationMarkerResolution implements
+ IMarkerResolution2 {
+ private IType type;
+ private String label;
+
+ public AddRetentionAnnotationMarkerResolution(IType type){
+ this.type = type;
+ label = NLS.bind(CDIUIMessages.ADD_RETENTION_MARKER_RESOLUTION_TITLE, type.getElementName());
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void run(IMarker marker) {
+ try{
+ ICompilationUnit original = type.getCompilationUnit();
+ ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
+
+ MarkerResolutionUtils.addImport(CDIConstants.RETENTION_POLICY_RUNTIME_TYPE_NAME, compilationUnit, true);
+
+ IType workingCopyType = MarkerResolutionUtils.findWorkingCopyType(compilationUnit, type);
+
+ MarkerResolutionUtils.addAnnotation(CDIConstants.RETENTION_ANNOTATION_TYPE_NAME, compilationUnit, workingCopyType, "(RUNTIME)");
+
+ compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ compilationUnit.discardWorkingCopy();
+ }catch(CoreException ex){
+ CDIUIPlugin.getDefault().logError(ex);
+ }
+ }
+
+ public String getDescription() {
+ return label;
+ }
+
+ public Image getImage() {
+ return null;
+ }
+}
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java 2011-07-19 18:55:40 UTC (rev 33049)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java 2011-07-19 20:45:55 UTC (rev 33050)
@@ -187,6 +187,23 @@
}
}
}
+ }else if(messageId == CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_QUALIFIER_TYPE_ID ||
+ messageId == CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE_ID ||
+ messageId == CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE_ID){
+
+ TypeAndAnnotation ta = findTypeOrRetentionAnnotation(file, start);
+ if(ta != null){
+ if(ta.annotation == null){
+ return new IMarkerResolution[] {
+ new AddRetentionAnnotationMarkerResolution(ta.type)
+ };
+ }else{
+ return new IMarkerResolution[] {
+ new ChangeRetentionAnnotationMarkerResolution(ta.type, ta.annotation)
+ };
+
+ }
+ }
}
}
return new IMarkerResolution[] {};
@@ -287,6 +304,39 @@
return null;
}
+ class TypeAndAnnotation{
+ IType type;
+ IAnnotation annotation;
+
+ public TypeAndAnnotation(IType type){
+ this.type = type;
+ }
+
+ public TypeAndAnnotation(IType type, IAnnotation annotation){
+ this(type);
+ this.annotation = annotation;
+ }
+ }
+
+ private TypeAndAnnotation findTypeOrRetentionAnnotation(IFile file, int start) throws JavaModelException{
+ IJavaElement javaElement = findJavaElement(file, start);
+ if(javaElement != null && javaElement instanceof IType){
+ IType type = (IType)javaElement;
+ if(!type.isBinary()){
+ String shortName = MarkerResolutionUtils.getShortName(CDIConstants.RETENTION_ANNOTATION_TYPE_NAME);
+ IAnnotation[] annotations = type.getAnnotations();
+ for(IAnnotation annotation : annotations){
+ if(annotation.getElementName().equals(CDIConstants.RETENTION_ANNOTATION_TYPE_NAME) ||
+ annotation.getElementName().equals(shortName))
+ return new TypeAndAnnotation(type, annotation);
+
+ }
+ return new TypeAndAnnotation(type);
+ }
+ }
+ return null;
+ }
+
private IJavaElement findJavaElement(IFile file, int start){
try{
ICompilationUnit compilationUnit = EclipseUtil.getCompilationUnit(file);
Added: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeRetentionAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeRetentionAnnotationMarkerResolution.java (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeRetentionAnnotationMarkerResolution.java 2011-07-19 20:45:55 UTC (rev 33050)
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.cdi.ui.marker;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IBuffer;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IMarkerResolution2;
+import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.ui.CDIUIMessages;
+import org.jboss.tools.cdi.ui.CDIUIPlugin;
+
+public class ChangeRetentionAnnotationMarkerResolution implements
+ IMarkerResolution2 {
+ private String label=null;
+ private IType type;
+ private IAnnotation annotation;
+
+ public ChangeRetentionAnnotationMarkerResolution(IType type, IAnnotation annotation){
+ this.type = type;
+ this.annotation = annotation;
+ try {
+ label = NLS.bind(CDIUIMessages.CHANGE_RETENTION_MARKER_RESOLUTION_TITLE, annotation.getSource());
+ } catch (JavaModelException e) {
+ CDIUIPlugin.getDefault().logError(e);
+ }
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void run(IMarker marker) {
+ try{
+ ICompilationUnit original = type.getCompilationUnit();
+ ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
+
+ MarkerResolutionUtils.addImport(CDIConstants.RETENTION_POLICY_RUNTIME_TYPE_NAME, compilationUnit, true);
+
+ IAnnotation workingCopyAnnotation = MarkerResolutionUtils.findWorkingCopyAnnotation(compilationUnit, type, annotation);
+
+ IBuffer buffer = compilationUnit.getBuffer();
+ String shortName = MarkerResolutionUtils.getShortName(CDIConstants.RETENTION_ANNOTATION_TYPE_NAME);
+
+
+ buffer.replace(workingCopyAnnotation.getSourceRange().getOffset(), workingCopyAnnotation.getSourceRange().getLength(), MarkerResolutionUtils.AT+shortName+"(RUNTIME)");
+
+ compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ compilationUnit.discardWorkingCopy();
+ }catch(CoreException ex){
+ CDIUIPlugin.getDefault().logError(ex);
+ }
+ }
+
+ public String getDescription() {
+ return label;
+ }
+
+ public Image getImage() {
+ return null;
+ }
+}
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeRetentionAnnotationMarkerResolution.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java 2011-07-19 18:55:40 UTC (rev 33049)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java 2011-07-19 20:45:55 UTC (rev 33050)
@@ -19,6 +19,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IAnnotatable;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IBuffer;
@@ -91,6 +92,18 @@
* @throws JavaModelException
*/
public static boolean addImport(String qualifiedName, ICompilationUnit compilationUnit) throws JavaModelException{
+ return addImport(qualifiedName, compilationUnit, false);
+ }
+
+ /**
+ *
+ * @param qualifiedName
+ * @param compilationUnit
+ * @param staticFlag
+ * @return true if there is import in compilation unit with the same short name
+ * @throws JavaModelException
+ */
+ public static boolean addImport(String qualifiedName, ICompilationUnit compilationUnit, boolean staticFlag) throws JavaModelException{
if(primitives.contains(qualifiedName))
return false;
@@ -136,12 +149,19 @@
return true;
}
- compilationUnit.createImport(qualifiedName, null, new NullProgressMonitor());
+ if(staticFlag)
+ compilationUnit.createImport(qualifiedName, null, Flags.AccStatic, new NullProgressMonitor());
+ else
+ compilationUnit.createImport(qualifiedName, null, new NullProgressMonitor());
}
return false;
}
public static void addAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IType element) throws JavaModelException{
+ addAnnotation(qualifiedName, compilationUnit, element, "");
+ }
+
+ public static void addAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IType element, String params) throws JavaModelException{
IAnnotation annotation = getAnnotation(element, qualifiedName);
if(annotation != null && annotation.exists())
return;
@@ -156,7 +176,7 @@
if(duplicateShortName)
shortName = qualifiedName;
- buffer.replace(element.getSourceRange().getOffset(), 0, AT+shortName+lineDelim);
+ buffer.replace(element.getSourceRange().getOffset(), 0, AT+shortName+params+lineDelim);
synchronized(compilationUnit) {
compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
@@ -449,4 +469,21 @@
}
return null;
}
+
+ public static IType findWorkingCopyType(ICompilationUnit compilationUnit, IType type) throws JavaModelException{
+ for(IType t : compilationUnit.getAllTypes()){
+ if(t.getFullyQualifiedName().equals(type.getFullyQualifiedName()))
+ return t;
+ }
+ return null;
+ }
+
+ public static IAnnotation findWorkingCopyAnnotation(ICompilationUnit compilationUnit, IType type, IAnnotation annotation) throws JavaModelException{
+ IType workingCopyType = findWorkingCopyType(compilationUnit, type);
+ for(IAnnotation a : workingCopyType.getAnnotations()){
+ if(a.getElementName().equals(annotation.getElementName()))
+ return a;
+ }
+ return null;
+ }
}
14 years, 8 months
JBoss Tools SVN: r33049 - trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-07-19 14:55:40 -0400 (Tue, 19 Jul 2011)
New Revision: 33049
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
Log:
https://issues.jboss.org/browse/JBIDE-9307
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2011-07-19 18:22:58 UTC (rev 33048)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2011-07-19 18:55:40 UTC (rev 33049)
@@ -563,49 +563,47 @@
private void fillElReferencesForNode(IDocument document, IDOMNode node, XmlContextImpl context) {
if(Node.ELEMENT_NODE == node.getNodeType() || Node.TEXT_NODE == node.getNodeType()) {
IStructuredDocumentRegion regionNode = node.getFirstStructuredDocumentRegion();
- while (regionNode != null){
- //return;
- ITextRegionList regions = regionNode.getRegions();
- for(int i=0; i<regions.size(); i++) {
- ITextRegion region = regions.get(i);
- if(region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE || region.getType() == DOMRegionContext.XML_CONTENT) {
- String text = regionNode.getFullText(region);
- if(text.indexOf("{")>-1) { //$NON-NLS-1$
- int offset = regionNode.getStartOffset() + region.getStart();
- int startEl = text.indexOf("#{"); //$NON-NLS-1$
- if(startEl==-1) {
- startEl = text.indexOf("${"); //$NON-NLS-1$
- }
- if(startEl>-1) {
- ELParser parser = ELParserUtil.getJbossFactory().createParser();
- ELModel model = parser.parse(text);
- List<ELInstance> is = model.getInstances();
-
- ELReference elReference = new KbELReference();
- elReference.setResource(context.getResource());
- elReference.setEl(is);
- elReference.setLength(text.length());
- elReference.setStartPosition(offset);
- try {
- if(Node.TEXT_NODE == node.getNodeType()) {
- if(is.size()==1) {
- elReference.setLineNumber(document.getLineOfOffset(elReference.getStartPossitionOfFirstEL()) + 1);
- }
- } else {
- elReference.setLineNumber(document.getLineOfOffset(offset) + 1);
+ if (regionNode == null)
+ return;
+ ITextRegionList regions = regionNode.getRegions();
+ for(int i=0; i<regions.size(); i++) {
+ ITextRegion region = regions.get(i);
+ if(region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE || region.getType() == DOMRegionContext.XML_CONTENT) {
+ String text = regionNode.getFullText(region);
+ if(text.indexOf("{")>-1) { //$NON-NLS-1$
+ int offset = regionNode.getStartOffset() + region.getStart();
+ int startEl = text.indexOf("#{"); //$NON-NLS-1$
+ if(startEl==-1) {
+ startEl = text.indexOf("${"); //$NON-NLS-1$
+ }
+ if(startEl>-1) {
+ ELParser parser = ELParserUtil.getJbossFactory().createParser();
+ ELModel model = parser.parse(text);
+ List<ELInstance> is = model.getInstances();
+
+ ELReference elReference = new KbELReference();
+ elReference.setResource(context.getResource());
+ elReference.setEl(is);
+ elReference.setLength(text.length());
+ elReference.setStartPosition(offset);
+ try {
+ if(Node.TEXT_NODE == node.getNodeType()) {
+ if(is.size()==1) {
+ elReference.setLineNumber(document.getLineOfOffset(elReference.getStartPossitionOfFirstEL()) + 1);
}
- } catch (BadLocationException e) {
- WebKbPlugin.getDefault().logError(e);
+ } else {
+ elReference.setLineNumber(document.getLineOfOffset(offset) + 1);
}
-
- elReference.setSyntaxErrors(model.getSyntaxErrors());
-
- context.addELReference(elReference);
+ } catch (BadLocationException e) {
+ WebKbPlugin.getDefault().logError(e);
}
+
+ elReference.setSyntaxErrors(model.getSyntaxErrors());
+
+ context.addELReference(elReference);
}
}
}
- regionNode = regionNode.getNext();
}
}
}
14 years, 8 months
JBoss Tools SVN: r33048 - in trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test: projects/JSF2CompositeOpenOn/WebContent/WEB-INF and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2011-07-19 14:22:58 -0400 (Tue, 19 Jul 2011)
New Revision: 33048
Added:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2XMLOpenOnTest.java
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSFHyperlinkTestUtil.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/META-INF/MANIFEST.MF
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/WebContent/WEB-INF/faces-config.xml
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2CCAttrsOpenOnTest.java
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2MessagesOpenOnTest.java
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JsfTextExtAllTests.java
Log:
https://issues.jboss.org/browse/JBIDE-9307
Modified: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/META-INF/MANIFEST.MF 2011-07-19 17:41:31 UTC (rev 33047)
+++ trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/META-INF/MANIFEST.MF 2011-07-19 18:22:58 UTC (rev 33048)
@@ -24,7 +24,8 @@
org.jboss.tools.jsf.text.ext.richfaces,
org.jboss.tools.jsf.ui,
org.eclipse.jst.standard.schemas,
- org.jboss.tools.jst.text.ext.test;bundle-version="3.3.0"
+ org.jboss.tools.jst.text.ext.test;bundle-version="3.3.0",
+ org.eclipse.jdt.ui;bundle-version="3.7.0"
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor.0
Export-Package: org.jboss.tools.jsf.text.ext.test
Modified: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/WebContent/WEB-INF/faces-config.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/WebContent/WEB-INF/faces-config.xml 2011-07-19 17:41:31 UTC (rev 33047)
+++ trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/WebContent/WEB-INF/faces-config.xml 2011-07-19 18:22:58 UTC (rev 33048)
@@ -22,6 +22,7 @@
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
<locale-config/>
<resource-bundle>
+ <display-name>#{person.name}</display-name>
<base-name>resources</base-name>
<var>registeredMsgs</var>
</resource-bundle>
Modified: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2CCAttrsOpenOnTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2CCAttrsOpenOnTest.java 2011-07-19 17:41:31 UTC (rev 33047)
+++ trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2CCAttrsOpenOnTest.java 2011-07-19 18:22:58 UTC (rev 33048)
@@ -17,11 +17,10 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.jsf.text.ext.test.JSFHyperlinkTestUtil.TestRegion;
+import org.jboss.tools.jsf.text.ext.test.JSFHyperlinkTestUtil.TestHyperlink;
import org.jboss.tools.jst.text.ext.hyperlink.ELHyperlink;
import org.jboss.tools.jst.text.ext.hyperlink.ELHyperlinkDetector;
-import org.jboss.tools.jst.text.ext.test.HyperlinkTestUtil;
-import org.jboss.tools.jst.text.ext.test.HyperlinkTestUtil.TestHyperlink;
-import org.jboss.tools.jst.text.ext.test.HyperlinkTestUtil.TestRegion;
import org.jboss.tools.test.util.JobUtils;
/**
@@ -62,7 +61,7 @@
regionList.add(new TestRegion(786, 7, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open a Custom Component Attribute definition")}));
regionList.add(new TestRegion(795, 10, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open a Custom Component Attribute definition")}));
- HyperlinkTestUtil.checkRegions(project, PAGE_NAME, regionList, new ELHyperlinkDetector());
+ JSFHyperlinkTestUtil.checkRegions(project, PAGE_NAME, regionList, new ELHyperlinkDetector());
}
@@ -81,7 +80,7 @@
regionList.add(new TestRegion(738, 7, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open a Custom Component Attribute definition")}));
regionList.add(new TestRegion(747, 10, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open a Custom Component Attribute definition")}));
- HyperlinkTestUtil.checkRegions(project, PAGE2_NAME, regionList, new ELHyperlinkDetector());
+ JSFHyperlinkTestUtil.checkRegions(project, PAGE2_NAME, regionList, new ELHyperlinkDetector());
}
Modified: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2MessagesOpenOnTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2MessagesOpenOnTest.java 2011-07-19 17:41:31 UTC (rev 33047)
+++ trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2MessagesOpenOnTest.java 2011-07-19 18:22:58 UTC (rev 33048)
@@ -19,9 +19,8 @@
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.jst.text.ext.hyperlink.ELHyperlink;
import org.jboss.tools.jst.text.ext.hyperlink.ELHyperlinkDetector;
-import org.jboss.tools.jst.text.ext.test.HyperlinkTestUtil;
-import org.jboss.tools.jst.text.ext.test.HyperlinkTestUtil.TestHyperlink;
-import org.jboss.tools.jst.text.ext.test.HyperlinkTestUtil.TestRegion;
+import org.jboss.tools.jsf.text.ext.test.JSFHyperlinkTestUtil.TestHyperlink;
+import org.jboss.tools.jsf.text.ext.test.JSFHyperlinkTestUtil.TestRegion;
import org.jboss.tools.test.util.JobUtils;
/**
@@ -65,7 +64,7 @@
regionList.add(new TestRegion(1125, 7, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'resources'", "resources.properties")}));
regionList.add(new TestRegion(1134, 25, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'demo.long.named.property' of bundle 'resources'", "resources.properties")}));
- HyperlinkTestUtil.checkRegions(project, PAGE_NAME, regionList, new ELHyperlinkDetector());
+ JSFHyperlinkTestUtil.checkRegions(project, PAGE_NAME, regionList, new ELHyperlinkDetector());
}
Added: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2XMLOpenOnTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2XMLOpenOnTest.java (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2XMLOpenOnTest.java 2011-07-19 18:22:58 UTC (rev 33048)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.text.ext.test;
+
+import java.util.ArrayList;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.jst.text.ext.hyperlink.ELHyperlink;
+import org.jboss.tools.jst.text.ext.hyperlink.ELHyperlinkDetector;
+import org.jboss.tools.jsf.text.ext.test.JSFHyperlinkTestUtil.TestHyperlink;
+import org.jboss.tools.jsf.text.ext.test.JSFHyperlinkTestUtil.TestRegion;
+import org.jboss.tools.test.util.JobUtils;
+
+public class JSF2XMLOpenOnTest extends TestCase {
+ private static final String PROJECT_NAME = "JSF2CompositeOpenOn";
+ private static final String PAGE_NAME = "/WebContent/WEB-INF/faces-config.xml";
+
+ public IProject project = null;
+
+ protected void setUp() {
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ PROJECT_NAME);
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
+ JobUtils.waitForIdle();
+ }
+
+ protected void tearDown() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
+ }
+
+ public JSF2XMLOpenOnTest() {
+ super("JSF2 OpenOn on messages test");
+ }
+
+ public void testELHyperlink() throws Exception{
+
+ ArrayList<TestRegion> regionList = new ArrayList<TestRegion>();
+ regionList.add(new TestRegion(992, 5, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'Person - demo'", "Person.java")}));
+ regionList.add(new TestRegion(999, 3, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'Person.getName() - demo'", "Person.java")}));
+
+ JSFHyperlinkTestUtil.checkRegions(project, PAGE_NAME, regionList, new ELHyperlinkDetector());
+
+ }
+
+}
+
Property changes on: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2XMLOpenOnTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSFHyperlinkTestUtil.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSFHyperlinkTestUtil.java (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSFHyperlinkTestUtil.java 2011-07-19 18:22:58 UTC (rev 33048)
@@ -0,0 +1,331 @@
+package org.jboss.tools.jsf.text.ext.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
+import org.eclipse.jdt.internal.ui.text.JavaWordFinder;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.DocumentProviderRegistry;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.jboss.tools.common.model.ui.editor.EditorPartWrapper;
+import org.jboss.tools.common.model.ui.texteditors.XMLTextEditorStandAlone;
+import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import org.jboss.tools.common.text.ext.util.AxisUtil;
+import org.jboss.tools.jsf.ui.editor.FacesConfigEditor;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.jst.web.ui.editors.WebCompoundEditor;
+import org.jboss.tools.common.model.ui.texteditors.XMLTextEditorComponent;
+
+public class JSFHyperlinkTestUtil extends TestCase{
+
+ public static void checkRegions(IProject project, String fileName, List<TestRegion> regionList, AbstractHyperlinkDetector elDetector) throws Exception {
+ IFile file = project.getFile(fileName);
+
+ assertNotNull("The file \"" + fileName + "\" is not found", file);
+ assertTrue("The file \"" + fileName + "\" is not found", file.isAccessible());
+
+ FileEditorInput editorInput = new FileEditorInput(file);
+
+ IDocumentProvider documentProvider = null;
+ try {
+ documentProvider = DocumentProviderRegistry.getDefault().getDocumentProvider(editorInput);
+ } catch (Exception x) {
+ x.printStackTrace();
+ fail("An exception caught: " + x.getMessage());
+ }
+
+ assertNotNull("The document provider for the file \"" + fileName + "\" is not loaded", documentProvider);
+
+ try {
+ documentProvider.connect(editorInput);
+ } catch (Exception x) {
+ x.printStackTrace();
+ fail("The document provider is not able to be initialized with the editor input\nAn exception caught: "+x.getMessage());
+ }
+
+ IDocument document = documentProvider.getDocument(editorInput);
+
+ assertNotNull("The document for the file \"" + fileName + "\" is not loaded", document);
+
+ int expected = 0;
+ for(TestRegion testRegion : regionList)
+ expected += testRegion.region.getLength()+1;
+
+ IEditorPart part = openFileInEditor(file);
+ ISourceViewer viewer = null;
+ if(part instanceof JavaEditor){
+ viewer = ((JavaEditor)part).getViewer();
+ elDetector.setContext(new TestContext((ITextEditor)part));
+ }else if(part instanceof EditorPartWrapper){
+ if(((EditorPartWrapper)part).getEditor() instanceof WebCompoundEditor){
+ WebCompoundEditor wce = (WebCompoundEditor)((EditorPartWrapper)part).getEditor();
+ viewer = wce.getSourceEditor().getTextViewer();
+ elDetector.setContext(new TestContext(wce.getSourceEditor()));
+ }else if(((EditorPartWrapper)part).getEditor() instanceof XMLTextEditorStandAlone){
+ XMLTextEditorStandAlone xtesa = (XMLTextEditorStandAlone)((EditorPartWrapper)part).getEditor();
+ viewer = xtesa.getTextViewer();
+ elDetector.setContext(new TestContext(xtesa));
+ }else if(((EditorPartWrapper)part).getEditor() instanceof FacesConfigEditor){
+ FacesConfigEditor fce = (FacesConfigEditor)((EditorPartWrapper)part).getEditor();
+ fce.selectPageByName("Source");
+ viewer = ((XMLTextEditorComponent)fce.getActiveEditor()).getTextViewer();
+ elDetector.setContext(new TestContext((XMLTextEditorComponent)fce.getActiveEditor()));
+ }else fail("unsupported editor type - "+((EditorPartWrapper)part).getEditor().getClass());
+ }else if(part instanceof JSPMultiPageEditor){
+ viewer = ((JSPMultiPageEditor)part).getJspEditor().getTextViewer();
+ elDetector.setContext(new TestContext(((JSPMultiPageEditor)part).getJspEditor()));
+ }else if(part instanceof FacesConfigEditor){
+ viewer = ((FacesConfigEditor)part).getSourceEditor().getTextViewer();
+ elDetector.setContext(new TestContext(((FacesConfigEditor)part).getSourceEditor()));
+ }else fail("unsupported editor type - "+part.getClass());
+
+ int counter = 0;
+ for (int i = 0; i < document.getLength(); i++) {
+ TestData testData = new TestData(document, i);
+ IHyperlink[] links = elDetector.detectHyperlinks(viewer, testData.getHyperlinkRegion(), true);
+
+ boolean recognized = links != null;
+// if(recognized)
+// System.out.println("Recognized - "+i);
+
+ if (recognized) {
+ counter++;
+ TestRegion testRegion = findOffsetInRegions(i, regionList);
+ if(testRegion == null){
+ fail("Wrong detection for offset - "+i);
+ }else{
+ checkTestRegion(links, testRegion);
+ }
+ }
+ else {
+ for(TestRegion testRegion : regionList){
+ if(i >= testRegion.region.getOffset() && i <= testRegion.region.getOffset()+testRegion.region.getLength()) {
+ int line = document.getLineOfOffset(testRegion.region.getOffset());
+ fail("Wrong detection for region - "+testRegion.region.getOffset()+" : "+testRegion.region.getLength()+" region - "+i);
+ }
+ }
+ }
+ }
+
+ assertEquals("Wrong recognized region count: ", expected, counter);
+
+ documentProvider.disconnect(editorInput);
+ }
+
+ private static void checkTestRegion(IHyperlink[] links, TestRegion testRegion){
+ for(IHyperlink link : links){
+ TestHyperlink testLink = findTestHyperlink(testRegion.hyperlinks, link);
+ assertNotNull("Unexpected hyperlink - "+link.getHyperlinkText(), testLink);
+ assertEquals("Unexpected hyperlink type", testLink.hyperlink, link.getClass());
+ if(testLink.fileName != null){
+ assertTrue("HyperLink must be inherited from AbstractHyperlink", link instanceof AbstractHyperlink);
+
+ IFile f = ((AbstractHyperlink)link).getReadyToOpenFile();
+ assertNotNull("HyperLink must return not null file", f);
+ assertEquals(testLink.fileName, f.getName());
+
+ }
+ }
+
+ for(TestHyperlink testLink : testRegion.hyperlinks){
+ IHyperlink link = findHyperlink(links, testLink);
+ assertNotNull("Hyperlink - "+testLink.name+" not found", link);
+ }
+ }
+
+ private static TestHyperlink findTestHyperlink(List<TestHyperlink> testHyperlinks, IHyperlink link){
+ for(TestHyperlink testLink : testHyperlinks){
+ if(testLink.name.equals(link.getHyperlinkText()))
+ return testLink;
+ }
+ return null;
+ }
+
+ private static IHyperlink findHyperlink(IHyperlink[] links, TestHyperlink testLink){
+ for(IHyperlink link : links){
+ if(testLink.name.equals(link.getHyperlinkText()))
+ return link;
+ }
+ return null;
+ }
+
+ private static TestRegion findOffsetInRegions(int offset, List<TestRegion> regionList){
+ for(TestRegion testRegion : regionList){
+ if(offset >= testRegion.region.getOffset() && offset <= testRegion.region.getOffset()+testRegion.region.getLength())
+ return testRegion;
+ }
+ return null;
+ }
+
+ public static IEditorPart openFileInEditor(IFile input) {
+ return openFileInEditor(input, null);
+ }
+
+ public static IEditorPart openFileInEditor(IFile input, String id) {
+ if (input != null && input.exists()) {
+ try {
+ if(id==null) {
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ return IDE.openEditor(page, input, true);
+ } else {
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ return IDE.openEditor(page, input, id, true);
+ }
+ } catch (PartInitException pie) {
+ pie.printStackTrace();
+ fail(pie.getMessage());
+ }
+ }
+ return null;
+ }
+
+ static class TestData {
+ IDocument document;
+ int offset;
+ IRegion region;
+ String contentType;
+ private IHyperlinkRegion hyperlinkRegion = null;
+
+ TestData (IDocument document, int offset) {
+ this.document = document;
+ this.offset = offset;
+ init();
+ }
+
+ private void init() {
+ this.region = getDocumentRegion();
+ this.contentType = getContentType();
+ this.hyperlinkRegion = getHyperlinkRegion();
+ }
+
+ private IRegion getDocumentRegion() {
+ IRegion region = null;
+ try {
+ region = JavaWordFinder.findWord(document, offset);
+ } catch (Exception x) {
+ x.printStackTrace();
+ fail(x.getMessage());
+ }
+
+ return region;
+ }
+
+ public IHyperlinkRegion getHyperlinkRegion() {
+ if (hyperlinkRegion != null)
+ return hyperlinkRegion;
+
+ return new IHyperlinkRegion() {
+ public String getAxis() {
+ return AxisUtil.getAxis(document, region.getOffset());
+ }
+ public String getContentType() {
+ return contentType;
+ }
+ public String getType() {
+ return region.toString();
+ }
+ public int getLength() {
+ return region.getLength();
+ }
+ public int getOffset() {
+ return region.getOffset();
+ }
+ public String toString() {
+ return "[" + getOffset() + "-" + (getOffset() + getLength() - 1) + ":" + getType() + ":" + getContentType() + "]";
+ }
+ };
+ }
+
+ /**
+ * Returns the content type of document
+ *
+ * @param document -
+ * assumes document is not null
+ * @return String content type of given document
+ */
+ private String getContentType() {
+ String type = null;
+
+ IModelManager mgr = StructuredModelManager.getModelManager();
+ IStructuredModel model = null;
+ try {
+ model = mgr.getExistingModelForRead(document);
+ if (model != null) {
+ type = model.getContentTypeIdentifier();
+ }
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+ return type;
+ }
+ }
+
+ static class TestContext implements IAdaptable{
+ ITextEditor editor;
+
+ public TestContext(ITextEditor editor){
+ this.editor = editor;
+ }
+
+ public Object getAdapter(Class adapter) {
+ if(adapter.equals(ITextEditor.class))
+ return editor;
+ return null;
+ }
+ }
+
+ public static class TestRegion{
+ Region region;
+ ArrayList<TestHyperlink> hyperlinks = new ArrayList<TestHyperlink>();
+
+ public TestRegion(int offset, int length, TestHyperlink[] testHyperlinks){
+ region = new Region(offset, length);
+ for(TestHyperlink testHyperlink : testHyperlinks){
+ hyperlinks.add(testHyperlink);
+ }
+ }
+ }
+
+ public static class TestHyperlink{
+ Class<? extends IHyperlink> hyperlink;
+ String name;
+ String fileName=null;
+
+ public TestHyperlink(Class<? extends IHyperlink> hyperlink, String name, String fileName){
+ this(hyperlink, name);
+ this.fileName = fileName;
+ }
+
+ public TestHyperlink(Class<? extends IHyperlink> hyperlink, String name){
+ this.hyperlink = hyperlink;
+ this.name = name;
+ }
+
+ }
+}
\ No newline at end of file
Property changes on: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSFHyperlinkTestUtil.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JsfTextExtAllTests.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JsfTextExtAllTests.java 2011-07-19 17:41:31 UTC (rev 33047)
+++ trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JsfTextExtAllTests.java 2011-07-19 18:22:58 UTC (rev 33048)
@@ -41,6 +41,10 @@
"org.jboss.tools.jsf.text.ext.test",
new String[]{"projects/JSF2CompositeOpenOn"},
new String[]{"JSF2CompositeOpenOn"}));
+ suite.addTest(new ProjectImportTestSetup(new TestSuite(JSF2XMLOpenOnTest.class),
+ "org.jboss.tools.jsf.text.ext.test",
+ new String[]{"projects/JSF2CompositeOpenOn"},
+ new String[]{"JSF2CompositeOpenOn"}));
return suite;
}
}
\ No newline at end of file
14 years, 8 months
JBoss Tools SVN: r33047 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-07-19 13:41:31 -0400 (Tue, 19 Jul 2011)
New Revision: 33047
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerUtil.java
Log:
[JBIDE-9369] corrected NPE when using the service instance variable which is not instantiated when using the #getCurrentStateSynchronous (the normal life-cycle start with #beginPolling which initializes all instance variables. if you use #getCurrentStateSynchronous directly these instance vars are not initialized yet!)
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java 2011-07-19 17:00:30 UTC (rev 33046)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java 2011-07-19 17:41:31 UTC (rev 33047)
@@ -22,6 +22,7 @@
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller2;
import org.jboss.ide.eclipse.as.core.server.internal.PollThread;
import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7ManagerUtil.IServiceAware;
/**
* @author André Dietisheim
@@ -131,18 +132,18 @@
return TIMEOUT_BEHAVIOR_FAIL;
}
- public boolean getCurrentStateSynchronous(IServer server) {
- IJBoss7ManagerService service = null;
+ public boolean getCurrentStateSynchronous(final IServer server) {
try {
- service = JBoss7ManagerUtil.getService(server);
- JBoss7ServerState state = service.getServerState(server.getHost(), getManagementPort(server));
- return state == JBoss7ServerState.RUNNING ? IServerStatePoller.SERVER_UP : IServerStatePoller.SERVER_DOWN;
+ JBoss7ManagerUtil.executeWithService(new IServiceAware<Boolean>() {
+
+ @Override
+ public Boolean execute(IJBoss7ManagerService service) throws Exception {
+ JBoss7ServerState state = service.getServerState(server.getHost(), getManagementPort(server));
+ return state == JBoss7ServerState.RUNNING ? IServerStatePoller.SERVER_UP : IServerStatePoller.SERVER_DOWN;
+ }
+ }, server);
} catch(Exception e) {
// ignore
- } finally {
- if (service != null) {
- service.dispose();
- }
}
return IServerStatePoller.SERVER_DOWN;
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerUtil.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerUtil.java 2011-07-19 17:00:30 UTC (rev 33046)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerUtil.java 2011-07-19 17:41:31 UTC (rev 33047)
@@ -13,6 +13,7 @@
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.server.IJBoss7ManagerService;
+import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import org.osgi.framework.BundleContext;
public class JBoss7ManagerUtil {
@@ -39,4 +40,23 @@
service.dispose();
}
}
+
+ public static <RESULT> RESULT executeWithService(IServiceAware<RESULT> serviceAware, IServer server) throws Exception {
+ IJBoss7ManagerService service = null;
+ try {
+ service = JBoss7ManagerUtil.getService(server);
+ return serviceAware.execute(service);
+ } finally {
+ if (service != null) {
+ service.dispose();
+ }
+ }
+ }
+
+ public static interface IServiceAware<RESULT> {
+
+ public RESULT execute(IJBoss7ManagerService service) throws Exception;
+
+ }
+
}
14 years, 8 months
JBoss Tools SVN: r33046 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-07-19 13:00:30 -0400 (Tue, 19 Jul 2011)
New Revision: 33046
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java
Log:
[JBIDE-9369] corrected NPE when using the service instance variable which is not instantiated when using the #getCurrentStateSynchronous (the normal life-cycle start with #beginPolling which initializes all instance variables. if you use #getCurrentStateSynchronous directly these instance vars are not initialized yet!)
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java 2011-07-19 15:39:12 UTC (rev 33045)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java 2011-07-19 17:00:30 UTC (rev 33046)
@@ -140,7 +140,9 @@
} catch(Exception e) {
// ignore
} finally {
- service.dispose();
+ if (service != null) {
+ service.dispose();
+ }
}
return IServerStatePoller.SERVER_DOWN;
}
14 years, 8 months
JBoss Tools SVN: r33045 - trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards.
by jbosstools-commits@lists.jboss.org
Author: jlukas(a)redhat.com
Date: 2011-07-19 11:39:12 -0400 (Tue, 19 Jul 2011)
New Revision: 33045
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WebServiceClientWizard.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WebServiceWizard.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WsWizardBase.java
Log:
another guard tests against lost focus
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WebServiceClientWizard.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WebServiceClientWizard.java 2011-07-19 15:29:06 UTC (rev 33044)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WebServiceClientWizard.java 2011-07-19 15:39:12 UTC (rev 33045)
@@ -28,7 +28,7 @@
}
public WebServiceClientWizard setClientProject(String name) {
- setTargetProject("Client project:", name);
+ setTargetProject("Client project:", name, "Specify Client Project Settings");
return this;
}
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WebServiceWizard.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WebServiceWizard.java 2011-07-19 15:29:06 UTC (rev 33044)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WebServiceWizard.java 2011-07-19 15:39:12 UTC (rev 33045)
@@ -94,5 +94,9 @@
public boolean isClientEnabled() {
return isScaleEnabled(1);
- }
+ }
+
+ private void setTargetProject(String label, String name) {
+ setTargetProject(label, name, "Specify Service Project Settings");
+ }
}
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WsWizardBase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WsWizardBase.java 2011-07-19 15:29:06 UTC (rev 33044)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WsWizardBase.java 2011-07-19 15:39:12 UTC (rev 33045)
@@ -86,11 +86,13 @@
return this;
}
- protected WsWizardBase setTargetProject(String label, String name) {
+ protected WsWizardBase setTargetProject(String label, String name, String shellTitle) {
setFocus();
sleep(100);
findLink(label).get(0).click();
- SWTBotShell sh = bot().activeShell();
+ sleep(100);
+ SWTBotShell sh = bot().shell(shellTitle);
+ sh.setFocus();
SWTBotCombo c = sh.bot().comboBoxWithLabel(label);
String[] items = c.items();
boolean found = false;
14 years, 8 months
JBoss Tools SVN: r33044 - trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2011-07-19 11:29:06 -0400 (Tue, 19 Jul 2011)
New Revision: 33044
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/Flasher.java
Log:
https://issues.jboss.org/browse/JBIDE-7295 : Closing Jboss Tools Jsp Editor causes Eclipse to crash
https://issues.jboss.org/browse/JBIDE-8796 : Revert workaround for JBIDE-7295
- reverted changes
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/Flasher.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/Flasher.java 2011-07-19 15:19:54 UTC (rev 33043)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/Flasher.java 2011-07-19 15:29:06 UTC (rev 33044)
@@ -18,9 +18,6 @@
*/
public class Flasher {
private inIFlasher iFlasher;
- private static final boolean IS_OPEN_JDK = (System.getProperty("java.runtime.name")!=null&&System.getProperty("java.runtime.name").contains("OpenJDK")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- //fix for JBIDE-7957
- private static final boolean IS_LINUX=Platform.OS_LINUX.equals(Platform.getOS());
// added by Maksim Areshkau as element for which we
// have drowed border. When we draw new border,
// we should remove old one;
@@ -34,9 +31,7 @@
XPCOM.IN_FLASHER_CONTRACTID, inIFlasher.INIFLASHER_IID);
iFlasher.setThickness(2);
//fix for JBIDE-7295, added by Maksim Areshkau
- if (Platform.OS_MACOSX.equals(Platform.getOS())
- ||IS_OPEN_JDK
- ||IS_LINUX) {
+ if (Platform.OS_MACOSX.equals(Platform.getOS())) {
drawOutline = new DrawOutlineInterface() {
private List<FlasherData> previouslyBorderedElements = null;
public void drawElementOutline(List<FlasherData> flasherData) {
14 years, 8 months
JBoss Tools SVN: r33043 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-07-19 11:19:54 -0400 (Tue, 19 Jul 2011)
New Revision: 33043
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java
Log:
[JBIDE-9369] corrected NPE when using the service instance variable which is not instantiated when using the #getCurrentStateSynchronous (the normal life-cycle start with #beginPolling which initializes all instance variables. if you use #getCurrentStateSynchronous directly these instance vars are not initialized yet!)
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java 2011-07-19 13:58:24 UTC (rev 33042)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java 2011-07-19 15:19:54 UTC (rev 33043)
@@ -56,10 +56,10 @@
return server;
}
- private int getManagementPort() {
- JBoss7Server server = (JBoss7Server)getServer().loadAdapter(JBoss7Server.class, new NullProgressMonitor());
+ private int getManagementPort(IServer server) {
+ JBoss7Server jbossServer = (JBoss7Server) server.loadAdapter(JBoss7Server.class, new NullProgressMonitor());
if( server != null )
- return server.getManagementPort();
+ return jbossServer.getManagementPort();
// TODO: provide this default in a single place (currently it is spread across the
// behavior and this poller). This port is already offered as constant in AS7Manager#MGMT_PORT
return 9999;
@@ -81,7 +81,7 @@
try {
JBoss7ServerState serverState = null;
do {
- serverState = service.getServerState(getServer().getHost(), getManagementPort());
+ serverState = service.getServerState(getServer().getHost(), getManagementPort(getServer()));
} while (serverState == JBoss7ServerState.STARTING);
return serverState == JBoss7ServerState.RUNNING;
} catch (Exception e) {
@@ -93,7 +93,7 @@
try {
JBoss7ServerState serverState = null;
do {
- serverState = service.getServerState(getServer().getHost(), getManagementPort());
+ serverState = service.getServerState(getServer().getHost(), getManagementPort(getServer()));
} while (serverState == JBoss7ServerState.RUNNING);
return false;
} catch (JBoss7ManangerConnectException e) {
@@ -105,7 +105,7 @@
public boolean getState() throws PollingException, RequiresInfoException {
try {
- JBoss7ServerState serverState = service.getServerState(getServer().getHost(), getManagementPort());
+ JBoss7ServerState serverState = service.getServerState(getServer().getHost(), getManagementPort(getServer()));
return serverState == JBoss7ServerState.RUNNING
|| serverState == JBoss7ServerState.RESTART_REQUIRED;
} catch (Exception e) {
@@ -132,10 +132,15 @@
}
public boolean getCurrentStateSynchronous(IServer server) {
+ IJBoss7ManagerService service = null;
try {
- JBoss7ServerState state = service.getServerState(getServer().getHost(), getManagementPort());
+ service = JBoss7ManagerUtil.getService(server);
+ JBoss7ServerState state = service.getServerState(server.getHost(), getManagementPort(server));
return state == JBoss7ServerState.RUNNING ? IServerStatePoller.SERVER_UP : IServerStatePoller.SERVER_DOWN;
} catch(Exception e) {
+ // ignore
+ } finally {
+ service.dispose();
}
return IServerStatePoller.SERVER_DOWN;
}
14 years, 8 months
JBoss Tools SVN: r33042 - in trunk/as/plugins: org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-07-19 09:58:24 -0400 (Tue, 19 Jul 2011)
New Revision: 33042
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEJBoss7LaunchConfigurator.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerRuntime.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7ServerRuntime.java
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEJBoss7StartLaunchDelegate.java
Log:
[JBIDE-9367] moved launch command building to RSEJBoss7LaunchConfigurator, implemented building the launch command from scratch (was: used the launch settings built by the local launch config and transformed it)
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerRuntime.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerRuntime.java 2011-07-19 12:06:18 UTC (rev 33041)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerRuntime.java 2011-07-19 13:58:24 UTC (rev 33042)
@@ -70,7 +70,9 @@
// for startup
public String getDefaultRunArgs();
+ public String getDefaultRunArgs(IPath serverHome);
public String getDefaultRunVMArgs();
+ public String getDefaultRunVMArgs(IPath serverHome);
public HashMap<String, String> getDefaultRunEnvVars();
public boolean isUsingDefaultJRE();
public boolean isEAP();
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java 2011-07-19 12:06:18 UTC (rev 33041)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java 2011-07-19 13:58:24 UTC (rev 33042)
@@ -121,8 +121,18 @@
}
@Override
+ public String getDefaultRunArgs(IPath serverHome) {
+ return getDefaultRunArgs();
+ }
+
+ @Override
public String getDefaultRunVMArgs() {
- File sysJar = new File(getRuntime().getLocation().toFile(), JBossServerType.AS.getSystemJarPath());
+ return getDefaultRunVMArgs(getRuntime().getLocation());
+ }
+
+ @Override
+ public String getDefaultRunVMArgs(IPath serverHome) {
+ File sysJar = new File(serverHome.toFile(), JBossServerType.AS.getSystemJarPath());
String version = new ServerBeanLoader().getFullServerVersion(sysJar);
String name = getRuntime().getName();
@@ -145,18 +155,18 @@
ret += SYSPROP + SUN_CLIENT_GC_ARG + EQ + 3600000 + SPACE;
ret += SYSPROP + SUN_SERVER_GC_ARG + EQ + 3600000 + SPACE;
ret += QUOTE + SYSPROP + ENDORSED_DIRS + EQ +
- (getRuntime().getLocation().append(LIB).append(ENDORSED)) + QUOTE + SPACE;
- if( getRuntime().getLocation().append(BIN).append(NATIVE).toFile().exists() )
+ (serverHome.append(LIB).append(ENDORSED)) + QUOTE + SPACE;
+ if( serverHome.append(BIN).append(NATIVE).toFile().exists() )
ret += SYSPROP + JAVA_LIB_PATH + EQ + QUOTE +
- getRuntime().getLocation().append(BIN).append(NATIVE) + QUOTE + SPACE;
+ serverHome.append(BIN).append(NATIVE) + QUOTE + SPACE;
if( version.startsWith(IJBossToolingConstants.V6_1)) {
ret += SYSPROP + LOGGING_CONFIG_PROP + EQ + QUOTE + FILE_COLON +
- getRuntime().getLocation().append(BIN).append(LOGGING_PROPERTIES) + QUOTE + SPACE;
+ serverHome.append(BIN).append(LOGGING_PROPERTIES) + QUOTE + SPACE;
}
return ret;
}
-
+
@Override
public HashMap<String, String> getDefaultRunEnvVars(){
HashMap<String, String> envVars = new HashMap<String, String>(1);
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7ServerRuntime.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7ServerRuntime.java 2011-07-19 12:06:18 UTC (rev 33041)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7ServerRuntime.java 2011-07-19 13:58:24 UTC (rev 33042)
@@ -11,7 +11,6 @@
package org.jboss.ide.eclipse.as.core.server.internal.v7;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.jboss.ide.eclipse.as.core.server.internal.LocalJBossServerRuntime;
@@ -19,22 +18,30 @@
public class LocalJBoss7ServerRuntime extends LocalJBossServerRuntime {
@Override
- public void setDefaults(IProgressMonitor monitor) {
- super.setDefaults(monitor);
- }
-
- @Override
public IStatus validate() {
return Status.OK_STATUS;
}
@Override
- public String getDefaultRunArgs() {
- IPath loc = getRuntime().getLocation();
+ public String getDefaultRunArgs(IPath serverHome) {
return "-mp \"" //$NON-NLS-1$
- + loc.append("modules").toString() //$NON-NLS-1$
+ + serverHome.append("modules").toString() //$NON-NLS-1$
+ "\" -logmodule org.jboss.logmanager -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone"; //$NON-NLS-1$
}
+
+ @Override
+ public String getDefaultRunVMArgs(IPath serverHome) {
+ IPath bootLog = serverHome.append("standalone").append("log").append("boot.log"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ IPath logConfig = serverHome.append("standalone").append("configuration").append("logging.properties"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ return "-server -Xms64m -Xmx512m -XX:MaxPermSize=256m " //$NON-NLS-1$
+ + "-Djava.net.preferIPv4Stack=true " //$NON-NLS-1$
+ + "-Dorg.jboss.resolver.warning=true " //$NON-NLS-1$
+ + "-Dsun.rmi.dgc.client.gcInterval=3600000 " //$NON-NLS-1$
+ + "-Dsun.rmi.dgc.server.gcInterval=3600000 " //$NON-NLS-1$
+ + "\"-Dorg.jboss.boot.log.file=" + bootLog.toString() + "\" " //$NON-NLS-1$ //$NON-NLS-2$
+ + "\"-Dlogging.configuration=file:" + logConfig.toString() + "\" " //$NON-NLS-1$ //$NON-NLS-2$
+ + "\"-Djboss.home.dir=" + serverHome.toString() + "\""; //$NON-NLS-1$ //$NON-NLS-2$"
+ }
@Override
public String getDefaultRunVMArgs() {
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEJBoss7LaunchConfigurator.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEJBoss7LaunchConfigurator.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEJBoss7LaunchConfigurator.java 2011-07-19 13:58:24 UTC (rev 33042)
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.ide.eclipse.as.rse.core;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
+import org.jboss.ide.eclipse.as.core.server.internal.launch.configuration.ILaunchConfigConfigurator;
+import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
+import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+
+/**
+ * @author André Dietisheim
+ */
+public class RSEJBoss7LaunchConfigurator implements ILaunchConfigConfigurator {
+
+ private JBossServer jbossServer;
+ private IJBossServerRuntime jbossRuntime;
+
+ public RSEJBoss7LaunchConfigurator(IServer server) throws CoreException {
+ this.jbossServer = ServerConverter.checkedGetJBossServer(server);
+ this.jbossRuntime = jbossServer.getRuntime();
+ }
+
+ @Override
+ public void configure(ILaunchConfigurationWorkingCopy launchConfig) throws CoreException {
+
+ boolean detectStartupCommand = RSELaunchConfigProperties.isDetectStartupCommand(launchConfig, true);
+ String currentStartupCmd = RSELaunchConfigProperties.getStartupCommand(launchConfig);
+ if( detectStartupCommand || !isSet(currentStartupCmd)) {
+ RSELaunchConfigProperties.setStartupCommand(getLaunchCommand(jbossServer, jbossRuntime), launchConfig);
+ }
+ }
+
+ protected String getLaunchCommand(JBossServer jbossServer, IJBossServerRuntime jbossRuntime) throws CoreException {
+ String programArguments = getDefaultProgramArguments(jbossServer, jbossRuntime);
+ String vmArguments = getDefaultVMArguments(jbossServer, jbossRuntime);
+ String jar = getJar(jbossServer, jbossRuntime);
+
+ String command = "java "
+ + vmArguments
+ + " -jar " + jar + " "
+ + IJBossRuntimeConstants.SPACE + programArguments
+ + "&";
+ return command;
+
+ }
+
+ protected String getDefaultVMArguments(JBossServer server, IJBossServerRuntime runtime) {
+ String rseHomeDir = RSEUtils.getRSEHomeDir(server.getServer());
+ return runtime.getDefaultRunVMArgs(new Path(rseHomeDir));
+ }
+
+ protected String getDefaultProgramArguments(JBossServer server, IJBossServerRuntime runtime) {
+ String rseHomeDir = RSEUtils.getRSEHomeDir(server.getServer());
+ return runtime.getDefaultRunArgs(new Path(rseHomeDir));
+ }
+
+ protected String getJar(JBossServer server, IJBossServerRuntime runtime) {
+ String rseHome = RSEUtils.getRSEHomeDir(server.getServer());
+ return new Path(rseHome).append(IJBossRuntimeResourceConstants.JBOSS7_MODULES_JAR).toOSString();
+ }
+
+ protected String getMainType() {
+ return IJBossRuntimeResourceConstants.JBOSS7_MODULES_JAR;
+ }
+
+ private boolean isSet(String value) {
+ return value != null
+ && value.length() > 0;
+ }
+}
Property changes on: trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEJBoss7LaunchConfigurator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEJBoss7StartLaunchDelegate.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEJBoss7StartLaunchDelegate.java 2011-07-19 12:06:18 UTC (rev 33041)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEJBoss7StartLaunchDelegate.java 2011-07-19 13:58:24 UTC (rev 33042)
@@ -13,23 +13,15 @@
package org.jboss.ide.eclipse.as.rse.core;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.server.internal.DelegatingServerBehavior;
-import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.jboss.ide.eclipse.as.core.server.internal.launch.DelegatingStartLaunchConfiguration;
-import org.jboss.ide.eclipse.as.core.server.internal.launch.configuration.JBossLaunchConfigProperties;
-import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
import org.jboss.ide.eclipse.as.core.util.JBossServerBehaviorUtils;
import org.jboss.ide.eclipse.as.core.util.LaunchCommandPreferences;
-import org.jboss.ide.eclipse.as.core.util.LaunchConfigUtils;
-import org.jboss.ide.eclipse.as.core.util.RegExUtils;
-import org.jboss.ide.eclipse.as.core.util.ServerConverter;
-import org.jboss.ide.eclipse.as.core.util.ServerUtil;
public class RSEJBoss7StartLaunchDelegate extends AbstractRSELaunchDelegate {
@@ -61,63 +53,6 @@
@Override
public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IServer server)
throws CoreException {
- new RSELaunchConfigurator(getDefaultLaunchCommand(workingCopy), getDefaultStopCommand(server))
- .configure(workingCopy);
+ new RSEJBoss7LaunchConfigurator(server).configure(workingCopy);
}
-
- private String getDefaultStopCommand(IServer server) {
- try {
- return getDefaultStopCommand(server, false);
- } catch (CoreException ce) {/* ignore, INTENTIONAL */
- }
- return null;
- }
-
- private String getDefaultStopCommand(IServer server, boolean errorOnFail) throws CoreException {
- return null;
- }
-
- private String getDefaultLaunchCommand(ILaunchConfiguration config) throws CoreException {
- /*
- * -server
- * -Xms64m
- * -Xmx512m
- * -XX:MaxPermSize=256m
- * -Djava.net.preferIPv4Stack=true
- * -Dorg.jboss.resolver.warning=true
- * -Dsun.rmi.dgc.client.gcInterval=3600000
- * -Dsun.rmi.dgc.server.gcInterval=3600000
- * -Djboss.modules.system.pkgs=org.jboss.byteman
- * -Dorg.jboss.boot.log.file=/home/adietish/jboss-runtimes/jboss-as-web-7.0.0.Final/standalone/log/boot.log
- * -Dlogging.configuration=file:/home/adietish/jboss-runtimes/jboss-as-web-7.0.0.Final/standalone/configuration/logging.properties
- * -jar /home/adietish/jboss-runtimes/jboss-as-web-7.0.0.Final/jboss-modules.jar
- * -mp /home/adietish/jboss-runtimes/jboss-as-web-7.0.0.Final/modules -logmodule org.jboss.logmanager
- * -jaxpmodule javax.xml.jaxp-provider
- * org.jboss.as.standalone
- * -Djboss.home.dir=/home/adietish/jboss-runtimes/jboss-as-web-7.0.0.Final
- */
-
- String serverId = JBossLaunchConfigProperties.getServerId(config);
- JBossServer jbossServer = ServerConverter.checkedFindJBossServer(serverId);
- String currentArgs = JBossLaunchConfigProperties.getProgramArguments(config);
- String rseArgs = replaceLocalPath(currentArgs, jbossServer);
- String currentVMArgs = JBossLaunchConfigProperties.getVMArguments(config);
- String rseVMArgs = replaceLocalPath(currentVMArgs, jbossServer);
- String jarArg = LaunchConfigUtils.classpathUserClassesToString(config);
- String rseJarArg = replaceLocalPath(jarArg, jbossServer);
-
- String cmd = "java "
- + rseVMArgs
- + " -jar " + rseJarArg + " "
- + IJBossRuntimeConstants.SPACE + rseArgs
- + "&";
- return cmd;
- }
-
- private String replaceLocalPath(String value, JBossServer jbossServer) throws CoreException {
- IPath localHome = ServerUtil.getServerHomePath(jbossServer);
- String localHomeRegex = RegExUtils.escapeRegex(localHome.toOSString());
- String rseHome = RSEUtils.getRSEHomeDir(jbossServer.getServer());
- return value.replaceAll(localHomeRegex, rseHome);
- }
}
14 years, 8 months