Search in sources :

Example 6 with Stylesheet

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

the class TestStylesheet method testGetColumnNumber.

@Test
public void testGetColumnNumber() {
    Stylesheet stylesheet = builder.getStylesheet(getFile("globalVariablesTest.xsl"), false);
    assertNotNull("Model failed to load, returned NULL", stylesheet);
    // Line Number is off by 1 from what is displayed in the Editor
    assertEquals("Incorrect column number.", 0, stylesheet.getColumnNumber());
}
Also used : Stylesheet(org.eclipse.wst.xsl.core.model.Stylesheet) Test(org.junit.Test)

Example 7 with Stylesheet

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

the class TestStylesheet method testgetLocalTemplatesTemplates.

@Test
public void testgetLocalTemplatesTemplates() {
    Stylesheet model = builder.getStylesheet(getFile("style1.xsl"), false);
    assertNotNull("Model failed to load, returned NULL", model);
    List<Template> templatesList = model.getTemplates();
    assertEquals("Wrong number of templates returned.", 2, templatesList.size());
}
Also used : Stylesheet(org.eclipse.wst.xsl.core.model.Stylesheet) Template(org.eclipse.wst.xsl.core.model.Template) Test(org.junit.Test)

Example 8 with Stylesheet

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

the class TestStylesheet method testGetLineNumber.

@Test
public void testGetLineNumber() {
    Stylesheet stylesheet = builder.getStylesheet(getFile("globalVariablesTest.xsl"), false);
    assertNotNull("Model failed to load, returned NULL", stylesheet);
    // Line Number is off by 1 from what is displayed in the Editor
    assertEquals("Incorrect line number.", 12, stylesheet.getLineNumber());
}
Also used : Stylesheet(org.eclipse.wst.xsl.core.model.Stylesheet) Test(org.junit.Test)

Example 9 with Stylesheet

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

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

the class XSLCore method buildStylesheet.

/**
 * Completely rebuild the source file from its DOM
 *
 * @param file
 * @return the stylesheet model, or null if it could not be created.
 * @since 1.0
 */
public synchronized StylesheetModel buildStylesheet(IFile file) {
    Stylesheet stylesheet = StylesheetBuilder.getInstance().getStylesheet(file, true);
    if (stylesheet == null)
        return null;
    StylesheetModel stylesheetComposed = new StylesheetModel(stylesheet);
    stylesheetsComposed.put(file, stylesheetComposed);
    stylesheetComposed.fix();
    return stylesheetComposed;
}
Also used : StylesheetModel(org.eclipse.wst.xsl.core.model.StylesheetModel) Stylesheet(org.eclipse.wst.xsl.core.model.Stylesheet)

Aggregations

Stylesheet (org.eclipse.wst.xsl.core.model.Stylesheet)19 Test (org.junit.Test)12 Function (org.eclipse.wst.xsl.core.model.Function)3 Import (org.eclipse.wst.xsl.core.model.Import)2 Include (org.eclipse.wst.xsl.core.model.Include)2 Template (org.eclipse.wst.xsl.core.model.Template)2 Variable (org.eclipse.wst.xsl.core.model.Variable)2 XSLModelObject (org.eclipse.wst.xsl.core.model.XSLModelObject)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)1 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)1 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)1 StylesheetModel (org.eclipse.wst.xsl.core.model.StylesheetModel)1 XSLAttribute (org.eclipse.wst.xsl.core.model.XSLAttribute)1