Search in sources :

Example 1 with CMGroupNode

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

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

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

the class ContentModelGroupSection method refresh.

/*
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
	 */
public void refresh() {
    setListenerEnabled(false);
    Object input = getInput();
    if (input != null) {
        if (input instanceof CMGroupNode) {
            CMGroupNode node = (CMGroupNode) input;
            char modelType = node.getConnector();
            if (CMGroupNode.CHOICE == modelType)
                modelGroupCombo.setText(CHOICE);
            else if (CMGroupNode.SEQUENCE == modelType)
                modelGroupCombo.setText(SEQUENCE);
        }
    }
    setListenerEnabled(true);
}
Also used : CMGroupNode(org.eclipse.wst.dtd.core.internal.CMGroupNode)

Example 4 with CMGroupNode

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

the class AddElementToContentModelAction method updateSelection.

protected boolean updateSelection(IStructuredSelection selection) {
    boolean rc = super.updateSelection(selection);
    DTDNode node = getFirstNodeSelected(selection);
    if (node instanceof CMGroupNode) {
        setEnabled(true);
    } else {
        setEnabled(false);
    }
    return rc;
}
Also used : DTDNode(org.eclipse.wst.dtd.core.internal.DTDNode) CMGroupNode(org.eclipse.wst.dtd.core.internal.CMGroupNode)

Example 5 with CMGroupNode

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

the class ContentModelTypeSection method widgetSelected.

public void widgetSelected(SelectionEvent e) {
    if (e.widget == typeCombo) {
        Object input = getInput();
        if (input instanceof CMGroupNode || input instanceof CMBasicNode) {
            CMNode node = (CMNode) input;
            String selected = typeCombo.getText();
            if (CMNode.MIXED.equals(selected))
                node.setMixedContent();
            else if (CMNode.CHILDREN.equals(selected))
                // $NON-NLS-1$
                node.setChildrenContent("");
            else if (CMNode.EMPTY.equals(selected) || CMNode.ANY.equals(selected) || CMNode.PCDATA.equals(selected))
                node.setContent(selected);
            else
                node.setChildrenContent(selected);
        }
    }
}
Also used : CMNode(org.eclipse.wst.dtd.core.internal.CMNode) CMGroupNode(org.eclipse.wst.dtd.core.internal.CMGroupNode) CMBasicNode(org.eclipse.wst.dtd.core.internal.CMBasicNode)

Aggregations

CMGroupNode (org.eclipse.wst.dtd.core.internal.CMGroupNode)7 DTDNode (org.eclipse.wst.dtd.core.internal.DTDNode)5 CMNode (org.eclipse.wst.dtd.core.internal.CMNode)4 Element (org.eclipse.wst.dtd.core.internal.Element)4 CMBasicNode (org.eclipse.wst.dtd.core.internal.CMBasicNode)3 DTDFile (org.eclipse.wst.dtd.core.internal.DTDFile)3 Iterator (java.util.Iterator)2 AttributeList (org.eclipse.wst.dtd.core.internal.AttributeList)2 Entity (org.eclipse.wst.dtd.core.internal.Entity)2 Separator (org.eclipse.jface.action.Separator)1 ITextSelection (org.eclipse.jface.text.ITextSelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 Attribute (org.eclipse.wst.dtd.core.internal.Attribute)1 CMRepeatableNode (org.eclipse.wst.dtd.core.internal.CMRepeatableNode)1 Comment (org.eclipse.wst.dtd.core.internal.Comment)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 LabelValuePair (org.eclipse.wst.dtd.core.internal.util.LabelValuePair)1