Author: mareshkau
Date: 2011-02-07 11:20:10 -0500 (Mon, 07 Feb 2011)
New Revision: 29053
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/IJSFValidationComponent.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/LocalizedMessage.java
Removed:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/components/IJSFValidationComponent.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFAbstractValidationComponent.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2SourceValidator.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2XMLValidator.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/components/JSF2ComponentFactory.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/util/JSF2ComponentRecognizer.java
Log:
https://issues.jboss.org/browse/JBIDE-7005, localized mesasge has been moved out from
jsf2validator to allow use this in non-ls validator.
Copied:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/IJSFValidationComponent.java
(from rev 29043,
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/components/IJSFValidationComponent.java)
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/IJSFValidationComponent.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/IJSFValidationComponent.java 2011-02-07
16:20:10 UTC (rev 29053)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jsf.web.validation;
+
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
+public interface IJSFValidationComponent{
+
+ int getLine();
+
+ int getStartOffSet();
+
+ int getLength();
+
+ String getValidationMessage();
+
+ Object[] getMessageParams();
+
+ String getType();
+
+ String getComponentResourceLocation();
+
+ int getSeverity();
+
+}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFAbstractValidationComponent.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFAbstractValidationComponent.java 2011-02-07
15:53:46 UTC (rev 29052)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFAbstractValidationComponent.java 2011-02-07
16:20:10 UTC (rev 29053)
@@ -11,7 +11,6 @@
package org.jboss.tools.jsf.web.validation;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.jboss.tools.jsf.web.validation.jsf2.components.IJSFValidationComponent;
public abstract class JSFAbstractValidationComponent implements
IJSFValidationComponent {
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/LocalizedMessage.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/LocalizedMessage.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/LocalizedMessage.java 2011-02-07
16:20:10 UTC (rev 29053)
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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.jsf.web.validation;
+
+import java.util.Locale;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.wst.validation.ValidatorMessage;
+import org.eclipse.wst.validation.internal.core.Message;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.jboss.tools.jsf.jsf2.util.JSF2ResourceUtil;
+import org.jboss.tools.jsf.web.validation.jsf2.JSF2XMLValidator;
+import org.jboss.tools.jsf.web.validation.jsf2.components.JSF2AttrTempComponent;
+import org.jboss.tools.jsf.web.validation.jsf2.components.JSF2CompositeTempComponent;
+import org.jboss.tools.jsf.web.validation.jsf2.components.JSF2URITempComponent;
+import org.jboss.tools.jsf.web.validation.jsf2.util.JSF2ValidatorConstants;
+/**
+ * @author mareshkau
+ *
+ */
+@SuppressWarnings("restriction")
+public class LocalizedMessage extends Message {
+ private IJSFValidationComponent component;
+
+ private LocalizedMessage(){}
+
+ public static LocalizedMessage createJSF2LocalizedMessage(IJSFValidationComponent
component,
+ IFile validateFile){
+ LocalizedMessage jsf2LocMessage = new LocalizedMessage();
+ jsf2LocMessage.component = component;
+ jsf2LocMessage.setAttribute("problemType", JSF2XMLValidator.JSF2_PROBLEM_ID);
//$NON-NLS-1$
+ jsf2LocMessage.setAttribute(JSF2ValidatorConstants.JSF2_TYPE_KEY, component
+ .getType());
+ jsf2LocMessage.setAttribute(
+ "validateResourcePath", validateFile == null ? "" :
validateFile.getFullPath().toString()); //$NON-NLS-1$//$NON-NLS-2$
+ jsf2LocMessage.setAttribute(JSF2ResourceUtil.COMPONENT_RESOURCE_PATH_KEY,
+ component.getComponentResourceLocation());
+ jsf2LocMessage.setAttribute(IMarker.LINE_NUMBER, jsf2LocMessage.getLineNumber());
+ jsf2LocMessage.setAttribute(IMarker.SEVERITY, 1);
+ jsf2LocMessage.setAttribute(ValidatorMessage.ValidationId,
"org.jboss.tools.jsf.jsf2.source"); //$NON-NLS-1$
+ if (component instanceof JSF2URITempComponent) {
+ jsf2LocMessage.setAttribute(JSF2ValidatorConstants.JSF2_URI_NAME_KEY,
+ ((JSF2URITempComponent) component).getURI());
+ } else if (component instanceof JSF2AttrTempComponent) {
+ jsf2LocMessage.setAttribute(JSF2ValidatorConstants.JSF2_ATTR_NAME_KEY,
+ ((JSF2AttrTempComponent) component).getName());
+ jsf2LocMessage.setAttribute(JSF2ResourceUtil.JSF2_COMPONENT_NAME,
((JSF2AttrTempComponent) component).getElementName());
+ } else if (component instanceof JSF2CompositeTempComponent) {
+ String[] attrNames = ((JSF2CompositeTempComponent) component)
+ .getAttrNames();
+ if (attrNames != null) {
+ for (int i = 0; i < attrNames.length; i++) {
+ jsf2LocMessage.setAttribute(
+ JSF2ValidatorConstants.JSF2_ATTR_NAME_KEY
+ + String.valueOf(i), attrNames[i]);
+ }
+ jsf2LocMessage.setAttribute(JSF2ResourceUtil.JSF2_COMPONENT_NAME,
((JSF2CompositeTempComponent) component).getElement().getLocalName());
+ }
+ }
+ jsf2LocMessage.setAttribute(IMarker.MESSAGE,jsf2LocMessage.getText());
+ return jsf2LocMessage;
+ }
+
+ @Override
+ public int getLineNumber() {
+ return component.getLine();
+ }
+
+ @Override
+ public int getLength() {
+ return component.getLength();
+ }
+
+ @Override
+ public int getOffset() {
+ return component.getStartOffSet();
+ }
+
+ @Override
+ public String getText() {
+ return component.getValidationMessage();
+ }
+
+ @Override
+ public String getText(Locale locale) {
+ return component.getValidationMessage();
+ }
+
+ @Override
+ public String getText(Locale locale, ClassLoader classLoader) {
+ return component.getValidationMessage();
+ }
+
+ @Override
+ public String getText(ClassLoader classLoader) {
+ return component.getValidationMessage();
+ }
+
+ @Override
+ public int getSeverity() {
+ return IMessage.NORMAL_SEVERITY;
+ }
+}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2SourceValidator.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2SourceValidator.java 2011-02-07
15:53:46 UTC (rev 29052)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2SourceValidator.java 2011-02-07
16:20:10 UTC (rev 29053)
@@ -11,7 +11,6 @@
package org.jboss.tools.jsf.web.validation.jsf2;
-import java.util.Locale;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
@@ -21,22 +20,16 @@
import org.eclipse.jface.text.IRegion;
import org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator;
import org.eclipse.wst.sse.ui.internal.reconcile.validator.IncrementalHelper;
-import org.eclipse.wst.validation.ValidatorMessage;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
import org.eclipse.wst.validation.internal.provisional.core.IValidator;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.jboss.tools.jsf.JSFModelPlugin;
import org.jboss.tools.jsf.jsf2.model.JSF2ComponentModelManager;
-import org.jboss.tools.jsf.jsf2.util.JSF2ResourceUtil;
-import org.jboss.tools.jsf.web.validation.jsf2.components.IJSFValidationComponent;
-import org.jboss.tools.jsf.web.validation.jsf2.components.JSF2AttrTempComponent;
-import org.jboss.tools.jsf.web.validation.jsf2.components.JSF2CompositeTempComponent;
-import org.jboss.tools.jsf.web.validation.jsf2.components.JSF2URITempComponent;
-import org.jboss.tools.jsf.web.validation.jsf2.util.JSF2ValidatorConstants;
+import org.jboss.tools.jsf.web.validation.IJSFValidationComponent;
+import org.jboss.tools.jsf.web.validation.LocalizedMessage;
/**
* Validates when we change smth in file
@@ -104,7 +97,7 @@
try {
resource.deleteMarkers(JSF2XMLValidator.JSF2_PROBLEM_ID, false,
IResource.DEPTH_INFINITE);
for (int i = 0; i < validationComponents.length; i++) {
- Message locMessage = new LocalizedMessage(validationComponents[i], validateFile);
+ Message locMessage =
LocalizedMessage.createJSF2LocalizedMessage(validationComponents[i], validateFile);
reporter.addMessage(this, locMessage);
IMarker marker = resource.createMarker(JSF2XMLValidator.JSF2_PROBLEM_ID);
marker.setAttributes(locMessage.getAttributes());
@@ -114,86 +107,4 @@
}
}
-
- private static class LocalizedMessage extends Message {
-
- private IJSFValidationComponent component;
-
- public LocalizedMessage(IJSFValidationComponent component,
- IFile validateFile) {
- this.component = component;
- setAttribute("problemType", JSF2XMLValidator.JSF2_PROBLEM_ID);
//$NON-NLS-1$
- setAttribute(JSF2ValidatorConstants.JSF2_TYPE_KEY, component
- .getType());
- setAttribute(
- "validateResourcePath", validateFile == null ? "" :
validateFile.getFullPath().toString()); //$NON-NLS-1$//$NON-NLS-2$
- setAttribute(JSF2ResourceUtil.COMPONENT_RESOURCE_PATH_KEY,
- component.getComponentResourceLocation());
- setAttribute(IMarker.LINE_NUMBER, getLineNumber());
- setAttribute(IMarker.SEVERITY, 1);
- setAttribute(ValidatorMessage.ValidationId,
"org.jboss.tools.jsf.jsf2.source"); //$NON-NLS-1$
- if (component instanceof JSF2URITempComponent) {
- setAttribute(JSF2ValidatorConstants.JSF2_URI_NAME_KEY,
- ((JSF2URITempComponent) component).getURI());
- } else if (component instanceof JSF2AttrTempComponent) {
- setAttribute(JSF2ValidatorConstants.JSF2_ATTR_NAME_KEY,
- ((JSF2AttrTempComponent) component).getName());
- setAttribute(JSF2ResourceUtil.JSF2_COMPONENT_NAME, ((JSF2AttrTempComponent)
component).getElementName());
- } else if (component instanceof JSF2CompositeTempComponent) {
- String[] attrNames = ((JSF2CompositeTempComponent) component)
- .getAttrNames();
- if (attrNames != null) {
- for (int i = 0; i < attrNames.length; i++) {
- setAttribute(
- JSF2ValidatorConstants.JSF2_ATTR_NAME_KEY
- + String.valueOf(i), attrNames[i]);
- }
- setAttribute(JSF2ResourceUtil.JSF2_COMPONENT_NAME, ((JSF2CompositeTempComponent)
component).getElement().getLocalName());
- }
- }
- setAttribute(IMarker.MESSAGE,getText());
- }
-
- @Override
- public int getLineNumber() {
- return component.getLine();
- }
-
- @Override
- public int getLength() {
- return component.getLength();
- }
-
- @Override
- public int getOffset() {
- return component.getStartOffSet();
- }
-
- @Override
- public String getText() {
- return component.getValidationMessage();
- }
-
- @Override
- public String getText(Locale locale) {
- return component.getValidationMessage();
- }
-
- @Override
- public String getText(Locale locale, ClassLoader classLoader) {
- return component.getValidationMessage();
- }
-
- @Override
- public String getText(ClassLoader classLoader) {
- return component.getValidationMessage();
- }
-
- @Override
- public int getSeverity() {
- return IMessage.NORMAL_SEVERITY;
- }
-
- }
-
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2XMLValidator.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2XMLValidator.java 2011-02-07
15:53:46 UTC (rev 29052)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/JSF2XMLValidator.java 2011-02-07
16:20:10 UTC (rev 29053)
@@ -26,7 +26,7 @@
import org.jboss.tools.jsf.JSFModelPlugin;
import org.jboss.tools.jsf.jsf2.model.JSF2ComponentModelManager;
import org.jboss.tools.jsf.jsf2.util.JSF2ComponentUtil;
-import org.jboss.tools.jsf.web.validation.jsf2.components.IJSFValidationComponent;
+import org.jboss.tools.jsf.web.validation.IJSFValidationComponent;
import org.jboss.tools.jsf.web.validation.jsf2.util.JSF2ComponentRecognizer;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.PageContextFactory;
Deleted:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/components/IJSFValidationComponent.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/components/IJSFValidationComponent.java 2011-02-07
15:53:46 UTC (rev 29052)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/components/IJSFValidationComponent.java 2011-02-07
16:20:10 UTC (rev 29053)
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.jsf.web.validation.jsf2.components;
-
-/**
- *
- * @author yzhishko
- *
- */
-
-public interface IJSFValidationComponent {
-
- int getLine();
-
- int getStartOffSet();
-
- int getLength();
-
- String getValidationMessage();
-
- Object[] getMessageParams();
-
- String getType();
-
- String getComponentResourceLocation();
-
- int getSeverity();
-
-}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/components/JSF2ComponentFactory.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/components/JSF2ComponentFactory.java 2011-02-07
15:53:46 UTC (rev 29052)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/components/JSF2ComponentFactory.java 2011-02-07
16:20:10 UTC (rev 29053)
@@ -22,6 +22,7 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.jboss.tools.jsf.jsf2.model.JSF2ComponentModelManager;
+import org.jboss.tools.jsf.web.validation.IJSFValidationComponent;
import org.jboss.tools.jsf.web.validation.jsf2.util.JSF2ValidatorConstants;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/util/JSF2ComponentRecognizer.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/util/JSF2ComponentRecognizer.java 2011-02-07
15:53:46 UTC (rev 29052)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/jsf2/util/JSF2ComponentRecognizer.java 2011-02-07
16:20:10 UTC (rev 29053)
@@ -18,7 +18,7 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.jboss.tools.jsf.jsf2.util.JSF2ResourceUtil;
-import org.jboss.tools.jsf.web.validation.jsf2.components.IJSFValidationComponent;
+import org.jboss.tools.jsf.web.validation.IJSFValidationComponent;
import org.jboss.tools.jsf.web.validation.jsf2.components.JSF2ComponentFactory;
/**