Search in sources :

Example 1 with CSSEditorView

use of org.jboss.tools.jst.web.ui.internal.css.view.CSSEditorView in project jbosstools-jst by jbosstools.

the class ExtendingCSSViewTest_JBIDE4850 method testInlineStyleEditing.

public void testInlineStyleEditing() throws CoreException, SecurityException, IllegalArgumentException, NoSuchFieldException, IllegalAccessException {
    IFile pageFile = getComponentPath(TEST_PAGE_NAME, getProjectName());
    assertNotNull(pageFile);
    StructuredTextEditor editor = (StructuredTextEditor) openEditor(pageFile, JSP_EDITOR_ID);
    JobUtils.waitForIdle();
    assertNotNull(editor);
    CSSEditorView view = (CSSEditorView) openView(CSS_EDITOR_VIEW);
    assertNotNull(view);
    IDOMModel model = (IDOMModel) getStructuredModel(pageFile);
    assertNotNull(model);
    IDOMDocument document = model.getDocument();
    assertNotNull(document);
    Element element = document.getElementById(TESTED_ELEMENT_ID);
    assertNotNull(element);
    int offset = ((IndexedRegion) element).getStartOffset();
    setSelection(editor, offset, 0);
    Object selectedObject = getSelectedObject(view);
    assertTrue(selectedObject instanceof StyleContainer);
    assertSame(element, ((StyleContainer) selectedObject).getStyleObject());
}
Also used : CSSEditorView(org.jboss.tools.jst.web.ui.internal.css.view.CSSEditorView) IFile(org.eclipse.core.resources.IFile) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) StyleContainer(org.jboss.tools.jst.web.ui.internal.css.common.StyleContainer) Element(org.w3c.dom.Element) IDOMElement(org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor) IndexedRegion(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)

Example 2 with CSSEditorView

use of org.jboss.tools.jst.web.ui.internal.css.view.CSSEditorView in project jbosstools-jst by jbosstools.

the class ExtendingCSSViewTest_JBIDE4850 method testStyleTagEditing.

public void testStyleTagEditing() throws CoreException, SecurityException, IllegalArgumentException, NoSuchFieldException, IllegalAccessException {
    IFile pageFile = getComponentPath(TEST_PAGE_NAME, getProjectName());
    assertNotNull(pageFile);
    StructuredTextEditor editor = (StructuredTextEditor) openEditor(pageFile, JSP_EDITOR_ID);
    JobUtils.waitForIdle();
    assertNotNull(editor);
    CSSEditorView view = (CSSEditorView) openView(CSS_EDITOR_VIEW);
    assertNotNull(view);
    IDOMModel model = (IDOMModel) getStructuredModel(pageFile);
    assertNotNull(model);
    IDOMDocument document = model.getDocument();
    assertNotNull(document);
    Element element = document.getElementById(TESTED_STYLE_ID);
    assertNotNull(element);
    int offset = ((IDOMElement) element).getStartEndOffset();
    setSelection(editor, offset, 0);
    Object selectedObject = getSelectedObject(view);
    assertTrue(selectedObject instanceof StyleContainer);
}
Also used : CSSEditorView(org.jboss.tools.jst.web.ui.internal.css.view.CSSEditorView) IFile(org.eclipse.core.resources.IFile) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) StyleContainer(org.jboss.tools.jst.web.ui.internal.css.common.StyleContainer) Element(org.w3c.dom.Element) IDOMElement(org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor) IDOMElement(org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement)

Example 3 with CSSEditorView

use of org.jboss.tools.jst.web.ui.internal.css.view.CSSEditorView 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)

Example 4 with CSSEditorView

use of org.jboss.tools.jst.web.ui.internal.css.view.CSSEditorView in project jbosstools-jst by jbosstools.

the class NotCompletedCSS_JBIDE4677 method testNotCompletedCSS.

public void testNotCompletedCSS() throws CoreException, SecurityException, IllegalArgumentException, NoSuchFieldException, IllegalAccessException {
    IFile pageFile = getComponentPath(TEST_PAGE_NAME, getProjectName());
    assertNotNull(pageFile);
    StructuredTextEditor editor = (StructuredTextEditor) openEditor(pageFile, CSS_EDITOR_ID);
    JobUtils.waitForIdle();
    assertNotNull(editor);
    CSSEditorView view = (CSSEditorView) openView(CSS_EDITOR_VIEW);
    assertNotNull(view);
    IPage page = view.getCurrentPage();
    assertNotNull(page);
    StructuredSelection selection = (StructuredSelection) ((CSSPropertyPage) page).getCurrentSelection();
    assertNotNull(selection);
    assertNull(selection.getFirstElement());
}
Also used : CSSEditorView(org.jboss.tools.jst.web.ui.internal.css.view.CSSEditorView) IPage(org.eclipse.ui.part.IPage) IFile(org.eclipse.core.resources.IFile) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor)

Example 5 with CSSEditorView

use of org.jboss.tools.jst.web.ui.internal.css.view.CSSEditorView in project jbosstools-jst by jbosstools.

the class CSSViewTest method testEditorViewSelection.

/**
 * @throws PartInitException
 * @throws CoreException
 * @throws NoSuchFieldException
 * @throws SecurityException
 * @throws IllegalAccessException
 * @throws IllegalArgumentException
 */
public void testEditorViewSelection() throws PartInitException, CoreException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    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);
    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);
    Object selectedObject = getSelectedObject(view);
    assertTrue(selectedObject instanceof StyleContainer);
    assertEquals(cssRule, ((StyleContainer) selectedObject).getStyleObject());
    setSelection(editor, 0, 0);
    selectedObject = getSelectedObject(view);
    assertNull(selectedObject);
}
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) StyleContainer(org.jboss.tools.jst.web.ui.internal.css.common.StyleContainer) ICSSStyleSheet(org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor)

Aggregations

IFile (org.eclipse.core.resources.IFile)9 StructuredTextEditor (org.eclipse.wst.sse.ui.StructuredTextEditor)9 CSSEditorView (org.jboss.tools.jst.web.ui.internal.css.view.CSSEditorView)9 CSSStructuredDocumentRegionContainer (org.eclipse.wst.css.core.internal.document.CSSStructuredDocumentRegionContainer)4 ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)4 ICSSStyleSheet (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet)4 CSSPropertyPage (org.jboss.tools.jst.web.ui.internal.css.properties.CSSPropertyPage)4 CSSRule (org.w3c.dom.css.CSSRule)4 IPage (org.eclipse.ui.part.IPage)3 StyleContainer (org.jboss.tools.jst.web.ui.internal.css.common.StyleContainer)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)2 IDOMElement (org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement)2 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)2 Element (org.w3c.dom.Element)2 Method (java.lang.reflect.Method)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 Tree (org.eclipse.swt.widgets.Tree)1 TabbedPropertyRegistry (org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyRegistry)1 TabbedPropertyViewer (org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyViewer)1