Search in sources :

Example 11 with Template

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

the class XSLWorkbenchAdapter method getLabel.

public String getLabel(Object o) {
    String label = null;
    XSLModelObject obj = (XSLModelObject) o;
    switch(obj.getModelType()) {
        case STYLESHEET:
            Stylesheet stylesheet = (Stylesheet) obj;
            label = stylesheet.getVersion() == null ? "?" : // $NON-NLS-1$
            stylesheet.getVersion();
            break;
        case IMPORT:
            Import imp = (Import) obj;
            label = imp.getHref();
            break;
        case INCLUDE:
            Include inc = (Include) obj;
            label = inc.getHref();
            break;
        case TEMPLATE:
            Template t = (Template) obj;
            StringBuffer sb = new StringBuffer();
            if (t.getName() != null)
                // $NON-NLS-1$
                sb.append(t.getName()).append(" ");
            if (t.getMatch() != null)
                // $NON-NLS-1$
                sb.append(t.getMatch()).append(" ");
            if (t.getMode() != null)
                // $NON-NLS-1$//$NON-NLS-2$
                sb.append("(").append(t.getMode()).append(")");
            label = sb.toString();
            break;
        case VARIABLE:
            Variable v = (Variable) obj;
            label = v.getName();
            break;
        case FUNCTION:
            Function f = (Function) obj;
            label = f.getName();
    }
    return label;
}
Also used : Function(org.eclipse.wst.xsl.core.model.Function) Import(org.eclipse.wst.xsl.core.model.Import) Variable(org.eclipse.wst.xsl.core.model.Variable) XSLModelObject(org.eclipse.wst.xsl.core.model.XSLModelObject) Include(org.eclipse.wst.xsl.core.model.Include) Stylesheet(org.eclipse.wst.xsl.core.model.Stylesheet) Template(org.eclipse.wst.xsl.core.model.Template)

Example 12 with Template

use of org.eclipse.wst.xsl.core.model.Template 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

Template (org.eclipse.wst.xsl.core.model.Template)12 StylesheetModel (org.eclipse.wst.xsl.core.model.StylesheetModel)4 XSLAttribute (org.eclipse.wst.xsl.core.model.XSLAttribute)4 CallTemplate (org.eclipse.wst.xsl.core.model.CallTemplate)3 Parameter (org.eclipse.wst.xsl.core.model.Parameter)3 ArrayList (java.util.ArrayList)2 IFile (org.eclipse.core.resources.IFile)2 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)2 CustomCompletionProposal (org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal)2 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)2 Function (org.eclipse.wst.xsl.core.model.Function)2 Stylesheet (org.eclipse.wst.xsl.core.model.Stylesheet)2 XSLModelObject (org.eclipse.wst.xsl.core.model.XSLModelObject)2 Test (org.junit.Test)2 Node (org.w3c.dom.Node)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Path (org.eclipse.core.runtime.Path)1 Position (org.eclipse.jface.text.Position)1