Search in sources :

Example 6 with Element

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

the class ContentModelNameSection method refresh.

/*
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
	 */
public void refresh() {
    Object input = getInput();
    if (input != null) {
        if (input instanceof CMBasicNode) {
            typeCombo.removeAll();
            typeCombo.add(CMNode.PCDATA);
            // NodeList list =
            // ((CMBasicNode)fInput).getDTDFile().getElementsAndParameterEntityReferences();
            Iterator iterator = ((CMBasicNode) input).getDTDFile().getNodes().iterator();
            boolean isForRootContent = ((CMBasicNode) input).isRootElementContent();
            while (iterator.hasNext()) {
                DTDNode node = (DTDNode) iterator.next();
                if (!isForRootContent && node instanceof Element)
                    typeCombo.add(node.getName());
                if (node instanceof Entity && ((Entity) node).isParameterEntity())
                    // $NON-NLS-1$ //$NON-NLS-2$
                    typeCombo.add("%" + node.getName() + ";");
            }
            typeCombo.setText(((CMBasicNode) input).getName());
        }
    }
}
Also used : Entity(org.eclipse.wst.dtd.core.internal.Entity) DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) Element(org.eclipse.wst.dtd.core.internal.Element) Iterator(java.util.Iterator) CMBasicNode(org.eclipse.wst.dtd.core.internal.CMBasicNode)

Example 7 with Element

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

the class DTDTreeContentProvider method expandToNode.

private void expandToNode(DTDNode node) {
    DTDFile dtdFile = node.getDTDFile();
    // first expand the root
    AbstractTreeViewer viewer = (AbstractTreeViewer) fViewer;
    viewer.expandToLevel(dtdFile, 1);
    NodeList listToExpand = null;
    if (node instanceof Element || node instanceof ParameterEntityReference) {
        listToExpand = dtdFile.getElementsAndParameterEntityReferences();
    } else if (node instanceof Notation) {
        listToExpand = dtdFile.getNotations();
    } else if (node instanceof Entity) {
        listToExpand = dtdFile.getEntities();
    } else if (node instanceof Comment) {
        listToExpand = dtdFile.getComments();
    }
    if (listToExpand != null) {
        viewer.expandToLevel(listToExpand, 1);
    }
    viewer.expandToLevel(node, 0);
}
Also used : ParameterEntityReference(org.eclipse.wst.dtd.core.internal.ParameterEntityReference) Entity(org.eclipse.wst.dtd.core.internal.Entity) Comment(org.eclipse.wst.dtd.core.internal.Comment) NodeList(org.eclipse.wst.dtd.core.internal.NodeList) Element(org.eclipse.wst.dtd.core.internal.Element) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) Notation(org.eclipse.wst.dtd.core.internal.Notation) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Example 8 with Element

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

the class AddAttributeAction method updateSelection.

protected boolean updateSelection(IStructuredSelection selection) {
    boolean rc = super.updateSelection(selection);
    DTDNode node = getFirstNodeSelected(selection);
    if (node instanceof Element) {
        // System.out.println("attribute set to true");
        setEnabled(true);
    } else {
        // System.out.println("attribute set to false");
        setEnabled(false);
    }
    return rc;
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) Element(org.eclipse.wst.dtd.core.internal.Element)

Example 9 with Element

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

the class DTDReferenceUpdater method nameAboutToChange.

public synchronized void nameAboutToChange(Object requestor, DTDNode referencedNode, String newName) {
    if (isUpdating) {
        return;
    }
    if (!(referencedNode instanceof Entity || referencedNode instanceof Element || referencedNode instanceof Notation)) {
        // just ignore if it is not one of these
        return;
    }
    if (referencedNode instanceof Entity && !((Entity) referencedNode).isParameterEntity()) {
        // if it is not a parameter entity, ignore as well
        return;
    }
    isUpdating = true;
    this.requestor = requestor;
    oldRefName = referencedNode.getName();
    this.newName = newRefName = newName;
    isParmEntity = false;
    isNotation = referencedNode instanceof Notation;
    if (referencedNode instanceof Entity) {
        isParmEntity = true;
        // $NON-NLS-1$ //$NON-NLS-2$
        oldRefName = "%" + oldRefName + ";";
        // $NON-NLS-1$ //$NON-NLS-2$
        newRefName = "%" + newRefName + ";";
    }
    if (this.referencedNode != null) {
        // change the previous regions
        if (this.referencedNode == referencedNode) {
            quickUpdate();
            isUpdating = false;
            return;
        }
    }
    // clear the cache if we get here
    this.referencedNode = referencedNode;
    references.clear();
    DTDFile dtdFile = referencedNode.getDTDFile();
    visit(dtdFile);
    isUpdating = false;
}
Also used : Entity(org.eclipse.wst.dtd.core.internal.Entity) Element(org.eclipse.wst.dtd.core.internal.Element) Notation(org.eclipse.wst.dtd.core.internal.Notation) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Example 10 with Element

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

the class DTDSectionLabelProvider method getText.

/**
 * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
 */
