Author: akazakov
Date: 2009-10-15 08:31:45 -0400 (Thu, 15 Oct 2009)
New Revision: 18105
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityConfigurationBlock.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityPreferencePage.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityPreferencesMessages.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityPreferencesMessages.properties
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/preferences/
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/preferences/SeverityPreferences.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFSeverityPreferencesMessages.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFSeverityPreferencesMessages.properties
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFValidatorConfigurationBlock.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFValidatorPreferencePage.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/preferences/
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/preferences/JSFPreferenceInitializer.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/preferences/JSFSeverityPreferences.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFValidationMessages.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/messages.properties
trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/validator.exsd
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ContextValidationHelper.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatingProjectSet.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationContext.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationErrorManager.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/ELReference.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidatingProjectSet.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationContext.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationContextProvider.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationErrorManager.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidator.java
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolution.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolutionImpl.java
trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.properties
trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml
trunk/jsf/plugins/org.jboss.tools.jsf/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-4978
Modified: trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF 2009-10-15 11:23:11
UTC (rev 18104)
+++ trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF 2009-10-15 12:31:45
UTC (rev 18105)
@@ -13,14 +13,7 @@
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.jboss.tools.common;singleton:=true
Bundle-Localization: plugin
-Export-Package: org.jboss.tools.common,
- org.jboss.tools.common.log,
- org.jboss.tools.common.reporting,
- org.jboss.tools.common.text,
- org.jboss.tools.common.util,
- org.jboss.tools.common.xml,
- org.jboss.tools.common.zip,
- org.apache.commons.codec,
+Export-Package: org.apache.commons.codec,
org.apache.commons.codec.binary,
org.apache.commons.codec.digest,
org.apache.commons.codec.language,
@@ -127,6 +120,14 @@
org.apache.xml.resolver.readers,
org.apache.xml.resolver.tools,
org.apache.xml.serialize,
+ org.jboss.tools.common,
+ org.jboss.tools.common.log,
+ org.jboss.tools.common.preferences,
+ org.jboss.tools.common.reporting,
+ org.jboss.tools.common.text,
+ org.jboss.tools.common.util,
+ org.jboss.tools.common.xml,
+ org.jboss.tools.common.zip,
org.w3c.dom.html,
org.w3c.dom.ls
Require-Bundle: org.eclipse.core.runtime,
@@ -136,7 +137,9 @@
org.eclipse.ui,
org.eclipse.ui.ide,
org.eclipse.wst.common.uriresolver;visibility:=reexport,
-
org.eclipse.core.net
+
org.eclipse.core.net,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.ui
Bundle-Version: 2.0.0.qualifier
Bundle-ActivationPolicy: lazy
Bundle-ManifestVersion: 2
Added:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/preferences/SeverityPreferences.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/preferences/SeverityPreferences.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/preferences/SeverityPreferences.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.common.preferences;
+
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jdt.core.JavaCore;
+
+/**
+ * Constants for names of seam preferences.
+ * Static accesses to seam preferences.
+ *
+ * Framework for Severity preferences.
+ * 1) Create a class which extends SeverityPreferences
+ * 2) Add constant using static method createSeverityOption(String)
+ * Put it under relevant section, e.g. //components, or create new section
+ * in the sub-class
+ * 3) Add in messages.properties in core plug-in of the sub-class
+ * error message with the same name
+ * 4) Add constant and property named
<ID>ValidatorConfigurationBlock_pb_%name%_label,
+ * where %name% is produced from constant name in Preferences like AAA_BBB_CCC ->
aaaBbbCcc
+ * to <ID>PreferencesMessages.java
+ * and <ID>PreferencesMessages.properties
+ * in UI plug-in.
+ * Put these entries under relevant section. For a new section add constant and
property
+ * <ID>ValidatorConfigurationBlock_section_%newSectionName%
+ * 5) In class <ID>ValidatorConfigurationBlock (in UI plug-in)
+ * modify SectionDescription constants, according to instruction there.
+ *
+ * @author Viacheslav Kabanovich, Alexey Kazakov
+ */
+public abstract class SeverityPreferences {
+
+ public static final String ERROR = "error"; //$NON-NLS-1$
+ public static final String WARNING = "warning"; //$NON-NLS-1$
+ public static final String IGNORE = "ignore"; //$NON-NLS-1$
+
+ public static final String ENABLE = JavaCore.ENABLED;
+ public static final String DISABLE = JavaCore.DISABLED;
+
+ abstract protected Set<String> getSeverityOptionNames();
+
+ abstract protected String createSeverityOption(String shortName);
+
+ abstract protected String getPluginId();
+
+ public IEclipsePreferences getProjectPreferences(IProject project) {
+ return new ProjectScope(project).getNode(getPluginId());
+ }
+
+ public IEclipsePreferences getDefaultPreferences() {
+ return new DefaultScope().getNode(getPluginId());
+ }
+
+ public IEclipsePreferences getInstancePreferences() {
+ return new InstanceScope().getNode(getPluginId());
+ }
+
+ public String getProjectPreference(IProject project, String key) {
+ IEclipsePreferences p = getProjectPreferences(project);
+ if(p == null) {
+ return null;
+ }
+ String value = p.get(key, null);
+ return value != null ? value : getInstancePreference(key);
+ }
+
+ public String getInstancePreference(String key) {
+ IEclipsePreferences p = getInstancePreferences();
+ String value = p == null ? null : p.get(key, null);
+ return value != null ? value : getDefaultPreference(key);
+ }
+
+ public String getDefaultPreference(String key) {
+ IEclipsePreferences p = getDefaultPreferences();
+ if(p == null) {
+ return null;
+ }
+ return p.get(key, null);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/preferences/SeverityPreferences.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolution.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolution.java 2009-10-15
11:23:11 UTC (rev 18104)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolution.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -71,4 +71,9 @@
* @return last segment. May return null.
*/
ELSegment getLastSegment();
+
+ /**
+ * @return the number of resolved segments
+ */
+ int getNumberOfResolvedSegments();
}
\ No newline at end of file
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolutionImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolutionImpl.java 2009-10-15
11:23:11 UTC (rev 18104)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolutionImpl.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -207,4 +207,20 @@
}
return null;
}
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.common.el.core.resolver.ELResolution#getNumberOfResolvedSegments()
+ */
+ public int getNumberOfResolvedSegments() {
+ int i = 0;
+ for (ELSegment segment : segments) {
+ if(segment.isResolved()) {
+ i++;
+ } else {
+ break;
+ }
+ }
+ return i;
+ }
}
\ No newline at end of file
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityConfigurationBlock.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityConfigurationBlock.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityConfigurationBlock.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.common.model.ui.preferences;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock;
+import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+import org.jboss.tools.common.preferences.SeverityPreferences;
+
+/**
+ * Find in SeverirtyPreferences the instruction to Framework for Severity preferences
+ * To modify section descriptions:
+ * 1) If new option is to be added to existing description,
+ * add array of two String objects, where first is the preference name
+ * defined in SeverityPreferences, and second is label defined in
+ * SeverityPreferencesMessages (do not forget put property to
SeverirtyPreferencesMessages.properties
+ * and constant to SeverityPreferencesMessages.java)
+ *
+ * 2) If new section named A is to be created create constant
+ * private static SectionDescription SECTION_A = new SectionDescription(
+ * SeamPreferencesMessages.SeamValidatorConfigurationBlock_section_a,
+ * new String[][]{
+ * }
+ * );
+ * create required constant and property in SeverityPreferencesMessages,
+ * and add SECTION_A to array ALL_SECTIONS.
+ *
+ * @author Viacheslav Kabanovich
+ */
+abstract public class SeverityConfigurationBlock extends OptionsConfigurationBlock {
+
+ protected static final String ERROR = SeverityPreferences.ERROR;
+ protected static final String WARNING = SeverityPreferences.WARNING;
+ protected static final String IGNORE = SeverityPreferences.IGNORE;
+
+ protected static final String ENABLED = JavaCore.ENABLED;
+ protected static final String DISABLED = JavaCore.DISABLED;
+
+ protected abstract Composite createStyleTabContent(Composite folder);
+
+ public SeverityConfigurationBlock(IStatusChangeListener context,
+ IProject project, Key[] allKeys,
+ IWorkbenchPreferenceContainer container) {
+ super(context, project, allKeys, container);
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ setShell(parent.getShell());
+
+ Composite mainComp = new Composite(parent, SWT.NONE);
+ mainComp.setFont(parent.getFont());
+ GridLayout layout= new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ mainComp.setLayout(layout);
+
+ Composite commonComposite = createStyleTabContent(mainComp);
+ GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
+ gridData.heightHint = convertHeightInCharsToPixels(parent,20);
+ commonComposite.setLayoutData(gridData);
+
+ validateSettings(null, null, null);
+
+ return mainComp;
+ }
+
+ private int convertHeightInCharsToPixels(Control control,int chars) {
+ Font font = control.getFont();
+ GC gc = new GC(font.getDevice());
+ gc.setFont(font);
+ FontMetrics fFontMetrics = gc.getFontMetrics();
+ gc.dispose();
+ return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
+ }
+
+ @Override
+ protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
+ String title= SeverityPreferencesMessages.ValidatorConfigurationBlock_needsbuild_title;
+ String message;
+ if (workspaceSettings) {
+ message=
SeverityPreferencesMessages.ValidatorConfigurationBlock_needsfullbuild_message;
+ } else {
+ message=
SeverityPreferencesMessages.ValidatorConfigurationBlock_needsprojectbuild_message;
+ }
+ return new String[] { title, message };
+ }
+
+ @Override
+ protected void validateSettings(Key changedKey, String oldValue,
+ String newValue) {
+ if (!areSettingsEnabled()) {
+ return;
+ }
+
+ fContext.statusChanged(new StatusInfo());
+ }
+
+ public static class SectionDescription {
+ public String label;
+ public OptionDescription[] options;
+
+ public SectionDescription(String label, String[][] optionLabelsAndKeys, String
pluginId) {
+ this.label = label;
+ options = new OptionDescription[optionLabelsAndKeys.length];
+ for (int i = 0; i < options.length; i++) {
+ options[i] = new OptionDescription(optionLabelsAndKeys[i][0],
optionLabelsAndKeys[i][1], pluginId);
+ }
+ }
+ }
+
+ public static class OptionDescription {
+ public String label;
+ public Key key;
+
+ public OptionDescription(String keyName, String label, String pluginId) {
+ this.label = label;
+ key = getKey(pluginId, keyName);
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityConfigurationBlock.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityPreferencePage.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityPreferencePage.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityPreferencePage.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.common.model.ui.preferences;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public abstract class SeverityPreferencePage extends PropertyAndPreferencePage {
+
+ protected abstract SeverityConfigurationBlock getConfigurationBlock();
+
+ @Override
+ protected Control createPreferenceContent(Composite composite) {
+ return getConfigurationBlock().createContents(composite);
+ }
+
+ @Override
+ protected boolean hasProjectSpecificOptions(IProject project) {
+ return getConfigurationBlock().hasProjectSpecificOptions(project);
+ }
+
+ /*
+ * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (getConfigurationBlock() != null) {
+ getConfigurationBlock().dispose();
+ }
+ super.dispose();
+ }
+
+ /*
+ * @see
org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
+ */
+ @Override
+ protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
+ super.enableProjectSpecificSettings(useProjectSpecificSettings);
+ if (getConfigurationBlock() != null) {
+ getConfigurationBlock().useProjectSpecificSettings(useProjectSpecificSettings);
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
+ */
+ @Override
+ protected void performDefaults() {
+ super.performDefaults();
+ if (getConfigurationBlock() != null) {
+ getConfigurationBlock().performDefaults();
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+ */
+ @Override
+ public boolean performOk() {
+ if (getConfigurationBlock() != null && !getConfigurationBlock().performOk()) {
+ return false;
+ }
+ return super.performOk();
+ }
+
+ /*
+ * @see org.eclipse.jface.preference.IPreferencePage#performApply()
+ */
+ @Override
+ public void performApply() {
+ if (getConfigurationBlock() != null) {
+ getConfigurationBlock().performApply();
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityPreferencePage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityPreferencesMessages.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityPreferencesMessages.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityPreferencesMessages.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.common.model.ui.preferences;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class SeverityPreferencesMessages extends NLS {
+
+ private static final String BUNDLE_NAME =
"org.jboss.tools.common.model.ui.preferences.SeverityPreferencesMessages";
//$NON-NLS-1$
+
+ public static String ValidatorConfigurationBlock_needsbuild_title;
+ public static String ValidatorConfigurationBlock_needsfullbuild_message;
+ public static String ValidatorConfigurationBlock_needsprojectbuild_message;
+
+ public static String VALIDATOR_CONFIGURATION_BLOCK_ERROR;
+ public static String VALIDATOR_CONFIGURATION_BLOCK_IGNORE;
+ public static String VALIDATOR_CONFIGURATION_BLOCK_WARNING;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, SeverityPreferencesMessages.class);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityPreferencesMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityPreferencesMessages.properties
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityPreferencesMessages.properties
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityPreferencesMessages.properties 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,19 @@
+##################################################################################
+### Copyright (c) 2007 Red Hat, Inc.
+### Distributed under license by Red Hat, Inc. All rights reserved.
+### This program is made available under the terms of the
+### Eclipse Public License v1.0 which accompanies this distribution,
+### and is available at
http://www.eclipse.org/legal/epl-v10.html
+###
+### Contributors:
+### Red Hat, Inc. - initial API and implementation
+##################################################################################
+
+#Preferences Page
+ValidatorConfigurationBlock_needsbuild_title=Validator Settings Changed
+ValidatorConfigurationBlock_needsfullbuild_message=The validator settings have changed. A
full rebuild is required for changes to take effect. Do the full build now?
+ValidatorConfigurationBlock_needsprojectbuild_message=The validator settings have
changed. A rebuild of the project is required for changes to take effect. Build the
project now?
+
+VALIDATOR_CONFIGURATION_BLOCK_ERROR=Error
+VALIDATOR_CONFIGURATION_BLOCK_WARNING=Warning
+VALIDATOR_CONFIGURATION_BLOCK_IGNORE=Ignore
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/preferences/SeverityPreferencesMessages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/META-INF/MANIFEST.MF 2009-10-15 11:23:11 UTC
(rev 18104)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/META-INF/MANIFEST.MF 2009-10-15 12:31:45 UTC
(rev 18105)
@@ -6,8 +6,9 @@
Bundle-SymbolicName: org.jboss.tools.jsf;singleton:=true
Bundle-Localization: plugin
Export-Package: org.jboss.tools.jsf,
+ org.jboss.tools.jsf.facelet.model,
+ org.jboss.tools.jsf.jsf2.model,
org.jboss.tools.jsf.messages,
- org.jboss.tools.jsf.facelet.model,
org.jboss.tools.jsf.model,
org.jboss.tools.jsf.model.handlers,
org.jboss.tools.jsf.model.handlers.bean,
@@ -22,12 +23,13 @@
org.jboss.tools.jsf.model.impl,
org.jboss.tools.jsf.model.pv,
org.jboss.tools.jsf.model.pv.handler,
+ org.jboss.tools.jsf.preferences,
org.jboss.tools.jsf.project,
org.jboss.tools.jsf.project.capabilities,
org.jboss.tools.jsf.web,
org.jboss.tools.jsf.web.helpers.context,
org.jboss.tools.jsf.web.pattern,
- org.jboss.tools.jsf.jsf2.model
+ org.jboss.tools.jsf.web.validation
Require-Bundle: org.jboss.tools.jst.web;visibility:=reexport,
org.jboss.tools.jst.web.kb;visibility:=reexport,
org.jboss.tools.common.el.core,
@@ -40,7 +42,8 @@
org.eclipse.wst.common.frameworks,
org.eclipse.wst.common.modulecore,
org.eclipse.wst.validation,
- org.eclipse.jdt.core.manipulation;bundle-version="1.3.0"
+ org.eclipse.jdt.core.manipulation,
+ org.eclipse.jst.j2ee
Bundle-Version: 2.0.0
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml 2009-10-15 11:23:11 UTC (rev 18104)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml 2009-10-15 12:31:45 UTC (rev 18105)
@@ -462,4 +462,8 @@
</contribution>
</extension>
-</plugin>
+ <extension point="org.eclipse.core.runtime.preferences">
+ <initializer
class="org.jboss.tools.jsf.preferences.JSFPreferenceInitializer"/>
+ </extension>
+
+</plugin>
\ No newline at end of file
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/preferences/JSFPreferenceInitializer.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/preferences/JSFPreferenceInitializer.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/preferences/JSFPreferenceInitializer.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.jboss.tools.jsf.JSFModelPlugin;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class JSFPreferenceInitializer extends AbstractPreferenceInitializer {
+
+ public JSFPreferenceInitializer() {}
+
+ @Override
+ public void initializeDefaultPreferences() {
+
+ IEclipsePreferences defaultPreferences = ((IScopeContext) new
DefaultScope()).getNode(JSFModelPlugin.PLUGIN_ID);
+ for (String name : JSFSeverityPreferences.SEVERITY_OPTION_NAMES) {
+ defaultPreferences.put(name, JSFSeverityPreferences.ERROR);
+ }
+ defaultPreferences.put(JSFSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME,
JSFSeverityPreferences.IGNORE);
+ defaultPreferences.put(JSFSeverityPreferences.UNKNOWN_EL_VARIABLE_PROPERTY_NAME,
JSFSeverityPreferences.WARNING);
+ defaultPreferences.put(JSFSeverityPreferences.UNPAIRED_GETTER_OR_SETTER,
JSFSeverityPreferences.IGNORE);
+ defaultPreferences.put(JSFSeverityPreferences.EL_SYNTAX_ERROR,
JSFSeverityPreferences.WARNING);
+ defaultPreferences.put(JSFSeverityPreferences.CHECK_VARS,
JSFSeverityPreferences.ENABLE);
+ defaultPreferences.put(JSFSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL,
JSFSeverityPreferences.ENABLE);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/preferences/JSFPreferenceInitializer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/preferences/JSFSeverityPreferences.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/preferences/JSFSeverityPreferences.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/preferences/JSFSeverityPreferences.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.preferences;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.jboss.tools.common.preferences.SeverityPreferences;
+import org.jboss.tools.jsf.JSFModelPlugin;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class JSFSeverityPreferences extends SeverityPreferences {
+
+ public static final Set<String> SEVERITY_OPTION_NAMES = new
HashSet<String>();
+
+ private static JSFSeverityPreferences INSTANCE = new JSFSeverityPreferences();
+
+ // Expression Language
+
+ // Mark EL Variable name which we can't resolve.
+ public static final String UNKNOWN_EL_VARIABLE_NAME =
INSTANCE.createSeverityOption("unknownElVariableName"); //$NON-NLS-1$
+ // Check "var" attributes.
+ public static final String CHECK_VARS =
INSTANCE.createSeverityOption("checkVars"); //$NON-NLS-1$
+ // Re-validate unresolved ELs.
+ public static final String RE_VALIDATE_UNRESOLVED_EL =
INSTANCE.createSeverityOption("revalidateUnresolvedEl"); //$NON-NLS-1$
+ // Mark EL Variable property name which we can't resolve.
+ public static final String UNKNOWN_EL_VARIABLE_PROPERTY_NAME =
INSTANCE.createSeverityOption("unknownElVariablePropertyName"); //$NON-NLS-1$
+ // If Expression use property of bean and this property has only setter(getter) without
getter(setter) then mark it.
+ public static final String UNPAIRED_GETTER_OR_SETTER =
INSTANCE.createSeverityOption("unpairedGetterOrSetter"); //$NON-NLS-1$
+
+ public static final String EL_SYNTAX_ERROR =
INSTANCE.createSeverityOption("elSyntaxError"); //$NON-NLS-1$
+
+ /**
+ * @return the only instance of JSFSeverityPreferences
+ */
+ public static JSFSeverityPreferences getInstance() {
+ return INSTANCE;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.common.preferences.SeverityPreferences#createSeverityOption(java.lang.String)
+ */
+ @Override
+ protected String createSeverityOption(String shortName) {
+ String name = getPluginId() + ".validator.problem." + shortName;
//$NON-NLS-1$
+ SEVERITY_OPTION_NAMES.add(name);
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.common.preferences.SeverityPreferences#getPluginId()
+ */
+ @Override
+ protected String getPluginId() {
+ return JSFModelPlugin.PLUGIN_ID;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.common.preferences.SeverityPreferences#getSeverityOptionNames()
+ */
+ @Override
+ protected Set<String> getSeverityOptionNames() {
+ return SEVERITY_OPTION_NAMES;
+ }
+
+ public static boolean shouldValidateEL(IProject project) {
+ return !(SeverityPreferences.IGNORE.equals(INSTANCE.getProjectPreference(project,
UNKNOWN_EL_VARIABLE_NAME)) &&
+ SeverityPreferences.IGNORE.equals(INSTANCE.getProjectPreference(project,
UNKNOWN_EL_VARIABLE_PROPERTY_NAME)) &&
+ SeverityPreferences.IGNORE.equals(INSTANCE.getProjectPreference(project,
EL_SYNTAX_ERROR)) &&
+ SeverityPreferences.IGNORE.equals(INSTANCE.getProjectPreference(project,
UNPAIRED_GETTER_OR_SETTER)));
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/preferences/JSFSeverityPreferences.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,558 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.web.validation;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+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.jdt.internal.ui.text.FastJavaPartitionScanner;
+import org.eclipse.jdt.ui.text.IJavaPartitions;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.validation.internal.core.ValidationException;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
+import org.jboss.tools.common.el.core.model.ELExpression;
+import org.jboss.tools.common.el.core.model.ELInstance;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
+import org.jboss.tools.common.el.core.parser.ELParser;
+import org.jboss.tools.common.el.core.parser.ELParserFactory;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
+import org.jboss.tools.common.el.core.parser.LexicalToken;
+import org.jboss.tools.common.el.core.parser.SyntaxError;
+import org.jboss.tools.common.el.core.resolver.ELResolution;
+import org.jboss.tools.common.el.core.resolver.ELResolver;
+import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
+import org.jboss.tools.common.el.core.resolver.ELSegment;
+import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
+import org.jboss.tools.common.el.core.resolver.IVariable;
+import org.jboss.tools.common.el.core.resolver.JavaMemberELSegmentImpl;
+import org.jboss.tools.common.el.core.resolver.SimpleELContext;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector;
+import org.jboss.tools.common.el.core.resolver.Var;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.jsf.JSFModelPlugin;
+import org.jboss.tools.jsf.preferences.JSFSeverityPreferences;
+import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.kb.KbProjectFactory;
+import org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper;
+import org.jboss.tools.jst.web.kb.internal.validation.ValidationErrorManager;
+import org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager;
+import org.jboss.tools.jst.web.kb.validation.ELReference;
+import org.jboss.tools.jst.web.kb.validation.IValidatingProjectSet;
+import org.jboss.tools.jst.web.kb.validation.IValidationContext;
+import org.jboss.tools.jst.web.kb.validation.IValidator;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * EL Validator
+ * @author Alexey Kazakov
+ */
+public class ELValidator extends ValidationErrorManager implements IValidator {
+
+ protected static final String UNKNOWN_EL_VARIABLE_NAME_MESSAGE_ID =
"UNKNOWN_EL_VARIABLE_NAME"; //$NON-NLS-1$
+ protected static final String UNKNOWN_EL_VARIABLE_PROPERTY_NAME_MESSAGE_ID =
"UNKNOWN_EL_VARIABLE_PROPERTY_NAME"; //$NON-NLS-1$
+ protected static final String UNPAIRED_GETTER_OR_SETTER_MESSAGE_ID =
"UNPAIRED_GETTER_OR_SETTER"; //$NON-NLS-1$
+ protected static final String SYNTAX_ERROR_MESSAGE_ID = "EL_SYNTAX_ERROR";
//$NON-NLS-1$
+
+ protected static final String VALIDATING_EL_FILE_MESSAGE_ID =
"VALIDATING_EL_FILE"; //$NON-NLS-1$
+
+ private ELResolver[] resolvers;
+ private ELParserFactory mainFactory;
+
+ private List<Var> varListForCurentValidatedNode = new ArrayList<Var>();
+ private IProject currentProject;
+ private IProject rootProject;
+ private IResource[] currentSources;
+ private IContainer webRootFolder;
+ private boolean revalidateUnresolvedELs = false;
+
+ public ELValidator() {
+ }
+
+ private boolean isEnabled(IProject project) {
+ return JSFSeverityPreferences.shouldValidateEL(project);
+ }
+
+ protected void init(IProject project, ContextValidationHelper validationHelper,
ValidatorManager manager, IReporter reporter, IValidationContext validationContext) {
+ super.init(project, validationHelper, manager, reporter, validationContext);
+ resolvers = ELResolverFactoryManager.getInstance().getResolvers(project);
+ mainFactory = ELParserUtil.getDefaultFactory();
+ }
+
+ public IStatus validate(Set<IFile> changedFiles, IProject project,
ContextValidationHelper validationHelper, ValidatorManager manager, IReporter reporter,
IValidationContext validationContext) throws ValidationException {
+ init(project, validationHelper, manager, reporter, validationContext);
+ webRootFolder = null;
+ initRevalidationFlag();
+ IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
+
+ Set<IFile> filesToValidate = new HashSet<IFile>();
+ boolean containsJavaOrComponentsXml = false;
+ for (IFile file : changedFiles) {
+ filesToValidate.add(file);
+ if(!containsJavaOrComponentsXml) {
+ String fileName = file.getName().toLowerCase();
+ containsJavaOrComponentsXml = fileName.endsWith(".java") ||
fileName.endsWith(".properties") || fileName.equals("components.xml");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+
+ if(containsJavaOrComponentsXml) {
+ if(revalidateUnresolvedELs) {
+ Set<IPath> unnamedResources = validationContext.getUnnamedElResources();
+ for (IPath path : unnamedResources) {
+ IFile file = wsRoot.getFile(path);
+ if(file.exists()) {
+ filesToValidate.add(file);
+ }
+ }
+ }
+ }
+
+ Set<ELReference> elsToValidate =
validationContext.getElsForValidation(changedFiles, false);
+ validationContext.removeLinkedEls(filesToValidate);
+ for (IFile file : filesToValidate) {
+ if(!reporter.isCancelled()) {
+ validateFile(file);
+ }
+ }
+ if(revalidateUnresolvedELs) {
+ for (ELReference el : elsToValidate) {
+ if(!filesToValidate.contains(el.getResource())) {
+ validateEL(el);
+ }
+ }
+ }
+
+ validationContext.clearOldVariableNameForElValidation();
+ return OK_STATUS;
+ }
+
+ private void initRevalidationFlag() {
+ String revalidateUnresolvedELsString =
JSFSeverityPreferences.getInstance().getProjectPreference(rootProject,
JSFSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL);
+ revalidateUnresolvedELs =
JSFSeverityPreferences.ENABLE.equals(revalidateUnresolvedELsString);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.internal.core.validation.ISeamValidator#validateAll()
+ */
+ public IStatus validateAll(IProject project, ContextValidationHelper validationHelper,
ValidatorManager manager, IReporter reporter, IValidationContext validationContext) throws
ValidationException {
+ init(project, validationHelper, manager, reporter, validationContext);
+ webRootFolder = null;
+ initRevalidationFlag();
+ Set<IFile> files = validationContext.getRegisteredFiles();
+ for (IFile file : files) {
+ if(!reporter.isCancelled()) {
+ if(file.exists()) {
+ validateFile(file);
+ } else {
+ validationContext.removeUnnamedElResource(file.getFullPath());
+ }
+ }
+ }
+ return OK_STATUS;
+ }
+
+ private static final String JAVA_EXT = "java"; //$NON-NLS-1$
+
+ private boolean enabled = true;
+
+ private boolean shouldFileBeValidated(IFile file) {
+ IProject project = file.getProject();
+ if(currentProject==null || !project.equals(currentProject)) {
+ enabled = isEnabled(project);
+ }
+ if(!enabled) {
+ return false;
+ }
+ if(!file.isSynchronized(IResource.DEPTH_ZERO)) {
+ // The resource is out of sync with the file system
+ // Just ignore this resource.
+ return false;
+ }
+ if(!project.equals(currentProject)) {
+ if(webRootFolder!=null && !project.equals(webRootFolder.getProject())) {
+ webRootFolder = null;
+ }
+ if(webRootFolder==null) {
+ IFacetedProject facetedProject = null;
+ try {
+ facetedProject = ProjectFacetsManager.create(project);
+ } catch (CoreException e) {
+ JSFModelPlugin.getDefault().logError(JSFValidationMessages.EL_VALIDATOR_ERROR_VALIDATING,
e);
+ }
+ if(facetedProject!=null &&
facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.DYNAMIC_WEB_FACET)!=null) {
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ if(component!=null) {
+ IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new
Path("/")); //$NON-NLS-1$
+ webRootFolder = webRootVirtFolder.getUnderlyingFolder();
+ }
+ }
+ }
+ currentProject = project;
+ currentSources = EclipseResourceUtil.getJavaSourceRoots(project);
+ }
+ // Validate all files from java source folders.
+ for (int i = 0; i < currentSources.length; i++) {
+ if(currentSources[i].getLocation().isPrefixOf(file.getLocation())) {
+ return true;
+ }
+ }
+ // If *.java is out of Java Source path then ignore it.
+ if(JAVA_EXT.equalsIgnoreCase(file.getFileExtension())) {
+ return false;
+ }
+ // Otherwise validate only files from Web-Content (in case of WTP project)
+ if(webRootFolder!=null) {
+ return webRootFolder.getLocation().isPrefixOf(file.getLocation());
+ }
+ return true;
+ }
+
+ private void validateFile(IFile file) {
+ if(!shouldFileBeValidated(file)) {
+ return;
+ }
+ removeAllMessagesFromResource(file);
+ displaySubtask(VALIDATING_EL_FILE_MESSAGE_ID, new String[]{file.getProject().getName(),
file.getName()});
+ String ext = file.getFileExtension();
+ String content = null;
+ try {
+ content = FileUtil.readStream(file.getContents());
+ } catch (CoreException e) {
+ JSFModelPlugin.getPluginLog().logError(e);
+ return;
+ }
+ if(ext.equalsIgnoreCase(JAVA_EXT)) {
+ validateJava(file, content);
+ } else {
+ validateDom(file, content);
+ }
+ }
+
+ private void validateEL(ELReference el) {
+ el.deleteMarkers();
+ for (ELExpression expresion : el.getEl()) {
+ validateELExpression(el, expresion);
+ }
+ }
+
+ private void validateJava(IFile file, String content) {
+ try {
+ FastJavaPartitionScanner scaner = new FastJavaPartitionScanner();
+ Document document = new Document(content);
+ scaner.setRange(document, 0, document.getLength());
+ IToken token = scaner.nextToken();
+ while(token!=null && token!=Token.EOF && !reporter.isCancelled()) {
+ if(IJavaPartitions.JAVA_STRING.equals(token.getData())) {
+ int length = scaner.getTokenLength();
+ int offset = scaner.getTokenOffset();
+ String value = document.get(offset, length);
+ if(value.indexOf('{')>-1) {
+ validateString(file, value, offset);
+ }
+ }
+ token = scaner.nextToken();
+ }
+ } catch (BadLocationException e) {
+ JSFModelPlugin.getDefault().logError(JSFValidationMessages.EL_VALIDATOR_ERROR_VALIDATING,
e);
+ }
+ }
+
+ private void validateDom(IFile file, String content) {
+ varListForCurentValidatedNode.clear();
+ IModelManager manager = StructuredModelManager.getModelManager();
+ if(manager == null) {
+ // this can happen if plugin org.eclipse.wst.sse.core
+ // is stopping or uninstalled, that is Eclipse is shutting down.
+ // there is no need to report it, just stop validation.
+ return;
+ }
+ IStructuredModel model = null;
+ try {
+ model = manager.getModelForRead(file);
+ if (model instanceof IDOMModel) {
+ IDOMModel domModel = (IDOMModel) model;
+ IDOMDocument document = domModel.getDocument();
+ validateChildNodes(file, document);
+ }
+ } catch (CoreException e) {
+ JSFModelPlugin.getDefault().logError(JSFValidationMessages.EL_VALIDATOR_ERROR_VALIDATING,
e);
+ } catch (IOException e) {
+
JSFModelPlugin.getDefault().logError(JSFValidationMessages.EL_VALIDATOR_ERROR_VALIDATING,
e);
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+ return;
+ }
+
+ private void validateChildNodes(IFile file, Node parent) {
+ String preferenceValue =
JSFSeverityPreferences.getInstance().getProjectPreference(rootProject,
JSFSeverityPreferences.CHECK_VARS);
+ NodeList children = parent.getChildNodes();
+ for(int i=0; i<children.getLength() && !reporter.isCancelled(); i++) {
+ Node curentValidatedNode = children.item(i);
+ Var var = null;
+ if(Node.ELEMENT_NODE == curentValidatedNode.getNodeType()) {
+ if (JSFSeverityPreferences.ENABLE.equals(preferenceValue)) {
+ var = ElVarSearcher.findVar(curentValidatedNode, mainFactory);
+ }
+ if(var!=null) {
+ varListForCurentValidatedNode.add(var);
+ }
+ validateNodeContent(file,
((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(),
DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE);
+ } else if(Node.TEXT_NODE == curentValidatedNode.getNodeType()) {
+ validateNodeContent(file,
((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(),
DOMRegionContext.XML_CONTENT);
+ }
+ validateChildNodes(file, curentValidatedNode);
+ if(var!=null) {
+ varListForCurentValidatedNode.remove(var);
+ }
+ }
+ }
+
+ private void validateNodeContent(IFile file, IStructuredDocumentRegion node, String
regionType) {
+ ITextRegionList regions = node.getRegions();
+ for(int i=0; i<regions.size(); i++) {
+ ITextRegion region = regions.get(i);
+ if(region.getType() == regionType) {
+ String text = node.getFullText(region);
+ if(text.indexOf("{")>-1) { //$NON-NLS-1$
+ int offset = node.getStartOffset() + region.getStart();
+ validateString(file, text, offset);
+ }
+ }
+ }
+ }
+
+ /**
+ * @param offset - offset of string in file
+ * @param length - length of string in file
+ */
+ private void validateString(IFile file, String string, int offset) {
+ int startEl = string.indexOf("#{"); //$NON-NLS-1$
+ if(startEl>-1) {
+ ELParser parser = ELParserUtil.getJbossFactory().createParser();
+ ELModel model = parser.parse(string);
+ List<ELInstance> is = model.getInstances();
+
+ ELReference elReference = new ELReference();
+ elReference.setResource(file);
+ elReference.setEl(is);
+ elReference.setLength(string.length());
+ elReference.setStartPosition(offset);
+
+ List<SyntaxError> errors = model.getSyntaxErrors();
+ if(!errors.isEmpty()) {
+ for (SyntaxError error: errors) {
+ IMarker marker = addError(SYNTAX_ERROR_MESSAGE_ID,
JSFSeverityPreferences.EL_SYNTAX_ERROR, new String[]{"" + error.getProblem()},
1, offset + error.getPosition(), file);
+ elReference.addMarker(marker);
+ }
+ }
+ for (ELInstance i : is) {
+ if (reporter.isCancelled()) {
+ return;
+ }
+ if(!i.getErrors().isEmpty()) {
+ //Already reported syntax problem in this piece of EL.
+ continue;
+ }
+ validateELExpression(elReference, i.getExpression());
+ }
+ }
+ }
+
+ private void validateELExpression(ELReference elReference, ELExpression el) {
+ if(el == null) return;
+ List<ELInvocationExpression> es = el.getInvocations();
+ for (ELInvocationExpression token: es) {
+ validateElOperand(elReference, token);
+ }
+ }
+
+ private SimpleELContext context = new SimpleELContext();
+
+ private void validateElOperand(ELReference elReference, ELInvocationExpression
operandToken) {
+ IFile file = elReference.getResource();
+ int documnetOffset = elReference.getStartPosition();
+ String operand = operandToken.getText();
+ String varName = operand;
+ int offsetOfVarName = documnetOffset + operandToken.getFirstToken().getStart();
+ int lengthOfVarName = varName.length();
+ boolean unresolvedTokenIsVariable = false;
+ if (!operand.endsWith(".")) { //$NON-NLS-1$
+ ELResolution resolution = null;
+ context.setVars(varListForCurentValidatedNode);
+ context.setElResolvers(resolvers);
+ context.setResource(file);
+ int maxNumberOfResolvedSegments = -1;
+ for (int i = 0; i < resolvers.length; i++) {
+ ELResolution elResolution = resolvers[i].resolve(context, operandToken);
+ if(elResolution.isResolved()) {
+ resolution = elResolution;
+ break;
+ }
+ int number = resolution.getNumberOfResolvedSegments();
+ if(number>maxNumberOfResolvedSegments) {
+ maxNumberOfResolvedSegments = number;
+ resolution = elResolution;
+ }
+ }
+
+ if(!resolution.isResolved()) {
+ Set<String> names = findVariableNames(operandToken);
+ for (String name : names) {
+ validationContext.addLinkedEl(name, elReference);
+ }
+ }
+
+ List<ELSegment> segments = resolution.getSegments();
+ List<IVariable> usedVariables = new ArrayList<IVariable>();
+ for (ELSegment segment : segments) {
+ if(!segment.getVariables().isEmpty()) {
+ usedVariables.addAll(segment.getVariables());
+ }
+ // Check pair for getter/setter
+ if(segment instanceof JavaMemberELSegmentImpl) {
+ JavaMemberELSegmentImpl javaSegment = (JavaMemberELSegmentImpl)segment;
+ if(!javaSegment.getUnpairedGettersOrSetters().isEmpty()) {
+ TypeInfoCollector.MethodInfo unpairedMethod =
javaSegment.getUnpairedGettersOrSetters().values().iterator().next();
+ String methodName = unpairedMethod.getName();
+ String propertyName =
javaSegment.getUnpairedGettersOrSetters().keySet().iterator().next();
+ String missingMethodName = JSFValidationMessages.EL_VALIDATOR_SETTER;
+ String existedMethodName = JSFValidationMessages.EL_VALIDATOR_GETTER;
+ if(methodName.startsWith("s")) { //$NON-NLS-1$
+ missingMethodName = existedMethodName;
+ existedMethodName = JSFValidationMessages.EL_VALIDATOR_SETTER;
+ }
+ int startPosition = documnetOffset + operandToken.getStartPosition();
+ int length = operandToken.getLength();
+ int startPr = operand.indexOf(propertyName);
+ if(startPr>-1) {
+ startPosition = startPosition + startPr;
+ length = propertyName.length();
+ }
+ IMarker marker = addError(UNPAIRED_GETTER_OR_SETTER_MESSAGE_ID,
JSFSeverityPreferences.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName,
existedMethodName, missingMethodName}, length, startPosition, file);
+ elReference.addMarker(marker);
+ }
+ }
+ }
+ // Save links between resource and used variables names
+ for(IVariable variable: usedVariables) {
+ validationContext.addLinkedEl(variable.getName(), elReference);
+ }
+
+ if (resolution.isResolved()) {
+ // It's valid EL.
+ return;
+ }
+
+ ELSegment segment = resolution.getUnresolvedSegment();
+ LexicalToken token = segment.getToken();
+
+ varName = token.getText();
+ if(varName == null) {
+ //This is syntax error case. Reported by parser.
+ return;
+ }
+ offsetOfVarName = documnetOffset + token.getStart();
+ lengthOfVarName = varName == null ? 0 : varName.length();
+ if(usedVariables.isEmpty()) {
+ unresolvedTokenIsVariable = true;
+ }
+ }
+ // Mark invalid EL
+ if(unresolvedTokenIsVariable) {
+ IMarker marker = addError(UNKNOWN_EL_VARIABLE_NAME_MESSAGE_ID,
JSFSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME, new String[]{varName}, lengthOfVarName,
offsetOfVarName, file);
+ elReference.addMarker(marker);
+ } else {
+ IMarker marker = addError(UNKNOWN_EL_VARIABLE_PROPERTY_NAME_MESSAGE_ID,
JSFSeverityPreferences.UNKNOWN_EL_VARIABLE_PROPERTY_NAME, new String[]{varName},
lengthOfVarName, offsetOfVarName, file);
+ elReference.addMarker(marker);
+ }
+ }
+
+ private Set<String> findVariableNames(ELInvocationExpression
invocationExpression){
+ Set<String> names = new HashSet<String>();
+ while(invocationExpression != null) {
+ if(invocationExpression instanceof ELPropertyInvocation) {
+ String name = ((ELPropertyInvocation)invocationExpression).getQualifiedName();
+ if(name != null) {
+ names.add(name);
+ }
+ }
+ invocationExpression = invocationExpression.getLeft();
+ }
+ return names;
+ }
+
+ @Override
+ protected String getPreference(IProject project, String preferenceKey) {
+ // TODO
+ return null;
+ }
+
+ public String getId() {
+ // TODO
+ return null;
+ }
+
+ public IValidatingProjectSet getValidatingProjects(IProject project) {
+ List<IProject> projects = new ArrayList<IProject>();
+ projects.add(project);
+ IKbProject kbProject = KbProjectFactory.getKbProject(project, false);
+ if(kbProject!=null) {
+ // IValidationContext context = kbProject.getValidationContext();
+
+ }
+ return null;
+ }
+
+ public boolean shouldValidate(IProject project) {
+ // TODO
+ return false;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/ELValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFValidationMessages.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFValidationMessages.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFValidationMessages.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,15 @@
+package org.jboss.tools.jsf.web.validation;
+
+import org.eclipse.osgi.util.NLS;
+
+public class JSFValidationMessages {
+ private static final String BUNDLE_NAME =
"org.jboss.tools.jsf.web.validation.messages"; //$NON-NLS-1$
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, JSFValidationMessages.class);
+ }
+
+ public static String EL_VALIDATOR_ERROR_VALIDATING;
+ public static String EL_VALIDATOR_SETTER;
+ public static String EL_VALIDATOR_GETTER;
+}
\ No newline at end of file
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFValidationMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/messages.properties
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/messages.properties
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/messages.properties 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,23 @@
+#*******************************************************************************
+#* Copyright (c) 2007 Red Hat, Inc.
+#* Distributed under license by Red Hat, Inc. All rights reserved.
+#* This program is made available under the terms of the
+#* Eclipse Public License v1.0 which accompanies this distribution,
+#* and is available at
http://www.eclipse.org/legal/epl-v10.html
+#*
+#* Contributors:
+#* Red Hat, Inc. - initial API and implementation
+#******************************************************************************/
+
+#Expression Language
+UNKNOWN_EL_VARIABLE_NAME="{0}" cannot be resolved
+UNKNOWN_EL_VARIABLE_PROPERTY_NAME="{0}" cannot be resolved
+UNPAIRED_GETTER_OR_SETTER=Property "{0}" has only {1}. {2} is missing.
+EL_SYNTAX_ERROR=EL syntax error: {0}.
+
+#Messages for Progress Monitor
+VALIDATING_EL_FILE=project "{0}"; EL in "{1}"
+
+EL_VALIDATOR_ERROR_VALIDATING=Error validating EL
+EL_VALIDATOR_SETTER=Setter
+EL_VALIDATOR_GETTER=Getter
\ No newline at end of file
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF 2009-10-15 11:23:11 UTC
(rev 18104)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF 2009-10-15 12:31:45 UTC
(rev 18105)
@@ -45,6 +45,7 @@
org.eclipse.gef,
org.eclipse.ui.workbench.texteditor,
org.eclipse.core.expressions,
+ org.eclipse.ui.forms,
org.jboss.tools.common.gef;bundle-version="2.0.0"
Bundle-Version: 2.0.0
Bundle-ActivationPolicy: lazy
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.properties
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.properties 2009-10-15 11:23:11 UTC
(rev 18104)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.properties 2009-10-15 12:31:45 UTC
(rev 18105)
@@ -23,6 +23,8 @@
PreferencePage_JSFImplementations=JSF Environment
PreferencePage_JSFPages=JSF Pages
PreferencePage_JSFFlowTabbed=JSF Flow Diagram
+PreferencePage_Validator=Validator
+PreferencePage_JSFValidator=JSF Validator
NewWizardCat_JBossTools=JBoss Tools
NewWizardCat_JSF=JSF
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2009-10-15 11:23:11 UTC (rev
18104)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2009-10-15 12:31:45 UTC (rev
18105)
@@ -30,9 +30,28 @@
class="org.jboss.tools.jsf.ui.preferences.JSFFlowTabbedPreferencesPage"
id="org.jboss.tools.jsf.ui.jsfflowdiagram"
name="%PreferencePage_JSFFlowTabbed"/>
+ <page
+ category="org.jboss.tools.jsf.ui"
+ class="org.jboss.tools.jsf.ui.preferences.JSFValidatorPreferencePage"
+ id="org.jboss.tools.jsf.ui.preferences.JSFValidatorPreferencePage"
+ name="%PreferencePage_Validator">
+ </page>
</extension>
-
-
+
+ <extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+ name="%PreferencePage_JSFValidator"
+
class="org.jboss.tools.jsf.ui.preferences.JSFValidatorPreferencePage"
+
id="org.jboss.tools.jsf.ui.propertyPages.JSFValidatorPreferencePage">
+ <enabledWhen>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <test property="org.eclipse.core.resources.projectNature"
value="org.jboss.tools.jsf.jsfnature"/>
+ </adapt>
+ </enabledWhen>
+ </page>
+ </extension>
+
<extension id="e" name="XML Editors"
point="org.jboss.tools.common.model.ui.xmlEditor">
<xmlEditor
class="org.jboss.tools.jsf.ui.editor.FacesConfigEditor"
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFSeverityPreferencesMessages.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFSeverityPreferencesMessages.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFSeverityPreferencesMessages.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jsf.ui.preferences;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class JSFSeverityPreferencesMessages extends NLS {
+
+ private static final String BUNDLE_NAME =
"org.jboss.tools.jsf.ui.preferences.JSFSeverityPreferencesMessages";
//$NON-NLS-1$
+
+ public static String
JSF_VALIDATOR_CONFIGURATION_BLOCK_JSF_VALIDATOR_CONFIGURATION_BLOCK;
+ public static String JSF_VALIDATOR_PREFERENCE_PAGE_JSF_VALIDATOR;
+
+ //Validator Preference page
+ public static String JSFValidatorConfigurationBlock_common_description;
+
+ //Expression Language
+ public static String JSFValidatorConfigurationBlock_section_el;
+ public static String JSFValidatorConfigurationBlock_pb_elSyntaxError_label;
+ public static String JSFValidatorConfigurationBlock_pb_unknownElVariableName_label;
+ public static String JSFValidatorConfigurationBlock_pb_checkVars_label;
+ public static String JSFValidatorConfigurationBlock_pb_revalidateUnresolvedEl_label;
+ public static String
JSFValidatorConfigurationBlock_pb_unknownElVariablePropertyName_label;
+ public static String JSFValidatorConfigurationBlock_pb_unpairedGetterOrSetter_label;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, JSFSeverityPreferencesMessages.class);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFSeverityPreferencesMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFSeverityPreferencesMessages.properties
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFSeverityPreferencesMessages.properties
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFSeverityPreferencesMessages.properties 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,25 @@
+##################################################################################
+### Copyright (c) 2007 Red Hat, Inc.
+### Distributed under license by Red Hat, Inc. All rights reserved.
+### This program is made available under the terms of the
+### Eclipse Public License v1.0 which accompanies this distribution,
+### and is available at
http://www.eclipse.org/legal/epl-v10.html
+###
+### Contributors:
+### Red Hat, Inc. - initial API and implementation
+##################################################################################
+
+#Preferences Page
+JSFValidatorConfigurationBlock_common_description=Select the severity level for the
following optional JSF Validator problems:
+
+##Expression Language
+JSFValidatorConfigurationBlock_section_el=Expression language
+JSFValidatorConfigurationBlock_pb_elSyntaxError_label=EL Syntax Error
+JSFValidatorConfigurationBlock_pb_unknownElVariableName_label=Variable cannot be
resolved:
+JSFValidatorConfigurationBlock_pb_checkVars_label=Recognize "var" attributes
+JSFValidatorConfigurationBlock_pb_revalidateUnresolvedEl_label=Revalidate unresolved ELs
automatically.
+JSFValidatorConfigurationBlock_pb_unknownElVariablePropertyName_label=Property cannot be
resolved:
+JSFValidatorConfigurationBlock_pb_unpairedGetterOrSetter_label=Unpaired Getter/Setter:
+
+JSF_VALIDATOR_CONFIGURATION_BLOCK_JSF_VALIDATOR_CONFIGURATION_BLOCK=JSFValidatorConfigurationBlock
+JSF_VALIDATOR_PREFERENCE_PAGE_JSF_VALIDATOR=JSF Validator
\ No newline at end of file
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFSeverityPreferencesMessages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFValidatorConfigurationBlock.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFValidatorConfigurationBlock.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFValidatorConfigurationBlock.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jsf.ui.preferences;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.internal.ui.preferences.ScrolledPageContent;
+import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+import org.jboss.tools.common.model.ui.preferences.SeverityConfigurationBlock;
+import org.jboss.tools.common.model.ui.preferences.SeverityPreferencesMessages;
+import org.jboss.tools.jsf.JSFModelPlugin;
+import org.jboss.tools.jsf.preferences.JSFSeverityPreferences;
+
+/**
+ * Find the instruction to Framework for Severity preferences in
SeverityConfigurationBlock.java
+ *
+ * @author Viacheslav Kabanovich
+ */
+public class JSFValidatorConfigurationBlock extends SeverityConfigurationBlock {
+ private static final String SETTINGS_SECTION_NAME =
JSFSeverityPreferencesMessages.JSF_VALIDATOR_CONFIGURATION_BLOCK_JSF_VALIDATOR_CONFIGURATION_BLOCK;
+
+ private Button recognizeVarsCheckBox;
+ private Button revalidateUnresolvedElCheckBox;
+ private Combo elVariablesCombo;
+ private Combo elPropertiesCombo;
+
+ private static SectionDescription SECTION_EL = new SectionDescription(
+ JSFSeverityPreferencesMessages.JSFValidatorConfigurationBlock_section_el,
+ new String[][] {
+ {JSFSeverityPreferences.EL_SYNTAX_ERROR,
JSFSeverityPreferencesMessages.JSFValidatorConfigurationBlock_pb_elSyntaxError_label},
+ {JSFSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME,
JSFSeverityPreferencesMessages.JSFValidatorConfigurationBlock_pb_unknownElVariableName_label},
+ {JSFSeverityPreferences.UNKNOWN_EL_VARIABLE_PROPERTY_NAME,
JSFSeverityPreferencesMessages.JSFValidatorConfigurationBlock_pb_unknownElVariablePropertyName_label},
+ {JSFSeverityPreferences.UNPAIRED_GETTER_OR_SETTER,
JSFSeverityPreferencesMessages.JSFValidatorConfigurationBlock_pb_unpairedGetterOrSetter_label},
+ },
+ JSFModelPlugin.PLUGIN_ID
+ );
+
+ private static SectionDescription[] ALL_SECTIONS = new SectionDescription[]{
+ SECTION_EL,
+ };
+
+ private static Key[] getKeys() {
+ ArrayList<Key> keys = new ArrayList<Key>();
+ for (int i = 0; i < ALL_SECTIONS.length; i++) {
+ for (int j = 0; j < ALL_SECTIONS[i].options.length; j++) {
+ keys.add(ALL_SECTIONS[i].options[j].key);
+ }
+ }
+ keys.add(getKey(JSFModelPlugin.PLUGIN_ID, JSFSeverityPreferences.CHECK_VARS));
+ return keys.toArray(new Key[0]);
+ }
+
+ public JSFValidatorConfigurationBlock(IStatusChangeListener context,
+ IProject project,
+ IWorkbenchPreferenceContainer container) {
+ super(context, project, getKeys(), container);
+ }
+
+ @Override
+ protected Composite createStyleTabContent(Composite folder) {
+ String[] errorWarningIgnore = new String[] {ERROR, WARNING, IGNORE};
+ String[] enableDisableValues= new String[] {ENABLED, DISABLED};
+
+ String[] errorWarningIgnoreLabels = new String[] {
+ SeverityPreferencesMessages.VALIDATOR_CONFIGURATION_BLOCK_ERROR,
+ SeverityPreferencesMessages.VALIDATOR_CONFIGURATION_BLOCK_WARNING,
+ SeverityPreferencesMessages.VALIDATOR_CONFIGURATION_BLOCK_IGNORE
+ };
+
+ int nColumns = 3;
+
+ final ScrolledPageContent sc1 = new ScrolledPageContent(folder);
+
+ Composite composite = sc1.getBody();
+ GridLayout layout= new GridLayout(nColumns, false);
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ composite.setLayout(layout);
+
+ Label description= new Label(composite, SWT.LEFT | SWT.WRAP);
+ description.setFont(description.getFont());
+ description.setText(JSFSeverityPreferencesMessages.JSFValidatorConfigurationBlock_common_description);
+ description.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true,
false, nColumns - 1, 1));
+
+ int defaultIndent = 0;
+
+ for (int i = 0; i < ALL_SECTIONS.length; i++) {
+ SectionDescription section = ALL_SECTIONS[i];
+ String label = section.label;
+ ExpandableComposite excomposite = createStyleSection(composite, label, nColumns);
+
+ Composite inner = new Composite(excomposite, SWT.NONE);
+ inner.setFont(composite.getFont());
+ inner.setLayout(new GridLayout(nColumns, false));
+ excomposite.setClient(inner);
+
+ for (int j = 0; j < section.options.length; j++) {
+ OptionDescription option = section.options[j];
+ label = option.label;
+ Combo combo = addComboBox(inner, label, option.key, errorWarningIgnore,
errorWarningIgnoreLabels, defaultIndent);
+ if(option.label ==
JSFSeverityPreferencesMessages.JSFValidatorConfigurationBlock_pb_unknownElVariableName_label)
{
+ elVariablesCombo = combo;
+ combo.addSelectionListener(new SelectionListener(){
+ public void widgetDefaultSelected(SelectionEvent e) {
+ updateELCombox();
+ }
+ public void widgetSelected(SelectionEvent e) {
+ updateELCombox();
+ }
+ });
+ } else if(option.label ==
JSFSeverityPreferencesMessages.JSFValidatorConfigurationBlock_pb_unknownElVariablePropertyName_label)
{
+ elPropertiesCombo = combo;
+ combo.addSelectionListener(new SelectionListener(){
+ public void widgetDefaultSelected(SelectionEvent e) {
+ updateELCombox();
+ }
+ public void widgetSelected(SelectionEvent e) {
+ updateELCombox();
+ }
+ });
+ }
+ }
+
+ if(section==SECTION_EL) {
+ label =
JSFSeverityPreferencesMessages.JSFValidatorConfigurationBlock_pb_checkVars_label;
+ recognizeVarsCheckBox = addCheckBox(inner, label, getKey(JSFModelPlugin.PLUGIN_ID,
JSFSeverityPreferences.CHECK_VARS), enableDisableValues, defaultIndent);
+
+ label =
JSFSeverityPreferencesMessages.JSFValidatorConfigurationBlock_pb_revalidateUnresolvedEl_label;
+ revalidateUnresolvedElCheckBox = addCheckBox(inner, label,
getKey(JSFModelPlugin.PLUGIN_ID, JSFSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL),
enableDisableValues, defaultIndent);
+ }
+ }
+
+ IDialogSettings section =
JSFModelPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION_NAME);
+ restoreSectionExpansionStates(section);
+
+ updateELCombox();
+
+ return sc1;
+ }
+
+ @Override
+ public void performDefaults() {
+ super.performDefaults();
+ updateELCombox();
+ }
+
+ private void updateELCombox() {
+ boolean enable = elPropertiesCombo.getSelectionIndex()!=2 ||
elVariablesCombo.getSelectionIndex()!=2;
+ recognizeVarsCheckBox.setEnabled(enable);
+ revalidateUnresolvedElCheckBox.setEnabled(enable);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFValidatorConfigurationBlock.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFValidatorPreferencePage.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFValidatorPreferencePage.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFValidatorPreferencePage.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jsf.ui.preferences;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+import org.jboss.tools.common.model.ui.preferences.SeverityConfigurationBlock;
+import org.jboss.tools.common.model.ui.preferences.SeverityPreferencePage;
+import org.jboss.tools.jsf.JSFModelPlugin;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class JSFValidatorPreferencePage extends SeverityPreferencePage {
+ public static final String PREF_ID =
"org.jboss.tools.jsf.ui.preferences.JSFValidatorPreferencePage"; //$NON-NLS-1$
+ public static final String PROP_ID =
"org.jboss.tools.jsf.ui.propertyPages.JSFValidatorPreferencePage";
//$NON-NLS-1$
+
+ private JSFValidatorConfigurationBlock fConfigurationBlock;
+
+ public JSFValidatorPreferencePage() {
+ setPreferenceStore(JSFModelPlugin.getDefault().getPreferenceStore());
+ setTitle(JSFSeverityPreferencesMessages.JSF_VALIDATOR_PREFERENCE_PAGE_JSF_VALIDATOR);
+ }
+
+ @Override
+ protected String getPreferencePageID() {
+ return PREF_ID;
+ }
+
+ @Override
+ protected String getPropertyPageID() {
+ return PROP_ID;
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer)
getContainer();
+ fConfigurationBlock = new JSFValidatorConfigurationBlock(getNewStatusChangedListener(),
getProject(), container);
+
+ super.createControl(parent);
+ }
+
+ @Override
+ protected SeverityConfigurationBlock getConfigurationBlock() {
+ return fConfigurationBlock;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/preferences/JSFValidatorPreferencePage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-10-15 11:23:11
UTC (rev 18104)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-10-15 12:31:45
UTC (rev 18105)
@@ -13,7 +13,9 @@
org.eclipse.jface.text,
org.eclipse.wst.sse.core,
org.eclipse.wst.xml.ui;bundle-version="1.1.0",
- org.eclipse.jdt.ui;bundle-version="3.5.0"
+ org.eclipse.jdt.ui;bundle-version="3.5.0",
+ org.eclipse.wst.validation;bundle-version="1.2.102",
+ org.eclipse.ui.editors;bundle-version="3.5.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
@@ -22,5 +24,7 @@
org.jboss.tools.jst.web.kb.internal,
org.jboss.tools.jst.web.kb.internal.scanner,
org.jboss.tools.jst.web.kb.internal.taglib,
+ org.jboss.tools.jst.web.kb.internal.taglib.composite,
+ org.jboss.tools.jst.web.kb.internal.validation,
org.jboss.tools.jst.web.kb.taglib,
- org.jboss.tools.jst.web.kb.internal.taglib.composite
+ org.jboss.tools.jst.web.kb.validation
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2009-10-15 11:23:11 UTC (rev
18104)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2009-10-15 12:31:45 UTC (rev
18105)
@@ -2,6 +2,7 @@
<?eclipse version="3.0"?>
<plugin>
<extension-point id="tagLib" name="Kb Custom Tag Lib"
schema="schema/tagLib.exsd"/>
+ <extension-point id="validator" name="KB Validator"
schema="schema/validator.exsd"/>
<extension
id="kbbuilder"
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/validator.exsd
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/validator.exsd
(rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/validator.exsd 2009-10-15 12:31:45
UTC (rev 18105)
@@ -0,0 +1,119 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.jst.web.kb"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.jboss.tools.jst.web.kb"
id="validator" name="KB Validator"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="validator" minOccurs="1"
maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="validator">
+ <complexType>
+ <attribute name="class" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.tools.jst.web.kb.validation.IValidator"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="extends" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier"
basedOn="org.jboss.tools.jst.web.kb.validator/validator/@id"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/validator.exsd
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ContextValidationHelper.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ContextValidationHelper.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ContextValidationHelper.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.validation;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.ui.editors.text.TextFileDocumentProvider;
+import org.eclipse.wst.validation.internal.operations.WorkbenchContext;
+import org.jboss.tools.jst.web.kb.validation.IValidationContext;
+
+/**
+ * Helper for Validators that use Validator Context.
+ * @author Alexey Kazakov
+ */
+public class ContextValidationHelper extends WorkbenchContext {
+
+ protected IValidationContext validationContext;
+ protected TextFileDocumentProvider documentProvider = new TextFileDocumentProvider();
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.wst.validation.internal.operations.WorkbenchContext#registerResource(org.eclipse.core.resources.IResource)
+ */
+ @Override
+ public void registerResource(IResource resource) {
+ if(resource instanceof IFile) {
+ IFile file = (IFile)resource;
+ if(!file.exists()) {
+ getValidationContext().addRemovedFile(file);
+ } else {
+ getValidationContext().registerFile(file);
+ }
+ }
+ }
+
+ /**
+ * @return Set of changed resources
+ */
+ public Set<IFile> getChangedFiles() {
+ Set<IFile> result = new HashSet<IFile>();
+ String[] uris = getURIs();
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ for (int i = 0; i < uris.length; i++) {
+ IFile currentFile = root.getFile(new Path(uris[i]));
+ result.add(currentFile);
+ }
+ result.addAll(getValidationContext().getRemovedFiles());
+ return result;
+ }
+
+ public IValidationContext getValidationContext() {
+ if(validationContext==null) {
+ validationContext = new ValidationContext(getProject());
+ }
+ return validationContext;
+ }
+
+ public void setValidationContext(IValidationContext context) {
+ validationContext = context;
+ }
+
+ public TextFileDocumentProvider getDocumentProvider(){
+ return documentProvider;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ContextValidationHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatingProjectSet.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatingProjectSet.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatingProjectSet.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.kb.internal.validation;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.jboss.tools.jst.web.kb.validation.IValidatingProjectSet;
+import org.jboss.tools.jst.web.kb.validation.IValidationContext;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class ValidatingProjectSet implements IValidatingProjectSet {
+
+ protected IProject rootProject;
+ protected List<IProject> allProjects;
+ protected IValidationContext rootContext;
+
+ /**
+ * @param rootProject
+ * @param allProjects
+ * @param rootContext
+ */
+ public ValidatingProjectSet(IProject rootProject, List<IProject> allProjects,
IValidationContext rootContext) {
+ this.rootProject = rootProject;
+ this.allProjects = allProjects;
+ this.rootContext = rootContext;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.validation.IValidatingProjectSet#getAllProjests()
+ */
+ public List<IProject> getAllProjests() {
+ return allProjects;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.validation.IValidatingProjectSet#getRootContext()
+ */
+ public IValidationContext getRootContext() {
+ return rootContext;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.validation.IValidatingProjectSet#getRootProject()
+ */
+ public IProject getRootProject() {
+ return rootProject;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatingProjectSet.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationContext.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationContext.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationContext.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,324 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.kb.internal.validation;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.jboss.tools.jst.web.kb.validation.ELReference;
+import org.jboss.tools.jst.web.kb.validation.IValidatingProjectSet;
+import org.jboss.tools.jst.web.kb.validation.IValidationContext;
+import org.jboss.tools.jst.web.kb.validation.IValidator;
+import org.w3c.dom.Element;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class ValidationContext implements IValidationContext {
+
+ private IValidationContext rootContext;
+ private IProject rootProject;
+ private static List<IValidator> ALL_VALIDATORS;
+ private List<IValidator> validators;
+
+ public ValidationContext(IProject project) {
+ if(ALL_VALIDATORS == null) {
+ // Load all validators
+ ALL_VALIDATORS = new ArrayList<IValidator>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint =
registry.getExtensionPoint(IValidator.EXTENSION_POINT_ID);
+ if (extensionPoint != null) {
+ Map<String, IValidator> extendsIds = new HashMap<String, IValidator>();
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i=0; i<extensions.length; i++) {
+ IExtension extension = extensions[i];
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ for(int j=0; j<elements.length; j++) {
+ try {
+ IValidator validator =
(IValidator)elements[j].createExecutableExtension("class"); //$NON-NLS-1$
+ String extendsId = elements[j].getAttribute("extends"); //$NON-NLS-1$
+ if(extendsId!=null) {
+ IValidator[] tempArray = ALL_VALIDATORS.toArray(new IValidator[0]);
+ for (IValidator vld : tempArray) {
+ if(extendsId.equals(vld.getId())) {
+ ALL_VALIDATORS.remove(vld);
+ }
+ }
+ extendsIds.put(extendsId, validator);
+ }
+ if(!extendsIds.containsKey(validator.getId())) {
+ ALL_VALIDATORS.add(validator);
+ }
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+ }
+ }
+ }
+ }
+
+ // Init context for given project.
+ for (IValidator validator : ALL_VALIDATORS) {
+ if(validator.shouldValidate(project)) {
+ validators.add(validator);
+ }
+ }
+ for (IValidator validator : validators) {
+ IValidatingProjectSet prSet = validator.getValidatingProjects(project);
+ IProject vProject = prSet.getRootProject();
+ if(vProject!=project) {
+ rootProject = vProject;
+ rootContext = prSet.getRootContext();
+ } else if(rootContext==null) {
+ rootContext = prSet.getRootContext();
+ }
+ }
+ if(rootProject==null) {
+ rootProject = project;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.validation.IValidationContext#getValidators()
+ */
+ public List<IValidator> getValidators() {
+ return validators;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addLinkedCoreResource(java.lang.String,
org.eclipse.core.runtime.IPath, boolean)
+ */
+ public void addLinkedCoreResource(String variableName, IPath linkedResourcePath, boolean
declaration) {
+ rootContext.addLinkedCoreResource(variableName, linkedResourcePath, declaration);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addLinkedEl(java.lang.String,
org.jboss.tools.seam.internal.core.validation.ELReference)
+ */
+ public void addLinkedEl(String variableName, ELReference el) {
+ rootContext.addLinkedEl(variableName, el);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addRemovedFile(org.eclipse.core.resources.IFile)
+ */
+ public void addRemovedFile(IFile file) {
+ rootContext.addRemovedFile(file);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addUnnamedCoreResource(org.eclipse.core.runtime.IPath)
+ */
+ public void addUnnamedCoreResource(IPath fullPath) {
+ rootContext.addUnnamedCoreResource(fullPath);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addUnnamedElResource(org.eclipse.core.runtime.IPath)
+ */
+ public void addUnnamedElResource(IPath fullPath) {
+ rootContext.addUnnamedElResource(fullPath);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addVariableNameForELValidation(java.lang.String)
+ */
+ public void addVariableNameForELValidation(String name) {
+ rootContext.addVariableNameForELValidation(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearAll()
+ */
+ public void clearAll() {
+ rootContext.clearAll();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearAllResourceLinks()
+ */
+ public void clearAllResourceLinks() {
+ rootContext.clearAllResourceLinks();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearElResourceLinks()
+ */
+ public void clearElResourceLinks() {
+ rootContext.clearElResourceLinks();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearOldVariableNameForElValidation()
+ */
+ public void clearOldVariableNameForElValidation() {
+ rootContext.clearOldVariableNameForElValidation();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearRegisteredFiles()
+ */
+ public void clearRegisteredFiles() {
+ rootContext.clearRegisteredFiles();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getCoreResourcesByVariableName(java.lang.String,
boolean)
+ */
+ public Set<IPath> getCoreResourcesByVariableName(String variableName, boolean
declaration) {
+ return rootContext.getCoreResourcesByVariableName(variableName, declaration);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getElsByVariableName(java.lang.String)
+ */
+ public Set<ELReference> getElsByVariableName(String variableName) {
+ return rootContext.getElsByVariableName(variableName);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getElsForValidation(java.util.Set,
boolean)
+ */
+ public Set<ELReference> getElsForValidation(Set<IFile> changedFiles, boolean
onlyChangedVariables) {
+ return rootContext.getElsForValidation(changedFiles, onlyChangedVariables);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getRegisteredFiles()
+ */
+ public Set<IFile> getRegisteredFiles() {
+ return rootContext.getRegisteredFiles();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getRemovedFiles()
+ */
+ public Set<IFile> getRemovedFiles() {
+ return rootContext.getRemovedFiles();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getUnnamedCoreResources()
+ */
+ public Set<IPath> getUnnamedCoreResources() {
+ return rootContext.getUnnamedCoreResources();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getUnnamedElResources()
+ */
+ public Set<IPath> getUnnamedElResources() {
+ return rootContext.getUnnamedElResources();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getVariableNamesByCoreResource(org.eclipse.core.runtime.IPath,
boolean)
+ */
+ public Set<String> getVariableNamesByCoreResource(IPath fullPath, boolean
declaration) {
+ return rootContext.getVariableNamesByCoreResource(fullPath, declaration);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#load(org.w3c.dom.Element)
+ */
+ public void load(Element root) {
+ rootContext.load(root);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#registerFile(org.eclipse.core.resources.IFile)
+ */
+ public void registerFile(IFile file) {
+ rootContext.registerFile(file);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeLinkedCoreResource(org.eclipse.core.runtime.IPath)
+ */
+ public void removeLinkedCoreResource(IPath resource) {
+ rootContext.removeLinkedCoreResource(resource);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeLinkedCoreResource(java.lang.String,
org.eclipse.core.runtime.IPath)
+ */
+ public void removeLinkedCoreResource(String name, IPath linkedResourcePath) {
+ rootContext.removeLinkedCoreResource(name, linkedResourcePath);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeLinkedCoreResources(java.util.Set)
+ */
+ public void removeLinkedCoreResources(Set<IPath> resources) {
+ rootContext.removeLinkedCoreResources(resources);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeLinkedEl(java.lang.String,
org.jboss.tools.seam.internal.core.validation.ELReference)
+ */
+ public void removeLinkedEl(String name, ELReference el) {
+ rootContext.removeLinkedEl(name, el);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeLinkedEls(java.util.Set)
+ */
+ public void removeLinkedEls(Set<IFile> resorces) {
+ rootContext.removeLinkedEls(resorces);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeUnnamedCoreResource(org.eclipse.core.runtime.IPath)
+ */
+ public void removeUnnamedCoreResource(IPath fullPath) {
+ rootContext.removeUnnamedCoreResource(fullPath);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeUnnamedElResource(org.eclipse.core.runtime.IPath)
+ */
+ public void removeUnnamedElResource(IPath fullPath) {
+ rootContext.removeUnnamedElResource(fullPath);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#store(org.w3c.dom.Element)
+ */
+ public void store(Element root) {
+ rootContext.store(root);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.validation.IValidationContext#getRootProject()
+ */
+ public IProject getRootProject() {
+ return rootProject;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationErrorManager.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationErrorManager.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationErrorManager.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,297 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.validation;
+
+import java.util.Set;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.wst.validation.internal.TaskListUtility;
+import org.eclipse.wst.validation.internal.core.Message;
+import org.eclipse.wst.validation.internal.operations.WorkbenchReporter;
+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.IValidator;
+import org.jboss.tools.common.model.project.ext.ITextSourceReference;
+import org.jboss.tools.common.preferences.SeverityPreferences;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.jboss.tools.jst.web.kb.validation.IValidationContext;
+import org.jboss.tools.jst.web.kb.validation.IValidationErrorManager;
+
+/**
+ * @author Alexey Kazakov
+ */
+public abstract class ValidationErrorManager implements IValidationErrorManager {
+
+ protected IStatus OK_STATUS = new Status(IStatus.OK,
+ "org.eclipse.wst.validation", 0, "OK", null); //$NON-NLS-1$
//$NON-NLS-2$
+
+ protected IValidator validationManager;
+ protected ContextValidationHelper coreHelper;
+ protected IReporter reporter;
+ protected IProject rootProject;
+ protected String markerId;
+ protected String baseName;
+ protected IValidationContext validationContext;
+
+ /**
+ * Constructor
+ */
+ public ValidationErrorManager() {
+ }
+
+ protected void init(IProject project, ContextValidationHelper validationHelper,
ValidatorManager manager, IReporter reporter, IValidationContext validationContext) {
+ setRootProject(project);
+ setCoreHelper(validationHelper);
+ setValidationManager(manager);
+ setReporter(reporter);
+ setValidationContext(validationContext);
+ }
+
+ /**
+ * @param baseName the baseName to set
+ */
+ public void setBaseName(String baseName) {
+ this.baseName = baseName;
+ }
+
+ /**
+ * @param validationManager the validationManager to set
+ */
+ public void setValidationManager(IValidator validationManager) {
+ this.validationManager = validationManager;
+ }
+
+ /**
+ * @param coreHelper the coreHelper to set
+ */
+ public void setCoreHelper(ContextValidationHelper coreHelper) {
+ this.coreHelper = coreHelper;
+ }
+
+ /**
+ * @param reporter the reporter to set
+ */
+ public void setReporter(IReporter reporter) {
+ this.reporter = reporter;
+ }
+
+ /**
+ * @param rootProject the rootProject to set
+ */
+ public void setRootProject(IProject rootProject) {
+ this.rootProject = rootProject;
+ }
+
+ /**
+ * @param markerId the markerId to set
+ */
+ public void setMarkerId(String markerId) {
+ this.markerId = markerId;
+ }
+
+ /**
+ * @param validationContext the validationContext to set
+ */
+ public void setValidationContext(IValidationContext validationContext) {
+ this.validationContext = validationContext;
+ }
+
+ protected String getBaseName() {
+ return baseName;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.jboss.tools.seam.internal.core.validation.IValidationErrorManager#addError(java.lang.String,
+ * java.lang.String, java.lang.String[],
+ * org.jboss.tools.seam.core.ISeamTextSourceReference,
+ * org.eclipse.core.resources.IResource)
+ */
+ public IMarker addError(String messageId, String preferenceKey,
+ String[] messageArguments, ITextSourceReference location,
+ IResource target) {
+ return addError(messageId, preferenceKey, messageArguments, location
+ .getLength(), location.getStartPosition(), target);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.jboss.tools.seam.internal.core.validation.IValidationErrorManager#addError(java.lang.String,
+ * java.lang.String,
+ * org.jboss.tools.seam.core.ISeamTextSourceReference,
+ * org.eclipse.core.resources.IResource)
+ */
+ public IMarker addError(String messageId, String preferenceKey,
+ ITextSourceReference location, IResource target) {
+ return addError(messageId, preferenceKey, new String[0], location, target);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.IValidationErrorManager#addError(java.lang.String,
java.lang.String, java.lang.String[], org.eclipse.core.resources.IResource)
+ */
+ public IMarker addError(String messageId, String preferenceKey,
+ String[] messageArguments, IResource target) {
+ return addError(messageId, preferenceKey, messageArguments, 0, 0, target);
+ }
+
+ private String getMarkerId() {
+ return markerId;
+ }
+
+ /**
+ * @param project
+ * @param preferenceKey
+ * @return
+ */
+ protected abstract String getPreference(IProject project, String preferenceKey);
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.IValidationErrorManager#addError(java.lang.String,
java.lang.String, java.lang.String[], int, int, org.eclipse.core.resources.IResource)
+ */
+ public IMarker addError(String messageId, String preferenceKey,
+ String[] messageArguments, int length, int offset, IResource target) {
+ String preferenceValue = getPreference(target.getProject(), preferenceKey);
+ boolean ignore = false;
+ int messageSeverity = IMessage.HIGH_SEVERITY;
+ if (SeverityPreferences.WARNING.equals(preferenceValue)) {
+ messageSeverity = IMessage.NORMAL_SEVERITY;
+ } else if (SeverityPreferences.IGNORE.equals(preferenceValue)) {
+ ignore = true;
+ }
+
+ if (ignore) {
+ return null;
+ }
+
+ IMessage message = new Message(getBaseName(), messageSeverity,
+ messageId, messageArguments, target,
+ getMarkerId());
+ message.setLength(length);
+ message.setOffset(offset);
+ try {
+ if (coreHelper != null) {
+ coreHelper.getDocumentProvider().connect(target);
+ message.setLineNo(coreHelper.getDocumentProvider().getDocument(
+ target).getLineOfOffset(offset) + 1);
+ }
+ } catch (BadLocationException e) {
+ WebKbPlugin.getDefault().logError(
+ "Exception occurred during error line number calculation",
+ e);
+ return null;
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(
+ "Exception occurred during error line number calculation",
+ e);
+ return null;
+ } finally {
+ if(coreHelper!=null) {
+ coreHelper.getDocumentProvider().disconnect(target);
+ }
+ }
+
+ int severity = message.getSeverity();
+ try {
+ return TaskListUtility.addTask(this.getClass().getName().intern(), target,
""+message.getLineNumber(), message.getId(),
+ message.getText(this.getClass().getClassLoader()), severity, null,
message.getGroupName(), message.getOffset(), message.getLength());
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.IValidationErrorManager#addError(java.lang.String,
int, java.lang.String[], int, int, org.eclipse.core.resources.IResource)
+ */
+ public IMarker addError(String messageId, int severity, String[] messageArguments, int
length, int offset, IResource target) {
+ IMessage message = new Message(getBaseName(), severity,
+ messageId, messageArguments, target,
+ getMarkerId());
+ message.setLength(length);
+ message.setOffset(offset);
+ try {
+ if (coreHelper != null) {
+ coreHelper.getDocumentProvider().connect(target);
+ message.setLineNo(coreHelper.getDocumentProvider().getDocument(
+ target).getLineOfOffset(offset) + 1);
+ }
+ } catch (BadLocationException e) {
+ WebKbPlugin.getDefault().logError(
+ "Exception occurred during error line number calculation",
+ e);
+ return null;
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(
+ "Exception occurred during error line number calculation",
+ e);
+ return null;
+ }
+
+ try {
+ return TaskListUtility.addTask(this.getClass().getName().intern(), target,
""+message.getLineNumber(), message.getId(),
+ message.getText(this.getClass().getClassLoader()), severity, null,
message.getGroupName(), message.getOffset(), message.getLength());
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.jboss.tools.seam.internal.core.validation.IValidationErrorManager#displaySubtask(java.lang.String)
+ */
+ public void displaySubtask(String messageId) {
+ displaySubtask(messageId, null);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.jboss.tools.seam.internal.core.validation.IValidationErrorManager#displaySubtask(java.lang.String,
+ * java.lang.String[])
+ */
+ public void displaySubtask(String messageId, String[] messageArguments) {
+ IMessage message = new Message(getBaseName(), IMessage.NORMAL_SEVERITY,
+ messageId, messageArguments);
+ reporter.displaySubtask(validationManager, message);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.jboss.tools.seam.internal.core.validation.IValidationErrorManager#removeMessagesFromResources(java.util.Set)
+ */
+ public void removeMessagesFromResources(Set<IResource> resources) {
+ for (IResource r : resources) {
+ WorkbenchReporter.removeAllMessages(r, new String[]{this.getClass().getName()},
null);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.IValidationErrorManager#removeAllMessagesFromResource(org.eclipse.core.resources.IResource)
+ */
+ public void removeAllMessagesFromResource(IResource resource) {
+// reporter.removeAllMessages(validationManager, resource);
+ WorkbenchReporter.removeAllMessages(resource, new String[]{this.getClass().getName()},
null);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationErrorManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,119 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.validation;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.wst.validation.internal.core.ValidationException;
+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.IValidatorJob;
+import org.jboss.tools.jst.web.kb.validation.IValidator;
+
+/**
+ * This Manager invokes all dependent validators that should be invoked in one job.
+ * We need this one because wst validation framework does not let us invoke
+ * dependent validators in the same job.
+ * @author Alexey Kazakov
+ */
+public class ValidatorManager implements IValidatorJob {
+
+ private static Set<IProject> validatingProjects = new HashSet<IProject>();
+
+ public ValidatorManager() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.wst.validation.internal.provisional.core.IValidatorJob#getSchedulingRule(org.eclipse.wst.validation.internal.provisional.core.IValidationContext)
+ */
+ public ISchedulingRule getSchedulingRule(IValidationContext helper) {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.wst.validation.internal.provisional.core.IValidatorJob#validateInJob(org.eclipse.wst.validation.internal.provisional.core.IValidationContext,
org.eclipse.wst.validation.internal.provisional.core.IReporter)
+ */
+ public IStatus validateInJob(IValidationContext helper, IReporter reporter) throws
ValidationException {
+ ContextValidationHelper validationHelper = (ContextValidationHelper)helper;
+ IProject project = validationHelper.getProject();
+ if(project==null) {
+ return OK_STATUS;
+ }
+ IProject rootProject = validationHelper.getValidationContext().getRootProject();
+ IStatus status = OK_STATUS;
+ synchronized (validatingProjects) {
+ if(validatingProjects.contains(rootProject)) {
+ return OK_STATUS;
+ }
+ validatingProjects.add(rootProject);
+ }
+ synchronized (validatingProjects) {
+ org.jboss.tools.jst.web.kb.validation.IValidationContext validationContext = null;
+ try {
+ validationContext = new ValidationContext(project);
+ validationHelper.setValidationContext(validationContext);
+
+ List<IValidator> validators =
validationHelper.getValidationContext().getValidators();
+ Set<IFile> changedFiles = validationHelper.getChangedFiles();
+ if(!changedFiles.isEmpty()) {
+ status = validate(validators, changedFiles, rootProject, validationHelper,
reporter);
+ } else if(!validationContext.getRegisteredFiles().isEmpty()) {
+ validationContext.clearAllResourceLinks();
+ status = validateAll(validators, rootProject, validationHelper, reporter);
+ }
+ } finally {
+ if(validationContext!=null) {
+ validationContext.clearRegisteredFiles();
+ }
+ validatingProjects.remove(rootProject);
+ }
+ }
+ return status;
+ }
+
+ private IStatus validate(List<IValidator> validators, Set<IFile>
changedFiles, IProject rootProject, ContextValidationHelper validationHelper, IReporter
reporter) throws ValidationException {
+ for (IValidator validator : validators) {
+ validator.validate(changedFiles, rootProject, validationHelper, this, reporter,
validationHelper.getValidationContext());
+ }
+ return OK_STATUS;
+ }
+
+ private IStatus validateAll(List<IValidator> validators, IProject rootProject,
ContextValidationHelper validationHelper, IReporter reporter) throws ValidationException
{
+ for (IValidator validator : validators) {
+ validator.validateAll(rootProject, validationHelper, this, reporter,
validationHelper.getValidationContext());
+ }
+ return OK_STATUS;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.wst.validation.internal.provisional.core.IValidator#cleanup(org.eclipse.wst.validation.internal.provisional.core.IReporter)
+ */
+ public void cleanup(IReporter reporter) {
+ reporter = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.wst.validation.internal.provisional.core.IValidator#validate(org.eclipse.wst.validation.internal.provisional.core.IValidationContext,
org.eclipse.wst.validation.internal.provisional.core.IReporter)
+ */
+ public void validate(IValidationContext helper, IReporter reporter) throws
ValidationException {
+ validateInJob(helper, reporter);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/ELReference.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/ELReference.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/ELReference.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,292 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.kb.validation;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.common.el.core.model.ELExpression;
+import org.jboss.tools.common.el.core.model.ELInstance;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.parser.ELParser;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
+import org.jboss.tools.common.el.core.parser.SyntaxError;
+import org.jboss.tools.common.model.project.ext.ITextSourceReference;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.w3c.dom.Element;
+
+/**
+ * Represents a reference to EL in a resource
+ * @author Alexey Kazakov
+ */
+public class ELReference implements ITextSourceReference {
+
+ private IFile resource;
+ private IPath path;
+ private int length;
+ private int startPosition;
+ private ELExpression[] el;
+ private Set<IMarker> markers;
+ private IMarker[] markerArray;
+ private boolean needToInitMarkers = false;
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.core.ISeamTextSourceReference#getLength()
+ */
+ public int getLength() {
+ return length;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.core.ISeamTextSourceReference#getStartPosition()
+ */
+ public int getStartPosition() {
+ return startPosition;
+ }
+
+ /**
+ * @param length
+ */
+ public void setLength(int length) {
+ this.length = length;
+ }
+
+ /**
+ * @param startPosition
+ */
+ public void setStartPosition(int startPosition) {
+ this.startPosition = startPosition;
+ }
+
+ /**
+ * @return the resource
+ */
+ public IFile getResource() {
+ if(resource==null) {
+ IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
+ resource = wsRoot.getFile(path);
+ }
+ return resource;
+ }
+
+ /**
+ * @param resource the resource to set
+ */
+ public void setResource(IFile resource) {
+ this.resource = resource;
+ if(resource!=null) {
+ this.path = resource.getFullPath();
+ }
+ }
+
+ /**
+ * @return the path
+ */
+ public IPath getPath() {
+ return path;
+ }
+
+ /**
+ * @param path the path to set
+ */
+ public void setPath(IPath path) {
+ this.path = path;
+ }
+
+ /**
+ * @return the el
+ */
+ public ELExpression[] getEl() {
+ if(el==null) {
+ Set<ELExpression> exps = new HashSet<ELExpression>();
+ try {
+ String content = FileUtil.readStream(getResource().getContents());
+ String elText = content.substring(startPosition, startPosition + length);
+ int startEl = elText.indexOf("#{"); //$NON-NLS-1$
+ if(startEl>-1) {
+ ELParser parser = ELParserUtil.getJbossFactory().createParser();
+ ELModel model = parser.parse(elText);
+ List<SyntaxError> errors = model.getSyntaxErrors();
+ if(!errors.isEmpty()) {
+ WebKbPlugin.getDefault().logWarning("ELObject hold incorrect information.
Maybe resource " + getResource() + " has been changed.");
+ return null;
+ }
+ List<ELInstance> is = model.getInstances();
+ for (ELInstance i : is) {
+ if(!i.getErrors().isEmpty()) {
+ WebKbPlugin.getDefault().logWarning("ELObject hold incorrect information.
Maybe resource " + getResource() + " has been changed.");
+ continue;
+ }
+ exps.add(i.getExpression());
+ }
+ }
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+ el = exps.toArray(new ELExpression[0]);
+ }
+ return el;
+ }
+
+ /**
+ * @param el the el to set
+ */
+ public void setEl(ELExpression[] el) {
+ this.el = el;
+ }
+
+ /**
+ * @param insts
+ */
+ public void setEl(List<ELInstance> insts) {
+ Set<ELExpression> exps = new HashSet<ELExpression>();
+ for (ELInstance el : insts) {
+ exps.add(el.getExpression());
+ }
+ el = exps.toArray(new ELExpression[0]);
+ }
+
+ private IMarker[] EMPTY_MARKER_ARRAY = new IMarker[0];
+
+ private void initMarkers() {
+ if(markers==null) {
+ markers = new HashSet<IMarker>();
+ if(needToInitMarkers) {
+ IFile file = getResource();
+ if(file!=null) {
+ IMarker[] markers = null;
+ try {
+ markers = file.findMarkers(null, true, IResource.DEPTH_INFINITE);
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+ for(int i=0; i<markers.length; i++){
+ String groupName = markers[i].getAttribute("groupName", null);
//$NON-NLS-1$
+ if(groupName!=null &&
(groupName.equals(groupName.equals(IValidator.MARKED_RESOURCE_MESSAGE_GROUP)))) {
+ int start = markers[i].getAttribute(IMarker.CHAR_START, -1);
+ int end = markers[i].getAttribute(IMarker.CHAR_END, -1);
+ if(start>=startPosition && end<=startPosition+length) {
+ addMarker(markers[i]);
+ }
+ }
+ }
+ }
+ }
+ needToInitMarkers = false;
+ }
+ }
+
+ /**
+ * @param needToInitMarkers the needToInitMarkers to set
+ */
+ public synchronized void setNeedToInitMarkers(boolean needToInitMarkers) {
+ this.needToInitMarkers = needToInitMarkers;
+ }
+
+ public synchronized void setMarkers(Set<IMarker> markers) {
+ this.markers = markers;
+ }
+
+ /**
+ * @return the markers
+ */
+ public synchronized IMarker[] getMarkers() {
+ initMarkers();
+ if(markerArray==null) {
+ if(markers.isEmpty()) {
+ markerArray = EMPTY_MARKER_ARRAY;
+ } else {
+ markerArray = markers.toArray(new IMarker[0]);
+ }
+ }
+ return markerArray;
+ }
+
+ /**
+ * @param markers the markers to set
+ */
+ public synchronized void addMarker(IMarker marker) {
+ if(marker==null) {
+ return;
+ }
+ markerArray = null;
+ if(markers==null) {
+ markers = new HashSet<IMarker>();
+ }
+ markers.add(marker);
+ }
+
+ /**
+ * Removes all markers from this EL.
+ */
+ public synchronized void deleteMarkers() {
+ initMarkers();
+ for (IMarker marker : markers) {
+ try {
+ marker.delete();
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+ }
+ markers.clear();
+ markerArray = null;
+ }
+
+ /**
+ * Store this EL into XML element.
+ * @param element
+ */
+ public synchronized void store(Element element) {
+ element.setAttribute("path", path.toString()); //$NON-NLS-1$
+ element.setAttribute("offset", "" + startPosition); //$NON-NLS-1$
//$NON-NLS-2$
+ element.setAttribute("length", "" + length); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ /**
+ * Load this EL from XML element.
+ * @param element
+ */
+ public synchronized void load(Element element) {
+ path = new Path(element.getAttribute("path")); //$NON-NLS-1$
+ startPosition = new Integer(element.getAttribute("offset")); //$NON-NLS-1$
+ length = new Integer(element.getAttribute("length")); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if(this == obj) {
+ return true;
+ }
+ ELReference el = (ELReference)obj;
+ return this.path.equals(el.path) && this.startPosition == el.startPosition;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return path.hashCode() + startPosition;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/ELReference.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidatingProjectSet.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidatingProjectSet.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidatingProjectSet.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.kb.validation;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+
+/**
+ * Represents a set of projects which are being validated.
+ * @author Alexey Kazakov
+ */
+public interface IValidatingProjectSet {
+
+ /**
+ * @return the root project which holds a link to validating context for this project
set.
+ */
+ IProject getRootProject();
+
+ /**
+ * @return all projects of the set.
+ */
+ List<IProject> getAllProjests();
+
+ /**
+ * @return Root validating context which is associated with the root project.
+ */
+ IValidationContext getRootContext();
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidatingProjectSet.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationContext.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationContext.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationContext.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.kb.validation;
+
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.w3c.dom.Element;
+
+/**
+ * Contains information for validators that must be saved between validation invoking.
+ * @author Alexey Kazakov
+ */
+public interface IValidationContext {
+
+ /**
+ * @return IProject which holds this context. One context could store information for a
few dependent projects.
+ * But the only one project should store a context for all dependent projects. Such root
project will be returned by this method.
+ */
+ IProject getRootProject();
+
+ /**
+ * Save link between core resource and variable name.
+ * It's needed for incremental validation because we must save all linked resources
of changed java file.
+ */
+ void addLinkedCoreResource(String variableName, IPath linkedResourcePath, boolean
declaration);
+
+ /**
+ * Removes link between core resource and variable name.
+ * @param oldVariableName
+ * @param linkedResourcePath
+ */
+ void removeLinkedCoreResource(String name, IPath linkedResourcePath);
+
+ /**
+ * Removes link between core resources and variable names.
+ * @param linkedResources
+ */
+ void removeLinkedCoreResources(Set<IPath> resources);
+
+ /**
+ * Removes link between core resource and variable names.
+ * @param linkedResource
+ */
+ void removeLinkedCoreResource(IPath resource);
+
+ Set<IPath> getCoreResourcesByVariableName(String variableName, boolean
declaration);
+
+ Set<String> getVariableNamesByCoreResource(IPath fullPath, boolean declaration);
+
+ /**
+ * Adds core resource without any link to any context variable name.
+ * @param fullPath
+ */
+ void addUnnamedCoreResource(IPath fullPath);
+
+ /**
+ * @return Set of coreresources without any link to any context variable name.
+ * @param fullPath
+ */
+ Set<IPath> getUnnamedCoreResources();
+
+ /**
+ * Removes unnamed EL resource.
+ * @param fullPath
+ */
+ void removeUnnamedCoreResource(IPath fullPath);
+
+ /**
+ * Adds EL resource without any link to any context variable name.
+ * @param fullPath
+ */
+ void addUnnamedElResource(IPath fullPath);
+
+ /**
+ * @return Set of EL resources without any link to any context variable name.
+ * @param fullPath
+ */
+ Set<IPath> getUnnamedElResources();
+
+ /**
+ * Removes unnamed EL resource.
+ * @param fullPath
+ */
+ void removeUnnamedElResource(IPath fullPath);
+
+ /**
+ * We should validate all EL resources which use these names.
+ * @param name
+ */
+ void addVariableNameForELValidation(String name);
+
+ void removeLinkedEls(Set<IFile> resorces);
+
+ /**
+ * Get ELs which should be validated
+ * @param changedFiles
+ * @param onlyChangedVariables
+ * @return
+ */
+ Set<ELReference> getElsForValidation(Set<IFile> changedFiles, boolean
onlyChangedVariables);
+
+ void clearAll();
+
+ void clearAllResourceLinks();
+
+ void clearRegisteredFiles();
+
+ void clearElResourceLinks();
+
+ void clearOldVariableNameForElValidation();
+
+ /**
+ * Save link between EL and variable name.
+ * @param variableName
+ * @param el
+ */
+ void addLinkedEl(String variableName, ELReference el);
+
+ /**
+ * Removes link between EL and variable name.
+ * @param name
+ * @param el
+ */
+ void removeLinkedEl(String name, ELReference el);
+
+ /**
+ * Return ELs with given variable name
+ * @param variableName
+ * @return
+ */
+ Set<ELReference> getElsByVariableName(String variableName);
+
+ /**
+ * Stores context to XML element
+ * @param root
+ */
+ void store(Element root);
+
+ /**
+ * Loads context from XML element
+ * @param root
+ */
+ void load(Element root);
+
+ Set<IFile> getRemovedFiles();
+
+ void addRemovedFile(IFile file);
+
+ Set<IFile> getRegisteredFiles();
+
+ void registerFile(IFile file);
+
+ /**
+ * @return a list of validators which are associated with this context.
+ */
+ List<IValidator> getValidators();
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationContextProvider.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationContextProvider.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationContextProvider.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.kb.validation;
+
+
+/**
+ * @author Alexey Kazakov
+ */
+public interface IValidationContextProvider {
+
+ /**
+ * @return validation context
+ */
+ public IValidationContext getValidationContext();
+
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationContextProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationErrorManager.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationErrorManager.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationErrorManager.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,104 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.validation;
+
+import java.util.Set;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.jboss.tools.common.model.project.ext.ITextSourceReference;
+
+/**
+ * @author Alexey Kazakov
+ */
+public interface IValidationErrorManager {
+
+ /**
+ * Adds a marker to the resource
+ * @param messageId
+ * @param preferenceKey
+ * @param messageArguments
+ * @param location
+ * @param target
+ */
+ IMarker addError(String messageId, String preferenceKey,
+ String[] messageArguments, ITextSourceReference location,
+ IResource target);
+
+ /**
+ * Adds a marker to the resource
+ * @param messageId
+ * @param preferenceKey
+ * @param messageArguments
+ * @param target
+ */
+ IMarker addError(String messageId, String preferenceKey,
+ String[] messageArguments,
+ IResource target);
+
+ /**
+ * Adds a marker to the resource
+ * @param messageId
+ * @param preferenceKey
+ * @param location
+ * @param target
+ */
+ IMarker addError(String messageId, String preferenceKey,
+ ITextSourceReference location, IResource target);
+
+ /**
+ * Adds a marker to the resource
+ * @param messageId
+ * @param preferenceKey
+ * @param messageArguments
+ * @param length
+ * @param offset
+ * @param target
+ */
+ IMarker addError(String messageId, String preferenceKey,
+ String[] messageArguments, int length, int offset, IResource target);
+
+ /**
+ * Adds a marker to the resource
+ * @param messageId
+ * @param severity
+ * @param messageArguments
+ * @param length
+ * @param offset
+ * @param target
+ */
+ IMarker addError(String messageId, int severity, String[] messageArguments, int length,
int offset, IResource target);
+
+ /**
+ * Displays a subtask in the progress view.
+ * @param messageId
+ */
+ void displaySubtask(String messageId);
+
+ /**
+ * Displays a subtask in the progress view.
+ * @param messageId
+ * @param messageArguments
+ */
+ void displaySubtask(String messageId, String[] messageArguments);
+
+ /**
+ * Removes all markers for the resources
+ * @param resources
+ */
+ void removeMessagesFromResources(Set<IResource> resources);
+
+ /**
+ * Remove all validation messages for the resource.
+ * @param resource
+ */
+ void removeAllMessagesFromResource(IResource resource);
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationErrorManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidator.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidator.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidator.java 2009-10-15
12:31:45 UTC (rev 18105)
@@ -0,0 +1,63 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.validation;
+
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.validation.internal.core.ValidationException;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper;
+import org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager;
+
+/**
+ * Represents a validator that is managed by ValidatorManager.
+ * @author Alexey Kazakov
+ */
+public interface IValidator {
+
+ public static final String MARKED_RESOURCE_MESSAGE_GROUP = "markedKbResource";
//$NON-NLS-1$
+ public static final String RESOURCE_MESSAGE_ID = "org.jboss.tools.kb.problem";
//$NON-NLS-1$
+ public static final String EXTENSION_POINT_ID =
"org.jboss.tools.jst.web.kb.validator"; //$NON-NLS-1$
+
+ /**
+ * Incremental Validation
+ * @return
+ * @throws ValidationException
+ */
+ IStatus validate(Set<IFile> changedFiles, IProject project,
ContextValidationHelper validationHelper, ValidatorManager manager, IReporter reporter,
IValidationContext validationContext) throws ValidationException;
+
+ /**
+ * Full Validation
+ * @return
+ * @throws ValidationException
+ */
+ IStatus validateAll(IProject project, ContextValidationHelper validationHelper,
ValidatorManager manager, IReporter reporter, IValidationContext validationContext) throws
ValidationException;
+
+ /**
+ * @return unique ID of the validator
+ */
+ String getId();
+
+ /**
+ * @param project
+ * @return a set of projects which should be validated with given project.
+ */
+ IValidatingProjectSet getValidatingProjects(IProject project);
+
+ /**
+ * @param project
+ * @return true if this validator should validate given project.
+ */
+ boolean shouldValidate(IProject project);
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain