Search in sources :

Example 1 with XSLModelObject

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

the class XSLWorkbenchAdapter method getImageDescriptor.

public ImageDescriptor getImageDescriptor(Object object) {
    XSLModelObject obj = (XSLModelObject) object;
    String path = null;
    switch(obj.getModelType()) {
        case STYLESHEET:
            path = XSLPluginImages.IMG_ELM_STYLESHET;
            break;
        case IMPORT:
        case INCLUDE:
            path = XSLPluginImages.IMG_ELM_IMPORT_INCLUDE;
            break;
        case TEMPLATE:
            {
                Template template = (Template) obj;
                if (template.getName() != null) {
                    path = XSLPluginImages.IMG_ELM_TEMPLATE_NAME;
                } else {
                    path = XSLPluginImages.IMG_ELM_TEMPLATE;
                }
                break;
            }
        case VARIABLE:
            path = XSLPluginImages.IMG_ELM_VARIABLE;
            break;
        case FUNCTION:
            path = XSLPluginImages.IMG_ELM_FUNCTION;
            break;
    }
    return path == null ? null : AbstractUIPlugin.imageDescriptorFromPlugin(XSLUIPlugin.PLUGIN_ID, path);
}
Also used : XSLModelObject(org.eclipse.wst.xsl.core.model.XSLModelObject) Template(org.eclipse.wst.xsl.core.model.Template)

Example 2 with XSLModelObject

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

the class XSLWorkbenchAdapter method getChildren.

public Object[] getChildren(Object o) {
    if (o instanceof XSLModelObject) {
        XSLModelObject obj = (XSLModelObject) o;
        switch(obj.getModelType()) {
            case STYLESHEET:
                Stylesheet stylesheet = (Stylesheet) obj;
                ArrayList modelItems = new ArrayList();
                modelItems.add(new ListWorkbenchAdapter(stylesheet, null, stylesheet.getVersion(), XSLPluginImages.IMG_ELM_STYLESHET));
                // $NON-NLS-1$
                modelItems.add(new ListWorkbenchAdapter(stylesheet, stylesheet.getImports(), "Imports", XSLPluginImages.IMG_ELM_IMPORT_INCLUDE));
                // $NON-NLS-1$
                modelItems.add(new ListWorkbenchAdapter(stylesheet, stylesheet.getIncludes(), "Includes", XSLPluginImages.IMG_ELM_IMPORT_INCLUDE));
                // $NON-NLS-1$
                modelItems.add(new ListWorkbenchAdapter(stylesheet, stylesheet.getGlobalVariables(), "Variables", XSLPluginImages.IMG_ELM_VARIABLE));
                // $NON-NLS-1$
                modelItems.add(new ListWorkbenchAdapter(stylesheet, stylesheet.getTemplates(), "Templates", XSLPluginImages.IMG_ELM_TEMPLATE));
                if (stylesheet.getFunctions().size() > 0) {
                    // $NON-NLS-1$
                    modelItems.add(new ListWorkbenchAdapter(stylesheet, stylesheet.getTemplates(), "Functions", XSLPluginImages.IMG_ELM_FUNCTION));
                }
                return modelItems.toArray();
        }
    }
    return EMPTY;
}
Also used : XSLModelObject(org.eclipse.wst.xsl.core.model.XSLModelObject) ArrayList(java.util.ArrayList) Stylesheet(org.eclipse.wst.xsl.core.model.Stylesheet)

Example 3 with XSLModelObject

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

Aggregations

XSLModelObject (org.eclipse.wst.xsl.core.model.XSLModelObject)3 Stylesheet (org.eclipse.wst.xsl.core.model.Stylesheet)2 Template (org.eclipse.wst.xsl.core.model.Template)2 ArrayList (java.util.ArrayList)1 Function (org.eclipse.wst.xsl.core.model.Function)1 Import (org.eclipse.wst.xsl.core.model.Import)1 Include (org.eclipse.wst.xsl.core.model.Include)1 Variable (org.eclipse.wst.xsl.core.model.Variable)1