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 'bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation')
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/ValidateAction.java151
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/ValidateXMLFileActionDelegate.java96
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/Validator.java158
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/XMLMessageInfoHelper.java92
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/XMLValidator.java73
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/ValidateAction.java434
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorActionDelegate.java163
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorDialog.java289
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorUtility.java131
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/TaskListTableViewer.java181
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/xmlvalidation.properties41
11 files changed, 0 insertions, 1809 deletions
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/ValidateAction.java b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/ValidateAction.java
deleted file mode 100644
index 9aafd263f9..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/ValidateAction.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.xml.ui.internal.validation;
-
-import java.io.InputStream;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.xml.core.internal.validation.XMLValidationReport;
-import org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage;
-
-
-/**
- * This class managers the 'UI' related details of validation
- * Here's a quick overview of the details :
- * - manages Marker creation based on the results of the validation
- * - (optionally) displays dialog to summarize the results of validation
- *
- * @author Craig Saler, IBM
- * @author Lawrence Mandel, IBM
- */
-public class ValidateAction extends org.eclipse.wst.xml.ui.internal.validation.core.ValidateAction
-{
- private static final String _UI_VALIDATION_FAILED = "_UI_VALIDATION_FAILED";
- private static final String _UI_THE_XML_FILE_IS_NOT_VALID = "_UI_THE_XML_FILE_IS_NOT_VALID";
- private static final String _UI_VALIDATION_SUCEEDED = "_UI_VALIDATION_SUCEEDED";
- private static final String _UI_THE_XML_FILE_IS_VALID_WITH_WARNINGS = "_UI_THE_XML_FILE_IS_VALID_WITH_WARNINGS";
- private static final String _UI_THE_XML_FILE_IS_WELL_FORMED_WITH_WARNINGS = "_UI_THE_XML_FILE_IS_WELL_FORMED_WITH_WARNINGS";
- private static final String _UI_NO_GRAMMAR_WARNING = "_UI_NO_GRAMMAR_WARNING";
- private static final String _UI_THE_XML_FILE_IS_VALID = "_UI_THE_XML_FILE_IS_VALID";
- private static final String _UI_THE_XML_FILE_IS_WELL_FORMED = "_UI_THE_XML_FILE_IS_WELL_FORMED";
- //dw private static final String _UI_MESSAGE_LIMITE_EXCEEDED = "_UI_MESSAGE_LIMITE_EXCEEDED";
-
- private InputStream inputStream;
-
-
- /**
- * Constructor.
- *
- * @param file The file to validate.
- * @param showDialog Whether to display a dialog after validation.
- */
- public ValidateAction(IFile file, boolean showDialog)
- {
- super(file, showDialog);
- }
-
- /*
- * Store additional information in the message parameters
- * param[0] = the column number of the error
- * param[1] = the 'squiggle selection strategy' for which DOM part to squiggle
- * param[2] = the name or value of what is to be squiggled
- */
- protected void addInfoToMessage(ValidationMessage validationMessage, IMessage message)
- {
- if (inputStream != null)
- {
- XMLMessageInfoHelper messageInfoHelper = new XMLMessageInfoHelper();
- String[] messageInfo = messageInfoHelper.createMessageInfo(validationMessage.getKey(), validationMessage.getMessageArguments());
-
- message.setAttribute(COLUMN_NUMBER_ATTRIBUTE, new Integer(validationMessage.getColumnNumber()));
- message.setAttribute(SQUIGGLE_SELECTION_STRATEGY_ATTRIBUTE, messageInfo[0]);
- message.setAttribute(SQUIGGLE_NAME_OR_VALUE_ATTRIBUTE, messageInfo[1]);
- }
- }
-
-
- protected void validate(final IFile file) {
- XMLValidationOutcome valoutcome = new XMLValidationOutcome();
- IPath path = file.getLocation();
- final String uri = createURIForFilePath(path.toString());
-
- XMLValidator validator = XMLValidator.getInstance();
-
- clearMarkers(file);
- XMLValidationReport valreport = null;
- if (inputStream != null) {
- valreport = validator.validate(uri, inputStream);
- }
- else {
- valreport = validator.validate(uri);
- }
-
- valoutcome.isValid = valreport.isValid();
- if (valreport.getValidationMessages().length == 0) {
- valoutcome.hasMessages = false;
- }
- else {
- valoutcome.hasMessages = true;
- }
- valoutcome.isGrammarEncountered = valreport.isGrammarEncountered();
- createMarkers(file, valreport.getValidationMessages());
-
- try {
- file.setSessionProperty(ValidationMessage.ERROR_MESSAGE_MAP_QUALIFIED_NAME, valreport.getNestedMessages());
- }
- catch (CoreException e) {
- }
-
-
- if (showDialog) {
- // The file is invalid.
- if (!valoutcome.isValid) {
- String title = resourceBundle.getString(_UI_VALIDATION_FAILED);
- String message = resourceBundle.getString(_UI_THE_XML_FILE_IS_NOT_VALID);
- openErrorDialog(title, message);
- }
- else {
- // The file is valid however warnings were issued.
- if (valoutcome.hasMessages) {
- String title = resourceBundle.getString(_UI_VALIDATION_SUCEEDED);
- String message = valoutcome.isGrammarEncountered ? resourceBundle.getString(_UI_THE_XML_FILE_IS_VALID_WITH_WARNINGS) : resourceBundle.getString(_UI_THE_XML_FILE_IS_WELL_FORMED_WITH_WARNINGS) + resourceBundle.getString(_UI_NO_GRAMMAR_WARNING);
-
- openWarningDialog(title, message);
- }
- // The file is valid with no warnings.
- else {
- String title = resourceBundle.getString(_UI_VALIDATION_SUCEEDED);
- String message = valoutcome.isGrammarEncountered ? resourceBundle.getString(_UI_THE_XML_FILE_IS_VALID) : resourceBundle.getString(_UI_THE_XML_FILE_IS_WELL_FORMED) + resourceBundle.getString(_UI_NO_GRAMMAR_WARNING);
-
- openValidDialog(title, message);
- }
- }
- }
- }
-
- /**
- * An XML specific validation outcome that includes whether a grammar
- * was encountered.
- *
- * @author Lawrence Mandel, IBM
- */
- protected class XMLValidationOutcome extends ValidationOutcome
- {
- public boolean isGrammarEncountered = false;
- }
- public void setInputStream(InputStream inputStream)
- { this.inputStream = inputStream;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/ValidateXMLFileActionDelegate.java b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/ValidateXMLFileActionDelegate.java
deleted file mode 100644
index b4f57cd607..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/ValidateXMLFileActionDelegate.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.xml.ui.internal.validation;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IActionDelegate;
-
-/**
- * A delegate to invoke XML validation from the context menu's Validate XML option.
- *
- * @author Craig Saler, IBM
- * @author Lawrence Mandel, IBM
- */
-public class ValidateXMLFileActionDelegate implements IActionDelegate
-{
- public static final String copyright = "(c) Copyright IBM Corporation 2002.";
- protected ISelection selection;
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction action)
- {
- IFile fileResource = null;
- try
- {
- // CS.. for now the following line tests to ensure the user has xerces jars installed
- // so that we can perform some 'fail fast' behaviour
- //
- Class theClass = Class.forName("org.apache.xerces.xni.parser.XMLParserConfiguration", true, this.getClass().getClassLoader());
- if (theClass == null)
- {
- throw(new Exception("Missing Xerces jars in plugin's 'jars' folder"));
- }
-
- if (!selection.isEmpty() && selection instanceof IStructuredSelection)
- {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- Object element = structuredSelection.getFirstElement();
-
- if (element instanceof IFile)
- {
- fileResource = (IFile) element;
- }
- else
- {
- return;
- }
- }
-
- if (fileResource != null)
- {
- //IProject project = fileResource.getProject();
- //URIResolver resolver = (URIResolver) project.getAdapter(URIResolver.class);
- // if (resolver == null)
- // resolver = new ProjectResolver(project);
- //resolver.setFileBaseLocation(fileResource.getLocation().toString());
- //return resolver;
- ValidateAction validateAction = new ValidateAction(fileResource, true);
- validateAction.setValidator(new Validator());
- validateAction.run();
- }
- }
- catch (Exception e)
- {
- // CS... here's where we need to pop up a dialog to tell the user that xerces is not available
- //
- String xercesLine1 = "Required files xercesImpl.jar and xmlParserAPIs.jar cannot be found.\n\n";
- String xercesLine2 = "Download Xerces 2.6.2 and place xercesImpl.jar and xmlParserAPIs.jar in a folder entitled jars in the org.eclipse.wst.xml.validation plugin.\n\n";
- String xercesLine3 = "For more information see www.eclipse.org/webtools/wst/components/xml/xercesInfo.xml.";
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Missing Xerces", xercesLine1 + xercesLine2 + xercesLine3);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection)
- {
- this.selection = selection;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/Validator.java b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/Validator.java
deleted file mode 100644
index ce27832690..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/Validator.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.xml.ui.internal.validation;
-
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.operations.IRuleGroup;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-/**
- * A validator to plug the XML validator into the validation framework.
- *
- * @author Craig Salter, IBM
- * @author Lawrence Mandel, IBM
- */
-public class Validator implements IValidator
-{
- private final String GET_FILE = "getFile";
- public final String GET_PROJECT_FILES = "getAllFiles";
-
- static boolean shouldValidate(IFile file) {
- IResource resource = file;
- do {
- if (resource.isDerived() || resource.isTeamPrivateMember() || !resource.isAccessible() || resource.getName().charAt(0) == '.') {
- return false;
- }
- resource = resource.getParent();
- }
- while ((resource.getType() & IResource.PROJECT) == 0);
- return true;
- }
-
- /**
- * Validate the given file.
- *
- * @param file The file to validate.
- */
- public void validate(IFile file)
- {
- ValidateAction validateAction = new ValidateAction(file, false);
- validateAction.setValidator(this);
- validateAction.run();
- }
- public void validate(IFile file, InputStream inputStream, IReporter reporter)
- {
- ValidateAction validateAction = new ValidateAction(file, false);
- validateAction.setValidator(this);
- if (inputStream != null)
- {
- validateAction.setInputStream(inputStream);
- validateAction.setReporter(reporter);
- }
- validateAction.run();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wtp.validation.core.IValidator#validate(org.eclipse.wtp.validation.core.IHelper, org.eclipse.wtp.validation.core.IReporter, org.eclipse.wtp.validation.core.IFileDelta[])
- */
- public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
- String[] fileURIs = helper.getURIs();
- if (fileURIs != null && fileURIs.length > 0)
- {
- for (int i = 0; i < fileURIs.length; i++)
- {
- String fileName = fileURIs[i];
- if (fileName != null)
- {
- Object []parms = {fileName};
-
- IFile file = (IFile) helper.loadModel(GET_FILE, parms);
- if (file != null && shouldValidate(file))
- { //the helper might not have the file stored in it. could have an InputStream
- if (helper.loadModel("inputStream") instanceof InputStream)
- {
- validate(file, (InputStream)helper.loadModel("inputStream"), reporter); //do we need the fileName? what is int ruleGroup?
- }
- else
- {
- //if (((Helper)helper).isInJavaBuildPath(file) &&
- // !((WorkbenchContext)helper).isInJavaSourcePath(file))
- //{
- // continue;
- //}
- validateIfNeeded(file, helper, reporter);
- }
- }
- }
- }
- }
- else
- {
- Object []parms = {this.getClass().getName()};
- Collection files = (Collection) helper.loadModel(GET_PROJECT_FILES, parms);
- Iterator iter = files.iterator();
- while (iter.hasNext())
- {
- IFile file = (IFile) iter.next();
- validateIfNeeded(file, helper, reporter);
- }
- }
- }
-
- /**
- * Validate the given file and use the reporter for the validation messages.
- *
- * @param file The file to validate.
- * @param reporter The reporter to report the validation messages.
- * @param ruleGroup
- */
- public void validate(IFile file, IReporter reporter, int ruleGroup)
- {
- ValidateAction validateAction = new ValidateAction(file, false);
- validateAction.setValidator(this);
- validateAction.run();
-
-
- }
-
- /**
- * Validate the given file if validation is required.
- *
- * @param file The file to validate.
- * @param helper An aid for the validation.
- * @param reporter The reporter to report the validation messages.
- */
- protected void validateIfNeeded(IFile file, IValidationContext helper, IReporter reporter)
- {
- Integer ruleGroupInt = (Integer)helper.loadModel(IRuleGroup.PASS_LEVEL, null); // pass in a "null" so that loadModel doesn't attempt to cast the result into a RefObject
- int ruleGroup = (ruleGroupInt == null) ? IRuleGroup.PASS_FULL : ruleGroupInt.intValue();
-
- validate(file, reporter, ruleGroup);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wtp.validation.core.IValidator#cleanup(org.eclipse.wtp.validation.core.IReporter)
- */
- public void cleanup(IReporter reporter)
- {
- // Nothing to do.
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/XMLMessageInfoHelper.java b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/XMLMessageInfoHelper.java
deleted file mode 100644
index 08fd9b8c56..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/XMLMessageInfoHelper.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.xml.ui.internal.validation;
-
-public class XMLMessageInfoHelper
-{
- public XMLMessageInfoHelper()
- {
- super();
- }
-
- /**
- * returns an array containing information about what should be underlined with the red "squiggles"
- * using the errorKey, and the messageArguments
- * <br>Position 0 of the array returned contains the selection Strategy,or what DOM Element to underline.
- * For example "ATTRIBUTE_NAME"
- * <br>Position 1 contains the name or value to squiggle.
- * <p>For example, if we wanted to squiggle the attribute name of an attribute name
- * foo this method would return {"ATTRIBUTE_NAME", "foo"}
- * </p>
- * @param errorKey the error key given by the Xerces parser
- * @param messageArguments the arguments used by Xerces to "fill in the blanks" of their messages
- * @return an array containing the squiggle information
- * @see org.eclipse.wst.xml.ui.internal.validation.DelegatingSourceValidator
- *
- */
- public String[] createMessageInfo(String errorKey, Object[] messageArguments)
- {
- String selectionStrategy = null;
- String nameOrValue = null;
-
- if (errorKey.equals("cvc-complex-type.2.4.a") || errorKey.equals("cvc-complex-type.2.4.d") || errorKey.equals("cvc-complex-type.2.4.b") || errorKey.equals("MSG_CONTENT_INVALID")
- | errorKey.equals("MSG_CONTENT_INCOMPLETE") || errorKey.equals("MSG_REQUIRED_ATTRIBUTE_NOT_SPECIFIED") || errorKey.equals("cvc-complex-type.4"))
- {
- selectionStrategy = "START_TAG";
- }
- else if (errorKey.equals("cvc-type.3.1.3"))
- {
- selectionStrategy = "TEXT";
- }
- else if (errorKey.equals("cvc-complex-type.2.3"))
- {
- selectionStrategy = "FIRST_NON_WHITESPACE_TEXT";
- }
- else if (errorKey.equals("cvc-type.3.1.1"))
- {
- selectionStrategy = "ALL_ATTRIBUTES";
- }
- else if (errorKey.equals("cvc-complex-type.3.2.2") || errorKey.equals("MSG_ATTRIBUTE_NOT_DECLARED"))
- {
- selectionStrategy = "ATTRIBUTE_NAME";
- //in this case we need nameOrValue to be the name of the attribute to underline
- nameOrValue = (String)messageArguments[1];
- }
- else if (errorKey.equals("cvc-attribute.3") || errorKey.equals("MSG_ATTRIBUTE_VALUE_NOT_IN_LIST") || errorKey.equals("cvc-complex-type.3.1"))
- {
- selectionStrategy = "ATTRIBUTE_VALUE";
- //in this case we need nameOrValue to be the name of the Attribute
- if (errorKey.equals("cvc-attribute.3") || errorKey.equals("cvc-complex-type.3.1"))
- { nameOrValue = (String)messageArguments[1];
- }
- else if (errorKey.equals("MSG_ATTRIBUTE_VALUE_NOT_IN_LIST"))
- { nameOrValue = (String)messageArguments[0];
- }
- }
- else if (errorKey.equals("cvc-elt.4.2"))
- { selectionStrategy="VALUE_OF_ATTRIBUTE_WITH_GIVEN_VALUE";
- //in this case we need nameOrValue to be the value of the attribute we want to unerline
- nameOrValue = (String)messageArguments[1];
- }
- else if (errorKey.equals("EntityNotDeclared"))
- { selectionStrategy="TEXT_ENTITY_REFERENCE";
- }
- else if (errorKey.equals("ElementUnterminated"))
- {
- selectionStrategy = "ENTIRE_ELEMENT";
- }
- String messageInfo[] = new String[2];
- messageInfo[0] = selectionStrategy != null? selectionStrategy: "";
- messageInfo[1] = nameOrValue;
- return messageInfo;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/XMLValidator.java b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/XMLValidator.java
deleted file mode 100644
index 0f6756870d..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/XMLValidator.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.xml.ui.internal.validation;
-
-import java.io.InputStream;
-
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-import org.eclipse.wst.xml.core.internal.validation.XMLValidationReport;
-
-/**
- * An XML validator specific to Eclipse. This validator will wrap the internal
- * XML validator an provide automatic URI resolver support.
- * Using this class is equivalent to using the internal XML validator and registering
- * the URI resolver.
- *
- * @author Lawrence Mandel, IBM
- */
-public class XMLValidator
-{
- private static XMLValidator instance = null;
- private org.eclipse.wst.xml.core.internal.validation.XMLValidator validator = null;
-
- /**
- * Return the one and only instance of the XML validator. The validator
- * can be reused and cannot be customized so there should only be one instance of it.
- *
- * @return The one and only instance of the XML validator.
- */
- public static XMLValidator getInstance()
- {
- if(instance == null)
- {
- instance = new XMLValidator();
- }
- return instance;
- }
- /**
- * Constructor. Create the XML validator and set the URI resolver.
- */
- protected XMLValidator()
- {
- validator = new org.eclipse.wst.xml.core.internal.validation.XMLValidator();
- validator.setURIResolver(URIResolverPlugin.createResolver());
- }
- /**
- * Validate the file at the given URI.
- *
- * @param uri The URI of the file to validate.
- */
- public XMLValidationReport validate(String uri)
- {
- return validator.validate(uri);
- }
- /**
- * Validate the InputStream
- *
- * @param uri The URI of the file to validate.
- * @param inputStream The input stream to validate.
- */
- public XMLValidationReport validate(String uri, InputStream inputStream)
- {
- return validator.validate(uri, inputStream);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/ValidateAction.java b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/ValidateAction.java
deleted file mode 100644
index 8273702120..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/ValidateAction.java
+++ /dev/null
@@ -1,434 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.xml.ui.internal.validation.core;
-
-import java.util.List;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.validation.internal.operations.LocalizedMessage;
-import org.eclipse.wst.validation.internal.operations.WorkbenchReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-import org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage;
-import org.eclipse.wst.xml.core.internal.validation.core.logging.ILogger;
-import org.eclipse.wst.xml.core.internal.validation.core.logging.LoggerFactory;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-/**
- * A general validate action class that can be extended by validators. This class
- * provides methods to run the action, add markers to a file and will handle
- * showing a dialog with the results of validation (if requested) and prompt to
- * save dirty files (if requested.)
- */
-public abstract class ValidateAction extends Action
-{
- // Locally used, non-UI strings.
- private static final String REFERENCED_FILE_ERROR_OPEN = "referencedFileError(";
-
- private static final String REFERENCED_FILE_ERROR_CLOSE = ")";
-
- private static final String REFERENCED_FILE_ERROR = "referencedFileError";
-
- private static final String GROUP_NAME = "groupName";
-
- private static final String _UI_SAVE_DIRTY_FILE_MESSAGE = "_UI_SAVE_DIRTY_FILE_MESSAGE";
- private static final String _UI_SAVE_DIRTY_FILE_TITLE = "_UI_SAVE_DIRTY_FILE_TITLE";
-
- private static final String FILE_PROTOCOL_NO_SLASH = "file:";
- private static final String FILE_PROTOCOL = "file:///";
-
- protected static final String COLUMN_NUMBER_ATTRIBUTE = "columnNumber";
- protected static final String SQUIGGLE_SELECTION_STRATEGY_ATTRIBUTE = "squiggleSelectionStrategy";
- protected static final String SQUIGGLE_NAME_OR_VALUE_ATTRIBUTE = "squiggleNameOrValue";
-
- protected boolean showDialog = true;
-
- protected IFile file = null;
-
- protected IReporter reporter;
-
- protected IValidator validator;
-
- protected ResourceBundle resourceBundle;
-
- /**
- * Constructor.
- *
- * @param file
- * The file to validate.
- * @param showDialog
- * Whether or not to show a dialog when validation is complete.
- */
- public ValidateAction(IFile file, boolean showDialog)
- {
- this.showDialog = showDialog;
- this.file = file;
- resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.xml.ui.internal.validation.xmlvalidation");
- }
-
- /**
- * Validate the specified file.
- *
- * @param file
- * The file to validate.
- */
- protected abstract void validate(final IFile file);
-
- protected void addInfoToMessage (ValidationMessage v, IMessage m)
- { // This method is overidden by subclasses
- }
-
- /**
- * Create markers for the valiation messages generated from the validation.
- *
- * @param iFile
- * The resource to create the markers on.
- * @param valmessages
- * The array of validation messages.
- */
- public void createMarkers(IFile iFile, ValidationMessage[] valmessages)
- {
- if (!fileIsOK(iFile))
- {
- return;
- }
- int nummessages = valmessages.length;
- for (int i = 0; i < nummessages; i++)
- {
- ValidationMessage validationMessage = valmessages[i];
- String uri = validationMessage.getUri();
-
- LocalizedMessage message;
- if (validationMessage.getSeverity() == ValidationMessage.SEV_LOW)
- {
- message = new LocalizedMessage(getValidationFrameworkSeverity(IMarker.SEVERITY_WARNING), validationMessage
- .getMessage(), iFile);
- }
- else
- {
- message = new LocalizedMessage(getValidationFrameworkSeverity(IMarker.SEVERITY_ERROR), validationMessage.getMessage(), iFile);
- }
-
- message.setLineNo(validationMessage.getLineNumber());
- addInfoToMessage(validationMessage, message);
-
- List nestederrors = validationMessage.getNestedMessages();
- if (nestederrors != null && !nestederrors.isEmpty())
- {
- message.setGroupName(REFERENCED_FILE_ERROR_OPEN + uri + REFERENCED_FILE_ERROR_CLOSE);
- }
-
- getOrCreateReporter().addMessage(getValidator(), message);
-
-
- }
- try
- {
- IMarker[] markers = iFile.findMarkers(null, true, IResource.DEPTH_INFINITE);
- for (int i = 0; i < markers.length; i++)
- {
- IMarker marker = markers[i];
- String groupName = null;
- try
- {
- groupName = (String) marker.getAttribute(GROUP_NAME);
- }
- catch (Exception e)
- {
- }
-
- if (groupName != null && groupName.startsWith(REFERENCED_FILE_ERROR))
- {
-
- marker.setAttribute(IMarker.DONE, true);
- }
- }
- }
- catch (CoreException e)
- {
- e.printStackTrace();
- }
-
- }
-
- public void clearMarkers(IFile iFile)
- {
- if (fileIsOK(iFile))
- {
- getOrCreateReporter().removeAllMessages(getValidator(), iFile);
- }
- }
-
- public void run()
- {
- try
- {
- // CS... a temporary test to avoid performing validation in the absence of xerces
- //
- //dw Class theClass =
- Class.forName("org.apache.xerces.xni.parser.XMLParserConfiguration", true, this.getClass().getClassLoader());
-
- if (fileIsOK(file))
- {
- // Check if the editor is dirty for this file. If so, prompt the user to
- // save before validating.
- if(showDialog)
- {
- checkIfFileDirty(file);
- }
- try
- {
- validate(file);
- }
- catch (Exception e)
- {
- ILogger logger = LoggerFactory.getLoggerInstance();
- logger.logError("", e);
- // e.printStackTrace();
- }
- }
- }
- catch (Exception e)
- {
- }
- }
-
- /**
- * Test whether the file given is OK to use. A file is OK to use if 1. It is
- * not null 2. It exists. 3. The project containing the file is accessible.
- *
- * @param file The file to check.
- * @return True if the file is OK to use, false otherwise.
- */
- protected boolean fileIsOK(IFile file)
- {
- if (file != null && file.exists() && file.getProject().isAccessible())
- {
- return true;
- }
- return false;
- }
-
- /**
- * Check if the file is dirty. A file is dirty if there is an open editor for
- * the file that contains changes that haven't been saved.
- *
- * @param file The file to check to see if it is dirty.
- */
- protected void checkIfFileDirty(IFile file)
- {
- IEditorPart[] dirtyEditors = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow()
- .getActivePage().getDirtyEditors();
- int numeditors = dirtyEditors.length;
- for (int i = 0; i < numeditors; i++)
- {
- IEditorInput editorInput = dirtyEditors[i].getEditorInput();
- if (editorInput instanceof FileEditorInput)
- {
- FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
- if (fileEditorInput.getFile().equals(file))
- {
- String message = resourceBundle.getString(_UI_SAVE_DIRTY_FILE_MESSAGE);
- String title = resourceBundle.getString(_UI_SAVE_DIRTY_FILE_TITLE);
- if (MessageDialog.openQuestion(Display.getDefault().getActiveShell(), title, message))
- {
- dirtyEditors[i].doSave(null);
- }
- // There can only be one open editor/file so we can break.
- break;
- }
- }
- }
- }
-
- /**
- * Gets the reporter.
- *
- * @return Returns a IReporter
- */
- public IReporter getReporter()
- {
- return reporter;
- }
-
- /**
- * Sets the reporter.
- *
- * @param reporter
- * The reporter to set
- */
- public void setReporter(IReporter reporter)
- {
- this.reporter = reporter;
- }
-
- /**
- * Gets the validator.
- *
- * @return Returns a IValidator
- */
- public IValidator getValidator()
- {
- return validator;
- }
-
- /**
- * Sets the validator.
- *
- * @param validator
- * The validator to set
- */
- public void setValidator(IValidator validator)
- {
- this.validator = validator;
- }
-
- protected IReporter getOrCreateReporter()
- {
- if (reporter == null)
- {
- reporter = new WorkbenchReporter(file.getProject(), new NullProgressMonitor());
- }
- return reporter;
- }
-
- /**
- * Originally from *validation.Helper
- *
- * @param severity
- * The severity given.
- * @return The validation framework severity corresponding to the error.
- */
- protected int getValidationFrameworkSeverity(int severity)
- {
- switch (severity) {
- case IMarker.SEVERITY_ERROR:
- return IMessage.HIGH_SEVERITY;
- case IMarker.SEVERITY_WARNING:
- return IMessage.NORMAL_SEVERITY;
- case IMarker.SEVERITY_INFO:
- return IMessage.LOW_SEVERITY;
- }
- return IMessage.LOW_SEVERITY;
- }
-
- /**
- * Open an error dialog with the given title and message. Show the problems view
- * if it is not already visible.
- *
- * @param title The title of the error dialog.
- * @param message The message in the error dialog.
- */
- protected void openErrorDialog(String title, String message)
- {
- showProblemsView();
- MessageDialog.openError(Display.getDefault().getActiveShell(), title, message);
- }
-
- /**
- * Open an warning dialog with the given title and message. Show the problems view
- * if it is not already visible.
- *
- * @param title The title of the warning dialog.
- * @param message The message in the warning dialog.
- */
- protected void openWarningDialog(String title, String message)
- {
- showProblemsView();
- MessageDialog.openWarning(Display.getDefault().getActiveShell(), title, message);
- }
-
- /**
- * Open a valid dialog with the given title and message.
- *
- * @param title The title of the valid dialog.
- * @param message The message in the valid dialog.
- */
- protected void openValidDialog(String title, String message)
- {
- MessageDialog.openInformation(Display.getDefault().getActiveShell(), title, message);
- }
-
- /**
- * Show the problems view if it is not already visible.
- */
- protected void showProblemsView()
- {
- IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage page = dw.getActivePage();
- IWorkbenchPart activePart = page.getActivePart();
- try
- {
- if (page != null)
- {
- page.showView("org.eclipse.ui.views.ProblemView");
- }
- }
- catch (PartInitException e)
- {
- }
- page.activate(activePart);
- }
-
- /**
- * Format a file name into a correct URI.
- *
- * @param filename The file name to format.
- * @return The formatted URI.
- */
- protected String createURIForFilePath(String filename)
- {
- if(!filename.startsWith(FILE_PROTOCOL_NO_SLASH))
- {
- while(filename.startsWith("/"))
- {
- filename = filename.substring(1);
- }
- filename = FILE_PROTOCOL + filename;
- }
- return filename;
- }
-
- /**
- * The validation outcome class holds the results from validating
- * a file.
- *
- * @author Lawrence Mandel, IBM
- */
- protected class ValidationOutcome
- {
- public boolean isValid = true;
-
- public boolean hasMessages = false;
-
- public ValidationOutcome()
- {
- }
- }
-}
-
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorActionDelegate.java b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorActionDelegate.java
deleted file mode 100644
index fbc7e5c086..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorActionDelegate.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.xml.ui.internal.validation.core.errorinfo;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.actions.ActionDelegate;
-import org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage;
-
-public class ReferencedFileErrorActionDelegate extends ActionDelegate implements IObjectActionDelegate
-{
- protected IMarker selectedMarker;
-
- protected ResourceBundle resourceBundle;
-
- /**
- *
- */
- public ReferencedFileErrorActionDelegate()
- {
- super();
- resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.xml.ui.internal.validation.xmlvalidation");
- }
-
- public void run(IAction action)
- {
- if (selectedMarker != null)
- {
- try
- {
-
- Map map = (Map) selectedMarker.getResource().getSessionProperty(ValidationMessage.ERROR_MESSAGE_MAP_QUALIFIED_NAME);
- if (map == null)
- {
- String infoUnavailable = resourceBundle.getString("_UI_DETAILS_INFORMATION_UNAVAILABLE");
- String revalidateToRegenerateErrors = resourceBundle.getString("_UI_DETAILS_INFO_REVALIDATE_TO_REGENERATE");
- MessageDialog.openInformation(Display.getCurrent().getActiveShell(), infoUnavailable, revalidateToRegenerateErrors);
- }
- else
- {
- String uri = null;
-
- String groupName = (String) selectedMarker.getAttribute("groupName");
- if (groupName.startsWith("referencedFileError"))
- {
- int index1 = groupName.indexOf("(");
- int index2 = groupName.lastIndexOf(")");
- if (index1 != -1 && index2 > index1)
- {
- uri = groupName.substring(index1 + 1, index2);
- }
- }
-
- if (uri != null)
- {
- List list = Collections.EMPTY_LIST;
-
- ValidationMessage message = (ValidationMessage) map.get(uri);
- if (message != null)
- {
- list = message.getNestedMessages();
- }
-
- String validatedFileURI = selectedMarker.getResource().getLocation().toOSString();//URIHelper.normalize(selectedMarker.getResource().getLocation().toOSString());
- validatedFileURI = "file:/" + validatedFileURI;
-
- ReferencedFileErrorDialog dialog = new ReferencedFileErrorDialog(Display.getCurrent().getActiveShell(), list, validatedFileURI, uri);
- dialog.createAndOpen();
- }
- }
- }
- catch (CoreException e)
- {
- // Do nothing.
- }
- }
- }
-
- public void selectionChanged(IAction action, ISelection selection)
- {
- super.selectionChanged(action, selection);
- selectedMarker = null;
- if (selection instanceof IStructuredSelection)
- {
- try
- {
- Object first = ((IStructuredSelection) selection).getFirstElement();
-
- IMarker marker = (IMarker)first;
- selectedMarker = marker;
-// String groupName = (String) marker.getAttribute("groupName");
-// if (groupName.startsWith("referencedFileError"))
-// {
-// selectedMarker = marker;
-// }
- }
- catch (Exception e)
- {
- // Do nothing.
- }
- }
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
- */
- public void setActivePart(IAction action, IWorkbenchPart targetPart)
- {
- //dw int i = 0;
- }
-}
-
-/*
- private static void printMap(Map map)
- {
- for (Iterator i = map.keySet().iterator(); i.hasNext();)
- {
- String key = (String) i.next();
- System.out.println("entry : " + key + " = " + map.get(key));
- }
- }
-
- private void printErrorMap(Map map)
- {
- for (Iterator i = map.keySet().iterator(); i.hasNext();)
- {
- String key = (String) i.next();
- ErrorMessage message = (ErrorMessage) map.get(key);
- if (message != null)
- {
- printErrorMessage(message);
- }
- }
- }
-
- private void printErrorMessage(ErrorMessage errorMessage)
- {
- System.out.println(errorMessage.getText());
- for (Iterator i = errorMessage.getNestedErrors().iterator(); i.hasNext();)
- {
- printErrorMessage((ErrorMessage) i.next());
- }
- }
- */ \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorDialog.java b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorDialog.java
deleted file mode 100644
index 5f893e8621..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorDialog.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.xml.ui.internal.validation.core.errorinfo;
-
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.ResourceBundle;
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage;
-
-
-public class ReferencedFileErrorDialog extends Dialog
-{
- protected TaskListTableViewer tableViewer;
- protected List errorList;
- protected String markedUpDetailsMessage;
- protected String contextFile;
- protected String referencedFile;
- protected StyledText styledText;
- protected Text fullFileNameField;
-
- protected ResourceBundle resourceBundle;
-
- public ReferencedFileErrorDialog(Shell parentShell, List errorList, String contextFile, String referencedFile)
- {
- super(parentShell);
-
- resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.xml.ui.internal.validation.xmlvalidation");
-
- int styleBits = getShellStyle() | SWT.RESIZE;
- styleBits &= ~SWT.APPLICATION_MODAL;
-
- setShellStyle(styleBits);
- this.errorList = errorList;
-
- this.referencedFile = referencedFile;
- this.contextFile = contextFile;
- this.markedUpDetailsMessage = getMarkedUpDetailsMessage();
- }
-
- public int createAndOpen()
- {
- create();
- getShell().setText(resourceBundle.getString("_UI_REF_FILE_ERROR_DETAILS"));
-
- setBlockOnOpen(false);
- return open();
- }
-
-
- protected Control createButtonBar(Composite parent)
- {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- fullFileNameField = new Text(composite, SWT.NONE);
- fullFileNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fullFileNameField.setBackground(parent.getBackground());
- fullFileNameField.setEditable(false);
-
- super.createButtonBar(composite);
-
- return composite;
- }
-
- protected Control createDialogArea(Composite parent)
- {
- Composite dialogArea = (Composite) super.createDialogArea(parent);
- dialogArea.setLayout(new GridLayout());
-
- Composite c = new Composite(dialogArea, SWT.NONE);
- c.setLayout(new GridLayout());
- c.setLayoutData(createGridData(true, -1, 200));
-
- styledText = new StyledText(c, SWT.MULTI | SWT.WRAP);
- styledText.setBackground(c.getBackground());
- setStyledText(styledText, markedUpDetailsMessage);
- styledText.setEditable(false);
- styledText.setLayoutData(createGridData(false, 650, -1));
-
- MouseListener mouseListener = new MouseListener();
- styledText.addMouseMoveListener(mouseListener);
-
- tableViewer = new TaskListTableViewer(c, 10);
- tableViewer.setInput(errorList);
- tableViewer.addSelectionChangedListener(new InternalSelectionListener());
- tableViewer.getControl().setLayoutData(createGridData(true, 700, -1));
- return dialogArea;
- }
-
- String getFullURI(int offset)
- {
- String uri = "";
- int index = getIndex(offset);
- if (index != -1)
- {
- if (index == 0 || index == 2 || index == 3)
- {
- uri = referencedFile;
- }
- else
- {
- uri = contextFile;
- }
- }
- return uri;
- }
-
- private int getIndex(int offset)
- {
- int result = -1;
- StyleRange[] range = styledText.getStyleRanges();
- for (int i = 0; i < range.length; i++)
- {
- int l = range[i].start;
- int r = l + range[i].length;
- if (l <= offset && r >= offset)
- {
- result = i;
- break;
- }
- }
- return result;
- }
-
- class MouseListener implements MouseMoveListener
- {
- public void mouseMove(MouseEvent event)
- {
- String toolTipText = "";
- try
- {
-
- int offset = styledText.getOffsetAtLocation(new Point(event.x, event.y));
- toolTipText = getFullURI(offset);
-
- }
- catch (Exception e)
- {
- // Do nothing.
- }
- styledText.setToolTipText(toolTipText);
- if (toolTipText != null && toolTipText.length() > 0)
- {
- fullFileNameField.setText(toolTipText);
- }
- }
- }
-
- private String getMarkedUpDetailsMessage()
- {
- String detailsMessage = "";
- // TODO... need to move '_UI_REF_FILE_ERROR_DESCRIPTION' to this plugin's properties file
- //
- String string = resourceBundle.getString("_UI_REF_FILE_ERROR_DESCRIPTION");
- // TODO... need to edit the properties file to remove "'" characters from the string
- // I'm using these characters to markup the bold font. It's safer if I add these programtically.
- //
- string = removePattern(string, "'");
-
- String c = "'" + getLastSegment(contextFile) + "'";
- String r = "'" + getLastSegment(referencedFile) + "'";
-
- detailsMessage = MessageFormat.format(string, new Object[] { r, c, r, c });
- return detailsMessage;
- }
-
- private String removePattern(String string, String pattern)
- {
- while (true)
- {
- int index = string.indexOf(pattern);
- if (index != -1)
- {
- string = string.substring(0, index) + string.substring(index + pattern.length());
- }
- else
- {
- break;
- }
- }
- return string;
- }
-
- private void setStyledText(StyledText styledText, String text)
- {
- String visibleMessage = "";
- for (StringTokenizer st = new StringTokenizer(markedUpDetailsMessage, "'", false); st.hasMoreTokens();)
- {
- String token = st.nextToken();
- visibleMessage += token;
- }
-
- styledText.setText(visibleMessage);
- //dw Font font = styledText.getFont();
-
- boolean inQuote = false;
- int position = 0;
- for (StringTokenizer st = new StringTokenizer(markedUpDetailsMessage, "'", true); st.hasMoreTokens();)
- {
- String token = st.nextToken();
-
- if (token.equals("'"))
- {
- inQuote = !inQuote;
- }
- else
- {
- if (inQuote)
- {
- try
- {
-
- StyleRange style = new StyleRange(position, token.length(), styledText.getForeground(), styledText.getBackground(), SWT.BOLD);
- styledText.setStyleRange(style);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- position = position + token.length();
- }
- }
- }
-
- private static GridData createGridData(boolean fillBoth, int w, int h)
- {
- GridData gd = new GridData(fillBoth ? GridData.FILL_BOTH : GridData.FILL_HORIZONTAL);
- gd.widthHint = w;
- gd.heightHint = h;
- return gd;
- }
-
- private static String getLastSegment(String uri)
- {
- String result = uri;
- int index = Math.max(uri.lastIndexOf("/"), uri.lastIndexOf("\\"));
- if (index != -1)
- {
- result = uri.substring(index + 1);
- }
- return result;
- }
-
- protected class InternalSelectionListener implements ISelectionChangedListener
- {
- public void selectionChanged(SelectionChangedEvent event)
- {
- ISelection selection = event.getSelection();
- if (selection instanceof StructuredSelection)
- {
- ValidationMessage validationMessage = (ValidationMessage) ((StructuredSelection) selection).getFirstElement();
- if (validationMessage != null)
- {
- String uristring = validationMessage.getUri();
- ReferencedFileErrorUtility.openEditorAndGotoError(uristring, validationMessage.getLineNumber(), validationMessage.getColumnNumber());
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorUtility.java b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorUtility.java
deleted file mode 100644
index 6b75d6c381..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/ReferencedFileErrorUtility.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.xml.ui.internal.validation.core.errorinfo;
-
-import java.net.URL;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.editors.text.TextEditor;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.wst.xml.core.internal.validation.core.logging.LoggerFactory;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-
-public class ReferencedFileErrorUtility
-{
- public static void openEditorAndGotoError(String uristring, final int line, final int column)
- {
- if (uristring != null)
- {
- try
- {
- URL uri = new URL(uristring);
- if (uri != null)
- {
- if ("file".equals(uri.getProtocol()))
- {
- String pathString = uri.getPath();
- IPath path = new Path(pathString);
- String device = path.getDevice();
- if (device != null && device.startsWith("/"))
- {
- path = path.setDevice(device.substring(1));
- }
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
- if (file != null && file.exists())
- {
- //WorkbenchUtility.openEditor(file);
- // Open the editor for this file.
- final IFile iFile = file;
- IWorkbench workbench = XMLUIPlugin.getInstance().getWorkbench();
- final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
-
- Display.getDefault().asyncExec
- (new Runnable()
- {
- public void run()
- {
- try
- {
- IEditorDescriptor descriptor = XMLUIPlugin.getInstance().getWorkbench().getEditorRegistry().getDefaultEditor(iFile.getName());
- String editorId;
- if(descriptor != null)
- {
- editorId = descriptor.getId();
- }
- else
- {
- editorId = XMLUIPlugin.getInstance().getWorkbench().getEditorRegistry().getDefaultEditor(iFile.getName() + ".txt").getId();
- }
- workbenchWindow.getActivePage().openEditor(new FileEditorInput(iFile), editorId);
- }
- catch (PartInitException ex)
- {
- LoggerFactory.getLoggerInstance().logError("Exception encountered when attempting to open file: " + iFile + "\n\n", ex);
- //B2BGUIPlugin.getPlugin().getMsgLogger().write("Exception encountered when attempting to open file: " + iFile + "\n\n" + ex);
- }
- }
- });
-
- Runnable runnable = new Runnable()
- {
- public void run()
- {
- //IEditorPart editorPart = WorkbenchUtility.getActiveEditor();
- IEditorPart editorPart = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- gotoError(editorPart, line, column);
- }
- };
- Display.getCurrent().asyncExec(runnable);
- }
- }
- }
- }
- catch (Exception e)
- {
- // Do nothing.
- }
- }
- }
-
- static void gotoError(IEditorPart editorPart, int line, int column)
- {
- if (editorPart != null)
- {
- TextEditor textEditor = (TextEditor) editorPart.getAdapter(TextEditor.class);
- if (textEditor != null)
- {
- try
- {
- IDocumentProvider dp = textEditor.getDocumentProvider();
- IDocument document = (dp != null) ? dp.getDocument(textEditor.getEditorInput()) : null;
- textEditor.selectAndReveal(document.getLineOffset(line - 1) + column - 1, 0);
- }
- catch (BadLocationException x)
- {
- // marker refers to invalid text position -> do nothing
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/TaskListTableViewer.java b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/TaskListTableViewer.java
deleted file mode 100644
index e616192d6e..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/core/errorinfo/TaskListTableViewer.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.xml.ui.internal.validation.core.errorinfo;
-
-import java.util.List;
-
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-
-
-public class TaskListTableViewer extends TableViewer
-{
- protected static final int COLUMN_ICON = 0;
- protected static final int COLUMN_DESCRIPTION = 1;
- protected static final int COLUMN_RESOURCE = 3;
- protected static final int COLUMN_LOCATION = 2;
-
- protected static final String LABEL_ICON = "";
- protected static final String LABEL_DESCRIPTION = "Description";
- protected static final String LABEL_RESOURCE = "Resource";
- protected static final String LABEL_LOCATION = "Location";
-
- protected int visibleRows = -1;
-
- protected int getColumnWidth(int column)
- {
- int result = 0;
- switch (column)
- {
- case COLUMN_ICON :
- {
- result = 1;
- break;
- }
- case COLUMN_DESCRIPTION :
- {
- result = 20;
- break;
- }
- case COLUMN_RESOURCE :
- {
- result = 3;
- break;
- }
- case COLUMN_LOCATION :
- {
- result = 3;
- break;
- }
- }
- return result;
- }
-
- public TaskListTableViewer(Composite parent, int visibleRows)
- {
- this(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER, visibleRows);
- }
-
- public TaskListTableViewer(Composite parent, int style, int visibleRows)
- {
- super(new Table(parent, style));
- getTable().setLinesVisible(true);
-
- Provider provider = new Provider();
- setContentProvider(provider);
- setLabelProvider(provider);
-
- String[] columnPropertiesArray = { LABEL_ICON, LABEL_DESCRIPTION, LABEL_LOCATION };
- setColumnProperties(columnPropertiesArray);
-
- Table table = getTable();
- table.setHeaderVisible(true);
- table.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- TableLayout layout = new TableLayout();
-
- for (int i = 0; i < columnPropertiesArray.length; i++)
- {
- TableColumn column = new TableColumn(table, i);
- column.setText(columnPropertiesArray[i]);
- column.setAlignment(SWT.LEFT);
- layout.addColumnData(new ColumnWeightData(getColumnWidth(i), true));
- }
-
- table.setLayout(layout);
-
- this.visibleRows = visibleRows;
- }
-
- /**
- * NamespaceInfoTableLabelProvider
- */
- protected class Provider extends LabelProvider implements ITableLabelProvider, IStructuredContentProvider
- {
- Viewer viewer;
- Image errorImage;
- Image warnImage;
-
- public Provider()
- {
- errorImage = XMLUIPlugin.getInstance().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
-
- warnImage = XMLUIPlugin.getInstance().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
- this.viewer = viewer;
- }
-
- public Object[] getElements(Object inputElement)
- {
- List list = (List) viewer.getInput();
- return list != null ? list.toArray() : null;
- }
-
- public Image getColumnImage(Object object, int columnIndex)
- {
- ValidationMessage validationMessage = (ValidationMessage) object;
- Image result = null;
- if (columnIndex == 0)
- {
- int severity = validationMessage.getSeverity();
- if (severity == IMessage.HIGH_SEVERITY ||
- severity == IMessage.NORMAL_SEVERITY)
- {
- result = errorImage;
- }
- else
- {
- result = warnImage;
- }
- }
- return result;
- }
-
- public String getColumnText(Object object, int column)
- {
- ValidationMessage errorMessage = (ValidationMessage) object;
- String result = "";
- switch (column)
- {
- case COLUMN_DESCRIPTION :
- {
- result = errorMessage.getMessage();
- break;
- }
- case COLUMN_LOCATION :
- {
- result = "line " + errorMessage.getLineNumber();
- break;
- }
- }
- return result;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/xmlvalidation.properties b/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/xmlvalidation.properties
deleted file mode 100644
index 18f0bd2fa7..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-validation/org/eclipse/wst/xml/ui/internal/validation/xmlvalidation.properties
+++ /dev/null
@@ -1,41 +0,0 @@
-###############################################################################
-# Copyright (c) 2001, 2004 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
-###############################################################################
-!-- Constants for strings
-providerName=Eclipse.org
-pluginName=XML Validator
-nlFeatureName=XML Validator NL Support
-
-_UI_VALIDATION_INTERNAL_ERROR = Internal Error
-_UI_VALIDATION_FAILED = Validation Failed
-_UI_VALIDATION_SUCEEDED = Validation Succeeded
-_UI_THE_XML_FILE_IS_NOT_VALID = The XML file is not valid. See the Problems view for a list of the validation errors.
-_UI_THE_XML_FILE_IS_VALID = The XML file is valid.
-_UI_THE_XML_FILE_IS_VALID_WITH_WARNINGS = The XML file is valid however warnings have been issued. See the Problems view for the warning messages.
-_UI_THE_XML_FILE_IS_WELL_FORMED = The XML file is well formed.
-_UI_THE_XML_FILE_IS_WELL_FORMED_WITH_WARNINGS = The XML file is well formed however warnings have been issued. See the Problems view for the warning messages.
-_UI_NO_GRAMMAR_WARNING = Warning : No grammar constraints detected for the document.
-_UI_MESSAGE_LIMITE_EXCEEDED = The XML file is not valid. The message limit for the Problems view has been exceeded. To see all the messages increase the limit and validate again.
-
-!
-! Referenced File Dialog Related Message
-!
-_UI_REF_FILE_ERROR_DESCRIPTION = The errors below were detected when validating the file "{0}" via the file "{1}". In most cases these errors can be detected by validating "{2}" directly. However it is possible that errors will only occur when {2} is validated in the context of {3}.
-_UI_REF_FILE_ERROR_MESSAGE = Referenced file contains errors ({0}). For more information, right click on the message and select "Show Details..."
-_UI_REF_FILE_ERROR_DETAILS = Referenced File Error Details
-
-_UI_DETAILS_INFORMATION_UNAVAILABLE = Details Information Unavailable
-_UI_DETAILS_INFO_REVALIDATE_TO_REGENERATE = Details information currently unavailable. Please revalidate the file to regenerate the error details.
-
-!
-! Dirty File Dialog Related Messages
-!
-_UI_SAVE_DIRTY_FILE_MESSAGE = An open editor contains changes to this file that have not been saved. Do you want to save the file before running validation? (If you do not save the file the previously saved version will be validated.)
-_UI_SAVE_DIRTY_FILE_TITLE = Save file?

Back to the top