[254647] [ui]Validation should be triggered when changing the setting of the "indicate if grammar is not specified" preference settings
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/ui/AbstractValidationSettingsPage.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/ui/AbstractValidationSettingsPage.java
deleted file mode 100644
index 3d7d962..0000000
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/ui/AbstractValidationSettingsPage.java
+++ /dev/null
@@ -1,424 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.jsp.ui.internal.preferences.ui;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IPreferencesService;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.resource.JFaceResources;
-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.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.forms.events.ExpansionAdapter;
-import org.eclipse.ui.forms.events.ExpansionEvent;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
-import org.eclipse.wst.sse.core.internal.validate.ValidationMessage;
-import org.eclipse.wst.sse.ui.internal.preferences.ui.ScrolledPageContent;
-import org.eclipse.wst.validation.ValidationFramework;
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- * Based on org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock
- */
-abstract class AbstractValidationSettingsPage extends AbstractPropertyPreferencePage {
-
- private List fCombos;
- private List fExpandables;
-
- private SelectionListener fSelectionListener;
-
- private IPreferencesService fPreferencesService = null;
-
- private static final String SETTINGS_EXPANDED = "expanded"; //$NON-NLS-1$
-
- private ValidationFramework fValidation;
-
- private class ComboData {
- private String fKey;
- private int[] fSeverities;
- private int fIndex;
- int originalSeverity = -2;
-
- public ComboData(String key, int[] severities, int index) {
- fKey = key;
- fSeverities = severities;
- fIndex = index;
- }
-
- public String getKey() {
- return fKey;
- }
-
- public void setIndex(int index) {
- fIndex = index;
- }
-
- public int getIndex() {
- return fIndex;
- }
-
- /**
- * Sets the severity index based on <code>severity</code>.
- * If the severity doesn't exist, the index is set to -1.
- *
- * @param severity the severity level
- */
- public void setSeverity(int severity) {
- for (int i = 0; fSeverities != null && i < fSeverities.length; i++) {
- if (fSeverities[i] == severity) {
- setIndex(i);
- return;
- }
- }
-
- setIndex(-1);
- }
-
- public int getSeverity() {
- return (fIndex >= 0 && fSeverities != null && fIndex < fSeverities.length) ? fSeverities[fIndex] : -1;
- }
-
- boolean isChanged() {
- return fSeverities[fIndex] != originalSeverity;
- }
- }
-
- public AbstractValidationSettingsPage() {
- super();
- fCombos = new ArrayList();
- fExpandables = new ArrayList();
- fPreferencesService = Platform.getPreferencesService();
- fValidation = ValidationFramework.getDefault();
- }
-
- /**
- * Creates a Combo widget in the composite <code>parent</code>. The data
- * in the Combo is associated with <code>key</code>. The Combo data is
- * generated based on the integer <code>values</code> where the index
- * of <code>values</code> corresponds to the index of <code>valueLabels</code>
- *
- * @param parent the composite to create the combo box in
- * @param label the label to give the combo box
- * @param key the unique key to identify the combo box
- * @param values the values represented by the combo options
- * @param valueLabels the calues displayed in the combo box
- * @param indent how far to indent the combo box label
- *
- * @return the generated combo box
- */
- protected Combo addComboBox(Composite parent, String label, String key, int[] values, String[] valueLabels, int indent) {
- GridData gd = new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1);
- gd.horizontalIndent = indent;
-
- Label labelControl = new Label(parent, SWT.LEFT);
- labelControl.setFont(JFaceResources.getDialogFont());
- labelControl.setText(label);
- labelControl.setLayoutData(gd);
-
- Combo comboBox = newComboControl(parent, key, values, valueLabels);
- comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-
- return comboBox;
- }
-
- /**
- * Creates a combo box and associates the combo data with the
- * combo box.
- *
- * @param composite the composite to create the combo box in
- * @param key the unique key to identify the combo box
- * @param values the values represented by the combo options
- * @param valueLabels the values displayed in the combo box
- *
- * @return the generated combo box
- */
- protected Combo newComboControl(Composite composite, String key, int[] values, String[] valueLabels) {
- ComboData data = new ComboData(key, values, -1);
-
- Combo comboBox = new Combo(composite, SWT.READ_ONLY);
- comboBox.setItems(valueLabels);
- comboBox.setData(data);
- comboBox.addSelectionListener(getSelectionListener());
- comboBox.setFont(JFaceResources.getDialogFont());
-
- makeScrollableCompositeAware(comboBox);
-
- int severity = -1;
- if (key != null)
- severity = fPreferencesService.getInt(getPreferenceNodeQualifier(), key, ValidationMessage.WARNING, createPreferenceScopes());
-
- if (severity == ValidationMessage.ERROR || severity == ValidationMessage.WARNING || severity == ValidationMessage.IGNORE) {
- data.setSeverity(severity);
- data.originalSeverity = severity;
- }
-
- if (data.getIndex() >= 0)
- comboBox.select(data.getIndex());
-
- fCombos.add(comboBox);
- return comboBox;
- }
-
- protected SelectionListener getSelectionListener() {
- if (fSelectionListener == null) {
- fSelectionListener = new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {}
-
- public void widgetSelected(SelectionEvent e) {
- controlChanged(e.widget);
- }
- };
- }
- return fSelectionListener;
- }
-
- protected void controlChanged(Widget widget) {
- ComboData data = (ComboData) widget.getData();
- if (widget instanceof Combo) {
- data.setIndex(((Combo) widget).getSelectionIndex());
- }
- else {
- return;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractSettingsPage#storeValues()
- */
- protected void storeValues() {
- if (fCombos == null || fCombos.size() == 0)
- return;
-
- Iterator it = fCombos.iterator();
-
- IScopeContext[] contexts = createPreferenceScopes();
-
- while (it.hasNext()) {
- ComboData data = (ComboData) ((Combo) it.next()).getData();
- if (data.getKey() != null) {
- contexts[0].getNode(getPreferenceNodeQualifier()).putInt(data.getKey(), data.getSeverity());
- }
- }
-
- for (int i = 0; i < contexts.length; i++) {
- try {
- contexts[i].getNode(getPreferenceNodeQualifier()).flush();
- }
- catch (BackingStoreException e) {
-
- }
- }
- }
-
- protected ExpandableComposite getParentExpandableComposite(Control control) {
- Control parent = control.getParent();
- while (!(parent instanceof ExpandableComposite) && parent != null) {
- parent = parent.getParent();
- }
- if (parent instanceof ExpandableComposite) {
- return (ExpandableComposite) parent;
- }
- return null;
- }
-
- protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns) {
- ExpandableComposite excomposite = new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
- excomposite.setText(label);
- excomposite.setExpanded(false);
- excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
- excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1));
- excomposite.addExpansionListener(new ExpansionAdapter() {
- public void expansionStateChanged(ExpansionEvent e) {
- expandedStateChanged((ExpandableComposite) e.getSource());
- }
- });
- fExpandables.add(excomposite);
- makeScrollableCompositeAware(excomposite);
- return excomposite;
- }
-
- protected Composite createStyleSectionWithContentComposite(Composite parent, String label, int nColumns) {
- ExpandableComposite excomposite = new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
- excomposite.setText(label);
- excomposite.setExpanded(false);
- excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
- excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1));
- excomposite.addExpansionListener(new ExpansionAdapter() {
- public void expansionStateChanged(ExpansionEvent e) {
- expandedStateChanged((ExpandableComposite) e.getSource());
- }
- });
- fExpandables.add(excomposite);
- makeScrollableCompositeAware(excomposite);
-
- Composite inner = new Composite(excomposite, SWT.NONE);
- inner.setFont(excomposite.getFont());
- inner.setLayout(new GridLayout(nColumns, false));
- excomposite.setClient(inner);
- return inner;
- }
-
- protected final void expandedStateChanged(ExpandableComposite expandable) {
- ScrolledPageContent parentScrolledComposite = getParentScrolledComposite(expandable);
- if (parentScrolledComposite != null) {
- parentScrolledComposite.reflow(true);
- }
- }
-
- private void makeScrollableCompositeAware(Control control) {
- ScrolledPageContent parentScrolledComposite = getParentScrolledComposite(control);
- if (parentScrolledComposite != null) {
- parentScrolledComposite.adaptChild(control);
- }
- }
-
- protected ScrolledPageContent getParentScrolledComposite(Control control) {
- Control parent = control.getParent();
- while (!(parent instanceof ScrolledPageContent) && parent != null) {
- parent = parent.getParent();
- }
- if (parent instanceof ScrolledPageContent) {
- return (ScrolledPageContent) parent;
- }
- return null;
- }
-
- protected void storeSectionExpansionStates(IDialogSettings section) {
- for (int i = 0; i < fExpandables.size(); i++) {
- ExpandableComposite comp = (ExpandableComposite) fExpandables.get(i);
- section.put(SETTINGS_EXPANDED + String.valueOf(i), comp.isExpanded());
- }
- }
-
- protected void restoreSectionExpansionStates(IDialogSettings settings) {
- for (int i= 0; i < fExpandables.size(); i++) {
- ExpandableComposite excomposite= (ExpandableComposite) fExpandables.get(i);
- if (settings == null) {
- excomposite.setExpanded(i == 0); // only expand the first node by default
- } else {
- excomposite.setExpanded(settings.getBoolean(SETTINGS_EXPANDED + String.valueOf(i)));
- }
- }
- }
-
- protected void resetSeverities() {
- IEclipsePreferences defaultContext = new DefaultScope().getNode(getPreferenceNodeQualifier());
- for (int i = 0; i < fCombos.size(); i++) {
- ComboData data = (ComboData) ((Combo) fCombos.get(i)).getData();
- int severity = defaultContext.getInt(data.getKey(), ValidationMessage.WARNING);
- data.setSeverity(severity);
- ((Combo) fCombos.get(i)).select(data.getIndex());
- }
- }
-
- protected boolean shouldRevalidateOnSettingsChange() {
- Iterator it = fCombos.iterator();
-
- while (it.hasNext()) {
- ComboData data = (ComboData) ((Combo) it.next()).getData();
- if (data.isChanged())
- return true;
- }
- return false;
- }
-
- public boolean performOk() {
- if(super.performOk() && shouldRevalidateOnSettingsChange()) {
- MessageBox mb = new MessageBox(this.getShell(), SWT.APPLICATION_MODAL | SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_INFORMATION | SWT.RIGHT);
- mb.setText(HTMLUIMessages.Validation_Title);
- /* Choose which message to use based on if its project or workspace settings */
- String msg = (getProject() == null) ? HTMLUIMessages.Validation_Workspace : HTMLUIMessages.Validation_Project;
- mb.setMessage(msg);
- switch(mb.open()) {
- case SWT.CANCEL:
- return false;
- case SWT.YES:
- storeValues();
- ValidateJob job = new ValidateJob(HTMLUIMessages.Validation_jobName);
- job.schedule();
- case SWT.NO:
- storeValues();
- default:
- return true;
- }
- }
- return true;
- }
-
- /**
- * Performs validation after validation preferences have been modified.
- */
- private class ValidateJob extends Job {
-
- public ValidateJob(String name) {
- super(name);
- }
-
- protected IStatus run(IProgressMonitor monitor) {
- IStatus status = Status.OK_STATUS;
- try {
- IProject[] projects = null;
- /* Changed preferences for a single project, only validate it */
- if (getProject() != null)
- projects = new IProject[]{getProject()};
- /* Workspace-wide preferences changed */
- else {
- /* Get all of the projects in the workspace */
- projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- IEclipsePreferences prefs = null;
- List projectList = new ArrayList();
-
- /* Filter out projects that use project-specific settings or have been closed */
- for (int i = 0; i < projects.length; i++) {
- prefs = new ProjectScope(projects[i]).getNode(getPreferenceNodeQualifier());
- if (projects[i].isAccessible() && !prefs.getBoolean(getProjectSettingsKey(), false))
- projectList.add(projects[i]);
- }
- projects = (IProject[]) projectList.toArray(new IProject[projectList.size()]);
- }
- fValidation.validate(projects, true, false, monitor);
- }
- catch (CoreException ce) {
- status = Status.CANCEL_STATUS;
- }
-
- return status;
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/ui/JSPValidationPreferencePage.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/ui/JSPValidationPreferencePage.java
index f67dae3..39d4fb6 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/ui/JSPValidationPreferencePage.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/ui/JSPValidationPreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * Copyright (c) 2008, 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
@@ -40,6 +40,7 @@
import org.eclipse.ui.dialogs.PreferenceLinkArea;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
import org.eclipse.wst.sse.core.internal.validate.ValidationMessage;
+import org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractValidationSettingsPage;
import org.eclipse.wst.sse.ui.internal.preferences.ui.ScrolledPageContent;
public class JSPValidationPreferencePage extends AbstractValidationSettingsPage {
diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java
index 8c1b3e4..e1f4b83 100644
--- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java
+++ b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java
@@ -204,11 +204,7 @@
public static String HTMLValidationPreferencePage_8;
public static String HTMLValidationPreferencePage_9;
- // Validation
- public static String Validation_Title;
- public static String Validation_Workspace;
- public static String Validation_Project;
- public static String Validation_jobName;
+
// Hyperlinks
public static String Hyperlink_line;
diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties
index 13b58c4..d148dd8f9 100644
--- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties
+++ b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties
@@ -179,10 +179,5 @@
HTMLValidationPreferencePage_36=Invalid location of text in tag:
HTMLValidationPreferencePage_37=Missing attribute equals sign character:
-Validation_Title=Validation Settings Changed
-Validation_Workspace=The validation settings have changed. A full validation is required for changes to take effect. Validate now?
-Validation_Project=The validation settings have changed. A validation of the project is required for changes to take effect. Validate the project now?
-Validation_jobName=Validating...
-
Hyperlink_line={0}={1} : line {2}
Open=Open ''{0}''
diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLValidationPreferencePage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLValidationPreferencePage.java
index 3c227f7..9186cce 100644
--- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLValidationPreferencePage.java
+++ b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLValidationPreferencePage.java
@@ -25,6 +25,7 @@
import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
import org.eclipse.wst.sse.core.internal.validate.ValidationMessage;
+import org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractValidationSettingsPage;
import org.eclipse.wst.sse.ui.internal.preferences.ui.ScrolledPageContent;
public class HTMLValidationPreferencePage extends AbstractValidationSettingsPage {
diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/PropertyPreferencePage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/PropertyPreferencePage.java
deleted file mode 100644
index ae95c84..0000000
--- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/PropertyPreferencePage.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.html.ui.internal.preferences.ui;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.dialogs.ControlEnableState;
-import org.eclipse.jface.viewers.DecoratingLabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-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.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.dialogs.ListDialog;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.eclipse.ui.views.navigator.ResourceSorter;
-import org.eclipse.wst.sse.core.internal.tasks.TaskTagPreferenceKeys;
-import org.eclipse.wst.sse.ui.internal.SSEUIMessages;
-import org.eclipse.wst.sse.ui.internal.SSEUIPlugin;
-
-/**
- * Based loosely on org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage
- */
-abstract class PropertyPreferencePage extends PropertyPage implements IWorkbenchPreferencePage {
- private static final boolean _debugPreferences = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.ui/preferences-properties")); //$NON-NLS-1$ //$NON-NLS-2$
- /*
- * Disable link data, prevents the display of a "workspace" or "project"
- * settings link to prevent recursive dialog launching
- */
- private static final Object DISABLE_LINK = "DISABLE_LINK"; //$NON-NLS-1$
-
- private Map fData = null;
-
- private Button fEnableProjectSettings;
-
- private Link fProjectSettingsLink;
-
- private Control fCommon;
-
- private ControlEnableState fEnablements;
-
- public PropertyPreferencePage() {
- super();
- }
-
- public final void applyData(Object data) {
- super.applyData(data);
- if (data instanceof Map) {
- fData = (Map) data;
- updateLinkEnablement();
- }
- }
-
- protected abstract Control createCommonContents(Composite composite);
-
- public final Control createContents(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
-
- GridLayout layout = new GridLayout();
- composite.setLayout(layout);
- GridData data = new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(data);
-
- Composite checkLinkComposite = new Composite(composite, SWT.NONE);
- checkLinkComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- checkLinkComposite.setLayout(new GridLayout(2, false));
-
- if (getProject() != null) {
- fEnableProjectSettings = new Button(checkLinkComposite, SWT.CHECK);
- fEnableProjectSettings.setText(SSEUIMessages.EnableProjectSettings); //$NON-NLS-1$//$NON-NLS-2$
- fEnableProjectSettings.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
- boolean enabledForProject = createPreferenceScopes()[0].getNode(getPreferenceNodeQualifier()).getBoolean(getProjectSettingsKey(), false);
- fEnableProjectSettings.setSelection(enabledForProject);
- }
- else {
- Label spacer = new Label(checkLinkComposite, SWT.CHECK);
- spacer.setLayoutData(new GridData());
- }
-
- fProjectSettingsLink = new Link(checkLinkComposite, SWT.NONE);
- fProjectSettingsLink.setLayoutData(new GridData(SWT.END, SWT.BEGINNING, true, false));
-
- /*
- * "element" should be a project, if null, link to per-project
- * properties
- */
- if (getProject() != null) {
- fProjectSettingsLink.setText("<a>" + SSEUIMessages.ConfigureWorkspaceSettings + "</a>"); //$NON-NLS-1$//$NON-NLS-2$
- }
- else {
- fProjectSettingsLink.setText("<a>" + SSEUIMessages.ConfigureProjectSettings + "</a>"); //$NON-NLS-1$//$NON-NLS-2$
- }
-
- updateLinkEnablement();
-
- fProjectSettingsLink.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
- if (getProject() == null) {
- openProjectSettings();
- }
- else {
- openWorkspaceSettings();
- }
- }
-
- });
-
- if (getProject() != null) {
- Label line = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
- line.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
- }
-
-// final Control common = createCommonContents(composite);
- fCommon = createCommonContents(composite);
-
- fCommon.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- if (fEnableProjectSettings != null) {
- SelectionAdapter selectionAdapter = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- super.widgetSelected(e);
- enablePreferenceContent(fEnableProjectSettings.getSelection());
- }
- };
- selectionAdapter.widgetSelected(null);
- fEnableProjectSettings.addSelectionListener(selectionAdapter);
- }
-
- applyDialogFont(composite);
- return composite;
- }
-
- protected IScopeContext[] createPreferenceScopes() {
- IProject project = getProject();
- if (project != null) {
- return new IScopeContext[]{new ProjectScope(project), new InstanceScope(), new DefaultScope()};
- }
- return new IScopeContext[]{new InstanceScope(), new DefaultScope()};
- }
-
- protected abstract String getPreferenceNodeQualifier();
-
- protected abstract String getPreferencePageID();
-
- protected IProject getProject() {
- if (getElement() != null) {
- if (getElement() instanceof IProject) {
- return (IProject) getElement();
- }
- Object adapter = getElement().getAdapter(IProject.class);
- if (adapter instanceof IProject) {
- return (IProject) adapter;
- }
- adapter = getElement().getAdapter(IResource.class);
- if (adapter instanceof IProject) {
- return (IProject) adapter;
- }
- }
- return null;
- }
-
- protected abstract String getProjectSettingsKey();
-
- protected abstract String getPropertyPageID();
-
- protected boolean isElementSettingsEnabled() {
- return fEnableProjectSettings != null && fEnableProjectSettings.getSelection();
- }
-
- void openProjectSettings() {
- ListDialog dialog = new ListDialog(getShell()) {
-
- protected Control createDialogArea(Composite container) {
- Control area = super.createDialogArea(container);
- getTableViewer().setSorter(new ResourceSorter(ResourceSorter.NAME));
- return area;
- }
- };
- dialog.setMessage(SSEUIMessages.PropertyPreferencePage_02);
- dialog.setContentProvider(new IStructuredContentProvider() {
- public void dispose() {
- }
-
- public Object[] getElements(Object inputElement) {
- return ((IWorkspace) inputElement).getRoot().getProjects();
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- });
- dialog.setLabelProvider(new DecoratingLabelProvider(new WorkbenchLabelProvider(), SSEUIPlugin.getDefault().getWorkbench().getDecoratorManager().getLabelDecorator()));
- dialog.setInput(ResourcesPlugin.getWorkspace());
- dialog.setTitle(SSEUIMessages.PropertyPreferencePage_01);
- if (dialog.open() == Window.OK) {
- Object[] result = dialog.getResult();
- if (result.length > 0) {
- IProject project = (IProject) dialog.getResult()[0];
- Map data = new HashMap();
- data.put(DISABLE_LINK, Boolean.TRUE);
- PreferencesUtil.createPropertyDialogOn(getShell(), project, getPropertyPageID(), new String[]{getPropertyPageID()}, data).open();
- }
- }
- }
-
- void openWorkspaceSettings() {
- Map data = new HashMap();
- data.put(DISABLE_LINK, Boolean.TRUE);
- PreferencesUtil.createPreferenceDialogOn(getShell(), getPreferencePageID(), new String[]{getPreferencePageID()}, data).open();
- }
-
- public boolean performOk() {
- boolean ok = super.performOk();
- IScopeContext[] preferenceScopes = createPreferenceScopes();
- if (getProject() != null) {
- if (isElementSettingsEnabled()) {
- if (_debugPreferences) {
- System.out.println(getClass().getName() + " setting " + TaskTagPreferenceKeys.TASK_TAG_PER_PROJECT + " (" + true + ") in scope " + preferenceScopes[0].getName() + ":" + preferenceScopes[0].getLocation()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- preferenceScopes[0].getNode(getPreferenceNodeQualifier()).putBoolean(getProjectSettingsKey(), fEnableProjectSettings.getSelection());
- }
- else {
- if (_debugPreferences) {
- System.out.println(getClass().getName() + " removing " + TaskTagPreferenceKeys.TASK_TAG_PER_PROJECT + " from scope " + preferenceScopes[0].getName() + ":" + preferenceScopes[0].getLocation()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- preferenceScopes[0].getNode(getPreferenceNodeQualifier()).remove(getProjectSettingsKey());
- }
- }
- return ok;
- }
-
- protected void performDefaults() {
- if(getProject() != null && fEnableProjectSettings != null) {
- fEnableProjectSettings.setSelection(false);
- enablePreferenceContent(false);
- }
- super.performDefaults();
- }
-
- private void updateLinkEnablement() {
- if (fData != null && fProjectSettingsLink != null) {
- fProjectSettingsLink.setEnabled(!Boolean.TRUE.equals(fData.get(DISABLE_LINK)));
- }
- }
-
- /**
- * Controls the enablement of the common content region
- * of a property or preference page
- *
- * @param enable the enabled state of the common content
- * area
- */
- protected void enablePreferenceContent(boolean enable) {
- if(enable) {
- if(fEnablements != null) {
- fEnablements.restore();
- fEnablements = null;
- }
- }
- else {
- if(fEnablements == null)
- fEnablements = ControlEnableState.disable(fCommon);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src-tasktags/org/eclipse/wst/sse/ui/internal/preferences/ui/PropertyPreferencePage.java b/bundles/org.eclipse.wst.sse.ui/src-tasktags/org/eclipse/wst/sse/ui/internal/preferences/ui/PropertyPreferencePage.java
index 11b85ad..3aefbf8 100644
--- a/bundles/org.eclipse.wst.sse.ui/src-tasktags/org/eclipse/wst/sse/ui/internal/preferences/ui/PropertyPreferencePage.java
+++ b/bundles/org.eclipse.wst.sse.ui/src-tasktags/org/eclipse/wst/sse/ui/internal/preferences/ui/PropertyPreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
+ * Copyright (c) 2001, 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
@@ -67,6 +67,10 @@
private Link fProjectSettingsLink;
+ private Control fCommon;
+
+ private ControlEnableState fEnablements;
+
public PropertyPreferencePage() {
super();
}
@@ -142,24 +146,14 @@
line.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
}
- final Control common = createCommonContents(composite);
- common.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fCommon = createCommonContents(composite);
+ fCommon.setLayoutData(new GridData(GridData.FILL_BOTH));
if (fEnableProjectSettings != null) {
SelectionAdapter selectionAdapter = new SelectionAdapter() {
- ControlEnableState enablements = null;
-
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
- if (fEnableProjectSettings.getSelection()) {
- if (enablements != null) {
- enablements.restore();
- enablements = null;
- }
- }
- else {
- enablements = ControlEnableState.disable(common);
- }
+ enablePreferenceContent(fEnableProjectSettings.getSelection());
}
};
selectionAdapter.widgetSelected(null);
@@ -275,6 +269,34 @@
return ok;
}
+ protected void performDefaults() {
+ if(getProject() != null && fEnableProjectSettings != null) {
+ fEnableProjectSettings.setSelection(false);
+ enablePreferenceContent(false);
+ }
+ super.performDefaults();
+ }
+
+ /**
+ * Controls the enablement of the common content region
+ * of a property or preference page
+ *
+ * @param enable the enabled state of the common content
+ * area
+ */
+ protected void enablePreferenceContent(boolean enable) {
+ if(enable) {
+ if(fEnablements != null) {
+ fEnablements.restore();
+ fEnablements = null;
+ }
+ }
+ else {
+ if(fEnablements == null)
+ fEnablements = ControlEnableState.disable(fCommon);
+ }
+ }
+
private void updateLinkEnablement() {
if (fData != null && fProjectSettingsLink != null) {
fProjectSettingsLink.setEnabled(!Boolean.TRUE.equals(fData.get(DISABLE_LINK)));
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/SSEUIMessages.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/SSEUIMessages.java
index 6da6081..114cee3 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/SSEUIMessages.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/SSEUIMessages.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2005, 2010 IBM Corporation and others. All rights reserved. This
+ * 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 http://www.eclipse.org/legal/epl-v10.html
@@ -465,4 +465,11 @@
public static String CodeAssistAdvancedConfigurationBlock_PagesDown;
public static String CodeAssistAdvancedConfigurationBlock_PagesUp;
public static String CodeAssistAdvancedConfigurationBlock_separate_table_category_column_title;
+
+ // Validation
+ public static String Validation_Title;
+ public static String Validation_Workspace;
+ public static String Validation_Project;
+ public static String Validation_jobName;
+
}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/SSEUIPluginResources.properties b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/SSEUIPluginResources.properties
index 9d018de..4a51ea9 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/SSEUIPluginResources.properties
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/SSEUIPluginResources.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2001, 2009 IBM Corporation and others.
+# Copyright (c) 2001, 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
@@ -443,4 +443,8 @@
CodeAssistAdvancedConfigurationBlock_PagesDown=Do&wn
CodeAssistAdvancedConfigurationBlock_PagesUp=U&p
CodeAssistAdvancedConfigurationBlock_separate_table_description=Select the &enablement and order of proposal categories that are cycled through when repeatedly invoking content assist:
-CodeAssistAdvancedConfigurationBlock_separate_table_category_column_title=Content Assist Pages
\ No newline at end of file
+CodeAssistAdvancedConfigurationBlock_separate_table_category_column_title=Content Assist Pages
+Validation_Title=Validation Settings Changed
+Validation_Workspace=The validation settings have changed. A full validation is required for changes to take effect. Validate now?
+Validation_Project=The validation settings have changed. A validation of the project is required for changes to take effect. Validate the project now?
+Validation_jobName=Validating...
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/AbstractValidationSettingsPage.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/ui/AbstractValidationSettingsPage.java
similarity index 88%
rename from bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/AbstractValidationSettingsPage.java
rename to bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/ui/AbstractValidationSettingsPage.java
index f2ab08d..32fbb58 100644
--- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/AbstractValidationSettingsPage.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/ui/AbstractValidationSettingsPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
+ * Copyright (c) 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
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.wst.html.ui.internal.preferences.ui;
+package org.eclipse.wst.sse.ui.internal.preferences.ui;
import java.util.ArrayList;
import java.util.Iterator;
@@ -33,6 +33,7 @@
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.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -42,19 +43,18 @@
import org.eclipse.ui.forms.events.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.wst.html.ui.internal.HTMLUIMessages;
import org.eclipse.wst.sse.core.internal.validate.ValidationMessage;
-import org.eclipse.wst.sse.ui.internal.preferences.ui.ScrolledPageContent;
+import org.eclipse.wst.sse.ui.internal.SSEUIMessages;
import org.eclipse.wst.validation.ValidationFramework;
import org.osgi.service.prefs.BackingStoreException;
/**
* Based on org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock
*/
-abstract class AbstractValidationSettingsPage extends PropertyPreferencePage {
+public abstract class AbstractValidationSettingsPage extends PropertyPreferencePage {
private List fCombos;
- private List fExpandables;
+ protected List fExpandables;
private SelectionListener fSelectionListener;
@@ -268,6 +268,27 @@
return excomposite;
}
+ protected Composite createStyleSectionWithContentComposite(Composite parent, String label, int nColumns) {
+ ExpandableComposite excomposite = new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
+ excomposite.setText(label);
+ excomposite.setExpanded(false);
+ excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
+ excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1));
+ excomposite.addExpansionListener(new ExpansionAdapter() {
+ public void expansionStateChanged(ExpansionEvent e) {
+ expandedStateChanged((ExpandableComposite) e.getSource());
+ }
+ });
+ fExpandables.add(excomposite);
+ makeScrollableCompositeAware(excomposite);
+
+ Composite inner = new Composite(excomposite, SWT.NONE);
+ inner.setFont(excomposite.getFont());
+ inner.setLayout(new GridLayout(nColumns, false));
+ excomposite.setClient(inner);
+ return inner;
+ }
+
protected final void expandedStateChanged(ExpandableComposite expandable) {
ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(expandable);
if (parentScrolledComposite != null) {
@@ -275,7 +296,7 @@
}
}
- private void makeScrollableCompositeAware(Control control) {
+ protected void makeScrollableCompositeAware(Control control) {
ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(control);
if (parentScrolledComposite != null) {
parentScrolledComposite.adaptChild(control);
@@ -335,16 +356,16 @@
public boolean performOk() {
if(super.performOk() && shouldRevalidateOnSettingsChange()) {
MessageBox mb = new MessageBox(this.getShell(), SWT.APPLICATION_MODAL | SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_INFORMATION | SWT.RIGHT);
- mb.setText(HTMLUIMessages.Validation_Title);
+ mb.setText(SSEUIMessages.Validation_Title);
/* Choose which message to use based on if its project or workspace settings */
- String msg = (getProject() == null) ? HTMLUIMessages.Validation_Workspace : HTMLUIMessages.Validation_Project;
+ String msg = (getProject() == null) ? SSEUIMessages.Validation_Workspace : SSEUIMessages.Validation_Project;
mb.setMessage(msg);
switch(mb.open()) {
case SWT.CANCEL:
return false;
case SWT.YES:
storeValues();
- ValidateJob job = new ValidateJob(HTMLUIMessages.Validation_jobName);
+ ValidateJob job = new ValidateJob(SSEUIMessages.Validation_jobName);
job.schedule();
case SWT.NO:
storeValues();
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java
index 4183f42..5ff3602 100644
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java
+++ b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 IBM Corporation and others.
+ * Copyright (c) 2006, 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
@@ -78,7 +78,7 @@
setupValidation(nestedcontext);
teardownRequired = true;
}
-
+ nestedcontext.setProject(file.getProject());
validate(file, null, result, reporter, nestedcontext);
if (teardownRequired)
@@ -109,6 +109,7 @@
IFile file = (IFile) context.loadModel(GET_FILE, parms);
if (file != null && shouldValidate(file))
{
+ nestedcontext.setProject(file.getProject());
// The helper may not have a file stored in it but may have an InputStream if being
// called from a source other than the validation framework such as an editor.
if (context.loadModel(GET_INPUTSTREAM) instanceof InputStream)
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/NestedValidatorContext.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/NestedValidatorContext.java
index 3c2710a..bb96caf 100644
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/NestedValidatorContext.java
+++ b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/NestedValidatorContext.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
+ * Copyright (c) 2006, 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,8 @@
package org.eclipse.wst.xml.core.internal.validation.core;
+import org.eclipse.core.resources.IProject;
+
/**
* A context class for validators to be able to determine the context of
@@ -19,4 +21,13 @@
*/
public class NestedValidatorContext
{
+ private IProject fProject;
+
+ public void setProject(IProject project) {
+ fProject = project;
+ }
+
+ public IProject getProject() {
+ return fProject;
+ }
}
diff --git a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/Validator.java b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/Validator.java
index 4aae874..1824ab4 100644
--- a/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/Validator.java
+++ b/bundles/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/eclipse/Validator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
+ * Copyright (c) 2001, 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
@@ -14,8 +14,13 @@
import java.io.InputStream;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IPreferencesService;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.wst.validation.ValidationResult;
import org.eclipse.wst.validation.ValidationState;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -33,7 +38,6 @@
{
private static final String XML_VALIDATOR_CONTEXT = "org.eclipse.wst.xml.core.validatorContext"; //$NON-NLS-1$
protected int indicateNoGrammar = 0;
-
/**
* Set any preferences for XML validation.
*
@@ -42,9 +46,19 @@
protected void setupValidation(NestedValidatorContext context)
{
super.setupValidation(context);
- indicateNoGrammar = XMLCorePlugin.getDefault().getPluginPreferences().getInt(XMLCorePreferenceNames.INDICATE_NO_GRAMMAR);
+ //indicateNoGrammar = XMLCorePlugin.getDefault().getPluginPreferences().getInt();
}
+ protected IScopeContext[] createPreferenceScopes(NestedValidatorContext context) {
+ final IProject project = context.getProject();
+ if (project != null && project.isAccessible()) {
+ final ProjectScope projectScope = new ProjectScope(project);
+ if (projectScope.getNode(XMLCorePlugin.getDefault().getBundle().getSymbolicName()).getBoolean(XMLCorePreferenceNames.USE_PROJECT_SETTINGS, false))
+ return new IScopeContext[]{projectScope, new InstanceScope(), new DefaultScope()};
+ }
+ return new IScopeContext[]{new InstanceScope(), new DefaultScope()};
+ }
+
/* (non-Javadoc)
* @see org.eclipse.wst.xml.core.internal.validation.core.AbstractNestedValidator#validate(java.lang.String, java.io.InputStream, org.eclipse.wst.xml.core.internal.validation.core.NestedValidatorContext)
*/
@@ -58,12 +72,16 @@
XMLValidator validator = XMLValidator.getInstance();
XMLValidationConfiguration configuration = new XMLValidationConfiguration();
+ final IScopeContext[] preferenceScopes = createPreferenceScopes(context);
+ final IPreferencesService preferencesService = Platform.getPreferencesService();
+ indicateNoGrammar = preferencesService.getInt(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.INDICATE_NO_GRAMMAR, 0, preferenceScopes);
+
try
{
- Preferences pluginPreferences = XMLCorePlugin.getDefault().getPluginPreferences();
+ //Preferences pluginPreferences = XMLCorePlugin.getDefault().getPluginPreferences();
configuration.setFeature(XMLValidationConfiguration.INDICATE_NO_GRAMMAR, indicateNoGrammar);
- configuration.setFeature(XMLValidationConfiguration.USE_XINCLUDE, pluginPreferences.getBoolean(XMLCorePreferenceNames.USE_XINCLUDE));
- configuration.setFeature(XMLValidationConfiguration.HONOUR_ALL_SCHEMA_LOCATIONS, pluginPreferences.getBoolean(XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS));
+ configuration.setFeature(XMLValidationConfiguration.USE_XINCLUDE, preferencesService.getBoolean(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.USE_XINCLUDE, false, preferenceScopes));
+ configuration.setFeature(XMLValidationConfiguration.HONOUR_ALL_SCHEMA_LOCATIONS, preferencesService.getBoolean(XMLCorePlugin.getDefault().getBundle().getSymbolicName(), XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS, true, preferenceScopes));
}
catch(Exception e)
{
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java
index 00f597c..edaf2a6 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2010 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
@@ -284,4 +284,5 @@
public static final String NAMESPACE_IN_PI_TARGET = "namespaceInPITarget"; //$NON-NLS-1$
public static final String MISSING_TAG_NAME = "missingTagName"; //$NON-NLS-1$
public static final String WHITESPACE_AT_START = "whitespaceAtStart"; //$NON-NLS-1$
+ public static final String USE_PROJECT_SETTINGS = "use-project-settings";//$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.wst.xml.ui/plugin.properties b/bundles/org.eclipse.wst.xml.ui/plugin.properties
index b8c51a8..501baf1 100644
--- a/bundles/org.eclipse.wst.xml.ui/plugin.properties
+++ b/bundles/org.eclipse.wst.xml.ui/plugin.properties
@@ -24,6 +24,7 @@
XML_Syntax_Coloring=Syntax Coloring
XML_Typing=Typing
XML_Editor.name=XML Editor
+XML_Property_validation=XML Syntax
###############################################################################
_UI_WIZARD_NEW_XML=XML File
XML_New_File.tooltip=New XML File
diff --git a/bundles/org.eclipse.wst.xml.ui/plugin.xml b/bundles/org.eclipse.wst.xml.ui/plugin.xml
index 1e6e62d..d38b647 100644
--- a/bundles/org.eclipse.wst.xml.ui/plugin.xml
+++ b/bundles/org.eclipse.wst.xml.ui/plugin.xml
@@ -227,6 +227,20 @@
</page>
</extension>
+ <!-- Web content settings -->
+ <extension point="org.eclipse.ui.propertyPages">
+ <page
+ name="%XML_Property_validation"
+ class="org.eclipse.wst.xml.ui.internal.preferences.XMLValidatorPreferencePage"
+ id="org.eclipse.wst.xml.ui.propertyPage.project.validation"
+ category="ValidationPropertiesPage">
+ <enabledWhen>
+ <adapt type="org.eclipse.core.resources.IProject">
+
+ </adapt>
+ </enabledWhen>
+ </page>
+ </extension>
<!-- Keywords for preference and properties pages -->
<extension point="org.eclipse.ui.keywords">
<keyword
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLValidatorPreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLValidatorPreferencePage.java
index 155bdaa..273a5ef 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLValidatorPreferencePage.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLValidatorPreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2010 IBM Corporation and others.
+ * Copyright (c) 2001, 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
@@ -13,14 +13,15 @@
package org.eclipse.wst.xml.ui.internal.preferences;
-
import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.jface.dialogs.ControlEnableState;
-import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -28,491 +29,295 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferencePage;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.wst.sse.core.internal.validate.ValidationMessage;
+import org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractValidationSettingsPage;
import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds;
+import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
+public class XMLValidatorPreferencePage extends AbstractValidationSettingsPage {
+ private static final String SETTINGS_SECTION_NAME = "XMLValidationSeverities";//$NON-NLS-1$
-public class XMLValidatorPreferencePage extends AbstractPreferencePage {
- private Combo fIndicateNoGrammar;
-
- private Button fHonourAllSchemaLocations;
+ boolean fOriginalUseXIncludeButtonSelected;
- private Button fUseXinclude;
-
- private Button fExtendedMarkupValidation;
-
- private Combo fEmptyElementTag;
-
- private Combo fEndTagWithAttributes;
-
- private Combo fInvalidWhitespaceBeforeTagname;
-
- private Combo fMissingClosingBracket;
-
- private Combo fMissingClosingQuote;
-
- private Combo fMissingEndTag;
-
- private Combo fMissingStartTag;
-
- private Combo fMissingQuotes;
-
- private Combo fInvalidNamespaceInPI;
-
- private Combo fMissingTagName;
-
- private Combo fInvalidWhitespaceAtStart;
+ boolean fOriginalUseHonourAllButtonSelected;
- private Group fMarkupValidationGroup;
- private ControlEnableState fMarkupState;
-
- private static final String[] SEVERITIES = {XMLUIMessages.Indicate_no_grammar_specified_severities_error, XMLUIMessages.Indicate_no_grammar_specified_severities_warning, XMLUIMessages.Indicate_no_grammar_specified_severities_ignore};
- private static final String[] MARKUP_SEVERITIES = {XMLUIMessages.Severity_error, XMLUIMessages.Severity_warning, XMLUIMessages.Severity_ignore};
+ boolean fOriginalUseExtendedMarkupValidation;
- protected Control createContents(Composite parent) {
- Composite composite = (Composite)super.createContents(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.XML_PREFWEBX_VALIDATOR_HELPID);
- createContentsForValidatingGroup(composite);
- createContentsForMarkupValidationGroup(composite);
- setSize(composite);
- loadPreferences();
+ private Combo fIndicateNoGrammar = null;
- return composite;
- }
+ private Button fHonourAllSchemaLocations = null;
- protected void createContentsForValidatingGroup(Composite parent) {
- Group validatingGroup = createGroup(parent, 2);
- ((GridLayout)validatingGroup.getLayout()).makeColumnsEqualWidth = false;
- validatingGroup.setText(XMLUIMessages.Validating_files);
+ private Button fUseXinclude = null;
- if (fIndicateNoGrammar == null) {
- createLabel(validatingGroup, XMLUIMessages.Indicate_no_grammar_specified);
- fIndicateNoGrammar = createCombo(validatingGroup, SEVERITIES);
- }
- if (fUseXinclude == null) {
- fUseXinclude = createCheckBox(validatingGroup, XMLUIMessages.Use_XInclude);
- ((GridData)fUseXinclude.getLayoutData()).horizontalSpan = 2;
- }
- if (fHonourAllSchemaLocations == null) {
- fHonourAllSchemaLocations = createCheckBox(validatingGroup, XMLUIMessages.Honour_all_schema_locations);
- ((GridData)fHonourAllSchemaLocations.getLayoutData()).horizontalSpan = 2;
- }
- }
- private void handleMarkupSeveritySelection(boolean selection){
- if (selection) {
- fMarkupState.restore();
- }
- else {
- fMarkupState = ControlEnableState.disable(fMarkupValidationGroup);
- }
- }
+ private Button fExtendedMarkupValidation;
- protected void createContentsForMarkupValidationGroup(Composite parent) {
-
- if (fExtendedMarkupValidation == null) {
- fExtendedMarkupValidation = createCheckBox(parent, XMLUIMessages.MarkupValidation_files);
- ((GridData)fExtendedMarkupValidation.getLayoutData()).horizontalSpan = 2;
- fExtendedMarkupValidation.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleMarkupSeveritySelection(fExtendedMarkupValidation.getSelection());
- }
- });
- }
- fMarkupValidationGroup = createGroup(parent, 3);
- ((GridLayout)fMarkupValidationGroup.getLayout()).makeColumnsEqualWidth = false;
- fMarkupValidationGroup.setText(XMLUIMessages.MarkupValidation_files_label);
+ private Combo fMissingStartTag;
- if (fMissingStartTag == null) {
- fMissingStartTag = createMarkupCombo(fMarkupValidationGroup, XMLUIMessages.Missing_start_tag, MARKUP_SEVERITIES);
- }
- if (fMissingEndTag == null) {
- fMissingEndTag = createMarkupCombo(fMarkupValidationGroup, XMLUIMessages.Missing_end_tag, MARKUP_SEVERITIES);
- }
- if (fMissingTagName == null) {
- fMissingTagName = createMarkupCombo(fMarkupValidationGroup, XMLUIMessages.Tag_name_missing, MARKUP_SEVERITIES);
- }
- if (fMissingQuotes == null) {
- fMissingQuotes = createMarkupCombo(fMarkupValidationGroup, XMLUIMessages.Missing_quotes, MARKUP_SEVERITIES);
- }
- if (fMissingClosingBracket == null) {
- fMissingClosingBracket = createMarkupCombo(fMarkupValidationGroup, XMLUIMessages.Missing_closing_bracket, MARKUP_SEVERITIES);
- }
- if (fMissingClosingQuote == null) {
- fMissingClosingQuote = createMarkupCombo(fMarkupValidationGroup, XMLUIMessages.Missing_closing_quote, MARKUP_SEVERITIES);
- }
- if (fEmptyElementTag == null) {
- fEmptyElementTag = createMarkupCombo(fMarkupValidationGroup, XMLUIMessages.Empty_element_tag, MARKUP_SEVERITIES);
- }
- if (fEndTagWithAttributes == null) {
- fEndTagWithAttributes = createMarkupCombo(fMarkupValidationGroup, XMLUIMessages.End_tag_with_attributes, MARKUP_SEVERITIES);
- }
- if (fInvalidWhitespaceBeforeTagname == null) {
- fInvalidWhitespaceBeforeTagname = createMarkupCombo(fMarkupValidationGroup, XMLUIMessages.Invalid_whitespace_before_tagname, MARKUP_SEVERITIES);
- }
- if (fInvalidNamespaceInPI == null) {
- fInvalidNamespaceInPI = createMarkupCombo(fMarkupValidationGroup, XMLUIMessages.Namespace_in_pi_target, MARKUP_SEVERITIES);
- }
- if (fInvalidWhitespaceAtStart == null) {
- fInvalidWhitespaceAtStart = createMarkupCombo(fMarkupValidationGroup, XMLUIMessages.Whitespace_at_start, MARKUP_SEVERITIES);
- }
+ private Combo fMissingEndTag;
- }
+ private Combo fMissingTagName;
- /**
- * @param parent
- * @return
- */
- private Combo createCombo(Composite parent, String[] items) {
- Combo combo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
- combo.setItems(items);
+ private Combo fEmptyElementTag;
- //GridData
- GridData data = new GridData(SWT.FILL, SWT.CENTER, true, true);
- combo.setLayoutData(data);
+ private Combo fEndTagWithAttributes;
- return combo;
- }
+ private Combo fInvalidWhitespaceBeforeTagname;
- private Combo createMarkupCombo(Composite parent, String text, String[] items) {
- Label label = new Label(parent, SWT.LEFT);
- GridData gd = new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1);
- label.setFont(JFaceResources.getDialogFont());
- label.setText(text);
- label.setLayoutData(gd);
+ private Combo fMissingClosingBracket;
- Combo combo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
- combo.setItems(items);
+ private Combo fMissingClosingQuote;
- //GridData
- // GridData data = new GridData(SWT.FILL, SWT.CENTER, false, true);
- combo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ private Combo fMissingQuotes;
- return combo;
- }
-
- protected void initializeValues() {
- initializeValuesForValidatingGroup();
- initializeValuesForMarkupValidationGroup();
- }
+ private Combo fInvalidNamespaceInPI;
- protected void initializeValuesForValidatingGroup() {
- Preferences modelPreferences = getModelPreferences();
- int indicateNoGrammarButtonSelected = modelPreferences.getInt(XMLCorePreferenceNames.INDICATE_NO_GRAMMAR);
- boolean useXIncludeButtonSelected = modelPreferences.getBoolean(XMLCorePreferenceNames.USE_XINCLUDE);
+ private Combo fInvalidWhitespaceAtStart;
- if (fIndicateNoGrammar != null) {
- fIndicateNoGrammar.select(2 - indicateNoGrammarButtonSelected);
- fIndicateNoGrammar.setText(SEVERITIES[2 - indicateNoGrammarButtonSelected]);
- }
- if (fUseXinclude != null) {
- fUseXinclude.setSelection(useXIncludeButtonSelected);
- }
+ private Group fMarkupValidationGroup;
+ private ControlEnableState fMarkupState;
- boolean honourAllSelected = modelPreferences.getBoolean(XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS);
- if (fHonourAllSchemaLocations != null) {
- fHonourAllSchemaLocations.setSelection(honourAllSelected);
- }
- }
-
- protected void initializeValuesForMarkupValidationGroup() {
- Preferences modelPreferences = getModelPreferences();
- boolean useExtendedMarkupValidation = modelPreferences.getBoolean(XMLCorePreferenceNames.MARKUP_VALIDATION);
+ private static final int[] XML_SEVERITIES = { ValidationMessage.WARNING, ValidationMessage.ERROR, ValidationMessage.IGNORE };
-
- if (fExtendedMarkupValidation != null) {
- fExtendedMarkupValidation.setSelection(useExtendedMarkupValidation);
- }
- int emptyElementTag = modelPreferences.getInt(XMLCorePreferenceNames.ATTRIBUTE_HAS_NO_VALUE);
-
- if (fEmptyElementTag != null) {
- fEmptyElementTag.select(2 - emptyElementTag);
- fEmptyElementTag.setText(MARKUP_SEVERITIES[2 - emptyElementTag]);
- }
-
- int endTagWithAttributes = modelPreferences.getInt(XMLCorePreferenceNames.END_TAG_WITH_ATTRIBUTES);
-
- if (fEndTagWithAttributes != null) {
- fEndTagWithAttributes.select(2 - endTagWithAttributes);
- fEndTagWithAttributes.setText(MARKUP_SEVERITIES[2 - endTagWithAttributes]);
- }
-
- int invalidWhitespaceBeforeTagname = modelPreferences.getInt(XMLCorePreferenceNames.WHITESPACE_BEFORE_TAGNAME);
-
- if (fInvalidWhitespaceBeforeTagname != null) {
- fInvalidWhitespaceBeforeTagname.select(2 - invalidWhitespaceBeforeTagname);
- fInvalidWhitespaceBeforeTagname.setText(MARKUP_SEVERITIES[2 - invalidWhitespaceBeforeTagname]);
- }
-
- int missingClosingBracket = modelPreferences.getInt(XMLCorePreferenceNames.MISSING_CLOSING_BRACKET);
-
- if (fMissingClosingBracket != null) {
- fMissingClosingBracket.select(2 - missingClosingBracket);
- fMissingClosingBracket.setText(MARKUP_SEVERITIES[2 - missingClosingBracket]);
- }
-
- int missingClosingQuote = modelPreferences.getInt(XMLCorePreferenceNames.MISSING_CLOSING_QUOTE);
-
- if (fMissingClosingQuote != null) {
- fMissingClosingQuote.select(2 - missingClosingQuote);
- fMissingClosingQuote.setText(MARKUP_SEVERITIES[2 - missingClosingQuote]);
- }
-
- int missingEndTag = modelPreferences.getInt(XMLCorePreferenceNames.MISSING_END_TAG);
-
- if (fMissingEndTag != null) {
- fMissingEndTag.select(2 - missingEndTag);
- fMissingEndTag.setText(MARKUP_SEVERITIES[2 - missingEndTag]);
- }
-
- int missingStartTag = modelPreferences.getInt(XMLCorePreferenceNames.MISSING_START_TAG);
-
- if (fMissingStartTag != null) {
- fMissingStartTag.select(2 - missingStartTag);
- fMissingStartTag.setText(MARKUP_SEVERITIES[2 - missingStartTag]);
- }
-
- int missingQuotes = modelPreferences.getInt(XMLCorePreferenceNames.MISSING_QUOTES);
-
- if (fMissingQuotes != null) {
- fMissingQuotes.select(2 - missingQuotes);
- fMissingQuotes.setText(MARKUP_SEVERITIES[2 - missingQuotes]);
- }
-
- int invalidNamespaceInPI = modelPreferences.getInt(XMLCorePreferenceNames.NAMESPACE_IN_PI_TARGET);
-
- if (fInvalidNamespaceInPI != null) {
- fInvalidNamespaceInPI.select(2 - invalidNamespaceInPI);
- fInvalidNamespaceInPI.setText(MARKUP_SEVERITIES[2 - invalidNamespaceInPI]);
- }
-
- int tagNameMissing = modelPreferences.getInt(XMLCorePreferenceNames.MISSING_TAG_NAME);
-
- if (fMissingTagName != null) {
- fMissingTagName.select(2 - tagNameMissing);
- fMissingTagName.setText(MARKUP_SEVERITIES[2 - tagNameMissing]);
- }
-
- int invalidWhitespaceAtStart = modelPreferences.getInt(XMLCorePreferenceNames.WHITESPACE_AT_START);
-
- if (fInvalidWhitespaceAtStart != null) {
- fInvalidWhitespaceAtStart.select(2 - invalidWhitespaceAtStart);
- fInvalidWhitespaceAtStart.setText(MARKUP_SEVERITIES[2 - invalidWhitespaceAtStart]);
+ private static final String[] MARKUP_SEVERITIES = { XMLUIMessages.Severity_error, XMLUIMessages.Severity_warning, XMLUIMessages.Severity_ignore };
+
+ protected void createContentsForValidatingGroup(Composite validatingGroup) {
+
+ if (fIndicateNoGrammar == null)
+ fIndicateNoGrammar = addComboBox(validatingGroup, XMLUIMessages.Indicate_no_grammar_specified, XMLCorePreferenceNames.INDICATE_NO_GRAMMAR, XML_SEVERITIES, MARKUP_SEVERITIES, 0);
+
+ if (fUseXinclude == null) {
+ fUseXinclude = createCheckBox(validatingGroup, XMLUIMessages.Use_XInclude);
+ ((GridData) fUseXinclude.getLayoutData()).horizontalSpan = 2;
}
- if (!useExtendedMarkupValidation)
- fMarkupState = ControlEnableState.disable(fMarkupValidationGroup);
- }
+ if (fHonourAllSchemaLocations == null) {
+ fHonourAllSchemaLocations = createCheckBox(validatingGroup, XMLUIMessages.Honour_all_schema_locations);
+ ((GridData) fHonourAllSchemaLocations.getLayoutData()).horizontalSpan = 2;
+ }
- protected void performDefaultsForValidatingGroup() {
- Preferences modelPreferences = getModelPreferences();
- int indicateNoGrammarButtonSelected = modelPreferences.getDefaultInt(XMLCorePreferenceNames.INDICATE_NO_GRAMMAR);
- boolean useXIncludeButtonSelected = modelPreferences.getDefaultBoolean(XMLCorePreferenceNames.USE_XINCLUDE);
+ IScopeContext[] contexts = createPreferenceScopes();
+ fOriginalUseXIncludeButtonSelected = contexts[0].getNode(getPreferenceNodeQualifier()).getBoolean(XMLCorePreferenceNames.USE_XINCLUDE, true);
- if (fIndicateNoGrammar != null) {
- fIndicateNoGrammar.setSelection(new Point(indicateNoGrammarButtonSelected, 2 - indicateNoGrammarButtonSelected));
- fIndicateNoGrammar.setText(SEVERITIES[indicateNoGrammarButtonSelected]);
- }
- if (fUseXinclude != null) {
- fUseXinclude.setSelection(useXIncludeButtonSelected);
- }
+ if (fUseXinclude != null) {
+ fUseXinclude.setSelection(fOriginalUseXIncludeButtonSelected);
+ }
+ fOriginalUseHonourAllButtonSelected = contexts[0].getNode(getPreferenceNodeQualifier()).getBoolean(XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS, true);
+ if (fHonourAllSchemaLocations != null) {
+ fHonourAllSchemaLocations.setSelection(fOriginalUseHonourAllButtonSelected);
+ }
- boolean honourAllButtonSelected = modelPreferences.getDefaultBoolean(XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS);
- if (fHonourAllSchemaLocations != null) {
- fHonourAllSchemaLocations.setSelection(honourAllButtonSelected);
- }
- }
-
- protected void performDefaultsForMarkupValidationGroup() {
- Preferences modelPreferences = getModelPreferences();
- boolean useExtendedMarkupValidation = modelPreferences.getDefaultBoolean(XMLCorePreferenceNames.MARKUP_VALIDATION);
-
-
- if (fExtendedMarkupValidation != null) {
- if (fExtendedMarkupValidation.getSelection() != useExtendedMarkupValidation) {
- handleMarkupSeveritySelection(useExtendedMarkupValidation);
- }
- fExtendedMarkupValidation.setSelection(useExtendedMarkupValidation);
-
- }
- int emptyElementTag = modelPreferences.getDefaultInt(XMLCorePreferenceNames.ATTRIBUTE_HAS_NO_VALUE);
-
- if (fEmptyElementTag != null) {
- fEmptyElementTag.setSelection(new Point(emptyElementTag,2 - emptyElementTag));
- fEmptyElementTag.setText(MARKUP_SEVERITIES[2 - emptyElementTag]);
- }
-
- int endTagWithAttributes = modelPreferences.getDefaultInt(XMLCorePreferenceNames.END_TAG_WITH_ATTRIBUTES);
-
- if (fEndTagWithAttributes != null) {
- fEndTagWithAttributes.setSelection(new Point(endTagWithAttributes,2 - endTagWithAttributes));
- fEndTagWithAttributes.setText(MARKUP_SEVERITIES[2 - endTagWithAttributes]);
- }
-
- int invalidWhitespaceBeforeTagname = modelPreferences.getDefaultInt(XMLCorePreferenceNames.WHITESPACE_BEFORE_TAGNAME);
-
- if (fInvalidWhitespaceBeforeTagname != null) {
- fInvalidWhitespaceBeforeTagname.setSelection(new Point(invalidWhitespaceBeforeTagname,2 - invalidWhitespaceBeforeTagname));
- fInvalidWhitespaceBeforeTagname.setText(MARKUP_SEVERITIES[2 - invalidWhitespaceBeforeTagname]);
- }
-
- int missingClosingBracket = modelPreferences.getDefaultInt(XMLCorePreferenceNames.MISSING_CLOSING_BRACKET);
-
- if (fMissingClosingBracket != null) {
- fMissingClosingBracket.setSelection(new Point(missingClosingBracket,2 - missingClosingBracket));
- fMissingClosingBracket.setText(MARKUP_SEVERITIES[2 - missingClosingBracket]);
- }
-
- int missingClosingQuote = modelPreferences.getDefaultInt(XMLCorePreferenceNames.MISSING_CLOSING_QUOTE);
-
- if (fMissingClosingQuote != null) {
- fMissingClosingQuote.setSelection(new Point(missingClosingQuote,2 - missingClosingQuote));
- fMissingClosingQuote.setText(MARKUP_SEVERITIES[2 - missingClosingQuote]);
- }
-
- int missingEndTag = modelPreferences.getDefaultInt(XMLCorePreferenceNames.MISSING_END_TAG);
-
- if (fMissingEndTag != null) {
- fMissingEndTag.setSelection(new Point(missingEndTag,2 - missingEndTag));
- fMissingEndTag.setText(MARKUP_SEVERITIES[2 - missingEndTag]);
- }
-
- int missingStartTag = modelPreferences.getDefaultInt(XMLCorePreferenceNames.MISSING_START_TAG);
-
- if (fMissingStartTag != null) {
- fMissingStartTag.setSelection(new Point(missingStartTag,2 - missingStartTag));
- fMissingStartTag.setText(MARKUP_SEVERITIES[2 - missingStartTag]);
- }
-
- int missingQuotes = modelPreferences.getDefaultInt(XMLCorePreferenceNames.MISSING_QUOTES);
-
- if (fMissingQuotes != null) {
- fMissingQuotes.setSelection(new Point(missingQuotes,2 - missingQuotes));
- fMissingQuotes.setText(MARKUP_SEVERITIES[2 - missingQuotes]);
- }
-
- int invalidNamespaceInPI = modelPreferences.getDefaultInt(XMLCorePreferenceNames.NAMESPACE_IN_PI_TARGET);
-
- if (fInvalidNamespaceInPI != null) {
- fInvalidNamespaceInPI.setSelection(new Point(invalidNamespaceInPI,2 - invalidNamespaceInPI));
- fInvalidNamespaceInPI.setText(MARKUP_SEVERITIES[2 - invalidNamespaceInPI]);
- }
-
- int tagNameMissing = modelPreferences.getDefaultInt(XMLCorePreferenceNames.MISSING_TAG_NAME);
-
- if (fMissingTagName != null) {
- fMissingTagName.setSelection(new Point(tagNameMissing,2 - tagNameMissing));
- fMissingTagName.setText(MARKUP_SEVERITIES[2 - tagNameMissing]);
- }
-
- int invalidWhitespaceAtStart = modelPreferences.getDefaultInt(XMLCorePreferenceNames.WHITESPACE_AT_START);
-
- if (fInvalidWhitespaceAtStart != null) {
- fInvalidWhitespaceAtStart.setSelection(new Point(invalidWhitespaceAtStart,2 - invalidWhitespaceAtStart));
- fInvalidWhitespaceAtStart.setText(MARKUP_SEVERITIES[2 - invalidWhitespaceAtStart]);
- }
- }
-
- protected void storeValuesForValidatingGroup()
- {
- Preferences modelPreferences = getModelPreferences();
- if (fIndicateNoGrammar != null) {
- int warnNoGrammarButtonSelected = 2 - fIndicateNoGrammar.getSelectionIndex();
- modelPreferences.setValue(XMLCorePreferenceNames.INDICATE_NO_GRAMMAR, warnNoGrammarButtonSelected);
- }
- if (fUseXinclude != null) {
- boolean useXIncludeButtonSelected = fUseXinclude.getSelection();
- modelPreferences.setValue(XMLCorePreferenceNames.USE_XINCLUDE, useXIncludeButtonSelected);
- }
- if (fHonourAllSchemaLocations != null) {
- boolean honourAllButtonSelected = fHonourAllSchemaLocations.getSelection();
- modelPreferences.setValue(XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS, honourAllButtonSelected);
- }
- }
- protected void storeValuesForMarkupValidationGroup()
- {
- Preferences modelPreferences = getModelPreferences();
- if (fExtendedMarkupValidation != null) {
- boolean extendedMarkupValidation = fExtendedMarkupValidation.getSelection();
- modelPreferences.setValue(XMLCorePreferenceNames.MARKUP_VALIDATION, extendedMarkupValidation);
- }
- if (fEmptyElementTag != null) {
- int emptyElementTag = 2 - fEmptyElementTag.getSelectionIndex();
- modelPreferences.setValue(XMLCorePreferenceNames.ATTRIBUTE_HAS_NO_VALUE, emptyElementTag);
- }
- if (fEndTagWithAttributes != null) {
- int endTagWithAttributes = 2 - fEndTagWithAttributes.getSelectionIndex();
- modelPreferences.setValue(XMLCorePreferenceNames.END_TAG_WITH_ATTRIBUTES, endTagWithAttributes);
- }
- if (fInvalidWhitespaceBeforeTagname != null) {
- int invalidWhitespaceBeforeTagname = 2 - fInvalidWhitespaceBeforeTagname.getSelectionIndex();
- modelPreferences.setValue(XMLCorePreferenceNames.WHITESPACE_BEFORE_TAGNAME, invalidWhitespaceBeforeTagname);
- }
- if (fMissingClosingBracket != null) {
- int missingClosingBracket = 2 - fMissingClosingBracket.getSelectionIndex();
- modelPreferences.setValue(XMLCorePreferenceNames.MISSING_CLOSING_BRACKET, missingClosingBracket);
- }
- if (fMissingClosingQuote != null) {
- int missingClosingQuote = 2 - fMissingClosingQuote.getSelectionIndex();
- modelPreferences.setValue(XMLCorePreferenceNames.MISSING_CLOSING_BRACKET, missingClosingQuote);
- }
- if (fMissingEndTag != null) {
- int missingEndTag = 2 - fMissingEndTag.getSelectionIndex();
- modelPreferences.setValue(XMLCorePreferenceNames.MISSING_END_TAG, missingEndTag);
- modelPreferences.getInt(XMLCorePreferenceNames.MISSING_END_TAG);
- }
- if (fMissingStartTag != null) {
- int missingStartTag = 2 - fMissingStartTag.getSelectionIndex();
- modelPreferences.setValue(XMLCorePreferenceNames.MISSING_START_TAG, missingStartTag);
}
- if (fMissingQuotes != null) {
- int missingQuotes = 2 - fMissingQuotes.getSelectionIndex();
- modelPreferences.setValue(XMLCorePreferenceNames.MISSING_QUOTES, missingQuotes);
- }
- if (fInvalidNamespaceInPI != null) {
- int invalidNamespaceInPI = 2 - fInvalidNamespaceInPI.getSelectionIndex();
- modelPreferences.setValue(XMLCorePreferenceNames.NAMESPACE_IN_PI_TARGET, invalidNamespaceInPI);
- }
- if (fMissingTagName != null) {
- int missingTagName = 2 - fMissingTagName.getSelectionIndex();
- modelPreferences.setValue(XMLCorePreferenceNames.MISSING_TAG_NAME, missingTagName);
- }
- if (fInvalidWhitespaceAtStart != null) {
- int invalidWhitespaceAtStart = 2 - fInvalidWhitespaceAtStart.getSelectionIndex();
- modelPreferences.setValue(XMLCorePreferenceNames.WHITESPACE_AT_START, invalidWhitespaceAtStart);
- }
-
-
- }
-
- protected void storeValues() {
- storeValuesForValidatingGroup();
- storeValuesForMarkupValidationGroup();
- }
- protected void performDefaults() {
- performDefaultsForValidatingGroup();
- performDefaultsForMarkupValidationGroup();
- super.performDefaults();
- }
-
- protected Preferences getModelPreferences() {
- return XMLCorePlugin.getDefault().getPluginPreferences();
- }
-
- protected void doSavePreferenceStore() {
- XMLCorePlugin.getDefault().savePluginPreferences(); // model
- }
+ private void handleMarkupSeveritySelection(boolean selection) {
+ if (selection) {
+ if (fMarkupState != null) {
+ fMarkupState.restore();
+ fMarkupState = null;
+ }
+ } else {
+ if (fMarkupState == null)
+ fMarkupState = ControlEnableState.disable(fMarkupValidationGroup);
+ }
+ }
- public boolean performOk() {
- boolean result = super.performOk();
+ protected void createContentsForMarkupValidationGroup(Composite parent) {
- doSavePreferenceStore();
+ IScopeContext[] contexts = createPreferenceScopes();
- return result;
- }
+ fOriginalUseExtendedMarkupValidation = contexts[0].getNode(getPreferenceNodeQualifier()).getBoolean(XMLCorePreferenceNames.MARKUP_VALIDATION, false);
+ fExtendedMarkupValidation = createCheckBox(parent, XMLUIMessages.MarkupValidation_files);
+
+ ((GridData) fExtendedMarkupValidation.getLayoutData()).horizontalSpan = 2;
+ fExtendedMarkupValidation.setSelection(fOriginalUseExtendedMarkupValidation);
+
+ fExtendedMarkupValidation.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleMarkupSeveritySelection(fExtendedMarkupValidation.getSelection());
+ }
+ });
+
+ fMarkupValidationGroup = createGroup(parent, 3);
+ ((GridLayout) fMarkupValidationGroup.getLayout()).makeColumnsEqualWidth = false;
+ fMarkupValidationGroup.setText(XMLUIMessages.MarkupValidation_files_label);
+ GridLayout layout = new GridLayout(3, false);
+ fMarkupValidationGroup.setLayout(layout);
+
+ if (fMissingStartTag == null)
+ fMissingStartTag = addComboBox(fMarkupValidationGroup, XMLUIMessages.Missing_start_tag, XMLCorePreferenceNames.MISSING_START_TAG, XML_SEVERITIES, MARKUP_SEVERITIES, 0);
+ if (fMissingEndTag == null)
+ fMissingEndTag = addComboBox(fMarkupValidationGroup, XMLUIMessages.Missing_end_tag, XMLCorePreferenceNames.MISSING_END_TAG, XML_SEVERITIES, MARKUP_SEVERITIES, 0);
+ if (fMissingTagName == null)
+ fMissingTagName = addComboBox(fMarkupValidationGroup, XMLUIMessages.Tag_name_missing, XMLCorePreferenceNames.MISSING_TAG_NAME, XML_SEVERITIES, MARKUP_SEVERITIES, 0);
+ if (fMissingQuotes == null)
+ fMissingQuotes = addComboBox(fMarkupValidationGroup, XMLUIMessages.Missing_quotes, XMLCorePreferenceNames.MISSING_QUOTES, XML_SEVERITIES, MARKUP_SEVERITIES, 0);
+ if (fMissingClosingBracket == null)
+ fMissingClosingBracket = addComboBox(fMarkupValidationGroup, XMLUIMessages.Missing_closing_bracket, XMLCorePreferenceNames.MISSING_CLOSING_BRACKET, XML_SEVERITIES, MARKUP_SEVERITIES, 0);
+ if (fMissingClosingQuote == null)
+ fMissingClosingQuote = addComboBox(fMarkupValidationGroup, XMLUIMessages.Missing_closing_quote, XMLCorePreferenceNames.MISSING_CLOSING_QUOTE, XML_SEVERITIES, MARKUP_SEVERITIES, 0);
+ if (fEmptyElementTag == null)
+ fEmptyElementTag = addComboBox(fMarkupValidationGroup, XMLUIMessages.Empty_element_tag, XMLCorePreferenceNames.ATTRIBUTE_HAS_NO_VALUE, XML_SEVERITIES, MARKUP_SEVERITIES, 0);
+ if (fEndTagWithAttributes == null)
+ fEndTagWithAttributes = addComboBox(fMarkupValidationGroup, XMLUIMessages.End_tag_with_attributes, XMLCorePreferenceNames.END_TAG_WITH_ATTRIBUTES, XML_SEVERITIES, MARKUP_SEVERITIES, 0);
+ if (fInvalidWhitespaceBeforeTagname == null)
+ fInvalidWhitespaceBeforeTagname = addComboBox(fMarkupValidationGroup, XMLUIMessages.Invalid_whitespace_before_tagname, XMLCorePreferenceNames.WHITESPACE_BEFORE_TAGNAME, XML_SEVERITIES, MARKUP_SEVERITIES, 0);
+ if (fInvalidNamespaceInPI == null)
+ fInvalidNamespaceInPI = addComboBox(fMarkupValidationGroup, XMLUIMessages.Namespace_in_pi_target, XMLCorePreferenceNames.NAMESPACE_IN_PI_TARGET, XML_SEVERITIES, MARKUP_SEVERITIES, 0);
+ if (fInvalidWhitespaceAtStart == null)
+ fInvalidWhitespaceAtStart = addComboBox(fMarkupValidationGroup, XMLUIMessages.Whitespace_at_start, XMLCorePreferenceNames.WHITESPACE_AT_START, XML_SEVERITIES, MARKUP_SEVERITIES, 0);
+
+ handleMarkupSeveritySelection(fOriginalUseExtendedMarkupValidation);
+
+ }
+
+ protected void performDefaultsForValidatingGroup() {
+ IEclipsePreferences modelPreferences = new DefaultScope().getNode(getPreferenceNodeQualifier());
+ boolean useXIncludeButtonSelected = modelPreferences.getBoolean(XMLCorePreferenceNames.USE_XINCLUDE, true);
+
+ if (fUseXinclude != null) {
+ fUseXinclude.setSelection(useXIncludeButtonSelected);
+ }
+ boolean useHonourAllButtonSelected = modelPreferences.getBoolean(XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS, true);
+ if (fHonourAllSchemaLocations != null) {
+ fHonourAllSchemaLocations.setSelection(useHonourAllButtonSelected);
+ }
+ }
+
+ protected void performDefaultsForMarkupValidationGroup() {
+ IEclipsePreferences modelPreferences = new DefaultScope().getNode(getPreferenceNodeQualifier());
+ boolean useExtendedMarkupValidation = modelPreferences.getBoolean(XMLCorePreferenceNames.MARKUP_VALIDATION, false);
+
+ if (fExtendedMarkupValidation != null) {
+ if (fExtendedMarkupValidation.getSelection() != useExtendedMarkupValidation) {
+ handleMarkupSeveritySelection(useExtendedMarkupValidation);
+ }
+ fExtendedMarkupValidation.setSelection(useExtendedMarkupValidation);
+ }
+ }
+
+ protected void storeValuesForValidatingGroup(IScopeContext[] contexts) {
+ if (fUseXinclude != null) {
+ boolean useXIncludeButtonSelected = fUseXinclude.getSelection();
+ contexts[0].getNode(getPreferenceNodeQualifier()).putBoolean(XMLCorePreferenceNames.USE_XINCLUDE, useXIncludeButtonSelected);
+ }
+ if (fHonourAllSchemaLocations != null) {
+ boolean honourAllButtonSelected = fHonourAllSchemaLocations.getSelection();
+ contexts[0].getNode(getPreferenceNodeQualifier()).putBoolean(XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS, honourAllButtonSelected);
+ }
+ }
+
+ protected void storeValuesForMarkupValidationGroup(IScopeContext[] contexts) {
+ if (fExtendedMarkupValidation != null) {
+ boolean extendedMarkupValidation = fExtendedMarkupValidation.getSelection();
+ contexts[0].getNode(getPreferenceNodeQualifier()).putBoolean(XMLCorePreferenceNames.MARKUP_VALIDATION, extendedMarkupValidation);
+ }
+ }
+
+ protected void performDefaults() {
+ resetSeverities();
+ performDefaultsForValidatingGroup();
+ performDefaultsForMarkupValidationGroup();
+ super.performDefaults();
+ }
+
+ protected Preferences getModelPreferences() {
+ return XMLCorePlugin.getDefault().getPluginPreferences();
+ }
+
+ protected void doSavePreferenceStore() {
+ XMLCorePlugin.getDefault().savePluginPreferences(); // model
+ }
+
+ protected void storeValues() {
+ super.storeValues();
+ IScopeContext[] contexts = createPreferenceScopes();
+
+ storeValuesForValidatingGroup(contexts);
+ storeValuesForMarkupValidationGroup(contexts);
+ }
+
+ protected Control createCommonContents(Composite parent) {
+ final Composite page = new Composite(parent, SWT.NULL);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ page.setLayout(layout);
+
+ Group validatingGroup = createGroup(page, 3);
+ validatingGroup.setText(XMLUIMessages.Validating_files);
+ createContentsForValidatingGroup(validatingGroup);
+
+ createContentsForMarkupValidationGroup(page);
+
+ return page;
+ }
+
+ protected String getPreferenceNodeQualifier() {
+ return XMLCorePlugin.getDefault().getBundle().getSymbolicName();
+ }
+
+ protected String getPreferencePageID() {
+ return "org.eclipse.wst.sse.ui.preferences.xml.validation";//$NON-NLS-1$
+ }
+
+ protected String getProjectSettingsKey() {
+ return XMLCorePreferenceNames.USE_PROJECT_SETTINGS;
+ }
+
+ protected String getPropertyPageID() {
+ return "org.eclipse.wst.xml.ui.propertyPage.project.validation";//$NON-NLS-1$
+ }
+
+ public void init(IWorkbench workbench) {
+ }
+
+ private Group createGroup(Composite parent, int numColumns) {
+
+ Group group = new Group(parent, SWT.NULL);
+
+ // GridLayout
+ GridLayout layout = new GridLayout();
+ layout.numColumns = numColumns;
+ group.setLayout(layout);
+
+ // GridData
+ GridData data = new GridData(GridData.FILL);
+ data.horizontalIndent = 0;
+ data.verticalAlignment = GridData.FILL;
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ group.setLayoutData(data);
+
+ return group;
+ }
+
+ private Button createCheckBox(Composite group, String label) {
+ Button button = new Button(group, SWT.CHECK | SWT.LEFT);
+ button.setText(label);
+
+ // button.setLayoutData(GridDataFactory.fillDefaults().create());
+
+ // GridData
+ GridData data = new GridData(GridData.FILL);
+ data.verticalAlignment = GridData.CENTER;
+ data.horizontalAlignment = GridData.FILL;
+ button.setLayoutData(data);
+
+ return button;
+ }
+
+ public void dispose() {
+ storeSectionExpansionStates(getDialogSettings().addNewSection(SETTINGS_SECTION_NAME));
+ super.dispose();
+ }
+
+ protected IDialogSettings getDialogSettings() {
+ return XMLUIPlugin.getDefault().getDialogSettings();
+ }
+
+ protected boolean shouldRevalidateOnSettingsChange() {
+ return fOriginalUseExtendedMarkupValidation != fExtendedMarkupValidation.getSelection() || fOriginalUseXIncludeButtonSelected != fUseXinclude.getSelection() || fOriginalUseHonourAllButtonSelected != fHonourAllSchemaLocations.getSelection() || super.shouldRevalidateOnSettingsChange();
+ }
}