public String getText(Object object) {
    if (object == null || object.equals(StructuredSelection.EMPTY)) {
        return null;
    }
    Object selected = object;
    if (object instanceof IStructuredSelection) {
        selected = ((IStructuredSelection) object).getFirstElement();
    }
    if (selected instanceof DTDFile) {
        return ((DTDFile) selected).getName();
    } else if (selected instanceof CMBasicNode) {
        if (((CMBasicNode) selected).isReference())
            return DTDPropertiesMessages._UI_PROPERTIES_VIEW_TITLE_ELEMENT_REF;
        else
            return ((CMBasicNode) selected).getName();
    } else if (selected instanceof CMRepeatableNode) {
        CMRepeatableNode node = (CMRepeatableNode) selected;
        String name = node.getName();
        if (node instanceof CMGroupNode) {
            if (((CMGroupNode) node).getConnector() == CMGroupNode.CHOICE)
                name = DTDPropertiesMessages.DTDSectionLabelProvider_0;
            else
                name = DTDPropertiesMessages.DTDSectionLabelProvider_1;
        }
        char occurrence = node.getOccurrence();
        switch(occurrence) {
            case CMRepeatableNode.ONCE:
                // $NON-NLS-1$
                name += " [1..1]";
                break;
            case CMRepeatableNode.OPTIONAL:
                // $NON-NLS-1$
                name += " [0..1]";
                break;
            case CMRepeatableNode.ONE_OR_MORE:
                // $NON-NLS-1$
                name += " [1..*]";
                break;
            case CMRepeatableNode.ZERO_OR_MORE:
                // $NON-NLS-1$
                name += " [0..*]";
                break;
        }
        return name;
    } else if (selected instanceof DTDNode) {
        if (selected instanceof Element)
            return DTDPropertiesMessages.DTDSectionLabelProvider_6;
        else if (selected instanceof Attribute)
            return DTDPropertiesMessages.DTDSectionLabelProvider_7;
        else if (selected instanceof AttributeList)
            return DTDPropertiesMessages.DTDSectionLabelProvider_8;
        else if (selected instanceof Comment)
            return DTDPropertiesMessages.DTDSectionLabelProvider_9;
        else if (selected instanceof Entity)
            return DTDPropertiesMessages.DTDSectionLabelProvider_10;
        else if (selected instanceof Notation)
            return DTDPropertiesMessages.DTDSectionLabelProvider_11;
        else if (selected instanceof ParameterEntityReference)
            // return "parameter entity reference";
            return null;
        else
            return ((DTDNode) selected).getName();
    } else if (selected instanceof org.w3c.dom.Element) {
        return ((org.w3c.dom.Element) selected).getLocalName();
    } else if (object instanceof ITextSelection) {
        // $NON-NLS-1$
        return "";
    } else
        return object.toString();
}
Also used : Comment(org.eclipse.wst.dtd.core.internal.Comment) Entity(org.eclipse.wst.dtd.core.internal.Entity) CMRepeatableNode(org.eclipse.wst.dtd.core.internal.CMRepeatableNode) Attribute(org.eclipse.wst.dtd.core.internal.Attribute) AttributeList(org.eclipse.wst.dtd.core.internal.AttributeList) Element(org.eclipse.wst.dtd.core.internal.Element) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CMGroupNode(org.eclipse.wst.dtd.core.internal.CMGroupNode) Notation(org.eclipse.wst.dtd.core.internal.Notation) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile) ITextSelection(org.eclipse.jface.text.ITextSelection) ParameterEntityReference(org.eclipse.wst.dtd.core.internal.ParameterEntityReference) DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) CMBasicNode(org.eclipse.wst.dtd.core.internal.CMBasicNode)

Aggregations

Element (org.eclipse.wst.dtd.core.internal.Element)15 DTDNode (org.eclipse.wst.dtd.core.internal.DTDNode)12 DTDFile (org.eclipse.wst.dtd.core.internal.DTDFile)8 Entity (org.eclipse.wst.dtd.core.internal.Entity)6 Iterator (java.util.Iterator)5 AttributeList (org.eclipse.wst.dtd.core.internal.AttributeList)5 CMGroupNode (org.eclipse.wst.dtd.core.internal.CMGroupNode)4 CMNode (org.eclipse.wst.dtd.core.internal.CMNode)4 NodeList (org.eclipse.wst.dtd.core.internal.NodeList)4 CMBasicNode (org.eclipse.wst.dtd.core.internal.CMBasicNode)3 Notation (org.eclipse.wst.dtd.core.internal.Notation)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Comment (org.eclipse.wst.dtd.core.internal.Comment)2 ParameterEntityReference (org.eclipse.wst.dtd.core.internal.ParameterEntityReference)2 Separator (org.eclipse.jface.action.Separator)1 ITextSelection (org.eclipse.jface.text.ITextSelection)1 AbstractTreeViewer (org.eclipse.jface.viewers.AbstractTreeViewer)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 Attribute (org.eclipse.wst.dtd.core.internal.Attribute)1