JBoss Tools SVN: r39170 - in trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal: utils and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-02-28 09:58:29 -0500 (Tue, 28 Feb 2012)
New Revision: 39170
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/utils/ValidationMessages.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/ValidationMessages.properties
Log:
Fixed - JBIDE-11068 - Wrong error: This parameter type (javax.servlet.http.HttpServletRequest) cannot be annotated with @Context
Fixed - JBIDE-11070 - JAX-RS validation problem marked as Error instead of Warning
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-02-28 14:43:50 UTC (rev 39169)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java 2012-02-28 14:58:29 UTC (rev 39170)
@@ -35,9 +35,12 @@
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.text.TypedRegion;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.validation.ValidatorMessage;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsMetamodelBuilder;
import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
+import org.jboss.tools.ws.jaxrs.core.internal.utils.ValidationMessages;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
import org.jboss.tools.ws.jaxrs.core.jdt.JavaMethodParameter;
import org.jboss.tools.ws.jaxrs.core.jdt.JavaMethodSignature;
@@ -47,18 +50,20 @@
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsResourceMethod;
/** @author xcoulon */
-public class JaxrsResourceMethod extends JaxrsResourceElement<IMethod> implements IJaxrsResourceMethod {
+public class JaxrsResourceMethod extends JaxrsResourceElement<IMethod>
+ implements IJaxrsResourceMethod {
/** The parameter type names that can be annotated with {@link Context}. */
private final static List<String> CONTEXT_TYPE_NAMES = new ArrayList<String>(Arrays.asList(
"javax.ws.rs.core.HttpHeaders", "javax.ws.rs.core.UriInfo", "javax.ws.rs.core.Request",
- "javax.servlet.HttpServletRequest", "javax.servlet.HttpServletResponse", "javax.servlet.ServletConfig",
+ "javax.servlet.http.HttpServletRequest", "javax.servlet.http.HttpServletResponse", "javax.servlet.ServletConfig",
"javax.servlet.ServletContext", "javax.ws.rs.core.SecurityContext"));
private final JaxrsResource parentResource;
/**
- * return type of the java javaMethod. Null if this is not a subresource locator.
+ * return type of the java javaMethod. Null if this is not a subresource
+ * locator.
*/
private IType returnedJavaType = null;
@@ -76,7 +81,8 @@
private final List<JavaMethodParameter> javaMethodParameters = new ArrayList<JavaMethodParameter>();
private IType returnedJavaType;
- public Builder(IMethod method, JaxrsResource parentResource, JaxrsMetamodel metamodel) {
+ public Builder(IMethod method, JaxrsResource parentResource,
+ JaxrsMetamodel metamodel) {
assert method != null;
assert parentResource != null;
assert metamodel != null;
@@ -131,8 +137,9 @@
if (producesAnnotation != null) {
annotations.add(producesAnnotation);
}
- JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod(javaMethod, parentResource,
- javaMethodParameters, returnedJavaType, annotations, metamodel);
+ JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod(
+ javaMethod, parentResource, javaMethodParameters,
+ returnedJavaType, annotations, metamodel);
return resourceMethod;
}
@@ -150,8 +157,10 @@
*
* @throws CoreException
*/
- private JaxrsResourceMethod(final IMethod javaMethod, final JaxrsResource parentResource,
- List<JavaMethodParameter> javaMethodParameters, IType returnedJavaType, List<Annotation> annotations,
+ private JaxrsResourceMethod(final IMethod javaMethod,
+ final JaxrsResource parentResource,
+ List<JavaMethodParameter> javaMethodParameters,
+ IType returnedJavaType, List<Annotation> annotations,
final JaxrsMetamodel metamodel) {
super(javaMethod, annotations, parentResource, metamodel);
this.parentResource = parentResource;
@@ -162,10 +171,12 @@
this.parentResource.addMethod(this);
}
- public int update(JavaMethodSignature methodSignature) throws JavaModelException {
+ public int update(JavaMethodSignature methodSignature)
+ throws JavaModelException {
int flag = F_NONE;
// method parameters, including annotations
- final List<JavaMethodParameter> methodParameters = methodSignature.getMethodParameters();
+ final List<JavaMethodParameter> methodParameters = methodSignature
+ .getMethodParameters();
if (!this.javaMethodParameters.equals(methodParameters)) {
this.javaMethodParameters.clear();
this.javaMethodParameters.addAll(methodParameters);
@@ -201,15 +212,13 @@
messages.addAll(validateMissingPathParamAnnotations());
messages.addAll(validateParamsWithContextAnnotation());
messages.addAll(validateSingleParamWithoutAnnotation());
- if(messages.size() > 0) {
- this.hasErrors(true);
- }
return messages;
}
/**
- * Validate that only one method parameter is not annotated with a JAX-RS annotation. This non-annotated parameter
- * is the "Entity parameter", coming from the client's request body, unmarshalled by the appropriate
+ * Validate that only one method parameter is not annotated with a JAX-RS
+ * annotation. This non-annotated parameter is the "Entity parameter",
+ * coming from the client's request body, unmarshalled by the appropriate
* {@link MesssageBodyReader}.
*
* @return
@@ -220,64 +229,70 @@
}
/**
- * Validates that the method parameters annotated with {@link Context} are of the supported types in the spec:
- * {@link UriInfo}, {@link HttpHeaders}, {@link ServletConfig}, {@link ServletContext}, {@link HttpServletRequest},
- * {@link Request}, {@link HttpServletResponse} and {@link Response}.
+ * Validates that the method parameters annotated with {@link Context} are
+ * of the supported types in the spec: {@link UriInfo}, {@link HttpHeaders},
+ * {@link ServletConfig}, {@link ServletContext}, {@link HttpServletRequest}
+ * , {@link Request}, {@link HttpServletResponse} and {@link Response}.
*
* @return
*/
private List<ValidatorMessage> validateParamsWithContextAnnotation() {
final List<ValidatorMessage> messages = new ArrayList<ValidatorMessage>();
for (JavaMethodParameter parameter : this.javaMethodParameters) {
- final Annotation annotation = parameter.getAnnotation(Context.class.getName());
+ final Annotation annotation = parameter.getAnnotation(Context.class
+ .getName());
final String typeName = parameter.getTypeName();
- if (annotation != null && typeName != null && !CONTEXT_TYPE_NAMES.contains(typeName)) {
- final ValidatorMessage message = ValidatorMessage.create("This parameter type (" + typeName
- + ") cannot be annotated with @Context", this.getResource());
- message.setAttribute(IMarker.MARKER, JaxrsMetamodelBuilder.JAXRS_PROBLEM);
- message.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
- message.setAttribute(IMarker.CHAR_START, parameter.getRegion().getOffset());
- message.setAttribute(IMarker.CHAR_END, parameter.getRegion().getOffset()
- + parameter.getRegion().getLength());
- messages.add(message);
- Logger.debug("Validation message for {}: {}", this.getJavaElement().getElementName(),
- message.getAttribute(IMarker.MESSAGE));
+ if (annotation != null && typeName != null
+ && !CONTEXT_TYPE_NAMES.contains(typeName)) {
+ final String msg = NLS
+ .bind(ValidationMessages.INVALID_CONTEXT_ANNOTATION,
+ typeName);
+ ValidatorMessage validationMsg = createValidationMessage(msg, IMarker.SEVERITY_ERROR, parameter.getRegion().getOffset(), parameter.getRegion().getLength());
+ messages.add(validationMsg);
+ this.hasErrors(true);
}
}
- return messages;
+ return messages;
}
- private List<ValidatorMessage> validateMissingPathParamAnnotations() throws JavaModelException {
+ /**
+ * Validates that the @Path annotation parameters have a counterpart in the
+ * java method paramters, otherwise, issues some markers with a 'warning'
+ * severity.
+ *
+ * @return
+ * @throws JavaModelException
+ */
+ private List<ValidatorMessage> validateMissingPathParamAnnotations()
+ throws JavaModelException {
final List<ValidatorMessage> messages = new ArrayList<ValidatorMessage>();
final List<String> pathParamValueProposals = getPathParamValueProposals();
for (String proposal : pathParamValueProposals) {
boolean matching = false;
for (JavaMethodParameter parameter : this.javaMethodParameters) {
- final Annotation annotation = parameter.getAnnotation(PathParam.class.getName());
- if (annotation != null && annotation.getValue("value").equals(proposal)) {
+ final Annotation annotation = parameter
+ .getAnnotation(PathParam.class.getName());
+ if (annotation != null
+ && annotation.getValue("value").equals(proposal)) {
matching = true;
break;
}
}
if (!matching) {
- final ValidatorMessage message = ValidatorMessage.create("Missing @PathParam value: expected "
- + proposal, this.getResource());
- message.setAttribute(IMarker.MARKER, JaxrsMetamodelBuilder.JAXRS_PROBLEM);
- message.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+ final String msg = NLS
+ .bind(ValidationMessages.INVALID_PATHPARAM_VALUE,
+ proposal);
final ISourceRange nameRange = getJavaElement().getNameRange();
- message.setAttribute(IMarker.CHAR_START, nameRange.getOffset());
- message.setAttribute(IMarker.CHAR_END, nameRange.getOffset() + nameRange.getLength());
- messages.add(message);
- Logger.debug("Validation message for {}: {}", this.getJavaElement().getElementName(),
- message.getAttribute(IMarker.MESSAGE));
+ ValidatorMessage validationMsg = createValidationMessage(msg, IMarker.SEVERITY_WARNING, nameRange.getOffset(), nameRange.getLength());
+ messages.add(validationMsg);
}
}
return messages;
}
/**
- * Checks that the {@link PathParam} annotation values match the params in the {@link Path} annotations at the
- * method and the parent type levels.
+ * Checks that the {@link PathParam} annotation values match the params in
+ * the {@link Path} annotations at the method and the parent type levels.
*
* @return errors in case of mismatch, empty list otherwise.
*/
@@ -285,29 +300,52 @@
final List<ValidatorMessage> messages = new ArrayList<ValidatorMessage>();
final List<String> pathParamValueProposals = getPathParamValueProposals();
for (JavaMethodParameter parameter : this.javaMethodParameters) {
- final Annotation annotation = parameter.getAnnotation(PathParam.class.getName());
+ final Annotation annotation = parameter
+ .getAnnotation(PathParam.class.getName());
if (annotation != null) {
final String value = annotation.getValue("value");
if (!pathParamValueProposals.contains(value)) {
- final ValidatorMessage message = ValidatorMessage.create("Invalid @PathParam value: expected "
- + pathParamValueProposals, this.getResource());
- message.setAttribute(IMarker.MARKER, JaxrsMetamodelBuilder.JAXRS_PROBLEM);
- message.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
- message.setAttribute(IMarker.CHAR_START, annotation.getRegion().getOffset());
- message.setAttribute(IMarker.CHAR_END, annotation.getRegion().getOffset()
- + annotation.getRegion().getLength());
- messages.add(message);
- Logger.debug("Validation message for {}: {}", this.getJavaElement().getElementName(),
- message.getAttribute(IMarker.MESSAGE));
+ final String msg = NLS
+ .bind(ValidationMessages.INVALID_PATHPARAM_VALUE,
+ pathParamValueProposals);
+ final TypedRegion region = annotation.getRegion();
+ ValidatorMessage validationMsg = createValidationMessage(msg, IMarker.SEVERITY_ERROR, region.getOffset(), region.getLength());
+ hasErrors(true);
+ messages.add(validationMsg);
}
}
}
return messages;
}
+ /**
+ * Creates a validation message from the given parameters. The created validation messages is of the 'JAX-RS' type.
+ * @param msg the message to display
+ * @param severity the severity of the marker
+ * @param region the region that the validation marker points to
+ * @return the created validation message.
+ */
+ private ValidatorMessage createValidationMessage(final String msg,
+ int severity, final int offset, int length) {
+ final ValidatorMessage validationMsg = ValidatorMessage.create(msg,
+ this.getResource());
+ validationMsg.setAttribute(IMarker.MARKER,
+ JaxrsMetamodelBuilder.JAXRS_PROBLEM);
+ validationMsg.setAttribute(IMarker.SEVERITY, severity);
+ validationMsg.setAttribute(IMarker.CHAR_START, offset);
+ validationMsg.setAttribute(IMarker.CHAR_END, offset + length);
+ Logger.debug("Validation message for {}: {}", this.getJavaElement()
+ .getElementName(), validationMsg.getAttribute(IMarker.MESSAGE));
+ return validationMsg;
+ }
+
+
/*
* (non-Javadoc)
- * @see org.jboss.tools.ws.jaxrs.core.internal.metamodel.IResourceMethod#hasErrors (boolean)
+ *
+ * @see
+ * org.jboss.tools.ws.jaxrs.core.internal.metamodel.IResourceMethod#hasErrors
+ * (boolean)
*/
@Override
public void hasErrors(final boolean h) {
@@ -319,7 +357,10 @@
/*
* (non-Javadoc)
- * @see org.jboss.tools.ws.jaxrs.core.internal.metamodel.IResourceMethod#getKind ()
+ *
+ * @see
+ * org.jboss.tools.ws.jaxrs.core.internal.metamodel.IResourceMethod#getKind
+ * ()
*/
@Override
public final EnumKind getKind() {
@@ -337,7 +378,9 @@
/*
* (non-Javadoc)
- * @see org.jboss.tools.ws.jaxrs.core.internal.metamodel.IResourceMethod# getParentResource()
+ *
+ * @see org.jboss.tools.ws.jaxrs.core.internal.metamodel.IResourceMethod#
+ * getParentResource()
*/
@Override
public final JaxrsResource getParentResource() {
@@ -359,7 +402,8 @@
public Annotation getHttpMethodAnnotation() {
for (IJaxrsHttpMethod httpMethod : getMetamodel().getAllHttpMethods()) {
- final Annotation annotation = getAnnotation(httpMethod.getJavaElement().getFullyQualifiedName());
+ final Annotation annotation = getAnnotation(httpMethod
+ .getJavaElement().getFullyQualifiedName());
if (annotation != null) {
return annotation;
}
@@ -407,14 +451,16 @@
public List<JavaMethodParameter> getJavaMethodParameters() {
return javaMethodParameters;
}
-
+
/*
* (non-Javadoc)
+ *
* @see java.lang.Object#toString()
*/
@Override
public final String toString() {
- return "ResourceMethod '" + parentResource.getName() + "." + getJavaElement().getElementName() + "' ("
+ return "ResourceMethod '" + parentResource.getName() + "."
+ + getJavaElement().getElementName() + "' ("
+ getKind().toString() + ")";
}
@@ -426,7 +472,8 @@
final String value = methodPathAnnotation.getValue("value");
proposals.addAll(extractParamsFromUriTemplateFragment(value));
}
- final Annotation typePathAnnotation = getParentResource().getPathAnnotation();
+ final Annotation typePathAnnotation = getParentResource()
+ .getPathAnnotation();
if (typePathAnnotation != null) {
final String value = typePathAnnotation.getValue("value");
proposals.addAll(extractParamsFromUriTemplateFragment(value));
@@ -435,19 +482,22 @@
}
/**
- * Extracts all the character sequences inside of curly braces ('{' and '}') and returns them as a list of strings
+ * Extracts all the character sequences inside of curly braces ('{' and '}')
+ * and returns them as a list of strings
*
* @param value
* the given value
* @return the list of character sequences, or an empty list
*/
- private static List<String> extractParamsFromUriTemplateFragment(String value) {
+ private static List<String> extractParamsFromUriTemplateFragment(
+ String value) {
List<String> params = new ArrayList<String>();
int beginIndex = -1;
while ((beginIndex = value.indexOf("{", beginIndex + 1)) != -1) {
int semicolonIndex = value.indexOf(":", beginIndex);
int closingCurlyBraketIndex = value.indexOf("}", beginIndex);
- int endIndex = semicolonIndex != -1 ? semicolonIndex : closingCurlyBraketIndex;
+ int endIndex = semicolonIndex != -1 ? semicolonIndex
+ : closingCurlyBraketIndex;
params.add(value.substring(beginIndex + 1, endIndex).trim());
}
return params;
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/ValidationMessages.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/ValidationMessages.java 2012-02-28 14:43:50 UTC (rev 39169)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/ValidationMessages.java 2012-02-28 14:58:29 UTC (rev 39170)
@@ -16,7 +16,9 @@
public class ValidationMessages extends NLS {
private static final String BUNDLE_NAME = ValidationMessages.class.getName(); //$NON-NLS-1$
- public static String unbound_parameter;
+ public static String INVALID_CONTEXT_ANNOTATION;
+
+ public static String INVALID_PATHPARAM_VALUE;
static {
NLS.initializeMessages(BUNDLE_NAME, ValidationMessages.class);
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/ValidationMessages.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/ValidationMessages.properties 2012-02-28 14:43:50 UTC (rev 39169)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/ValidationMessages.properties 2012-02-28 14:58:29 UTC (rev 39170)
@@ -1 +1 @@
-unbound_parameter = @PathParam annotation value {0} does not match any parameter of the same method or type @Path annotation(s).
\ No newline at end of file
+INVALID_CONTEXT_ANNOTATION=The parameter type ''{0}'' cannot be annotated with @Context INVALID_PATHPARAM_VALUE=Invalid @PathParam value: expected ''{0}''
\ No newline at end of file
12 years, 10 months
JBoss Tools SVN: r39169 - trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/META-INF.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2012-02-28 09:43:50 -0500 (Tue, 28 Feb 2012)
New Revision: 39169
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/META-INF/MANIFEST.MF
Log:
https://issues.jboss.org/browse/JBIDE-11047 : BrowserSim: the features should be disabled for 64-bit Java on 64-bit Windows
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/META-INF/MANIFEST.MF 2012-02-28 14:43:32 UTC (rev 39168)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/META-INF/MANIFEST.MF 2012-02-28 14:43:50 UTC (rev 39169)
@@ -8,3 +8,8 @@
Export-Package: org.jboss.tools.vpe.browsersim.browser
Require-Bundle: org.eclipse.swt;bundle-version="3.7.0"
Bundle-Vendor: JBoss by Red Hat
+Eclipse-PlatformFilter: (|
+ (&(osgi.ws=win32)(osgi.os=win32)(osgi.arch=x86))
+ (&(osgi.ws=cocoa)(osgi.os=macosx) (|(osgi.arch=x86)(osgi.arch=x86_64)) )
+ (&(osgi.ws=gtk)(osgi.os=linux) (|(osgi.arch=x86)(osgi.arch=x86_64)) )
+ )
12 years, 10 months
JBoss Tools SVN: r39168 - in branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal: utils and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-02-28 09:43:32 -0500 (Tue, 28 Feb 2012)
New Revision: 39168
Modified:
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/ValidationMessages.java
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/ValidationMessages.properties
Log:
Fixed JBIDE-11068 and JBIDE-11070
Applied patches
Modified: branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java 2012-02-28 12:54:26 UTC (rev 39167)
+++ branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java 2012-02-28 14:43:32 UTC (rev 39168)
@@ -31,14 +31,20 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jface.text.TypedRegion;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.validation.ValidatorMessage;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsMetamodelBuilder;
import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
+import org.jboss.tools.ws.jaxrs.core.internal.utils.ValidationMessages;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
+import org.jboss.tools.ws.jaxrs.core.jdt.CompilationUnitsRepository;
import org.jboss.tools.ws.jaxrs.core.jdt.JavaMethodParameter;
import org.jboss.tools.ws.jaxrs.core.jdt.JavaMethodSignature;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
@@ -47,18 +53,24 @@
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsResourceMethod;
/** @author xcoulon */
-public class JaxrsResourceMethod extends JaxrsResourceElement<IMethod> implements IJaxrsResourceMethod {
+public class JaxrsResourceMethod extends JaxrsResourceElement<IMethod>
+ implements IJaxrsResourceMethod {
/** The parameter type names that can be annotated with {@link Context}. */
- private final static List<String> CONTEXT_TYPE_NAMES = new ArrayList<String>(Arrays.asList(
- "javax.ws.rs.core.HttpHeaders", "javax.ws.rs.core.UriInfo", "javax.ws.rs.core.Request",
- "javax.servlet.HttpServletRequest", "javax.servlet.HttpServletResponse", "javax.servlet.ServletConfig",
- "javax.servlet.ServletContext", "javax.ws.rs.core.SecurityContext"));
+ private final static List<String> CONTEXT_TYPE_NAMES = new ArrayList<String>(
+ Arrays.asList("javax.ws.rs.core.HttpHeaders",
+ "javax.ws.rs.core.UriInfo", "javax.ws.rs.core.Request",
+ "javax.servlet.HttpServletRequest",
+ "javax.servlet.HttpServletResponse",
+ "javax.servlet.ServletConfig",
+ "javax.servlet.ServletContext",
+ "javax.ws.rs.core.SecurityContext"));
private final JaxrsResource parentResource;
/**
- * return type of the java javaMethod. Null if this is not a subresource locator.
+ * return type of the java javaMethod. Null if this is not a subresource
+ * locator.
*/
private IType returnedJavaType = null;
@@ -76,7 +88,8 @@
private final List<JavaMethodParameter> javaMethodParameters = new ArrayList<JavaMethodParameter>();
private IType returnedJavaType;
- public Builder(IMethod method, JaxrsResource parentResource, JaxrsMetamodel metamodel) {
+ public Builder(IMethod method, JaxrsResource parentResource,
+ JaxrsMetamodel metamodel) {
assert method != null;
assert parentResource != null;
assert metamodel != null;
@@ -131,8 +144,9 @@
if (producesAnnotation != null) {
annotations.add(producesAnnotation);
}
- JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod(javaMethod, parentResource,
- javaMethodParameters, returnedJavaType, annotations, metamodel);
+ JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod(
+ javaMethod, parentResource, javaMethodParameters,
+ returnedJavaType, annotations, metamodel);
return resourceMethod;
}
@@ -150,8 +164,10 @@
*
* @throws CoreException
*/
- private JaxrsResourceMethod(final IMethod javaMethod, final JaxrsResource parentResource,
- List<JavaMethodParameter> javaMethodParameters, IType returnedJavaType, List<Annotation> annotations,
+ private JaxrsResourceMethod(final IMethod javaMethod,
+ final JaxrsResource parentResource,
+ List<JavaMethodParameter> javaMethodParameters,
+ IType returnedJavaType, List<Annotation> annotations,
final JaxrsMetamodel metamodel) {
super(javaMethod, annotations, parentResource, metamodel);
this.parentResource = parentResource;
@@ -162,10 +178,12 @@
this.parentResource.addMethod(this);
}
- public int update(JavaMethodSignature methodSignature) throws JavaModelException {
+ public int update(JavaMethodSignature methodSignature)
+ throws JavaModelException {
int flag = F_NONE;
// method parameters, including annotations
- final List<JavaMethodParameter> methodParameters = methodSignature.getMethodParameters();
+ final List<JavaMethodParameter> methodParameters = methodSignature
+ .getMethodParameters();
if (!this.javaMethodParameters.equals(methodParameters)) {
this.javaMethodParameters.clear();
this.javaMethodParameters.addAll(methodParameters);
@@ -201,15 +219,13 @@
messages.addAll(validateMissingPathParamAnnotations());
messages.addAll(validateParamsWithContextAnnotation());
messages.addAll(validateSingleParamWithoutAnnotation());
- if(messages.size() > 0) {
- this.hasErrors(true);
- }
return messages;
}
/**
- * Validate that only one method parameter is not annotated with a JAX-RS annotation. This non-annotated parameter
- * is the "Entity parameter", coming from the client's request body, unmarshalled by the appropriate
+ * Validate that only one method parameter is not annotated with a JAX-RS
+ * annotation. This non-annotated parameter is the "Entity parameter",
+ * coming from the client's request body, unmarshalled by the appropriate
* {@link MesssageBodyReader}.
*
* @return
@@ -220,94 +236,127 @@
}
/**
- * Validates that the method parameters annotated with {@link Context} are of the supported types in the spec:
- * {@link UriInfo}, {@link HttpHeaders}, {@link ServletConfig}, {@link ServletContext}, {@link HttpServletRequest},
- * {@link Request}, {@link HttpServletResponse} and {@link Response}.
+ * Validates that the method parameters annotated with {@link Context} are
+ * of the supported types in the spec: {@link UriInfo}, {@link HttpHeaders},
+ * {@link ServletConfig}, {@link ServletContext}, {@link HttpServletRequest}
+ * , {@link Request}, {@link HttpServletResponse} and {@link Response}.
*
* @return
+ * @throws JavaModelException
*/
- private List<ValidatorMessage> validateParamsWithContextAnnotation() {
+ private List<ValidatorMessage> validateParamsWithContextAnnotation() throws JavaModelException {
final List<ValidatorMessage> messages = new ArrayList<ValidatorMessage>();
for (JavaMethodParameter parameter : this.javaMethodParameters) {
- final Annotation annotation = parameter.getAnnotation(Context.class.getName());
+ final Annotation annotation = parameter.getAnnotation(Context.class
+ .getName());
final String typeName = parameter.getTypeName();
- if (annotation != null && typeName != null && !CONTEXT_TYPE_NAMES.contains(typeName)) {
- final ValidatorMessage message = ValidatorMessage.create("This parameter type (" + typeName
- + ") cannot be annotated with @Context", this.getResource());
- message.setAttribute(IMarker.MARKER, JaxrsMetamodelBuilder.JAXRS_PROBLEM);
- message.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
- message.setAttribute(IMarker.CHAR_START, parameter.getRegion().getOffset());
- message.setAttribute(IMarker.CHAR_END, parameter.getRegion().getOffset()
- + parameter.getRegion().getLength());
- messages.add(message);
- Logger.debug("Validation message for {}: {}", this.getJavaElement().getElementName(),
- message.getAttribute(IMarker.MESSAGE));
+ if (annotation != null && typeName != null
+ && !CONTEXT_TYPE_NAMES.contains(typeName)) {
+ final String msg = NLS
+ .bind(ValidationMessages.INVALID_CONTEXT_ANNOTATION,
+ typeName);
+ ValidatorMessage validationMsg = createValidationMessage(msg, IMarker.SEVERITY_ERROR, parameter.getRegion().getOffset(), parameter.getRegion().getLength());
+ messages.add(validationMsg);
+ this.hasErrors(true);
}
}
- return messages;
+ return messages;
}
- private List<ValidatorMessage> validateMissingPathParamAnnotations() throws JavaModelException {
+ /**
+ * Validates that the @Path annotation parameters have a counterpart in the
+ * java method paramters, otherwise, issues some markers with a 'warning'
+ * severity.
+ *
+ * @return
+ * @throws JavaModelException
+ */
+ private List<ValidatorMessage> validateMissingPathParamAnnotations()
+ throws JavaModelException {
final List<ValidatorMessage> messages = new ArrayList<ValidatorMessage>();
final List<String> pathParamValueProposals = getPathParamValueProposals();
for (String proposal : pathParamValueProposals) {
boolean matching = false;
for (JavaMethodParameter parameter : this.javaMethodParameters) {
- final Annotation annotation = parameter.getAnnotation(PathParam.class.getName());
- if (annotation != null && annotation.getValue("value").equals(proposal)) {
+ final Annotation annotation = parameter
+ .getAnnotation(PathParam.class.getName());
+ if (annotation != null
+ && annotation.getValue("value").equals(proposal)) {
matching = true;
break;
}
}
if (!matching) {
- final ValidatorMessage message = ValidatorMessage.create("Missing @PathParam value: expected "
- + proposal, this.getResource());
- message.setAttribute(IMarker.MARKER, JaxrsMetamodelBuilder.JAXRS_PROBLEM);
- message.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+ final String msg = NLS
+ .bind(ValidationMessages.INVALID_PATHPARAM_VALUE,
+ proposal);
final ISourceRange nameRange = getJavaElement().getNameRange();
- message.setAttribute(IMarker.CHAR_START, nameRange.getOffset());
- message.setAttribute(IMarker.CHAR_END, nameRange.getOffset() + nameRange.getLength());
- messages.add(message);
- Logger.debug("Validation message for {}: {}", this.getJavaElement().getElementName(),
- message.getAttribute(IMarker.MESSAGE));
+ ValidatorMessage validationMsg = createValidationMessage(msg, IMarker.SEVERITY_WARNING, nameRange.getOffset(), nameRange.getLength());
+ messages.add(validationMsg);
}
}
return messages;
}
/**
- * Checks that the {@link PathParam} annotation values match the params in the {@link Path} annotations at the
- * method and the parent type levels.
+ * Checks that the {@link PathParam} annotation values match the params in
+ * the {@link Path} annotations at the method and the parent type levels.
*
* @return errors in case of mismatch, empty list otherwise.
+ * @throws JavaModelException
*/
- private List<ValidatorMessage> validateMissingPathValueInPathParamAnnotations() {
+ private List<ValidatorMessage> validateMissingPathValueInPathParamAnnotations() throws JavaModelException {
final List<ValidatorMessage> messages = new ArrayList<ValidatorMessage>();
final List<String> pathParamValueProposals = getPathParamValueProposals();
for (JavaMethodParameter parameter : this.javaMethodParameters) {
- final Annotation annotation = parameter.getAnnotation(PathParam.class.getName());
+ final Annotation annotation = parameter
+ .getAnnotation(PathParam.class.getName());
if (annotation != null) {
final String value = annotation.getValue("value");
if (!pathParamValueProposals.contains(value)) {
- final ValidatorMessage message = ValidatorMessage.create("Invalid @PathParam value: expected "
- + pathParamValueProposals, this.getResource());
- message.setAttribute(IMarker.MARKER, JaxrsMetamodelBuilder.JAXRS_PROBLEM);
- message.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
- message.setAttribute(IMarker.CHAR_START, annotation.getRegion().getOffset());
- message.setAttribute(IMarker.CHAR_END, annotation.getRegion().getOffset()
- + annotation.getRegion().getLength());
- messages.add(message);
- Logger.debug("Validation message for {}: {}", this.getJavaElement().getElementName(),
- message.getAttribute(IMarker.MESSAGE));
+ final String msg = NLS
+ .bind(ValidationMessages.INVALID_PATHPARAM_VALUE,
+ pathParamValueProposals);
+ final TypedRegion region = annotation.getRegion();
+ ValidatorMessage validationMsg = createValidationMessage(msg, IMarker.SEVERITY_ERROR, region.getOffset(), region.getLength());
+ hasErrors(true);
+ messages.add(validationMsg);
}
}
}
return messages;
}
+ /**
+ * Creates a validation message from the given parameters. The created validation messages is of the 'JAX-RS' type.
+ * @param msg the message to display
+ * @param severity the severity of the marker
+ * @param region the region that the validation marker points to
+ * @return the created validation message.
+ * @throws JavaModelException
+ */
+ private ValidatorMessage createValidationMessage(final String msg,
+ int severity, final int offset, int length) throws JavaModelException {
+ final ValidatorMessage validationMsg = ValidatorMessage.create(msg,
+ this.getResource());
+ validationMsg.setAttribute(IMarker.MARKER,
+ JaxrsMetamodelBuilder.JAXRS_PROBLEM);
+ validationMsg.setAttribute(IMarker.SEVERITY, severity);
+ validationMsg.setAttribute(IMarker.CHAR_START, offset);
+ validationMsg.setAttribute(IMarker.CHAR_END, offset + length);
+
+ Logger.debug("Validation message for {}: {}", this.getJavaElement()
+ .getElementName(), validationMsg.getAttribute(IMarker.MESSAGE));
+ return validationMsg;
+ }
+
+
/*
* (non-Javadoc)
- * @see org.jboss.tools.ws.jaxrs.core.internal.metamodel.IResourceMethod#hasErrors (boolean)
+ *
+ * @see
+ * org.jboss.tools.ws.jaxrs.core.internal.metamodel.IResourceMethod#hasErrors
+ * (boolean)
*/
@Override
public void hasErrors(final boolean h) {
@@ -319,7 +368,10 @@
/*
* (non-Javadoc)
- * @see org.jboss.tools.ws.jaxrs.core.internal.metamodel.IResourceMethod#getKind ()
+ *
+ * @see
+ * org.jboss.tools.ws.jaxrs.core.internal.metamodel.IResourceMethod#getKind
+ * ()
*/
@Override
public final EnumKind getKind() {
@@ -337,7 +389,9 @@
/*
* (non-Javadoc)
- * @see org.jboss.tools.ws.jaxrs.core.internal.metamodel.IResourceMethod# getParentResource()
+ *
+ * @see org.jboss.tools.ws.jaxrs.core.internal.metamodel.IResourceMethod#
+ * getParentResource()
*/
@Override
public final JaxrsResource getParentResource() {
@@ -359,7 +413,8 @@
public Annotation getHttpMethodAnnotation() {
for (IJaxrsHttpMethod httpMethod : getMetamodel().getAllHttpMethods()) {
- final Annotation annotation = getAnnotation(httpMethod.getJavaElement().getFullyQualifiedName());
+ final Annotation annotation = getAnnotation(httpMethod
+ .getJavaElement().getFullyQualifiedName());
if (annotation != null) {
return annotation;
}
@@ -407,14 +462,16 @@
public List<JavaMethodParameter> getJavaMethodParameters() {
return javaMethodParameters;
}
-
+
/*
* (non-Javadoc)
+ *
* @see java.lang.Object#toString()
*/
@Override
public final String toString() {
- return "ResourceMethod '" + parentResource.getName() + "." + getJavaElement().getElementName() + "' ("
+ return "ResourceMethod '" + parentResource.getName() + "."
+ + getJavaElement().getElementName() + "' ("
+ getKind().toString() + ")";
}
@@ -426,7 +483,8 @@
final String value = methodPathAnnotation.getValue("value");
proposals.addAll(extractParamsFromUriTemplateFragment(value));
}
- final Annotation typePathAnnotation = getParentResource().getPathAnnotation();
+ final Annotation typePathAnnotation = getParentResource()
+ .getPathAnnotation();
if (typePathAnnotation != null) {
final String value = typePathAnnotation.getValue("value");
proposals.addAll(extractParamsFromUriTemplateFragment(value));
@@ -435,19 +493,22 @@
}
/**
- * Extracts all the character sequences inside of curly braces ('{' and '}') and returns them as a list of strings
+ * Extracts all the character sequences inside of curly braces ('{' and '}')
+ * and returns them as a list of strings
*
* @param value
* the given value
* @return the list of character sequences, or an empty list
*/
- private static List<String> extractParamsFromUriTemplateFragment(String value) {
+ private static List<String> extractParamsFromUriTemplateFragment(
+ String value) {
List<String> params = new ArrayList<String>();
int beginIndex = -1;
while ((beginIndex = value.indexOf("{", beginIndex + 1)) != -1) {
int semicolonIndex = value.indexOf(":", beginIndex);
int closingCurlyBraketIndex = value.indexOf("}", beginIndex);
- int endIndex = semicolonIndex != -1 ? semicolonIndex : closingCurlyBraketIndex;
+ int endIndex = semicolonIndex != -1 ? semicolonIndex
+ : closingCurlyBraketIndex;
params.add(value.substring(beginIndex + 1, endIndex).trim());
}
return params;
Modified: branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/ValidationMessages.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/ValidationMessages.java 2012-02-28 12:54:26 UTC (rev 39167)
+++ branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/ValidationMessages.java 2012-02-28 14:43:32 UTC (rev 39168)
@@ -16,7 +16,11 @@
public class ValidationMessages extends NLS {
private static final String BUNDLE_NAME = ValidationMessages.class.getName(); //$NON-NLS-1$
- public static String unbound_parameter;
+ public static String INVALID_CONTEXT_ANNOTATION;
+
+ public static String INVALID_PATHPARAM_VALUE;
+
+ public static String LINE_NUMBER;
static {
NLS.initializeMessages(BUNDLE_NAME, ValidationMessages.class);
Modified: branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/ValidationMessages.properties
===================================================================
--- branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/ValidationMessages.properties 2012-02-28 12:54:26 UTC (rev 39167)
+++ branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/ValidationMessages.properties 2012-02-28 14:43:32 UTC (rev 39168)
@@ -1 +1,3 @@
-unbound_parameter = @PathParam annotation value {0} does not match any parameter of the same method or type @Path annotation(s).
\ No newline at end of file
+INVALID_CONTEXT_ANNOTATION=The parameter type ''{0}'' cannot be annotated with @Context
+INVALID_PATHPARAM_VALUE=Invalid @PathParam value: expected ''{0}''
+LINE_NUMBER=line {0}
\ No newline at end of file
12 years, 10 months
JBoss Tools SVN: r39167 - trunk/as/plugins/org.jboss.ide.eclipse.as.core.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-02-28 07:54:26 -0500 (Tue, 28 Feb 2012)
New Revision: 39167
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
Log:
JBIDE-11058 to trunk - renamed jboss_as7_config_file to jboss_config_file (forgot a file)
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2012-02-28 12:24:50 UTC (rev 39166)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2012-02-28 12:54:26 UTC (rev 39167)
@@ -1124,7 +1124,7 @@
supportsArgument="true">
</variable>
<variable
- name="jboss_as7_config_file"
+ name="jboss_config_file"
description="Returns the full path of the configuration file for the server who's name matches the variable, or, if none, the runtime who's name matches the variable"
resolver="org.jboss.ide.eclipse.as.core.resolvers.ConfigNameResolver"
supportsArgument="true">
@@ -1190,5 +1190,15 @@
</with></enablement>
</moduleArtifactAdapter>
</extension>
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.wst.server.core.IServer"
+ class="org.jboss.ide.eclipse.as.core.server.internal.ExtendedPropertiesServerAdapterFactory">
+ <adapter
+ type="org.jboss.ide.eclipse.as.core.Adapter1">
+ </adapter>
+ </factory>
+ </extension>
</plugin>
12 years, 10 months
JBoss Tools SVN: r39166 - trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2012-02-28 07:24:50 -0500 (Tue, 28 Feb 2012)
New Revision: 39166
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToManyMappingDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToOneMappingDefinition.java
Log:
https://issues.jboss.org/browse/JBIDE-11079
Hibernate extension mixed up OneToOne and OneToMany mappings
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToManyMappingDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToManyMappingDefinition.java 2012-02-28 11:54:47 UTC (rev 39165)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToManyMappingDefinition.java 2012-02-28 12:24:50 UTC (rev 39166)
@@ -20,9 +20,9 @@
import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JoinColumnsAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnsAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.MapKeyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OrderByAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
/**
@@ -49,11 +49,11 @@
}
public String getKey() {
- return MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
+ return MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY;
}
public String getAnnotationName() {
- return OneToOneAnnotation.ANNOTATION_NAME;
+ return OneToManyAnnotation.ANNOTATION_NAME;
}
public boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
@@ -66,10 +66,10 @@
private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
JoinTableAnnotation.ANNOTATION_NAME,
+ MapKeyAnnotation.ANNOTATION_NAME,
+ OrderByAnnotation.ANNOTATION_NAME,
JoinColumnAnnotation.ANNOTATION_NAME,
- JoinColumnsAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME
+ JoinColumnsAnnotation.ANNOTATION_NAME
};
private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
@@ -79,7 +79,7 @@
}
public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
- return factory.buildJavaOneToOneMapping(persistentAttribute);
+ return factory.buildJavaOneToManyMapping(persistentAttribute);
}
@Override
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToOneMappingDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToOneMappingDefinition.java 2012-02-28 11:54:47 UTC (rev 39165)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/definition/HibernateJavaOneToOneMappingDefinition.java 2012-02-28 12:24:50 UTC (rev 39166)
@@ -20,9 +20,9 @@
import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JoinColumnsAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.MapKeyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.OrderByAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnsAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
/**
@@ -49,11 +49,11 @@
}
public String getKey() {
- return MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY;
+ return MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
}
public String getAnnotationName() {
- return OneToManyAnnotation.ANNOTATION_NAME;
+ return OneToOneAnnotation.ANNOTATION_NAME;
}
public boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
@@ -66,10 +66,10 @@
private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
JoinTableAnnotation.ANNOTATION_NAME,
- MapKeyAnnotation.ANNOTATION_NAME,
- OrderByAnnotation.ANNOTATION_NAME,
JoinColumnAnnotation.ANNOTATION_NAME,
- JoinColumnsAnnotation.ANNOTATION_NAME
+ JoinColumnsAnnotation.ANNOTATION_NAME,
+ PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
+ PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME
};
private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
@@ -79,7 +79,7 @@
}
public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
- return factory.buildJavaOneToManyMapping(persistentAttribute);
+ return factory.buildJavaOneToOneMapping(persistentAttribute);
}
@Override
12 years, 10 months
JBoss Tools SVN: r39165 - trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-02-28 06:54:47 -0500 (Tue, 28 Feb 2012)
New Revision: 39165
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java
Log:
JBIDE-11063 to trunk
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java 2012-02-28 11:02:56 UTC (rev 39164)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEUtils.java 2012-02-28 11:54:47 UTC (rev 39165)
@@ -29,6 +29,7 @@
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
/*
* Some of this code will need to be abstracted out from JBossServer
@@ -100,7 +101,7 @@
// Cannot move this code to JBossServer because this requires an
// RSE-specific key!! Damn!
- if (server.getServerType().getId().equals(IJBossToolingConstants.SERVER_AS_70)) {
+ if (ServerUtil.isJBoss7(server.getServerType())) {
IPath p = new Path("standalone/deployments/");
return makeGlobal(server, p).toString();
} else {
12 years, 10 months
JBoss Tools SVN: r39164 - in trunk/as/plugins/org.jboss.ide.eclipse.as.core: properties and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-02-28 06:02:56 -0500 (Tue, 28 Feb 2012)
New Revision: 39164
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.70.default.ports.properties
trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.71.default.ports.properties
Log:
JBIDE-11058 to trunk - renamed jboss_as7_config_file to jboss_config_file
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java 2012-02-28 10:28:13 UTC (rev 39163)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java 2012-02-28 11:02:56 UTC (rev 39164)
@@ -34,7 +34,7 @@
public static final String JBOSS_CONFIG = "jboss_config"; //$NON-NLS-1$
public static final String JBOSS_CONFIG_DIR = "jboss_config_dir"; //$NON-NLS-1$
- public static final String JBOSS_AS7_CONFIG_FILE = "jboss_as7_config_file"; //$NON-NLS-1$
+ public static final String JBOSS_AS7_CONFIG_FILE = "jboss_config_file"; //$NON-NLS-1$
/*
* entry points to fill out the server name in these variable substitutions
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.70.default.ports.properties
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.70.default.ports.properties 2012-02-28 10:28:13 UTC (rev 39163)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.70.default.ports.properties 2012-02-28 11:02:56 UTC (rev 39164)
@@ -3,4 +3,4 @@
JBoss_Web_ATTRIBUTE=port
JBoss_Management=//*[local-name()="management-interfaces"]/*[local-name()="native-interface"]
JBoss_Management_ATTRIBUTE=port
-JBoss_Management_FILE=standalone/configuration/${jboss_as7_config_file}
\ No newline at end of file
+JBoss_Management_FILE=standalone/configuration/${jboss_config_file}
\ No newline at end of file
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.71.default.ports.properties
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.71.default.ports.properties 2012-02-28 10:28:13 UTC (rev 39163)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/properties/jboss.71.default.ports.properties 2012-02-28 11:02:56 UTC (rev 39164)
@@ -3,4 +3,4 @@
JBoss_Web_ATTRIBUTE=port
JBoss_Management=//*[local-name()="socket-binding-group"]/*[local-name()="socket-binding"][@name="management-native"]
JBoss_Management_ATTRIBUTE=port
-JBoss_Management_FILE=standalone/configuration/${jboss_as7_config_file}
\ No newline at end of file
+JBoss_Management_FILE=standalone/configuration/${jboss_config_file}
\ No newline at end of file
12 years, 10 months
JBoss Tools SVN: r39163 - in trunk/as/plugins: org.jboss.ide.eclipse.as.ui and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-02-28 05:28:13 -0500 (Tue, 28 Feb 2012)
New Revision: 39163
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/RequiredCredentialsDialog.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerPasswordSection.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
JBIDE-11071 and JBIDE-11055 to trunk
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2012-02-28 07:49:23 UTC (rev 39162)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2012-02-28 10:28:13 UTC (rev 39163)
@@ -31,7 +31,6 @@
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLEncoder;
import java.util.Date;
import org.eclipse.core.runtime.IPath;
@@ -40,9 +39,6 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
-import org.eclipse.equinox.security.storage.EncodingUtils;
-import org.eclipse.equinox.security.storage.ISecurePreferences;
-import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
import org.eclipse.equinox.security.storage.StorageException;
import org.eclipse.jst.server.core.IWebModule;
import org.eclipse.wst.server.core.IModule;
@@ -252,7 +248,7 @@
// first class parameters
public String getUsername() {
- return getAttribute(SERVER_USERNAME, ""); //$NON-NLS-1$
+ return getAttribute(SERVER_USERNAME, "admin"); //$NON-NLS-1$
}
public void setUsername(String name) {
setAttribute(SERVER_USERNAME, name);
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/RequiredCredentialsDialog.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/RequiredCredentialsDialog.java 2012-02-28 07:49:23 UTC (rev 39162)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/RequiredCredentialsDialog.java 2012-02-28 10:28:13 UTC (rev 39163)
@@ -69,8 +69,8 @@
Label top = new Label(main, SWT.NONE);
Label userLabel = new Label(main, SWT.NONE);
Label passLabel = new Label(main, SWT.NONE);
- final Text userText = new Text(main, SWT.DEFAULT);
- final Text passText = new Text(main, SWT.DEFAULT);
+ final Text userText = new Text(main, SWT.SINGLE | SWT.BORDER);
+ final Text passText = new Text(main, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
userText.setEditable(true);
passText.setEditable(true);
final Button saveCredentials = new Button(main, SWT.CHECK);
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerPasswordSection.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerPasswordSection.java 2012-02-28 07:49:23 UTC (rev 39162)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerPasswordSection.java 2012-02-28 10:28:13 UTC (rev 39163)
@@ -11,6 +11,7 @@
package org.jboss.ide.eclipse.as.ui.editor;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
@@ -68,12 +69,12 @@
Label username = toolkit.createLabel(composite, Messages.swf_Username);
username.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- String n = helper.getAttribute(IJBossToolingConstants.SERVER_USERNAME, ""); //$NON-NLS-1$
+ String n = ServerConverter.getJBossServer(server.getOriginal()).getUsername();
String p = ServerConverter.getJBossServer(server.getOriginal()).getPassword();
nameText = toolkit.createText(composite, n);
Label password = toolkit.createLabel(composite, Messages.swf_Password);
password.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- passText = toolkit.createText(composite, p);
+ passText = toolkit.createText(composite, p, SWT.SINGLE | SWT.PASSWORD);
passwordString = p;
d = new GridData(); d.grabExcessHorizontalSpace = true; d.widthHint = 100;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2012-02-28 07:49:23 UTC (rev 39162)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2012-02-28 10:28:13 UTC (rev 39163)
@@ -186,13 +186,13 @@
class="org.jboss.ide.eclipse.as.ui.editor.ServerPasswordSection"
id="org.jboss.ide.eclipse.as.ui.editor.passwordSection"
insertionId="org.eclipse.wst.server.editor.overview.left"
- order="10"
+ order="9"
typeIds="%AllJBossServerTypes"/>
<section
class="org.jboss.ide.eclipse.as.ui.editor.ServerModeSection"
id="org.jboss.ide.eclipse.as.ui.editor.serverModeSection"
insertionId="org.eclipse.wst.server.editor.overview.left"
- order="9"
+ order="10"
typeIds="%AllJBTServerTypes"/>
<!-- NEW_SERVER_ADAPTER Add the server editor sections for a new server above this line -->
12 years, 10 months
JBoss Tools SVN: r39162 - in branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui: src/org/jboss/tools/openshift/express/internal/core/behaviour and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-02-28 02:49:23 -0500 (Tue, 28 Feb 2012)
New Revision: 39162
Added:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ShowInWelcomePageActionProvider.java
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
Log:
[JBIDE-11052] added separate action to show welcome page on OpenShift server adapters
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-02-28 07:22:15 UTC (rev 39161)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-02-28 07:49:23 UTC (rev 39162)
@@ -171,6 +171,40 @@
sourcePathComputerId="org.eclipse.jst.server.generic.core.sourcePathComputer"/>
</extension>
+ <extension point="org.eclipse.ui.navigator.viewer">
+ <viewerContentBinding viewerId="org.eclipse.wst.server.ui.ServersView">
+ </viewerContentBinding>
+ <viewerActionBinding viewerId="org.eclipse.wst.server.ui.ServersView">
+ <includes>
+ <actionExtension
+ pattern="org.jboss.tools.openshift.express.ui.internal.ui.console.tailServerLogActionProvider"/>
+ </includes>
+ </viewerActionBinding>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.navigator.navigatorContent">
+ <actionProvider
+ class="org.jboss.tools.openshift.express.internal.ui.behaviour.ShowInWelcomePageActionProvider"
+ id="org.jboss.tools.openshift.express.internal.ui.behaviour.ShowInWelcomePageActionProvider">
+ <enablement>
+ <instanceof
+ value="org.eclipse.wst.server.core.IServer">
+ </instanceof>
+ </enablement>
+ </actionProvider>
+ </extension>
+ <extension point="org.eclipse.ui.navigator.viewer">
+ <viewerContentBinding viewerId="org.eclipse.wst.server.ui.ServersView">
+ </viewerContentBinding>
+ <viewerActionBinding viewerId="org.eclipse.wst.server.ui.ServersView">
+ <includes>
+ <actionExtension
+ pattern="org.jboss.tools.openshift.express.internal.ui.behaviour.ShowInWelcomePageActionProvider"/>
+ </includes>
+ </viewerActionBinding>
+ </extension>
+
<!-- Extensions to Server View to provide 'tail' of the remote server.log file -->
<extension point="org.eclipse.ui.navigator.navigatorContent">
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-02-28 07:22:15 UTC (rev 39161)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-02-28 07:49:23 UTC (rev 39162)
@@ -19,6 +19,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jgit.transport.URIish;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerAttributes;
@@ -35,6 +36,7 @@
import org.jboss.ide.eclipse.as.core.util.ServerCreationUtils;
import org.jboss.tools.openshift.egit.core.EGitUtils;
import org.jboss.tools.openshift.express.internal.core.console.UserModel;
+import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import org.jboss.tools.openshift.express.internal.ui.wizard.IOpenShiftExpressWizardModel;
import com.openshift.express.client.IApplication;
@@ -328,17 +330,25 @@
}
public static IProject findProjectForServersApplication(IServer server) {
+ IApplication app = findApplicationForServer(server);
+ if (app == null) {
+ return null;
+ }
+ return ExpressServerUtils.findProjectForApplication(app);
+ }
+
+ public static IApplication findApplicationForServer(IServer server) {
try {
String user = ExpressServerUtils.getExpressUsername(server);
IUser user2 = UserModel.getDefault().findUser(user);
String appName = ExpressServerUtils.getExpressApplicationName(server);
IApplication app = user2.getApplicationByName(appName);
- IProject destProj = ExpressServerUtils.findProjectForApplication(app);
- return destProj;
+ return app;
} catch(OpenShiftException ose) {
- //TODO log and throw core e
+ Logger.error(NLS.bind("Could not find application for server {0}", server.getName()));
+ return null;
}
- return null;
}
+
}
Added: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ShowInWelcomePageActionProvider.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ShowInWelcomePageActionProvider.java (rev 0)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ShowInWelcomePageActionProvider.java 2012-02-28 07:49:23 UTC (rev 39162)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.behaviour;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.ui.Messages;
+import org.jboss.ide.eclipse.as.ui.views.server.extensions.AbstractOpenBrowserServerAction;
+import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
+import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+
+import com.openshift.express.client.IApplication;
+import com.openshift.express.client.OpenShiftException;
+
+/**
+ * Action that shows the welcome page for a given openshift application. This is
+ * actually a copy of org.jboss.ide.eclipse.as.ui.views.server.extensions.
+ * ShowInWelcomePageActionProvider, should be consolidated at some point.
+ *
+ * @author Andre Dietisheim
+ */
+public class ShowInWelcomePageActionProvider extends AbstractOpenBrowserServerAction {
+
+ protected String getActionText() {
+ return Messages.ShowInWelcomePage_Action_Text;
+ }
+
+ protected boolean shouldAddForSelection(IStructuredSelection sel) {
+ IServer server = getSingleServer(sel);
+ boolean shouldAddForSelection = false;
+ /**
+ * TODO: move this logic to the server, allow this action to ask the
+ * server if it supports welcome page: ex. #hasWelcomePage
+ */
+ if (server != null) {
+ shouldAddForSelection =
+ ExpressServerUtils.isOpenShiftRuntime(server)
+ && accepts(server);
+ }
+ return shouldAddForSelection;
+ }
+
+ protected boolean accepts(IServer server) {
+ return server.getServerState() == IServer.STATE_STARTED;
+ }
+
+ /**
+ * TODO: move this logic to the server, allow this action to ask the
+ * server for welcome page: ex. #getWelcomePage
+ */
+ protected String getURL(IServer server) throws CoreException {
+ if (!ExpressServerUtils.isOpenShiftRuntime(server)) {
+ return null;
+ }
+ IApplication application = ExpressServerUtils.findApplicationForServer(server);
+ if (application == null) {
+ return null;
+ }
+ try {
+ return application.getApplicationUrl();
+ } catch (OpenShiftException e) {
+ IStatus status = OpenShiftUIActivator.createErrorStatus(
+ NLS.bind("Could not get application url for server {0}", server.getName()), e);
+ throw new CoreException(status);
+ }
+ }
+}
Property changes on: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ShowInWelcomePageActionProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
12 years, 10 months
JBoss Tools SVN: r39161 - in trunk/as/plugins: org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-02-28 02:22:15 -0500 (Tue, 28 Feb 2012)
New Revision: 39161
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/Fileset.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java
Log:
Remove code duplication for string substition. No jira.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/Fileset.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/Fileset.java 2012-02-28 07:21:49 UTC (rev 39160)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/Fileset.java 2012-02-28 07:22:15 UTC (rev 39161)
@@ -12,18 +12,13 @@
import java.io.File;
-import org.eclipse.core.internal.variables.StringSubstitutionEngine;
-import org.eclipse.core.internal.variables.StringVariableManager;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.archives.core.asf.DirectoryScanner;
import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
-import org.jboss.ide.eclipse.archives.webtools.IntegrationPlugin;
+import org.jboss.ide.eclipse.as.core.resolvers.ConfigNameResolver;
public class Fileset implements Cloneable {
@@ -54,17 +49,6 @@
return name + SEP + folder + SEP + includesPattern + SEP + excludesPattern;
}
- public static final String JBOSS_CONFIG_DIR_ARG = "${jboss_config_dir}"; //$NON-NLS-1$
- public static final String JBOSS_SERVER_ARG = "${jboss_config}"; //$NON-NLS-1$
-
- public static final String getConfigDirSubstitute(IRuntime rt) {
- return "${jboss_config_dir:" + rt.getName() + "}"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public static final String getServerSubstitute(IRuntime rt) {
- return "${jboss_config:" + rt.getName() + "}"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
/**
* @return the folder
*/
@@ -76,23 +60,7 @@
return getFolder(folder, runtime, true);
}
public static String getFolder(String folder, IRuntime runtime, boolean ignoreError) {
-
- String tmp = folder == null ? "" : folder; //$NON-NLS-1$
- if( runtime != null ) {
- tmp = tmp.replace(JBOSS_CONFIG_DIR_ARG, getConfigDirSubstitute(runtime));
- tmp = tmp.replace(JBOSS_SERVER_ARG, getServerSubstitute(runtime));
- }
- try {
- StringSubstitutionEngine engine = new StringSubstitutionEngine();
- tmp = engine.performStringSubstitution(tmp, true,
- true, StringVariableManager.getDefault());
- } catch( CoreException ce ) {
- if( !ignoreError ) {
- IntegrationPlugin.getDefault().getLog().log(
- new Status(IStatus.WARNING, IntegrationPlugin.PLUGIN_ID, ce.getMessage(), ce));
- }
- }
-
+ String tmp = new ConfigNameResolver().performSubstitutions(folder, runtime.getName(), ignoreError);
IPath p = new Path(tmp);
if( !p.isAbsolute() && runtime != null ) {
p = runtime.getLocation().append(p);
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java 2012-02-28 07:21:49 UTC (rev 39160)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java 2012-02-28 07:22:15 UTC (rev 39161)
@@ -45,30 +45,35 @@
* server-related replacements (adding variables) beforehand.
*
* @param dir1
- * @param serverName
+ * @param serverOrRuntimeName
* @return
*/
- public String performSubstitutions(String dir1, String serverName) {
+ public String performSubstitutions(String dir1, String serverOrRuntimeName) {
+ return performSubstitutions(dir1, serverOrRuntimeName, false);
+ }
+ public String performSubstitutions(String dir1, String serverOrRuntimeName, boolean ignoreError) {
+
String dir2 = null;
if( dir1 != null ) {
- dir2 = replace(dir1, ConfigNameResolver.JBOSS_CONFIG, serverName);
- dir2 = replace(dir2, ConfigNameResolver.JBOSS_CONFIG_DIR, serverName);
- dir2 = replace(dir2, ConfigNameResolver.JBOSS_AS7_CONFIG_FILE, serverName);
+ dir2 = replace(dir1, ConfigNameResolver.JBOSS_CONFIG, serverOrRuntimeName);
+ dir2 = replace(dir2, ConfigNameResolver.JBOSS_CONFIG_DIR, serverOrRuntimeName);
+ dir2 = replace(dir2, ConfigNameResolver.JBOSS_AS7_CONFIG_FILE, serverOrRuntimeName);
try {
StringSubstitutionEngine engine = new StringSubstitutionEngine();
dir2 = engine.performStringSubstitution(dir2, true,
true, StringVariableManager.getDefault());
} catch( CoreException ce ) {
- JBossServerCorePlugin.log(ce.getStatus());
+ if( !ignoreError)
+ JBossServerCorePlugin.log(ce.getStatus());
}
}
return dir2;
}
- private String replace(String original, String variable, String serverName) {
+ private String replace(String original, String variable, String serverOrRuntimeName) {
if( original != null ) {
- return original.replace(getVariablePattern(variable), getVariablePattern(variable, serverName));
+ return original.replace(getVariablePattern(variable), getVariablePattern(variable, serverOrRuntimeName));
}
return null;
}
@@ -77,8 +82,8 @@
return "${" + var + "}"; //$NON-NLS-1$ //$NON-NLS-2$
}
- private String getVariablePattern(String var, String serverName) {
- return "${" + var + ":" + serverName + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private String getVariablePattern(String var, String serverOrRuntimeName) {
+ return "${" + var + ":" + serverOrRuntimeName + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@@ -128,17 +133,22 @@
return null;
}
- private IJBossServerRuntime findJBossServerRuntime(String serverName) {
+ /**
+ * Return either a server by this name, or a runtime by this name
+ * @param serverOrRuntimeName
+ * @return
+ */
+ private IJBossServerRuntime findJBossServerRuntime(String serverOrRuntimeName) {
IServer[] servers = ServerCore.getServers();
for( int i = 0; i < servers.length; i++ ) {
- if( servers[i].getName().equals(serverName)) {
+ if( servers[i].getName().equals(serverOrRuntimeName)) {
return (IJBossServerRuntime) servers[i].getRuntime()
.loadAdapter(IJBossServerRuntime.class, new NullProgressMonitor());
}
}
IRuntime[] runtimes = ServerCore.getRuntimes();
for( int i = 0; i < runtimes.length; i++ ) {
- if( runtimes[i].getName().equals(serverName)) {
+ if( runtimes[i].getName().equals(serverOrRuntimeName)) {
return (IJBossServerRuntime) runtimes[i]
.loadAdapter(IJBossServerRuntime.class, new NullProgressMonitor());
}
12 years, 10 months