JBoss Tools SVN: r40406 - in trunk/ws: plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain and 9 other directories.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-04-23 11:49:16 -0400 (Mon, 23 Apr 2012)
New Revision: 40406
Added:
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/lib/jboss-servlet-api_3.0_spec-1.0.0.Final.jar
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BarResource.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BazResource.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilder.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResource.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaAnnotationsVisitor.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/.classpath
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchTasks.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilderTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationScannerTestCase.java
Log:
Fixed - JBIDE-10886
JAX-RS validation returns false errors when method has multiple pathparams with regexp
https://issues.jboss.org/browse/JBIDE-10886
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilder.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilder.java 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilder.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -76,8 +76,7 @@
}
logBuild(kind, args, project);
switch (kind) {
- case CLEAN_BUILD:
- case FULL_BUILD:
+ case FULL_BUILD: // also called after a CLEAN_BUILD
case AUTO_BUILD:
case INCREMENTAL_BUILD:
build(kind, project, monitor);
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -47,7 +47,7 @@
public class JaxrsMetamodelChangedProcessor {
public List<JaxrsMetamodelDelta> processAffectedMetamodels(List<JaxrsMetamodelDelta> affectedMetamodels,
- IProgressMonitor progressMonitor) {
+ IProgressMonitor progressMonitor) throws CoreException {
for (JaxrsMetamodelDelta affectedMetamodel : affectedMetamodels) {
processAffectedMetamodel(affectedMetamodel, progressMonitor);
}
@@ -62,7 +62,7 @@
* @return the given metamodelDelta completed with affected endpoints.
*/
public JaxrsMetamodelDelta processAffectedMetamodel(final JaxrsMetamodelDelta metamodelDelta,
- IProgressMonitor progressMonitor) {
+ IProgressMonitor progressMonitor) throws CoreException {
final List<JaxrsElementDelta> affectedElements = metamodelDelta.getAffectedElements();
Collections.sort(affectedElements);
try {
@@ -78,8 +78,6 @@
metamodelDelta.addAffectedEndpoint(affectedEndpoints);
}
}
- } catch (CoreException e) {
- Logger.error("Failed to process JAX-RS element changes", e);
} finally {
Logger.debug("Done processing JAX-RS element change(s).");
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -114,21 +114,6 @@
return javaElement != null ? javaElement.getElementName() : "*unknown java element*";
}
- /**
- * Returns the CompilationUnit (AST3/DOM) of the given java element.
- *
- * @param element
- * the java element
- * @param progressMonitor
- * the progress monitor
- * @return the compilation unit or null
- * @throws JavaModelException
- * in case of underlying exception
- */
- final CompilationUnit getCompilationUnit(final IProgressMonitor progressMonitor) throws JavaModelException {
- return JdtUtils.parse(javaElement, progressMonitor);
- }
-
public Map<String, Annotation> getAnnotations() {
return annotations;
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -23,12 +23,10 @@
import java.util.Map.Entry;
import java.util.Set;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
@@ -62,9 +60,6 @@
/** The enclosing JavaProject. */
private final IJavaProject javaProject;
- /** The Service URI. Default is "/" */
- private String serviceUri = "/";
-
/**
* All the subclasses of <code>javax.ws.rs.core.Application</code>, although there should be only one.
*/
@@ -297,26 +292,7 @@
return Collections.unmodifiableList(new ArrayList<IJaxrsResource>(resources));
}
- public final String getServiceUri() {
- return serviceUri;
- }
-
/**
- * Sets the Base URI for the URI mapping templates.
- *
- * @param uri
- * the serviceUri to set
- */
- public final void setServiceUri(final String uri) {
- // remove trailing "*" character, if present.
- if (uri.endsWith("*")) {
- this.serviceUri = uri.substring(0, uri.length() - 1);
- } else {
- this.serviceUri = uri;
- }
- }
-
- /**
* Returns the JAX-RS ElementKind associated with the given java element.
*
* @param element
@@ -338,50 +314,6 @@
}
/**
- * Report errors from the given markers into the JAX-RS element(s) associated with the given compiltation unit.
- *
- * @param compilationUnit
- * the compilation unit
- * @param markers
- * the markers
- * @return true if errors were found and reported, false otherwise
- * @throws JavaModelException
- * in case of underlying exception
- */
- public final boolean reportErrors(final ICompilationUnit compilationUnit, final IMarker[] markers)
- throws JavaModelException {
- boolean hasErrors = false;
- for (IMarker marker : markers) {
- if (marker.getAttribute(IMarker.SEVERITY, 0) != IMarker.SEVERITY_ERROR) {
- continue;
- }
- Logger.debug("Error found: " + marker.getAttribute(IMarker.MESSAGE, ""));
- JaxrsJavaElement<?> element = (JaxrsJavaElement<?>) find(compilationUnit.getElementAt(marker.getAttribute(
- IMarker.CHAR_START, 0)));
- if (element != null) {
- element.hasErrors(true);
- }
- hasErrors = true;
- }
- return hasErrors;
- }
-
- /**
- * Resets this metamodel for further re-use (ie, before a new 'full/clean' build). Keeping the same instance of
- * Metamodel in the project's session properties is a convenient thing, especially on the UI side, where some
- * caching system is use to maintain the state of nodes in the Common Navigator (framework).
- */
- public void reset() {
- Logger.debug("Reseting the JAX-RS Metamodel fpr project {}", this.javaProject.getElementName());
- this.applications.clear();
- this.httpMethods.clear();
- this.providers.clear();
- this.resources.clear();
- this.elementsIndex.clear();
- this.endpoints.clear();
- }
-
- /**
* @param annotation
* (GET, POST, etc..)
* @param metamodel
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResource.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResource.java 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResource.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -122,16 +122,6 @@
return EnumKind.UNDEFINED;
}
- @Override
- public final void hasErrors(final boolean hasErrors) {
- super.hasErrors(hasErrors);
- if (!hasErrors) {
- for (IJaxrsResourceMethod resourceMethod : resourceMethods.values()) {
- resourceMethod.hasErrors(hasErrors);
- }
- }
- }
-
public final String getName() {
return getJavaElement().getElementName();
}
@@ -159,11 +149,6 @@
return null;
}
- public Annotation getConsumesAnnotation() {
- final Annotation consumesAnnotation = getAnnotation(Consumes.class.getName());
- return consumesAnnotation;
- }
-
@Override
public List<String> getProducedMediaTypes() {
final Annotation producesAnnotation = getAnnotation(Produces.class.getName());
@@ -178,10 +163,6 @@
return producesAnnotation;
}
- public final IJaxrsApplication getApplication() {
- return application;
- }
-
@Override
public final List<IJaxrsResourceMethod> getAllMethods() {
return Collections.unmodifiableList(new ArrayList<IJaxrsResourceMethod>(resourceMethods.values()));
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -476,7 +476,7 @@
@Override
public List<String> getPathParamValueProposals() {
- List<String> proposals = new ArrayList<String>();
+ final List<String> proposals = new ArrayList<String>();
final Annotation methodPathAnnotation = getPathAnnotation();
if (methodPathAnnotation != null) {
final String value = methodPathAnnotation.getValue("value");
@@ -506,7 +506,7 @@
while ((beginIndex = value.indexOf("{", beginIndex + 1)) != -1) {
int semicolonIndex = value.indexOf(":", beginIndex);
int closingCurlyBraketIndex = value.indexOf("}", beginIndex);
- int endIndex = semicolonIndex != -1 ? semicolonIndex
+ int endIndex = (semicolonIndex != -1)? Math.min(semicolonIndex, closingCurlyBraketIndex)
: closingCurlyBraketIndex;
params.add(value.substring(beginIndex + 1, endIndex).trim());
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaAnnotationsVisitor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaAnnotationsVisitor.java 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JavaAnnotationsVisitor.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -20,6 +20,7 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.AnnotationTypeDeclaration;
import org.eclipse.jdt.core.dom.FieldDeclaration;
@@ -32,8 +33,7 @@
import org.eclipse.jface.text.TypedRegion;
/**
- * A visitor for a single annotation on a java member (can be a method or a
- * type).
+ * A visitor for a single annotation on a java member (can be a method or a type).
*
* @author xcoulon
*/
@@ -45,6 +45,12 @@
/** the annotated member type. */
private final int memberType;
+ /** the annotated member start position, to distinguish between overloaded methods. */
+ private final int memberStartPosition;
+
+ /** the annotated member end position, to distinguish between overloaded methods. */
+ private final int memberEndPosition;
+
/** the name of the annotation. */
private final List<String> annotationNames = new ArrayList<String>();
@@ -52,8 +58,7 @@
private final List<Annotation> annotations = new ArrayList<Annotation>();
/**
- * Full Constructor to resolve a single annotation from its fully qualified
- * name.
+ * Full Constructor to resolve a single annotation from its fully qualified name.
*
* @param name
* the member name
@@ -61,17 +66,19 @@
* the member type
* @param name
* the annotation name
+ * @throws JavaModelException
*/
- public JavaAnnotationsVisitor(final IMember member, final String annotationName) {
+ public JavaAnnotationsVisitor(final IMember member, final String annotationName) throws JavaModelException {
super();
this.memberName = member.getElementName();
this.memberType = member.getElementType();
+ this.memberStartPosition = member.getSourceRange().getOffset();
+ this.memberEndPosition = member.getSourceRange().getOffset() + member.getSourceRange().getLength();
this.annotationNames.add(annotationName);
}
/**
- * Full Constructor to resolve a multiple annotations from their fully
- * qualified name.
+ * Full Constructor to resolve a multiple annotations from their fully qualified name.
*
* @param name
* the member name
@@ -79,11 +86,14 @@
* the member type
* @param name
* the annotation name
+ * @throws JavaModelException
*/
- public JavaAnnotationsVisitor(final IMember member, final List<String> annotationNames) {
+ public JavaAnnotationsVisitor(final IMember member, final List<String> annotationNames) throws JavaModelException {
super();
this.memberName = member.getElementName();
this.memberType = member.getElementType();
+ this.memberStartPosition = member.getSourceRange().getOffset();
+ this.memberEndPosition = member.getSourceRange().getOffset() + member.getSourceRange().getLength();
this.annotationNames.addAll(annotationNames);
}
@@ -94,7 +104,8 @@
*/
@Override
public final boolean visit(final AnnotationTypeDeclaration node) {
- if (memberType == IJavaElement.TYPE && node.getName().getFullyQualifiedName().equals(memberName)) {
+ if (memberType == IJavaElement.TYPE && node.getName().getFullyQualifiedName().equals(memberName)
+ && matchesLocation(node)) {
visitExtendedModifiers((List<?>) node.getStructuralProperty(AnnotationTypeDeclaration.MODIFIERS2_PROPERTY));
return false;
}
@@ -104,12 +115,12 @@
/**
* {@inheritDoc}
*
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.
- * TypeDeclaration)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom. TypeDeclaration)
*/
@Override
public final boolean visit(final TypeDeclaration node) {
- if (memberType == IJavaElement.TYPE && node.getName().getFullyQualifiedName().equals(memberName)) {
+ if (memberType == IJavaElement.TYPE && node.getName().getFullyQualifiedName().equals(memberName)
+ && matchesLocation(node)) {
visitExtendedModifiers((List<?>) node.getStructuralProperty(TypeDeclaration.MODIFIERS2_PROPERTY));
return false;
}
@@ -119,12 +130,12 @@
/**
* {@inheritDoc}
*
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.
- * MethodDeclaration)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom. MethodDeclaration)
*/
@Override
public final boolean visit(final MethodDeclaration node) {
- if (memberType == IJavaElement.METHOD && node.getName().getFullyQualifiedName().equals(memberName)) {
+ if (memberType == IJavaElement.METHOD && node.getName().getFullyQualifiedName().equals(memberName)
+ && matchesLocation(node)) {
visitExtendedModifiers((List<?>) node.getStructuralProperty(MethodDeclaration.MODIFIERS2_PROPERTY));
return false;
}
@@ -134,14 +145,13 @@
/**
* {@inheritDoc}
*
- * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.
- * MethodDeclaration)
+ * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom. MethodDeclaration)
*/
@Override
public final boolean visit(final FieldDeclaration node) {
if (memberType == IJavaElement.FIELD) {
VariableDeclarationFragment fragment = (VariableDeclarationFragment) (node.fragments().get(0));
- if (fragment.getName().toString().equals(memberName)) {
+ if (fragment.getName().toString().equals(memberName) && matchesLocation(node)) {
visitExtendedModifiers((List<?>) node.getStructuralProperty(FieldDeclaration.MODIFIERS2_PROPERTY));
return false;
}
@@ -150,6 +160,17 @@
}
/**
+ * Checks if the given node matches the expected member location by comparing start and end positions.
+ *
+ * @param node
+ * @return
+ */
+ private boolean matchesLocation(final ASTNode node) {
+ return node.getStartPosition() >= this.memberStartPosition
+ && (node.getStartPosition() + node.getLength()) <= this.memberEndPosition;
+ }
+
+ /**
* Visits the modifiers.
*
* @param modifiers
@@ -179,9 +200,8 @@
}
/**
- * Returns the Annotation element matching the annotation name given in the
- * visitor constructor. This method should only be called when the
- * constructor with a single annotation name was used.
+ * Returns the Annotation element matching the annotation name given in the visitor constructor. This method should
+ * only be called when the constructor with a single annotation name was used.
*
* @return the annotation found on the target java element
* @throws JavaModelException
@@ -196,10 +216,9 @@
}
/**
- * Returns the Annotation elements matching the annotations name given in
- * the visitor constructor. The matching annotations are indexed by their
- * associated Java type's fully qualified names. This method should only be
- * called when the constructor with multiple annotation names was used.
+ * Returns the Annotation elements matching the annotations name given in the visitor constructor. The matching
+ * annotations are indexed by their associated Java type's fully qualified names. This method should only be called
+ * when the constructor with multiple annotation names was used.
*
* @return the annotation found on the target java element
* @throws JavaModelException
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/.classpath
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/.classpath 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/.classpath 2012-04-23 15:49:16 UTC (rev 40406)
@@ -11,6 +11,7 @@
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/persistence-api-1.0.jar"/>
+ <classpathentry kind="lib" path="lib/jboss-servlet-api_3.0_spec-1.0.0.Final.jar"/>
<classpathentry kind="lib" path="lib/jaxrs-api-2.0.1.GA.jar"/>
<classpathentry kind="lib" path="lib/resteasy-jaxrs-2.0.1.GA.jar"/>
<classpathentry kind="lib" path="lib/resteasy-jaxb-provider-2.0.1.GA.jar"/>
Added: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/lib/jboss-servlet-api_3.0_spec-1.0.0.Final.jar
===================================================================
(Binary files differ)
Property changes on: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/lib/jboss-servlet-api_3.0_spec-1.0.0.Final.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BarResource.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BarResource.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BarResource.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -0,0 +1,27 @@
+package org.bytesparadise.pastebin.service;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+@Path("/foo/bar/{param1}")
+public class BarResource {
+
+ @PUT
+ @Path("{param2}")
+ public Response update1(@Context HttpServletRequest requestContext,
+ String bar, @PathParam("{param1}") String param1, @PathParam("{param2}") String param2) throws Exception {
+ return null;
+ }
+
+ @PUT
+ @Path("{param2}")
+ public Response update2(@Context HttpServletRequest requestContext,
+ String bar, @PathParam("{param2}") String param2) throws Exception {
+ return null;
+ }
+
+}
Property changes on: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BarResource.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BazResource.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BazResource.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BazResource.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -0,0 +1,37 @@
+package org.bytesparadise.pastebin.service;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+@Path("/foo/baz")
+public class BazResource {
+
+ @GET
+ @Path("/{id}")
+ public Response getContent(@PathParam("id") int id) {
+ return null;
+ }
+
+ @GET
+ @Path("/user/{id}/{format:(/format/[^/]+?)?}/{encoding:(/encoding/[^/]+?)?}")
+ public Response getContent(@PathParam("id") int id,
+ @PathParam("format") String format,
+ @PathParam("encoding") String encoding,
+ @QueryParam("start") int start) {
+ return null;
+ }
+
+ @GET
+ @Path("/user2/{id}/{format:(/format/[^/]+?)?}/{encoding:(/encoding/[^/]+?)?}")
+ public Response getContent2(@PathParam("id") int id,
+ @PathParam("format") String format,
+ @PathParam("encoding") String encoding,
+ @QueryParam("start") int start) {
+ return null;
+ }
+
+}
Property changes on: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/java/org/jboss/tools/ws/jaxrs/sample/services/BazResource.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchTasks.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchTasks.java 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchTasks.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -172,7 +172,7 @@
throws CoreException, OperationCanceledException, InterruptedException {
project.refreshLocal(IResource.DEPTH_INFINITE, progressMonitor);
project.build(buildKind, progressMonitor);
- Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_BUILD, null);
}
public static IPackageFragmentRoot addClasspathEntry(IJavaProject javaProject, String name,
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -194,9 +194,9 @@
final JavaElementDelta event = createEvent(sourceFolder, ADDED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
// verifications
- // 1 Application + 1 HttpMethod + 3 RootResources + 2 Subresources + all their methods and fields (total of 16)..
- assertThat(impacts.size(), equalTo(23));
- assertThat(metamodel.getElements(javaProject).size(), equalTo(27)); // 4 previous HttpMethods + 23 added items
+ // 1 Application + 1 HttpMethod + 6 RootResources + 2 Subresources + all their methods and fields (total of 16)..
+ assertThat(impacts.size(), equalTo(30));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(34)); // 4 previous HttpMethods + 29 added items
assertThat(impacts, everyItem(Matchers.<JaxrsElementDelta> hasProperty("deltaKind", equalTo(ADDED))));
}
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilderTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilderTestCase.java 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilderTestCase.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -11,8 +11,10 @@
package org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import org.eclipse.core.resources.IncrementalProjectBuilder;
@@ -23,6 +25,7 @@
import org.jboss.tools.ws.jaxrs.core.JBossJaxrsCorePlugin;
import org.jboss.tools.ws.jaxrs.core.WorkbenchTasks;
import org.jboss.tools.ws.jaxrs.core.WorkbenchUtils;
+import org.jboss.tools.ws.jaxrs.core.configuration.ProjectBuilderUtils;
import org.jboss.tools.ws.jaxrs.core.configuration.ProjectNatureUtils;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsMetamodel;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsMetamodel;
@@ -48,7 +51,7 @@
}
@Test
- public void shouldFullBuildProjectWithExistingMetamodel() throws CoreException, OperationCanceledException,
+ public void shouldFullBuildJaxrsProjectWithExistingMetamodel() throws CoreException, OperationCanceledException,
InterruptedException {
// pre-conditions
if (JaxrsMetamodelLocator.get(javaProject) == null) {
@@ -56,16 +59,16 @@
}
assertThat(JaxrsMetamodelLocator.get(javaProject), notNullValue());
// operation
+ WorkbenchTasks.buildProject(project, IncrementalProjectBuilder.CLEAN_BUILD, new NullProgressMonitor());
WorkbenchTasks.buildProject(project, IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
// verification
final IJaxrsMetamodel metamodel = JaxrsMetamodelLocator.get(javaProject);
assertThat(metamodel, notNullValue());
- assertThat(metamodel.getAllEndpoints().size(), equalTo(12));
+ assertThat(metamodel.getAllEndpoints().size(), equalTo(14));
}
@Test
- public void shouldFullBuildProjectWithoutExistingMetamodel() throws CoreException, OperationCanceledException,
+ public void shouldFullBuildJaxrsProjectWithoutExistingMetamodel() throws CoreException, OperationCanceledException,
InterruptedException {
// pre-conditions
if (JaxrsMetamodelLocator.get(javaProject) != null) {
@@ -73,50 +76,49 @@
}
assertThat(JaxrsMetamodelLocator.get(javaProject), nullValue());
// operation
+ WorkbenchTasks.buildProject(project, IncrementalProjectBuilder.CLEAN_BUILD, new NullProgressMonitor());
WorkbenchTasks.buildProject(project, IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
// verification
final IJaxrsMetamodel metamodel = JaxrsMetamodelLocator.get(javaProject);
assertThat(metamodel, notNullValue());
- assertThat(metamodel.getAllEndpoints().size(), equalTo(12));
+ assertThat(metamodel.getAllEndpoints().size(), equalTo(14));
}
@Test
- public void shouldCleanBuildProjectWithExistingMetamodel() throws CoreException, OperationCanceledException,
+ public void shouldNotFullBuildNonJaxrsProject() throws CoreException, OperationCanceledException,
InterruptedException {
// pre-conditions
- if (JaxrsMetamodelLocator.get(javaProject) == null) {
- JaxrsMetamodel.create(javaProject);
+ if (JaxrsMetamodelLocator.get(javaProject) != null) {
+ JaxrsMetamodelLocator.get(javaProject).remove();
}
- assertThat(JaxrsMetamodelLocator.get(javaProject), notNullValue());
+ assertThat(JaxrsMetamodelLocator.get(javaProject), nullValue());
+ ProjectNatureUtils.uninstallProjectNature(project, ProjectNatureUtils.JAXRS_NATURE_ID);
+ assertFalse(ProjectNatureUtils.isProjectNatureInstalled(project, ProjectNatureUtils.JAXRS_NATURE_ID));
// operation
WorkbenchTasks.buildProject(project, IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- project.build(IncrementalProjectBuilder.CLEAN_BUILD, new NullProgressMonitor());
// verification
final IJaxrsMetamodel metamodel = JaxrsMetamodelLocator.get(javaProject);
- assertThat(metamodel, notNullValue());
- assertThat(metamodel.getAllEndpoints().size(), equalTo(12));
+ assertThat(metamodel, nullValue());
}
-
+
@Test
- public void shouldCleanBuildProjectWithoutExistingMetamodel() throws CoreException, OperationCanceledException,
+ public void shouldNotCleanBuildNonJaxrsProject() throws CoreException, OperationCanceledException,
InterruptedException {
// pre-conditions
if (JaxrsMetamodelLocator.get(javaProject) != null) {
JaxrsMetamodelLocator.get(javaProject).remove();
}
assertThat(JaxrsMetamodelLocator.get(javaProject), nullValue());
+ ProjectNatureUtils.uninstallProjectNature(project, ProjectNatureUtils.JAXRS_NATURE_ID);
+ assertFalse(ProjectNatureUtils.isProjectNatureInstalled(project, ProjectNatureUtils.JAXRS_NATURE_ID));
// operation
- WorkbenchTasks.buildProject(project, IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- project.build(IncrementalProjectBuilder.CLEAN_BUILD, new NullProgressMonitor());
- // verification
+ WorkbenchTasks.buildProject(project, IncrementalProjectBuilder.CLEAN_BUILD, new NullProgressMonitor());
final IJaxrsMetamodel metamodel = JaxrsMetamodelLocator.get(javaProject);
- assertThat(metamodel, notNullValue());
- assertThat(metamodel.getAllEndpoints().size(), equalTo(12));
+ assertThat(metamodel, nullValue());
}
@Test
- public void shouldIncrementalBuildProjectAfterResourceCreationWithExistingMetamodel() throws CoreException,
+ public void shouldIncrementalBuildJaxrsProjectAfterResourceCreationWithExistingMetamodel() throws CoreException,
OperationCanceledException, InterruptedException {
// pre-conditions: trigger an initial build to have a delta later (when another build is triggered after the resource creation)
WorkbenchTasks.buildProject(project, IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
@@ -128,12 +130,12 @@
// verification
final IJaxrsMetamodel metamodel = JaxrsMetamodelLocator.get(javaProject);
assertThat(metamodel, notNullValue());
- // 12 usual endpoints + 2 newly created
- assertThat(metamodel.getAllEndpoints().size(), equalTo(14));
+ // 13 usual endpoints + 2 newly created
+ assertThat(metamodel.getAllEndpoints().size(), equalTo(16));
}
@Test
- public void shouldIncrementalBuildProjectAfterResourceCreationWithoutExistingMetamodel() throws CoreException,
+ public void shouldIncrementalBuildJaxrsProjectAfterResourceCreationWithoutExistingMetamodel() throws CoreException,
OperationCanceledException, InterruptedException {
// pre-conditions
if (JaxrsMetamodelLocator.get(javaProject) != null) {
@@ -146,7 +148,9 @@
// verification
final IJaxrsMetamodel metamodel = JaxrsMetamodelLocator.get(javaProject);
assertThat(metamodel, notNullValue());
- // 12 usual endpoints + 2 newly created
- assertThat(metamodel.getAllEndpoints().size(), equalTo(14));
+ // 13 usual endpoints + 2 newly created
+ assertThat(metamodel.getAllEndpoints().size(), equalTo(16));
}
+
+
}
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -135,7 +135,7 @@
}
private List<JaxrsEndpointDelta> processEvent(JaxrsElementDelta affectedElement,
- IProgressMonitor progressMonitor) {
+ IProgressMonitor progressMonitor) throws CoreException {
JaxrsMetamodelDelta affectedMetamodel = new JaxrsMetamodelDelta(metamodel, CHANGED);
affectedMetamodel.add(affectedElement);
delegate.processAffectedMetamodel(affectedMetamodel, progressMonitor);
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -196,11 +196,11 @@
assertThat(affectedMetamodel.getDeltaKind(), equalTo(CHANGED));
assertThat(affectedMetamodel.getMetamodel(), equalTo((IJaxrsMetamodel) metamodel));
final List<JaxrsElementDelta> affectedElements = affectedMetamodel.getAffectedElements();
- // 1 application + 1 HttpMethod + 3 RootResources + 2 Subresources
- assertThat(affectedElements.size(), equalTo(7));
+ // 1 application + 1 HttpMethod + 4 RootResources + 2 Subresources
+ assertThat(affectedElements.size(), equalTo(9));
assertThat(affectedElements, everyItem(Matchers.<JaxrsElementDelta> hasProperty("deltaKind", equalTo(ADDED))));
// all HttpMethods, Resources, ResourceMethods and ResourceFields
- assertThat(metamodel.getElements(javaProject).size(), equalTo(27));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(34));
}
@Test
@@ -222,11 +222,11 @@
metamodel = (JaxrsMetamodel) affectedMetamodel.getMetamodel();
assertThat(metamodel, equalTo((IJaxrsMetamodel) metamodel));
final List<JaxrsElementDelta> affectedElements = affectedMetamodel.getAffectedElements();
- // 1 application + 1 HttpMethod + 3 RootResources + 2 Subresources
- assertThat(affectedElements.size(), equalTo(13));
+ // 1 application + 1 HttpMethod + 4 RootResources + 2 Subresources
+ assertThat(affectedElements.size(), equalTo(15));
assertThat(affectedElements, everyItem(Matchers.<JaxrsElementDelta> hasProperty("deltaKind", equalTo(ADDED))));
// all Applications, HttpMethods (including @OPTIONS and @HEAD), Resources, ResourceMethods and ResourceFields
- assertThat(metamodel.getElements(javaProject).size(), equalTo(30));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(37));
}
/**
@@ -255,9 +255,9 @@
metamodel = (JaxrsMetamodel) affectedMetamodel.getMetamodel();
assertThat(metamodel, notNullValue());
final List<JaxrsElementDelta> affectedElements = affectedMetamodel.getAffectedElements();
- assertThat(affectedElements.size(), equalTo(13));
+ assertThat(affectedElements.size(), equalTo(15));
// all Applications, HttpMethods (including @OPTIONS and @HEAD), project Resources, ResourceMethods and ResourceFields
- assertThat(metamodel.getElements(javaProject).size(), equalTo(30));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(37));
}
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -13,6 +13,7 @@
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getMethod;
@@ -131,7 +132,7 @@
public void shouldAssertResourcesAndMethods() throws CoreException {
// for now, the result excludes the (binary) AsynchronousDispatcher, and
// hence, its (sub)resources
- Assert.assertEquals(5, metamodel.getAllResources().size());
+ Assert.assertEquals(7, metamodel.getAllResources().size());
for (IJaxrsResource jaxrsResource : metamodel.getAllResources()) {
assertThat(((JaxrsResource) jaxrsResource).getJavaElement(), notNullValue());
assertThat(((JaxrsResource) jaxrsResource).getKind(), notNullValue());
@@ -142,7 +143,7 @@
@Test
public void shouldAssertResolvedEndpoints() throws CoreException {
List<IJaxrsEndpoint> endpoints = metamodel.getAllEndpoints();
- Assert.assertEquals("Wrong result", 12, endpoints.size());
+ Assert.assertEquals("Wrong result", 14, endpoints.size());
for (IJaxrsEndpoint endpoint : endpoints) {
Assert.assertFalse("Empty list of resourceMethods", endpoint.getResourceMethods().isEmpty());
Assert.assertNotNull("No URI Path template", endpoint.getUriPathTemplate());
@@ -206,6 +207,17 @@
}
@Test
+ public void shouldRetrieveBarResourceMethodProposals() throws CoreException {
+ IType bazType = getType("org.jboss.tools.ws.jaxrs.sample.services.BazResource", javaProject);
+ IMethod bazMethod = getMethod(bazType, "getContent2");
+ final IJaxrsResourceMethod customerResourceMethod = (IJaxrsResourceMethod) metamodel.getElement(bazMethod);
+ Assert.assertThat(customerResourceMethod, notNullValue());
+ final List<String> pathParamValueProposals = customerResourceMethod.getPathParamValueProposals();
+ Assert.assertThat(pathParamValueProposals, hasSize(3));
+ Assert.assertThat(pathParamValueProposals, containsInAnyOrder("id", "format", "encoding"));
+ }
+
+ @Test
public void shouldSortHttpMethods() {
final List<IJaxrsHttpMethod> httpMethods = new ArrayList<IJaxrsHttpMethod>(metamodel.getAllHttpMethods());
Collections.sort(httpMethods);
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorTestCase.java 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorTestCase.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -61,7 +61,7 @@
}
@Test
- public void shouldValidateResourceMethod() throws CoreException {
+ public void shouldValidateCustomerResourceMethod() throws CoreException {
// preconditions
IType customerJavaType = WorkbenchUtils.getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final JaxrsBaseElement customerResource = metamodel.getElement(customerJavaType);
@@ -72,6 +72,29 @@
}
@Test
+ public void shouldValidateBarResourceMethod() throws CoreException {
+ // preconditions
+ IType barJavaType = WorkbenchUtils.getType("org.jboss.tools.ws.jaxrs.sample.services.BarResource", javaProject);
+ final JaxrsBaseElement barResource = metamodel.getElement(barJavaType);
+ // operation
+ final List<ValidatorMessage> validationMessages = barResource.validate();
+ // validation
+ // 3 errors because of curly brackets + 4 warnings because of missing (correct) parameters
+ assertThat(validationMessages.size(), equalTo(7));
+ }
+
+ @Test
+ public void shouldValidateBazResourceMethod() throws CoreException {
+ // preconditions
+ IType bazJavaType = WorkbenchUtils.getType("org.jboss.tools.ws.jaxrs.sample.services.BazResource", javaProject);
+ final JaxrsBaseElement barResource = metamodel.getElement(bazJavaType);
+ // operation
+ final List<ValidatorMessage> validationMessages = barResource.validate();
+ // validation
+ assertThat(validationMessages.size(), equalTo(0));
+ }
+
+ @Test
public void shouldNotValidateResourceMethod() throws CoreException {
// preconditions
IType customerJavaType = WorkbenchUtils.getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationScannerTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationScannerTestCase.java 2012-04-23 14:51:36 UTC (rev 40405)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationScannerTestCase.java 2012-04-23 15:49:16 UTC (rev 40406)
@@ -24,7 +24,7 @@
// operation
final List<IType> resources = JaxrsAnnotationsScanner.findResourceTypes(javaProject, new NullProgressMonitor());
// verifications
- assertThat(resources.size(), equalTo(5));
+ assertThat(resources.size(), equalTo(7));
}
@Test
@@ -60,7 +60,7 @@
final List<IMethod> resourceMethods = JaxrsAnnotationsScanner.findResourceMethods(javaProject,new ArrayList<IJaxrsHttpMethod>(),
new NullProgressMonitor());
// verifications
- assertThat(resourceMethods.size(), equalTo(9)); // just sub resource methods with @Path annotation
+ assertThat(resourceMethods.size(), equalTo(14)); // just sub resource methods with @Path annotation
}
@Test
13 years, 8 months
JBoss Tools SVN: r40405 - trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views.
by jbosstools-commits@lists.jboss.org
Author: bfitzpat
Date: 2012-04-23 10:51:36 -0400 (Mon, 23 Apr 2012)
New Revision: 40405
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java
Log:
JBIDE-11294 - working around URL issue
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java 2012-04-23 14:31:43 UTC (rev 40404)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java 2012-04-23 14:51:36 UTC (rev 40405)
@@ -1858,7 +1858,12 @@
JBossWSUIPlugin.PLUGIN_ID,
JBossWSUIMessages.JAXRSWSTestView_Exception_Status + innerE.getLocalizedMessage());
status.setResultsText(innerE.toString());
- JBossWSUIPlugin.log(e);
+
+ // this fix is to address JBIDE-11294 and the fact that we shouldn't actually log this exception from deep
+ // within the WS API.
+ if ((!innerE.getLocalizedMessage().contains("Unsupported endpoint address: REPLACE_WITH_ACTUAL_URL"))) { //$NON-NLS-1$
+ JBossWSUIPlugin.log(e);
+ }
return status;
}
}
13 years, 8 months
JBoss Tools SVN: r40404 - trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests.
by jbosstools-commits@lists.jboss.org
Author: ldimaggio
Date: 2012-04-23 10:31:43 -0400 (Mon, 23 Apr 2012)
New Revision: 40404
Modified:
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/Editing.java
Log:
Commented out one check - https://issues.jboss.org/browse/JBQA-5829
Modified: trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/Editing.java
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/Editing.java 2012-04-23 13:58:28 UTC (rev 40403)
+++ trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/Editing.java 2012-04-23 14:31:43 UTC (rev 40404)
@@ -65,10 +65,8 @@
wiz.textWithLabel(ESBESBProject.TEXT_PROJECT_NAME).setText(projectName);
wiz.button(IDELabel.Button.NEXT).click();
wiz.button(IDELabel.Button.NEXT).click();
-
-
- open.finish(wiz);
-
+ wiz.sleep(30000l);
+ open.finish(wiz);
}
@AfterClass
@@ -81,6 +79,7 @@
packageExplorer.show().bot().tree().select(projectName);
SWTBot wiz = open.newObject(ESBESBFile.LABEL);
wiz.textWithLabel(ESBESBFile.TEXT_NAME).setText("another-esb-config");
+ bot.sleep(30000l);
open.finish(wiz);
assertTrue(bot.editorByTitle("another-esb-config.xml") != null);
assertTrue("ESB Editor opened problems",
@@ -98,6 +97,7 @@
try {
log.info("Invoke " + m.getName());
ESBProvider action = (ESBProvider) m.invoke(null, new Object[]{});
+ bot.sleep(60000l);
action.create(getEditor(), actionPath);
providerList.remove(action.getMenuLabel());
bot.sleep(TIME_1S);
@@ -334,13 +334,14 @@
SWTBotText text = new SWTBotText(bot.widget(widgetOfType(Text.class),
section.widget));
text.setFocus();
- text.setText("<>@&");
+
+ text.setText("<>@&");
getEditor().save();
- Assertions.assertXmlContentString(getEditor().toTextEditor().getText(), xpathPath
- + "/property[@name='" + propertyName + "']/" + propertyName
- + "[@name='value']/text()", "<>@&");
- getEditor().save();
+ /* ldimaggi - https://issues.jboss.org/browse/JBQA-5829 */
+// Assertions.assertXmlContentString(getEditor().toTextEditor().getText(), xpathPath
+// + "/property[@name='" + propertyName + "']/" + propertyName
+// + "[@name='value']/text()", "<>@&");
}
13 years, 8 months
JBoss Tools SVN: r40403 - in trunk: maven/site and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: mickael_istria
Date: 2012-04-23 09:58:28 -0400 (Mon, 23 Apr 2012)
New Revision: 40403
Added:
trunk/maven/features/org.jboss.tools.maven.gwt.feature/sourceTemplateFeature/
Modified:
trunk/maven/site/category.xml
trunk/vpe/site/category.xml
Log:
JBIDE-11533
Added source features missing in VPE and Maven sites
Modified: trunk/maven/site/category.xml
===================================================================
--- trunk/maven/site/category.xml 2012-04-23 10:00:50 UTC (rev 40402)
+++ trunk/maven/site/category.xml 2012-04-23 13:58:28 UTC (rev 40403)
@@ -41,6 +41,9 @@
<feature url="features/org.jboss.tools.maven.profiles.feature_0.0.0.jar" id="org.jboss.tools.maven.profiles.feature" version="0.0.0">
<category name="JBoss Tools maven Nightly Build Update Site"/>
</feature>
+ <feature url="features/org.jboss.tools.maven.gwt.feature_0.0.0.jar" id="org.jboss.tools.maven.gwt.feature" version="0.0.0">
+ <category name="JBoss Tools maven Nightly Build Update Site"/>
+ </feature>
<!-- Sources -->
<feature url="features/org.jboss.tools.maven.feature.source_0.0.0.jar" id="org.jboss.tools.maven.feature.source" version="0.0.0">
<category name="JBoss Tools maven Nightly Build Update Site"/>
@@ -78,7 +81,7 @@
<feature url="features/org.jboss.tools.maven.profiles.feature.source_0.0.0.jar" id="org.jboss.tools.maven.profiles.feature.source" version="0.0.0">
<category name="JBoss Tools maven Nightly Build Update Site"/>
</feature>
- <feature url="features/org.jboss.tools.maven.gwt.feature_0.0.0.qualifier.jar" id="org.jboss.tools.maven.gwt.feature" version="0.0.0">
+ <feature url="features/org.jboss.tools.maven.gwt.feature.source_0.0.0.jar" id="org.jboss.tools.maven.gwt.feature.source" version="0.0.0">
<category name="JBoss Tools maven Nightly Build Update Site"/>
</feature>
</site>
Modified: trunk/vpe/site/category.xml
===================================================================
--- trunk/vpe/site/category.xml 2012-04-23 10:00:50 UTC (rev 40402)
+++ trunk/vpe/site/category.xml 2012-04-23 13:58:28 UTC (rev 40403)
@@ -37,5 +37,7 @@
</feature>
<feature url="features/org.jboss.tools.xulrunner.feature_0.0.0.jar" id="org.jboss.tools.xulrunner.feature" version="0.0.0">
</feature>
+ <feature url="features/org.jboss.tools.xulrunner.feature.source_0.0.0.jar" id="org.jboss.tools.xulrunner.feature.source" version="0.0.0">
+ </feature>
</site>
13 years, 8 months
JBoss Tools SVN: r40402 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-04-23 06:00:50 -0400 (Mon, 23 Apr 2012)
New Revision: 40402
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
Log:
[JBIDE-11607] enabled StringToCartridgeConverter again
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-04-23 08:28:27 UTC (rev 40401)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-04-23 10:00:50 UTC (rev 40402)
@@ -115,7 +115,7 @@
private Button uncheckAllButton;
public ApplicationConfigurationWizardPage(IWizard wizard, OpenShiftExpressApplicationWizardModel wizardModel) {
- super("Setup OpenShift Application",
+ super("Setup OpenShift Application",
"Enter a name and select a type for your new OpenShift Express application.",
"Setup OpenShift Application", wizard);
try {
@@ -124,7 +124,7 @@
IStatus status = OpenShiftUIActivator.createErrorStatus(e.getMessage(), e);
OpenShiftUIActivator.log(status);
ErrorDialog.openError(getShell(), "Error", "Error initializing application configuration page", status);
- } catch (SocketTimeoutException e) {
+ } catch (SocketTimeoutException e) {
IStatus status = OpenShiftUIActivator.createErrorStatus(e.getMessage(), e);
OpenShiftUIActivator.log(status);
ErrorDialog.openError(getShell(), "Error", "Error initializing application configuration page", status);
@@ -267,8 +267,11 @@
WidgetProperties.selection().observe(newAppCartridgeCombo);
final IObservableValue selectedCartridgeModelObservable = BeanProperties.value(
ApplicationConfigurationWizardPageModel.PROPERTY_SELECTED_CARTRIDGE).observe(pageModel);
- ValueBindingBuilder.bind(selectedCartridgeComboObservable) // .converting(new StringToCartridgeConverter())
- .to(selectedCartridgeModelObservable).converting(new CartridgeToStringConverter()).in(dbc);
+ ValueBindingBuilder.bind(selectedCartridgeComboObservable)
+ .converting(new StringToCartridgeConverter())
+ .to(selectedCartridgeModelObservable)
+ .converting(new CartridgeToStringConverter())
+ .in(dbc);
final ISWTObservableValue useExistingAppBtnSelection = WidgetProperties.selection().observe(useExistingAppBtn);
final NewApplicationNameValidator newApplicationNameValidator =
@@ -431,7 +434,8 @@
};
}
- private void addJenkinsCartridge(final IEmbeddableCartridge cartridge) throws OpenShiftException, SocketTimeoutException {
+ private void addJenkinsCartridge(final IEmbeddableCartridge cartridge) throws OpenShiftException,
+ SocketTimeoutException {
if (pageModel.hasApplicationOfType(ICartridge.JENKINS_14)) {
pageModel.getSelectedEmbeddedCartridges().add(cartridge);
} else {
@@ -564,20 +568,19 @@
}
}
- /*
- private static final class StringToCartridgeConverter extends Converter {
+ private final class StringToCartridgeConverter extends Converter {
private StringToCartridgeConverter() {
super(String.class, ICartridge.class);
}
@Override
public Object convert(Object fromObject) {
- if (fromObject instanceof String && ((String) fromObject).length() > 0) {
- return new Cartridge(((String) fromObject));
+ if (fromObject instanceof String) {
+ return pageModel.getCartridgeByName((String) fromObject);
}
return null;
}
- }*/
+ }
private static class JenkinsApplicationDialog extends InputDialog {
@@ -779,9 +782,11 @@
return ValidationStatus.error(NLS.bind("The application \"{0}\" does not exist.", appName));
}
} catch (SocketTimeoutException e) {
- return ValidationStatus.error(NLS.bind("The application \"{0}\" existance could not be verified.", appName));
+ return ValidationStatus.error(NLS.bind("The application \"{0}\" existance could not be verified.",
+ appName));
} catch (OpenShiftException e) {
- return ValidationStatus.error(NLS.bind("The application \"{0}\" existance could not be verified.", appName));
+ return ValidationStatus.error(NLS.bind("The application \"{0}\" existance could not be verified.",
+ appName));
}
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-04-23 08:28:27 UTC (rev 40401)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-04-23 10:00:50 UTC (rev 40402)
@@ -193,6 +193,23 @@
public List<ICartridge> getCartridges() {
return cartridges;
}
+
+ public ICartridge getCartridgeByName(String name) {
+ List<ICartridge> cartridges = getCartridges();
+ if (cartridges == null) {
+ return null;
+ }
+
+ ICartridge matchingCartridge = null;
+ for (ICartridge cartridge : cartridges) {
+ if (name.equals(cartridge.getName())) {
+ matchingCartridge = cartridge;
+ break;
+ }
+ }
+
+ return matchingCartridge;
+ }
public ICartridge getSelectedCartridge() {
return wizardModel.getApplicationCartridge();
13 years, 8 months
JBoss Tools SVN: r40401 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-04-23 04:28:27 -0400 (Mon, 23 Apr 2012)
New Revision: 40401
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
Log:
[JBIDE-11604] moved used types IEmbeddedCartridge to IEmbeddableCartridge to fix class-cast exceptions
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-04-23 01:49:52 UTC (rev 40400)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-04-23 08:28:27 UTC (rev 40401)
@@ -91,7 +91,6 @@
import com.openshift.client.IApplication;
import com.openshift.client.ICartridge;
import com.openshift.client.IEmbeddableCartridge;
-import com.openshift.client.IEmbeddedCartridge;
import com.openshift.client.NotFoundOpenShiftException;
import com.openshift.client.OpenShiftException;
@@ -294,7 +293,7 @@
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(1, 2).hint(400, 250)
.applyTo(tableContainer);
this.viewer = createTable(tableContainer);
- dbc.bindSet(ViewerProperties.checkedElements(IEmbeddedCartridge.class).observe(viewer),
+ dbc.bindSet(ViewerProperties.checkedElements(IEmbeddableCartridge.class).observe(viewer),
BeanProperties.set(ApplicationConfigurationWizardPageModel.PROPERTY_SELECTED_EMBEDDED_CARTRIDGES)
.observe(pageModel));
@@ -386,7 +385,7 @@
@Override
public void update(ViewerCell cell) {
- IEmbeddedCartridge cartridge = (IEmbeddedCartridge) cell.getElement();
+ IEmbeddableCartridge cartridge = (IEmbeddableCartridge) cell.getElement();
cell.setText(cartridge.getName());
}
}, viewer, tableLayout);
@@ -407,17 +406,17 @@
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
try {
- IEmbeddedCartridge cartridge = (IEmbeddedCartridge) event.getElement();
+ IEmbeddableCartridge cartridge = (IEmbeddableCartridge) event.getElement();
if (event.getChecked()) {
- if (IEmbeddedCartridge.PHPMYADMIN_34.equals(cartridge)) {
+ if (IEmbeddableCartridge.PHPMYADMIN_34.equals(cartridge)) {
addPhpMyAdminCartridge(cartridge);
- } else if (IEmbeddedCartridge.JENKINS_14.equals(cartridge)) {
+ } else if (IEmbeddableCartridge.JENKINS_14.equals(cartridge)) {
addJenkinsCartridge(cartridge);
} else {
addCartridge(cartridge);
}
} else {
- if (IEmbeddedCartridge.MYSQL_51.equals(cartridge)) {
+ if (IEmbeddableCartridge.MYSQL_51.equals(cartridge)) {
removeMySQLCartridge(cartridge);
} else {
removeCartridge(cartridge);
@@ -472,13 +471,13 @@
}
}
- private void addPhpMyAdminCartridge(IEmbeddedCartridge cartridge) throws OpenShiftException {
- if (!viewer.getChecked(IEmbeddedCartridge.MYSQL_51)) {
+ private void addPhpMyAdminCartridge(IEmbeddableCartridge cartridge) throws OpenShiftException {
+ if (!viewer.getChecked(IEmbeddableCartridge.MYSQL_51)) {
if (MessageDialog.openQuestion(getShell(), "Embed mysql cartridge",
"To embed phpmyadmin, you'd also have to embed mysql.")) {
- pageModel.selectEmbeddedCartridges(IEmbeddedCartridge.MYSQL_51);
+ pageModel.selectEmbeddedCartridges(IEmbeddableCartridge.MYSQL_51);
pageModel.selectEmbeddedCartridges(cartridge);
- viewer.setChecked(IEmbeddedCartridge.MYSQL_51, true);
+ viewer.setChecked(IEmbeddableCartridge.MYSQL_51, true);
} else {
viewer.setChecked(cartridge, false);
}
@@ -487,18 +486,18 @@
}
}
- private void addCartridge(IEmbeddedCartridge cartridge) throws OpenShiftException {
+ private void addCartridge(IEmbeddableCartridge cartridge) throws OpenShiftException {
pageModel.getSelectedEmbeddedCartridges().add(cartridge);
}
- private void removeMySQLCartridge(IEmbeddedCartridge cartridge) throws OpenShiftException {
+ private void removeMySQLCartridge(IEmbeddableCartridge cartridge) throws OpenShiftException {
Set<IEmbeddableCartridge> checkedCartridges = pageModel.getSelectedEmbeddedCartridges();
- if (viewer.getChecked(IEmbeddedCartridge.PHPMYADMIN_34)) {
+ if (viewer.getChecked(IEmbeddableCartridge.PHPMYADMIN_34)) {
if (MessageDialog.openQuestion(getShell(), "Remove phpmyadmin cartridge",
"If you remove the mysql cartridge, you'd also have to remove phpmyadmin.")) {
- checkedCartridges.remove(IEmbeddedCartridge.PHPMYADMIN_34);
+ checkedCartridges.remove(IEmbeddableCartridge.PHPMYADMIN_34);
checkedCartridges.remove(cartridge);
- viewer.setChecked(IEmbeddedCartridge.PHPMYADMIN_34, false);
+ viewer.setChecked(IEmbeddableCartridge.PHPMYADMIN_34, false);
} else {
viewer.setChecked(cartridge, true);
}
@@ -507,7 +506,7 @@
}
}
- private void removeCartridge(IEmbeddedCartridge cartridge) throws OpenShiftException {
+ private void removeCartridge(IEmbeddableCartridge cartridge) throws OpenShiftException {
pageModel.getSelectedEmbeddedCartridges().remove(cartridge);
}
@@ -518,7 +517,7 @@
public void widgetSelected(SelectionEvent e) {
viewer.setAllChecked(true);
try {
- addJenkinsCartridge(IEmbeddedCartridge.JENKINS_14);
+ addJenkinsCartridge(IEmbeddableCartridge.JENKINS_14);
} catch (OpenShiftException ex) {
OpenShiftUIActivator.log("Could not select jenkins cartridge", ex);
} catch (SocketTimeoutException ex) {
13 years, 8 months
JBoss Tools SVN: r40400 - trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples.
by jbosstools-commits@lists.jboss.org
Author: ldimaggio
Date: 2012-04-22 21:49:52 -0400 (Sun, 22 Apr 2012)
New Revision: 40400
Modified:
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/ESBExampleTest.java
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorld.java
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksCSV2XML.java
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksXML2POJO.java
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksXML2XMLDateManipulation.java
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksXML2XMLSimple.java
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/WebServiceConsumer1.java
Log:
ESBExampleTest.java
Added code to ensure that the server console is selected after the client executes
Added code to ensure that console text is returned to the calling test
HelloWorld.java
Added code to explicitly check for ERROR [org.apache.juddi.v3.client.transport.wrapper.RequestHandler] deploy error
WebServiceConsumer1.java
SmooksXML2POJO.java
SmooksXML2XMLSimple.java
SmooksCSV2XML.java
SmooksXML2XMLDateManipulation.java
Added statement to delete project from server after test completes
Modified: trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/ESBExampleTest.java
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/ESBExampleTest.java 2012-04-21 14:39:01 UTC (rev 40399)
+++ trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/ESBExampleTest.java 2012-04-23 01:49:52 UTC (rev 40400)
@@ -82,18 +82,39 @@
* @return string in server log console that was appended or null if nothing appended
*/
protected String executeClientGetServerOutput(String... clientClass) {
- String text = console.getConsoleText();
+ //String text = console.getConsoleText();
SWTBotTreeItem jmsCall = SWTEclipseExt.selectTreeLocation(packageExplorer.show().bot(),clientClass);
eclipse.runTreeItemAsJavaApplication(jmsCall);
bot.sleep(Timing.time5S());
util.waitForNonIgnoredJobs();
- console.switchConsole(configuredState.getServer().name);
+
+ // New - the consoles fail to switch....sometimes
+ boolean consoleSwitched = false;
+ int switchLimit = 30;
+ int switchCounter = 0;
+ consoleSwitched = console.switchConsole(configuredState.getServer().name);
+ while (!consoleSwitched) {
+ consoleSwitched = console.switchConsole(configuredState.getServer().name);
+ bot.sleep(Timing.time10S());
+ log.error("Console did not switch - retrying.");
+ if (switchCounter++ > switchLimit) {
+ break;
+ }
+ }
+ //console.switchConsole(configuredState.getServer().name);
+
//String text2 = console.getConsoleText(TIME_5S, TIME_20S, false);
String text2 = console.getConsoleText(TIME_5S, TIME_60S, false); /* https://issues.jboss.org/browse/JBQA-5838 - ldimaggi */
- if (text.length()>=text2.length()) {
+ log.info("text2=" + text2);
+ console.clearConsole();
+
+ if (text2.length() == 0) {
return null;
}
- return text2.substring(text.length());
+ else {
+ return text2;
+ }
+
}
/**
* executes given class in given project (path must include project name)
Modified: trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorld.java
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorld.java 2012-04-21 14:39:01 UTC (rev 40399)
+++ trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorld.java 2012-04-23 01:49:52 UTC (rev 40400)
@@ -6,6 +6,7 @@
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerType;
import org.junit.AfterClass;
+import org.junit.Test;
@Require(server=(a)Server(type=ServerType.SOA,state=ServerState.Running))
public class HelloWorld extends ESBExampleTest {
@@ -27,10 +28,13 @@
super.executeExample();
String text = executeClientGetServerOutput(getExampleClientProjectName(),"src","org.jboss.soa.esb.samples.quickstart.helloworld.test","SendJMSMessage.java");
assertNotNull("Calling JMS Send message failed, nothing appened to server log",text);
+ assertFalse ("Test fails due to ESB deployment error: NNNN", text.contains("ERROR [org.apache.juddi.v3.client.transport.wrapper.RequestHandler]"));
assertTrue("Calling JMS Send message failed, unexpected server output :"+text,text.contains("Body: Hello World"));
text = null;
+
text = executeClientGetServerOutput(getExampleClientProjectName(),"src","org.jboss.soa.esb.samples.quickstart.helloworld.test","SendEsbMessage.java");
assertNotNull("Calling ESB Send message failed, nothing appened to server log",text);
+ assertFalse ("Test fails due to ESB deployment error: NNNN", text.contains("ERROR [org.apache.juddi.v3.client.transport.wrapper.RequestHandler]"));
assertTrue("Calling ESB Send message failed, unexpected server output :"+text,text.contains("hello world esb"));
SWTTestExt.servers.removeAllProjectsFromServer();
Modified: trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksCSV2XML.java
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksCSV2XML.java 2012-04-21 14:39:01 UTC (rev 40399)
+++ trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksCSV2XML.java 2012-04-23 01:49:52 UTC (rev 40400)
@@ -20,8 +20,8 @@
protected void executeExample() {
super.executeExample();
String text = executeClientGetServerOutput(getExampleClientProjectName(),"src","org.jboss.soa.esb.samples.quickstart.transformcsv2xml","SendJMSMessage.java");
- SWTTestExt.servers.removeAllProjectsFromServer();
assertNotNull("Calling Send message failed, nothing appened to server log",text);
assertTrue("Calling Send message failed, unexpected server output :"+text,text.contains("<csv-set>"));
+ SWTTestExt.servers.removeAllProjectsFromServer();
}
}
Modified: trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksXML2POJO.java
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksXML2POJO.java 2012-04-21 14:39:01 UTC (rev 40399)
+++ trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksXML2POJO.java 2012-04-23 01:49:52 UTC (rev 40400)
@@ -25,7 +25,7 @@
assertNotNull("Calling Send message failed, nothing appened to server log",text);
assertTrue("Calling Send message failed, unexpected server output :"+text,text.contains("Order Items"));
text = executeClient(getExampleClientProjectName(),"src","org.jboss.soa.esb.samples.quickstart.transformxml2pojo.test","ReceiveJMSMessage.java");
+ assertTrue("Calling Send message failed, unexpected server output :"+text,text.contains("Order Items"));
SWTTestExt.servers.removeAllProjectsFromServer();
- assertTrue("Calling Send message failed, unexpected server output :"+text,text.contains("Order Items"));
}
}
Modified: trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksXML2XMLDateManipulation.java
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksXML2XMLDateManipulation.java 2012-04-21 14:39:01 UTC (rev 40399)
+++ trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksXML2XMLDateManipulation.java 2012-04-23 01:49:52 UTC (rev 40400)
@@ -21,8 +21,8 @@
super.executeExample();
String text = executeClientGetServerOutput(getExampleClientProjectName(),"src","org.jboss.soa.esb.samples.quickstart.transformxml2xmldatemanipulation.test","SendJMSMessage.java");
bot.sleep(Timing.time3S());
- SWTTestExt.servers.removeAllProjectsFromServer();
assertNotNull("Calling Send message failed, nothing appened to server log",text);
assertTrue("Calling Send message failed, unexpected server output :"+text,text.contains("OrderDate"));
+ SWTTestExt.servers.removeAllProjectsFromServer();
}
}
Modified: trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksXML2XMLSimple.java
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksXML2XMLSimple.java 2012-04-21 14:39:01 UTC (rev 40399)
+++ trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SmooksXML2XMLSimple.java 2012-04-23 01:49:52 UTC (rev 40400)
@@ -22,8 +22,8 @@
super.executeExample();
String text = executeClientGetServerOutput(getExampleClientProjectName(),"src","org.jboss.soa.esb.samples.quickstart.transformxml2xmlsimple.test","SendJMSMessage.java");
bot.sleep(Timing.time3S());
- SWTTestExt.servers.removeAllProjectsFromServer();
assertNotNull("Calling Send message failed, nothing appened to server log",text);
assertTrue("Calling Send message failed, unexpected server output :"+text,text.contains("<Order"));
+ SWTTestExt.servers.removeAllProjectsFromServer();
}
}
Modified: trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/WebServiceConsumer1.java
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/WebServiceConsumer1.java 2012-04-21 14:39:01 UTC (rev 40399)
+++ trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/WebServiceConsumer1.java 2012-04-23 01:49:52 UTC (rev 40400)
@@ -23,9 +23,8 @@
assertTrue("Calling JMS Send message failed, unexpected server output :"+text,text.contains("Hello World Greeting for"));
text = null;
text = executeClientGetServerOutput(getExampleClientProjectName(),"src","org.jboss.soa.esb.samples.quickstart.webservice_consumer1.test","SendEsbMessage.java");
- SWTTestExt.servers.removeAllProjectsFromServer();
assertNotNull("Calling ESB Send message failed, nothing appened to server log",text);
assertTrue("Calling ESB Send message failed, unexpected server output :"+text,text.contains("Hello World Greeting for"));
-
+ SWTTestExt.servers.removeAllProjectsFromServer();
}
}
13 years, 8 months
JBoss Tools SVN: r40399 - in trunk/modeshape: plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd and 8 other directories.
by jbosstools-commits@lists.jboss.org
Author: elvisisking
Date: 2012-04-21 10:39:01 -0400 (Sat, 21 Apr 2012)
New Revision: 40399
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CommentedCndElement.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/viewers/
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/viewers/CheckBoxLabelProvider.java
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/NamespaceMappingDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/preferences/CndPreferencePage.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ChildNodeDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NamespaceMapping.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NodeTypeDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/PropertyDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndTokenizer.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceStore.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/META-INF/MANIFEST.MF
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiUtils.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinitionTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndTokenizerTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NamespaceMappingTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinitionTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/aircraft.cnd
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/cnd-reader-test-input.cnd
Log:
JBIDE-11586 ModeShape Tools JCR CND Editor Deletes Comments And Vendor Extensions. Modified CndImporter and CndTokenizer so that comments are now parsed. CND Editor now supports one comment for each namespace mapping, node type definition, property definition, and child node definition.
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ChildNodeDefinition.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ChildNodeDefinition.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ChildNodeDefinition.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -15,12 +15,16 @@
import javax.jcr.nodetype.NodeDefinitionTemplate;
import javax.jcr.nodetype.NodeType;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.modeshape.jcr.attributes.AttributeState.Value;
import org.jboss.tools.modeshape.jcr.attributes.DefaultType;
import org.jboss.tools.modeshape.jcr.attributes.NodeAttributes;
import org.jboss.tools.modeshape.jcr.attributes.OnParentVersion;
import org.jboss.tools.modeshape.jcr.attributes.RequiredTypes;
+import org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement;
import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants;
import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
@@ -46,6 +50,9 @@
// name
copy.setName(childNodeBeingCopied.getName());
+ // comment
+ copy.comment = childNodeBeingCopied.comment;
+
// attributes
copy.attributes.getAutocreated().set(childNodeBeingCopied.attributes.getAutocreated().get());
copy.attributes.getMandatory().set(childNodeBeingCopied.attributes.getMandatory().get());
@@ -73,6 +80,11 @@
private final NodeAttributes attributes;
/**
+ * An optional comment (can be <code>null</code> or empty).
+ */
+ private String comment;
+
+ /**
* The node default type (never <code>null</code>).
*/
private final DefaultType defaultType;
@@ -260,7 +272,11 @@
return false;
}
- return this.requiredTypes.equals(that.requiredTypes);
+ if (!this.requiredTypes.equals(that.requiredTypes)) {
+ return false;
+ }
+
+ return Utils.equals(this.comment, that.comment);
}
/**
@@ -280,6 +296,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement#getComment()
+ */
+ @Override
+ public String getComment() {
+ return this.comment;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see javax.jcr.nodetype.ItemDefinition#getDeclaringNodeType()
* @throws UnsupportedOperationException if method is called
*/
@@ -464,7 +490,7 @@
@Override
public int hashCode() {
return Utils.hashCode(this.attributes, this.name, this.defaultType, this.requiredTypes,
- getDeclaringNodeTypeDefinitionName());
+ getDeclaringNodeTypeDefinitionName(), this.comment);
}
/**
@@ -525,7 +551,12 @@
try {
((PropertyChangeListener)listener).propertyChange(event);
} catch (final Exception e) {
- // TODO log this
+ if (Platform.isRunning()) {
+ Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ } else {
+ System.err.print(e.getMessage());
+ }
+
this.listeners.remove(listener);
}
}
@@ -572,6 +603,28 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement#setComment(java.lang.String)
+ */
+ @Override
+ public boolean setComment( String newComment ) {
+ if (!Utils.isEmpty(newComment)) {
+ newComment = newComment.trim();
+ }
+
+ final Object oldValue = this.comment;
+ final boolean changed = !Utils.equivalent(this.comment, newComment);
+
+ if (changed) {
+ this.comment = newComment;
+ notifyChangeListeners(PropertyName.COMMENT, oldValue, newComment);
+ }
+
+ return changed;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see javax.jcr.nodetype.NodeDefinitionTemplate#setDefaultPrimaryTypeName(java.lang.String)
*/
@Override
@@ -691,9 +744,34 @@
*/
@Override
public String toCndNotation( final NotationType notationType ) {
- JcrPreferenceStore prefStore = JcrPreferenceStore.get();
+ final JcrPreferenceStore prefStore = JcrPreferenceStore.get();
+ final StringBuilder builder = new StringBuilder();
+ String indent = Utils.EMPTY_STRING;
- final StringBuilder builder = new StringBuilder(NOTATION_PREFIX);
+ if (NotationType.LONG == notationType) {
+ indent = prefStore.get(JcrPreferenceConstants.CndPreference.ELEMENTS_START_DELIMITER);
+ }
+
+ { // comment
+ if (!Utils.isEmpty(this.comment)) {
+ String commentNotation = Utils.EMPTY_STRING;
+
+ if (NotationType.LONG == notationType) {
+ commentNotation += '\n';
+ }
+
+ commentNotation += CommentedCndElement.Helper.addCommentCharacters(this.comment, indent) + '\n';
+
+ // add comment above node type
+ builder.append(commentNotation);
+
+ if (NotationType.LONG == notationType) {
+ builder.append(indent);
+ }
+ }
+ }
+
+ builder.append(NOTATION_PREFIX);
builder.append((NotationType.LONG == notationType) ? Utils.SPACE_STRING : Utils.EMPTY_STRING);
final String DELIM = prefStore.get(JcrPreferenceConstants.CndPreference.CHILD_NODE_PROPERTY_DELIMITER);
@@ -716,6 +794,11 @@
AUTOCREATED,
/**
+ * The comment.
+ */
+ COMMENT,
+
+ /**
* The default type.
*/
DEFAULT_TYPE,
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemDefinition.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemDefinition.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemDefinition.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -7,12 +7,12 @@
*/
package org.jboss.tools.modeshape.jcr;
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+import org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement;
/**
* An interface for property definitions and child node definitions.
*/
-public interface ItemDefinition extends CndElement, Comparable<ItemDefinition> {
+public interface ItemDefinition extends CommentedCndElement, Comparable<ItemDefinition> {
/**
* Defines a residual set of child items.
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NamespaceMapping.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NamespaceMapping.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NamespaceMapping.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -12,13 +12,14 @@
import java.util.concurrent.CopyOnWriteArrayList;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+import org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement;
/**
* The <code>NamespaceMapping</code> class represents a namespace. Each namespace mapping includes a prefix and a URI.
*/
-public class NamespaceMapping implements CndElement, Comparable {
+public class NamespaceMapping implements CommentedCndElement, Comparable {
/**
* The delimeter used to separate the prefix from the URI.
@@ -40,10 +41,17 @@
* @return a new namespace mapping exactly equal to the one that was copied (never <code>null</code>)
*/
public static NamespaceMapping copy( final NamespaceMapping namespaceMappingToCopy ) {
- return new NamespaceMapping(namespaceMappingToCopy.getPrefix(), namespaceMappingToCopy.getUri());
+ final NamespaceMapping copy = new NamespaceMapping(namespaceMappingToCopy.getPrefix(), namespaceMappingToCopy.getUri());
+ copy.comment = namespaceMappingToCopy.comment;
+ return copy;
}
/**
+ * An optional comment (can be <code>null</code> or empty).
+ */
+ private String comment;
+
+ /**
* The registered property change listeners (never <code>null</code>).
*/
private final CopyOnWriteArrayList<PropertyChangeListener> listeners;
@@ -127,13 +135,26 @@
public boolean equals( final Object obj ) {
if ((obj != null) && getClass().equals(obj.getClass())) {
final NamespaceMapping that = (NamespaceMapping)obj;
- return (this.prefix.equals(that.prefix) && this.uri.equals(that.uri));
+
+ if (this.prefix.equals(that.prefix) && this.uri.equals(that.uri)) {
+ return Utils.equals(this.comment, that.comment);
+ }
}
return false;
}
/**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement#getComment()
+ */
+ @Override
+ public String getComment() {
+ return this.comment;
+ }
+
+ /**
* @return the prefix (can be <code>null</code> or empty)
*/
public String getPrefix() {
@@ -154,7 +175,7 @@
*/
@Override
public int hashCode() {
- return Utils.hashCode(this.prefix, this.uri);
+ return Utils.hashCode(this.prefix, this.uri, this.comment);
}
/**
@@ -173,7 +194,12 @@
try {
((PropertyChangeListener)listener).propertyChange(event);
} catch (final Exception e) {
- Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ if (Platform.isRunning()) {
+ Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ } else {
+ System.err.print(e.getMessage());
+ }
+
this.listeners.remove(listener);
}
}
@@ -189,6 +215,28 @@
}
/**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement#setComment(java.lang.String)
+ */
+ @Override
+ public boolean setComment( String newComment ) {
+ if (!Utils.isEmpty(newComment)) {
+ newComment = newComment.trim();
+ }
+
+ final Object oldValue = this.comment;
+ final boolean changed = !Utils.equivalent(this.comment, newComment);
+
+ if (changed) {
+ this.comment = newComment;
+ notifyChangeListeners(PropertyName.COMMENT, oldValue, newComment);
+ }
+
+ return changed;
+ }
+
+ /**
* @param newPrefix the new prefix value (can be <code>null</code> or empty)
* @return true if the prefix was changed
*/
@@ -226,15 +274,31 @@
@Override
public String toCndNotation( final NotationType notationType ) {
final StringBuilder builder = new StringBuilder();
+
+ // comment
+ if (!Utils.isEmpty(this.comment)) {
+ String commentNotation = Utils.EMPTY_STRING;
+
+ if (NotationType.LONG == notationType) {
+ commentNotation += '\n';
+ }
+
+ commentNotation += CommentedCndElement.Helper.addCommentCharacters(this.comment, null) + '\n';
+
+ // add comment above namespace
+ builder.append(commentNotation);
+ }
+
+ // namespace mapping
builder.append(NOTATION_PREFIX);
builder.append(this.prefix.toCndNotation(notationType));
-
+
if (NotationType.LONG == notationType) {
builder.append(Utils.SPACE_STRING);
}
builder.append(NOTATION_DELIMITER);
-
+
if (NotationType.LONG == notationType) {
builder.append(Utils.SPACE_STRING);
}
@@ -268,6 +332,11 @@
public enum PropertyName {
/**
+ * The comment.
+ */
+ COMMENT,
+
+ /**
* The namespace prefix.
*/
PREFIX,
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NodeTypeDefinition.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NodeTypeDefinition.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NodeTypeDefinition.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -25,13 +25,14 @@
import org.jboss.tools.modeshape.jcr.attributes.NodeTypeAttributes;
import org.jboss.tools.modeshape.jcr.attributes.SuperTypes;
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+import org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement;
import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants;
import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
/**
* Represents a CND node type definition.
*/
-public class NodeTypeDefinition implements CndElement, Comparable, ItemOwnerProvider, NodeTypeTemplate {
+public class NodeTypeDefinition implements CommentedCndElement, Comparable, ItemOwnerProvider, NodeTypeTemplate {
/**
* Then node type name prefix used in the CND notation.
@@ -55,6 +56,9 @@
// name
copy.setName(nodeTypeToCopy.getName());
+ // comment
+ copy.comment = nodeTypeToCopy.comment;
+
// attributes
copy.attributes.setAbstract(nodeTypeToCopy.attributes.getAbstract().get());
copy.attributes.setMixin(nodeTypeToCopy.attributes.getMixin().get());
@@ -94,6 +98,11 @@
private List<CndElement> cndElements;
/**
+ * An optional comment (can be <code>null</code> or empty).
+ */
+ private String comment;
+
+ /**
* The collection of property change listeners (never <code>null</code>).
*/
private final CopyOnWriteArrayList<PropertyChangeListener> listeners;
@@ -313,7 +322,7 @@
}
}
- return true;
+ return Utils.equals(this.comment, that.comment);
}
/**
@@ -338,6 +347,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement#getComment()
+ */
+ @Override
+ public String getComment() {
+ return this.comment;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see javax.jcr.nodetype.NodeTypeDefinition#getDeclaredChildNodeDefinitions()
*/
@Override
@@ -573,7 +592,7 @@
*/
@Override
public int hashCode() {
- final int result1 = Utils.hashCode(this.name, this.attributes, this.superTypes);
+ final int result1 = Utils.hashCode(this.name, this.attributes, this.superTypes, this.comment);
final int result2 = Utils.hashCode(getElements().toArray());
return Utils.hashCode(result1, result2);
}
@@ -739,6 +758,28 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement#setComment(java.lang.String)
+ */
+ @Override
+ public boolean setComment( String newComment ) {
+ if (!Utils.isEmpty(newComment)) {
+ newComment = newComment.trim();
+ }
+
+ final Object oldValue = this.comment;
+ final boolean changed = !Utils.equivalent(this.comment, newComment);
+
+ if (changed) {
+ this.comment = newComment;
+ notifyChangeListeners(PropertyName.COMMENT, oldValue, newComment);
+ }
+
+ return changed;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see javax.jcr.nodetype.NodeTypeTemplate#setDeclaredSuperTypeNames(java.lang.String[])
*/
@Override
@@ -830,6 +871,21 @@
final JcrPreferenceStore prefStore = JcrPreferenceStore.get();
final StringBuilder builder = new StringBuilder();
+ { // comment
+ if (!Utils.isEmpty(this.comment)) {
+ String commentNotation = Utils.EMPTY_STRING;
+
+ if (NotationType.LONG == notationType) {
+ commentNotation += '\n';
+ }
+
+ commentNotation += CommentedCndElement.Helper.addCommentCharacters(this.comment, null) + '\n';
+
+ // add comment above node type
+ builder.append(commentNotation);
+ }
+ }
+
{ // name
builder.append(NAME_NOTATION_PREFIX).append(this.name.toCndNotation(notationType)).append(NAME_NOTATION_SUFFIX);
@@ -897,6 +953,11 @@
CHILD_NODES,
/**
+ * The comment.
+ */
+ COMMENT,
+
+ /**
* The mixin attribute.
*/
MIXIN,
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/PropertyDefinition.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/PropertyDefinition.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/PropertyDefinition.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -16,6 +16,9 @@
import javax.jcr.nodetype.NodeType;
import javax.jcr.nodetype.PropertyDefinitionTemplate;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.modeshape.jcr.attributes.AttributeState;
import org.jboss.tools.modeshape.jcr.attributes.AttributeState.Value;
@@ -26,6 +29,7 @@
import org.jboss.tools.modeshape.jcr.attributes.QueryOperators;
import org.jboss.tools.modeshape.jcr.attributes.QueryOperators.QueryOperator;
import org.jboss.tools.modeshape.jcr.attributes.ValueConstraints;
+import org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement;
import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants;
import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
@@ -56,6 +60,9 @@
// name
copy.setName(propertyBeingCopied.getName());
+ // comment
+ copy.comment = propertyBeingCopied.comment;
+
// attributes
copy.attributes.getAutocreated().set(propertyBeingCopied.attributes.getAutocreated().get());
copy.attributes.getMandatory().set(propertyBeingCopied.attributes.getMandatory().get());
@@ -93,6 +100,11 @@
private final PropertyAttributes attributes;
/**
+ * An optional comment (can be <code>null</code> or empty).
+ */
+ private String comment;
+
+ /**
* The property default values (never <code>null</code>).
*/
private final DefaultValues defaultValues;
@@ -339,7 +351,11 @@
return false;
}
- return this.valueConstraints.equals(that.valueConstraints);
+ if (!this.valueConstraints.equals(that.valueConstraints)) {
+ return false;
+ }
+
+ return Utils.equals(this.comment, that.comment);
}
/**
@@ -369,6 +385,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement#getComment()
+ */
+ @Override
+ public String getComment() {
+ return this.comment;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see javax.jcr.nodetype.ItemDefinition#getDeclaringNodeType()
* @throws UnsupportedOperationException if method is called
*/
@@ -540,7 +566,7 @@
@Override
public int hashCode() {
return Utils.hashCode(this.attributes, this.name, this.defaultValues, this.type, this.valueConstraints,
- getDeclaringNodeTypeDefinitionName());
+ getDeclaringNodeTypeDefinitionName(), this.comment);
}
/**
@@ -635,7 +661,12 @@
try {
((PropertyChangeListener)listener).propertyChange(event);
} catch (final Exception e) {
- // TODO log this
+ if (Platform.isRunning()) {
+ Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ } else {
+ System.err.print(e.getMessage());
+ }
+
this.listeners.remove(listener);
}
}
@@ -724,7 +755,11 @@
changed = true;
}
} catch (final Exception e) {
- // TODO log the invalid query operator
+ if (Platform.isRunning()) {
+ Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ } else {
+ System.err.print(e.getMessage());
+ }
}
}
}
@@ -737,6 +772,28 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement#setComment(java.lang.String)
+ */
+ @Override
+ public boolean setComment( String newComment ) {
+ if (!Utils.isEmpty(newComment)) {
+ newComment = newComment.trim();
+ }
+
+ final Object oldValue = this.comment;
+ final boolean changed = !Utils.equivalent(this.comment, newComment);
+
+ if (changed) {
+ this.comment = newComment;
+ notifyChangeListeners(PropertyName.COMMENT, oldValue, newComment);
+ }
+
+ return changed;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see javax.jcr.nodetype.PropertyDefinitionTemplate#setDefaultValues(javax.jcr.Value[])
*/
@Override
@@ -751,7 +808,11 @@
changed = true;
}
} catch (final Exception e) {
- // TODO log this
+ if (Platform.isRunning()) {
+ Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ } else {
+ System.err.print(e.getMessage());
+ }
}
}
}
@@ -917,8 +978,33 @@
@Override
public String toCndNotation( final NotationType notationType ) {
final JcrPreferenceStore prefStore = JcrPreferenceStore.get();
+ final StringBuilder builder = new StringBuilder();
+ String indent = Utils.EMPTY_STRING;
- final StringBuilder builder = new StringBuilder(NOTATION_PREFIX);
+ if (NotationType.LONG == notationType) {
+ indent = prefStore.get(JcrPreferenceConstants.CndPreference.ELEMENTS_START_DELIMITER);
+ }
+
+ { // comment
+ if (!Utils.isEmpty(this.comment)) {
+ String commentNotation = Utils.EMPTY_STRING;
+
+ if (NotationType.LONG == notationType) {
+ commentNotation += '\n';
+ }
+
+ commentNotation += CommentedCndElement.Helper.addCommentCharacters(this.comment, indent) + '\n';
+
+ // add comment above node type
+ builder.append(commentNotation);
+
+ if (NotationType.LONG == notationType) {
+ builder.append(indent);
+ }
+ }
+ }
+
+ builder.append(NOTATION_PREFIX);
builder.append((NotationType.LONG == notationType) ? Utils.SPACE_STRING : Utils.EMPTY_STRING);
final String DELIM = prefStore.get(JcrPreferenceConstants.CndPreference.PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER);
@@ -943,6 +1029,11 @@
AUTOCREATED,
/**
+ * The comment.
+ */
+ COMMENT,
+
+ /**
* A collection of default values.
*/
DEFAULT_VALUES,
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -14,6 +14,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Stack;
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.modeshape.jcr.ChildNodeDefinition;
@@ -60,21 +61,11 @@
@NotThreadSafe
public final class CndImporter {
- private final boolean jcr170;
+ private final boolean jcr170 = true;
- /**
- * Constructs an importer that is not JCR 170 compatible.
- */
- public CndImporter() {
- this.jcr170 = true;
- }
+ private final Stack<CndElement> cndElements = new Stack<CndElement>();
- /**
- * @param compatibleWithPreJcr2 indicates if the importer should be compatible with pre JCR 2 CND notation
- */
- public CndImporter( final boolean compatibleWithPreJcr2 ) {
- this.jcr170 = compatibleWithPreJcr2;
- }
+ private String currentComment;
/**
* Import the CND content from the supplied stream, placing the content into the importer's destination.
@@ -137,7 +128,10 @@
Utils.verifyIsNotNull(content, "content is null"); //$NON-NLS-1$
final CompactNodeTypeDefinition cnd = new CompactNodeTypeDefinition();
- final Tokenizer tokenizer = new CndTokenizer(false, false);
+
+ // start processing CND
+ push(cnd);
+ final Tokenizer tokenizer = new CndTokenizer();
final TokenStream tokens = new TokenStream(content, tokenizer, false);
tokens.start();
@@ -152,6 +146,8 @@
} else if (tokens.matches(NodeTypeDefinition.NAME_NOTATION_PREFIX, NodeTypeDefinition.NAME_NOTATION_SUFFIX)) {
// empty node type name (no problem recorded here but editor validation will have an error)
parseNodeTypeDefinition(tokens, cnd);
+ } else if (tokens.matches(CndTokenizer.COMMENT)) {
+ parseComment(tokens);
} else {
final Position position = tokens.previousPosition();
final Object[] args = new Object[] { tokens.consume(), position.getLine(), position.getColumn() };
@@ -159,6 +155,9 @@
}
}
+ // finished processing CND
+ final CndElement cndElement = pop();
+ assert (cnd == cndElement) : "CND Element not the expected CND: " + cndElement.toCndNotation(NotationType.LONG); //$NON-NLS-1$
return cnd;
}
@@ -177,6 +176,9 @@
tokens.consume(ChildNodeDefinition.NOTATION_PREFIX);
final ChildNodeDefinition childNodeDefn = new ChildNodeDefinition(nodeTypeDefn);
+ // start processing child node
+ push(childNodeDefn);
+
// name
final String name = parseName(tokens);
@@ -184,19 +186,41 @@
childNodeDefn.setName(name);
}
+ parseComment(tokens); // comment before required types
+
// required types
parseRequiredPrimaryTypes(tokens, childNodeDefn);
+ parseComment(tokens); // comment before default type
+
// default types
parseDefaultType(tokens, childNodeDefn.getDefaultType());
+ parseComment(tokens); // comment before attributes
+
// attributes
parseNodeAttributes(tokens, nodeTypeDefn, childNodeDefn);
// add child node definition
nodeTypeDefn.addChildNodeDefinition(childNodeDefn);
+
+ // finished processing child node
+ final CndElement cndElement = pop();
+ assert (childNodeDefn == cndElement) : "Element not expected child node: " + cndElement.toCndNotation(NotationType.LONG); //$NON-NLS-1$
}
+ private void parseComment( final TokenStream tokens ) {
+ if (tokens.matches(CndTokenizer.COMMENT)) {
+ final String newComment = CommentedCndElement.Helper.removeCommentCharacters(tokens.consume());
+
+ if (Utils.isEmpty(this.currentComment)) {
+ this.currentComment = newComment;
+ } else {
+ this.currentComment += '\n' + newComment;
+ }
+ }
+ }
+
/**
* Parse the child node definition's default type, if they appear next on the token stream.
*
@@ -209,6 +233,9 @@
assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
assert (defaultType != null) : "defaultType is null"; //$NON-NLS-1$
+ // start processing default type
+ push(defaultType);
+
if (tokens.canConsume(DefaultType.NOTATION)) {
if (tokens.canConsume(AttributeState.VARIANT_CHAR)) {
defaultType.set(Value.VARIANT);
@@ -220,6 +247,10 @@
}
}
}
+
+ // finished processing default type
+ final CndElement cndElement = pop();
+ assert (defaultType == cndElement) : "Element not expected default type: " + cndElement.toCndNotation(NotationType.LONG); //$NON-NLS-1$
}
/**
@@ -297,14 +328,25 @@
assert (tokens != null) : "tokens is null"; //$NON-NLS-1$
assert (cnd != null) : "cnd is null"; //$NON-NLS-1$
+ final NamespaceMapping namespaceMapping = new NamespaceMapping();
+
+ // start processing namespace mapping
+ push(namespaceMapping);
+
tokens.consume(NamespaceMapping.NOTATION_PREFIX);
final String prefix = removeQuotes(tokens.consume());
+ namespaceMapping.setPrefix(prefix);
tokens.consume(NamespaceMapping.NOTATION_DELIMITER);
final String uri = removeQuotes(tokens.consume());
+ namespaceMapping.setUri(uri);
tokens.consume(NamespaceMapping.NOTATION_SUFFIX);
- cnd.addNamespaceMapping(new NamespaceMapping(prefix, uri));
+ cnd.addNamespaceMapping(namespaceMapping);
+
+ // finished processing namespace mapping
+ final CndElement cndElement = pop();
+ assert (namespaceMapping == cndElement) : "Element not expected namespace mapping: " + cndElement.toCndNotation(NotationType.LONG); //$NON-NLS-1$
}
/**
@@ -472,6 +514,9 @@
final NodeTypeDefinition nodeType = new NodeTypeDefinition();
+ // start processing node type
+ push(nodeType);
+
// name
final String name = parseNodeTypeName(tokens);
@@ -487,13 +532,22 @@
nodeType.addSuperType(superType);
}
}
+
+ parseComment(tokens); // comment before attributes
+
// Read the node type options (and vendor extensions) ...
parseNodeTypeAttributes(tokens, nodeType);
+ parseComment(tokens); // comment before item definitions
+
// Parse property and child node definitions ...
parsePropertyOrChildNodeDefinitions(tokens, nodeType);
cnd.addNodeTypeDefinition(nodeType);
+
+ // finished processing node type
+ final CndElement cndElement = pop();
+ assert (nodeType == cndElement) : "Element not expected node type: " + cndElement.toCndNotation(NotationType.LONG); //$NON-NLS-1$
}
/**
@@ -621,6 +675,9 @@
tokens.consume(PropertyDefinition.NOTATION_PREFIX);
final PropertyDefinition propDefn = new PropertyDefinition(nodeTypeDefn);
+ // start processing property
+ push(propDefn);
+
// name
final String name = parseName(tokens);
@@ -628,19 +685,31 @@
propDefn.setName(name);
}
+ parseComment(tokens); // comment before type
+
// required type
parsePropertyType(tokens, propDefn);
+ parseComment(tokens); // comment before default values
+
// Parse the default values ...
parseDefaultValues(tokens, propDefn);
+ parseComment(tokens); // comment before attributes
+
// Parse the property attributes (and vendor extensions) ...
parsePropertyAttributes(tokens, nodeTypeDefn, propDefn);
+ parseComment(tokens); // comment before value constraints
+
// Parse the property constraints ...
parseValueConstraints(tokens, propDefn);
nodeTypeDefn.addPropertyDefinition(propDefn);
+
+ // finished processing property
+ final CndElement cndElement = pop();
+ assert (propDefn == cndElement) : "Element not expected property: " + cndElement.toCndNotation(NotationType.LONG); //$NON-NLS-1$
}
/**
@@ -661,6 +730,8 @@
parsePropertyDefinition(tokens, nodeTypeDefn);
} else if (tokens.matches(ChildNodeDefinition.NOTATION_PREFIX)) {
parseChildNodeDefinition(tokens, nodeTypeDefn);
+ } else if (tokens.matches(CndTokenizer.COMMENT)) {
+ parseComment(tokens);
} else {
// The next token does not signal either one of these, so stop ...
break;
@@ -827,6 +898,43 @@
}
}
+ private CndElement pop() {
+ return this.cndElements.pop();
+ }
+
+ private void push( final CndElement cndElement ) {
+ // set comment if one exists
+ if (!Utils.isEmpty(this.currentComment)) {
+ CommentedCndElement commentedElement = null;
+
+ if (cndElement instanceof CommentedCndElement) {
+ commentedElement = (CommentedCndElement)cndElement;
+ } else if (!this.cndElements.isEmpty()) {
+ // this should probably look back in the stack until it finds a CommentedCndElement
+ CndElement top = this.cndElements.peek();
+
+ if (top instanceof CommentedCndElement) {
+ commentedElement = (CommentedCndElement)top;
+ }
+ }
+
+ if (commentedElement != null) {
+ String cndElementComment = commentedElement.getComment();
+
+ if (cndElementComment == null) {
+ cndElementComment = Utils.EMPTY_STRING;
+ } else if (!cndElementComment.endsWith("\n")) { //$NON-NLS-1$
+ cndElementComment += '\n';
+ }
+
+ commentedElement.setComment(cndElementComment + this.currentComment);
+ this.currentComment = null;
+ }
+ }
+
+ this.cndElements.push(cndElement);
+ }
+
private final String removeQuotes( final String text ) {
// Remove leading and trailing quotes, if there are any ...
return text.replaceFirst("^['\"]+", "").replaceAll("['\"]+$", ""); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndTokenizer.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndTokenizer.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndTokenizer.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -35,42 +35,31 @@
/**
* The token type for tokens that consist of an individual '.' character.
*/
- public static final int DECIMAL = 3;
+ public static final int DECIMAL = 4;
/**
* The token type for tokens that consist of all the characters within single-quotes. Single quote characters are included if
* they are preceded (escaped) by a '\' character.
*/
- public static final int SINGLE_QUOTED_STRING = 4;
+ public static final int SINGLE_QUOTED_STRING = 8;
/**
* The token type for tokens that consist of all the characters within double-quotes. Double quote characters are included if
* they are preceded (escaped) by a '\' character.
*/
- public static final int DOUBLE_QUOTED_STRING = 5;
+ public static final int DOUBLE_QUOTED_STRING = 16;
/**
* The token type for tokens that consist of all the characters between "/*" and "*/" or between "//" and the next line
* terminator (e.g., '\n', '\r' or "\r\n").
*/
- public static final int COMMENT = 6;
+ public static final int COMMENT = 32;
/**
* The token type for the token containing a vendor extension block.
*/
- public static final int VENDOR_EXTENSION = 7;
+ public static final int VENDOR_EXTENSION = 64;
- private final boolean useComments = false;
+ private final boolean useComments = true;
private final boolean useVendorExtensions = false;
/**
- * <strong>Currently comments and vendor extensions are not supported by the framework.</strong>
- * @param useComments a flag indicating if comments should be used
- * @param useVendorExtensions a flag indicating if vendor extensions should be used
- */
- public CndTokenizer( boolean useComments,
- boolean useVendorExtensions ) {
-// this.useComments = useComments;
-// this.useVendorExtensions = useVendorExtensions;
- }
-
- /**
* {@inheritDoc}
*
* @see org.modeshape.common.text.TokenStream.Tokenizer#tokenize(CharacterStream, Tokens)
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -17,6 +17,7 @@
import java.util.StringTokenizer;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.modeshape.jcr.Activator;
@@ -741,7 +742,11 @@
}
}
} catch (final Exception e) {
- Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ if (Platform.isRunning()) {
+ Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ } else {
+ System.err.print(e.getMessage());
+ }
}
return status;
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CommentedCndElement.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CommentedCndElement.java (rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CommentedCndElement.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
+ */
+package org.jboss.tools.modeshape.jcr.cnd;
+
+import org.jboss.tools.modeshape.jcr.Utils;
+
+/**
+ * An element found in a CND file that may have an attached comment.
+ */
+public interface CommentedCndElement extends CndElement {
+
+ /**
+ * The characters that end a block comment. Value is {@value} .
+ */
+ String BLOCK_COMMENT_END_CHARS = "*/"; //$NON-NLS-1$
+
+ /**
+ * The characters that begin all lines besides the first and last line of a block comment. Value is {@value} .
+ */
+ String BLOCK_COMMENT_INNER_CHARS = " * "; //$NON-NLS-1$
+
+ /**
+ * The characters that start a block comment. Value is {@value} .
+ */
+ String BLOCK_COMMENT_START_CHARS = "/*"; //$NON-NLS-1$
+
+ /**
+ * The characters that start a line comment. Value is {@value} .
+ */
+ String LINE_COMMENT_CHARS = "//"; //$NON-NLS-1$
+
+ /**
+ * @return the comment associated with this CND element (can be <code>null</code> or empty)
+ */
+ String getComment();
+
+ /**
+ * @param text the comment text (can be <code>null</code> or empty)
+ * @return <code>true</code> if the comment was changed
+ */
+ boolean setComment( String text );
+
+ /**
+ * Utilities related to a commented CND elements.
+ */
+ public class Helper {
+
+ private static String BLOCK_COMMENT_INNER_CHARS2 = "* "; //$NON-NLS-1$
+
+ /**
+ * @param text the text that the comment characters will be added to (cannot be <code>null</code>)
+ * @param indent an optional indent string (can be <code>null</code> or empty)
+ * @return the commented text (never <code>null</code>)
+ */
+ public static String addCommentCharacters( final String text,
+ String indent ) {
+ Utils.verifyIsNotNull(text, "text"); //$NON-NLS-1$
+
+ if (indent == null) {
+ indent = Utils.EMPTY_STRING;
+ }
+
+ final StringBuilder builder = new StringBuilder(indent + BLOCK_COMMENT_START_CHARS);
+
+ if (!text.startsWith("\n")) { //$NON-NLS-1$
+ builder.append('\n');
+ }
+
+ builder.append(indent + BLOCK_COMMENT_INNER_CHARS);
+ builder.append(text.replace("\n", '\n' + indent + BLOCK_COMMENT_INNER_CHARS)); //$NON-NLS-1$
+
+ if (!text.endsWith("\n")) { //$NON-NLS-1$
+ builder.append('\n');
+ }
+
+ builder.append(indent + Utils.SPACE_STRING).append(BLOCK_COMMENT_END_CHARS);
+ return builder.toString();
+ }
+
+ /**
+ * @param comment the comment whose comment characters are being removed (cannot be <code>null</code>)
+ * @return the comment stripped of all comment characters (never <code>null</code>) or the original text if the comment is
+ * not properly formatted
+ */
+ public static String removeCommentCharacters( final String comment ) {
+ Utils.verifyIsNotNull(comment, "comment"); //$NON-NLS-1$
+
+ if (Utils.isEmpty(comment)) {
+ return comment;
+ }
+
+ String result = comment.trim();
+
+ if (result.startsWith(BLOCK_COMMENT_START_CHARS)) {
+ // invalid since no end comment block
+ if (result.length() == BLOCK_COMMENT_START_CHARS.length()) {
+ return comment;
+ }
+
+ // remove start comment chars
+ result = comment.substring(BLOCK_COMMENT_START_CHARS.length());
+ result = result.trim();
+
+ if (result.endsWith(BLOCK_COMMENT_END_CHARS)) {
+ result = result.substring(0, (result.length() - BLOCK_COMMENT_END_CHARS.length()));
+ result = result.trim();
+
+ // empty comment
+ if (result.isEmpty()) {
+ return result;
+ }
+
+ // remove beginning inner comment chars
+ if (result.startsWith(BLOCK_COMMENT_INNER_CHARS)) {
+ result = result.substring(BLOCK_COMMENT_INNER_CHARS.length());
+ result.trim();
+ } else if (result.startsWith(BLOCK_COMMENT_INNER_CHARS2)) {
+ result = result.substring(BLOCK_COMMENT_INNER_CHARS2.length());
+ result.trim();
+ }
+
+ // remove other inner comment chars
+ result = result.replace('\n' + BLOCK_COMMENT_INNER_CHARS, "\n"); //$NON-NLS-1$
+
+ return result.trim();
+ }
+ } else if (comment.startsWith(LINE_COMMENT_CHARS)) {
+ if (comment.length() == LINE_COMMENT_CHARS.length()) {
+ return Utils.EMPTY_STRING;
+ }
+
+ return comment.substring(LINE_COMMENT_CHARS.length()).trim();
+ }
+
+ return comment;
+ }
+ }
+}
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CommentedCndElement.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -16,6 +16,7 @@
import java.util.concurrent.CopyOnWriteArrayList;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.jboss.tools.modeshape.jcr.Activator;
import org.jboss.tools.modeshape.jcr.ChildNodeDefinition;
@@ -296,7 +297,11 @@
try {
matches.addAll(WorkspaceRegistry.get().getMatchingNodeTypeDefinitions(namespacePrefix));
} catch (final Exception e) {
- Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ if (Platform.isRunning()) {
+ Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ } else {
+ System.err.print(e.getMessage());
+ }
}
}
@@ -426,7 +431,12 @@
try {
((PropertyChangeListener)listener).propertyChange(event);
} catch (final Exception e) {
- Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ if (Platform.isRunning()) {
+ Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ } else {
+ System.err.print(e.getMessage());
+ }
+
this.listeners.remove(listener);
}
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceStore.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceStore.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceStore.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -189,7 +189,11 @@
try {
this.prefs.flush();
} catch (final BackingStoreException e) {
- Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ if (Platform.isRunning()) {
+ Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ } else {
+ System.err.print(e.getMessage());
+ }
}
} else {
// test mode
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -33,6 +33,8 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Cursor;
@@ -47,6 +49,7 @@
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.forms.FormDialog;
import org.eclipse.ui.forms.IManagedForm;
@@ -61,10 +64,12 @@
import org.jboss.tools.modeshape.jcr.ValidationStatus;
import org.jboss.tools.modeshape.jcr.attributes.OnParentVersion;
import org.jboss.tools.modeshape.jcr.cnd.CndValidator;
+import org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement;
import org.jboss.tools.modeshape.jcr.ui.Activator;
import org.jboss.tools.modeshape.jcr.ui.JcrUiConstants;
import org.jboss.tools.modeshape.jcr.ui.JcrUiUtils;
import org.jboss.tools.modeshape.ui.UiMessages;
+import org.jboss.tools.modeshape.ui.UiUtils;
import org.jboss.tools.modeshape.ui.actions.DelegateAction;
import org.jboss.tools.modeshape.ui.forms.ErrorMessage;
import org.jboss.tools.modeshape.ui.forms.FormUtils;
@@ -98,9 +103,9 @@
private final ErrorMessage nameError;
private ChildNodeDefinition originalChildNode;
-
+
private QualifiedNameProposalProvider requiredTypeProposalProvider;
-
+
private final ErrorMessage requiredTypesError;
private TableViewer requiredTypesViewer;
@@ -458,8 +463,10 @@
final Table table = FormUtils.createTable(toolkit, rightContainer);
table.setHeaderVisible(false);
table.setLinesVisible(false);
- ((GridData)table.getLayoutData()).horizontalSpan = 2;
- ((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 2;
+ GridData gd = (GridData)table.getLayoutData();
+ gd.horizontalSpan = 2;
+ gd.heightHint = table.getItemHeight() * 4;
+ gd.widthHint = UiUtils.convertWidthInCharsToPixels(table, 40);
this.requiredTypesError.setControl(table);
// table context menu
@@ -475,6 +482,44 @@
this.requiredTypesViewer.setInput(this);
}
+ { // bottom - comments
+ final Composite commentsContainer = toolkit.createComposite(body);
+ commentsContainer.setLayout(new GridLayout(2, false));
+ commentsContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ ((GridData)commentsContainer.getLayoutData()).horizontalSpan = 2;
+ toolkit.paintBordersFor(commentsContainer);
+
+ final Label lblComment = toolkit.createLabel(commentsContainer, CndMessages.commentLabel, SWT.NONE);
+ lblComment.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+
+ Text txtComment = toolkit.createText(commentsContainer, null, Styles.TEXT_STYLE | SWT.MULTI | SWT.H_SCROLL
+ | SWT.V_SCROLL);
+ txtComment.setToolTipText(CndMessages.commentedToolTip);
+
+ final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.verticalIndent += ((GridLayout)body.getLayout()).verticalSpacing;
+ gd.heightHint = txtComment.getLineHeight() * 3;
+ gd.widthHint = UiUtils.convertWidthInCharsToPixels(txtComment, 80);
+ txtComment.setLayoutData(gd);
+
+ if (isEditMode() && !Utils.isEmpty(this.childNodeBeingEdited.getComment())) {
+ txtComment.setText(CommentedCndElement.Helper.removeCommentCharacters(this.childNodeBeingEdited.getComment()));
+ }
+
+ txtComment.addModifyListener(new ModifyListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText( final ModifyEvent e ) {
+ handleCommentChanged(((Text)e.widget).getText());
+ }
+ });
+ }
+
// must be done after constructor
this.childNodeBeingEdited.addListener(new PropertyChangeListener() {
@@ -666,6 +711,10 @@
this.childNodeBeingEdited.setAutoCreated(newAutocreated);
}
+ void handleCommentChanged( final String newComment ) {
+ this.childNodeBeingEdited.setComment(newComment);
+ }
+
void handleDefaultTypeChanged( final String newDefaultType ) {
this.childNodeBeingEdited.setDefaultPrimaryTypeName(newDefaultType);
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -25,6 +25,8 @@
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -82,6 +84,7 @@
import org.jboss.tools.modeshape.jcr.ValidationStatus;
import org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType;
import org.jboss.tools.modeshape.jcr.cnd.CndValidator;
+import org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement;
import org.jboss.tools.modeshape.jcr.cnd.CompactNodeTypeDefinition;
import org.jboss.tools.modeshape.jcr.ui.Activator;
import org.jboss.tools.modeshape.jcr.ui.JcrUiConstants;
@@ -92,6 +95,7 @@
import org.jboss.tools.modeshape.ui.forms.FormUtils;
import org.jboss.tools.modeshape.ui.forms.FormUtils.Styles;
import org.jboss.tools.modeshape.ui.forms.MessageFormDialog;
+import org.jboss.tools.modeshape.ui.viewers.CheckBoxLabelProvider;
/**
* The GUI part of the CND editor.
@@ -134,6 +138,7 @@
private IAction showInheritedChildNodes;
private IAction showInheritedProperties;
private TableViewer superTypesViewer;
+ private Text txtComment;
private Text txtFilter;
/**
@@ -390,9 +395,21 @@
assert (this.columnIndex == ChildNodeColumnIndexes.ATTRIBUTES) : "Unexpected child node column index"; //$NON-NLS-1$
return childNodeDefinition.getAttributesCndNotation(notationType);
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
+ */
+ @Override
+ public String getToolTipText( Object element ) {
+ final ChildNodeDefinition childNodeDefinition = (ChildNodeDefinition)element;
+ return childNodeDefinition.toCndNotation(NotationType.LONG);
+ }
}
this.childNodeViewer = new TableViewer(childNodeTable);
+ ColumnViewerToolTipSupport.enableFor(this.childNodeViewer);
this.childNodeViewer.setContentProvider(new IStructuredContentProvider() {
/**
@@ -478,36 +495,42 @@
}
});
- { // create name column
+ { // name column
final TableViewerColumn nameColumn = new TableViewerColumn(this.childNodeViewer, SWT.LEFT);
UiUtils.configureColumn(nameColumn, new ChildNodeLabelProvider(ChildNodeColumnIndexes.NAME),
CndMessages.nameHeaderText, CndMessages.childNodeNameToolTip, false, true);
}
- { // create type column
+ { // type column
final TableViewerColumn typeColumn = new TableViewerColumn(this.childNodeViewer, SWT.LEFT);
UiUtils.configureColumn(typeColumn, new ChildNodeLabelProvider(ChildNodeColumnIndexes.REQUIRED_TYPES),
CndMessages.requiredTypesHeaderText, CndMessages.childNodeRequiredTypesToolTip, false, true);
}
- { // create default values column
+ { // default values column
final TableViewerColumn defaultValuesColumn = new TableViewerColumn(this.childNodeViewer, SWT.LEFT);
UiUtils.configureColumn(defaultValuesColumn, new ChildNodeLabelProvider(ChildNodeColumnIndexes.DEFAULT_TYPE),
CndMessages.defaultTypeHeaderText, CndMessages.childNodeDefaultTypeToolTip, false, true);
}
- { // create attributes column
+ { // attributes column
final TableViewerColumn attributesColumn = new TableViewerColumn(this.childNodeViewer, SWT.LEFT);
UiUtils.configureColumn(attributesColumn, new ChildNodeLabelProvider(ChildNodeColumnIndexes.ATTRIBUTES),
CndMessages.attributesHeaderText, CndMessages.childNodeAttributesToolTip, false, true);
}
- { // create declaring node type column
+ { // declaring node type column
final TableViewerColumn nodeTypeColumn = new TableViewerColumn(this.childNodeViewer, SWT.LEFT);
UiUtils.configureColumn(nodeTypeColumn, new ChildNodeLabelProvider(ChildNodeColumnIndexes.DECLARING_NODE_TYPE),
CndMessages.declaringNodeTypeHeaderText, CndMessages.declaringNodeTypeToolTip, false, true);
}
+ { // create comment column
+ final TableViewerColumn commentColumn = new TableViewerColumn(this.childNodeViewer, SWT.RIGHT);
+ UiUtils.configureColumn(commentColumn, new CommentLabelProvider(this.childNodeViewer), CndMessages.commentedHeaderText,
+ CndMessages.commentedToolTip, false, false);
+ }
+
// this will sort by child node name
this.childNodeViewer.setSorter(new ViewerSorter() {
@@ -686,42 +709,83 @@
rightContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
toolkit.paintBordersFor(rightContainer);
- final Label label = toolkit.createLabel(rightContainer, CndMessages.supertypesLabel);
- label.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, false, false));
+ { // supertypes
+ final Label label = toolkit.createLabel(rightContainer, CndMessages.supertypesLabel);
+ label.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, false, false));
- createSuperTypesActions();
+ createSuperTypesActions();
- // add toolbar buttons (add, edit, delete)
- final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
- final ToolBar toolBar = toolBarManager.createControl(rightContainer);
- toolBar.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
- toolkit.adapt(toolBar);
+ // add toolbar buttons (add, edit, delete)
+ final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
+ final ToolBar toolBar = toolBarManager.createControl(rightContainer);
+ toolBar.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
+ toolkit.adapt(toolBar);
- final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
- toolBar.setCursor(handCursor);
- toolBarManager.add(this.addSuperType);
- toolBarManager.add(this.editSuperType);
- toolBarManager.add(this.deleteSuperType);
- toolBarManager.update(true);
+ final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
+ toolBar.setCursor(handCursor);
+ toolBarManager.add(this.addSuperType);
+ toolBarManager.add(this.editSuperType);
+ toolBarManager.add(this.deleteSuperType);
+ toolBarManager.update(true);
- final Table table = FormUtils.createTable(toolkit, rightContainer);
- table.setHeaderVisible(false);
- table.setLinesVisible(false);
- ((GridData)table.getLayoutData()).horizontalSpan = 2;
- ((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 4;
- table.setToolTipText(CndMessages.supertypesToolTip);
+ final Table table = FormUtils.createTable(toolkit, rightContainer);
+ table.setHeaderVisible(false);
+ table.setLinesVisible(false);
+ GridData gd = (GridData)table.getLayoutData();
+ gd.horizontalSpan = 2;
+ gd.heightHint = table.getItemHeight() * 4;
+ gd.widthHint = UiUtils.convertWidthInCharsToPixels(table, 40);
+ table.setToolTipText(CndMessages.supertypesToolTip);
- // table context menu
- final MenuManager menuManager = new MenuManager();
- menuManager.add(new DelegateAction(CndMessages.addSuperTypeMenuText, this.addSuperType));
- menuManager.add(new DelegateAction(CndMessages.editSuperTypeMenuText, this.editSuperType));
- menuManager.add(new DelegateAction(CndMessages.deleteSuperTypeMenuText, this.deleteSuperType));
- table.setMenu(menuManager.createContextMenu(table));
+ // table context menu
+ final MenuManager menuManager = new MenuManager();
+ menuManager.add(new DelegateAction(CndMessages.addSuperTypeMenuText, this.addSuperType));
+ menuManager.add(new DelegateAction(CndMessages.editSuperTypeMenuText, this.editSuperType));
+ menuManager.add(new DelegateAction(CndMessages.deleteSuperTypeMenuText, this.deleteSuperType));
+ table.setMenu(menuManager.createContextMenu(table));
- createSuperTypesViewer(table);
+ createSuperTypesViewer(table);
+ // fill with data from CND
+ refreshSuperTypes();
+ }
+ }
+
+ { // bottom of details section (comments)
+ final Composite commentsContainer = toolkit.createComposite(detailsContainer);
+ commentsContainer.setLayout(new GridLayout());
+ commentsContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ ((GridData)commentsContainer.getLayoutData()).horizontalSpan = 2;
+ toolkit.paintBordersFor(commentsContainer);
+
+ final Label lblComment = toolkit.createLabel(commentsContainer, CndMessages.commentLabel, SWT.NONE);
+ lblComment.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+
+ this.txtComment = toolkit.createText(commentsContainer, null, Styles.TEXT_STYLE | SWT.MULTI | SWT.H_SCROLL
+ | SWT.V_SCROLL);
+ this.txtComment.setToolTipText(CndMessages.commentedToolTip);
+
+ final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.verticalIndent += ((GridLayout)detailsContainer.getLayout()).verticalSpacing;
+ gd.heightHint = this.txtComment.getLineHeight() * 3;
+ gd.widthHint = UiUtils.convertWidthInCharsToPixels(this.txtComment, 80);
+ this.txtComment.setLayoutData(gd);
+
+ this.txtComment.addModifyListener(new ModifyListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText( final ModifyEvent e ) {
+ handleCommentChanged(((Text)e.widget).getText());
+ }
+ });
+
// fill with data from CND
- refreshSuperTypes();
+ refreshComments();
}
}
@@ -847,11 +911,27 @@
return namespaceMapping.getPrefix();
}
- return namespaceMapping.getUri();
+ if (this.columnIndex == NamespaceColumnIndexes.URI) {
+ return namespaceMapping.getUri();
+ }
+
+ return Utils.EMPTY_STRING;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
+ */
+ @Override
+ public String getToolTipText( Object element ) {
+ final NamespaceMapping namespaceMapping = (NamespaceMapping)element;
+ return namespaceMapping.toCndNotation(NotationType.LONG);
+ }
}
this.namespaceViewer = new TableViewer(namespaceTable);
+ ColumnViewerToolTipSupport.enableFor(this.namespaceViewer);
this.namespaceViewer.setContentProvider(new IStructuredContentProvider() {
/**
@@ -932,6 +1012,12 @@
CndMessages.namespaceUriHeaderText, CndMessages.namespaceUriToolTip, false, true);
}
+ { // create comment column
+ final TableViewerColumn commentColumn = new TableViewerColumn(this.namespaceViewer, SWT.RIGHT);
+ UiUtils.configureColumn(commentColumn, new CommentLabelProvider(this.namespaceViewer), CndMessages.commentedHeaderText,
+ CndMessages.commentedToolTip, false, false);
+ }
+
// this will sort by prefix
this.namespaceViewer.setSorter(new ViewerSorter() {
@@ -1037,6 +1123,7 @@
final Table table = FormUtils.createTable(toolkit, viewerContainer);
table.setLinesVisible(false);
+ ((GridData)table.getLayoutData()).widthHint = UiUtils.convertWidthInCharsToPixels(table, 30);
// table context menu
final MenuManager menuManager = new MenuManager();
@@ -1082,9 +1169,21 @@
return name;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
+ */
+ @Override
+ public String getToolTipText( Object element ) {
+ final NodeTypeDefinition nodeTypeDefinition = (NodeTypeDefinition)element;
+ return nodeTypeDefinition.toCndNotation(NotationType.LONG);
+ }
}
this.nodeTypeViewer = new TableViewer(nodeTypeTable);
+ ColumnViewerToolTipSupport.enableFor(this.nodeTypeViewer);
this.nodeTypeViewer.setContentProvider(new IStructuredContentProvider() {
/**
@@ -1424,9 +1523,21 @@
return UiUtils.join(Arrays.asList(constraints), null);
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
+ */
+ @Override
+ public String getToolTipText( Object element ) {
+ final PropertyDefinition propertyDefinition = (PropertyDefinition)element;
+ return propertyDefinition.toCndNotation(NotationType.LONG);
+ }
}
this.propertyViewer = new TableViewer(propertyTable);
+ ColumnViewerToolTipSupport.enableFor(this.propertyViewer);
this.propertyViewer.setContentProvider(new IStructuredContentProvider() {
/**
@@ -1549,6 +1660,12 @@
CndMessages.declaringNodeTypeHeaderText, CndMessages.declaringNodeTypeToolTip, false, true);
}
+ { // create comment column
+ final TableViewerColumn commentColumn = new TableViewerColumn(this.propertyViewer, SWT.RIGHT);
+ UiUtils.configureColumn(commentColumn, new CommentLabelProvider(this.propertyViewer), CndMessages.commentedHeaderText,
+ CndMessages.commentedToolTip, false, false);
+ }
+
// this will sort by property name
this.propertyViewer.setSorter(new ViewerSorter() {
@@ -2063,6 +2180,14 @@
}
}
+ void handleCommentChanged( final String newComment ) {
+ final NodeTypeDefinition nodeType = getSelectedNodeType();
+
+ if (nodeType != null) {
+ nodeType.setComment(newComment);
+ }
+ }
+
void handleDeleteChildNode() {
assert (getSelectedNodeType() != null) : "Delete child node button is enabled and there is no node type selected"; //$NON-NLS-1$
assert (getSelectedChildNode() != null) : "Delete child node button is enabled and there is no child node selected"; //$NON-NLS-1$
@@ -2214,8 +2339,6 @@
void handleEditNamespace() {
assert (getSelectedNamespace() != null) : "Edit namespace handler has been called when there is no namespace selected"; //$NON-NLS-1$
final NamespaceMapping selectedNamespace = getSelectedNamespace();
-
- // TODO if prefix is changed should qualified names with old prefix be automatically updated?
final NamespaceMappingDialog dialog = new NamespaceMappingDialog(getShell(),
getCnd().getNamespaceMappings(),
selectedNamespace);
@@ -2393,6 +2516,7 @@
refreshNameControls();
refreshAttributeControls();
refreshSuperTypes();
+ refreshComments();
refreshPropertyViewer();
refreshChildNodeViewer();
}
@@ -2540,9 +2664,6 @@
private void populateUi() {
this.namespaceViewer.setInput(this);
- this.namespaceViewer.getTable().setToolTipText(NLS.bind(CndMessages.namespacesTableToolTip, getCnd().getNamespaceMappings()
- .size()));
-
this.nodeTypeViewer.setInput(this);
// size columns to the data
@@ -2711,6 +2832,22 @@
}
}
+ private void refreshComments() {
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+
+ if (nodeTypeDefinition == null) {
+ if (!Utils.isEmpty(this.txtComment.getText())) {
+ this.txtComment.setText(Utils.EMPTY_STRING);
+ }
+ } else {
+ String comment = nodeTypeDefinition.getComment();
+
+ if (!Utils.equivalent(comment, this.txtComment.getText())) {
+ this.txtComment.setText((comment == null) ? Utils.EMPTY_STRING : comment);
+ }
+ }
+ }
+
private void refreshNameControls() {
final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
@@ -2726,8 +2863,6 @@
private void refreshNamespaceControls() {
this.namespaceViewer.refresh();
- this.namespaceViewer.getTable().setToolTipText(NLS.bind(CndMessages.namespacesTableToolTip, getCnd().getNamespaceMappings()
- .size()));
}
private void refreshNodeTypeControls() {
@@ -3012,12 +3147,34 @@
interface ChildNodeColumnIndexes {
int ATTRIBUTES = 3;
+ int COMMENTS = 5;
int DECLARING_NODE_TYPE = 4;
int DEFAULT_TYPE = 2;
int NAME = 0;
int REQUIRED_TYPES = 1;
}
+ class CommentLabelProvider extends CheckBoxLabelProvider {
+
+ /**
+ * @param viewer the viewer (cannot be <code>null</code>)
+ */
+ public CommentLabelProvider( final ColumnViewer viewer ) {
+ super(viewer);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.tools.modeshape.ui.viewers.CheckBoxLabelProvider#isChecked(java.lang.Object)
+ */
+ @Override
+ protected boolean isChecked( final Object element ) {
+ final CommentedCndElement cndElement = (CommentedCndElement)element;
+ return !Utils.isEmpty(cndElement.getComment());
+ }
+ }
+
/**
* The memento keys for saving and restoring editor state.
*/
@@ -3030,14 +3187,16 @@
}
interface NamespaceColumnIndexes {
+ int COMMENT = 2;
int PREFIX = 0;
int URI = 1;
}
interface PropertyColumnIndexes {
int ATTRIBUTES = 3;
- int CONSTRAINTS = 4;
- int DECLARING_NODE_TYPE = 5;
+ int COMMENT = 6;
+ int CONSTRAINTS = 5;
+ int DECLARING_NODE_TYPE = 4;
int DEFAULT_VALUES = 2;
int NAME = 0;
int TYPE = 1;
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -338,6 +338,21 @@
* The title of the CND prefrence page.
*/
public static String cndPrefPageTitle;
+
+ /**
+ * The column header text indicating if a CND element has a comment.
+ */
+ public static String commentedHeaderText;
+
+ /**
+ * The tool tip message indicating the CND element has a comment.
+ */
+ public static String commentedToolTip;
+
+ /**
+ * A label for a control that shows a CND comment.
+ */
+ public static String commentLabel;
/**
* The column header text of the declaring node type of an item definition.
@@ -896,11 +911,6 @@
public static String namespacePrefixToolTip;
/**
- * The tool tip for a namespace mappings table.
- */
- public static String namespacesTableToolTip;
-
- /**
* The column header text for a namespace URI.
*/
public static String namespaceUriHeaderText;
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/NamespaceMappingDialog.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/NamespaceMappingDialog.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/NamespaceMappingDialog.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -11,6 +11,8 @@
import java.util.Collection;
import java.util.List;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.swt.SWT;
@@ -33,6 +35,7 @@
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.WorkspaceRegistry;
import org.jboss.tools.modeshape.jcr.cnd.CndValidator;
+import org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement;
import org.jboss.tools.modeshape.jcr.ui.Activator;
import org.jboss.tools.modeshape.jcr.ui.JcrUiConstants;
import org.jboss.tools.modeshape.ui.forms.FormUtils.Styles;
@@ -44,6 +47,8 @@
private Button btnOk;
+ private String comment;
+
/**
* An optional list of existing namespace mappings. When this is non-empty, it is checked to make sure the prefix and URI being
* edited is not a duplicate.
@@ -95,6 +100,7 @@
this.namespaceBeingEdited = namespaceBeingEdited;
this.prefix = this.namespaceBeingEdited.getPrefix();
this.uri = this.namespaceBeingEdited.getUri();
+ this.comment = this.namespaceBeingEdited.getComment();
// remove the namespace mapping being edited so validating doesn't show it as a duplicate
this.existingNamespaces.remove(this.namespaceBeingEdited);
@@ -209,6 +215,36 @@
}
});
}
+
+ { // comment
+ final Label lblComment = toolkit.createLabel(body, CndMessages.commentLabel, SWT.NONE);
+ lblComment.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+
+ Text txtComment = toolkit.createText(body, null, Styles.TEXT_STYLE | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ txtComment.setToolTipText(CndMessages.commentedToolTip);
+
+ final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.verticalIndent += ((GridLayout)body.getLayout()).verticalSpacing;
+ gd.heightHint = txtComment.getLineHeight() * 3;
+ txtComment.setLayoutData(gd);
+
+ if (isEditMode() && !Utils.isEmpty(this.namespaceBeingEdited.getComment())) {
+ txtComment.setText(CommentedCndElement.Helper.removeCommentCharacters(this.namespaceBeingEdited.getComment()));
+ }
+
+ txtComment.addModifyListener(new ModifyListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText( final ModifyEvent e ) {
+ handleCommentChanged(((Text)e.widget).getText());
+ }
+ });
+ }
}
/**
@@ -217,9 +253,16 @@
* @return a namespace mapping representing the dialog changes (never <code>null</code>)
*/
public NamespaceMapping getNamespaceMapping() {
- return new NamespaceMapping(this.prefix, this.uri);
+ NamespaceMapping namespaceMapping = new NamespaceMapping(this.prefix, this.uri);
+ namespaceMapping.setComment(this.comment);
+ return namespaceMapping;
}
+ void handleCommentChanged( final String newComment ) {
+ this.comment = newComment;
+ updateState();
+ }
+
void handlePrefixChanged( final String newPrefix ) {
this.prefix = newPrefix;
@@ -234,6 +277,7 @@
}
}
} catch (final Exception e) {
+ Activator.getSharedInstance().getLog().log(new Status(IStatus.ERROR, JcrUiConstants.PLUGIN_ID, null, e));
}
updateState();
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -33,6 +33,8 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Cursor;
@@ -47,6 +49,7 @@
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.forms.FormDialog;
import org.eclipse.ui.forms.IManagedForm;
@@ -63,10 +66,12 @@
import org.jboss.tools.modeshape.jcr.attributes.PropertyType;
import org.jboss.tools.modeshape.jcr.attributes.QueryOperators.QueryOperator;
import org.jboss.tools.modeshape.jcr.cnd.CndValidator;
+import org.jboss.tools.modeshape.jcr.cnd.CommentedCndElement;
import org.jboss.tools.modeshape.jcr.ui.Activator;
import org.jboss.tools.modeshape.jcr.ui.JcrUiConstants;
import org.jboss.tools.modeshape.jcr.ui.JcrUiUtils;
import org.jboss.tools.modeshape.ui.UiMessages;
+import org.jboss.tools.modeshape.ui.UiUtils;
import org.jboss.tools.modeshape.ui.actions.DelegateAction;
import org.jboss.tools.modeshape.ui.forms.ErrorMessage;
import org.jboss.tools.modeshape.ui.forms.FormUtils;
@@ -779,9 +784,9 @@
}
}
- { // bottom (default values, value constraints)
+ { // bottom (default values, value constraints, comments)
final Composite bottomContainer = toolkit.createComposite(body);
- bottomContainer.setLayout(new GridLayout(2, true));
+ bottomContainer.setLayout(new GridLayout(2, false));
bottomContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
toolkit.paintBordersFor(bottomContainer);
@@ -812,8 +817,10 @@
final Table table = FormUtils.createTable(toolkit, defaultValuesContainer);
table.setHeaderVisible(false);
table.setLinesVisible(false);
- ((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 4;
- ((GridData)table.getLayoutData()).horizontalSpan = 2;
+ GridData gd = (GridData)table.getLayoutData();
+ gd.heightHint = table.getItemHeight() * 4;
+ gd.horizontalSpan = 2;
+ gd.widthHint = UiUtils.convertWidthInCharsToPixels(table, 40);
table.setToolTipText(CndMessages.defaultValuesToolTip);
this.defaultValuesError.setControl(table);
@@ -857,8 +864,10 @@
final Table table = FormUtils.createTable(toolkit, valueConstraintsContainer);
table.setHeaderVisible(false);
table.setLinesVisible(false);
- ((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 4;
- ((GridData)table.getLayoutData()).horizontalSpan = 2;
+ GridData gd = (GridData)table.getLayoutData();
+ gd.heightHint = table.getItemHeight() * 4;
+ gd.horizontalSpan = 2;
+ gd.widthHint = UiUtils.convertWidthInCharsToPixels(table, 40);
table.setToolTipText(CndMessages.valueConstraintsToolTip);
this.valueConstraintsError.setControl(table);
@@ -874,6 +883,44 @@
// fill with data
this.valueConstraintsViewer.setInput(this);
}
+
+ { // comments
+ final Composite commentsContainer = toolkit.createComposite(bottomContainer);
+ commentsContainer.setLayout(new GridLayout(2, false));
+ commentsContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ ((GridData)commentsContainer.getLayoutData()).horizontalSpan = 2;
+ toolkit.paintBordersFor(commentsContainer);
+
+ final Label lblComment = toolkit.createLabel(commentsContainer, CndMessages.commentLabel, SWT.NONE);
+ lblComment.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+
+ Text txtComment = toolkit.createText(commentsContainer, null, Styles.TEXT_STYLE | SWT.MULTI | SWT.H_SCROLL
+ | SWT.V_SCROLL);
+ txtComment.setToolTipText(CndMessages.commentedToolTip);
+
+ final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.verticalIndent += ((GridLayout)body.getLayout()).verticalSpacing;
+ gd.heightHint = txtComment.getLineHeight() * 3;
+ gd.widthHint = UiUtils.convertWidthInCharsToPixels(txtComment, 80);
+ txtComment.setLayoutData(gd);
+
+ if (isEditMode() && !Utils.isEmpty(this.propertyBeingEdited.getComment())) {
+ txtComment.setText(CommentedCndElement.Helper.removeCommentCharacters(this.propertyBeingEdited.getComment()));
+ }
+
+ txtComment.addModifyListener(new ModifyListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText( final ModifyEvent e ) {
+ handleCommentChanged(((Text)e.widget).getText());
+ }
+ });
+ }
}
// must be done after constructor
@@ -1168,6 +1215,10 @@
this.propertyBeingEdited.setAutoCreated(newAutocreated);
}
+ void handleCommentChanged( final String newComment ) {
+ this.propertyBeingEdited.setComment(newComment);
+ }
+
void handleDefaultValueSelected() {
// update button enablements
final boolean enable = (getSelectedDefaultValue() != null);
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties 2012-04-21 14:39:01 UTC (rev 40399)
@@ -72,6 +72,9 @@
cndPrefPageDescription = Settings that determine how CND files are formatted.
cndPrefPageMessage = CND Notation
cndPrefPageTitle = CND Notation
+commentedHeaderText = Comments
+commentedToolTip = Indicates if there is an associated comment for the CND element
+commentLabel = Comments:
declaringNodeTypeHeaderText = Declaring Node Type
declaringNodeTypeToolTip = The node type definition that defines the property or child node
defaultTypeHeaderText = Default Type
@@ -185,7 +188,6 @@
namespacePrefixHeaderText = Prefix
namespacePrefixLabel = Prefix:
namespacePrefixToolTip = The prefix of the namespace mapping. Must be unique within a CND.
-namespacesTableToolTip = The mappings of prefixes to the namespace URIs used in a JCR repository. The current number of mappings in this CND is {0}.
namespaceUriHeaderText = URI
namespaceUriToolTip = The URI of the namespace mapping. Must be unique with a CND.
newNamespaceDialogTitle = New Namespace
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/preferences/CndPreferencePage.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/preferences/CndPreferencePage.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/preferences/CndPreferencePage.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -63,17 +63,20 @@
final String content = "<abc = 'http://namespace.com/abc/1.0'>\n" //$NON-NLS-1$
+ "<xyz = 'http://namespace.com/xyz/1.0'>\n" //$NON-NLS-1$
+ + "/* This is a comment for node type definition abc:NodeType. */\n" //$NON-NLS-1$
+ "[abc:NodeType] > abc:ParentType1, abc:ParentType2 abstract orderable mixin noquery primaryitem abc:propertyABC\n" //$NON-NLS-1$
+ "- abc:propertyABC (STRING) = 'default1', 'default2' mandatory autocreated protected multiple VERSION\n" //$NON-NLS-1$
+ " queryops '=, <>, <, <=, >, >=, LIKE' nofulltext noqueryorder < 'constraint1', 'constraint2'" //$NON-NLS-1$
+ "+ abc:node (abc:reqType1, abc:reqType2) = abc:defaultType mandatory autocreated protected sns version\n" //$NON-NLS-1$
+ "[xyz:NodeTypeX]\n" //$NON-NLS-1$
- + "- xyz:propertyX" //$NON-NLS-1$
+ + "/* This is a comment for property definition xyz:propertyX. */\n" //$NON-NLS-1$
+ + "- xyz:propertyX\n" //$NON-NLS-1$
+ "[xyz:NodeTypeY]\n" //$NON-NLS-1$
- + "- xyz:propertyY (LONG)" //$NON-NLS-1$
- + "+ xyz:childNodeY"; //$NON-NLS-1$
+ + "- xyz:propertyY (LONG)\n" //$NON-NLS-1$
+ + "/* This is a comment for child node definition xyz:childNodeX. */\n" //$NON-NLS-1$
+ + "+ xyz:childNodeY\n"; //$NON-NLS-1$
- CndImporter importer = new CndImporter(true);
+ CndImporter importer = new CndImporter();
Collection<Throwable> problems = new ArrayList<Throwable>();
_previewCnd = importer.importFrom(content, problems, "string"); //$NON-NLS-1$
@@ -142,7 +145,8 @@
this.txtPreview = new Text(previewPanel, SWT.READ_ONLY | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
this.txtPreview.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
this.txtPreview.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
- ((GridData)this.txtPreview.getLayoutData()).widthHint = convertWidthInCharsToPixels(120);
+ ((GridData)this.txtPreview.getLayoutData()).widthHint = convertWidthInCharsToPixels(100);
+ ((GridData)this.txtPreview.getLayoutData()).heightHint = convertHeightInCharsToPixels(20);
refreshPreview();
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/META-INF/MANIFEST.MF 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/META-INF/MANIFEST.MF 2012-04-21 14:39:01 UTC (rev 40399)
@@ -14,5 +14,6 @@
Export-Package: org.jboss.tools.modeshape.ui,
org.jboss.tools.modeshape.ui.actions,
org.jboss.tools.modeshape.ui.forms,
- org.jboss.tools.modeshape.ui.graphics
+ org.jboss.tools.modeshape.ui.graphics,
+ org.jboss.tools.modeshape.ui.viewers
Bundle-Activator: org.jboss.tools.modeshape.ui.Activator
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiUtils.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiUtils.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiUtils.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -10,10 +10,14 @@
import java.util.Collection;
import java.util.Iterator;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.CellLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.TableColumn;
/**
@@ -67,6 +71,21 @@
}
/**
+ * @param control the control whose font will be used during calculation (cannot be <code>null</code>)
+ * @param numChars the number of characters whose pixel width is being requested
+ * @return the number of pixels corresponding to the width of the given number of characters
+ */
+ public static int convertWidthInCharsToPixels( Control control,
+ int numChars ) {
+ verifyIsNotNull(control, "control"); //$NON-NLS-1$
+ GC gc = new GC(control);
+ gc.setFont(control.getFont());
+ FontMetrics fontMetrics = gc.getFontMetrics();
+ gc.dispose();
+ return Dialog.convertWidthInCharsToPixels(fontMetrics, numChars);
+ }
+
+ /**
* @param stringBeingChecked the string being checked (can be <code>null</code> or empty)
* @return <code>true</code> if <code>null</code> or empty
*/
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/viewers/CheckBoxLabelProvider.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/viewers/CheckBoxLabelProvider.java (rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/viewers/CheckBoxLabelProvider.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
+ */
+package org.jboss.tools.modeshape.ui.viewers;
+
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.modeshape.ui.UiUtils;
+
+/**
+ * Draws a native-looking checkbox.
+ */
+public abstract class CheckBoxLabelProvider extends ColumnLabelProvider {
+
+ private static final String CHECKED_KEY = "CHECKED"; //$NON-NLS-1$
+
+ private static final String UNCHECK_KEY = "UNCHECKED"; //$NON-NLS-1$
+
+ /**
+ * @param viewer the viewer installing this label provider (cannot be <code>null</code>)
+ */
+ public CheckBoxLabelProvider( final ColumnViewer viewer ) {
+ UiUtils.verifyIsNotNull(viewer, "viewer"); //$NON-NLS-1$
+
+ if (JFaceResources.getImageRegistry().getDescriptor(CHECKED_KEY) == null) {
+ JFaceResources.getImageRegistry().put(UNCHECK_KEY, createImage(viewer.getControl().getShell(), false));
+ JFaceResources.getImageRegistry().put(CHECKED_KEY, createImage(viewer.getControl().getShell(), true));
+ }
+ }
+
+ private Image createImage( final Shell shell,
+ final boolean type ) {
+ final Shell s = new Shell(shell, SWT.NO_TRIM);
+ final Button b = new Button(s, SWT.CHECK);
+ b.setSelection(type);
+
+ final Point bsize = b.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ b.setSize(bsize);
+ b.setLocation(0, 0);
+ s.setSize(bsize);
+ s.open();
+
+ final GC gc = new GC(b);
+ final Image image = new Image(shell.getDisplay(), bsize.x, bsize.y);
+ gc.copyArea(image, 0, 0);
+ gc.dispose();
+
+ s.close();
+
+ return image;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object)
+ */
+ @Override
+ public Image getImage( final Object element ) {
+ if (isChecked(element)) {
+ return JFaceResources.getImageRegistry().getDescriptor(CHECKED_KEY).createImage();
+ }
+
+ return JFaceResources.getImageRegistry().getDescriptor(UNCHECK_KEY).createImage();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText( Object element ) {
+ return UiUtils.EMPTY_STRING;
+ }
+
+ /**
+ * @param element the element being displayed in the viewer (cannot be <code>null</code>)
+ * @return <code>true</code> if a checked checkbox image should be returned
+ */
+ protected abstract boolean isChecked( Object element );
+}
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/viewers/CheckBoxLabelProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinitionTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinitionTest.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinitionTest.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -37,7 +37,7 @@
public void beforeEach() {
this.owner = new NodeTypeDefinition();
this.owner.setName(OWNER_NAME.get());
- this.childNodeDefinition = new ChildNodeDefinition(owner);
+ this.childNodeDefinition = new ChildNodeDefinition(this.owner);
}
@Test
@@ -51,6 +51,11 @@
assertEquals(this.childNodeDefinition, thatChildNodeDefinition);
assertEquals(this.childNodeDefinition.hashCode(), thatChildNodeDefinition.hashCode());
+ this.childNodeDefinition.setComment("comment goes here"); //$NON-NLS-1$
+ thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition, this.owner);
+ assertEquals(this.childNodeDefinition, thatChildNodeDefinition);
+ assertEquals(this.childNodeDefinition.hashCode(), thatChildNodeDefinition.hashCode());
+
this.childNodeDefinition.setDefaultPrimaryTypeName(Constants.DEFAULT_TYPE);
thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition, this.owner);
assertEquals(this.childNodeDefinition, thatChildNodeDefinition);
@@ -96,6 +101,10 @@
that.setName(this.childNodeDefinition.getName());
assertEquals(this.childNodeDefinition, that);
+ this.childNodeDefinition.setComment("comment goes here"); //$NON-NLS-1$
+ that.setComment(this.childNodeDefinition.getComment());
+ assertEquals(this.childNodeDefinition, that);
+
this.childNodeDefinition.setDefaultPrimaryTypeName(Constants.DEFAULT_TYPE);
that.setDefaultPrimaryTypeName(this.childNodeDefinition.getDefaultPrimaryTypeName());
assertEquals(this.childNodeDefinition, that);
@@ -148,6 +157,13 @@
}
@Test
+ public void shouldAllowNullEmptyComment() {
+ this.childNodeDefinition.setComment(null);
+ this.childNodeDefinition.setComment(Utils.EMPTY_STRING);
+
+ }
+
+ @Test
public void shouldChangeAutocreatedPropertyState() {
assertTrue(this.childNodeDefinition.changeState(PropertyName.AUTOCREATED, Value.IS));
assertEquals(this.childNodeDefinition.getState(PropertyName.AUTOCREATED), Value.IS);
@@ -255,6 +271,12 @@
}
@Test
+ public void shouldNotChangeCommentToSameValue() {
+ this.childNodeDefinition.setComment("newComment"); //$NON-NLS-1$
+ assertFalse(this.childNodeDefinition.setComment(this.childNodeDefinition.getComment()));
+ }
+
+ @Test
public void shouldNotClearSuperTypesWhenEmpty() {
assertFalse(this.childNodeDefinition.clearRequiredTypes());
}
@@ -353,6 +375,21 @@
}
@Test
+ public void shouldReceiveEventWhenCommentIsChanged() {
+ final Listener l = new Listener();
+ assertTrue(this.childNodeDefinition.addListener(l));
+
+ final String NEW_COMMENT = "comment"; //$NON-NLS-1$
+ this.childNodeDefinition.setComment(NEW_COMMENT);
+
+ assertEquals(NEW_COMMENT, this.childNodeDefinition.getComment());
+ assertEquals(1, l.getCount());
+ assertEquals(PropertyName.COMMENT.toString(), l.getPropertyName());
+ assertEquals(NEW_COMMENT, l.getNewValue());
+ assertNull(l.getOldValue());
+ }
+
+ @Test
public void shouldReceiveEventWhenOnParentVersionIsChanged() {
final Listener l = new Listener();
assertTrue(this.childNodeDefinition.addListener(l));
@@ -386,6 +423,13 @@
}
@Test
+ public void shouldSetComment() {
+ final String NEW_COMMENT = "newComment"; //$NON-NLS-1$
+ assertTrue(this.childNodeDefinition.setComment(NEW_COMMENT));
+ assertEquals(NEW_COMMENT, this.childNodeDefinition.getComment());
+ }
+
+ @Test
public void shouldSetMandatory() {
this.childNodeDefinition.setMandatory(true);
assertTrue(this.childNodeDefinition.isMandatory());
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -187,7 +187,7 @@
this.problems = new ArrayList<Throwable>();
// Set up the importer ...
- this.importer = new CndImporter(true);
+ this.importer = new CndImporter();
}
private NodeDefinition childDefn( final NodeTypeDefinition nodeType,
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndTokenizerTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndTokenizerTest.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndTokenizerTest.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -30,7 +30,7 @@
@Before
public void beforeEach() {
- this.tokenizer = new CndTokenizer(false, false);
+ this.tokenizer = new CndTokenizer();
final LinkedList<int[]> tokenValues = new LinkedList<int[]>();
this.tokenFactory = new Tokens() {
@Override
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NamespaceMappingTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NamespaceMappingTest.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NamespaceMappingTest.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -54,6 +54,11 @@
assertEquals(this.namespaceMapping, thatNamespaceMapping);
assertEquals(this.namespaceMapping.hashCode(), thatNamespaceMapping.hashCode());
+ assertTrue(this.namespaceMapping.setComment("comment goes here")); //$NON-NLS-1$
+ thatNamespaceMapping = NamespaceMapping.copy(this.namespaceMapping);
+ assertEquals(this.namespaceMapping, thatNamespaceMapping);
+ assertEquals(this.namespaceMapping.hashCode(), thatNamespaceMapping.hashCode());
+
assertTrue(this.namespaceMapping.setPrefix(Constants.NAMESPACE_PREFIX1));
thatNamespaceMapping = NamespaceMapping.copy(this.namespaceMapping);
assertEquals(this.namespaceMapping, thatNamespaceMapping);
@@ -76,6 +81,11 @@
}
@Test
+ public void shouldHaveEmptyCommentAfterConstruction() {
+ assertTrue(Utils.isEmpty(this.namespaceMapping.getComment()));
+ }
+
+ @Test
public void shouldHaveEmptyPrefixAfterConstruction() {
assertTrue(Utils.isEmpty(this.namespaceMapping.getPrefix()));
}
@@ -98,6 +108,13 @@
}
@Test
+ public void shouldNotSetCommentToSameValue() {
+ final String COMMENT = "comment"; //$NON-NLS-1$
+ assertTrue(this.namespaceMapping.setComment(COMMENT));
+ assertFalse(this.namespaceMapping.setComment(COMMENT));
+ }
+
+ @Test
public void shouldNotSetPrefixToSameValue() {
final String PREFIX = "prefix"; //$NON-NLS-1$
assertTrue(this.namespaceMapping.setPrefix(PREFIX));
@@ -112,6 +129,20 @@
}
@Test
+ public void shouldReceivePropertyChangeEventWhenCommentIsChanged() {
+ final Listener l = new Listener();
+ this.namespaceMapping.addListener(l);
+
+ final String OLD_VALUE = this.namespaceMapping.getComment();
+ final String NEW_VALUE = "comment"; //$NON-NLS-1$
+ assertTrue(this.namespaceMapping.setComment(NEW_VALUE));
+ assertEquals(1, l.getCount());
+ assertEquals(NamespaceMapping.PropertyName.COMMENT.toString(), l.getPropertyName());
+ assertEquals(OLD_VALUE, l.getOldValue());
+ assertEquals(NEW_VALUE, l.getNewValue());
+ }
+
+ @Test
public void shouldReceivePropertyChangeEventWhenPrefixIsChanged() {
final Listener l = new Listener();
this.namespaceMapping.addListener(l);
@@ -140,6 +171,13 @@
}
@Test
+ public void shouldSetComment() {
+ final String COMMENT = "comment"; //$NON-NLS-1$
+ assertTrue(this.namespaceMapping.setComment(COMMENT));
+ assertEquals(COMMENT, this.namespaceMapping.getComment());
+ }
+
+ @Test
public void shouldSetPrefix() {
final String PREFIX = "prefix"; //$NON-NLS-1$
assertTrue(this.namespaceMapping.setPrefix(PREFIX));
@@ -168,19 +206,12 @@
}
@Test
- public void twoNamespaceMappingsWithDifferentPrefixesAndSameUriShouldHaveDifferentHashCodes() {
- final NamespaceMapping namespace1 = new NamespaceMapping("prefix", "uri"); //$NON-NLS-1$ //$NON-NLS-2$
- final NamespaceMapping namespace2 = new NamespaceMapping(namespace1.getPrefix() + "different", namespace1.getUri()); //$NON-NLS-1$
-
- assertFalse(namespace1.hashCode() == namespace2.hashCode());
- }
-
- @Test
public void twoNamespaceMappingsWithDifferentPrefixesAndSameUriShouldNotBeEqual() {
final NamespaceMapping namespace1 = new NamespaceMapping("prefix", "uri"); //$NON-NLS-1$ //$NON-NLS-2$
final NamespaceMapping namespace2 = new NamespaceMapping(namespace1.getPrefix() + "different", namespace1.getUri()); //$NON-NLS-1$
assertFalse(namespace1.equals(namespace2));
+ assertFalse(namespace1.hashCode() == namespace2.hashCode());
}
@Test
@@ -189,13 +220,17 @@
final NamespaceMapping namespace2 = new NamespaceMapping(namespace1.getPrefix(), namespace1.getUri() + "different"); //$NON-NLS-1$
assertFalse(namespace1.equals(namespace2));
+ assertFalse(namespace1.hashCode() == namespace2.hashCode());
}
@Test
- public void twoNamespaceMappingsWithSamePrefixAndDifferentUrisShouldNotHaveSameHashCode() {
+ public void twoNamespaceMappingsWithSamePrefixAndSameUriButDifferentCommentShouldNotBeEqual() {
final NamespaceMapping namespace1 = new NamespaceMapping("prefix", "uri"); //$NON-NLS-1$ //$NON-NLS-2$
- final NamespaceMapping namespace2 = new NamespaceMapping(namespace1.getPrefix(), namespace1.getUri() + "different"); //$NON-NLS-1$
+ namespace1.setComment("comment"); //$NON-NLS-1$
+ final NamespaceMapping namespace2 = new NamespaceMapping(namespace1.getPrefix(), namespace1.getUri());
+ namespace2.setComment(namespace1.getComment() + "changed"); //$NON-NLS-1$
+ assertFalse(namespace1.equals(namespace2));
assertFalse(namespace1.hashCode() == namespace2.hashCode());
}
@@ -205,13 +240,6 @@
final NamespaceMapping namespace2 = new NamespaceMapping(namespace1.getPrefix(), namespace1.getUri());
assertTrue(namespace1.equals(namespace2));
- }
-
- @Test
- public void twoNamespaceMappingsWithSamePrefixAndSameUriShouldHaveSameHashCode() {
- final NamespaceMapping namespace1 = new NamespaceMapping("prefix", "uri"); //$NON-NLS-1$ //$NON-NLS-2$
- final NamespaceMapping namespace2 = new NamespaceMapping(namespace1.getPrefix(), namespace1.getUri());
-
assertEquals(namespace1.hashCode(), namespace2.hashCode());
}
}
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinitionTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinitionTest.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinitionTest.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -49,6 +49,11 @@
assertEquals(this.nodeTypeDefinition, thatNodeTypeDefinition);
assertEquals(this.nodeTypeDefinition.hashCode(), thatNodeTypeDefinition.hashCode());
+ this.nodeTypeDefinition.setComment("comment goes here"); //$NON-NLS-1$
+ thatNodeTypeDefinition = NodeTypeDefinition.copy(this.nodeTypeDefinition);
+ assertEquals(this.nodeTypeDefinition, thatNodeTypeDefinition);
+ assertEquals(this.nodeTypeDefinition.hashCode(), thatNodeTypeDefinition.hashCode());
+
this.nodeTypeDefinition.setAbstract(!this.nodeTypeDefinition.isAbstract());
thatNodeTypeDefinition = NodeTypeDefinition.copy(this.nodeTypeDefinition);
assertEquals(this.nodeTypeDefinition, thatNodeTypeDefinition);
@@ -112,6 +117,13 @@
}
@Test
+ public void shouldAllowNullEmptyComment() {
+ this.nodeTypeDefinition.setComment(null);
+ this.nodeTypeDefinition.setComment(Utils.EMPTY_STRING);
+
+ }
+
+ @Test
public void shouldChangeAbstractPropertyState() {
assertTrue(this.nodeTypeDefinition.changeState(PropertyName.ABSTRACT, Value.IS));
assertEquals(this.nodeTypeDefinition.getState(PropertyName.ABSTRACT), Value.IS);
@@ -201,6 +213,12 @@
}
@Test
+ public void shouldNotChangeCommentToSameValue() {
+ this.nodeTypeDefinition.setComment("newComment"); //$NON-NLS-1$
+ assertFalse(this.nodeTypeDefinition.setComment(this.nodeTypeDefinition.getComment()));
+ }
+
+ @Test
public void shouldNotHaveChildNodeDefinitionsAfterConstruction() {
assertEquals(0, this.nodeTypeDefinition.getChildNodeDefinitions().size());
}
@@ -358,6 +376,21 @@
}
@Test
+ public void shouldReceiveEventWhenCommentIsChanged() {
+ final Listener l = new Listener();
+ assertTrue(this.nodeTypeDefinition.addListener(l));
+
+ final String NEW_COMMENT = "comment"; //$NON-NLS-1$
+ this.nodeTypeDefinition.setComment(NEW_COMMENT);
+
+ assertEquals(NEW_COMMENT, this.nodeTypeDefinition.getComment());
+ assertEquals(1, l.getCount());
+ assertEquals(PropertyName.COMMENT.toString(), l.getPropertyName());
+ assertEquals(NEW_COMMENT, l.getNewValue());
+ assertNull(l.getOldValue());
+ }
+
+ @Test
public void shouldRemoveChildNodeDefinition() {
assertTrue(this.nodeTypeDefinition.addChildNodeDefinition(this.childNodeDefinition));
assertTrue(this.nodeTypeDefinition.removeChildNodeDefinition(this.childNodeDefinition));
@@ -393,6 +426,13 @@
}
@Test
+ public void shouldSetComment() {
+ final String NEW_COMMENT = "newComment"; //$NON-NLS-1$
+ assertTrue(this.nodeTypeDefinition.setComment(NEW_COMMENT));
+ assertEquals(NEW_COMMENT, this.nodeTypeDefinition.getComment());
+ }
+
+ @Test
public void shouldSetMixinProperty() {
this.nodeTypeDefinition.setMixin(true);
assertTrue(this.nodeTypeDefinition.isMixin());
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java 2012-04-21 14:39:01 UTC (rev 40399)
@@ -52,6 +52,11 @@
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
+ this.propDefn.setComment("comment goes here"); //$NON-NLS-1$
+ thatPropDefn = PropertyDefinition.copy(this.propDefn, this.owner);
+ assertEquals(this.propDefn, thatPropDefn);
+ assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
+
this.propDefn.setAvailableQueryOperators(Constants.Helper.getDefaultQueryOperators());
thatPropDefn = PropertyDefinition.copy(this.propDefn, this.owner);
assertEquals(this.propDefn, thatPropDefn);
@@ -117,62 +122,75 @@
public void differentInstancesWithSameValuesShouldBeEqual() {
final PropertyDefinition thatPropDefn = new PropertyDefinition(this.owner);
assertEquals(this.propDefn, thatPropDefn);
+ assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setAvailableQueryOperators(Constants.Helper.getDefaultQueryOperators());
thatPropDefn.setAvailableQueryOperators(this.propDefn.getAvailableQueryOperators());
assertEquals(this.propDefn, thatPropDefn);
+ assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setAutoCreated(!this.propDefn.isAutoCreated());
thatPropDefn.setAutoCreated(this.propDefn.isAutoCreated());
assertEquals(this.propDefn, thatPropDefn);
+ assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
+ this.propDefn.setComment("comment"); //$NON-NLS-1$
+ thatPropDefn.setComment(this.propDefn.getComment());
+ assertEquals(this.propDefn, thatPropDefn);
+ assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
+
this.propDefn.setDefaultValues(Constants.Helper.getDefaultStringValues());
thatPropDefn.setDefaultValues(this.propDefn.getDefaultValues());
assertEquals(this.propDefn, thatPropDefn);
+ assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setFullTextSearchable(!this.propDefn.isFullTextSearchable());
thatPropDefn.setFullTextSearchable(this.propDefn.isFullTextSearchable());
assertEquals(this.propDefn, thatPropDefn);
+ assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setMandatory(!this.propDefn.isMandatory());
thatPropDefn.setMandatory(this.propDefn.isMandatory());
assertEquals(this.propDefn, thatPropDefn);
+ assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setMultiple(!this.propDefn.isMultiple());
thatPropDefn.setMultiple(this.propDefn.isMultiple());
assertEquals(this.propDefn, thatPropDefn);
+ assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setName(Constants.QUALIFIED_NAME1.get());
thatPropDefn.setName(this.propDefn.getName());
assertEquals(this.propDefn, thatPropDefn);
+ assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setOnParentVersion(OnParentVersion.COMPUTE.asJcrValue());
thatPropDefn.setOnParentVersion(this.propDefn.getOnParentVersion());
assertEquals(this.propDefn, thatPropDefn);
+ assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setProtected(!this.propDefn.isProtected());
thatPropDefn.setProtected(this.propDefn.isProtected());
assertEquals(this.propDefn, thatPropDefn);
+ assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setQueryOrderable(!this.propDefn.isQueryOrderable());
thatPropDefn.setQueryOrderable(this.propDefn.isQueryOrderable());
assertEquals(this.propDefn, thatPropDefn);
+ assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setRequiredType(PropertyType.BINARY.asJcrValue());
thatPropDefn.setRequiredType(this.propDefn.getRequiredType());
assertEquals(this.propDefn, thatPropDefn);
+ assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setValueConstraints(Constants.DEFAULT_VALUE_CONSTRAINTS);
thatPropDefn.setValueConstraints(this.propDefn.getValueConstraints());
assertEquals(this.propDefn, thatPropDefn);
+ assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
}
@Test
- public void differentInstancesWithSameValuesShouldHaveSameHashCode() {
- assertEquals(this.propDefn.hashCode(), new PropertyDefinition(this.owner).hashCode());
- }
-
- @Test
public void onParentVersionDefaultValueShouldBeCopy() {
assertEquals(OnParentVersion.COPY, OnParentVersion.DEFAULT_VALUE);
}
@@ -202,30 +220,24 @@
}
@Test
- public void shouldSupportAllQueryOperatorsInitially() {
- // setup
- String[] queryOps = this.propDefn.getAvailableQueryOperators();
- QueryOperator[] allOperators = QueryOperator.values();
-
- assertEquals(allOperators.length, queryOps.length);
-
- for (String queryOp : queryOps) {
- QueryOperator.find(queryOp); // throws exception if not found
- }
- }
-
- @Test
public void shouldAddValueConstraint() {
- final String CONSTRAINT = "constraint"; //$NON-NLS-1$
+ final String CONSTRAINT = Constants.VALUE_CONSTRAINT1;
assertTrue(this.propDefn.addValueConstraint(CONSTRAINT));
assertEquals(1, this.propDefn.getValueConstraints().length);
assertEquals(CONSTRAINT, this.propDefn.getValueConstraints()[0]);
}
@Test
+ public void shouldAllowNullEmptyComment() {
+ this.propDefn.setComment(null);
+ this.propDefn.setComment(Utils.EMPTY_STRING);
+
+ }
+
+ @Test
public void shouldAllowNullEmptyName() {
this.propDefn.setName(null);
- this.propDefn.setName(""); //$NON-NLS-1$
+ this.propDefn.setName(Utils.EMPTY_STRING);
}
@@ -408,6 +420,12 @@
}
@Test
+ public void shouldNotChangeCommentToSameValue() {
+ this.propDefn.setComment("newComment"); //$NON-NLS-1$
+ assertFalse(this.propDefn.setComment(this.propDefn.getComment()));
+ }
+
+ @Test
public void shouldNotClearDefaultValuesWhenEmpty() {
assertFalse(this.propDefn.clearDefaultValues());
}
@@ -588,6 +606,21 @@
}
@Test
+ public void shouldReceiveEventWhenCommentIsChanged() {
+ final Listener l = new Listener();
+ assertTrue(this.propDefn.addListener(l));
+
+ final String NEW_COMMENT = "comment"; //$NON-NLS-1$
+ this.propDefn.setComment(NEW_COMMENT);
+
+ assertEquals(NEW_COMMENT, this.propDefn.getComment());
+ assertEquals(1, l.getCount());
+ assertEquals(PropertyName.COMMENT.toString(), l.getPropertyName());
+ assertEquals(NEW_COMMENT, l.getNewValue());
+ assertNull(l.getOldValue());
+ }
+
+ @Test
public void shouldReceiveEventWhenNameIsChanged() {
final Listener l = new Listener();
assertTrue(this.propDefn.addListener(l));
@@ -693,6 +726,13 @@
}
@Test
+ public void shouldSetComment() {
+ final String NEW_COMMENT = "newComment"; //$NON-NLS-1$
+ assertTrue(this.propDefn.setComment(NEW_COMMENT));
+ assertEquals(NEW_COMMENT, this.propDefn.getComment());
+ }
+
+ @Test
public void shouldSetDefaultValues() {
assertTrue(this.propDefn.addDefaultValue("defaultValueBeingOverridden")); //$NON-NLS-1$
@@ -884,4 +924,17 @@
this.propDefn.setValueConstraints(null);
assertEquals(0, this.propDefn.getValueConstraints().length);
}
+
+ @Test
+ public void shouldSupportAllQueryOperatorsInitially() {
+ // setup
+ final String[] queryOps = this.propDefn.getAvailableQueryOperators();
+ final QueryOperator[] allOperators = QueryOperator.values();
+
+ assertEquals(allOperators.length, queryOps.length);
+
+ for (final String queryOp : queryOps) {
+ QueryOperator.find(queryOp); // throws exception if not found
+ }
+ }
}
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/aircraft.cnd
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/aircraft.cnd 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/aircraft.cnd 2012-04-21 14:39:01 UTC (rev 40399)
@@ -59,6 +59,6 @@
< '\d{1,3}(,?\d{3})*\s*(lb|kg|gal|L)' // followed by 'lb', 'kg', 'gal', or 'L'
- air:crew (long) < '[0,)' // any non-negative value
- air:numberBuilt (string) // any integer (with optional ',' every 1000s place)
- < '\d{1,3}(,?\d{3})*\s*[+]?' , // optionally followed by '+'
- '([<>]\s*)?\d{1,3}(,?\d{3})*' // or prefixed by '<' or '>'
+ < '\d{1,3}(,?\d{3})*\s*[+]?' ,
+ '([<>]\s*)?\d{1,3}(,?\d{3})*' // optionally followed by '+' or prefixed by '<' or '>'
- air:url (string)
\ No newline at end of file
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/cnd-reader-test-input.cnd
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/cnd-reader-test-input.cnd 2012-04-21 12:34:27 UTC (rev 40398)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/cnd-reader-test-input.cnd 2012-04-21 14:39:01 UTC (rev 40399)
@@ -16,23 +16,25 @@
*/
<ex = "http://example.org/jackrabbit/example">
<jcr='http://www.jcp.org/jcr/1.0'>
-<mix='http://www.jcp.org/jcr/mix/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'> // added since no auto-registering
<nt='http://www.jcp.org/jcr/nt/1.0'>
// test remapping
<REP='internal'>
-// omit this namespace to test auto-registering
-// <mix='http://www.jcp.org/jcr/mix/1.0'>
-
//------------------------------------------------------------------------------
// E X A M P L E T Y P E S
//------------------------------------------------------------------------------
[ex:NodeType] > ex:ParentNodeType1, ex:ParentNodeType2
+// node type comment
orderable mixin
- - ex:property (long) = '1', '2' primary mandatory autocreated protected multiple version < '[1,10]'
- + ex:node (ex:RequiredNodeType1, ex:RequiredNodeType2) = ex:RequiredNodeType1 mandatory autocreated protected multiple version
+ - ex:property
+ // property comment
+ (long) = '1', '2' primary mandatory autocreated protected multiple version < '[1,10]'
+ + ex:node
+ // child node comment
+ (ex:RequiredNodeType1, ex:RequiredNodeType2) = ex:RequiredNodeType1 mandatory autocreated protected multiple version
[ex:AnotherNodeType] > ex:NodeType
- * (string) = 'a residual property' multiple
13 years, 8 months
JBoss Tools SVN: r40398 - trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2012-04-21 08:34:27 -0400 (Sat, 21 Apr 2012)
New Revision: 40398
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/FieldPostProcessor.java
Log:
Modified: trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/FieldPostProcessor.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/FieldPostProcessor.java 2012-04-21 11:42:21 UTC (rev 40397)
+++ trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/FieldPostProcessor.java 2012-04-21 12:34:27 UTC (rev 40398)
@@ -24,14 +24,14 @@
public void postProcess(Map<String, String> commandDetails) {
try {
String crn = commandDetails.get("crn");
- String par = commandDetails.get("par").trim();
+ String par = commandDetails.get("par");
IFile file = ForgeCommandPostProcessorHelper.getFile(crn);
if (file == null) return;
IJavaElement javaElement = JavaCore.create(file);
if (javaElement != null && javaElement.getElementType() == IJavaElement.COMPILATION_UNIT) {
try {
IType type = ((ICompilationUnit)javaElement).getTypes()[0];
- IField field = type.getField(par);
+ IField field = getFieldToPostProcess(par, type);
if (field != null) {
ISourceRange sourceRange = field.getSourceRange();
IWorkbenchPage workbenchPage = ForgeCommandPostProcessorHelper.getActiveWorkbenchPage();
@@ -48,5 +48,16 @@
ForgeUIPlugin.log(e);
}
}
+
+ private IField getFieldToPostProcess(String par, IType type) {
+ String[] candidates = par.trim().split(" ");
+ for (String candidate : candidates) {
+ IField field = type.getField(candidate);
+ if (field != null && field.exists()) {
+ return field;
+ }
+ }
+ return null;
+ }
}
13 years, 8 months
JBoss Tools SVN: r40397 - in trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core: process and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2012-04-21 07:42:21 -0400 (Sat, 21 Apr 2012)
New Revision: 40397
Modified:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/ForgeCorePlugin.java
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeAbstractRuntime.java
Log:
JBIDE-11200: Forge process fails to stop
Modified: trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/ForgeCorePlugin.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/ForgeCorePlugin.java 2012-04-21 02:06:55 UTC (rev 40396)
+++ trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/ForgeCorePlugin.java 2012-04-21 11:42:21 UTC (rev 40397)
@@ -1,8 +1,13 @@
package org.jboss.tools.forge.core;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IProcess;
import org.osgi.framework.BundleContext;
public class ForgeCorePlugin extends Plugin {
@@ -11,10 +16,34 @@
private static ForgeCorePlugin plugin;
+ private static Thread shutdownHook;
+ private static List<IProcess> processes = new ArrayList<IProcess>();
+
public void start(BundleContext context) throws Exception {
super.start(context);
+ initializeShutdownHook();
plugin = this;
}
+
+ private void initializeShutdownHook() {
+ if (shutdownHook == null) {
+ shutdownHook = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ for (IProcess process : processes) {
+ if (process != null && process.canTerminate()) {
+ try {
+ process.terminate();
+ } catch (DebugException e) {
+ log(e);
+ }
+ }
+ }
+ }
+ });
+ Runtime.getRuntime().addShutdownHook(shutdownHook);
+ }
+ }
public void stop(BundleContext context) throws Exception {
plugin = null;
@@ -33,4 +62,12 @@
return new Status(IStatus.ERROR, PLUGIN_ID, IStatus.INFO, message, exception);
}
+ public static void addForgeProcess(IProcess process) {
+ processes.add(process);
+ }
+
+ public static void removeForgeProcess(IProcess process) {
+ processes.remove(process);
+ }
+
}
Modified: trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeAbstractRuntime.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeAbstractRuntime.java 2012-04-21 02:06:55 UTC (rev 40396)
+++ trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeAbstractRuntime.java 2012-04-21 11:42:21 UTC (rev 40397)
@@ -75,6 +75,7 @@
}
} finally {
if (process != null) {
+ ForgeCorePlugin.addForgeProcess(process);
IStreamsProxy streamsProxy = process.getStreamsProxy();
if (streamsProxy != null) {
IStreamMonitor outputStreamMonitor = streamsProxy.getOutputStreamMonitor();
@@ -155,6 +156,7 @@
}
}
process.terminate();
+ ForgeCorePlugin.removeForgeProcess(process);
}
} catch (DebugException e) {
ForgeCorePlugin.log(e);
@@ -227,6 +229,7 @@
@Override
public void run() {
setNewState(STATE_NOT_RUNNING);
+ ForgeCorePlugin.removeForgeProcess(process);
process = null;
DebugPlugin.getDefault().removeDebugEventListener(terminateListener);
}
13 years, 8 months