[366103] Add a new filter rule to include/exclude based on a target runtime WTP 3.3.2
diff --git a/plugins/org.eclipse.wst.validation.ui/property_files/org/eclipse/wst/validation/ui/internal/messages.properties b/plugins/org.eclipse.wst.validation.ui/property_files/org/eclipse/wst/validation/ui/internal/messages.properties
index 5e847ec..364d308 100644
--- a/plugins/org.eclipse.wst.validation.ui/property_files/org/eclipse/wst/validation/ui/internal/messages.properties
+++ b/plugins/org.eclipse.wst.validation.ui/property_files/org/eclipse/wst/validation/ui/internal/messages.properties
@@ -110,6 +110,7 @@
LabelProjects=Project &nature
LabelFacets=&Facet
LabelContentType=&Content Type
+LabelTargetRuntime=&Target Runtime
# Note to translators, keep the <A> and </A> tags exactly as they are
DoNotShowResults=Do not show this dialog in the future.
@@ -119,6 +120,7 @@
DescProjects=A project nature.
DescFacets=A facet.
DescContentType=A content type, for example the XML content type.
+DescTargetRuntime=A target runtime, for example "JBoss v5.0".
ErrorsWarnings=Errors/Warnings
@@ -149,6 +151,7 @@
FrContentType=Content Type
FrContentTypeLabel=&Content Type:
FrMsgSev=Select the severity level for the following problems
+FrTargetRuntimeLabel=Target Runtime
RebuildTitle=Validation Settings Changed
RebuildMsg=The validation settings have changed. A full rebuild is required for the changes to take effect. Do the full build now?
diff --git a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ValUIMessages.java b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ValUIMessages.java
index 8040b8d..5001d84 100644
--- a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ValUIMessages.java
+++ b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ValUIMessages.java
@@ -73,12 +73,14 @@
public static String LabelFacets;
public static String LabelContentType;
public static String LabelEnableProjectSpecific;
+ public static String LabelTargetRuntime;
public static String DescExtension;
public static String DescFile;
public static String DescProjects;
public static String DescFacets;
public static String DescContentType;
+ public static String DescTargetRuntime;
public static String Validation;
public static String ValidationStatus;
@@ -107,6 +109,7 @@
public static String FrNewFacitLabel;
public static String FrContentTypeLabel;
public static String FrMsgSev;
+ public static String FrTargetRuntimeLabel;
public static String RebuildTitle;
public static String RebuildMsg;
diff --git a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/NewFilterRule.java b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/NewFilterRule.java
index 709621e..5c7e53b 100644
--- a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/NewFilterRule.java
+++ b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/NewFilterRule.java
@@ -43,6 +43,7 @@
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.common.project.facet.core.internal.ProjectFacet;
import org.eclipse.wst.validation.internal.model.FilterRule;
+import org.eclipse.wst.validation.internal.model.ValidatorHelper;
import org.eclipse.wst.validation.ui.internal.HelpContextIds;
import org.eclipse.wst.validation.ui.internal.ValUIMessages;
@@ -95,7 +96,11 @@
private IWizardPage returnOrBuildPage(int selectedFilter) {
IWizardPage page = null;
- if (_project != null && selectedFilter == 2)selectedFilter = 4;
+ if (_project != null){
+ if(selectedFilter == 2) selectedFilter = 4;
+ else if(selectedFilter == 3) selectedFilter = 5;
+ }
+
switch (selectedFilter){
case 0:
page = new FileExtPage();
@@ -112,6 +117,9 @@
case 4:
page = new ContentTypePage();
break;
+ case 5:
+ page = new TargetRuntimePage();
+ break;
}
addPage(page);
return page;
@@ -136,19 +144,19 @@
String[] desc = null;
if (_project != null){
labels = new String[]{ValUIMessages.LabelExtension, ValUIMessages.LabelFile,
- ValUIMessages.LabelContentType};
+ ValUIMessages.LabelContentType, ValUIMessages.LabelTargetRuntime};
desc = new String[]{ValUIMessages.DescExtension, ValUIMessages.DescFile,
- ValUIMessages.DescContentType};
+ ValUIMessages.DescContentType, ValUIMessages.DescTargetRuntime};
}
else {
labels = new String[]{ValUIMessages.LabelExtension, ValUIMessages.LabelFile,
ValUIMessages.LabelProjects, ValUIMessages.LabelFacets,
- ValUIMessages.LabelContentType};
+ ValUIMessages.LabelContentType, ValUIMessages.LabelTargetRuntime};
desc = new String[]{ValUIMessages.DescExtension, ValUIMessages.DescFile,
ValUIMessages.DescProjects, ValUIMessages.DescFacets,
- ValUIMessages.DescContentType};
+ ValUIMessages.DescContentType, ValUIMessages.DescTargetRuntime};
}
Composite control = new Composite(parent, SWT.NONE);
@@ -581,6 +589,67 @@
}
+ public static class TargetRuntimePage extends WizardPage implements FilterWizardPage {
+
+ private Combo _pattern;
+ private String [] ids;
+
+ public TargetRuntimePage(){
+ super("targetRuntime", ValUIMessages.FrTargetRuntimeLabel, null); //$NON-NLS-1$
+ }
+
+ public void createControl(Composite parent) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HelpContextIds.FRContentType);
+ Composite control = new Composite(parent, SWT.NONE);
+ setControl(control);
+ control.setLayout(new GridLayout(2, false));
+ (new Label(control, SWT.NONE)).setText("Target Runtime"); //$NON-NLS-1$
+
+ Object[] targetRuntimes = ValidatorHelper.getRuntimes();
+
+ String items[] = new String[targetRuntimes.length];
+ ids = new String[targetRuntimes.length];
+
+ for(int i = 0; i < targetRuntimes.length; i++)
+ {
+
+ ids[i] = ValidatorHelper.getRuntimeID(targetRuntimes[i]);
+ items[i] = ValidatorHelper.getRuntimeName(targetRuntimes[i]);
+ }
+
+ _pattern = new Combo(control, SWT.DROP_DOWN | SWT.READ_ONLY);
+ _pattern.setFocus();
+ _pattern.setLayoutData(new GridData(300, SWT.DEFAULT));
+ _pattern.setVisibleItemCount(20);
+ _pattern.setItems(items);
+ _pattern.addModifyListener(new ModifyListener(){
+
+ public void modifyText(ModifyEvent e) {
+ getContainer().updateButtons();
+ }
+
+ });
+ }
+
+ public FilterRule getFilterRule() {
+ if (!isPageComplete())return null;
+
+ int i = _pattern.getSelectionIndex();
+ if (i == -1) return null;
+
+ FilterRule rule = FilterRule.createTargetRuntime(ids[i]);
+ return rule;
+ }
+
+
+ public boolean isPageComplete() {
+ if (_pattern == null)return false;
+ if (_pattern.getText() == null)return false;
+ return _pattern.getText().trim().length() > 0;
+ }
+
+ }
+
interface FilterWizardPage {
/**
* Answer the rule that was created.
diff --git a/plugins/org.eclipse.wst.validation/property_files/org/eclipse/wst/validation/internal/messages.properties b/plugins/org.eclipse.wst.validation/property_files/org/eclipse/wst/validation/internal/messages.properties
index 8a77220..26b62fb 100644
--- a/plugins/org.eclipse.wst.validation/property_files/org/eclipse/wst/validation/internal/messages.properties
+++ b/plugins/org.eclipse.wst.validation/property_files/org/eclipse/wst/validation/internal/messages.properties
@@ -50,6 +50,7 @@
RuleFolder=Folder
RuleFull=Qualified File
RulePattern=Pattern
+RuleTargetRuntime=Target Runtime
FileExtWithCase={0}: {1} (case sensitive)
FileExtWithoutCase={0}: {1}
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ExtensionConstants.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ExtensionConstants.java
index 6649d59..c0b4bda 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ExtensionConstants.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ExtensionConstants.java
@@ -103,6 +103,9 @@
/** contentType - filter by content type. */
String contentType = "contentType"; //$NON-NLS-1$
+ /** targetRuntime - filter by targetRuntime. */
+ String targetRuntime = "targetRuntime"; //$NON-NLS-1$
+
/** pattern - filter paths by regular expression. */
String pattern = "pattern"; //$NON-NLS-1$
}
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValMessages.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValMessages.java
index d2383c1..2835105 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValMessages.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/ValMessages.java
@@ -67,6 +67,7 @@
public static String RuleContentType;
public static String RuleFacet;
public static String RulePattern;
+ public static String RuleTargetRuntime;
public static String ContentTypeExact;
public static String ContentTypeNotExact;
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/model/FilterRule.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/model/FilterRule.java
index f4fa8de..edcf8da 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/model/FilterRule.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/model/FilterRule.java
@@ -95,6 +95,11 @@
return new Facet(pattern, null);
}
+ if (ExtensionConstants.Rule.targetRuntime.equals(type)){
+ String pattern = des.getString();
+ return new TargetRuntime(pattern);
+ }
+
if (ExtensionConstants.Rule.pattern.equals(type)){
String pattern = des.getString();
boolean caseSensitive = des.getBoolean();
@@ -124,6 +129,10 @@
public static FilterRule createContentType(String contentType, boolean exactMatch){
return new ContentType(contentType, exactMatch);
}
+
+ public static FilterRule createTargetRuntime(String targetRuntime){
+ return new TargetRuntime(targetRuntime);
+ }
protected FilterRule(String pattern){
_pattern = pattern;
@@ -383,7 +392,7 @@
public static final class Facet extends FilterRule {
private final String _versionExpression;
- private String _facetLabel;
+ private String _facetLabel = null;
private Facet(IConfigurationElement rule){
super(rule.getAttribute(ExtensionConstants.RuleAttrib.id));
@@ -395,10 +404,14 @@
super(facetId);
_versionExpression = versionExpression;
- IProjectFacet facet = ProjectFacetsManager.getProjectFacet(facetId);
-
- if(facet != null){
- _facetLabel = facet.getLabel();
+ try
+ {
+ IProjectFacet facet = ProjectFacetsManager.getProjectFacet(facetId);
+ if(facet != null){
+ _facetLabel = facet.getLabel();
+ }
+ } catch(IllegalArgumentException ex) {
+ //do nothing
}
}
@@ -522,6 +535,42 @@
}
}
+ public static final class TargetRuntime extends FilterRule {
+
+ private String patternLabel = null;
+
+ private TargetRuntime(IConfigurationElement rule) {
+ super(rule.getAttribute(ExtensionConstants.RuleAttrib.id));
+ }
+
+ public TargetRuntime(String targetRuntime) {
+ super(targetRuntime);
+
+ String runtime = ValidatorHelper.getRuntimeName(targetRuntime);
+
+ if(runtime != null){
+ patternLabel = runtime;
+ }
+ }
+
+ public String getType() {
+ return ExtensionConstants.Rule.targetRuntime;
+ }
+
+ public String getDisplayableType() {
+ return ValMessages.RuleTargetRuntime;
+ }
+
+ @Override
+ public String toString() {
+ if(patternLabel != null && patternLabel.length() > 0){
+ return getDisplayableType() + ": " + patternLabel.concat(" - ").concat(_pattern); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ return getDisplayableType() + ": " + _pattern; //$NON-NLS-1$
+ }
+ }
+
public static final class FilePattern extends FilterRuleCaseSensitive {
private final Pattern _compiledPattern;
@@ -556,7 +605,7 @@
return _compiledPattern.matcher(name).matches();
}
}
-
+
/**
* Save your settings into the serializer.
* @param ser
@@ -571,5 +620,4 @@
if (_pattern != null)h += _pattern.hashCode();
return h;
}
-
}
diff --git a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/model/ValidatorHelper.java b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/model/ValidatorHelper.java
index 288f226..4ecb4ca 100644
--- a/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/model/ValidatorHelper.java
+++ b/plugins/org.eclipse.wst.validation/vf2/org/eclipse/wst/validation/internal/model/ValidatorHelper.java
@@ -10,6 +10,12 @@
*******************************************************************************/
package org.eclipse.wst.validation.internal.model;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;
+import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
import org.eclipse.wst.validation.internal.ValidatorMutable;
/**
@@ -27,4 +33,62 @@
for (FilterGroup group : v.getGroups())if (group.isExclude())return true;
return false;
}
+
+ /**
+ * Return all the Runtimes defined in the workspace.
+ */
+ public static Object[] getRuntimes()
+ {
+ Iterator<IRuntime> runtimes = RuntimeManager.getRuntimes().iterator();
+ List <IRuntime> list = new ArrayList<IRuntime>();
+
+ while (runtimes.hasNext()) {
+ IRuntime runtime1 = (IRuntime) runtimes.next();
+ String id = runtime1.getProperty("id"); //$NON-NLS-1$
+
+ if(id != null){
+ list.add(runtime1);
+ }
+ }
+
+ return list.toArray();
+ }
+
+
+ /**
+ * Return the ID of the given target Runtime.
+ * @param targetRuntime
+ * @return
+ */
+ public static String getRuntimeID(Object targetRuntime)
+ {
+ IRuntime runtime = (IRuntime) targetRuntime;
+ return runtime.getProperty("id"); //$NON-NLS-1$
+ }
+
+ /**
+ * Return the target runtime name of the given the ID
+ * @param id
+ * @return
+ */
+ public static String getRuntimeName(String id)
+ {
+ IRuntime runtime = RuntimeManager.getRuntime(id);
+ if(runtime != null)
+ return runtime.getLocalizedName();
+
+ return null;
+ }
+
+ /**
+ * Return the Name of the given target runtime.
+ * @param targetRuntime
+ * @return
+ */
+ public static String getRuntimeName(Object targetRuntime)
+ {
+ IRuntime runtime = (IRuntime) targetRuntime;
+
+ return runtime.getLocalizedName();
+ }
}
diff --git a/plugins/org.eclipse.wst.validation/xsds/exclude.exsd b/plugins/org.eclipse.wst.validation/xsds/exclude.exsd
index 92d7647..4637c14 100644
--- a/plugins/org.eclipse.wst.validation/xsds/exclude.exsd
+++ b/plugins/org.eclipse.wst.validation/xsds/exclude.exsd
@@ -2,15 +2,20 @@
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.wst.validation" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
- <appinfo>
+ <appInfo>
<meta.schema plugin="org.eclipse.wst.validation" id="exclude" name="Validator Exclusion"/>
- </appinfo>
+ </appInfo>
<documentation>
A way to add additional exclusion filters to a V2 validator.
</documentation>
</annotation>
<element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
<complexType>
<sequence>
<element ref="validator" minOccurs="1" maxOccurs="unbounded"/>
@@ -34,9 +39,9 @@
<documentation>
The short user friendly name for the exclusion.
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute translatable="true"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
@@ -57,9 +62,9 @@
<documentation>
The fully qualifed validator id that is being extended.
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="identifier"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
@@ -119,6 +124,23 @@
</complexType>
</element>
+ <element name="targetRuntime">
+ <annotation>
+ <documentation>
+ Used to filter on target runtime.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The target runtime id, for example "org.eclipse.jst.server.generic.runtime.jboss5".
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
<element name="file">
<complexType>
<attribute name="name" type="string" use="required">
@@ -168,6 +190,7 @@
<element ref="projectNature" minOccurs="0" maxOccurs="unbounded"/>
<element ref="facet" minOccurs="0" maxOccurs="unbounded"/>
<element ref="contentType" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="targetRuntime" minOccurs="0" maxOccurs="unbounded"/>
<element ref="pattern" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
@@ -208,6 +231,7 @@
</attribute>
</complexType>
</element>
+
<element name="pattern">
<annotation>
<documentation>
@@ -234,18 +258,18 @@
</element>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="since"/>
- </appinfo>
+ </appInfo>
<documentation>
WebTools 3.0
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="examples"/>
- </appinfo>
+ </appInfo>
<documentation>
<!-- A plug-in is turning off the T1A validator for projects that have the ModuleCoreNature -->
<extension
@@ -262,14 +286,13 @@
</exclude>
</validator>
</extension>
-
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="apiInfo"/>
- </appinfo>
+ </appInfo>
<documentation>
Provisional API.
</documentation>
@@ -277,5 +300,4 @@
-
</schema>
diff --git a/plugins/org.eclipse.wst.validation/xsds/validator.exsd b/plugins/org.eclipse.wst.validation/xsds/validator.exsd
index 737f8cb..b03167d 100644
--- a/plugins/org.eclipse.wst.validation/xsds/validator.exsd
+++ b/plugins/org.eclipse.wst.validation/xsds/validator.exsd
@@ -225,6 +225,7 @@
<element ref="projectNature" minOccurs="0" maxOccurs="unbounded"/>
<element ref="facet" minOccurs="0" maxOccurs="unbounded"/>
<element ref="contentType" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="targetRuntime" minOccurs="0" maxOccurs="unbounded"/>
<element ref="pattern" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
@@ -249,6 +250,23 @@
</complexType>
</element>
+ <element name="targetRuntime">
+ <annotation>
+ <documentation>
+ Used to filter on target runtimes.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The target runtime id.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
<element name="group">
<annotation>
<documentation>