Search in sources :

Example 1 with Attribute

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

the class DTDDragAndDropManager method createCommand.

public DragAndDropCommand createCommand(Object target, float location, int operations, int operation, Collection source) {
    if (target instanceof DTDNode) {
        DTDNode node = (DTDNode) target;
        source = mergeSource(source);
        if (node instanceof TopLevelNode) {
            return new DragTopLevelNodesCommand(target, location, operations, operation, source);
        }
        if (node instanceof Attribute) {
            return new DragAttributeCommand(target, location, operations, operation, source);
        }
        if (node instanceof CMNode) {
            return new DragContentModelCommand(target, location, operations, operation, source);
        }
    }
    return null;
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) Attribute(org.eclipse.wst.dtd.core.internal.Attribute) CMNode(org.eclipse.wst.dtd.core.internal.CMNode) TopLevelNode(org.eclipse.wst.dtd.core.internal.TopLevelNode)

Example 2 with Attribute

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

the class TypeSection method widgetSelected.

/**
 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(SelectionEvent)
 */
public void widgetSelected(SelectionEvent e) {
    if (e.widget == typeCombo) {
        Object input = getInput();
        if (input instanceof Attribute) {
            Attribute attribute = (Attribute) input;
            attribute.setType(typeCombo.getText());
        }
    }
}
Also used : Attribute(org.eclipse.wst.dtd.core.internal.Attribute)

Example 3 with Attribute

use of org.eclipse.wst.dtd.core.internal.Attribute 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 4 with Attribute

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

the class DTDVisitor method visitAttributes.

public void visitAttributes(List attributes) {
    int size = attributes.size();
    for (int i = 0; i < size; i++) {
        Attribute attr = (Attribute) attributes.get(i);
        visitAttribute(attr);
    }
}
Also used : Attribute(org.eclipse.wst.dtd.core.internal.Attribute)

Example 5 with Attribute

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

the class AttributeDefaultSection method widgetSelected.

public void widgetSelected(SelectionEvent e) {
    if (e.widget == usageCombo) {
        Object input = getInput();
        if (input instanceof Attribute) {
            String usage = usageCombo.getText();
            Attribute attribute = (Attribute) input;
            if (usage.equals(DTDPropertiesMessages._UI_DEFAULT))
                // $NON-NLS-1$
                attribute.setDefaultKind("");
            else
                attribute.setDefaultKind(usage);
            if (DTDPropertiesMessages._UI_DEFAULT.equals(usage) || FIXED.equals(usage)) {
                defaultValueLabel.setVisible(true);
                defaultValueText.setVisible(true);
                defaultValueText.setEnabled(true);
            } else {
                defaultValueLabel.setVisible(false);
                defaultValueText.setVisible(false);
                defaultValueText.setEnabled(false);
            }
        }
    }
}
Also used : Attribute(org.eclipse.wst.dtd.core.internal.Attribute)

Aggregations

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