Search in sources :

Example 1 with StyleAttributes

use of org.jboss.tools.jst.web.ui.internal.css.dialog.common.StyleAttributes in project jbosstools-jst by jbosstools.

the class InputFractionalValueTest_JBIDE4790 method testInputFractionalValue.

public void testInputFractionalValue() throws CoreException {
    IFile pageFile = getComponentPath(TEST_PAGE_NAME, getProjectName());
    assertNotNull(pageFile);
    StructuredTextEditor editor = (StructuredTextEditor) openEditor(pageFile, CSS_EDITOR_ID);
    assertNotNull(editor);
    CSSEditorView view = (CSSEditorView) openView(CSS_EDITOR_VIEW);
    assertNotNull(view);
    CSSPropertyPage page = (CSSPropertyPage) view.getCurrentPage();
    assertNotNull(page);
    ICSSModel model = (ICSSModel) getStructuredModel(pageFile);
    assertNotNull(model);
    ICSSStyleSheet document = (ICSSStyleSheet) model.getDocument();
    assertNotNull(document);
    CSSRule cssRule = document.getCssRules().item(0);
    assertNotNull(cssRule);
    int offset = ((CSSStructuredDocumentRegionContainer) cssRule).getStartOffset();
    setSelection(editor, offset, 0);
    CSSStyleDeclaration declaration = ((CSSStyleRule) cssRule).getStyle();
    String testedValue = declaration.getPropertyValue(TEST_CSS_ATTRIBUTE_NAME);
    assertNotNull(testedValue);
    StyleAttributes styleAttributes = page.getStyleAttributes();
    assertEquals(testedValue, styleAttributes.get(TEST_CSS_ATTRIBUTE_NAME));
    String[] parsedTestValue = Util.convertExtString(testedValue);
    assertEquals(parsedTestValue.length, 2);
    // $NON-NLS-1$
    String newTestedValue = removeWhitespaces(parsedTestValue[0]) + "3" + parsedTestValue[1];
    try {
        styleAttributes.put(TEST_CSS_ATTRIBUTE_NAME, newTestedValue);
    } catch (DOMException e) {
        // $NON-NLS-1$
        fail("Changing of attribute's value leads to DOMException. Probably it is problem concerned with of JBIDE-4790 ");
    }
    testedValue = declaration.getPropertyValue(TEST_CSS_ATTRIBUTE_NAME);
    assertNotNull(testedValue);
    assertEquals(removeWhitespaces(testedValue), removeWhitespaces(newTestedValue));
}
Also used : CSSEditorView(org.jboss.tools.jst.web.ui.internal.css.view.CSSEditorView) IFile(org.eclipse.core.resources.IFile) CSSRule(org.w3c.dom.css.CSSRule) CSSStructuredDocumentRegionContainer(org.eclipse.wst.css.core.internal.document.CSSStructuredDocumentRegionContainer) ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) ICSSStyleSheet(org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet) CSSStyleDeclaration(org.w3c.dom.css.CSSStyleDeclaration) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor) DOMException(org.w3c.dom.DOMException) StyleAttributes(org.jboss.tools.jst.web.ui.internal.css.dialog.common.StyleAttributes) CSSPropertyPage(org.jboss.tools.jst.web.ui.internal.css.properties.CSSPropertyPage) CSSStyleRule(org.w3c.dom.css.CSSStyleRule)

Aggregations

IFile (org.eclipse.core.resources.IFile)1 CSSStructuredDocumentRegionContainer (org.eclipse.wst.css.core.internal.document.CSSStructuredDocumentRegionContainer)1 ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)1 ICSSStyleSheet (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet)1 StructuredTextEditor (org.eclipse.wst.sse.ui.StructuredTextEditor)1 StyleAttributes (org.jboss.tools.jst.web.ui.internal.css.dialog.common.StyleAttributes)1 CSSPropertyPage (org.jboss.tools.jst.web.ui.internal.css.properties.CSSPropertyPage)1 CSSEditorView (org.jboss.tools.jst.web.ui.internal.css.view.CSSEditorView)1 DOMException (org.w3c.dom.DOMException)1 CSSRule (org.w3c.dom.css.CSSRule)1 CSSStyleDeclaration (org.w3c.dom.css.CSSStyleDeclaration)1 CSSStyleRule (org.w3c.dom.css.CSSStyleRule)1