Search in sources :

Example 1 with StyleContainer

use of org.jboss.tools.jst.web.ui.internal.css.common.StyleContainer 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 StyleContainer

use of org.jboss.tools.jst.web.ui.internal.css.common.StyleContainer 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 StyleContainer

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

Example 4 with StyleContainer

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

the class CSSPropertyPage method selectionChanged.

@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    if ((this.part != part) && (selection instanceof IStructuredSelection)) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        Object newSelectedObject = structuredSelection.getFirstElement();
        // here we should process only elements of StyleContainer or set selection to null(clean)
        if (newSelectedObject == null || (newSelectedObject instanceof StyleContainer)) {
            selectedObject = newSelectedObject;
            update();
            /*
				 * https://issues.jboss.org/browse/JBIDE-9739
				 * {super} should be called after the selection has been updated.
				 * Because TabQuickEditControl's addContent() method uses
				 * getStyleAttributes() to fill in the tab content.
				 */
            super.selectionChanged(part, selection);
        }
    }
}
Also used : StyleContainer(org.jboss.tools.jst.web.ui.internal.css.common.StyleContainer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 5 with StyleContainer

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

the class CSSPreview method selectionChanged.

public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    if (selection instanceof IStructuredSelection) {
        Map<String, String> newAttributes;
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        if (structuredSelection.getFirstElement() instanceof StyleContainer) {
            newAttributes = ((StyleContainer) structuredSelection.getFirstElement()).getStyleAttributes();
        } else {
            newAttributes = Collections.emptyMap();
        }
        updateView(newAttributes);
    }
}
Also used : StyleContainer(org.jboss.tools.jst.web.ui.internal.css.common.StyleContainer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

StyleContainer (org.jboss.tools.jst.web.ui.internal.css.common.StyleContainer)5 IFile (org.eclipse.core.resources.IFile)3 StructuredTextEditor (org.eclipse.wst.sse.ui.StructuredTextEditor)3 CSSEditorView (org.jboss.tools.jst.web.ui.internal.css.view.CSSEditorView)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)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 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 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)1 CSSRule (org.w3c.dom.css.CSSRule)1