Search in sources :

Example 1 with DTDModelImpl

use of org.eclipse.wst.dtd.core.internal.document.DTDModelImpl in project webtools.sourceediting by eclipse.

the class DTDContentOutlineConfiguration method getMenuListener.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getMenuListener(org.eclipse.jface.viewers.TreeViewer)
	 */
public IMenuListener getMenuListener(TreeViewer viewer) {
    IMenuListener listener = null;
    if (fMenuHelper == null && viewer.getInput() instanceof DTDModelImpl) {
        fMenuHelper = new DTDContextMenuHelper((DTDModelImpl) viewer.getInput());
        fMenuHelper.createMenuListenersFor(viewer);
    }
    if (fMenuHelper != null) {
        listener = fMenuHelper.getMenuListener();
    }
    return listener;
}
Also used : DTDModelImpl(org.eclipse.wst.dtd.core.internal.document.DTDModelImpl) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 2 with DTDModelImpl

use of org.eclipse.wst.dtd.core.internal.document.DTDModelImpl in project webtools.sourceediting by eclipse.

the class DTDTreeContentProvider method getParents.

/**
 * @param element get the tree parents of this element
 * @return {@link List} of parents of the given element
 */
private List getParents(Object element) {
    List parents = new ArrayList();
    Object parent = null;
    if (element instanceof DTDNode) {
        DTDNode node = (DTDNode) element;
        if (element instanceof Attribute) {
            parent = node.getParentNode();
            if (parent != null && parent instanceof AttributeList) {
                parents.addAll(getElementParentsOfAttributeList((AttributeList) parent));
            }
        } else if (element instanceof AttributeList) {
            parents.addAll(getElementParentsOfAttributeList((AttributeList) element));
        }
        // acting as a parent in the tree
        if (isShowLogicalOrder()) {
            Object[] indexedNodeLists = getChildren(((DTDModelImpl) fInputObject).getDTDFile());
            for (int i = 0; i < indexedNodeLists.length && parent == null; i++) {
                if (indexedNodeLists[i] instanceof NodeList) {
                    if (((NodeList) indexedNodeLists[i]).getNodes().contains(element)) {
                        parents.add(indexedNodeLists[i]);
                    }
                }
            }
        }
        // try and get the simple parent
        parent = ((DTDNode) element).getParentNode();
        if (parent != null) {
            parents.add(parent);
        }
        // if no parents found must be new nodes so refresh from root
        if (parents.size() == 0) {
            parents.add(((DTDModelImpl) fInputObject).getDTDFile());
        }
    } else if (element instanceof NodeList && fInputObject instanceof DTDModelImpl) {
        parents.add(((DTDModelImpl) fInputObject).getDTDFile());
    }
    return parents;
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) DTDModelImpl(org.eclipse.wst.dtd.core.internal.document.DTDModelImpl) Attribute(org.eclipse.wst.dtd.core.internal.Attribute) AttributeList(org.eclipse.wst.dtd.core.internal.AttributeList) NodeList(org.eclipse.wst.dtd.core.internal.NodeList) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) AttributeList(org.eclipse.wst.dtd.core.internal.AttributeList) NodeList(org.eclipse.wst.dtd.core.internal.NodeList)

Example 3 with DTDModelImpl

use of org.eclipse.wst.dtd.core.internal.document.DTDModelImpl in project webtools.sourceediting by eclipse.

the class DTDFileTest method testGetTopLevelNodeAt.

public void testGetTopLevelNodeAt() throws Exception {
    IModelManager modelManager = StructuredModelManager.getModelManager();
    DTDModelImpl model = (DTDModelImpl) modelManager.createUnManagedStructuredModelFor(ContentTypeIdForDTD.ContentTypeID_DTD);
    String dtdText = "<!ELEMENT NewElement3 (#PCDATA)><!ENTITY % NewEntity SYSTEM \"\" >";
    IStructuredDocument document = model.getStructuredDocument();
    document.set(dtdText);
    model.setStructuredDocument(document);
    DTDFile dtdFile = model.getDTDFile();
    DTDNode dtdNode = dtdFile.getTopLevelNodeAt(32);
    assertNotNull("Node is null", dtdNode);
    assertEquals("Unexpected Node Type.", "NewEntity", dtdNode.getName());
}
Also used : DTDModelImpl(org.eclipse.wst.dtd.core.internal.document.DTDModelImpl) DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Example 4 with DTDModelImpl

use of org.eclipse.wst.dtd.core.internal.document.DTDModelImpl in project webtools.sourceediting by eclipse.

the class DTDModelTests method testcreateUnmanagedDTDModel.

public void testcreateUnmanagedDTDModel() {
    IModelManager modelManager = StructuredModelManager.getModelManager();
    IStructuredModel model = modelManager.createUnManagedStructuredModelFor(ContentTypeIdForDTD.ContentTypeID_DTD);
    assertTrue("Did not get DTD Model", model instanceof DTDModelImpl);
}
Also used : DTDModelImpl(org.eclipse.wst.dtd.core.internal.document.DTDModelImpl) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Aggregations

DTDModelImpl (org.eclipse.wst.dtd.core.internal.document.DTDModelImpl)4 DTDNode (org.eclipse.wst.dtd.core.internal.DTDNode)2 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 Attribute (org.eclipse.wst.dtd.core.internal.Attribute)1 AttributeList (org.eclipse.wst.dtd.core.internal.AttributeList)1 DTDFile (org.eclipse.wst.dtd.core.internal.DTDFile)1 NodeList (org.eclipse.wst.dtd.core.internal.NodeList)1 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)1 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)1