### Eclipse Workspace Patch 1.0
#P org.eclipse.jst.jsp.ui
Index: src/org/eclipse/jst/jsp/ui/internal/preferences/ui/AbstractValidationSettingsPage.java
===================================================================
RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/ui/AbstractValidationSettingsPage.java,v
retrieving revision 1.3
diff -u -r1.3 AbstractValidationSettingsPage.java
--- src/org/eclipse/jst/jsp/ui/internal/preferences/ui/AbstractValidationSettingsPage.java 15 Oct 2009 22:48:43 -0000 1.3
+++ src/org/eclipse/jst/jsp/ui/internal/preferences/ui/AbstractValidationSettingsPage.java 7 Sep 2010 05:06:22 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
+ * Copyright (c) 2008, 2010 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
@@ -43,10 +43,10 @@
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.eclipse.wst.xml.ui.internal.XMLUIMessages;
import org.osgi.service.prefs.BackingStoreException;
/**
@@ -359,16 +359,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(XMLUIMessages.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) ? XMLUIMessages.Validation_Workspace : XMLUIMessages.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(XMLUIMessages.Validation_jobName);
job.schedule();
case SWT.NO:
storeValues();
#P org.eclipse.wst.html.ui
Index: src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java
===================================================================
RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java,v
retrieving revision 1.20
diff -u -r1.20 HTMLUIMessages.java
--- src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java 26 Feb 2010 20:59:37 -0000 1.20
+++ src/org/eclipse/wst/html/ui/internal/HTMLUIMessages.java 7 Sep 2010 05:06:27 -0000
@@ -196,11 +196,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;
Index: src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties
===================================================================
RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties,v
retrieving revision 1.29
diff -u -r1.29 HTMLUIPluginResources.properties
--- src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties 30 Mar 2010 03:05:44 -0000 1.29
+++ src/org/eclipse/wst/html/ui/internal/HTMLUIPluginResources.properties 7 Sep 2010 05:06:28 -0000
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2004, 2009 IBM Corporation and others.
+# Copyright (c) 2004, 2010 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
@@ -171,10 +171,7 @@
HTMLValidationPreferencePage_9=Invalid tag name:
HTMLValidationPreferencePage_35=Attribute value refers to missing resource:
-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}''
Index: src/org/eclipse/wst/html/ui/internal/preferences/ui/AbstractValidationSettingsPage.java
===================================================================
RCS file: src/org/eclipse/wst/html/ui/internal/preferences/ui/AbstractValidationSettingsPage.java
diff -N src/org/eclipse/wst/html/ui/internal/preferences/ui/AbstractValidationSettingsPage.java
--- src/org/eclipse/wst/html/ui/internal/preferences/ui/AbstractValidationSettingsPage.java 15 Oct 2009 22:48:40 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,400 +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.wst.html.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.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 PropertyPreferencePage {
-
- 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 severity
.
- * 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) {
- fIndex = i;
- return;
- }
- }
-
- fIndex = -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 parent
. The data
- * in the Combo is associated with key
. The Combo data is
- * generated based on the integer values
where the index
- * of values
corresponds to the index of valueLabels
- *
- * @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 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;
- }
-
- }
-
-}
Index: src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLValidationPreferencePage.java
===================================================================
RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLValidationPreferencePage.java,v
retrieving revision 1.7
diff -u -r1.7 HTMLValidationPreferencePage.java
--- src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLValidationPreferencePage.java 15 Oct 2009 22:48:40 -0000 1.7
+++ src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLValidationPreferencePage.java 7 Sep 2010 05:06:28 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
+ * Copyright (c) 2008, 2010 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
@@ -26,6 +26,7 @@
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.ScrolledPageContent;
+import org.eclipse.wst.xml.ui.internal.preferences.AbstractValidationSettingsPage;
public class HTMLValidationPreferencePage extends AbstractValidationSettingsPage {
Index: src/org/eclipse/wst/html/ui/internal/preferences/ui/PropertyPreferencePage.java
===================================================================
RCS file: src/org/eclipse/wst/html/ui/internal/preferences/ui/PropertyPreferencePage.java
diff -N src/org/eclipse/wst/html/ui/internal/preferences/ui/PropertyPreferencePage.java
--- src/org/eclipse/wst/html/ui/internal/preferences/ui/PropertyPreferencePage.java 25 Mar 2008 18:12:23 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -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("" + SSEUIMessages.ConfigureWorkspaceSettings + ""); //$NON-NLS-1$//$NON-NLS-2$
- }
- else {
- fProjectSettingsLink.setText("" + SSEUIMessages.ConfigureProjectSettings + ""); //$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);
- }
- }
-}
#P org.eclipse.wst.xml.core
Index: src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java
===================================================================
RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java,v
retrieving revision 1.15
diff -u -r1.15 XMLCorePreferenceNames.java
--- src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java 21 Apr 2010 19:32:14 -0000 1.15
+++ src/org/eclipse/wst/xml/core/internal/preferences/XMLCorePreferenceNames.java 7 Sep 2010 05:06:34 -0000
@@ -284,4 +284,7 @@
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$
+
}
#P org.eclipse.wst.xml.ui
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.ui/META-INF/MANIFEST.MF,v
retrieving revision 1.44
diff -u -r1.44 MANIFEST.MF
--- META-INF/MANIFEST.MF 13 Jul 2010 15:33:17 -0000 1.44
+++ META-INF/MANIFEST.MF 7 Sep 2010 05:06:39 -0000
@@ -45,6 +45,7 @@
Import-Package: com.ibm.icu.util; version="3.8",
com.ibm.icu.text; version="3.8"
Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.ui.forms;bundle-version="[3.4.0,4.0.0)",
org.eclipse.ui.views;bundle-version="[3.4.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.5.0,4.0.0)",
org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)",
Index: plugin.properties
===================================================================
RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.ui/plugin.properties,v
retrieving revision 1.47
diff -u -r1.47 plugin.properties
--- plugin.properties 25 Aug 2010 18:06:26 -0000 1.47
+++ plugin.properties 7 Sep 2010 05:06:37 -0000
@@ -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
Index: plugin.xml
===================================================================
RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.ui/plugin.xml,v
retrieving revision 1.118
diff -u -r1.118 plugin.xml
--- plugin.xml 25 Aug 2010 18:06:26 -0000 1.118
+++ plugin.xml 7 Sep 2010 05:06:39 -0000
@@ -227,6 +227,20 @@
+
+
+
+
+
+
+
+
+
+
severity.
+ * 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) {
+ fIndex = i;
+ return;
+ }
+ }
+
+ fIndex = -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 parent
. The data
+ * in the Combo is associated with key
. The Combo data is
+ * generated based on the integer values
where the index
+ * of values
corresponds to the index of valueLabels
+ *
+ * @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 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(XMLUIMessages.Validation_Title);
+ /* Choose which message to use based on if its project or workspace settings */
+ String msg = (getProject() == null) ? XMLUIMessages.Validation_Workspace : XMLUIMessages.Validation_Project;
+ mb.setMessage(msg);
+ switch(mb.open()) {
+ case SWT.CANCEL:
+ return false;
+ case SWT.YES:
+ storeValues();
+ ValidateJob job = new ValidateJob(XMLUIMessages.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;
+ }
+
+ }
+
+}
Index: src/org/eclipse/wst/xml/ui/internal/preferences/PropertyPreferencePage.java
===================================================================
RCS file: src/org/eclipse/wst/xml/ui/internal/preferences/PropertyPreferencePage.java
diff -N src/org/eclipse/wst/xml/ui/internal/preferences/PropertyPreferencePage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/wst/xml/ui/internal/preferences/PropertyPreferencePage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,300 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.xml.ui.internal.preferences;
+
+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("" + SSEUIMessages.ConfigureWorkspaceSettings + ""); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ else {
+ fProjectSettingsLink.setText("" + SSEUIMessages.ConfigureProjectSettings + ""); //$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);
+ }
+ }
+}
Index: src/org/eclipse/wst/xml/ui/internal/preferences/XMLValidatorPreferencePage.java
===================================================================
RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLValidatorPreferencePage.java,v
retrieving revision 1.4
diff -u -r1.4 XMLValidatorPreferencePage.java
--- src/org/eclipse/wst/xml/ui/internal/preferences/XMLValidatorPreferencePage.java 19 Apr 2010 17:18:15 -0000 1.4
+++ src/org/eclipse/wst/xml/ui/internal/preferences/XMLValidatorPreferencePage.java 7 Sep 2010 05:06:44 -0000
@@ -13,11 +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.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
@@ -28,491 +32,443 @@
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.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$
+
+ boolean fOriginalUseXIncludeButtonSelected;
+
+ boolean fOriginalUseHonourAllButtonSelected;
+
+ boolean fOriginalUseExtendedMarkupValidation;
+
+ private Combo fIndicateNoGrammar = null;
+
+ private Button fHonourAllSchemaLocations = null;
+
+ private Button fUseXinclude = null;
+
+ private Button fExtendedMarkupValidation;
+
+ private Combo fMissingStartTag;
+
+ private Combo fMissingEndTag;
+
+ private Combo fMissingTagName;
+
+ private Combo fEmptyElementTag;
+
+ private Combo fEndTagWithAttributes;
+
+ private Combo fInvalidWhitespaceBeforeTagname;
+
+ private Combo fMissingClosingBracket;
+
+ private Combo fMissingClosingQuote;
+
+
+ private Combo fMissingQuotes;
+
+ private Combo fInvalidNamespaceInPI;
+
+
+ private Combo fInvalidWhitespaceAtStart;
+
+ private Group fMarkupValidationGroup;
+ private ControlEnableState fMarkupState;
+
+
+ private static final int[] XML_SEVERITIES = { ValidationMessage.WARNING,
+ ValidationMessage.ERROR, ValidationMessage.IGNORE };
+
+ private static final String[] MARKUP_SEVERITIES = {
+ XMLUIMessages.Severity_error, XMLUIMessages.Severity_warning,
+ XMLUIMessages.Severity_ignore };
+
+ protected void createContentsForValidatingGroup(Composite validatingGroup) {
+ int nColumns = 3;
+
+ GridLayout layout = new GridLayout(nColumns, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ validatingGroup.setLayout(layout);
+
+ 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 (fHonourAllSchemaLocations == null) {
+ fHonourAllSchemaLocations = createCheckBox(validatingGroup,
+ XMLUIMessages.Honour_all_schema_locations);
+ ((GridData) fHonourAllSchemaLocations.getLayoutData()).horizontalSpan = 2;
+ }
+
+ IScopeContext[] contexts = createPreferenceScopes();
+ fOriginalUseXIncludeButtonSelected = contexts[0].getNode(getPreferenceNodeQualifier()).getBoolean(
+ XMLCorePreferenceNames.USE_XINCLUDE, true);
+
+ if (fUseXinclude != null) {
+ fUseXinclude.setSelection(fOriginalUseXIncludeButtonSelected);
+ }
+ fOriginalUseHonourAllButtonSelected = contexts[0].getNode(getPreferenceNodeQualifier()).getBoolean(
+ XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS, true);
+ if (fHonourAllSchemaLocations != null) {
+ fHonourAllSchemaLocations.setSelection(fOriginalUseHonourAllButtonSelected);
+ }
+
+ }
+
+ private void handleMarkupSeveritySelection(boolean selection) {
+ if(selection) {
+ if(fMarkupState != null) {
+ fMarkupState.restore();
+ fMarkupState = null;
+ }
+ }
+ else {
+ if(fMarkupState == null)
+ fMarkupState = ControlEnableState.disable(fMarkupValidationGroup);
+ }
+ }
+
+
+ protected void createContentsForMarkupValidationGroup(Composite parent) {
+
+ IScopeContext[] contexts = createPreferenceScopes();
+
+ 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);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ 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();
+ }
-public class XMLValidatorPreferencePage extends AbstractPreferencePage {
- private Combo fIndicateNoGrammar;
-
- private Button fHonourAllSchemaLocations;
-
- 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;
-
- 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};
-
- 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();
-
- return composite;
- }
-
- protected void createContentsForValidatingGroup(Composite parent) {
- Group validatingGroup = createGroup(parent, 2);
- ((GridLayout)validatingGroup.getLayout()).makeColumnsEqualWidth = false;
- validatingGroup.setText(XMLUIMessages.Validating_files);
-
- 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);
- }
- }
-
- 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);
-
- 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);
- }
-
- }
-
- /**
- * @param parent
- * @return
- */
- private Combo createCombo(Composite parent, String[] items) {
- Combo combo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
- combo.setItems(items);
-
- //GridData
- GridData data = new GridData(SWT.FILL, SWT.CENTER, true, true);
- combo.setLayoutData(data);
-
- return combo;
- }
-
- 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);
-
- Combo combo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
- combo.setItems(items);
-
- //GridData
- // GridData data = new GridData(SWT.FILL, SWT.CENTER, false, true);
- combo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-
- return combo;
- }
-
- protected void initializeValues() {
- initializeValuesForValidatingGroup();
- initializeValuesForMarkupValidationGroup();
- }
-
- protected void initializeValuesForValidatingGroup() {
- Preferences modelPreferences = getModelPreferences();
- int indicateNoGrammarButtonSelected = modelPreferences.getInt(XMLCorePreferenceNames.INDICATE_NO_GRAMMAR);
- boolean useXIncludeButtonSelected = modelPreferences.getBoolean(XMLCorePreferenceNames.USE_XINCLUDE);
-
- if (fIndicateNoGrammar != null) {
- fIndicateNoGrammar.select(2 - indicateNoGrammarButtonSelected);
- fIndicateNoGrammar.setText(SEVERITIES[2 - indicateNoGrammarButtonSelected]);
- }
- if (fUseXinclude != null) {
- fUseXinclude.setSelection(useXIncludeButtonSelected);
- }
-
- 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);
-
-
- 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]);
- }
-
- if (!useExtendedMarkupValidation)
- fMarkupState = ControlEnableState.disable(fMarkupValidationGroup);
- }
-
- protected void performDefaultsForValidatingGroup() {
- Preferences modelPreferences = getModelPreferences();
- int indicateNoGrammarButtonSelected = modelPreferences.getDefaultInt(XMLCorePreferenceNames.INDICATE_NO_GRAMMAR);
- boolean useXIncludeButtonSelected = modelPreferences.getDefaultBoolean(XMLCorePreferenceNames.USE_XINCLUDE);
-
- if (fIndicateNoGrammar != null) {
- fIndicateNoGrammar.setSelection(new Point(indicateNoGrammarButtonSelected, 2 - indicateNoGrammarButtonSelected));
- fIndicateNoGrammar.setText(SEVERITIES[indicateNoGrammarButtonSelected]);
- }
- if (fUseXinclude != null) {
- fUseXinclude.setSelection(useXIncludeButtonSelected);
- }
-
- 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
- }
+ protected void doSavePreferenceStore() {
+ XMLCorePlugin.getDefault().savePluginPreferences(); // model
+ }
- public boolean performOk() {
- boolean result = super.performOk();
+ 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);
- doSavePreferenceStore();
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ page.setLayout(layout);
+
+ Group validatingGroup = new Group(page, SWT.NONE);
+ validatingGroup.setLayoutData(GridDataFactory.fillDefaults()
+ .grab(true, false).create());
+ validatingGroup.setLayout(new GridLayout(1, false));
+ validatingGroup.setText(XMLUIMessages.Validating_files);
+ createContentsForValidatingGroup(validatingGroup);
+
+
+ createContentsForMarkupValidationGroup(page);
+
+ return page;
+ }
+
+ protected Composite createComposite(Composite parent, int numColumns) {
+ Composite composite = new Composite(parent, SWT.NULL);
+
+ // GridLayout
+ GridLayout layout = new GridLayout();
+ layout.numColumns = numColumns;
+ composite.setLayout(layout);
+
+ // GridData
+ GridData data = new GridData(GridData.FILL);
+ data.horizontalIndent = 0;
+ data.verticalAlignment = GridData.FILL;
+ data.horizontalAlignment = GridData.FILL;
+ composite.setLayoutData(data);
+
+ return composite;
+ }
+
+ protected Composite createScrolledComposite(Composite parent) {
+ // create scrollbars for this parent when needed
+ final ScrolledComposite sc1 = new ScrolledComposite(parent,
+ SWT.H_SCROLL | SWT.V_SCROLL);
+ sc1.setLayoutData(new GridData(GridData.FILL_BOTH));
+ Composite composite = createComposite(sc1, 1);
+ sc1.setContent(composite);
+
+ // not calling setSize for composite will result in a blank composite,
+ // so calling it here initially
+ // setSize actually needs to be called after all controls are created,
+ // so scrolledComposite
+ // has correct minSize
+ setSize(composite);
+ return composite;
+ }
+
+ protected void setSize(Composite composite) {
+ if (composite != null) {
+ // Note: The font is set here in anticipation that the class
+ // inheriting
+ // this base class may add widgets to the dialog. setSize
+ // is assumed to be called just before we go live.
+ applyDialogFont(composite);
+ Point minSize = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ composite.setSize(minSize);
+ // set scrollbar composite's min size so page is expandable but
+ // has scrollbars when needed
+ if (composite.getParent() instanceof ScrolledComposite) {
+ ScrolledComposite sc1 = (ScrolledComposite) composite
+ .getParent();
+ sc1.setMinSize(minSize);
+ sc1.setExpandHorizontal(true);
+ sc1.setExpandVertical(true);
+ }
+ }
+ }
+
+ protected String getPreferenceNodeQualifier() {
+ return XMLCorePlugin.getDefault().getBundle().getSymbolicName();
+ }
- return result;
- }
+ 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();
+ }
}