[302914] [UI] Filter settings UI needs polish
diff --git a/plugins/org.eclipse.wst.validation.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.validation.ui/META-INF/MANIFEST.MF
index f25773c..a6b01be 100644
--- a/plugins/org.eclipse.wst.validation.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.wst.validation.ui/META-INF/MANIFEST.MF
@@ -16,6 +16,7 @@
org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
org.eclipse.wst.common.frameworks;bundle-version="[1.1.200,2.0.0)",
org.eclipse.wst.validation;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.ui.forms;bundle-version="[3.3.100,4.0.0)"
+ org.eclipse.ui.forms;bundle-version="[3.3.100,4.0.0)",
+ org.eclipse.wst.common.project.facet.core;bundle-version="[1.4.102,2.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
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 b08bb43..5e847ec 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
@@ -145,6 +145,7 @@
FrProjectNatureLabel=Project &nature:
FrFacit=Facet
FrFacitLabel=&Facet id:
+FrNewFacitLabel=&Facet:
FrContentType=Content Type
FrContentTypeLabel=&Content Type:
FrMsgSev=Select the severity level for the following problems
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 99da9b9..8040b8d 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
@@ -104,6 +104,7 @@
public static String FrFacit;
public static String FrFacitLabel;
public static String FrContentType;
+ public static String FrNewFacitLabel;
public static String FrContentTypeLabel;
public static String FrMsgSev;
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 7f64b96..709621e 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,6 +11,7 @@
package org.eclipse.wst.validation.ui.internal.dialog;
import java.util.Map;
+import java.util.Set;
import java.util.TreeMap;
import org.eclipse.core.resources.IProject;
@@ -38,6 +39,9 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+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.ui.internal.HelpContextIds;
import org.eclipse.wst.validation.ui.internal.ValUIMessages;
@@ -419,9 +423,11 @@
IProjectNatureDescriptor[] pn = ResourcesPlugin.getWorkspace().getNatureDescriptors();
String items[] = new String[pn.length];
_ids = new String[pn.length];
+ String natureLabel = null;
for (int i=0; i<pn.length; i++){
+ natureLabel = pn[i].getLabel();
_ids[i] = pn[i].getNatureId();
- items[i] = pn[i].getLabel() + " - " + _ids[i]; //$NON-NLS-1$
+ items[i] = natureLabel.length() == 0 ? _ids[i] : natureLabel + " - " + _ids[i]; //$NON-NLS-1$
}
_natures = new Combo(control, SWT.DROP_DOWN);
_natures.setItems(items);
@@ -453,7 +459,8 @@
public static class FacetPage extends WizardPage implements FilterWizardPage {
- private Text _pattern;
+ private Combo facets;
+ private String [] ids;
public FacetPage(){
super("facet", ValUIMessages.FrFacit, null); //$NON-NLS-1$
@@ -464,11 +471,24 @@
Composite control = new Composite(parent, SWT.NONE);
setControl(control);
control.setLayout(new GridLayout(2, false));
- (new Label(control, SWT.NONE)).setText(ValUIMessages.FrFacitLabel);
- _pattern = new Text(control, SWT.BORDER);
- _pattern.setFocus();
- _pattern.setLayoutData(new GridData(300, SWT.DEFAULT));
- _pattern.addModifyListener(new ModifyListener(){
+ (new Label(control, SWT.NONE)).setText(ValUIMessages.FrNewFacitLabel);
+
+ Set<IProjectFacet> projectFacets = ProjectFacetsManager.getProjectFacets();
+
+ Object[] projectFacetsArray = projectFacets.toArray();
+ String items[] = new String[projectFacetsArray.length];
+ ids = new String[projectFacetsArray.length];
+
+ for(int i = 0; i < projectFacetsArray.length; i++)
+ {
+ ProjectFacet facet = (ProjectFacet)projectFacetsArray[i];
+ ids[i] = facet.getId();
+ items[i] = facet.getLabel() + " - " + ids[i]; //$NON-NLS-1$
+ }
+
+ facets = new Combo(control, SWT.DROP_DOWN);
+ facets.setItems(items);
+ facets.addModifyListener(new ModifyListener(){
public void modifyText(ModifyEvent e) {
getContainer().updateButtons();
@@ -479,14 +499,18 @@
public FilterRule getFilterRule() {
if (!isPageComplete())return null;
- FilterRule rule = FilterRule.createFacet(_pattern.getText());
+
+ int i = facets.getSelectionIndex();
+ if (i == -1) return null;
+
+ FilterRule rule = FilterRule.createFacet(ids[i]);
return rule;
}
public boolean isPageComplete() {
- if (_pattern == null)return false;
- if (_pattern.getText() == null)return false;
- return _pattern.getText().trim().length() > 0;
+ if (facets == null)return false;
+ if (facets.getText() == null)return false;
+ return facets.getText().trim().length() > 0;
}
}
@@ -512,6 +536,8 @@
for (IContentType type : types){
String name = type.getName();
if (name == null)name = type.getId();
+ else
+ name = name + " - " + type.getId(); //$NON-NLS-1$
_map.put(name, type);
}
String items[] = new String[_map.size()];
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 dffd276..8a8c04c 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
@@ -14,7 +14,9 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNatureDescriptor;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -22,6 +24,8 @@
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.validation.internal.ContentTypeWrapper;
import org.eclipse.wst.validation.internal.Deserializer;
import org.eclipse.wst.validation.internal.ExtensionConstants;
@@ -206,6 +210,8 @@
public static final class ProjectNature extends FilterRule {
+ private String patternLabel = null;
+
private ProjectNature(IConfigurationElement rule) {
super(rule.getAttribute(ExtensionConstants.RuleAttrib.id));
@@ -213,6 +219,9 @@
public ProjectNature(String projectNature) {
super(projectNature);
+
+ IProjectNatureDescriptor nature = ResourcesPlugin.getWorkspace().getNatureDescriptor(projectNature);
+ patternLabel = nature.getLabel();
}
public String getDisplayableType() {
@@ -232,6 +241,14 @@
return Boolean.FALSE;
}
+ 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 FileExt extends FilterRuleCaseSensitive {
@@ -363,6 +380,7 @@
public static final class Facet extends FilterRule {
private final String _versionExpression;
+ private String _facetLabel;
private Facet(IConfigurationElement rule){
super(rule.getAttribute(ExtensionConstants.RuleAttrib.id));
@@ -373,6 +391,9 @@
public Facet(String facetId, String versionExpression) {
super(facetId);
_versionExpression = versionExpression;
+
+ IProjectFacet facet = ProjectFacetsManager.getProjectFacet(facetId);
+ _facetLabel = facet.getLabel();
}
public String getType() {
@@ -397,9 +418,20 @@
@Override
public String toString() {
+ String facetLabel = _facetLabel;
StringBuffer b = new StringBuffer(200);
b.append(getDisplayableType());
b.append(": "); //$NON-NLS-1$
+
+ //Dispay facet Labels when selecting Settings
+ if(_facetLabel == null){
+ IProjectFacet facet = ProjectFacetsManager.getProjectFacet(_pattern);
+ facetLabel = facet.getLabel();
+ }
+
+ b.append(facetLabel);
+ b.append(" - "); //$NON-NLS-1$
+
b.append(_pattern);
if (_versionExpression != null){
@@ -409,7 +441,6 @@
}
return b.toString();
}
-
}
public static final class ContentType extends FilterRule {
@@ -475,10 +506,14 @@
@Override
public String toString() {
- if (_exactMatch)return NLS.bind(ValMessages.ContentTypeExact, getDisplayableType(), _pattern);
- return NLS.bind(ValMessages.ContentTypeNotExact, getDisplayableType(), _pattern);
+ try {
+ if (_exactMatch)return NLS.bind(ValMessages.ContentTypeExact, getDisplayableType(), _type.getName().concat(" - ").concat(_pattern)); //$NON-NLS-1$
+ return NLS.bind(ValMessages.ContentTypeNotExact, getDisplayableType(), _type.getName().concat(" - ").concat(_pattern)); //$NON-NLS-1$
+ }catch(NullPointerException npe) {
+ if (_exactMatch)return NLS.bind(ValMessages.ContentTypeExact, getDisplayableType(), _pattern);
+ return NLS.bind(ValMessages.ContentTypeNotExact, getDisplayableType(), _pattern);
+ }
}
-
}
public static final class FilePattern extends FilterRuleCaseSensitive {