Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.wst.validation.ui/vf2/org')
-rw-r--r--plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/AdapterFactory.java95
-rw-r--r--plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/HelpContextIds.java18
-rw-r--r--plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ImageNames.java24
-rw-r--r--plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ManualValidationRunner.java105
-rw-r--r--plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ValUIMessages.java118
-rw-r--r--plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/FilterDialog.java458
-rw-r--r--plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/NewFilterRule.java568
-rw-r--r--plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/ResultsDialog.java158
-rw-r--r--plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/preferences/ValidationPreferencePage.java861
-rw-r--r--plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/preferences/ValidationPropertyPage.java854
10 files changed, 0 insertions, 3259 deletions
diff --git a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/AdapterFactory.java b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/AdapterFactory.java
deleted file mode 100644
index 43375344e..000000000
--- a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/AdapterFactory.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.validation.ui.internal;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.wst.validation.Validator;
-import org.eclipse.wst.validation.internal.model.FilterGroup;
-import org.eclipse.wst.validation.internal.model.FilterRule;
-
-public class AdapterFactory implements IAdapterFactory {
-
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- if (adapterType == IWorkbenchAdapter.class&& adaptableObject instanceof Validator.V2)return _valAdaptor;
- if (adapterType == IWorkbenchAdapter.class && adaptableObject instanceof FilterGroup)return _fgAdaptor;
- if (adapterType == IWorkbenchAdapter.class && adaptableObject instanceof FilterRule)return _ruleAdaptor;
-
- return null;
- }
-
- public Class[] getAdapterList() {
- return new Class[] { IWorkbenchAdapter.class };
- }
-
- private IWorkbenchAdapter _valAdaptor = new IWorkbenchAdapter() {
-
- public Object[] getChildren(Object o) {
- return ((Validator.V2) o).getGroups();
- }
-
- public ImageDescriptor getImageDescriptor(Object o) {
- return null;
- }
-
- public String getLabel(Object o) {
- return ((Validator.V2) o).getName();
- }
-
- public Object getParent(Object o) {
- return null;
- }
-
- };
-
- private IWorkbenchAdapter _fgAdaptor = new IWorkbenchAdapter() {
-
- public Object[] getChildren(Object o) {
- return ((FilterGroup) o).getRules();
- }
-
- public ImageDescriptor getImageDescriptor(Object o) {
- return null;
- }
-
- public String getLabel(Object o) {
- FilterGroup fg = (FilterGroup) o;
- return fg.getDisplayableType();
- }
-
- public Object getParent(Object o) {
- return null;
- }
- };
-
- private IWorkbenchAdapter _ruleAdaptor = new IWorkbenchAdapter() {
-
- public Object[] getChildren(Object o) {
- return new Object[0];
- }
-
- public ImageDescriptor getImageDescriptor(Object o) {
- return null;
- }
-
- public String getLabel(Object o) {
- FilterRule rule = (FilterRule) o;
- return rule.getName();
- }
-
- public Object getParent(Object o) {
- return null;
- }
-
- };
-
-}
diff --git a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/HelpContextIds.java b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/HelpContextIds.java
deleted file mode 100644
index 1af7aeb85..000000000
--- a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/HelpContextIds.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.eclipse.wst.validation.ui.internal;
-
-import org.eclipse.wst.validation.internal.ui.plugin.ValidationUIPlugin;
-
-public interface HelpContextIds {
- String PreferencePage = ValidationUIPlugin.VALIDATION_PLUGIN_ID + ".jvgp0000"; //$NON-NLS-1$
-
- String FilterRule = ValidationUIPlugin.VALIDATION_PLUGIN_ID + ".jvgp0100"; //$NON-NLS-1$
- String FRFileExt = ValidationUIPlugin.VALIDATION_PLUGIN_ID + ".jvgp0101"; //$NON-NLS-1$
- String FRName = ValidationUIPlugin.VALIDATION_PLUGIN_ID + ".jvgp0102"; //$NON-NLS-1$
- String FRProjectNature = ValidationUIPlugin.VALIDATION_PLUGIN_ID + ".jvgp0103"; //$NON-NLS-1$
- String FRFacet = ValidationUIPlugin.VALIDATION_PLUGIN_ID + ".jvgp0104"; //$NON-NLS-1$
- String FRContentType = ValidationUIPlugin.VALIDATION_PLUGIN_ID + ".jvgp0105"; //$NON-NLS-1$
-
- String ProjectPage = ValidationUIPlugin.VALIDATION_PLUGIN_ID + ".jvpp0000"; //$NON-NLS-1$
- String ProjectFilterRule = ValidationUIPlugin.VALIDATION_PLUGIN_ID + ".jvpp0100"; //$NON-NLS-1$
-
-}
diff --git a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ImageNames.java b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ImageNames.java
deleted file mode 100644
index 58731705e..000000000
--- a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ImageNames.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.validation.ui.internal;
-
-/**
- * Names of the images.
- * @author karasiuk
- *
- */
-public interface ImageNames {
-
- String okTable = "ok_tbl"; //$NON-NLS-1$
- String failTable = "fail_tbl"; //$NON-NLS-1$
- String settings = "settings"; //$NON-NLS-1$
- String disabled = "_disabled"; //$NON-NLS-1$
-}
diff --git a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ManualValidationRunner.java b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ManualValidationRunner.java
deleted file mode 100644
index 52b47ea13..000000000
--- a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ManualValidationRunner.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 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.validation.ui.internal;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.WorkspaceJob;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.MultiRule;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.validation.ValidationResult;
-import org.eclipse.wst.validation.internal.ValOperation;
-import org.eclipse.wst.validation.internal.ValType;
-import org.eclipse.wst.validation.internal.ValidationRunner;
-import org.eclipse.wst.validation.ui.internal.dialog.ResultsDialog;
-
-/**
- * Run a manual validation.
- * @author karasiuk
- *
- */
-public class ManualValidationRunner extends WorkspaceJob {
-
- private Map<IProject, Set<IResource>> _projects;
- private ValType _valType;
- private boolean _showResults;
-
- /**
- * Validate the selected projects and/or resources.
- *
- * @param projects
- * The selected projects. The key is an IProject and the value is
- * the Set of IResources that were selected. Often this will be
- * every resource in the project.
- *
- * @param isManual
- * Is this a manual validation?
- *
- * @param isBuild
- * Is this a build based validation?
- *
- * @param showResults
- * When the validation is finished, show the results in a dialog box.
- */
- public static void validate(Map<IProject, Set<IResource>> projects, ValType valType, boolean showResults){
- ManualValidationRunner me = new ManualValidationRunner(projects, valType, showResults);
-
- //TODO optimize this, I don't like the idea of validators having to lock the entire project
- Set<IProject> keys = projects.keySet();
- IProject[] projectArray = new IProject[keys.size()];
- keys.toArray(projectArray);
- if (projectArray.length == 1)me.setRule(projectArray[0]);
- else {
- me.setRule(MultiRule.combine(projectArray));
- }
- me.schedule();
- }
-
- private ManualValidationRunner(Map<IProject, Set<IResource>> projects, ValType valType, boolean showResults){
- super(ValUIMessages.Validation);
- _projects = projects;
- _valType = valType;
- _showResults = showResults;
- }
-
- public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
-
- long start = System.currentTimeMillis();
- final ValOperation vo = ValidationRunner.validate(_projects, _valType, monitor, false);
- final long time = System.currentTimeMillis() - start;
- int resourceCount = 0;
- for (Set s : _projects.values())resourceCount += s.size();
- final int finalResourceCount = resourceCount;
- if (vo.getResult().isCanceled())return Status.CANCEL_STATUS;
-
- if (_showResults){
- Display display = Display.getDefault();
- Runnable run = new Runnable(){
-
- public void run() {
- ValidationResult vr = vo.getResult();
- ResultsDialog rd = new ResultsDialog(null, vr, time, finalResourceCount);
- rd.open();
- }
-
- };
- display.asyncExec(run);
- }
- return Status.OK_STATUS;
- }
-}
diff --git a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ValUIMessages.java b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ValUIMessages.java
deleted file mode 100644
index 99da9b935..000000000
--- a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/ValUIMessages.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 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.validation.ui.internal;
-
-import org.eclipse.osgi.util.NLS;
-
-public class ValUIMessages extends NLS {
-
- private static final String BUNDLE_NAME = "org.eclipse.wst.validation.ui.internal.messages"; //$NON-NLS-1$
-
- public static String ADD_VALIDATION_BUILDER;
-
- public static String PREF_BUTTON_OVERRIDE;
- public static String PREF_VALLIST_TITLE;
- public static String PREF_BUTTON_ENABLEALL;
- public static String PREF_BUTTON_DISABLEALL;
- public static String PREF_MNU_MANUAL;
- public static String PREF_MNU_BUILD;
- public static String PREF_MNU_SETTINGS;
-
- public static String ConfigWsSettings;
- public static String DoNotShowResults;
- public static String DelegatesDialogTitle;
- public static String DelegatesComboLabel;
-
- public static String ErrorsWarnings;
-
- public static String VBF_EXC_INTERNAL_TITLE;
- public static String VBF_EXC_INTERNAL_PAGE;
- public static String VBF_EXC_INVALID_REGISTER;
- public static String DISABLE_VALIDATION;
-
- public static String MANUAL;
- public static String BUILD;
- public static String SETTINGS;
- public static String VALIDATOR;
- public static String VBF_UI_NO_VALIDATORS_INSTALLED;
-
- public static String SaveFilesDialog_saving;
- public static String SaveFilesDialog_always_save;
- public static String SaveFilesDialog_save_all_resources;
- public static String SaveFilesDialog_must_save;
- public static String PrefPage_always_save;
- public static String PrefPageConfirmDialog;
- public static String ProjectOverridesNotAllowed;
- public static String RunValidationDialogTitle;
-
- /* Validator Filters */
- public static String fdTitle;
- public static String fdNoFilters;
-
- public static String ErrConfig;
-
- public static String FilterHelp;
-
- public static String ButtonAddGroupInclude;
- public static String ButtonAddGroupExclude;
- public static String ButtonAddRule;
- public static String ButtonRemove;
-
- public static String LabelExtension;
- public static String LabelFile;
- public static String LabelProjects;
- public static String LabelFacets;
- public static String LabelContentType;
- public static String LabelEnableProjectSpecific;
-
- public static String DescExtension;
- public static String DescFile;
- public static String DescProjects;
- public static String DescFacets;
- public static String DescContentType;
-
- public static String Validation;
- public static String ValidationStatus;
-
- public static String ErrSummary;
- public static String ValidationSuccessful;
-
- public static String FrWizard;
- public static String FrSelectFilterType;
- public static String FrFileExtension;
- public static String FrFileExtensionLabel;
- public static String FrCaseSensitive;
- public static String FrExactMatch;
- public static String FrFolderOrFile;
- public static String FrFolderOrFileLabel;
- public static String FrBrowseFile;
- public static String FrFileFilter;
- public static String FrBrowseFolder;
- public static String FrFolderFilter;
- public static String FrProjectNature;
- public static String FrProjectNatureLabel;
- public static String FrSimpleFileName;
- public static String FrFacit;
- public static String FrFacitLabel;
- public static String FrContentType;
- public static String FrContentTypeLabel;
- public static String FrMsgSev;
-
- public static String RebuildTitle;
- public static String RebuildMsg;
-
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, ValUIMessages.class);
- }
-
-}
diff --git a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/FilterDialog.java b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/FilterDialog.java
deleted file mode 100644
index 672b2d093..000000000
--- a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/FilterDialog.java
+++ /dev/null
@@ -1,458 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.validation.ui.internal.dialog;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-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.swt.widgets.Shell;
-import org.eclipse.ui.model.BaseWorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.eclipse.wst.validation.MessageSeveritySetting;
-import org.eclipse.wst.validation.Validator;
-import org.eclipse.wst.validation.internal.ValManager;
-import org.eclipse.wst.validation.internal.ValMessages;
-import org.eclipse.wst.validation.internal.delegates.ValidatorDelegateDescriptor;
-import org.eclipse.wst.validation.internal.delegates.ValidatorDelegatesRegistry;
-import org.eclipse.wst.validation.internal.model.FilterGroup;
-import org.eclipse.wst.validation.internal.model.FilterRule;
-import org.eclipse.wst.validation.internal.model.ValidatorHelper;
-import org.eclipse.wst.validation.ui.internal.AdapterFactory;
-import org.eclipse.wst.validation.ui.internal.ValUIMessages;
-
-/**
- * Display a filter dialog for a particular Validator, that is a list of all the filters that are active for
- * the validator.
- *
- * @author karasiuk
- *
- */
-public class FilterDialog extends Dialog {
-
- /**
- * If we are doing project level filters this will point to the project. This is null if we are doing
- * workspace level filters.
- */
- private IProject _project;
-
- /**
- * A deep copy of the validator, so that we can use it as a model object, and not worry about the
- * user not saving their changes.
- */
- private Validator _validator;
-
- // The V2 version of _validator.
- private Validator.V2 _v2;
- private TreeViewer _tree;
- private Combo _delegating;
- private IAdapterFactory _adaptorFactory = new AdapterFactory();
-
- private Button _addGroupInclude;
- private Button _addGroupExclude;
- private Button _addRule;
- private Button _remove;
- private ISelectionChangedListener _nodeChangedListener;
-
- private FilterGroup _selectedGroup;
- private FilterRule _selectedRule;
-
- private Combo[] _messageSev;
-
- private static String[] _messages = new String[]{
- ValMessages.SevError, ValMessages.SevWarning, ValMessages.SevIgnore};
-
- private Shell _shell;
-
- /**
- * Create a dialog that knows how to change a validator's filters.
- *
- * @param shell
- *
- * @param validator the validator that is being updated.
- *
- * @param project the project that the filters are being added to. If these are workspace
- * level filters, then this must be null.
- */
- public FilterDialog(Shell shell, Validator validator, IProject project){
- super(shell);
- _shell = shell;
- setShellStyle(getShellStyle() | SWT.CLOSE|SWT.MIN|SWT.MAX|SWT.RESIZE);
- _validator = validator.copy(true);
- _v2 = _validator.asV2Validator();
- _project = project;
- }
-
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(NLS.bind(ValUIMessages.fdTitle, _validator.getName()));
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite c = (Composite)super.createDialogArea(parent);
- c.setLayout(new GridLayout(2, false));
- if (_v2 == null){
- new Label(c, SWT.NONE).setText(ValUIMessages.fdNoFilters);
- }
- else {
- Label blurb = new Label(c, SWT.LEFT | SWT.WRAP);
- blurb.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
- blurb.setText(ValUIMessages.FilterHelp);
-
- _tree = new TreeViewer(c, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- _tree.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- Platform.getAdapterManager().registerAdapters(_adaptorFactory, Validator.V2.class);
- Platform.getAdapterManager().registerAdapters(_adaptorFactory, FilterGroup.class);
- Platform.getAdapterManager().registerAdapters(_adaptorFactory, FilterRule.class);
- _tree.setContentProvider(new BaseWorkbenchContentProvider());
- _tree.setLabelProvider(new WorkbenchLabelProvider());
- _tree.setInput(_v2);
- _tree.expandAll();
-
- addButtons(c);
-
- String delegatingId = _v2.getDelegatingId();
- if (delegatingId != null){
- addDelegatorSelection(c);
- }
-
- _nodeChangedListener = new ISelectionChangedListener(){
-
- public void selectionChanged(SelectionChangedEvent event) {
- _selectedGroup = null;
- _selectedRule = null;
- if (event.getSelection() instanceof IStructuredSelection){
- IStructuredSelection sel = (IStructuredSelection)event.getSelection();
- if (sel.getFirstElement() instanceof FilterGroup){
- _selectedGroup = (FilterGroup)sel.getFirstElement();
- }
- else if (sel.getFirstElement() instanceof FilterRule){
- _selectedRule = (FilterRule)sel.getFirstElement();
- }
- }
- updateButtons();
- }
-
- };
-
- _tree.addSelectionChangedListener(_nodeChangedListener);
-
- addMessageMappings(c);
- }
- return c;
- }
-
- private void addButtons(Composite c) {
- Composite buttons = new Composite(c, SWT.TOP);
- GridData gd = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1);
- buttons.setLayoutData(gd);
- buttons.setLayout(new GridLayout(1, true));
- _addGroupInclude = new Button(buttons, SWT.PUSH | SWT.FILL | SWT.CENTER);
- _addGroupInclude.setText(ValUIMessages.ButtonAddGroupInclude);
- _addGroupInclude.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
-
- _addGroupInclude.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- addGroup(false);
- }
-
- public void widgetSelected(SelectionEvent e) {
- addGroup(false);
- }
-
- });
-
- _addGroupExclude = new Button(buttons, SWT.PUSH | SWT.FILL | SWT.CENTER);
- _addGroupExclude.setText(ValUIMessages.ButtonAddGroupExclude);
- _addGroupExclude.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
-
- _addGroupExclude.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- addGroup(true);
- }
-
- public void widgetSelected(SelectionEvent e) {
- addGroup(true);
- }
-
- });
-
- _addRule = new Button(buttons, SWT.PUSH | SWT.FILL | SWT.CENTER);
- _addRule.setText(ValUIMessages.ButtonAddRule);
- _addRule.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
- _addRule.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- doIt();
- }
-
- public void widgetSelected(SelectionEvent e) {
- doIt();
- }
-
- private void doIt(){
- NewFilterRule nfr = new NewFilterRule(_project);
- WizardDialog wd = new WizardDialog(_shell, nfr);
- wd.setBlockOnOpen(true);
- int rc = wd.open();
- if (rc == WizardDialog.CANCEL)return;
-
- FilterRule rule = nfr.getRule();
- if (rule != null){
- _selectedGroup.add(rule);
- _v2.bumpChangeCountGroups();
- refresh();
- }
- }
-
- });
-
- _remove = new Button(buttons, SWT.PUSH | SWT.FILL | SWT.CENTER);
- _remove.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
- _remove.setText(ValUIMessages.ButtonRemove);
- _remove.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- remove();
- }
-
- public void widgetSelected(SelectionEvent e) {
- remove();
- }
- });
-
- Button restore = new Button(buttons, SWT.PUSH | SWT.FILL | SWT.CENTER);
- restore.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
- String defaults = JFaceResources.getString("defaults"); //$NON-NLS-1$
- restore.setText(defaults);
- restore.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- restoreDefaults();
- }
-
- public void widgetSelected(SelectionEvent e) {
- restoreDefaults();
- }
- });
- }
-
- private void restoreDefaults() {
- if (_v2 != null){
- try {
- String id = _v2.getId();
- Validator[] vals = ValManager.getDefaultValidators();
- for (Validator v : vals){
- if (v.getId().equals(id)){
- _validator = v;
- _v2 = v.asV2Validator();
- _tree.setInput(_v2);
- _tree.expandAll();
- refresh();
- return;
- }
- }
- }
- catch (InvocationTargetException e){
-
- }
- }
-
- }
-
-
- private void addMessageMappings(Composite c) {
- if (_v2 == null)return;
- Map<String,MessageSeveritySetting> mappings = _validator.getMessageSettings();
- if (mappings == null || mappings.size() == 0)return;
-
- Group group = new Group(c, SWT.NONE);
- group.setText(ValUIMessages.FrMsgSev);
- group.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
- group.setLayout(new GridLayout(2, false));
-
-// Label heading = new Label(c, SWT.LEFT);
-// heading.setText(ValUIMessages.ErrorsWarnings);
-// heading.setFont(JFaceResources.getHeaderFont());
-// heading.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
-
- _messageSev = new Combo[mappings.size()];
- int i= 0;
- for (MessageSeveritySetting ms : mappings.values()){
- Label label = new Label(group, SWT.LEFT);
- label.setText(" " + ms.getLabel() + ":"); //$NON-NLS-1$ //$NON-NLS-2$
-
- Combo sev = new Combo(group, SWT.RIGHT);
- _messageSev[i++] = sev;
- sev.setItems(_messages);
- sev.select(ms.getCurrent().ordinal());
- sev.setData(ms);
- sev.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- select(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
- select(e);
- }
-
- private void select(SelectionEvent e){
- Combo w = (Combo)e.widget;
- MessageSeveritySetting ms = (MessageSeveritySetting)w.getData();
- int i = w.getSelectionIndex();
- if (ms.setCurrent(MessageSeveritySetting.Severity.values()[i]))
- _validator.bumpChangeCountMessages();
- }
-
- });
- }
- }
-
- /**
- * Add a combo box so that the user can change which delegating validator to call.
- */
- private void addDelegatorSelection(Composite c) {
- Map map = ValidatorDelegatesRegistry.getInstance().getDelegateDescriptors(_v2.getValidatorClassname());
- if (map == null)return;
-
- Composite line = new Composite(c, SWT.NONE);
- line.setLayout(new RowLayout(SWT.HORIZONTAL));
- line.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
-
- Label label = new Label(line, SWT.CENTER);
- label.setText(ValUIMessages.DelegatesComboLabel);
-
-
- _delegating = new Combo(line, SWT.READ_ONLY);
- String[] items = new String[map.size()];
- final String ids[] = new String[map.size()];
- String selected = null;
- Iterator it = map.values().iterator();
- for (int i=0; i<items.length;i++){
- ValidatorDelegateDescriptor vd = (ValidatorDelegateDescriptor)it.next();
- items[i] = vd.getName();
- ids[i] = vd.getId();
- if (vd.getId().equals(_v2.getDelegatingId())){
- selected = vd.getName();
- }
- }
- _delegating.setItems(items);
- _delegating.setText(selected);
- _delegating.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- int sel = _delegating.getSelectionIndex();
- _v2.setDelegatingId(ids[sel]);
- }
-
- });
- }
-
- /**
- * Add a new filter group to the validator.
- * @param exclude
- */
- private void addGroup(boolean exclude){
- if (_v2 == null)return;
- _v2.add(FilterGroup.create(exclude));
- refresh();
-
- }
-
- private void refresh(){
- _tree.refresh();
- updateButtons();
- }
-
- /**
- * Remove the current selection from the validator.
- */
- private void remove(){
- if (_selectedRule != null){
- FilterGroup[] groups = _v2.getGroups();
- for (int i=0; i<groups.length; i++){
- if (groups[i].remove(_selectedRule)){
- _v2.bumpChangeCountGroups();
- refresh();
- return;
- }
- }
- }
-
- if (_selectedGroup != null){
- _v2.remove(_selectedGroup);
- refresh();
- return;
- }
- }
-
- private void updateButtons() {
- if (_v2 != null){
- _addGroupExclude.setEnabled(!ValidatorHelper.hasExcludeGroup(_v2));
- }
- _addRule.setEnabled(_selectedGroup != null);
- _remove.setEnabled(_selectedGroup != null || _selectedRule != null);
- if (_messageSev != null){
- Map<String,MessageSeveritySetting> msgs = _validator.getMessageSettings();
- if (msgs != null && _messageSev.length == msgs.size()){
- int i = 0;
- for (MessageSeveritySetting ms : msgs.values()){
- _messageSev[i++].select(ms.getCurrent().ordinal());
- }
- }
- }
- }
-
-
- public boolean close() {
- Platform.getAdapterManager().unregisterAdapters(_adaptorFactory);
- if (_tree != null)_tree.removeSelectionChangedListener(_nodeChangedListener);
- return super.close();
- }
-
- protected Point getInitialSize() {
- return new Point(600, 475);
- }
-
- public Validator getValidator() {
- return _validator;
- }
-}
diff --git a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/NewFilterRule.java b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/NewFilterRule.java
deleted file mode 100644
index fad49d751..000000000
--- a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/NewFilterRule.java
+++ /dev/null
@@ -1,568 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.validation.ui.internal.dialog;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectNatureDescriptor;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.validation.internal.model.FilterRule;
-import org.eclipse.wst.validation.ui.internal.HelpContextIds;
-import org.eclipse.wst.validation.ui.internal.ValUIMessages;
-
-/**
- * A wizard that adds new rules to validators.
- * @author karasiuk
- *
- */
-public class NewFilterRule extends Wizard {
-
- private Page1 _page1;
- private IWizardPage _page2;
-
- private IProject _project;
-
- private FilterRule _rule;
-
- public NewFilterRule(IProject project){
- _project = project;
- setWindowTitle(ValUIMessages.FrWizard);
- _page1 = new Page1(project);
- addPage(_page1);
- setForcePreviousAndNextButtons(true);
- }
-
- public boolean canFinish() {
- if (_page2 != null)return _page2.isPageComplete();
- return false;
- }
-
- public FilterRule getRule(){
- return _rule;
- }
-
- public boolean performFinish() {
- if (_page2 == null)return false;
- FilterWizardPage page = (FilterWizardPage)_page2;
- _rule = page.getFilterRule();
- return _rule != null;
- }
-
- public IWizardPage getNextPage(IWizardPage page) {
- if (page == _page1){
- setForcePreviousAndNextButtons(false);
- _page2 = returnOrBuildPage(_page1.getSelectedFilter());
- return _page2;
- }
- return null;
- }
-
- private IWizardPage returnOrBuildPage(int selectedFilter) {
- IWizardPage page = null;
- if (_project != null && selectedFilter == 2)selectedFilter = 4;
- switch (selectedFilter){
- case 0:
- page = new FileExtPage();
- break;
- case 1:
- page = new FilePage(_project);
- break;
- case 2:
- page = new ProjectPage();
- break;
- case 3:
- page = new FacetPage();
- break;
- case 4:
- page = new ContentTypePage();
- break;
- }
- addPage(page);
- return page;
- }
-
- public static class Page1 extends WizardPage {
-
- private int _selectedFilter;
- private IProject _project;
-
-
- public Page1(IProject project){
- super("page1", ValUIMessages.FrSelectFilterType, null); //$NON-NLS-1$
- setPageComplete(true);
- _project = project;
- }
-
- public void createControl(Composite parent) {
- String helpId = _project == null ? HelpContextIds.FilterRule : HelpContextIds.ProjectFilterRule;
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, helpId);
- String[] labels = null;
- String[] desc = null;
- if (_project != null){
- labels = new String[]{ValUIMessages.LabelExtension, ValUIMessages.LabelFile,
- ValUIMessages.LabelContentType};
-
- desc = new String[]{ValUIMessages.DescExtension, ValUIMessages.DescFile,
- ValUIMessages.DescContentType};
- }
- else {
- labels = new String[]{ValUIMessages.LabelExtension, ValUIMessages.LabelFile,
- ValUIMessages.LabelProjects, ValUIMessages.LabelFacets,
- ValUIMessages.LabelContentType};
-
- desc = new String[]{ValUIMessages.DescExtension, ValUIMessages.DescFile,
- ValUIMessages.DescProjects, ValUIMessages.DescFacets,
- ValUIMessages.DescContentType};
- }
-
- Composite control = new Composite(parent, SWT.NONE);
- control.setLayout(new GridLayout(2, false));
-
- SelectionListener listener = new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- doIt(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
- doIt(e);
- }
-
- private void doIt(SelectionEvent e){
- if (e.getSource() instanceof Button){
- Button b = (Button)e.getSource();
- if (b.getData() instanceof Integer) {
- Integer index = (Integer) b.getData();
- setSelectedFilter(index.intValue());
- }
- }
- }
-
- };
- for (int i=0; i<labels.length; i++){
- Button button = new Button(control, SWT.RADIO);
- button.setText(labels[i]);
- button.setData(new Integer(i));
- button.addSelectionListener(listener);
- (new Label(control, SWT.WRAP)).setText(desc[i]);
- if (i == 0)button.setSelection(true);
- }
- setControl(control);
- }
-
- public int getSelectedFilter() {
- return _selectedFilter;
- }
-
- public void setSelectedFilter(int selectedFilter) {
- _selectedFilter = selectedFilter;
- getContainer().updateButtons();
- }
-
- }
-
- public static class FileExtPage extends WizardPage implements FilterWizardPage {
-
- private Text _pattern;
- private Button _case;
-
- public FileExtPage(){
- super("fileext", ValUIMessages.FrFileExtension, null); //$NON-NLS-1$
- }
-
- public void createControl(Composite parent) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HelpContextIds.FRFileExt);
- Composite control = new Composite(parent, SWT.NONE);
- setControl(control);
- control.setLayout(new GridLayout(2, false));
- (new Label(control, SWT.NONE)).setText(ValUIMessages.FrFileExtensionLabel);
- _pattern = new Text(control, SWT.NONE);
- _pattern.setFocus();
- _pattern.addModifyListener(new ModifyListener(){
-
- public void modifyText(ModifyEvent e) {
- getContainer().updateButtons();
- }
-
- });
-
- _case = new Button(control, SWT.CHECK);
- _case.setText(ValUIMessages.FrCaseSensitive);
- _case.setSelection(false);
- _case.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING,false, false, 2, 1));
-
- }
-
- public FilterRule getFilterRule() {
- if (!isPageComplete())return null;
- return FilterRule.FileExt.createFileExt(_pattern.getText(), _case.getSelection());
- }
-
- public boolean isPageComplete() {
- return _pattern != null && _pattern.getText().trim().length() > 0;
- }
-
-
- }
-
- public static class FilePage extends WizardPage implements FilterWizardPage {
-
- private Text _pattern;
- private Button _browseFile;
- private Button _browseFolder;
- private Button _case;
- private Button _simpleFileName;
-
- private IProject _project;
- private int _type = FilterRule.File.FileTypeFile;
- private IPath _fullFileName;
- private String _root;
-
- public FilePage(IProject project){
- super("file", ValUIMessages.FrFolderOrFile, null); //$NON-NLS-1$
- _project = project;
- }
-
- public void createControl(Composite parent) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HelpContextIds.FRName);
- final Composite control = new Composite(parent, SWT.NONE);
- setControl(control);
- control.setLayout(new GridLayout(4, false));
- (new Label(control, SWT.NONE)).setText(ValUIMessages.FrFolderOrFileLabel);
- _pattern = new Text(control, SWT.NONE);
- _pattern.setFocus();
- _pattern.setLayoutData(new GridData(300, SWT.DEFAULT));
- _pattern.addModifyListener(new ModifyListener(){
-
- public void modifyText(ModifyEvent e) {
- getContainer().updateButtons();
- }
-
- });
-
- _root = null;
- IPath base = _project == null ? ResourcesPlugin.getWorkspace().getRoot().getLocation() :
- _project.getLocation();
- if (base != null)_root = base.toOSString();
-
- _browseFile = new Button(control, SWT.PUSH);
- _browseFile.setText(ValUIMessages.FrBrowseFile);
- _browseFile.setEnabled(_root != null);
- _browseFile.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- browse();
- }
-
- public void widgetSelected(SelectionEvent e) {
- browse();
- }
-
- private void browse(){
- FileDialog fd = new FileDialog(control.getShell(), SWT.OPEN);
- fd.setText(ValUIMessages.FrFileFilter);
- fd.setFilterPath(_root);
-
- String file = fd.open();
- if (file != null){
- if (file.startsWith(_root))file = file.substring(_root.length()+1);
- else file = null;
- }
- if (file != null){
- _fullFileName = new Path(file);
- if (_project == null)_fullFileName = _fullFileName.removeFirstSegments(1);
-
- if (_simpleFileName.getSelection()){
- _type = FilterRule.File.FileTypeFile;
- _pattern.setText(_fullFileName.lastSegment());
- }
- else {
- _type = FilterRule.File.FileTypeFull;
- _pattern.setText(_fullFileName.toPortableString());
- }
- }
- else {
- _fullFileName = null;
- _pattern.setText(""); //$NON-NLS-1$
- }
- }
- });
-
- _browseFolder = new Button(control, SWT.PUSH);
- _browseFolder.setText(ValUIMessages.FrBrowseFolder);
- _browseFolder.setEnabled(_root != null);
- _browseFolder.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- browse();
- }
-
- public void widgetSelected(SelectionEvent e) {
- browse();
- }
-
- private void browse(){
- DirectoryDialog fd = new DirectoryDialog(control.getShell());
- fd.setMessage(ValUIMessages.FrFolderFilter);
- fd.setFilterPath(_root);
- String dir = fd.open();
- if (dir != null){
- _fullFileName = null;
- _type = FilterRule.File.FileTypeFolder;
- if (dir.startsWith(_root) && dir.length() > _root.length()){
- dir = dir.substring(_root.length()+1);
- IPath path = new Path(dir);
- if (_project == null)path = path.removeFirstSegments(1);
- _pattern.setText(path.toPortableString());
- }
- else {
- _pattern.setText(""); //$NON-NLS-1$
- }
- }
- }
-
- });
-
- _case = new Button(control, SWT.CHECK);
- _case.setText(ValUIMessages.FrCaseSensitive);
- _case.setSelection(false);
- _case.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING,false, false, 4, 1));
-
- addSimpleFileNameButton(control);
- }
-
- private void addSimpleFileNameButton(final Composite control) {
- _simpleFileName = new Button(control, SWT.CHECK);
- _simpleFileName.setText(ValUIMessages.FrSimpleFileName);
- _simpleFileName.setSelection(_type == FilterRule.File.FileTypeFile);
- _simpleFileName.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING,false, false, 4, 1));
-
- _simpleFileName.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- if (_type == FilterRule.File.FileTypeFolder)return;
- if (_simpleFileName.getSelection()){
- if (_fullFileName != null)_pattern.setText(_fullFileName.lastSegment());
- _type = FilterRule.File.FileTypeFile;
- }
- else {
- if (_fullFileName != null)_pattern.setText(_fullFileName.toPortableString());
- _type = FilterRule.File.FileTypeFull; }
- }
- });
- }
-
- public FilterRule getFilterRule() {
- if (!isPageComplete())return null;
- return FilterRule.createFile(_pattern.getText(), _case.getSelection(), _type);
- }
-
- public boolean isPageComplete() {
- if (_pattern == null)return false;
- if (_pattern.getText() == null)return false;
- return _pattern.getText().trim().length() > 0;
- }
-
- }
-
- public static class ProjectPage extends WizardPage implements FilterWizardPage{
-
- private Combo _natures;
- private String[] _ids;
-
- public ProjectPage(){
- super("project", ValUIMessages.FrProjectNature, null); //$NON-NLS-1$
- }
-
- public void createControl(Composite parent) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HelpContextIds.FRProjectNature);
- Composite control = new Composite(parent, SWT.NONE);
- setControl(control);
- control.setLayout(new GridLayout(2, false));
- (new Label(control, SWT.NONE)).setText(ValUIMessages.FrProjectNatureLabel);
-
- IProjectNatureDescriptor[] pn = ResourcesPlugin.getWorkspace().getNatureDescriptors();
- String items[] = new String[pn.length];
- _ids = new String[pn.length];
- for (int i=0; i<pn.length; i++){
- _ids[i] = pn[i].getNatureId();
- items[i] = pn[i].getLabel() + " - " + _ids[i]; //$NON-NLS-1$
- }
- _natures = new Combo(control, SWT.DROP_DOWN);
- _natures.setItems(items);
- _natures.addModifyListener(new ModifyListener(){
-
- public void modifyText(ModifyEvent e) {
- getContainer().updateButtons();
- }
-
- });
-
- }
-
- public FilterRule getFilterRule() {
- if (!isPageComplete())return null;
- int i = _natures.getSelectionIndex();
- if (i == -1)return null;
-
- return FilterRule.createProject(_ids[i]);
- }
-
- public boolean isPageComplete() {
- if (_natures == null)return false;
- if (_natures.getText() == null)return false;
- return _natures.getText().trim().length() > 0;
- }
-
- }
-
- public static class FacetPage extends WizardPage implements FilterWizardPage {
-
- private Text _pattern;
-
- public FacetPage(){
- super("facet", ValUIMessages.FrFacit, null); //$NON-NLS-1$
- }
-
- public void createControl(Composite parent) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HelpContextIds.FRFacet);
- Composite control = new Composite(parent, SWT.NONE);
- setControl(control);
- control.setLayout(new GridLayout(2, false));
- (new Label(control, SWT.NONE)).setText(ValUIMessages.FrFacitLabel);
- _pattern = new Text(control, SWT.NONE);
- _pattern.setFocus();
- _pattern.setLayoutData(new GridData(300, SWT.DEFAULT));
- _pattern.addModifyListener(new ModifyListener(){
-
- public void modifyText(ModifyEvent e) {
- getContainer().updateButtons();
- }
-
- });
- }
-
- public FilterRule getFilterRule() {
- if (!isPageComplete())return null;
- FilterRule rule = FilterRule.createFacet(_pattern.getText());
- return rule;
- }
-
- public boolean isPageComplete() {
- if (_pattern == null)return false;
- if (_pattern.getText() == null)return false;
- return _pattern.getText().trim().length() > 0;
- }
-
- }
-
- public static class ContentTypePage extends WizardPage implements FilterWizardPage {
- private Combo _pattern;
- private Button _exactMatch;
- private Map<String, IContentType> _map;
-
- public ContentTypePage(){
- super("contentType", ValUIMessages.FrContentType, null); //$NON-NLS-1$
- }
-
- public void createControl(Composite parent) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HelpContextIds.FRContentType);
- Composite control = new Composite(parent, SWT.NONE);
- setControl(control);
- control.setLayout(new GridLayout(2, false));
- (new Label(control, SWT.NONE)).setText(ValUIMessages.FrContentTypeLabel);
-
- IContentType[] types = Platform.getContentTypeManager().getAllContentTypes();
- _map = new TreeMap<String, IContentType>();
- for (IContentType type : types){
- String name = type.getName();
- if (name == null)name = type.getId();
- _map.put(name, type);
- }
- String items[] = new String[_map.size()];
- int i = 0;
- for (String label : _map.keySet()){
- items[i++] = label;
- }
- _pattern = new Combo(control, SWT.DROP_DOWN | SWT.READ_ONLY);
- _pattern.setFocus();
- _pattern.setLayoutData(new GridData(300, SWT.DEFAULT));
- _pattern.setVisibleItemCount(20);
- _pattern.setItems(items);
- _pattern.addModifyListener(new ModifyListener(){
-
- public void modifyText(ModifyEvent e) {
- getContainer().updateButtons();
- }
-
- });
-
- _exactMatch = new Button(control, SWT.CHECK);
- _exactMatch.setText(ValUIMessages.FrExactMatch);
- _exactMatch.setSelection(false);
- _exactMatch.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING,false, false, 2, 1));
-
- }
-
- public FilterRule getFilterRule() {
- if (!isPageComplete())return null;
- IContentType type = _map.get(_pattern.getText());
- if (type == null)return null;
- FilterRule rule = FilterRule.createContentType(type.getId(), _exactMatch.getSelection());
- return rule;
- }
-
- public boolean isPageComplete() {
- if (_pattern == null)return false;
- if (_pattern.getText() == null)return false;
- return _pattern.getText().trim().length() > 0;
- }
-
- }
-
- interface FilterWizardPage {
- /**
- * Answer the rule that was created.
- *
- * @return null if the user didn't create a new rule.
- */
- FilterRule getFilterRule();
- }
-
-
-}
diff --git a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/ResultsDialog.java b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/ResultsDialog.java
deleted file mode 100644
index 4522eeaf1..000000000
--- a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/dialog/ResultsDialog.java
+++ /dev/null
@@ -1,158 +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.validation.ui.internal.dialog;
-
-
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IconAndMessageDialog;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-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.Shell;
-import org.eclipse.wst.validation.ValidationResult;
-import org.eclipse.wst.validation.internal.Misc;
-import org.eclipse.wst.validation.internal.ValManager;
-import org.eclipse.wst.validation.internal.ValPrefManagerGlobal;
-import org.eclipse.wst.validation.internal.model.GlobalPreferences;
-import org.eclipse.wst.validation.internal.ui.ValidationUIMessages;
-import org.eclipse.wst.validation.ui.internal.ValUIMessages;
-
-/**
- * A dialog for displaying the results of a manual validation.
- * @author karasiuk
- *
- */
-public class ResultsDialog extends IconAndMessageDialog {
-
- private ValidationResult _result;
- private long _time;
- private int _resourceCount;
- private Button _hideButton;
-
- /**
- * Create a dialog for displaying validation results.
- *
- * @param parentShell this can be null
- * @param results the results of the validation
- * @param time the time that the validation took in milliseconds
- * @param resourceCount the number of resources that were validated
- */
- public ResultsDialog(Shell parentShell, ValidationResult results, long time, int resourceCount) {
- super(parentShell);
- _result = results;
- _time = time;
- _resourceCount = resourceCount;
- }
-
- @Override
- protected void okPressed() {
- if(_hideButton!=null) {
- GlobalPreferences gp = ValManager.getDefault().getGlobalPreferences();
- gp.setConfirmDialog(!_hideButton.getSelection());
- ValPrefManagerGlobal.getDefault().savePreferences(gp);
- }
- super.okPressed();
- }
-
- @Override
- public int open() {
- if (!ErrorDialog.AUTOMATED_MODE) {
- return super.open();
- }
- setReturnCode(OK);
- return OK;
- }
-
- @Override
- protected Image getImage() {
- if (_result.getSeverityError() > 0)return getErrorImage();
- if (_result.getSeverityWarning() > 0)return getWarningImage();
- return getInfoImage();
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- message = getMessage();
- createMessageArea(parent);
-
- new Label(parent, SWT.NONE).setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create());
- addHideCheckbox(parent);
-
- Control c = super.createDialogArea(parent);
- return c;
- }
-
- private void addHideCheckbox(Composite parent) {
- _hideButton = new Button(parent, SWT.CHECK);
- GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).span(2, 1).applyTo(_hideButton);
- _hideButton.setText(ValUIMessages.DoNotShowResults);
- if (ValManager.getDefault().getGlobalPreferences().getConfirmDialog() && _hideButton.getSelection()) {
- // tell the user where to re-enable it?
- }
- _hideButton.setSelection(!ValManager.getDefault().getGlobalPreferences().getConfirmDialog());
- }
-
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(ValidationUIMessages.ValResults);
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- Button ok = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
- ok.setFocus();
- }
-
- private String getMessage(){
- if (_resourceCount > 1) {
- if (_result.getSeverityError() > 1)
- return NLS.bind(ValidationUIMessages.ValErrorsResources, new Object[]{_result.getSeverityError(), _resourceCount, Misc.getTimeMS(_time)});
- if (_result.getSeverityError() == 1)
- return NLS.bind(ValidationUIMessages.ValError1Resources, _resourceCount, Misc.getTimeMS(_time));
-
- if (_result.getSeverityWarning() > 1)
- return NLS.bind(ValidationUIMessages.ValWarnResources, new Object[]{_result.getSeverityWarning(), _resourceCount, Misc.getTimeMS(_time)});
- if (_result.getSeverityWarning() == 1)
- return NLS.bind(ValidationUIMessages.ValWarn1Resources, _resourceCount, Misc.getTimeMS(_time));
-
- if (_result.getSeverityInfo() > 1)
- return NLS.bind(ValidationUIMessages.ValInfoResources, new Object[]{_result.getSeverityInfo(), _resourceCount, Misc.getTimeMS(_time)});
- if (_result.getSeverityInfo() == 1)
- return NLS.bind(ValidationUIMessages.ValInfo1Resources, _resourceCount, Misc.getTimeMS(_time));
- }
- else if (_resourceCount == 1) {
- if (_result.getSeverityError() > 1)
- return NLS.bind(ValidationUIMessages.ValErrorsResource1, _result.getSeverityError(), Misc.getTimeMS(_time));
- if (_result.getSeverityError() == 1)
- return NLS.bind(ValidationUIMessages.ValError1Resource1, Misc.getTimeMS(_time));
-
- if (_result.getSeverityWarning() > 1)
- return NLS.bind(ValidationUIMessages.ValWarnResource1, _result.getSeverityWarning(), Misc.getTimeMS(_time));
- if (_result.getSeverityWarning() == 1)
- return NLS.bind(ValidationUIMessages.ValWarn1Resource1, Misc.getTimeMS(_time));
-
- if (_result.getSeverityInfo() > 1)
- return NLS.bind(ValidationUIMessages.ValInfoResource1, _result.getSeverityInfo(), Misc.getTimeMS(_time));
- if (_result.getSeverityInfo() == 1)
- return NLS.bind(ValidationUIMessages.ValInfo1Resource1, Misc.getTimeMS(_time));
- }
- return ValidationUIMessages.ValSuccess;
- }
-}
diff --git a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/preferences/ValidationPreferencePage.java b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/preferences/ValidationPreferencePage.java
deleted file mode 100644
index 0068b477c..000000000
--- a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/preferences/ValidationPreferencePage.java
+++ /dev/null
@@ -1,861 +0,0 @@
-package org.eclipse.wst.validation.ui.internal.preferences;
-
-/*******************************************************************************
- * 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
- *******************************************************************************/
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.MenuAdapter;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-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.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.validation.Validator;
-import org.eclipse.wst.validation.internal.ConfigurationManager;
-import org.eclipse.wst.validation.internal.FullBuildJob;
-import org.eclipse.wst.validation.internal.GlobalConfiguration;
-import org.eclipse.wst.validation.internal.ValManager;
-import org.eclipse.wst.validation.internal.ValPrefManagerGlobal;
-import org.eclipse.wst.validation.internal.ValidatorMetaData;
-import org.eclipse.wst.validation.internal.model.GlobalPreferences;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-import org.eclipse.wst.validation.internal.ui.DelegatingValidatorPreferencesDialog;
-import org.eclipse.wst.validation.internal.ui.plugin.ValidationUIPlugin;
-import org.eclipse.wst.validation.ui.internal.HelpContextIds;
-import org.eclipse.wst.validation.ui.internal.ImageNames;
-import org.eclipse.wst.validation.ui.internal.ValUIMessages;
-import org.eclipse.wst.validation.ui.internal.dialog.FilterDialog;
-
-/**
- * From this page the user can configure individual validators.
- * <p>
- * This class and its inner classes are not intended to be subclassed outside of
- * the validation framework.
- * </p>
- */
-public class ValidationPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
- private IValidationPage _pageImpl = null;
- private Shell _shell;
-
- public interface IValidationPage {
- Composite createPage(Composite parent) throws InvocationTargetException;
-
- boolean performOk() throws InvocationTargetException;
-
- boolean performDefaults() throws InvocationTargetException;
-
- Composite getControl();
-
- void dispose();
-
- void loseFocus();
-
- void gainFocus();
- }
-
- public class InvalidPage implements IValidationPage {
- private Composite page = null;
-
- private Composite composite = null;
- private GridLayout layout = null;
- private Label messageLabel = null;
-
- public InvalidPage(Composite parent) {
- page = createPage(parent);
- }
-
- /**
- * This page is added to the Properties guide if some internal problem
- * occurred; for example, the highlighted item in the workbench is not
- * an IProject (according to this page's plugin.xml, this page is only
- * valid when an IProject is selected).
- */
- public Composite createPage(Composite parent) {
- // Don't create the default and apply buttons.
- noDefaultAndApplyButton();
-
- final ScrolledComposite sc1 = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- sc1.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite = new Composite(sc1, SWT.NONE);
- sc1.setContent(composite);
- layout = new GridLayout();
- composite.setLayout(layout);
-
- messageLabel = new Label(composite, SWT.NONE);
- messageLabel.setText(ValUIMessages.VBF_EXC_INVALID_REGISTER);
-
- composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
-
- return composite;
- }
-
- public boolean performDefaults() {
- return true;
- }
-
- /**
- * Since this page occurs under invalid circumstances, there is nothing
- * to save.
- */
- public boolean performOk() {
- return true;
- }
-
- public Composite getControl() {
- return page;
- }
-
- public void dispose() {
- messageLabel.dispose();
- // layout.dispose();
- composite.dispose();
- }
-
- public void loseFocus() {
- // This page does not depend on the contents of any other page in
- // the wizard, so do nothing.
- }
-
- public void gainFocus() {
- // This page does not depend on the contents of any other page in
- // the wizard, so do nothing.
- }
- }
-
- private class ValidatorListPage implements IValidationPage {
- private Composite _page;
- private TableViewer _validatorList;
- private Button _enableAllButton;
- private Button _disableAllButton;
- private Button _override;
- private Button _suspend;
- private Button _autoSave;
- private Button _confirmButton;
- private Label _listLabel;
- private Table _validatorsTable;
- private GlobalPreferences _globalPreferences = ValManager.getDefault().getGlobalPreferences();
- private GlobalConfiguration _globalConfig;
- private Validator[] _validators;
-
- private int _changeCount;
-
- /**
- * This class is provided for the CheckboxTableViewer in the
- * ValidationPropertiesPage$ValidatorListPage class.
- */
- public class ValidationContentProvider implements IStructuredContentProvider {
- public void dispose() {
- }
-
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof Validator[]) {
- return (Validator[]) inputElement;
- }
- return new Object[0];
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- }
-
- /**
- * This class is provided for
- * ValidationPropertiesPage$ValidatorListPage's checkboxTableViewer element.
- */
- public class ValidationLabelProvider extends LabelProvider implements ITableLabelProvider {
- public String getText(Object element) {
- if (element == null)return ""; //$NON-NLS-1$
- else if (element instanceof Validator)
- return ((Validator) element).getName();
- else
- return super.getText(element);
- }
-
- private Image getImage(String imageName) {
- boolean isDisabled = !_validatorsTable.isEnabled();
- if (isDisabled)imageName = imageName + ImageNames.disabled;
-
- return ValidationUIPlugin.getPlugin().getImage(imageName);
- }
-
- public Image getColumnImage(Object element, int columnIndex) {
- Validator v = (Validator) element;
- if (columnIndex == 1) {
- return getImage(v.isManualValidation() ? ImageNames.okTable : ImageNames.failTable);
- } else if (columnIndex == 2) {
- return getImage(v.isBuildValidation() ? ImageNames.okTable : ImageNames.failTable);
- } else if (columnIndex == 3) {
- if (hasSettings(v))return getImage(ImageNames.settings);
- return null;
-
- }
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- if (columnIndex == 0)return ((Validator) element).getName();
- return null;
- }
- }
-
- /**
- * This class is used to sort the CheckboxTableViewer elements.
- */
- public class ValidationViewerSorter extends ViewerSorter {
- public int compare(Viewer viewer, Object e1, Object e2) {
- // Can't instantiate ViewerSorter because it's abstract, so use this
- // inner class to represent it.
- return super.compare(viewer, e1, e2);
- }
- }
-
- public ValidatorListPage(Composite parent) throws InvocationTargetException {
- _page = createPage(parent);
- }
-
- private void setupTableColumns(Table table) {
- TableColumn validatorColumn = new TableColumn(table, SWT.NONE);
- validatorColumn.setText(ValUIMessages.VALIDATOR);
- validatorColumn.setWidth(245);
- TableColumn manualColumn = new TableColumn(table, SWT.CENTER);
- manualColumn.setText(ValUIMessages.MANUAL);
- manualColumn.pack();
- TableColumn buildColumn = new TableColumn(table, SWT.CENTER);
- buildColumn.setText(ValUIMessages.BUILD);
- buildColumn.pack();
- TableColumn settingsColumn = new TableColumn(table, SWT.CENTER);
- settingsColumn.setText(ValUIMessages.SETTINGS);
- settingsColumn.pack();
- }
-
- public Composite createPage(Composite parent) throws InvocationTargetException {
- _globalConfig = new GlobalConfiguration(ConfigurationManager.getManager().getGlobalConfiguration());
- _validators = copyValidators(ValManager.getDefault().getValidators());
-
- Composite validatorGroup = new Composite(parent, SWT.NONE);
-
- GridLayout validatorGroupLayout = new GridLayout();
- validatorGroupLayout.numColumns = 2;
- validatorGroup.setLayout(validatorGroupLayout);
- GridDataFactory.fillDefaults().grab(true, true).applyTo(validatorGroup);
-
- new Label(validatorGroup, SWT.NONE).setLayoutData(new GridData());
-
- addOverride(validatorGroup);
- addSuspend(validatorGroup);
- addAutoSave(validatorGroup);
- addConfirm(validatorGroup);
-
- _listLabel = new Label(validatorGroup, SWT.NONE);
- GridData listLabelData = new GridData(GridData.FILL_HORIZONTAL);
- listLabelData.horizontalSpan = 2;
- _listLabel.setLayoutData(listLabelData);
- _listLabel.setText(ValUIMessages.PREF_VALLIST_TITLE);
-
- _validatorsTable = new Table(validatorGroup, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
- Point preferredSize = _validatorsTable.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- GridDataFactory.fillDefaults().grab(true, true).hint(preferredSize)
- .span(2,1).applyTo(_validatorsTable);
-
-
- _validatorsTable.setHeaderVisible(true);
- _validatorsTable.setLinesVisible(true);
-
- _validatorList = new TableViewer(_validatorsTable);
-// _validatorsTable.setLayoutData(validatorListData);
-// _validatorList.getTable().setLayoutData(validatorListData);
- _validatorList.setLabelProvider(new ValidationLabelProvider());
- _validatorList.setContentProvider(new ValidationContentProvider());
- _validatorList.setSorter(new ValidationViewerSorter());
- setupTableColumns(_validatorsTable);
-
- _validatorList.setInput(_validators);
- _validatorsTable.addMouseListener(new MouseAdapter() {
-
- public void mouseDown(MouseEvent e) {
- if (e.button != 1)return;
-
- TableItem tableItem = _validatorsTable.getItem(new Point(e.x, e.y));
- if (tableItem == null || tableItem.isDisposed())return;
- int columnNumber;
- int columnsCount = _validatorsTable.getColumnCount();
- if (columnsCount == 0) {
- // If no TableColumn, Table acts as if it has a single
- // column which takes the whole width.
- columnNumber = 0;
- } else {
- columnNumber = -1;
- for (int i = 0; i < columnsCount; i++) {
- Rectangle bounds = tableItem.getBounds(i);
- if (bounds.contains(e.x, e.y)) {
- columnNumber = i;
- break;
- }
- }
- if (columnNumber == -1)return;
- }
-
- columnClicked(columnNumber);
- }
- });
-
- _validatorsTable.setMenu(createContextMenu());
- _validatorsTable.addFocusListener(new FocusAdapter() {
-
- public void focusGained(FocusEvent e) {
- super.focusGained(e);
- if (_validatorsTable.getSelectionCount() == 0) {
- _validatorsTable.select(0);
- }
- }
- });
-
- addEnableDisable(validatorGroup);
-
- // Have to set the tab order or only the first checkbox in a
- // Composite can be tabbed to. (Seems to apply only to checkboxes. Have to use the
- // arrow key to navigate the checkboxes.)
- validatorGroup.setTabList(new Control[] { _suspend, _autoSave,
- _validatorsTable, _enableAllButton, _disableAllButton });
-
- updateWidgets();
-
- applyDialogFont(validatorGroup);
- validatorGroup.setSize(validatorGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- return validatorGroup;
- }
-
- private void addEnableDisable(Composite validatorGroup) {
- _enableAllButton = new Button(validatorGroup, SWT.PUSH);
- _enableAllButton.setLayoutData(new GridData());
- _enableAllButton.setText(ValUIMessages.PREF_BUTTON_ENABLEALL);
- _enableAllButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- try {
- performEnableAll();
- } catch (InvocationTargetException exc) {
- displayAndLogError(ValUIMessages.VBF_EXC_INTERNAL_TITLE,
- ValUIMessages.VBF_EXC_INTERNAL_PAGE, exc);
- }
- }
- });
-
- _disableAllButton = new Button(validatorGroup, SWT.PUSH);
- _disableAllButton.setLayoutData(new GridData());
- _disableAllButton.setText(ValUIMessages.PREF_BUTTON_DISABLEALL);
- _disableAllButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- try {
- performDisableAll();
- } catch (InvocationTargetException exc) {
- displayAndLogError(ValUIMessages.VBF_EXC_INTERNAL_TITLE,
- ValUIMessages.VBF_EXC_INTERNAL_PAGE, exc);
- }
- }
- });
- }
-
- /**
- * Make a copy of the current validators and store the results.
- */
- private Validator[] copyValidators(Validator[] vals){
- Validator[] copy = new Validator[vals.length];
- for (int i=0; i<vals.length; i++)copy[i] = vals[i].copy();
- return copy;
- }
-
- private void addConfirm(Composite validatorGroup) {
- GridData gd;
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- _confirmButton = new Button(validatorGroup, SWT.CHECK);
- _confirmButton.setLayoutData(gd);
- _confirmButton.setText(ValUIMessages.PrefPageConfirmDialog);
- _confirmButton.setSelection(_globalPreferences.getConfirmDialog());
- _confirmButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- // do not increment the _changeCount as this by itself should not trigger a build prompt
- _globalPreferences.setConfirmDialog(_confirmButton.getSelection());
- _confirmButton.setFocus();
- }
- });
- }
-
- private void addAutoSave(Composite validatorGroup) {
- GridData gd;
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- _autoSave = new Button(validatorGroup, SWT.CHECK);
- _autoSave.setLayoutData(gd);
- _autoSave.setText(ValUIMessages.PrefPage_always_save);
- _autoSave.setSelection(_globalPreferences.getSaveAutomatically());
- _autoSave.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- // do not increment the _changeCount as this by itself should not trigger a build prompt
- _globalPreferences.setSaveAutomatically(_autoSave.getSelection());
- _autoSave.setFocus();
- }
- });
- }
-
- private void addSuspend(Composite validatorGroup) {
- GridData gd;
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
-
- _suspend = new Button(validatorGroup, SWT.CHECK);
- _suspend.setLayoutData(gd);
- _suspend.setText(ValUIMessages.DISABLE_VALIDATION);
- _suspend.setSelection(_globalPreferences.getDisableAllValidation());
- _suspend.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- _changeCount++;
- _suspend.setFocus();
- _validatorsTable.setEnabled(!_suspend.getSelection());
- _enableAllButton.setEnabled(!_suspend.getSelection());
- _disableAllButton.setEnabled(!_suspend.getSelection());
- _validatorList.refresh();
- }
- });
- }
-
- private void addOverride(Composite validatorGroup) {
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
-
- _override = new Button(validatorGroup, SWT.CHECK);
- _override.setLayoutData(gd);
- _override.setText(ValUIMessages.PREF_BUTTON_OVERRIDE);
- _override.setEnabled(true);
- _override.setSelection(_globalPreferences.getOverride());
- _override.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- _changeCount++;
- _globalPreferences.setOverride(_override.getSelection());
- _override.setFocus();
-
- }
- });
- }
-
- protected Menu createContextMenu() {
- final Menu menu = new Menu(_validatorsTable.getShell(), SWT.POP_UP);
- final MenuItem manualItem = new MenuItem(menu, SWT.CHECK);
- manualItem.setText(ValUIMessages.PREF_MNU_MANUAL);
- final MenuItem buildItem = new MenuItem(menu, SWT.CHECK);
- buildItem.setText(ValUIMessages.PREF_MNU_BUILD);
- final MenuItem settingsItem = new MenuItem(menu, SWT.PUSH);
- settingsItem.setText(ValUIMessages.PREF_MNU_SETTINGS);
-
- class MenuItemListener extends SelectionAdapter {
- public void widgetSelected(SelectionEvent e) {
- MenuItem menuItem = (MenuItem) e.getSource();
- int index = menu.indexOf(menuItem) + 1;
- columnClicked(index);
- }
- }
- MenuItemListener listener = new MenuItemListener();
- manualItem.addSelectionListener(listener);
- buildItem.addSelectionListener(listener);
- settingsItem.addSelectionListener(listener);
-
- menu.addMenuListener(new MenuAdapter() {
- public void menuShown(MenuEvent e) {
- IStructuredSelection selection = (IStructuredSelection) _validatorList.getSelection();
- Validator vw = (Validator) selection.getFirstElement();
- manualItem.setSelection(vw.isManualValidation());
- buildItem.setSelection(vw.isBuildValidation());
- settingsItem.setEnabled(hasSettings(vw));
- }
- });
-
- return menu;
- }
-
- protected void columnClicked(int columnToEdit) {
- IStructuredSelection selection = (IStructuredSelection) _validatorList.getSelection();
- Validator val = (Validator) selection.getFirstElement();
-
- switch (columnToEdit) {
- case 1:
- _changeCount++;
- val.setManualValidation(!val.isManualValidation());
- break;
- case 2:
- _changeCount++;
- val.setBuildValidation(!val.isBuildValidation());
- break;
- case 3:
- Validator.V2 v2 = val.asV2Validator();
- if (v2 != null){
- FilterDialog fd = new FilterDialog(_shell, val, null);
- if (Window.OK == fd.open()){
- _changeCount++;
- val.become(fd.getValidator());
- }
- }
- else {
- handleOldDelegate(val);
- }
-
- break;
- default:
- break;
- }
- _validatorList.refresh();
- }
-
- private void handleOldDelegate(Validator val) {
- Validator.V1 v1 = val.asV1Validator();
- if (v1 == null)return;
-
- ValidatorMetaData vmd = v1.getVmd();
- if (!vmd.isDelegating())return;
-
- String delegateID = _globalConfig.getDelegateUniqueName(vmd);
- Shell shell = Display.getCurrent().getActiveShell();
- DelegatingValidatorPreferencesDialog dialog =
- new DelegatingValidatorPreferencesDialog(shell, vmd, delegateID);
-
- dialog.setBlockOnOpen(true);
- dialog.create();
-
- int result = dialog.open();
- if (result == Window.OK){
- _changeCount++;
- _globalConfig.setDelegateUniqueName(vmd, dialog.getDelegateID());
- }
- }
-
- /**
- * Does this validator have extra settings that can be configured?
- * @param v
- * @return true if it does
- */
- boolean hasSettings(Validator v){
- if (v.asV2Validator() != null)return true;
- if (v.getDelegatingId() != null)return true;
- return false;
- }
-
- protected void updateWidgets() throws InvocationTargetException {
- // Need to update even the widgets that do not change based on another
- // widgets because of performDefaults(). If performDefaults() is
- // selected, then the pagePreferences values are reset, and these widgets
- // might also need to be updated.
- updateAllWidgets();
- updateHelp();
- }
-
- private void updateAllWidgets() throws InvocationTargetException {
- _suspend.setSelection(_globalPreferences.getDisableAllValidation());
- _autoSave.setSelection(_globalPreferences.getSaveAutomatically());
- _confirmButton.setSelection(_globalPreferences.getConfirmDialog());
- _override.setSelection(_globalPreferences.getOverride());
- _validatorsTable.setEnabled(!_suspend.getSelection());
- _enableAllButton.setEnabled(!_suspend.getSelection());
- _disableAllButton.setEnabled(!_suspend.getSelection());
- _validatorList.setInput(_validators);
- _validatorList.refresh();
- }
-
- public boolean performOk() throws InvocationTargetException {
- _globalPreferences.setDisableAllValidation(_suspend.getSelection());
- _globalPreferences.setSaveAutomatically(_autoSave.getSelection());
- ValPrefManagerGlobal vpm = ValPrefManagerGlobal.getDefault();
- vpm.savePreferences(_globalPreferences, _validators);
- saveV1Preferences();
-
- if (_changeCount > 0 &&
- MessageDialog.openQuestion(_shell, ValUIMessages.RebuildTitle, ValUIMessages.RebuildMsg)){
-
- FullBuildJob fbj = new FullBuildJob();
- try {
- fbj.runInWorkspace(new NullProgressMonitor());
- }
- catch (CoreException e){
- ValidationPlugin.getPlugin().handleException(e);
- }
- }
- return true;
- }
-
- /**
- * Save the V1 preferences, so that the old validators continue to work.
- */
- private void saveV1Preferences(){
- try {
- GlobalConfiguration gc = ConfigurationManager.getManager().getGlobalConfiguration();
- // gc.setCanProjectsOverride(overrideButton.getSelection());
-
- if (_globalPreferences.getDisableAllValidation())gc.setDisableAllValidation(true);
- //pagePreferences.setEnabledValidators(getEnabledValidators());
-
- gc.setEnabledManualValidators(getEnabledManualValidators());
- gc.setEnabledBuildValidators(getEnabledBuildValidators());
-
- gc.passivate();
- gc.store();
- }
- catch (InvocationTargetException e){
- ValidationUIPlugin.getPlugin().handleException(e);
- }
-
- }
-
- /**
- * Answer all the V1 validators that are manually enabled.
- * @return
- */
- private ValidatorMetaData[] getEnabledManualValidators() {
- List<ValidatorMetaData> list = new LinkedList<ValidatorMetaData>();
- for (Validator v : _validators){
- if (v.isManualValidation()){
- Validator.V1 v1 = v.asV1Validator();
- if (v1 != null){
- list.add(v1.getVmd());
- }
- }
- }
- ValidatorMetaData[] result = new ValidatorMetaData[list.size()];
- list.toArray(result);
- return result;
- }
-
- /**
- * Answer all the V1 validators that are enabled for build.
- * @return
- */
- private ValidatorMetaData[] getEnabledBuildValidators() {
- List<ValidatorMetaData> list = new LinkedList<ValidatorMetaData>();
- for (Validator v : _validators){
- if (v.isBuildValidation()){
- Validator.V1 v1 = v.asV1Validator();
- if (v1 != null)list.add(v1.getVmd());
- }
- }
- ValidatorMetaData[] result = new ValidatorMetaData[list.size()];
- list.toArray(result);
- return result;
- }
-
- public boolean performDefaults() throws InvocationTargetException {
- _changeCount++;
- _validators = copyValidators(ValManager.getDefaultValidators());
- updateWidgets();
- getDefaultsButton().setFocus();
- return true;
- }
-
- public boolean performEnableAll() throws InvocationTargetException {
- setAllValidators(true);
- _enableAllButton.setFocus();
- _validatorList.refresh();
- return true;
- }
-
- public boolean performDisableAll() throws InvocationTargetException {
- setAllValidators(false);
- _disableAllButton.setFocus();
- _validatorList.refresh();
- return true;
- }
-
- private void setAllValidators(boolean bool){
- _changeCount++;
- for (Validator v : _validators){
- v.setBuildValidation(bool);
- v.setManualValidation(bool);
- }
- }
-
- protected void updateHelp() {
-// PlatformUI.getWorkbench().getHelpSystem().setHelp(_suspend, ContextIds.VALIDATION_PREFERENCE_PAGE_DISABLE_ALL_ENABLED);
- }
-
- /*
- * Store the current values of the controls into the preference store.
- */
-
- public Composite getControl() {
- return _page;
- }
-
- public void dispose() {
- _autoSave.dispose();
- _suspend.dispose();
- _disableAllButton.dispose();
- _enableAllButton.dispose();
- _listLabel.dispose();
- _suspend.dispose();
- _validatorList.getTable().dispose();
- }
-
- public void loseFocus() {
- }
-
- public void gainFocus() {
- }
- }
-
- /*
- * @see PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HelpContextIds.PreferencePage);
- try {
- _shell = parent.getShell();
- _pageImpl = new ValidatorListPage(parent);
- } catch (Exception exc) {
- _pageImpl = new InvalidPage(parent);
- displayAndLogError(ValUIMessages.VBF_EXC_INTERNAL_TITLE, ValUIMessages.VBF_EXC_INTERNAL_PAGE, exc);
- }
-
- return _pageImpl.getControl();
- }
-
- public void init(IWorkbench workbench) {
- }
-
- /**
- * Performs special processing when this page's Defaults button has been
- * pressed.
- * <p>
- * This is a framework hook method for subclasses to do special things when
- * the Defaults button has been pressed. Subclasses may override, but should
- * call <code>super.performDefaults</code>.
- * </p>
- */
- protected void performDefaults() {
- super.performDefaults();
-
- try {
- _pageImpl.performDefaults();
- } catch (Exception exc) {
- displayAndLogError(ValUIMessages.VBF_EXC_INTERNAL_TITLE, ValUIMessages.VBF_EXC_INTERNAL_PAGE, exc);
- }
- }
-
- /**
- * When the user presses the "OK" or "Apply" button on the Properties
- * Guide/Properties Page, respectively, some processing is performed by this
- * PropertyPage. If the page is found, and completes successfully, true is
- * returned. Otherwise, false is returned, and the guide doesn't finish.
- */
- public boolean performOk() {
- try {
- return _pageImpl.performOk();
- }
- catch (Exception exc) {
- displayAndLogError(ValUIMessages.VBF_EXC_INTERNAL_TITLE, ValUIMessages.VBF_EXC_INTERNAL_PAGE, exc);
- return false;
- }
- }
-
- /**
- * Since the pages are inner classes of a child PreferencePage, not a
- * PreferencePage itself, DialogPage's automatic disposal of its children's
- * widgets cannot be used. Instead, dispose of each inner class' widgets
- * explicitly.
- */
- public void dispose() {
- super.dispose();
- try {
- if (_pageImpl != null) {
- _pageImpl.dispose();
- _pageImpl = null;
- }
-
- // TODO figure out what this thing did
- // ExtensionManger.instance().getDelegate().disposePreferencePage();
- } catch (Exception exc) {
- displayAndLogError(ValUIMessages.VBF_EXC_INTERNAL_TITLE, ValUIMessages.VBF_EXC_INTERNAL_PAGE, exc);
- }
- }
-
- private void logError(Throwable exc) {
- ValidationUIPlugin.getPlugin().handleException(exc);
- }
-
- /*
- * package visibility because if this method is private, then the compiler
- * needs to create a synthetic accessor method for the internal classes, and
- * that can have performance implications.
- */
- void displayAndLogError(String title, String message, Throwable exc) {
- logError(exc);
- displayMessage(title, message, org.eclipse.swt.SWT.ICON_ERROR);
- }
-
- private void displayMessage(String title, String message, int iIconType) {
- MessageBox messageBox = new MessageBox(getShell(),
- org.eclipse.swt.SWT.OK | iIconType | org.eclipse.swt.SWT.APPLICATION_MODAL);
- messageBox.setMessage(message);
- messageBox.setText(title);
- messageBox.open();
- }
-
- /**
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
-
- if (_pageImpl == null)return;
- if (visible)_pageImpl.gainFocus();
- else _pageImpl.loseFocus();
- }
-
- protected Button getDefaultsButton() {
- return super.getDefaultsButton();
- }
-}
diff --git a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/preferences/ValidationPropertyPage.java b/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/preferences/ValidationPropertyPage.java
deleted file mode 100644
index ef8dabd38..000000000
--- a/plugins/org.eclipse.wst.validation.ui/vf2/org/eclipse/wst/validation/ui/internal/preferences/ValidationPropertyPage.java
+++ /dev/null
@@ -1,854 +0,0 @@
-package org.eclipse.wst.validation.ui.internal.preferences;
-
-/*******************************************************************************
- * 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
- *******************************************************************************/
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.MenuAdapter;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.wst.validation.Validator;
-import org.eclipse.wst.validation.internal.ConfigurationManager;
-import org.eclipse.wst.validation.internal.GlobalConfiguration;
-import org.eclipse.wst.validation.internal.ProjectConfiguration;
-import org.eclipse.wst.validation.internal.ValManager;
-import org.eclipse.wst.validation.internal.ValPrefManagerProject;
-import org.eclipse.wst.validation.internal.ValidatorMetaData;
-import org.eclipse.wst.validation.internal.model.ProjectPreferences;
-import org.eclipse.wst.validation.internal.operations.ValidatorManager;
-import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
-import org.eclipse.wst.validation.internal.ui.DelegatingValidatorPreferencesDialog;
-import org.eclipse.wst.validation.internal.ui.plugin.ValidationUIPlugin;
-import org.eclipse.wst.validation.ui.internal.HelpContextIds;
-import org.eclipse.wst.validation.ui.internal.ImageNames;
-import org.eclipse.wst.validation.ui.internal.ValUIMessages;
-import org.eclipse.wst.validation.ui.internal.dialog.FilterDialog;
-
-/**
- * From this page the user can configure individual validators on individual projects.
- *
- * @author karasiuk
- */
-public class ValidationPropertyPage extends PropertyPage {
-
- private IValidationPage _pageImpl;
- private Shell _shell;
-
- public interface IValidationPage {
- Composite createPage(Composite parent) throws InvocationTargetException;
-
- boolean performOk() throws InvocationTargetException;
-
- boolean performDefaults() throws InvocationTargetException;
-
- Composite getControl();
-
- void dispose();
-
- void loseFocus();
-
- void gainFocus();
- }
-
- public class InvalidPage implements IValidationPage {
- private Composite page = null;
-
- private Composite composite = null;
- private GridLayout layout = null;
- private Label messageLabel = null;
-
- public InvalidPage(Composite parent) {
- page = createPage(parent);
- }
-
- /**
- * This page is added to the Properties guide if some internal problem
- * occurred; for example, the highlighted item in the workbench is not
- * an IProject (according to this page's plugin.xml, this page is only
- * valid when an IProject is selected).
- */
- public Composite createPage(Composite parent) {
- noDefaultAndApplyButton();
-
- final ScrolledComposite sc1 = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- sc1.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite = new Composite(sc1, SWT.NONE);
- sc1.setContent(composite);
- layout = new GridLayout();
- composite.setLayout(layout);
-
- messageLabel = new Label(composite, SWT.NONE);
- messageLabel.setText(ValUIMessages.VBF_EXC_INVALID_REGISTER);
-
- composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
-
- return composite;
- }
-
- public boolean performDefaults() {
- return true;
- }
-
- /**
- * Since this page occurs under invalid circumstances, there is nothing
- * to save.
- */
- public boolean performOk() {
- return true;
- }
-
- public Composite getControl() {
- return page;
- }
-
- public void dispose() {
- messageLabel.dispose();
- // layout.dispose();
- composite.dispose();
- }
-
- public void loseFocus() {
- }
-
- public void gainFocus() {
- }
- }
-
- private class ValidatorListPage implements IValidationPage {
- private Composite _page;
-
- private TableViewer _validatorList;
- private Button _enableAllButton;
- private Button _disableAllButton;
- private Button _override;
- private Button _suspend;
- private Link _configLink;
- private Button _addValidationBuilder;
- private Table _validatorsTable;
- private Validator[] _validators;
-
- /**
- * This class is provided for the CheckboxTableViewer in the
- * ValidationPropertiesPage$ValidatorListPage class.
- */
- public class ValidationContentProvider implements IStructuredContentProvider {
- public void dispose() {
- }
-
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof Validator[]) {
- return (Validator[]) inputElement;
- }
- return new Object[0];
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- }
-
- /**
- * This class is provided for
- * ValidationPropertiesPage$ValidatorListPage's checkboxTableViewer
- * element.
- */
- public class ValidationLabelProvider extends LabelProvider implements ITableLabelProvider {
- public String getText(Object element) {
- if (element == null)return ""; //$NON-NLS-1$
- else if (element instanceof Validator)
- return ((Validator) element).getName();
- else
- return super.getText(element);
- }
-
- private Image getImage(String imageName) {
- boolean isDisabled = !_validatorsTable.isEnabled();
- if (isDisabled)
- imageName = imageName + ImageNames.disabled;
-
- return ValidationUIPlugin.getPlugin().getImage(imageName);
- }
-
- public Image getColumnImage(Object element, int columnIndex) {
- Validator v = (Validator) element;
- if (columnIndex == 1) {
- return getImage(v.isManualValidation() ? ImageNames.okTable
- : ImageNames.failTable);
- } else if (columnIndex == 2) {
- return getImage(v.isBuildValidation() ? ImageNames.okTable
- : ImageNames.failTable);
- } else if (columnIndex == 3) {
- if (hasSettings(v))return getImage(ImageNames.settings);
- return null;
- }
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- if (columnIndex == 0)return ((Validator) element).getName();
- return null;
- }
- }
-
- public ValidatorListPage(Composite parent) throws InvocationTargetException {
- _page = createPage(parent);
- }
-
- private void setupTableColumns(Table table) {
- TableColumn validatorColumn = new TableColumn(table, SWT.NONE);
- validatorColumn.setText(ValUIMessages.VALIDATOR);
- validatorColumn.setWidth(245);
- TableColumn manualColumn = new TableColumn(table, SWT.CENTER);
- manualColumn.setText(ValUIMessages.MANUAL);
- manualColumn.pack();
- TableColumn buildColumn = new TableColumn(table, SWT.CENTER);
- buildColumn.setText(ValUIMessages.BUILD);
- buildColumn.pack();
- TableColumn settingsColumn = new TableColumn(table, SWT.CENTER);
- settingsColumn.setText(ValUIMessages.SETTINGS);
- settingsColumn.pack();
- }
-
- public Composite createPage(Composite parent) throws InvocationTargetException {
- _validators = copyValidators(ValManager.getDefault().getValidators(getProject(), false));
-
- Composite validatorGroup = new Composite(parent, SWT.NONE);
-
- GridLayout validatorGroupLayout = new GridLayout();
- validatorGroupLayout.numColumns = 2;
- validatorGroup.setLayout(validatorGroupLayout);
- GridDataFactory.fillDefaults().grab(true, true).applyTo(validatorGroup);
-
- addOverride(validatorGroup);
- addConfigLink(validatorGroup);
- addSuspend(validatorGroup);
- addValidationBuilder(validatorGroup);
- new Label(validatorGroup, SWT.NONE).setLayoutData(new GridData());
-
- Label listLabel = new Label(validatorGroup, SWT.NONE);
- GridData listLabelData = new GridData(GridData.FILL_HORIZONTAL);
- listLabelData.horizontalSpan = 2;
- listLabel.setLayoutData(listLabelData);
- listLabel.setText(ValUIMessages.PREF_VALLIST_TITLE);
-
- _validatorsTable = new Table(validatorGroup, SWT.BORDER | SWT.FULL_SELECTION);
- Point preferredSize = _validatorsTable.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- GridDataFactory.fillDefaults().grab(true, true).hint(preferredSize)
- .span(2,1).applyTo(_validatorsTable);
-
- _validatorsTable.setHeaderVisible(true);
- _validatorsTable.setLinesVisible(true);
-
- _validatorList = new TableViewer(_validatorsTable);
- _validatorList.setLabelProvider(new ValidationLabelProvider());
- _validatorList.setContentProvider(new ValidationContentProvider());
- _validatorList.setSorter(new ViewerSorter());
- setupTableColumns(_validatorsTable);
-
- _validatorList.setInput(_validators);
- _validatorsTable.addMouseListener(new MouseAdapter() {
-
- public void mouseDown(MouseEvent e) {
- if (e.button != 1)return;
-
- TableItem tableItem = _validatorsTable.getItem(new Point(e.x, e.y));
- if (tableItem == null || tableItem.isDisposed()) {
- // item no longer exists
- return;
- }
- int columnNumber;
- int columnsCount = _validatorsTable.getColumnCount();
- if (columnsCount == 0) {
- // If no TableColumn, Table acts as if it has a single column
- // which takes the whole width.
- columnNumber = 0;
- } else {
- columnNumber = -1;
- for (int i = 0; i < columnsCount; i++) {
- Rectangle bounds = tableItem.getBounds(i);
- if (bounds.contains(e.x, e.y)) {
- columnNumber = i;
- break;
- }
- }
- if (columnNumber == -1)return;
- }
-
- columnClicked(columnNumber);
- }
- });
-
- _validatorsTable.setMenu(createContextMenu());
- _validatorsTable.addFocusListener(new FocusAdapter() {
-
- public void focusGained(FocusEvent e) {
- super.focusGained(e);
- if (_validatorsTable.getSelectionCount() == 0) {
- _validatorsTable.select(0);
- }
- }
- });
-
- addButtons(validatorGroup);
-
- // Have to set the tab order or only the first checkbox in a
- // Composite can be tabbed to. (Seems to apply only to checkboxes. Have to use the
- // arrow key to navigate the checkboxes.)
- validatorGroup.setTabList(new Control[] { _override, _suspend});
-
- updateWidgets();
-
- applyDialogFont(validatorGroup);
- validatorGroup.setSize(validatorGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));
-
- return validatorGroup;
- }
-
- private void addButtons(Composite validatorGroup) {
-
- Composite buttons = new Composite(validatorGroup, SWT.NONE);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- buttons.setLayout(new RowLayout());
-
- _enableAllButton = new Button(buttons, SWT.PUSH);
- _enableAllButton.setText(ValUIMessages.PREF_BUTTON_ENABLEALL);
- _enableAllButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- try {
- performEnableAll();
- } catch (InvocationTargetException exc) {
- displayAndLogError(ValUIMessages.VBF_EXC_INTERNAL_TITLE,ValUIMessages.VBF_EXC_INTERNAL_PAGE, exc);
- }
- }
- });
-
- _disableAllButton = new Button(buttons, SWT.PUSH);
- _disableAllButton.setText(ValUIMessages.PREF_BUTTON_DISABLEALL);
- _disableAllButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- try {
- performDisableAll();
- } catch (InvocationTargetException exc) {
- displayAndLogError(ValUIMessages.VBF_EXC_INTERNAL_TITLE, ValUIMessages.VBF_EXC_INTERNAL_PAGE, exc);
- }
- }
- });
- }
-
- private void addSuspend(Composite validatorGroup) {
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- _suspend = new Button(validatorGroup, SWT.CHECK);
- _suspend.setLayoutData(gd);
- _suspend.setText(ValUIMessages.DISABLE_VALIDATION);
- _suspend.setSelection(getProjectPreferences().getSuspend());
- _suspend.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- _suspend.setFocus();
- enableDisableWidgets();
- _validatorList.refresh();
- }
- });
- }
-
- private void addConfigLink(Composite validatorGroup){
- _configLink = new Link(validatorGroup,SWT.None);
- GridData layout = new GridData(GridData.HORIZONTAL_ALIGN_END);
- _configLink.setLayoutData(layout);
- _configLink.setText("<A>"+ //$NON-NLS-1$
- ValUIMessages.ConfigWsSettings+"</A>"); //$NON-NLS-1$
- _configLink.addSelectionListener(new SelectionListener() {
- public static final String DATA_NO_LINK = "PropertyAndPreferencePage.nolink"; //$NON-NLS-1$
-
- public void doLinkActivated(Link e) {
- String id = getPreferencePageID();
- PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[]{id}, DATA_NO_LINK).open();
- try {
- updateWidgets();
- } catch (InvocationTargetException ie) {
-
- }
- }
-
- private String getPreferencePageID() {
- return "ValidationPreferencePage"; //$NON-NLS-1$
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- doLinkActivated((Link) e.widget);
- }
-
- public void widgetSelected(SelectionEvent e) {
- doLinkActivated((Link) e.widget);
- }
- });
-
- }
-
- /**
- * If the current project doesn't have the validation builder configured on it,
- * and the user has asked us to add a builder, add the builder.
- * Otherwise return without doing anything.
- */
- private void addBuilder() {
- if (_addValidationBuilder != null && _addValidationBuilder.getSelection())
- ValidatorManager.addProjectBuildValidationSupport(getProject());
- }
-
-
- private void addValidationBuilder(Composite validatorGroup) {
- if (hasValidationBuilder())return;
-
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- _addValidationBuilder = new Button(validatorGroup, SWT.CHECK);
- _addValidationBuilder.setLayoutData(gd);
- _addValidationBuilder.setText(ValUIMessages.ADD_VALIDATION_BUILDER);
- _addValidationBuilder.setSelection(false);
- }
-
- /**
- * Make a copy of the current validators and store the results.
- */
- private Validator[] copyValidators(Validator[] vals){
- Validator[] validators = new Validator[vals.length];
- for (int i=0; i<vals.length; i++)validators[i] = vals[i].copy();
- return validators;
- }
-
- /**
- * Does this validator have extra settings that can be configured?
- * @param v
- * @return true if it does
- */
- boolean hasSettings(Validator v){
- if (v.asV2Validator() != null)return true;
- if (v.getDelegatingId() != null)return true;
- return false;
- }
-
- /**
- * Answer if this project has a validator builder assigned to it.
- */
- private boolean hasValidationBuilder(){
- try {
- IProjectDescription description = getProject().getDescription();
- ICommand[] commands = description.getBuildSpec();
- for (int i = 0; i < commands.length; i++) {
- if (commands[i].getBuilderName().equals(ValidationPlugin.VALIDATION_BUILDER_ID))
- return true;
- }
- return false;
- }
- catch (CoreException e){
- ValidationPlugin.getPlugin().handleException(e);
- }
- return false;
- }
-
-
- private void addOverride(Composite validatorGroup) {
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-// gd.horizontalSpan = 2;
- _override = new Button(validatorGroup, SWT.CHECK);
- _override.setLayoutData(gd);
- _override.setText(ValUIMessages.LabelEnableProjectSpecific);
- _override.setSelection(getProjectPreferences().getOverride());
- _override.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- _override.setFocus();
- if (ValManager.getDefault().getGlobalPreferences().getOverride()){
- enableDisableWidgets();
- _validatorList.refresh();
- }
- else {
- MessageDialog.openWarning(_shell, ValUIMessages.Validation,
- ValUIMessages.ProjectOverridesNotAllowed);
- }
- }
-
- });
- }
-
- protected Menu createContextMenu() {
- final Menu menu = new Menu(_validatorsTable.getShell(), SWT.POP_UP);
- final MenuItem manualItem = new MenuItem(menu, SWT.CHECK);
- manualItem.setText(ValUIMessages.PREF_MNU_MANUAL);
- final MenuItem buildItem = new MenuItem(menu, SWT.CHECK);
- buildItem.setText(ValUIMessages.PREF_MNU_BUILD);
- final MenuItem settingsItem = new MenuItem(menu, SWT.PUSH);
- settingsItem.setText(ValUIMessages.PREF_MNU_SETTINGS);
-
- class MenuItemListener extends SelectionAdapter {
- public void widgetSelected(SelectionEvent e) {
- MenuItem menuItem = (MenuItem) e.getSource();
- int index = menu.indexOf(menuItem) + 1;
- columnClicked(index);
- }
- }
- MenuItemListener listener = new MenuItemListener();
- manualItem.addSelectionListener(listener);
- buildItem.addSelectionListener(listener);
- settingsItem.addSelectionListener(listener);
-
- menu.addMenuListener(new MenuAdapter() {
- public void menuShown(MenuEvent e) {
- IStructuredSelection selection = (IStructuredSelection) _validatorList.getSelection();
- Validator val = (Validator) selection.getFirstElement();
- manualItem.setSelection(val.isManualValidation());
- buildItem.setSelection(val.isBuildValidation());
- settingsItem.setEnabled(hasSettings(val));
- }
- });
-
- return menu;
- }
-
- protected void columnClicked(int columnToEdit) {
- IStructuredSelection selection = (IStructuredSelection) _validatorList.getSelection();
- Validator val = (Validator) selection.getFirstElement();
-
- switch (columnToEdit) {
- case 1:
- val.setManualValidation(!val.isManualValidation());
- break;
- case 2:
- val.setBuildValidation(!val.isBuildValidation());
- break;
- case 3:
- Validator.V2 v2 = val.asV2Validator();
- if (v2 != null){
- FilterDialog fd = new FilterDialog(_shell, val, getProject());
- if (Window.OK == fd.open()){
- val.become(fd.getValidator());
- }
- }
- else {
- handleOldDelegate(val);
- }
-
- break;
- default:
- break;
- }
- _validatorList.refresh();
- }
-
- private void handleOldDelegate(Validator val) {
- try {
- Validator.V1 v1 = val.asV1Validator();
- if (v1 == null)return;
-
- ValidatorMetaData vmd = v1.getVmd();
- if (!vmd.isDelegating())return;
-
- GlobalConfiguration gc = ConfigurationManager.getManager().getGlobalConfiguration();
- String delegateID = gc.getDelegateUniqueName(vmd);
- Shell shell = Display.getCurrent().getActiveShell();
- DelegatingValidatorPreferencesDialog dialog =
- new DelegatingValidatorPreferencesDialog(shell, vmd, delegateID);
-
- dialog.setBlockOnOpen(true);
- dialog.create();
-
- int result = dialog.open();
- if (result == Window.OK)gc.setDelegateUniqueName(vmd, dialog.getDelegateID());
- }
- catch (InvocationTargetException e){
-
- }
- }
-
- protected void updateWidgets() throws InvocationTargetException {
- // Need to update even the widgets that do not change based on another
- // widgets because of performDefaults(). If performDefaults() is selected,
- // then the pagePreferences values are reset, and these widgets
- // might also need to be updated.
- updateAllWidgets();
- updateHelp();
- }
-
- protected void updateWidgetsForDefaults() throws InvocationTargetException {
- updateAllWidgets();
- updateHelp();
- }
-
- private void updateAllWidgets() throws InvocationTargetException {
- _suspend.setSelection(getProjectPreferences().getSuspend());
- _override.setSelection(getProjectPreferences().getOverride());
- enableDisableWidgets();
- _validatorList.setInput(_validators);
- _validatorList.refresh();
- }
-
- public boolean performOk() throws InvocationTargetException {
-
- addBuilder();
- // [213631] this warning should only be shown if the user actually tried to override
- // the validators
- if (!ValManager.getDefault().getGlobalPreferences().getOverride() && _override.getSelection()){
- MessageDialog.openWarning(_shell, ValUIMessages.Validation,
- ValUIMessages.ProjectOverridesNotAllowed);
- return false;
- }
- updateV1ProjectSettings();
- getProjectPreferences().setSuspend(_suspend.getSelection());
- getProjectPreferences().setOverride(_override.getSelection());
- IProject project = getProject();
- ValPrefManagerProject vpm = new ValPrefManagerProject(project);
- vpm.savePreferences(getProjectPreferences(), _validators);
- return true;
- }
-
- /**
- * Update the version 1 project settings.
- */
- private void updateV1ProjectSettings() {
- try {
- ProjectConfiguration pc = ConfigurationManager.getManager().getProjectConfiguration(getProject());
- pc.setDoesProjectOverride(_override.getSelection());
- pc.setDisableAllValidation(_suspend.getSelection());
- }
- catch (InvocationTargetException e){
- ValidationPlugin.getPlugin().handleException(e);
- }
- }
-
- /**
- * Answer the specific project preferences. If the project didn't have any specific project
- * preferences, then create a default set.
- * @return
- */
- private ProjectPreferences getProjectPreferences(){
- return ValManager.getDefault().getProjectPreferences(getProject());
- }
-
- public boolean performDefaults() throws InvocationTargetException {
- _validators = copyValidators(ValManager.getDefaultValidators(getProject()));
- updateWidgetsForDefaults();
- getDefaultsButton().setFocus();
- return true;
- }
-
- public boolean performEnableAll() throws InvocationTargetException {
- setAllValidators(true);
- _enableAllButton.setFocus();
- _validatorList.refresh();
- return true;
- }
-
- private void setAllValidators(boolean bool) {
- for (TableItem item : _validatorsTable.getItems()) {
- Validator val = (Validator) item.getData();
- val.setManualValidation(bool);
- val.setBuildValidation(bool);
- }
- }
-
- public boolean performDisableAll() throws InvocationTargetException {
- setAllValidators(false);
- _disableAllButton.setFocus();
- _validatorList.refresh();
- return true;
- }
-
- protected void updateHelp() {
-// PlatformUI.getWorkbench().getHelpSystem().setHelp(_suspend, ContextIds.VALIDATION_PREFERENCE_PAGE_DISABLE_ALL_ENABLED);
- }
-
- /*
- * Store the current values of the controls into the preference store.
- */
-
- public Composite getControl() {
- return _page;
- }
-
- public void dispose() {
- _override.dispose();
- _suspend.dispose();
- _configLink.dispose();
- _disableAllButton.dispose();
- _enableAllButton.dispose();
- _validatorList.getTable().dispose();
- }
-
- /**
- * Enable or disable the widgets based on some top level preferences.
- */
- private void enableDisableWidgets() {
- boolean globalOverride = ValManager.getDefault().getGlobalPreferences().getOverride();
- boolean enable = !_suspend.getSelection() & _override.getSelection() & globalOverride;
- _suspend.setEnabled(_override.getSelection() & globalOverride);
- _validatorsTable.setEnabled(enable);
- _enableAllButton.setEnabled(enable);
- _disableAllButton.setEnabled(enable);
- _configLink.setEnabled(!globalOverride || !_override.getSelection());
- }
-
- public void loseFocus() {
- // This page does not need to cache anything before it loses focus.
- }
-
- public void gainFocus() {
- }
- }
-
- protected Control createContents(Composite parent) {
- try {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HelpContextIds.ProjectPage);
- _shell = parent.getShell();
- _pageImpl = new ValidatorListPage(parent);
- } catch (Exception exc) {
- _pageImpl = new InvalidPage(parent);
- displayAndLogError(ValUIMessages.VBF_EXC_INTERNAL_TITLE, ValUIMessages.VBF_EXC_INTERNAL_PAGE, exc);
- }
-
- return _pageImpl.getControl();
- }
-
- protected void performDefaults() {
- super.performDefaults();
-
- try {
- _pageImpl.performDefaults();
- } catch (Exception exc) {
- displayAndLogError(ValUIMessages.VBF_EXC_INTERNAL_TITLE, ValUIMessages.VBF_EXC_INTERNAL_PAGE, exc);
- }
- }
-
- public boolean performOk() {
- try {
- return _pageImpl.performOk();
- } catch (Exception exc) {
- displayAndLogError(ValUIMessages.VBF_EXC_INTERNAL_TITLE, ValUIMessages.VBF_EXC_INTERNAL_PAGE, exc);
- return false;
- }
- }
-
- /**
- * Since the pages are inner classes of a child PreferencePage, not a
- * PreferencePage itself, DialogPage's automatic disposal of its children's
- * widgets cannot be used. Instead, dispose of each inner class' widgets
- * explicitly.
- */
- public void dispose() {
- super.dispose();
- try {
- if (_pageImpl != null) {
- _pageImpl.dispose();
- _pageImpl = null;
- }
- } catch (Exception exc) {
- displayAndLogError(ValUIMessages.VBF_EXC_INTERNAL_TITLE, ValUIMessages.VBF_EXC_INTERNAL_PAGE, exc);
- }
- }
-
- private void logError(Throwable exc) {
- ValidationUIPlugin.getPlugin().handleException(exc);
- }
-
- /*
- * package visibility because if this method is private, then the compiler
- * needs to create a synthetic accessor method for the internal classes, and
- * that can have performance implications.
- */
- void displayAndLogError(String title, String message, Throwable exc) {
- logError(exc);
- displayMessage(title, message, org.eclipse.swt.SWT.ICON_ERROR);
- }
-
- private void displayMessage(String title, String message, int iIconType) {
- MessageBox messageBox = new MessageBox(getShell(),
- org.eclipse.swt.SWT.OK | iIconType | org.eclipse.swt.SWT.APPLICATION_MODAL);
- messageBox.setMessage(message);
- messageBox.setText(title);
- messageBox.open();
- }
-
- /**
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- super.setVisible(visible);
-
- if (_pageImpl == null)return;
- if (visible)_pageImpl.gainFocus();
- else _pageImpl.loseFocus();
- }
-
- /**
- * @see org.eclipse.jface.preference.PreferencePage#getDefaultsButton()
- */
- protected Button getDefaultsButton() {
- return super.getDefaultsButton();
- }
-
- /**
- * Returns the selected project.
- */
- public IProject getProject() {
- IAdaptable selectedElement = getElement();
- if (selectedElement == null)return null;
- if (selectedElement instanceof IProject)return (IProject) selectedElement;
-
- Object adaptedObject = selectedElement.getAdapter(IProject.class);
- if (adaptedObject instanceof IProject)return (IProject) adaptedObject;
- return null;
-
- }
-}

Back to the top