Search in sources :

Example 6 with DTDNode

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

the class DragContentModelCommand method execute.

public void execute() {
    DTDNode referenceNode = (DTDNode) target;
    if (referenceNode instanceof CMNode) {
        DTDFile dtdFile = referenceNode.getDTDFile();
        DTDNode parent = (DTDNode) referenceNode.getParentNode();
        // $NON-NLS-1$
        dtdFile.getDTDModel().beginRecording(this, DTDUIMessages._UI_MOVE_CONTENT);
        boolean parentIsElement = false;
        Element element = null;
        CMGroupNode group = null;
        if (parent instanceof Element) {
            parentIsElement = true;
            element = (Element) parent;
        } else {
            group = (CMGroupNode) parent;
        }
        if (element == null && group == null) {
            // no parent to add to
            return;
        }
        Iterator iter = sources.iterator();
        while (iter.hasNext()) {
            DTDNode node = (DTDNode) iter.next();
            if (node instanceof CMNode) {
                if (parentIsElement) {
                    if (element.getContentModel() == node) {
                        continue;
                    }
                    element.replaceContentModel(this, (CMNode) node);
                } else {
                    if (referenceNode == node || (isAfter() && referenceNode.getNextSibling() == node) || (!isAfter() && node.getNextSibling() == referenceNode)) {
                        continue;
                    }
                    group.insertIntoModel(this, (CMNode) referenceNode, (CMNode) node, isAfter());
                }
                DTDNode nodeParent = (DTDNode) node.getParentNode();
                nodeParent.delete(this, node);
            }
        }
        dtdFile.getDTDModel().endRecording(this);
    }
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) Element(org.eclipse.wst.dtd.core.internal.Element) Iterator(java.util.Iterator) CMNode(org.eclipse.wst.dtd.core.internal.CMNode) CMGroupNode(org.eclipse.wst.dtd.core.internal.CMGroupNode) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Example 7 with DTDNode

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

the class ContentModelTypeSection 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 CMNode) {
            typeCombo.removeAll();
            typeCombo.add(CMNode.ANY);
            typeCombo.add(CMNode.EMPTY);
            typeCombo.add(CMNode.PCDATA);
            typeCombo.add(CMNode.CHILDREN);
            typeCombo.add(CMNode.MIXED);
            Iterator iterator = ((CMNode) input).getDTDFile().getNodes().iterator();
            String nodeName = null;
            while (iterator.hasNext()) {
                DTDNode node = (DTDNode) iterator.next();
                nodeName = node.getName();
                if (node instanceof Element && typeCombo.indexOf(nodeName) == -1)
                    typeCombo.add(nodeName);
                else if (node instanceof Entity && ((Entity) node).isParameterEntity() && typeCombo.indexOf(nodeName) == -1)
                    // $NON-NLS-1$ //$NON-NLS-2$
                    typeCombo.add("%" + nodeName + ";");
            }
            if (input instanceof CMGroupNode)
                typeCombo.setText(((CMGroupNode) input).getType());
            else if (input instanceof CMBasicNode)
                typeCombo.setText(((CMBasicNode) input).getType());
        }
    }
// end if (fInput != null)
}
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) CMNode(org.eclipse.wst.dtd.core.internal.CMNode) CMGroupNode(org.eclipse.wst.dtd.core.internal.CMGroupNode) CMBasicNode(org.eclipse.wst.dtd.core.internal.CMBasicNode)

Example 8 with DTDNode

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

the class NameSection method doHandleEvent.

public void doHandleEvent(Event event) {
    if (event.widget == nameText) {
        Object input = getInput();
        String newValue = nameText.getText();
        if (newValue.length() > 0 && input instanceof DTDNode) {
            DTDNode dtdNode = (DTDNode) input;
            dtdNode.setName(newValue);
        }
    }
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode)

Example 9 with DTDNode

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

the class AddAttributeListAction method run.

public void run() {
    DTDNode selectedNode = getFirstNodeSelected();
    DTDFile dtdFile = getModel().getDTDFile();
    // $NON-NLS-1$
    String attListName = "NewAttList";
    if (selectedNode != null) {
        DTDNode topLevelNode = dtdFile.getTopLevelNodeAt(selectedNode.getStartOffset());
        if (topLevelNode instanceof Element) {
            attListName = ((Element) topLevelNode).getName();
        }
    }
    getModel().getDTDFile().createAttributeList(selectedNode, attListName, true);
// newElement.setName(DTDUniqueNameHelper.getUniqueElementName(dtdFile));
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) Element(org.eclipse.wst.dtd.core.internal.Element) DTDFile(org.eclipse.wst.dtd.core.internal.DTDFile)

Example 10 with DTDNode

use of org.eclipse.wst.dtd.core.internal.DTDNode 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)

Aggregations

DTDNode (org.eclipse.wst.dtd.core.internal.DTDNode)32 DTDFile (org.eclipse.wst.dtd.core.internal.DTDFile)13 Element (org.eclipse.wst.dtd.core.internal.Element)13 Iterator (java.util.Iterator)9 AttributeList (org.eclipse.wst.dtd.core.internal.AttributeList)8 NodeList (org.eclipse.wst.dtd.core.internal.NodeList)6 CMGroupNode (org.eclipse.wst.dtd.core.internal.CMGroupNode)5 CMNode (org.eclipse.wst.dtd.core.internal.CMNode)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 Attribute (org.eclipse.wst.dtd.core.internal.Attribute)4 CMBasicNode (org.eclipse.wst.dtd.core.internal.CMBasicNode)3 Comment (org.eclipse.wst.dtd.core.internal.Comment)3 Entity (org.eclipse.wst.dtd.core.internal.Entity)3 Image (org.eclipse.swt.graphics.Image)2 ParameterEntityReference (org.eclipse.wst.dtd.core.internal.ParameterEntityReference)2 TopLevelNode (org.eclipse.wst.dtd.core.internal.TopLevelNode)2 DTDModelImpl (org.eclipse.wst.dtd.core.internal.document.DTDModelImpl)2 Separator (org.eclipse.jface.action.Separator)1