Search in sources :

Example 11 with StylesheetModel

use of org.eclipse.wst.xsl.core.model.StylesheetModel in project webtools.sourceediting by eclipse.

the class Validator2 method validate.

@Override
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
    /*
		 * String s; switch(kind) { case IResourceDelta.ADDED: s = "added"; break; case IResourceDelta.CHANGED: s = "CHANGED"; break; case IResourceDelta.CONTENT: s = "CONTENT"; break; case
		 * IResourceDelta.REMOVED: s = "REMOVED"; break; default: s = "other"; } System.out.println(s);
		 */
    ValidationResult result = new ValidationResult();
    if (resource.getType() == IResource.FILE) {
        IFile file = (IFile) resource;
        ValidationReport report = doValidation(file, kind, state, monitor);
        StylesheetModel stylesheet = XSLCore.getInstance().getStylesheet(file);
        IFile[] dependencies = stylesheet.getFileDependencies().toArray(new IFile[0]);
        result.setDependsOn(dependencies);
        for (ValidationMessage message : report.getValidationMessages()) {
            XSLValidationMessage xslMsg = (XSLValidationMessage) message;
            ValidatorMessage msg = ValidatorMessage.create(message.getMessage(), resource);
            // $NON-NLS-1$
            msg.setAttribute("lineNumber", xslMsg.getLineNumber());
            // $NON-NLS-1$
            msg.setAttribute("severity", xslMsg.getSeverity());
            result.add(msg);
        }
    }
    return result;
}
Also used : XSLValidationMessage(org.eclipse.wst.xsl.core.internal.validation.XSLValidationMessage) IFile(org.eclipse.core.resources.IFile) XSLValidationMessage(org.eclipse.wst.xsl.core.internal.validation.XSLValidationMessage) ValidationMessage(org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage) ValidationReport(org.eclipse.wst.xml.core.internal.validation.core.ValidationReport) ValidationResult(org.eclipse.wst.validation.ValidationResult) StylesheetModel(org.eclipse.wst.xsl.core.model.StylesheetModel) ValidatorMessage(org.eclipse.wst.validation.ValidatorMessage)

Example 12 with StylesheetModel

use of org.eclipse.wst.xsl.core.model.StylesheetModel in project webtools.sourceediting by eclipse.

the class TemplateNameAttributeContentAssist method getCompletionProposals.

/* (non-Javadoc)
	 * @see org.eclipse.wst.xsl.ui.internal.contentassist.AbstractXSLContentAssistRequest#getCompletionProposals()
	 */
@Override
public ArrayList<ICompletionProposal> getCompletionProposals() {
    proposals.clear();
    StylesheetModel model = getStylesheetModel();
    List<CallTemplate> templates = model.getCallTemplates();
    for (CallTemplate template : templates) {
        CustomCompletionProposal proposal = createProposal(template);
        addUniqueProposal(proposal);
    }
    return getAllCompletionProposals();
}
Also used : CustomCompletionProposal(org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal) StylesheetModel(org.eclipse.wst.xsl.core.model.StylesheetModel) CallTemplate(org.eclipse.wst.xsl.core.model.CallTemplate)

Example 13 with StylesheetModel

use of org.eclipse.wst.xsl.core.model.StylesheetModel in project webtools.sourceediting by eclipse.

the class XSLHyperlinkDetector method createCallTemplateHyperLink.

private IHyperlink createCallTemplateHyperLink(IFile currentFile, String templateName, IRegion hyperlinkRegion) {
    IHyperlink hyperlink = null;
    StylesheetModel sf = XSLCore.getInstance().getStylesheet(currentFile);
    if (sf != null) {
        List<Template> templates = sf.getTemplatesByName(templateName);
        if (templates != null && templates.size() == 1) {
            Template template = templates.get(0);
            hyperlink = new SourceFileHyperlink(hyperlinkRegion, template.getStylesheet().getFile(), template);
        }
    }
    return hyperlink;
}
Also used : IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) StylesheetModel(org.eclipse.wst.xsl.core.model.StylesheetModel) Template(org.eclipse.wst.xsl.core.model.Template)

Aggregations

StylesheetModel (org.eclipse.wst.xsl.core.model.StylesheetModel)13 IFile (org.eclipse.core.resources.IFile)5 Template (org.eclipse.wst.xsl.core.model.Template)4 Path (org.eclipse.core.runtime.Path)2 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)2 CustomCompletionProposal (org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal)2 ValidationResult (org.eclipse.wst.validation.ValidationResult)2 XSLValidationReport (org.eclipse.wst.xsl.core.internal.validation.XSLValidationReport)2 XSLAttribute (org.eclipse.wst.xsl.core.model.XSLAttribute)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Position (org.eclipse.jface.text.Position)1 Annotation (org.eclipse.jface.text.source.Annotation)1 IAnnotationModelExtension (org.eclipse.jface.text.source.IAnnotationModelExtension)1 ValidatorMessage (org.eclipse.wst.validation.ValidatorMessage)1 IDOMAttr (org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr)1 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)1 ValidationMessage (org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage)1 ValidationReport (org.eclipse.wst.xml.core.internal.validation.core.ValidationReport)1